getting started on the lights

This commit is contained in:
MitchellHansen
2017-02-02 22:37:27 -08:00
parent 03a7ee43fd
commit 3f0a99a435
8 changed files with 291 additions and 100 deletions

50
include/Light.h Normal file
View 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 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;
};

View File

@@ -4,6 +4,7 @@
#include <Map.h>
#include "Old_Map.h"
#include "Camera.h"
#include "Light.h"
class RayCaster {

View File

@@ -272,26 +272,26 @@ inline std::vector<float> sfml_get_float_input(sf::RenderWindow *window) {
}
struct Light {
sf::Vector4f rgbi;
// I believe that Vector3's get padded to Vector4's. Give them a non-garbage value
sf::Vector3f position;
sf::Vector3f direction_cartesian;
void look_at_center() {
direction_cartesian = SphereToCart(CartToNormalizedSphere(sf::Vector3f(256, 256, 256) - position));
};
void orbit_around_center(double time) {
position = sf::Vector3f(
position.x * cos(time/1000) - position.y * sin(time/1000),
position.x * sin(time/1000) + position.y * cos(time/1000),
position.z
);
look_at_center();
};
};
//struct Light {
// sf::Vector4f rgbi;
//
// // I believe that Vector3's get padded to Vector4's. Give them a non-garbage value
// sf::Vector3f position;
//
// sf::Vector3f direction_cartesian;
//
// void look_at_center() {
// direction_cartesian = SphereToCart(CartToNormalizedSphere(sf::Vector3f(256, 256, 256) - position));
// };
//
// void orbit_around_center(double time) {
// position = sf::Vector3f(
// position.x * cos(time/1000) - position.y * sin(time/1000),
// position.x * sin(time/1000) + position.y * cos(time/1000),
// position.z
// );
//
// look_at_center();
// };
//};