Hello. Just recently I have created a Manual Object and converted it to a node, but when taking the node's entity to make the collision shape, I get an assert for "pRep, file OgreSharedPtr.h."
I tried other strategies on this thread but the same exact line keeps messing up. Here is the code:
Code: Select all
ManualObject* textureArrayObject = myGameScene->createManualObject(mapFile+"_TexAtlas");
textureArrayObject->begin(texArrayMat->getName(), RenderOperation::OT_TRIANGLE_LIST);
for(int r=0;r<pHeight;++r){
for(int c=0;c<pWidth;++c){
float idx=0.5;
for (int b = 0; b < bytes; b++)
p[b] = buf[bytes * (pWidth * r + c) + b];
for(int a=0;a<tileVals.size();++a){
if (hex == tileVals[a]){
idx = float(a)/float(tileVals.size()); //scale to 0->1
///std::cout<<"picked value: " <<i<<std::endl;
break;
}
}
///Triangle 0
textureArrayObject->position(c*quadSize, 0, r*quadSize);
textureArrayObject->textureCoord(0, 0, idx);
textureArrayObject->position((c+1)*quadSize, 0, r*quadSize);
textureArrayObject->textureCoord(1, 0, idx);
textureArrayObject->position((c+1)*quadSize, 0, (r+1)*quadSize);
textureArrayObject->textureCoord(1, 1, idx);
///Triangle 1
textureArrayObject->position(c*quadSize, 0, r*quadSize);
textureArrayObject->textureCoord(0, 0, idx);
textureArrayObject->position((c+1)*quadSize, 0, (r+1)*quadSize);
textureArrayObject->textureCoord(1, 1, idx);
textureArrayObject->position(c*quadSize, 0, (r+1)*quadSize);
textureArrayObject->textureCoord(0, 1, idx);
}
}
textureArrayObject->end();
myMesh=textureArrayObject->convertToMesh(mapFile+"_mesh");
myCollMesh=textureArrayObject->convertToMesh(mapFile+"_Collmesh");
///mapM
mapM.entity=myGameScene->createEntity(myMesh);
mapM.entity->setMaterialName(texArrayMat->getName());
mapM.node=myGameScene->getRootSceneNode()->createChildSceneNode();
mapM.node->attachObject(mapM.entity);
mapM.node->setPosition((quadSize*pWidth/-2)-oWidth,0,(quadSize*pHeight/-2)-oHeight);
///CollM
collM.entity=myGameScene->createEntity(myCollMesh);
collM.entity->setMaterialName("ClearColl");
collM.node=myGameScene->getRootSceneNode()->createChildSceneNode();
collM.node->attachObject(collM.entity);
collM.node->setPosition((quadSize*pWidth/-2)-oWidth,0,(quadSize*pHeight/-2)-oHeight);
///Collision
BtOgre::StaticMeshToShapeConverter converter(collM.entity);
btBvhTriangleMeshShape *mShape = converter.createTrimesh();
//Inertia
btScalar mass = 5;
btVector3 inertia;
mShape->calculateLocalInertia(mass, inertia);
BtOgre::RigidBodyState *state = new BtOgre::RigidBodyState(collM.node);
coll.body=new btRigidBody(mass, state, mShape, inertia);
coll.body->setActivationState(ISLAND_SLEEPING);
myGameDW->addRigidBody(coll.body);
As seen by the code, I am creating a texture array manual object. More info here:
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=78085
Any help would be appreciated.