[1.0.22T5] getting inherited actor/noderenderable from scene

nargil

30-01-2009 23:03:35

Is there any good way to get objects from a specific factory ?

[cSwiatlo is my class that inherits from NodeRenderable and Actor. It manages lights in the scene editor]
For now i use
NxOgre::Actors* act = this->mScene->getActors();
cSwiatlo* swiatlo;
for(NxOgre::Actor* a = act->begin(); a = act->next();)
{
swiatlo = (cSwiatlo*)mScene->getActor(a->getName()); // this is so bad and newbish and not'Betajean'like xD Another method is to raycast to the actors position, but this is even worse.
if(swiatlo->getType()==12349)
{
swiatlo->getNode()->setVisible(pokaz,true);
}
}
But i don't like it for two reasons:
1. I have to cheack every actor
2. I have to double get it. Using for(cSwiatlo* a = (cSwiatlo*)act->begin(); a = (cSwiatlo*)act->next();) does throw 0x0000005 Access violation. Basicly there is garbage at ->getType() and ->getNode()

betajaen

30-01-2009 23:17:02

Is "cSwiatlo" your class that inherits Actor?

If so; this would probably work.

NxOgre::Actors* act = this->mScene->getActors();
for(NxOgre::Actor* a = act->begin(); a = act->next();)
{
if(a->getType()==12349)
{
cSwiatlo* swiatlo = static_cast<cSwiatlo*>(a);
swiatlo->getNode()->setVisible(pokaz,true);
}
}

nargil

30-01-2009 23:28:27

it doesnt. Tried that too. Something gets truncated when getting actor from container.

nargil

31-01-2009 09:20:19

Ok. I tried it again and it works. Must have made some kind of mistake yesterday.