Hi,
I use an imported model via OgreXML as battleground for my game.
Once the battleground is loaded ( and updated ), I add some characters on it.
My characters are also imported via OgreXML but they don’t have their own lights.
For now, I add a simple sunlight to my rootNode to see my characters.
My problem is as follow : I want the characters to inherits the lights from the battleground.
I use this method in the actual system to add my characters :
[java]
private void addSceneCharacterToTeam( SceneCharacter sceneChar, SceneTeam team )
{
// Add physics node
PhysicsCharacterNode node = sceneChar.getPhysicNode();
characterNodes.add( node );
rootNode.attachChild( node );
physicsSpace.add( node );
[…]
}
[/java]
So I tried to change it to :
[java]
private void addSceneCharacterToTeam( SceneCharacter sceneChar, SceneTeam team )
{
// Add physics node
PhysicsCharacterNode node = sceneChar.getPhysicNode();
characterNodes.add( node );
Node parent = (Node) battlegroundNode;
parent.updateGeometricState();
parent.attachChild( node );
parent.updateGeometricState();
physicsSpace.add( node );
[…]
}
[/java]
But it doesn’t behave as I wanted
- The character position is messed up. ( I think its something to do with my battleground center not in the origin. I should be able to manage this point )
- The character doesn’t inherit the lights of the parent node. ( They are invisible if I don’t add a SunLight )
- I have some error when I try to cast a collision ray though one of them :
[java]
java.lang.IllegalStateException: Scene graph must be updated before checking collision
at com.jme3.scene.Geometry.collideWith(Geometry.java:225)
at com.jme3.scene.Node.collideWith(Node.java:498)
[/java]
I also tried to use :
[java]
battlegroundNode.getLocalLightList();
battlegroundNode.getWorldLightList();
[/java]
but it seems that the lists are empty.
I think I have miss something somewhere but … I don’t know what xD
If someome can give me a hint …
Thanks in advance !