nuclear@2: #include nuclear@2: #include "opengl.h" nuclear@2: #include "room.h" nuclear@2: #include "game.h" nuclear@2: #include "object.h" nuclear@2: #include "scene.h" nuclear@2: #include "meshgen.h" nuclear@6: #include "revol.h" nuclear@2: nuclear@2: static Scene scn; nuclear@2: nuclear@6: static const vec2_t pillar_cp[] = { nuclear@6: {0.8, 10}, nuclear@6: {1.2, 5.5}, nuclear@6: {1, 0} nuclear@6: }; nuclear@6: static const BezCurve pillar_curve = { nuclear@6: sizeof pillar_cp / sizeof *pillar_cp, nuclear@6: (vec2_t*)pillar_cp, 1.0 nuclear@6: }; nuclear@6: nuclear@2: bool init_room() nuclear@2: { nuclear@2: Matrix4x4 xform; nuclear@2: nuclear@2: // generate room nuclear@2: Mesh *mroom = new Mesh; nuclear@6: gen_box(mroom, ROOM_WIDTH, ROOM_HEIGHT, ROOM_LENGTH); nuclear@6: xform.set_translation(Vector3(0, ROOM_HEIGHT / 2.0, 0)); nuclear@2: mroom->apply_xform(xform); nuclear@2: mroom->flip(); nuclear@2: nuclear@2: Object *oroom = new Object; nuclear@2: oroom->set_mesh(mroom); nuclear@6: oroom->mtl.diffuse = Vector3(0.5, 0.5, 0.5); nuclear@2: oroom->rop.cast_shadows = false; nuclear@6: scn.add_object(oroom); nuclear@2: nuclear@6: for(int i=0; i<8; i++) { nuclear@6: float x = (i < 4 ? -1.0 : 1.0) * ROOM_WIDTH * 0.3; nuclear@6: float z = (float)(i % 4) * 12.5 - 12.5; nuclear@6: nuclear@6: Mesh *mpillar = new Mesh; nuclear@6: gen_revol(mpillar, 16, 3, bezier_revol, bezier_revol_normal, (void*)&pillar_curve); nuclear@6: nuclear@6: Mesh mtorus; nuclear@6: gen_torus(&mtorus, 1.0, 0.25, 16, 8); nuclear@6: Matrix4x4 xform; nuclear@6: xform.set_translation(Vector3(0, 0.1, 0)); nuclear@6: mtorus.apply_xform(xform, Matrix4x4::identity); nuclear@6: mpillar->append(mtorus); nuclear@6: nuclear@6: mpillar->texcoord_gen_cylinder(); nuclear@6: nuclear@6: Object *opillar = new Object; nuclear@6: opillar->set_mesh(mpillar); nuclear@6: opillar->mtl.diffuse = Vector3(0.6, 0.6, 0.6); nuclear@6: opillar->xform().set_translation(Vector3(x, 0.0, z)); nuclear@6: nuclear@6: scn.add_object(opillar); nuclear@6: } nuclear@2: return true; nuclear@2: } nuclear@2: nuclear@2: void cleanup_room() nuclear@2: { nuclear@2: scn.clear(); nuclear@2: } nuclear@2: nuclear@2: void draw_room() nuclear@2: { nuclear@2: scn.draw(); nuclear@2: }