Browse Source

test an entity with multiple meshes

main
cinnaboot 4 years ago
parent
commit
b790990109
  1. 2
      .gitattributes
  2. BIN
      data/spaceship.bin
  3. BIN
      data/spaceship.gltf
  4. 39
      src/main.cpp
  5. 6
      src/tangerine.h

2
.gitattributes vendored

@ -2,3 +2,5 @@ data/ filter=lfs diff=lfs merge=lfs -text
data/textured_cube.bin filter=lfs diff=lfs merge=lfs -text
data/textured_cube.gltf filter=lfs diff=lfs merge=lfs -text
data/Color[[:space:]]Palette[[:space:]]140.png filter=lfs diff=lfs merge=lfs -text
data/spaceship.gltf filter=lfs diff=lfs merge=lfs -text
data/spaceship.bin filter=lfs diff=lfs merge=lfs -text

BIN
data/spaceship.bin (Stored with Git LFS)

Binary file not shown.

BIN
data/spaceship.gltf (Stored with Git LFS)

Binary file not shown.

39
src/main.cpp

@ -55,6 +55,39 @@ loadLights(RenderState* rs)
return true;
}
bool
loadSpaceShip(RenderState* rs)
{
Model* ship = getModelByPath(&rs->assets, "../data/spaceship.gltf");
if (!ship)
return false;
ShaderProgram* shader_lit = getShaderByName("full_lighting", rs->gl_ctx);
if (!shader_lit)
return false;
// load model into gl
RenderGroup* rg = getFreeRenderGroup(rs);
assert(rs);
initRenderGroup(rg, rs->rg_arena, shader_lit, 256, "ships");
Entity* e = getFreeEntity(rg);
assert(e);
if (initEntity(e, rs->gl_ctx,
rs->rg_arena,
ship,
shader_lit->num_vertex_attribs,
shader_lit->attrib_mappings,
"ship 01"))
{
setEntityPosition(e, glm::vec3(0, -10, -15));
} else {
return false;
}
return true;
}
bool
loadScene(RenderState* rs)
{
@ -107,6 +140,12 @@ loadScene(RenderState* rs)
scaleEntity(e, 3);
}
// NOTE: testing an entity with multiple meshes
#if 0
if (!loadSpaceShip(rs))
return false;
#endif
// NOTE: initilize the 'camera'
glm::vec3 cam_pos = { 0, 15, 40 };
glm::vec3 look_pos = { 0, 0, 0 };

6
src/tangerine.h

@ -15,9 +15,6 @@
/*
* === TODO: ===
* - add scene abstrastion for RenderState
* - test complex entities
* - need a separate GLBufferToAttribMapping for each mesh on an entity
* - maybe fixed now with MeshBufferType enum and getMeshData()
* - add an example of dynamically switching shaders for an entity
* - fix debug load times (either by using cgltf, or hiding tinygltf.h)
* - RenderGroups and Entities need to come into and out of existence during
@ -57,6 +54,9 @@
* - remove hard-coded values in full_lighting.frag
* - test buffer backed lights, probably need to pad any scalars/vec3s
* - add point light type with tweakable attenuation parameters
* - test complex entities
* - need a separate GLBufferToAttribMapping for each mesh on an entity
* - maybe fixed now with MeshBufferType enum and getMeshData()
*/

Loading…
Cancel
Save