dbf_amiga
diff src/room.cc @ 0:87dfe0e10235
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 31 Aug 2015 07:38:37 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/room.cc Mon Aug 31 07:38:37 2015 +0300 1.3 @@ -0,0 +1,73 @@ 1.4 +#include <stdio.h> 1.5 +#include "opengl.h" 1.6 +#include "room.h" 1.7 +#include "game.h" 1.8 +#include "object.h" 1.9 +#include "scene.h" 1.10 +#include "meshgen.h" 1.11 +#include "revol.h" 1.12 + 1.13 +static Scene scn; 1.14 + 1.15 +static const vec2_t pillar_cp[] = { 1.16 + {0.8, 10}, 1.17 + {1.2, 5.5}, 1.18 + {1, 0} 1.19 +}; 1.20 +static const BezCurve pillar_curve = { 1.21 + sizeof pillar_cp / sizeof *pillar_cp, 1.22 + (vec2_t*)pillar_cp, 1.0 1.23 +}; 1.24 + 1.25 +bool init_room() 1.26 +{ 1.27 + Matrix4x4 xform; 1.28 + 1.29 + // generate room 1.30 + Mesh *mroom = new Mesh; 1.31 + gen_box(mroom, ROOM_WIDTH, ROOM_HEIGHT, ROOM_LENGTH); 1.32 + xform.set_translation(Vector3(0, ROOM_HEIGHT / 2.0, 0)); 1.33 + mroom->apply_xform(xform); 1.34 + mroom->flip(); 1.35 + 1.36 + Object *oroom = new Object; 1.37 + oroom->set_mesh(mroom); 1.38 + oroom->mtl.diffuse = Vector3(0.5, 0.5, 0.5); 1.39 + oroom->rop.cast_shadows = false; 1.40 + scn.add_object(oroom); 1.41 + 1.42 + for(int i=0; i<8; i++) { 1.43 + float x = (i < 4 ? -1.0 : 1.0) * ROOM_WIDTH * 0.3; 1.44 + float z = (float)(i % 4) * 12.5 - 12.5; 1.45 + 1.46 + Mesh *mpillar = new Mesh; 1.47 + gen_revol(mpillar, 16, 3, bezier_revol, bezier_revol_normal, (void*)&pillar_curve); 1.48 + 1.49 + Mesh mtorus; 1.50 + gen_torus(&mtorus, 1.0, 0.25, 16, 8); 1.51 + Matrix4x4 xform; 1.52 + xform.set_translation(Vector3(0, 0.1, 0)); 1.53 + mtorus.apply_xform(xform, Matrix4x4::identity); 1.54 + mpillar->append(mtorus); 1.55 + 1.56 + mpillar->texcoord_gen_cylinder(); 1.57 + 1.58 + Object *opillar = new Object; 1.59 + opillar->set_mesh(mpillar); 1.60 + opillar->mtl.diffuse = Vector3(0.6, 0.6, 0.6); 1.61 + opillar->xform().set_translation(Vector3(x, 0.0, z)); 1.62 + 1.63 + scn.add_object(opillar); 1.64 + } 1.65 + return true; 1.66 +} 1.67 + 1.68 +void cleanup_room() 1.69 +{ 1.70 + scn.clear(); 1.71 +} 1.72 + 1.73 +void draw_room() 1.74 +{ 1.75 + scn.draw(); 1.76 +}