Skip to content

Commit

Permalink
Release 0.6.0: Physics. Added rigidbody physics and discrete collisio…
Browse files Browse the repository at this point in the history
…n detection to the engine (Spheres and Heightmaps). Fixed FPS bug. Fixed opengl pdb not loaded bug.
  • Loading branch information
avilapa committed Mar 31, 2019
1 parent d64d1c2 commit bc88d3d
Show file tree
Hide file tree
Showing 99 changed files with 2,810 additions and 429 deletions.
Binary file modified examples/01-HelloWorld/01-HelloWorld.exe
Binary file not shown.
Binary file modified examples/02-Instancing/02-Instancing.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions examples/02-Instancing/instancing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ namespace vxr
Engine::ref().submitDisplayList(std::move(frame));
}

void Main::update()
void Main::update(float dt)
{
// 15. Update instances position. This operations are performed in the update() instead of the renderUpdate() for them to take into account deltaTime() and be framerate independent.
static float v = 0;
Expand All @@ -190,13 +190,13 @@ namespace vxr
instance_positions_[i] =
{
(i / 500)*1.5f,
750.0f*(float)(sin(i*3.1415 / 10 + v) * deltaTime()),
750.0f*(float)(sin(i*3.1415 / 10 + v) * dt),
(float)(i % 500)*1.5f
};
}
v += 0.01f;

Application::update();
Application::update(dt);
}

void Main::renderUpdate()
Expand Down
2 changes: 1 addition & 1 deletion examples/02-Instancing/instancing.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace vxr

public:
virtual void start() override;
virtual void update() override;
virtual void update(float dt) override;
virtual void renderUpdate() override;
virtual void stop() override;

Expand Down
Binary file modified examples/03-Framebuffers/03-Framebuffers.exe
Binary file not shown.
12 changes: 6 additions & 6 deletions examples/03-Framebuffers/framebuffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,13 @@ namespace vxr
Application::start();
}

void Main::update()
void Main::update(float dt)
{
// 6. Update the contrast settings with the deltaTime().
static double v = 0.0;
v += 0.003;
u_state_contrast_.brightness = sin(u_state_contrast_.brightness * 50.0f * deltaTime() + v) + 2.0f * 0.2f;
u_state_contrast_.contrast = sin(u_state_contrast_.contrast * 21.0f * deltaTime() + v) + 1.5f;
u_state_contrast_.brightness = sin(u_state_contrast_.brightness * 50.0f * dt + v) + 2.0f * 0.2f;
u_state_contrast_.contrast = sin(u_state_contrast_.contrast * 21.0f * dt + v) + 1.5f;

// 7. Update the cubes model matrix by applying rotation.
for (uint32 x = 0; x < kNUM_CUBES_ROW; ++x)
Expand All @@ -253,14 +253,14 @@ namespace vxr
uint32 i = x * kNUM_CUBES_ROW + y;

mat4 model = u_state_stream_[i].model;
mat4 rot_x = glm::rotate((x + 1) * 0.21f * deltaTime(), glm::vec3(1.0f, 0.0f, 0.0f));
mat4 rot_y = glm::rotate((y + 1) * 0.37f * deltaTime(), glm::vec3(0.0f, 1.0f, 0.0f));
mat4 rot_x = glm::rotate((x + 1) * 0.21f * dt, glm::vec3(1.0f, 0.0f, 0.0f));
mat4 rot_y = glm::rotate((y + 1) * 0.37f * dt, glm::vec3(0.0f, 1.0f, 0.0f));

u_state_stream_[i].model = model * rot_x * rot_y;
}
}

Application::update();
Application::update(dt);
}

void Main::renderUpdate()
Expand Down
2 changes: 1 addition & 1 deletion examples/03-Framebuffers/framebuffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace vxr

public:
virtual void start() override;
virtual void update() override;
virtual void update(float dt) override;
virtual void renderUpdate() override;
virtual void stop() override;

Expand Down
Binary file modified examples/04-Mesh/04-Mesh.exe
Binary file not shown.
18 changes: 9 additions & 9 deletions examples/04-Mesh/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,25 @@ namespace vxr
Application::start();
}

