preliminary convex hull support using COLLADA_DOM,
draw convex hull in wireframe (point cloud doesn't have triangles)
This commit is contained in:
@@ -47,7 +47,7 @@ extern int gForwardAxis;
|
|||||||
#include "GLDebugDrawer.h"
|
#include "GLDebugDrawer.h"
|
||||||
|
|
||||||
//either FCollada or COLLADA_DOM
|
//either FCollada or COLLADA_DOM
|
||||||
#define USE_FCOLLADA 1
|
//#define USE_FCOLLADA 1
|
||||||
#ifdef USE_FCOLLADA
|
#ifdef USE_FCOLLADA
|
||||||
|
|
||||||
//Collada Physics test
|
//Collada Physics test
|
||||||
@@ -1082,7 +1082,7 @@ int main(int argc,char** argv)
|
|||||||
{
|
{
|
||||||
const domMeshRef meshRef = geom->getMesh();
|
const domMeshRef meshRef = geom->getMesh();
|
||||||
|
|
||||||
printf("mesh\n");
|
printf("(concave) mesh not supported yet\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geom->getConvex_mesh())
|
if (geom->getConvex_mesh())
|
||||||
@@ -1131,49 +1131,42 @@ int main(int argc,char** argv)
|
|||||||
domMesh *meshElement = lib->getMesh();
|
domMesh *meshElement = lib->getMesh();
|
||||||
if (meshElement)
|
if (meshElement)
|
||||||
{
|
{
|
||||||
for (int i=0;i<meshElement->getSource_array().getCount();i++)
|
const domVerticesRef vertsRef = meshElement->getVertices();
|
||||||
|
int numInputs = vertsRef->getInput_array().getCount();
|
||||||
|
for (int i=0;i<numInputs;i++)
|
||||||
{
|
{
|
||||||
|
domInputLocalRef localRef = vertsRef->getInput_array()[i];
|
||||||
domSourceRef srcRef = meshElement->getSource_array()[i];
|
daeString str = localRef->getSemantic();
|
||||||
|
if ( !strcmp(str,"POSITION"))
|
||||||
|
|
||||||
/*for (int j=0;j<srcRef->getFloat_array()->getCount();j++)
|
|
||||||
{
|
{
|
||||||
const domListOfFloats& listFloats = srcRef->getFloat_array()[i].getValue();
|
const domURIFragmentType& frag = localRef->getSource();
|
||||||
int cnt = listFloats.getCount();
|
|
||||||
|
|
||||||
for (int k=0;k+2<cnt;k+=3)
|
|
||||||
{
|
|
||||||
|
|
||||||
domFloat fl0 = listFloats.get(k);
|
|
||||||
domFloat fl1 = listFloats.get(k+1);
|
|
||||||
domFloat fl2 = listFloats.get(k+2);
|
|
||||||
|
|
||||||
convexHullShape->AddPoint(SimdPoint3(fl0,fl1,fl2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int tricount = meshElement->getTriangles_array().getCount();
|
|
||||||
int polycount = meshElement->getPolygons_array().getCount();
|
|
||||||
for (int i=0;i<polycount;i++)
|
|
||||||
{
|
|
||||||
domPolygons* poly = meshElement->getPolygons_array()[i];
|
|
||||||
for (int i=0;i<poly->getInput_array().getCount();i++)
|
|
||||||
{
|
|
||||||
domInputLocalOffsetRef offset = poly->getInput_array()[i];
|
|
||||||
|
|
||||||
|
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+2<numElem;k+=3)
|
||||||
|
{
|
||||||
|
domFloat fl0 = listFloats.get(k);
|
||||||
|
domFloat fl1 = listFloats.get(k+1);
|
||||||
|
domFloat fl2 = listFloats.get(k+2);
|
||||||
|
//printf("float %f %f %f\n",fl0,fl1,fl2);
|
||||||
|
|
||||||
|
convexHullShape->AddPoint(SimdPoint3(fl0,fl1,fl2));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
int vertexCount = meshElement->getVertices()->getInput_array().getCount(); //?
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1183,9 +1176,11 @@ int main(int argc,char** argv)
|
|||||||
if (convexHullShape->GetNumVertices())
|
if (convexHullShape->GetNumVertices())
|
||||||
{
|
{
|
||||||
colShape = convexHullShape;
|
colShape = convexHullShape;
|
||||||
|
printf("created convexHullShape with %i points\n",convexHullShape->GetNumVertices());
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
delete convexHullShape;
|
delete convexHullShape;
|
||||||
|
printf("failed to create convexHullShape\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||||
|
break;
|
||||||
case SPHERE_SHAPE_PROXYTYPE:
|
case SPHERE_SHAPE_PROXYTYPE:
|
||||||
{
|
{
|
||||||
const SphereShape* sphereShape = static_cast<const SphereShape*>(shape);
|
const SphereShape* sphereShape = static_cast<const SphereShape*>(shape);
|
||||||
|
|||||||
Reference in New Issue
Block a user