COLLADA import, avoided some crashes, improved <convex_mesh> support
This commit is contained in:
@@ -1239,7 +1239,7 @@ int main(int argc,char** argv)
|
||||
daeElement* geomElem = geomInstRef->getUrl().getElement();
|
||||
//elemRef->getTypeName();
|
||||
domGeometry* geom = (domGeometry*) geomElem;
|
||||
if (geom->getMesh())
|
||||
if (geom && geom->getMesh())
|
||||
{
|
||||
const domMeshRef meshRef = geom->getMesh();
|
||||
TriangleIndexVertexArray* tindexArray = new TriangleIndexVertexArray();
|
||||
@@ -1354,7 +1354,7 @@ int main(int argc,char** argv)
|
||||
|
||||
}
|
||||
|
||||
if (geom->getConvex_mesh())
|
||||
if (geom && geom->getConvex_mesh())
|
||||
{
|
||||
|
||||
{
|
||||
@@ -1382,6 +1382,8 @@ int main(int argc,char** argv)
|
||||
const domConvex_meshRef convexRef = geom->getConvex_mesh();
|
||||
//daeString urlref = convexRef->getConvex_hull_of().getURI();
|
||||
daeString urlref2 = convexRef->getConvex_hull_of().getOriginalURI();
|
||||
if (urlref2)
|
||||
{
|
||||
daeElementRef otherElemRef = convexRef->getConvex_hull_of().getElement();
|
||||
// if ( otherElemRef != NULL )
|
||||
// {
|
||||
@@ -1446,8 +1448,51 @@ int main(int argc,char** argv)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else
|
||||
{
|
||||
//no getConvex_hull_of but direct vertices
|
||||
const domVerticesRef vertsRef = convexRef->getVertices();
|
||||
int numInputs = vertsRef->getInput_array().getCount();
|
||||
for (int i=0;i<numInputs;i++)
|
||||
{
|
||||
domInputLocalRef localRef = vertsRef->getInput_array()[i];
|
||||
daeString str = localRef->getSemantic();
|
||||
if ( !strcmp(str,"POSITION"))
|
||||
{
|
||||
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+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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (convexHullShape->GetNumVertices())
|
||||
{
|
||||
colShape = convexHullShape;
|
||||
@@ -1459,10 +1504,6 @@ int main(int argc,char** argv)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//domGeometryRef linkedGeom = *(domGeometryRef*)&otherElemRef;
|
||||
|
||||
printf("convexmesh\n");
|
||||
@@ -1566,7 +1607,6 @@ int main(int argc,char** argv)
|
||||
char* bodyName = (char*)physObjects[i]->getNewClientInfo();
|
||||
if (!strcmp(bodyName,orgUri0))
|
||||
{
|
||||
printf("found\n");
|
||||
ctrl0=physObjects[i];
|
||||
}
|
||||
if (!strcmp(bodyName,orgUri1))
|
||||
@@ -1658,6 +1698,8 @@ int main(int argc,char** argv)
|
||||
}
|
||||
|
||||
|
||||
if (ctrl0 && ctrl1)
|
||||
{
|
||||
constraintId =physicsEnvironmentPtr->createUniversalD6Constraint(
|
||||
ctrl0,
|
||||
ctrl1,
|
||||
@@ -1668,6 +1710,10 @@ int main(int argc,char** argv)
|
||||
angularLowerLimits,
|
||||
angularUpperLimits
|
||||
);
|
||||
} else
|
||||
{
|
||||
printf("Error: Cannot find Rigidbodies(%s,%s) for constraint %s\n",orgUri0,orgUri1,constraintName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user