void Main::update()
void Main::update(float dt)
{
// 9. Rotate the meshes in update() instead of renderUpdate() to make the transformations framerate
// independent by multiplying it by deltaTime().The update() method may be executed several times in
// a frame to catch up with the render thread.
float t = Engine::ref().window()->uptime();

teapot_->transform()->rotateX(30.0f * deltaTime());
teapot_->transform()->rotateZ(25.0f * deltaTime());
teapot_->transform()->set_world_position(vec3(-2, cos(t) * 100 * deltaTime(), 0));
teapot_->transform()->rotateX(30.0f * dt);
teapot_->transform()->rotateZ(25.0f * dt);
teapot_->transform()->set_world_position(vec3(-2, cos(t) * 100 * dt, 0));

suzanne_->transform()->rotate(vec3(-15.0f, 10.0f, -5.0f) * deltaTime());
suzanne_->transform()->set_world_position(vec3(2, sin(t) * 100 * deltaTime(), 0));
suzanne_->transform()->rotate(vec3(-15.0f, 10.0f, -5.0f) * dt);
suzanne_->transform()->set_world_position(vec3(2, sin(t) * 100 * dt, 0));

sphere_->transform()->set_local_scale(vec3(sin(t) * 100 * deltaTime() * 0.5f + 1.0f));
sphere_->transform()->set_local_scale(vec3(sin(t) * 100 * dt * 0.5f + 1.0f));

cam_->transform()->rotateAround(sphere_, vec3(0,10,0) * deltaTime());
cam_->transform()->rotateAround(sphere_, vec3(0,10,0) * dt);

Application::update();
Application::update(dt);
}

} /* end of vxr namespace */
2 changes: 1 addition & 1 deletion examples/04-Mesh/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace vxr
Main();

virtual void start() override;
virtual void update() override;
virtual void update(float dt) override;

private:
ref_ptr<GameObject> cam_;
Expand Down
Binary file modified examples/05-Materials/05-Materials.exe
Binary file not shown.
Binary file modified examples/06-Procedural/06-Procedural.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/06-Procedural/imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ Collapsed=0

[Window][VXR]
Pos=0,0
Size=1920,1017
Size=1280,720
Collapsed=0

12 changes: 6 additions & 6 deletions examples/06-Procedural/procedural.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,33 +76,33 @@ namespace vxr
Application::start();
}

void Main::update()
void Main::update(float dt)
{
// 7. Interpolate camera position
float speed = 5.0f;
static bool first_zoom = true;
if (planet_->getComponent<Planet>()->zoom)
{
first_zoom = true;
cam_->transform()->set_local_position(Math::lerp(cam_->transform()->local_position(), zoom_on, speed * deltaTime()));
cam_->transform()->set_local_rotation(Math::lerp(cam_->transform()->local_rotation_angles(), vec3(0.0f), speed * deltaTime()));
cam_->transform()->set_local_position(Math::lerp(cam_->transform()->local_position(), zoom_on, speed * dt));
cam_->transform()->set_local_rotation(Math::lerp(cam_->transform()->local_rotation_angles(), vec3(0.0f), speed * dt));
}
else
{
if (first_zoom)
{
cam_->transform()->set_local_position(Math::lerp(cam_->transform()->local_position(), zoom_off, speed * deltaTime()));
cam_->transform()->set_local_position(Math::lerp(cam_->transform()->local_position(), zoom_off, speed * dt));
if (glm::epsilonEqual(cam_->transform()->local_position(), zoom_off, 0.001f) == bvec3(true))
{
first_zoom = false;
}
}
else
{
cam_->transform()->rotateAround(planet_, vec3(0.1f, 0.2f, -0.2f) * deltaTime());
cam_->transform()->rotateAround(planet_, vec3(0.1f, 0.2f, -0.2f) * dt);
}
}
Application::update();
Application::update(dt);
}

} /* end of vxr namespace */
2 changes: 1 addition & 1 deletion examples/06-Procedural/procedural.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace vxr
Main();

virtual void start() override;
virtual void update() override;
virtual void update(float dt) override;

private:
ref_ptr<GameObject> cam_;
Expand Down
Binary file added examples/07-Physics/07-Physics.exe
Binary file not shown.
Binary file added examples/07-Physics/assets/circle.bmp
Binary file not shown.
Binary file added examples/07-Physics/assets/diagonal.bmp
Binary file not shown.
Binary file added examples/07-Physics/assets/fall.bmp
Binary file not shown.
Binary file added examples/07-Physics/assets/heightmap.bmp
Binary file not shown.
Binary file added examples/07-Physics/assets/plane.bmp
Binary file not shown.
20 changes: 20 additions & 0 deletions examples/07-Physics/imgui.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0

[Window][Scene Selector]
Pos=60,60
Size=442,71
Collapsed=0

[Window][Material Editor]
Pos=60,60
Size=190,422
Collapsed=0

[Window][VXR]
Pos=0,0
Size=1280,720
Collapsed=0

Loading

0 comments on commit bc88d3d

Please sign in to comment.