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

@ -66,6 +66,17 @@ public:
return CYLINDER_SHAPE_PROXYTYPE;
}
virtual int GetUpAxis() const
{
return 1;
}
//debugging
virtual char* GetName()const
{
return "CylinderY";
}
};
@ -77,6 +88,16 @@ public:
virtual SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const;
virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const;
virtual int GetUpAxis() const
{
return 0;
}
//debugging
virtual char* GetName()const
{
return "CylinderX";
}
};
class CylinderShapeZ : public CylinderShape
@ -87,6 +108,16 @@ public:
virtual SimdVector3 LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const;
virtual void BatchedUnitVectorGetSupportingVertexWithoutMargin(const SimdVector3* vectors,SimdVector3* supportVerticesOut,int numVectors) const;
virtual int GetUpAxis() const
{
return 2;
}
//debugging
virtual char* GetName()const
{
return "CylinderZ";
}
};

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:

12586
friction.dae

File diff suppressed because one or more lines are too long

218
jenga.dae
View File

@ -3,13 +3,13 @@
<asset>
<contributor>
<author>Illusoft Collada 1.4.0 plugin for Blender - http://colladablender.illusoft.com</author>
<authoring_tool>Blender v:241 - Illusoft Collada Exporter v:0.2.45</authoring_tool>
<authoring_tool>Blender v:241 - Illusoft Collada Exporter v:0.2.56</authoring_tool>
<comments></comments>
<copyright></copyright>
<source_data>file://c:/blender/physics_demos-2.42-preview24/jenga_physics_test.blend</source_data>
</contributor>
<created>2006-06-02T17:45:13.891000</created>
<modified>2006-06-02T17:45:13.891000</modified>
<created>2006-06-06T14:18:41.437000</created>
<modified>2006-06-06T14:18:41.452000</modified>
<unit meter="0.01" name="centimeter"/>
<up_axis>Z_UP</up_axis>
</asset>
@ -29,7 +29,7 @@
<library_effects>
<effect id="Material-fx" name="Material-fx">
<profile_COMMON>
<technique>
<technique sid="">
<phong>
<emission>
<color>0.0 0.0 0.0 1.0</color>
@ -3604,7 +3604,8 @@
<translate>15.50131 29.68761 4.99616</translate>
<rotate>0.0 0.0 1.0 0.0</rotate>
<rotate>0.0 1.0 0.0 0.0</rotate>
<rotate>1.0 0.0 0.0 -36.81686</rotate>
<rotate>1.0 0.0 0.0 -36.81686</rotate>
<rotate>1.0 0.0 0.0 90.0</rotate>
<instance_geometry url="#Cylinder_004-Geometry"/>
</node>
<node id="Cylinder_003" name="Cylinder_003">
@ -3612,6 +3613,7 @@
<rotate>0.0 0.0 1.0 -38.06934</rotate>
<rotate>0.0 1.0 0.0 0.0</rotate>
<rotate>1.0 0.0 0.0 0.0</rotate>
<rotate>1.0 0.0 0.0 90.0</rotate>
<instance_geometry url="#Cylinder_003-Geometry"/>
</node>
<node id="Cylinder_002" name="Cylinder_002">
@ -3619,6 +3621,7 @@
<rotate>0.0 0.0 1.0 -38.06934</rotate>
<rotate>0.0 1.0 0.0 0.0</rotate>
<rotate>1.0 0.0 0.0 0.0</rotate>
<rotate>1.0 0.0 0.0 90.0</rotate>
<instance_geometry url="#Cylinder_002-Geometry"/>
</node>
<node id="Cylinder_001" name="Cylinder_001">
@ -3626,6 +3629,7 @@
<rotate>0.0 0.0 1.0 -38.06934</rotate>
<rotate>0.0 1.0 0.0 0.0</rotate>
<rotate>1.0 0.0 0.0 0.0</rotate>
<rotate>1.0 0.0 0.0 90.0</rotate>
<instance_geometry url="#Cylinder_001-Geometry"/>
</node>
<node id="Cylinder" name="Cylinder">
@ -3633,6 +3637,7 @@
<rotate>0.0 0.0 1.0 -23.42368</rotate>
<rotate>0.0 1.0 0.0 -47.70962</rotate>
<rotate>1.0 0.0 0.0 14.68375</rotate>
<rotate>1.0 0.0 0.0 90.0</rotate>
<instance_geometry url="#Cylinder-Geometry"/>
</node>
<node id="Cube_067" name="Cube_067">
@ -4261,6 +4266,13 @@
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cone_003-PhysicsMaterial" name="Cone_003-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
<restitution>0</restitution>
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cube_071-PhysicsMaterial" name="Cube_071-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
@ -4296,6 +4308,55 @@
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cone_001-PhysicsMaterial" name="Cone_001-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
<restitution>0</restitution>
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cone-PhysicsMaterial" name="Cone-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
<restitution>0</restitution>
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cylinder_004-PhysicsMaterial" name="Cylinder_004-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
<restitution>0</restitution>
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cylinder_003-PhysicsMaterial" name="Cylinder_003-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
<restitution>0</restitution>
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cylinder_002-PhysicsMaterial" name="Cylinder_002-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
<restitution>0</restitution>
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cylinder_001-PhysicsMaterial" name="Cylinder_001-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
<restitution>0</restitution>
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cylinder-PhysicsMaterial" name="Cylinder-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
<restitution>0</restitution>
<static_friction>0</static_friction>
</technique_common>
</physics_material>
<physics_material id="Cube_067-PhysicsMaterial" name="Cube_067-PhysicsMaterial">
<technique_common>
<dynamic_friction>0</dynamic_friction>
@ -4732,6 +4793,22 @@
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cone_003-PhysicsModel" name="Cone_003-PhysicsModel">
<rigid_body name="Cone_003-RigidBody">
<technique_common>
<instance_physics_material url="#Cone_003-PhysicsMaterial"/>
<shape>
<tapered_cylinder>
<radius1>1.0</radius1>
<radius2>0</radius2>
<height>1.0</height>
</tapered_cylinder>
</shape>
<dynamic>true</dynamic>
<mass>1.0</mass>
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cube_071-PhysicsModel" name="Cube_071-PhysicsModel">
<rigid_body name="Cube_071-RigidBody">
<technique_common>
@ -4796,6 +4873,113 @@
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cone_001-PhysicsModel" name="Cone_001-PhysicsModel">
<rigid_body name="Cone_001-RigidBody">
<technique_common>
<instance_physics_material url="#Cone_001-PhysicsMaterial"/>
<shape>
<tapered_cylinder>
<radius1>1.0</radius1>
<radius2>0</radius2>
<height>0.42013</height>
</tapered_cylinder>
</shape>
<dynamic>true</dynamic>
<mass>1.0</mass>
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cone-PhysicsModel" name="Cone-PhysicsModel">
<rigid_body name="Cone-RigidBody">
<technique_common>
<instance_physics_material url="#Cone-PhysicsMaterial"/>
<shape>
<tapered_cylinder>
<radius1>1.0</radius1>
<radius2>0</radius2>
<height>1.0</height>
</tapered_cylinder>
</shape>
<dynamic>true</dynamic>
<mass>1.0</mass>
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cylinder_004-PhysicsModel" name="Cylinder_004-PhysicsModel">
<rigid_body name="Cylinder_004-RigidBody">
<technique_common>
<instance_physics_material url="#Cylinder_004-PhysicsMaterial"/>
<shape>
<cylinder>
<radius>1.0</radius>
<height>1.0</height>
</cylinder>
</shape>
<dynamic>true</dynamic>
<mass>1.0</mass>
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cylinder_003-PhysicsModel" name="Cylinder_003-PhysicsModel">
<rigid_body name="Cylinder_003-RigidBody">
<technique_common>
<instance_physics_material url="#Cylinder_003-PhysicsMaterial"/>
<shape>
<cylinder>
<radius>1. 1.00</radius>
<height>1.0</height>
</cylinder>
</shape>
<dynamic>true</dynamic>
<mass>1.0</mass>
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cylinder_002-PhysicsModel" name="Cylinder_002-PhysicsModel">
<rigid_body name="Cylinder_002-RigidBody">
<technique_common>
<instance_physics_material url="#Cylinder_002-PhysicsMaterial"/>
<shape>
<cylinder>
<radius>1. 1.00</radius>
<height>1.0</height>
</cylinder>
</shape>
<dynamic>true</dynamic>
<mass>1.0</mass>
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cylinder_001-PhysicsModel" name="Cylinder_001-PhysicsModel">
<rigid_body name="Cylinder_001-RigidBody">
<technique_common>
<instance_physics_material url="#Cylinder_001-PhysicsMaterial"/>
<shape>
<cylinder>
<radius>1. 1.00</radius>
<height>1.0</height>
</cylinder>
</shape>
<dynamic>true</dynamic>
<mass>1.0</mass>
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cylinder-PhysicsModel" name="Cylinder-PhysicsModel">
<rigid_body name="Cylinder-RigidBody">
<technique_common>
<instance_physics_material url="#Cylinder-PhysicsMaterial"/>
<shape>
<cylinder>
<radius>1.0 1.0</radius>
<height>1.0</height>
</cylinder>
</shape>
<dynamic>true</dynamic>
<mass>1.0</mass>
</technique_common>
</rigid_body>
</physics_model>
<physics_model id="Cube_067-PhysicsModel" name="Cube_067-PhysicsModel">
<rigid_body name="Cube_067-RigidBody">
<technique_common>
@ -5617,6 +5801,9 @@
<instance_physics_model url="#Font-PhysicsModel">
<instance_rigid_body target="#Font"/>
</instance_physics_model>
<instance_physics_model url="#Cone_003-PhysicsModel">
<instance_rigid_body target="#Cone_003"/>
</instance_physics_model>
<instance_physics_model url="#Cube_071-PhysicsModel">
<instance_rigid_body target="#Cube_071"/>
</instance_physics_model>
@ -5632,6 +5819,27 @@
<instance_physics_model url="#Cube_068-PhysicsModel">
<instance_rigid_body target="#Cube_068"/>
</instance_physics_model>
<instance_physics_model url="#Cone_001-PhysicsModel">
<instance_rigid_body target="#Cone_001"/>
</instance_physics_model>
<instance_physics_model url="#Cone-PhysicsModel">
<instance_rigid_body target="#Cone"/>
</instance_physics_model>
<instance_physics_model url="#Cylinder_004-PhysicsModel">
<instance_rigid_body target="#Cylinder_004"/>
</instance_physics_model>
<instance_physics_model url="#Cylinder_003-PhysicsModel">
<instance_rigid_body target="#Cylinder_003"/>
</instance_physics_model>
<instance_physics_model url="#Cylinder_002-PhysicsModel">
<instance_rigid_body target="#Cylinder_002"/>
</instance_physics_model>
<instance_physics_model url="#Cylinder_001-PhysicsModel">
<instance_rigid_body target="#Cylinder_001"/>
</instance_physics_model>
<instance_physics_model url="#Cylinder-PhysicsModel">
<instance_rigid_body target="#Cylinder"/>
</instance_physics_model>
<instance_physics_model url="#Cube_067-PhysicsModel">
<instance_rigid_body target="#Cube_067"/>
</instance_physics_model>