DaCracker
10-08-2006 22:57:50
Hi!
I'm a new user of nxOgre, it seems to have some nice features
and I'm currently adding support for nxOgre in my game engine.
However, I've got some problems when I'm using nxOgre with
oFusion. I use this code to create an entity:
The strange thing is that from what I've seen, the createStaticBody() method creates an entity and attach it to a SceneNode, so... I should
be able to see my objects in the scene right? The thing that I find strange
is that i can't.
I've tried to add an extra entity, which I can view... but it seems like
a very bad solution to me, the code above shows how I've done this.
The second problem is that when I create this extra entity, the collision
detection seems to be wrong, it works fine at some places but at other
places I fall through the floor!
I'm sorry if these questions are very basic, but I've never used a
physics engine before
I'm a new user of nxOgre, it seems to have some nice features
and I'm currently adding support for nxOgre in my game engine.
However, I've got some problems when I'm using nxOgre with
oFusion. I use this code to create an entity:
// Create all entities in scene
void OSMScene::createEntities(TiXmlElement* pEntityNode, Ogre::SceneNode* pSceneRoot)
{
// Iterate all meshes, creating them.
for (TiXmlElement* pMeshElem = pEntityNode->FirstChildElement();
pMeshElem != 0; pMeshElem = pMeshElem->NextSiblingElement())
{
// Ogre could cast an exception, in which case we just try to
// continue reading the other meshes
try
{
const char *pszName = pMeshElem->Attribute("name");
const char *pszFileName = pMeshElem->Attribute("filename");
// Create node with full information
SceneNode *pObjNode = createNode(pMeshElem, pSceneRoot);
global->mScene->createStaticBody(pszName,pszFileName,new nxOgre::meshShape(pszFileName,global->mScene),pObjNode->getPosition());
// try to create the mesh
Entity *pEntity = mSceneMgr->createEntity(pszName, pszFileName);
if(pEntity==0) continue;
// Check if the object should cast shadows
const char *pszCastShadows=pMeshElem->Attribute("CastShadows");
if(pszCastShadows && stricmp(pszCastShadows, "no")==0)
{
pEntity->setCastShadows(false);
}
else
{
pEntity->setCastShadows(true);
}
// Attach the mesh entity to node
pObjNode->attachObject(pEntity);
// Notify
if(mCallbacks)
{
mCallbacks->OnEntityCreate(pEntity, pMeshElem);
}
// Add to entity list
mEntities.push_back(pEntity);
} catch(...)
{
continue;
}
}
}
The strange thing is that from what I've seen, the createStaticBody() method creates an entity and attach it to a SceneNode, so... I should
be able to see my objects in the scene right? The thing that I find strange
is that i can't.
I've tried to add an extra entity, which I can view... but it seems like
a very bad solution to me, the code above shows how I've done this.
The second problem is that when I create this extra entity, the collision
detection seems to be wrong, it works fine at some places but at other
places I fall through the floor!
I'm sorry if these questions are very basic, but I've never used a
physics engine before