Hooked up the phone controller to the light and added a demo video at 1440x900
This commit is contained in:
@@ -8,6 +8,6 @@ Featuring...
|
||||
* Shadowing
|
||||
* Textures
|
||||
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <util.hpp>
|
||||
#include <memory>
|
||||
#include "Pub_Sub.h"
|
||||
|
||||
|
||||
// Light Handle :
|
||||
@@ -31,7 +32,7 @@ struct LightPrototype;
|
||||
class LightController;
|
||||
struct PackedData;
|
||||
|
||||
class LightHandle {
|
||||
class LightHandle : public VrEventSubscriber{
|
||||
|
||||
public:
|
||||
|
||||
@@ -51,7 +52,10 @@ public:
|
||||
void set_direction(sf::Vector3f direction);
|
||||
void set_rgbi(sf::Vector4f rgbi);
|
||||
|
||||
// void update(double delta_time);
|
||||
|
||||
virtual void recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) override;
|
||||
|
||||
void update(double delta_time);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ void Camera::set_camera(sf::Vector3f input) {
|
||||
|
||||
int Camera::update(double delta_time) {
|
||||
|
||||
double multiplier = 40;
|
||||
double multiplier = 80;
|
||||
|
||||
position.x += static_cast<float>(movement.x * delta_time * multiplier);
|
||||
position.y += static_cast<float>(movement.y * delta_time * multiplier);
|
||||
|
||||
@@ -63,3 +63,35 @@ void LightHandle::set_rgbi(sf::Vector4f rgbi)
|
||||
|
||||
}
|
||||
|
||||
void LightHandle::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event)
|
||||
{
|
||||
if (event->type == vr::Event::JoystickMoved) {
|
||||
|
||||
vr::JoystickMoved *joystick_event = static_cast<vr::JoystickMoved*>(event.get());
|
||||
|
||||
if (joystick_event->axis == sf::Joystick::Axis::X) {
|
||||
movement.x = -joystick_event->position / 5;
|
||||
//add_relative_impulse(Camera::DIRECTION::FORWARD, joystick_event->position);
|
||||
}
|
||||
else if (joystick_event->axis == sf::Joystick::Axis::Y) {
|
||||
movement.y = joystick_event->position / 5;
|
||||
//add_relative_impulse(Camera::DIRECTION::RIGHT, joystick_event->position);
|
||||
}
|
||||
//else if (joystick_event->axis == sf::Joystick::Axis::Z) {
|
||||
// add_relative_impulse(Camera::DIRECTION::DOWN, joystick_event->position);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
void LightHandle::update(double delta_time) {
|
||||
|
||||
double multiplier = 40;
|
||||
|
||||
data_reference->position.x += static_cast<float>(movement.x * delta_time * multiplier);
|
||||
data_reference->position.y += static_cast<float>(movement.y * delta_time * multiplier);
|
||||
data_reference->position.z += static_cast<float>(movement.z * delta_time * multiplier);
|
||||
|
||||
//movement *= static_cast<float>(friction_coefficient * delta_time * multiplier);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ void NetworkInput::threaded_client_listener(int port) {
|
||||
event_queue.push_back(std::make_unique<vr::JoystickMoved>(vr::JoystickMoved(sf::Joystick::Axis::Y, 0, y)));
|
||||
event_queue.push_back(std::make_unique<vr::JoystickMoved>(vr::JoystickMoved(sf::Joystick::Axis::Z, 0, z)));
|
||||
|
||||
std::cout << "X: " << x << " Y: " << y << " Z: " << z << std::endl;
|
||||
//std::cout << "X: " << x << " Y: " << y << " Z: " << z << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,17 @@ void Old_Map::generate_terrain() {
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 100; x < 150; x += 10) {
|
||||
for (int y = 100; y < 150; y += 10) {
|
||||
for (int z = 0; z < 10; z += 1) {
|
||||
|
||||
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 5;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int x = 0; x < dimensions.x; x++) {
|
||||
for (int y = 0; y < dimensions.y; y++) {
|
||||
|
||||
14
src/main.cpp
14
src/main.cpp
@@ -39,8 +39,8 @@
|
||||
#include "LightController.h"
|
||||
#include "LightHandle.h"
|
||||
|
||||
const int WINDOW_X = 1000;
|
||||
const int WINDOW_Y = 1000;
|
||||
const int WINDOW_X = 1440;
|
||||
const int WINDOW_Y = 900;
|
||||
const int WORK_SIZE = WINDOW_X * WINDOW_Y;
|
||||
|
||||
const int MAP_X = 256;
|
||||
@@ -114,13 +114,11 @@ int main() {
|
||||
&window
|
||||
);
|
||||
|
||||
|
||||
|
||||
// *link* the camera to the GPU
|
||||
raycaster->assign_camera(camera);
|
||||
|
||||
// Generate and send the viewport to the GPU. Also creates the viewport texture
|
||||
raycaster->create_viewport(WINDOW_X, WINDOW_Y, 50.0f, 50.0f);
|
||||
raycaster->create_viewport(WINDOW_X, WINDOW_Y, 0.625f * 90.0f, 90.0f);
|
||||
|
||||
float w = 60.0;
|
||||
float h = 90.0;
|
||||
@@ -128,7 +126,7 @@ int main() {
|
||||
|
||||
LightController light_controller(raycaster);
|
||||
LightPrototype prototype(
|
||||
sf::Vector3f(256.0f, 256.0f, 256.0f),
|
||||
sf::Vector3f(100.0f, 100.0f, 30.0f),
|
||||
sf::Vector3f(-1.0f, -1.0f, -1.5f),
|
||||
sf::Vector4f(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
);
|
||||
@@ -183,6 +181,7 @@ int main() {
|
||||
camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::KeyPressed);
|
||||
camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::MouseMoved);
|
||||
//camera->subscribe_to_publisher(&ni, vr::Event::EventType::JoystickMoved);
|
||||
handle->subscribe_to_publisher(&ni, vr::Event::EventType::JoystickMoved);
|
||||
|
||||
WindowHandler win_hand(&window);
|
||||
win_hand.subscribe_to_publisher(&input_handler, vr::Event::EventType::Closed);
|
||||
@@ -194,7 +193,7 @@ int main() {
|
||||
input_handler.consume_sf_events(&window);
|
||||
input_handler.handle_held_keys();
|
||||
input_handler.dispatch_events();
|
||||
//ni.dispatch_events();
|
||||
ni.dispatch_events();
|
||||
|
||||
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::F11)) {
|
||||
@@ -257,6 +256,7 @@ int main() {
|
||||
|
||||
// ==== FPS LOCKED ====
|
||||
camera->update(delta_time);
|
||||
handle->update(delta_time);
|
||||
|
||||
window.clear(sf::Color::Black);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user