static Mat4 view_matrix, mouse_view_matrix, proj_matrix;
static TextureSet texman;
-static Scene *scn;
+static SceneSet sceneman;
+static MetaScene *mscn;
static unsigned int sdr_post_gamma;
static long prev_msec;
glClearColor(0.2, 0.2, 0.2, 1.0);
- scn = new Scene(&texman);
- if(!load_scene(scn, opt.scenefile ? opt.scenefile : "data/museum.scene")) {
+ mscn = new MetaScene(&sceneman, &texman);
+ if(!mscn->load(opt.scenefile ? opt.scenefile : "data/museum.scene")) {
return false;
}
- // set initial cam_pos above the center of the walk mesh (if any)
- if(scn->walk_mesh) {
- Vec3 bcent;
- float brad;
- scn->walk_mesh->get_bsphere(&bcent, &brad);
-
- floor_y = bcent.y;
- cam_pos = bcent + Vec3(0, user_eye_height, 0);
- }
+ cam_pos = mscn->start_pos;
+ // TODO use start_rot
if(!(sdr_ltmap_notex = create_program_load("sdr/lightmap.v.glsl", "sdr/lightmap-notex.p.glsl"))) {
return false;
if(opt.vr) {
goatvr_shutdown();
}
+
texman.clear();
+ sceneman.clear();
}
static bool constrain_walk_mesh(const Vec3 &v, Vec3 *newv)
{
- Mesh *wm = scn->walk_mesh;
+ Mesh *wm = mscn->walk_mesh;
if(!wm) {
*newv = v;
return true;
Ray downray = Ray(v, Vec3(0, -1, 0));
HitPoint hit;
- if(scn->walk_mesh->intersect(downray, &hit)) {
+ if(mscn->walk_mesh->intersect(downray, &hit)) {
*newv = hit.pos;
newv->y += user_eye_height;
return true;
static void update(float dt)
{
texman.update();
+ sceneman.update();
- scn->update(dt);
+ mscn->update(dt);
float speed = walk_speed * dt;
Vec3 dir;
set_light(1, lpos[1], Vec3(0.6, 0.7, 1.0) * 0.6);
set_light(2, lpos[2], Vec3(0.8, 1.0, 0.8) * 0.3);
- scn->draw();
+ mscn->draw();
- if(show_walk_mesh && scn->walk_mesh) {
+ if(show_walk_mesh && mscn->walk_mesh) {
glPushAttrib(GL_ENABLE_BIT);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glDepthMask(0);
glColor3f(0.3, 0.08, 0.01);
- scn->walk_mesh->draw();
+ mscn->walk_mesh->draw();
glDepthMask(1);