Browse Source

get assimp_loading example working

testing
cinnaboot 6 years ago
parent
commit
a42ff1bb9b
  1. 30
      examples/assimp_loading/main.cpp
  2. BIN
      examples/data/spaceship.glb

30
examples/assimp_loading/main.cpp

@ -50,8 +50,8 @@ doRenderLoop(render_state* rs, frame_callback_fn callback_fn, Entity* entities,
int
main()
{
// TODO: would be nice to be able to pass in viewport_dims, window title here
render_state* rs = renInit();
meInitAssimp();
// TODO: entInit() doesn't allocate memory because we want to do the allocation in
@ -60,21 +60,27 @@ main()
// TODO: this should be handled in entInit
entSetWorldPosition(spaceship, 0, 0, 0);
// set entity scale, rotation, world_transform to defaults :( ...
// need to finish loading binary texture data in mesh::loadDiffuseTexture()
spaceship.scale = glm::vec3(20, 20, 20);
spaceship.rotation = glm::vec4(0, 0, 0, 0);
// setup camera
glm::vec3 cam_pos(0, -100, 100);
cameraInitPerspective(rs->cam, cam_pos, spaceship.translation, rs->cam.world_up);
if (entInit(spaceship, "../data/spaceship.glb", rs->default_shader)) {
cameraInitPerspective(
rs->cam,
glm::vec3(200, -150, 150),
spaceship.translation,
glm::vec3(0,0,1)
);
// TODO: renderer::setDefaults() allocates 10 lights based on a MACRO in renderer.cpp
// probably need an interface to add more than that
// add a light
rs->num_lights = 1;
rs->lights[0].position = glm::vec3(200, -150, 150);
if (entInit(spaceship, "../data/spaceship.glb", rs->default_shader))
doRenderLoop(rs, doFrameCallback, &spaceship, 1);
} else {
else
LOG(Error) << "Error initializing entity, exiting\n";
}
// TODO: way more cleanup to do :(, see hexgame::cleanUp()
meShutdownAssimp();

BIN
examples/data/spaceship.glb (Stored with Git LFS)

Binary file not shown.
Loading…
Cancel
Save