Highlight voxel being touched

This commit is contained in:
Philip Rosedale 2013-12-03 16:52:38 -08:00
parent 8fdd78dc26
commit 423b2e8e0f
2 changed files with 17 additions and 9 deletions

View file

@ -1994,17 +1994,13 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) {
glDisable(GL_LIGHTING);
glPushMatrix();
glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
//printf("Render: %.6f,%.6f,%.6f %.8f\n", voxel.x, voxel.y, voxel.z,
// voxel.s);
const float EDGE_EXPAND = 1.01f;
//glColor3ub(voxel.red + 128, voxel.green + 128, voxel.blue + 128);
glColor3ub(255, 0, 0);
const float EDGE_EXPAND = 1.02f;
glColor3ub(voxel.red + 128, voxel.green + 128, voxel.blue + 128);
glTranslatef(voxel.x + voxel.s * 0.5f,
voxel.y + voxel.s * 0.5f,
voxel.z + voxel.s * 0.5f);
glLineWidth(4.0f);
glutWireCube(_mouseVoxel.s * EDGE_EXPAND);
glLineWidth(2.0f);
glutWireCube(voxel.s * EDGE_EXPAND);
glPopMatrix();
}
@ -3033,7 +3029,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
}
}
// restore default, white specular
glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);

View file

@ -100,11 +100,24 @@ void Hand::simulate(float deltaTime, bool isMine) {
// Collision has just started
palm.setIsCollidingWithVoxel(true);
handleVoxelCollision(&palm, fingerTipPosition, fingerNode, deltaTime);
// Set highlight voxel
VoxelDetail voxel;
glm::vec3 pos = fingerNode->getCorner();
voxel.x = pos.x;
voxel.y = pos.y;
voxel.z = pos.z;
voxel.s = fingerNode->getScale();
voxel.red = fingerNode->getColor()[0];
voxel.green = fingerNode->getColor()[1];
voxel.blue = fingerNode->getColor()[2];
Application::getInstance()->setHighlightVoxel(voxel);
Application::getInstance()->setIsHighlightVoxel(true);
}
} else {
if (palm.getIsCollidingWithVoxel()) {
// Collision has just ended
palm.setIsCollidingWithVoxel(false);
Application::getInstance()->setIsHighlightVoxel(false);
}
}
}