Browse Source

use glm::vec3 in entSetWorldPosition()

testing
cinnaboot 6 years ago
parent
commit
a3312a4c53
  1. 3
      examples/assimp_loading/main.cpp
  2. 3
      include/entity.h
  3. 10
      src/entity.cpp

3
examples/assimp_loading/main.cpp

@ -40,6 +40,7 @@ doRenderLoop(render_state* rs, frame_callback_fn callback_fn)
callback_fn(rs);
// TODO: need to implement new roDraw() and call from renRenderFrame()
renRenderFrame(rs);
SDL_GL_SwapWindow(rs->handles.window);
frameTime = SDL_GetTicks() - frameStart;
@ -66,7 +67,7 @@ main()
entity spaceship = group_1->entities[0];
// TODO: this should be handled in entInit
entSetWorldPosition(spaceship, 0, 0, 0);
entSetWorldPosition(spaceship, glm::vec3(0, 0, 0));
entScale(spaceship, glm::vec3(20, 20, 20));
// TODO: implement setting rotation from entity
//spaceship.rotation = glm::vec4(0, 0, 0, 0);

3
include/entity.h

@ -32,8 +32,7 @@ bool entInit(entity& e, const char* model_path);
void entFree(entity& e);
// TODO: just use glm::vec3 here also
void entSetWorldPosition(entity& e, float x, float y, float z);
void entSetWorldPosition(entity& e, glm::vec3 v);
void entTranslate(entity& e, glm::vec3 v);

10
src/entity.cpp

@ -21,7 +21,7 @@ entInit(entity& e, const char* model_path)
{
e.world_transform = glm::mat4(1.0);
entScale(e, glm::vec3(1.0));
entSetWorldPosition(e, 0, 0, 0);
entSetWorldPosition(e, glm::vec3(0, 0, 0));
if (meLoadFromFile(e.mesh_group, model_path)
&& loadMeshIntoGL(e))
@ -53,11 +53,11 @@ entFree(entity& e)
}
void
entSetWorldPosition(entity& e, float x, float y, float z)
entSetWorldPosition(entity& e, glm::vec3 v)
{
e.world_transform[3][0] = x;
e.world_transform[3][1] = y;
e.world_transform[3][2] = z;
e.world_transform[3][0] = v.x;
e.world_transform[3][1] = v.y;
e.world_transform[3][2] = v.z;
}
void

Loading…
Cancel
Save