ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > irrEdit
forum topic indicator irredit saving the wrong nodename to the wrong scenenodes?
person icon
Quillraven
Guest
Quote
2009-06-11 13:43:53

hi,

i get a wierd problem when loading my sccene from the .irr file when checking their name for special things.

in my example:
i have 2 particlesystems "fire" and "wind" and i need the wind particlesystem to set a special gravity when colliding with it.

i know, there is the function

smgr->getSceneNodeFromName( name, nodestart );


but i need a more "dynamic" way for any special nodes.


so i now have this code:


/**********************************
* function LoadStage
*
* takes number of stage to be load
*
**********************************/
bool Game::LoadStage( int stagenumber )
{
// load irr scene
std::ostringstream filepath (ostringstream::out);
filepath << "media/stage" << stagenumber << ".irr";
if( !smgr->loadScene( filepath.str().c_str() ) )
return false;

// pointer to the faerie scene node
scene::IAnimatedMeshSceneNode* faerienode = faerie->GetNode();

// find all meshes
core::array<scene::ISceneNode*> nodes;
smgr->getSceneNodesFromType(scene::ESNT_ANY, nodes);
world->removeAllTriangleSelectors();
environmentnodes.clear();

for (u32 i=0; i < nodes.size(); ++i)
{
scene::ISceneNode* node = nodes[i];
scene::ITriangleSelector* selector = 0;
node->setMaterialFlag( video::EMF_LIGHTING, nodematerial.Lighting );
node->setMaterialFlag( video::EMF_FOG_ENABLE, nodematerial.FogEnable );
node->setMaterialFlag( video::EMF_ANISOTROPIC_FILTER, nodematerial.getFlag( video::EMF_ANISOTROPIC_FILTER ) );

if( node == faerienode || node == camera )
continue;

switch(node->getType())
{
case scene::ESNT_CUBE:
case scene::ESNT_ANIMATED_MESH:
// Because the selector won't animate with the mesh,
// and is only being used for camera collision, we'll just use an approximate
// bounding box instead of ((scene::IAnimatedMeshSceneNode*)node)->getMesh(0)
selector = smgr->createTriangleSelectorFromBoundingBox( node );
break;

case scene::ESNT_MESH:
case scene::ESNT_SPHERE: // Derived from IMeshSceneNode
selector = smgr->createTriangleSelector( ((scene::IMeshSceneNode*)node)->getMesh(), node );
break;

case scene::ESNT_TERRAIN:
selector = smgr->createTerrainTriangleSelector( (scene::ITerrainSceneNode*)node );
break;

case scene::ESNT_OCT_TREE:
selector = smgr->createOctTreeTriangleSelector( ((scene::IMeshSceneNode*)node)->getMesh(), node );
break;

case scene::ESNT_PARTICLE_SYSTEM:
if( strcmp( node->getName(), "Fire" ) )
environmentnodes.push_back( new EnvironmentSceneNode( node, core::vector3df( 0, 1, 0 ), 1, 0 ) );
break;

case scene::ESNT_BILLBOARD:
break;
default:
// Don't create a selector for this node type
break;
}

if( selector )
{
// Add it to the meta selector, which will take a reference to it
world->addTriangleSelector( selector );
// And drop my reference to it, so that the meta selector owns it.
selector->drop();
}
}
nodes.clear();

// set faerie startlocation
startlocation = smgr->getSceneNodeFromName( "StartLocation" )->getAbsolutePosition();
startlocation.Y += 80;
faerie->RemoveCollision();
faerienode->setPosition( startlocation );
faerienode->updateAbsolutePosition();
faerie->InitCollision( smgr );

// add the new world to the collision animator of the faerie
world->grab();
faerie->GetCollisionAnimator()->setWorld( world );
world->drop();

return true;
}


textmessages tell me, that it jumps 2 times in the particlesystem case and the nodenames are Fire and WindUp.
this is correct :)

but later on i need to check, if the player collides with the wind node:

i have this:

[code]
// check if faere collides wiith environment
core::vector3df force( 0, 0, 0 );
core::vector3df faerieforce = faerie->GetCollisionAnimator()->getGravity();
for

person icon
Quillraven
Guest
Quote
2009-06-11 13:45:35

i have this:


// check if faerie collides wiith environment
core::vector3df force( 0, 0, 0 );
core::vector3df faerieforce = faerie->GetCollisionAnimator()->getGravity();
for (u32 i=0; i < environmentnodes.size(); ++i)
{
scene::ISceneNode* node = environmentnodes[i]->GetNode();
if( node->getTransformedBoundingBox().isPointInside( faerieposold ) )
{
if( environmentnodes[i]->GetType() == 1 )
force += environmentnodes[i]->GetForce();;
}
}


the wierd problem now is, that node is the fireparticlesystem oO
when i change the strcmp function to "Fire" i get the correct windup particlesystem node.

i wonder, if this is an irredit bug or sthg else?

person icon
niko
Moderator
Quote
2009-06-12 12:54:39

Just did a short look at your code, but should this line

if( strcmp( node->getName(), "Fire" ) )


look like this?

if( !strcmp( node->getName(), "Fire" ) )


But maybe I'm wrong here.

person icon
Quillraven
Guest
Quote
2009-06-12 13:00:15

thx again master niko :)

should've read the c++ reference more exactly ;)


Returns an integral value indicating the relationship between the strings:
A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value in str1 than in str2; And a value less than zero indicates the opposite.



Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |