X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fblob_exhibit.cc;h=cd29e9629e4d1ac277473f05003834bf620538ba;hp=3d133961159302e12c92e7a344b348dbc3bac9cd;hb=37b68f014b46922b885c6344d6b069cba3c9c3c5;hpb=b75b6703809abf0dc02f2e557ba73e9efbefa4d1 diff --git a/src/blob_exhibit.cc b/src/blob_exhibit.cc index 3d13396..cd29e96 100644 --- a/src/blob_exhibit.cc +++ b/src/blob_exhibit.cc @@ -23,6 +23,7 @@ static Metaball def_mball_data[] = { }; struct BlobPriv { + AABox vol; metasurface *msurf; Metaball mballs[NUM_MBALLS]; Texture *tex; @@ -34,6 +35,7 @@ BlobExhibit::BlobExhibit() for(int i=0; imballs[i] = def_mball_data[i]; } + priv->vol = AABox(Vec3(-3.5, -3.5, -3.5), Vec3(3.5, 3.5, 3.5)); } BlobExhibit::~BlobExhibit() @@ -49,10 +51,12 @@ bool BlobExhibit::init() } msurf_set_threshold(priv->msurf, 8); msurf_set_inside(priv->msurf, MSURF_GREATER); - msurf_set_bounds(priv->msurf, -3.5, 3.5, -3.5, 3.5, -3.5, 3.5); + msurf_set_bounds(priv->msurf, priv->vol.min.x, priv->vol.min.y, priv->vol.min.z, + priv->vol.max.x, priv->vol.max.y, priv->vol.max.z); msurf_enable(priv->msurf, MSURF_NORMALIZE); priv->tex = texman.get_texture("data/sphmap.jpg"); + return true; } @@ -71,6 +75,10 @@ void BlobExhibit::update(float dt) float xmin, xmax, ymin, ymax, zmin, zmax; int xres, yres, zres; + if(!msurf_voxels(priv->msurf)) { + return; + } + msurf_get_bounds(priv->msurf, &xmin, &ymin, &zmin, &xmax, &ymax, &zmax); msurf_get_resolution(priv->msurf, &xres, &yres, &zres); @@ -85,17 +93,12 @@ void BlobExhibit::update(float dt) priv->mballs[i].pos.z = -cos(t) * priv->mballs[i].path_scale.z + priv->mballs[i].path_offset.z; } - if(!msurf_voxels(priv->msurf)) { - return; - } - float max_energy = 0.0f; -//#pragma omp parallel for +#pragma omp parallel for for(int i=0; imsurf, i); - if(!voxptr) break; for(int j=0; jget_matrix()[0]); + } + glMatrixMode(GL_TEXTURE); glLoadIdentity(); glScalef(1, -1, 1); - glFrontFace(GL_CW); - - int nverts = msurf_vertex_count(priv->msurf); float *varr = msurf_vertices(priv->msurf); float *narr = msurf_normals(priv->msurf); - glBegin(GL_TRIANGLES); glColor3f(1, 1, 1); - for(int i=0; ivol, node ? node->get_matrix() : Mat4::identity); + calc_bounding_aabox(&aabb, &box); + return aabb; +}