added cylinder support in ColladaDemo, rendering of Cylinder, updated .dae files.

This commit is contained in:
ejcoumans
2006-06-09 00:17:20 +00:00
parent bff230b23c
commit b4df21acb5
5 changed files with 10620 additions and 2324 deletions

View File

@@ -19,6 +19,7 @@ subject to the following restrictions:
//#include "GL_LineSegmentShape.h"
#include "CollisionShapes/BoxShape.h"
#include "CollisionShapes/SphereShape.h"
#include "CollisionShapes/CylinderShape.h"
#include "CollisionShapes/ConeShape.h"
#include "CollisionShapes/ConvexHullShape.h"
@@ -45,7 +46,7 @@ extern int gForwardAxis;
#include "GLDebugDrawer.h"
//either FCollada or Collada-dom
//either FCollada or COLLADA_DOM
#define USE_FCOLLADA 1
#ifdef USE_FCOLLADA
@@ -681,6 +682,9 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode)
FCDPASCylinder* cylinder = (FCDPASCylinder*)analGeom;
printf("Cylinder\n");
//Blender exports Z cylinders
//collisionShape = new CylinderShapeZ(SimdVector3(cylinder->radius,cylinder->radius,cylinder->height));
collisionShape = new CylinderShape(SimdVector3(cylinder->radius,cylinder->height,cylinder->radius));
break;
@@ -718,7 +722,15 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode)
//FIXME: only using the first radius of the cylinder
FCDPASTaperedCylinder* tcylinder = (FCDPASTaperedCylinder*)analGeom;
printf("TaperedCylinder\n");
printf("TaperedCylinder, creating a cone for now\n");
if (!tcylinder->height)
{
printf("tapered_cylinder with height 0.0\n");
tcylinder->height = 1.f;
}
//either use radius1 or radius2 for now
collisionShape = new ConeShape(tcylinder->radius,tcylinder->height);
break;
}
@@ -1131,6 +1143,8 @@ void renderme()
float yIncr = -2.f;
SimdVector3 offset(xOffset,0,0);
SimdVector3 up = gCameraUp;
char buf[124];
glColor3f(0, 0, 0);
@@ -1163,39 +1177,54 @@ void renderme()
sprintf(buf,"mouse to interact");
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
SimdVector3 textPos = offset + up*yStart;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"space to reset");
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"cursor keys and z,x to navigate");
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart ;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"i to toggle simulation, s single step");
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart ;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"q to quit");
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart ;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"d to toggle deactivation");
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart ;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"a to draw temporal AABBs");
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart ;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"h to toggle help text");
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
@@ -1204,22 +1233,31 @@ void renderme()
bool useCCD = (getDebugMode() & IDebugDraw::DBG_EnableCCD);
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart ;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"m Bullet GJK = %i",!isSatEnabled);
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart ;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"n Bullet LCP = %i",useBulletLCP);
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart ;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"1 CCD mode (adhoc) = %i",useCCD);
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
textPos = offset + up*yStart ;
glRasterPos3f(textPos.getX(),textPos.getY(),textPos.getZ());
sprintf(buf,"+- shooting speed = %10.2f",bulletSpeed);
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
yStart += yIncr;
@@ -1232,8 +1270,6 @@ void clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
physicsEnvironmentPtr->proceedDeltaTime(0.f,deltaTime);
renderme();

View File

@@ -145,6 +145,8 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim
const ConeShape* coneShape = static_cast<const ConeShape*>(shape);
float radius = coneShape->GetRadius();//+coneShape->GetMargin();
float height = coneShape->GetHeight();//+coneShape->GetMargin();
//glRotatef(-90.0, 1.0, 0.0, 0.0);
glTranslatef(0.0, 0.0, -0.5*height);
glutSolidCone(radius,height,10,10);
useWireframeFallback = false;
break;
@@ -159,6 +161,45 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim
case CONVEX_SHAPE_PROXYTYPE:
case CYLINDER_SHAPE_PROXYTYPE:
{
const CylinderShape* cylinder = static_cast<const CylinderShape*>(shape);
int upAxis = cylinder->GetUpAxis();
GLUquadricObj *quadObj = gluNewQuadric();
glPushMatrix();
switch (upAxis)
{
case 0:
glRotatef(-90.0, 0.0, 1.0, 0.0);
glTranslatef(0.0, 0.0, -1.0);
break;
case 1:
glRotatef(-90.0, 1.0, 0.0, 0.0);
glTranslatef(0.0, 0.0, -1.0);
break;
case 2:
glTranslatef(0.0, 0.0, -1.0);
break;
default:
{
assert(0);
}
}
//The gluCylinder subroutine draws a cylinder that is oriented along the z axis.
//The base of the cylinder is placed at z = 0; the top of the cylinder is placed at z=height.
//Like a sphere, the cylinder is subdivided around the z axis into slices and along the z axis into stacks.
gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
float radius = cylinder->GetHalfExtents().getX();
float height = 2.f*cylinder->GetHalfExtents().getY();
gluCylinder(quadObj, radius, radius, height, 15, 10);
glPopMatrix();
glEndList();
break;
}
default: