gbisocoli
05-01-2010 03:48:37
Part I: (Solved)
Hi, I've recently moved from Bleeding (don't remember which version, I think T5 or something) to BloodyMess 1.5.5. I noticed that BloodyMess requires less code for creating an actor which of course is good but it created a problem for me.
On BloodyMess the code for creating an actor is for example:
void Ball::createEntity(float scale)
{
static const Ogre::Real mesh_scale = 0.02;
static const Ogre::Real physics_scale = 2.0;
// [OGRE] create player, set material and scale it
Ogre::SceneManager* sm= Ogre::Root::getSingleton().getSceneManager("Match SceneManager");
Ogre::Entity *E = sm->createEntity( name+"_entity", "sphere.mesh" );
E->setMaterialName("Soccer/Ball");
E->setQueryFlags(BALL);
mNode = sm->getRootSceneNode()->createChildSceneNode( name+"_node" );
mNode->attachObject( E );
mNode->scale( Vector3::UNIT_SCALE * mesh_scale * scale );
}
void Ball::createBody(Vector3 pos, float scale)
{
mBody= mNxRenderSystem->createBody(new NxOgre::Sphere(1), NxOgre::Vec3(pos), "sphere.mesh");
}
But I think this is wrong because there is no link between the OGRE3DBody (mBody) and the Ogre::entity (E) and Ogre::SceneNode (mNode) making imposible the visualization of the movement. In fact the ball appears and it doesn't move at all. I'll appreciate some help, thanks.
spacegaier
08-01-2010 08:19:42
The Ogre3DBody already has an Ogre::Entity and an Ogre::SceneNode inside of it, so you don't need to create them manually. And by moving the Ogre3DBody, the SceneNode (and therefore its attached Entities or whatever ius attached to it), are moved accordingly.
gbisocoli
10-01-2010 03:01:50
Thanks, I updated the code and now it works.
Part II: Now I can't visualize the mesh, I can move the body but I can't see it. This is the code:
void Player::createBody(Vector3 pos)
{
mBody= mNxRenderSystem->createBody(new NxOgre::Box(1, 1, 1), NxOgre::Vec3(pos), "cube.mesh");
mBody->getEntity()->setMaterialName("Examples/10PointBlock");
mBody->getEntity()->setQueryFlags(PLAYER);
}
I see the floor and the camera moves when I move (this is how I now the body moves) but I can't see the mesh. Any Ideas?
betajaen
10-01-2010 10:29:20
Is your cube.mesh the right size? Your not using the Ogre cube mesh that is 100x100x100m in size, aren't you?
gbisocoli
10-01-2010 19:43:58
... I'm using cube.mesh from "...\Visual Studio 2008\Projects\Soccer\media\models\", the one that comes with Ogre. I was using that one also with Bleeding and I had no problem at all.
This is the code that works for Bleeding:
void Player::createEntity(float scale)
{
// this is a scale between Ogre and NxOgre
// for example if u set scale to 5 it will be 0.1 in Ogre and 10 in NxOgre
static const Ogre::Real mesh_scale = 0.02;
static const Ogre::Real physics_scale = 2.0;
// [OGRE] create player, set material and scale it
Ogre::SceneManager* sm= Ogre::Root::getSingleton().getSceneManager("Match SceneManager");
Ogre::Entity *E = sm->createEntity( name+"_entity", "cube.mesh" );
E->setMaterialName("Examples/10PointBlock");
E->setQueryFlags(PLAYER);
mNode = sm->getRootSceneNode()->createChildSceneNode( name+"_node" );
mNode->attachObject( E );
mNode->scale( Vector3::UNIT_SCALE * mesh_scale * scale );
}
//-------------------------------------------------------------------------------------
void Player::createBody(Vector3 pos, float scale)
{
// create node renderable parms for body
NodeRenderableParams nrp;
nrp.setToDefault();
nrp.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
nrp.mIdentifier = mNode->getName();
// create body (name,shape,position,node renderable params,actor params)
// actor params is for example mass
mBody = static_cast<NxOgre::Body*>(mNxScene->createBody<NxOgre::Body>(name+"_body",new Cube(scale*2),pos,nrp,"mass:21"));
}
and this is the code for BloodyMess:
void Player::createBody(Vector3 pos)
{
mBody= mNxRenderSystem->createBody(new NxOgre::Box(1, 1, 1), NxOgre::Vec3(pos), "cube.mesh");
mBody->getEntity()->setMaterialName("Examples/10PointBlock");
mBody->getEntity()->setQueryFlags(PLAYER);
}
The only diferrence I see is the scale, on BloodyMess the Box is 1x1x1 and on Bleeding it was scale (1) by 2 = 2x2x2.
gbisocoli
14-01-2010 19:56:38
I found on Ogre.log that the material can't be assign but it is loaded correctly, here is part of the log:
16:48:55: *-*-* OGRE Initialising
16:48:55: *-*-* Version 1.6.1 (Shoggoth)
16:48:55: Creating resource group Bootstrap
16:48:55: Added resource location '../../media/packs/OgreCore.zip' of type 'Zip' to resource group 'Bootstrap'
16:48:55: Added resource location '../../media' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/fonts' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/materials/programs' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/materials/scripts' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/materials/textures' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/models' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/overlays' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/particle' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/gui' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/DeferredShadingMedia' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/PCZAppMedia' of type 'FileSystem' to resource group 'General'
16:48:55: Added resource location '../../media/packs/cubemap.zip' of type 'Zip' to resource group 'General'
16:48:55: Added resource location '../../media/packs/cubemapsJS.zip' of type 'Zip' to resource group 'General'
16:48:55: Added resource location '../../media/packs/dragon.zip' of type 'Zip' to resource group 'General'
16:48:55: Added resource location '../../media/packs/fresneldemo.zip' of type 'Zip' to resource group 'General'
16:48:55: Added resource location '../../media/packs/ogretestmap.zip' of type 'Zip' to resource group 'General'
16:48:55: Added resource location '../../media/packs/skybox.zip' of type 'Zip' to resource group 'General'
...
16:48:57: Parsing script Example.material
...
16:48:58: Parsing script Soccer.material
...
16:48:59: Texture: Grass0052_9_S.jpg: Loading 1 faces(PF_R8G8B8,1024x1024x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,1024x1024x1.
16:49:00: Mesh: Loading sphere.mesh.
16:49:00: Texture: NMBalls.png: Loading 1 faces(PF_R8G8B8,256x256x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
16:49:00: Mesh: Loading cube.mesh.
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_12-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Texture: 10points.png: Loading 1 faces(PF_A8R8G8B8,256x256x1) with hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_13-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_14-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_15-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_16-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_17-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_18-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_19-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_20-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_21-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:00: Can't assign material 1 - Default to SubEntity of Unnamed_22-Entity because this Material does not exist. Have you forgotten to define it in a .material script?
16:49:01: PCZone Factory Type 'ZoneType_Octree' unregistered
16:49:01: PCZone Factory Type 'ZoneType_Terrain' unregistered
16:49:01: Unregistering ResourceManager for type BspLevel
16:49:01: *-*-* OGRE Shutdown
...
and the materials are:
Soccer.material
material Soccer/Ball
{
technique
{
pass
{
texture_unit
{
texture NMBalls.png
}
}
}
}
and Example.material which is the one that comes with Ogre, and the textures are on ...\Visual Studio 2008\Projects\Soccer\media\materials\textures\.
Any help here? I'm totally lost.