From ddf9973fba39e0f3f1f82658fb9901bb17906755 Mon Sep 17 00:00:00 2001 From: ejcoumans Date: Sun, 18 Jun 2006 07:04:21 +0000 Subject: [PATCH] preliminary convex hull support using COLLADA_DOM, draw convex hull in wireframe (point cloud doesn't have triangles) --- Demos/ColladaDemo/ColladaDemo.cpp | 71 ++++++++++++++----------------- Demos/OpenGL/GL_ShapeDrawer.cpp | 1 + 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/Demos/ColladaDemo/ColladaDemo.cpp b/Demos/ColladaDemo/ColladaDemo.cpp index 06424974d..534eb8c25 100644 --- a/Demos/ColladaDemo/ColladaDemo.cpp +++ b/Demos/ColladaDemo/ColladaDemo.cpp @@ -47,7 +47,7 @@ extern int gForwardAxis; #include "GLDebugDrawer.h" //either FCollada or COLLADA_DOM -#define USE_FCOLLADA 1 +//#define USE_FCOLLADA 1 #ifdef USE_FCOLLADA //Collada Physics test @@ -1082,7 +1082,7 @@ int main(int argc,char** argv) { const domMeshRef meshRef = geom->getMesh(); - printf("mesh\n"); + printf("(concave) mesh not supported yet\n"); } if (geom->getConvex_mesh()) @@ -1131,49 +1131,42 @@ int main(int argc,char** argv) domMesh *meshElement = lib->getMesh(); if (meshElement) { - for (int i=0;igetSource_array().getCount();i++) + const domVerticesRef vertsRef = meshElement->getVertices(); + int numInputs = vertsRef->getInput_array().getCount(); + for (int i=0;igetSource_array()[i]; - - - /*for (int j=0;jgetFloat_array()->getCount();j++) + domInputLocalRef localRef = vertsRef->getInput_array()[i]; + daeString str = localRef->getSemantic(); + if ( !strcmp(str,"POSITION")) { - const domListOfFloats& listFloats = srcRef->getFloat_array()[i].getValue(); - int cnt = listFloats.getCount(); - - for (int k=0;k+2AddPoint(SimdPoint3(fl0,fl1,fl2)); - } - } - */ - - - - - } - - int tricount = meshElement->getTriangles_array().getCount(); - int polycount = meshElement->getPolygons_array().getCount(); - for (int i=0;igetPolygons_array()[i]; - for (int i=0;igetInput_array().getCount();i++) - { - domInputLocalOffsetRef offset = poly->getInput_array()[i]; + const domURIFragmentType& frag = localRef->getSource(); + daeElementConstRef constElem = frag.getElement(); + + const domSourceRef node = *(const domSourceRef*)&constElem; + const domFloat_arrayRef flArray = node->getFloat_array(); + if (flArray) + { + int numElem = flArray->getCount(); + const domListOfFloats& listFloats = flArray->getValue(); + + for (int k=0;k+2AddPoint(SimdPoint3(fl0,fl1,fl2)); + } + + } } - + } - int vertexCount = meshElement->getVertices()->getInput_array().getCount(); //? + } } @@ -1183,9 +1176,11 @@ int main(int argc,char** argv) if (convexHullShape->GetNumVertices()) { colShape = convexHullShape; + printf("created convexHullShape with %i points\n",convexHullShape->GetNumVertices()); } else { delete convexHullShape; + printf("failed to create convexHullShape\n"); } diff --git a/Demos/OpenGL/GL_ShapeDrawer.cpp b/Demos/OpenGL/GL_ShapeDrawer.cpp index 8247d5302..8beb20a85 100644 --- a/Demos/OpenGL/GL_ShapeDrawer.cpp +++ b/Demos/OpenGL/GL_ShapeDrawer.cpp @@ -131,6 +131,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim break; } case CONVEX_HULL_SHAPE_PROXYTYPE: + break; case SPHERE_SHAPE_PROXYTYPE: { const SphereShape* sphereShape = static_cast(shape);