Working more on the lights. Trying to get around the packing requirements for passing data to CL
This commit is contained in:
@@ -50,7 +50,8 @@ public:
|
||||
// Both will create the view matrix, view res buffer
|
||||
void create_viewport(int width, int height, float v_fov, float h_fov) override;
|
||||
|
||||
void assign_lights(std::vector<Light> *lights) override;
|
||||
void assign_lights(std::vector<LightController> *lights) override;
|
||||
void assign_lights();
|
||||
void assign_map(Old_Map *map) override;
|
||||
void assign_camera(Camera *camera) override;
|
||||
void validate() override;
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#pragma once
|
||||
#include <SFML/System/Vector3.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include "util.hpp"
|
||||
#include "Pub_Sub.h"
|
||||
|
||||
class Light : public VrEventSubscriber {
|
||||
public:
|
||||
|
||||
enum DIRECTION { FORWARD, REARWARD, LEFT, RIGHT, UP, DOWN };
|
||||
|
||||
Light();
|
||||
Light(sf::Vector3f position, sf::Vector3f direction);
|
||||
~Light();
|
||||
|
||||
int set_position(sf::Vector3f position);
|
||||
|
||||
int add_static_impulse(sf::Vector3f impulse);
|
||||
int add_relative_impulse(DIRECTION direction, float speed);
|
||||
|
||||
int slew_camera(sf::Vector3f input);
|
||||
void set_camera(sf::Vector3f input);
|
||||
|
||||
int update(double delta_time);
|
||||
|
||||
void look_at_center();
|
||||
|
||||
sf::Vector3f* get_direction_pointer();
|
||||
sf::Vector3f* get_position_pointer();
|
||||
sf::Vector3f* get_movement_pointer();
|
||||
|
||||
sf::Vector3f get_movement();
|
||||
sf::Vector3f get_position();
|
||||
sf::Vector3f get_direction();
|
||||
|
||||
|
||||
void recieve_event(VrEventPublisher* p, std::unique_ptr<vr::Event> event) override;
|
||||
|
||||
private:
|
||||
|
||||
// XYZ
|
||||
sf::Vector3f position;
|
||||
|
||||
sf::Vector3f direction_cartesian;
|
||||
|
||||
sf::Vector4f rgbi;
|
||||
|
||||
|
||||
};
|
||||
|
||||
50
include/LightController.h
Normal file
50
include/LightController.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include <SFML/System/Vector3.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include "util.hpp"
|
||||
#include "Pub_Sub.h"
|
||||
|
||||
class LightController : public VrEventSubscriber {
|
||||
public:
|
||||
|
||||
enum DIRECTION { FORWARD, REARWARD, LEFT, RIGHT, UP, DOWN };
|
||||
|
||||
struct Light {
|
||||
Light(sf::Vector3f position, sf::Vector3f direction_cartesian, sf::Vector4f rgbi) :
|
||||
position(position), direction_cartesian(direction_cartesian), rgbi(rgbi) {
|
||||
}
|
||||
Light();
|
||||
sf::Vector3f position;
|
||||
sf::Vector3f direction_cartesian;
|
||||
sf::Vector4f rgbi;
|
||||
};
|
||||
|
||||
LightController();
|
||||
LightController(sf::Vector3f position, sf::Vector3f direction, sf::Vector4f rgbi);
|
||||
~LightController();
|
||||
|
||||
void set_position(sf::Vector3f position);
|
||||
|
||||
int add_static_impulse(sf::Vector3f impulse);
|
||||
int add_relative_impulse(DIRECTION direction, float speed);
|
||||
|
||||
int update(double delta_time);
|
||||
|
||||
void look_at_center();
|
||||
|
||||
void recieve_event(VrEventPublisher* p, std::unique_ptr<vr::Event> event) override;
|
||||
|
||||
static void erase_light();
|
||||
std::vector<LightController::Light>* get_lights();
|
||||
private:
|
||||
|
||||
// Need to allow N byte light class to be packed into 10 byte packets
|
||||
int packed_size = sizeof(Light);
|
||||
|
||||
// Index that this light is in the packed data
|
||||
int packed_index;
|
||||
|
||||
std::vector<LightController::Light> packed_data;
|
||||
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <Map.h>
|
||||
#include "Old_Map.h"
|
||||
#include "Camera.h"
|
||||
#include "Light.h"
|
||||
#include "LightController.h"
|
||||
|
||||
|
||||
class RayCaster {
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
virtual void assign_map(Old_Map *map) = 0;
|
||||
virtual void assign_camera(Camera *camera) = 0;
|
||||
virtual void create_viewport(int width, int height, float v_fov, float h_fov) = 0;
|
||||
virtual void assign_lights(std::vector<Light> *lights) = 0;
|
||||
virtual void assign_lights(std::vector<LightController> *lights) = 0;
|
||||
virtual void validate() = 0;
|
||||
|
||||
// draw will abstract the gl sharing and software rendering
|
||||
@@ -40,7 +40,7 @@ protected:
|
||||
|
||||
Old_Map * map = nullptr;
|
||||
Camera *camera = nullptr;
|
||||
std::vector<Light> *lights;
|
||||
std::vector<LightController::Light> *lights;
|
||||
int light_count = 0;
|
||||
sf::Uint8 *viewport_image = nullptr;
|
||||
sf::Vector4f *viewport_matrix = nullptr;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define GAME_RENDERER_H
|
||||
|
||||
#include "SFML/Graphics.hpp"
|
||||
#include "CL_Wrapper.h"
|
||||
|
||||
#include "Camera.h"
|
||||
#include "Old_Map.h"
|
||||
#include "RayCaster.h"
|
||||
@@ -35,14 +35,13 @@ public:
|
||||
void register_map(Old_Map* map);
|
||||
void register_lights();
|
||||
void create_viewport(float v_fov, float h_fov, int height, int width);
|
||||
void register_light(Light l);
|
||||
void register_light(LightController l);
|
||||
|
||||
void draw();
|
||||
sf::RenderWindow* get_window();
|
||||
|
||||
private:
|
||||
|
||||
CL_Wrapper *cl;
|
||||
RayCaster *rc;
|
||||
|
||||
bool sharing_supported = false;
|
||||
@@ -51,7 +50,7 @@ private:
|
||||
sf::Uint8 *drawing_surface;
|
||||
sf::RenderWindow* window;
|
||||
|
||||
std::vector<Light> lights;
|
||||
std::vector<LightController> lights;
|
||||
Old_Map* map;
|
||||
Camera* camera;
|
||||
sf::Uint8 *view_matrix;
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
// Both will create the view matrix, view res buffer
|
||||
void create_viewport(int width, int height, float v_fov, float h_fov) override;
|
||||
|
||||
void assign_lights(std::vector<Light> *lights) override;
|
||||
void assign_lights(std::vector<LightController> *lights) override;
|
||||
void assign_map(Old_Map *map) override;
|
||||
void assign_camera(Camera *camera) override;
|
||||
void validate() override;
|
||||
|
||||
Reference in New Issue
Block a user