projects
/
laserbrain_demo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
picking up exhibits works again with the slot mechanism
[laserbrain_demo]
/
src
/
blob_exhibit.cc
diff --git
a/src/blob_exhibit.cc
b/src/blob_exhibit.cc
index
3d13396
..
c92ac7a
100644
(file)
--- a/
src/blob_exhibit.cc
+++ b/
src/blob_exhibit.cc
@@
-23,6
+23,7
@@
static Metaball def_mball_data[] = {
};
struct BlobPriv {
};
struct BlobPriv {
+ AABox vol;
metasurface *msurf;
Metaball mballs[NUM_MBALLS];
Texture *tex;
metasurface *msurf;
Metaball mballs[NUM_MBALLS];
Texture *tex;
@@
-34,6
+35,7
@@
BlobExhibit::BlobExhibit()
for(int i=0; i<NUM_MBALLS; i++) {
priv->mballs[i] = def_mball_data[i];
}
for(int i=0; i<NUM_MBALLS; i++) {
priv->mballs[i] = def_mball_data[i];
}
+ priv->vol = AABox(Vec3(-3.5, -3.5, -3.5), Vec3(3.5, 3.5, 3.5));
}
BlobExhibit::~BlobExhibit()
}
BlobExhibit::~BlobExhibit()
@@
-49,10
+51,12
@@
bool BlobExhibit::init()
}
msurf_set_threshold(priv->msurf, 8);
msurf_set_inside(priv->msurf, MSURF_GREATER);
}
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");
msurf_enable(priv->msurf, MSURF_NORMALIZE);
priv->tex = texman.get_texture("data/sphmap.jpg");
+
return true;
}
return true;
}
@@
-71,6
+75,10
@@
void BlobExhibit::update(float dt)
float xmin, xmax, ymin, ymax, zmin, zmax;
int xres, yres, zres;
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);
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;
}
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;
float max_energy = 0.0f;
-//#pragma omp parallel for
+#pragma omp parallel for
for(int i=0; i<zres; i++) {
float z = zmin + i * zstep;
float *voxptr = msurf_slice(priv->msurf, i);
for(int i=0; i<zres; i++) {
float z = zmin + i * zstep;
float *voxptr = msurf_slice(priv->msurf, i);
- if(!voxptr) break;
for(int j=0; j<yres; j++) {
float y = ymin + j * ystep;
for(int j=0; j<yres; j++) {
float y = ymin + j * ystep;
@@
-141,25
+144,24
@@
void BlobExhibit::draw() const
glLoadIdentity();
glScalef(1, -1, 1);
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);
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);
glColor3f(1, 1, 1);
- for(int i=0; i<nverts; i++) {
- glNormal3f(narr[0], narr[1], narr[2]);
- glVertex3f(varr[0], varr[1], varr[2]);
- varr += 3;
- narr += 3;
- }
- glEnd();
- glFrontFace(GL_CCW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, varr);
+ glNormalPointer(GL_FLOAT, 0, narr);
+ glDrawArrays(GL_TRIANGLES, 0, nverts);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+
+ /*
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
@@
-177,9
+179,17
@@
void BlobExhibit::draw() const
narr += 3;
}
glEnd();
narr += 3;
}
glEnd();
+ */
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPopAttrib();
}
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPopAttrib();
}
+
+const AABox &BlobExhibit::get_aabox() const
+{
+ Box box = Box(priv->vol, node->get_matrix());
+ calc_bounding_aabox(&aabb, &box);
+ return aabb;
+}