My models are black

Hey - this is most likely a lighting issue - but i dont really know how to fix.



So I load my .mesh.xml file and it loads the materials - however all i see is a black model instead of my textured model.



This is the code i use to load / light the model :



private PhysicsNode setupPlayer() {
      Spatial board = assetManager
            .loadModel("resources/models/snowboardf.mesh.xml");

      // flourescent main light
      pl = new PointLight();

      pl.setColor(ColorRGBA.White);

      CollisionShape boardCollision = CollisionShapeFactory
            .createMeshShape(board);
      playerNode = new PhysicsNode(board, boardCollision, 0f);
      playerNode.setName("player");
      playerNode.setFriction(0.1f);
      playerNode.setLocalTranslation(new Vector3f(0, 10, 0));
      playerNode.addLight(pl);
      // SnowParticle snow = new SnowParticle(assetManager);
      // playerNode.attachChild(snow);
      snowUtils.rotateModel180ZAxis(playerNode);
      getPhysicsSpace().add(playerNode);
      rootNode.attachChild(playerNode);

      return playerNode;



And this is the result:



please help!

Andy

You created a point light, but it is located at 0, 0, 0 (the origin) by default. Since the model is located above it, all you see is darkness. You should either place the light above the model or use DirectionalLight for outdoor scenes.

Right…



so if i did pl.setLocalTransfom(new Vector3f(0,10,0)); it would work?



How would i get a directional light to always look at my player?

Did you try it? PointLight is not a scene graph element, so it doesn't have that method. It has the method setPosition().

Also, the position 0, 10, 0 is at the center of the player, the light should be above him, not inside him (imagine putting a light inside your stomach, would it be useful? I don't think so).

A DirectionalLight with direction = 0, -1, 0 always points down, you can try that as well.

so what would a valid setPosition() be then? If 0,10,0 is inside the player, what is above him!?



Cheers



Andy

try 0,100,0



also

does this work:

CollisionShape boardCollision = CollisionShapeFactory

.createMeshShape(board);

playerNode = new PhysicsNode(board, boardCollision, 0f);

playerNode.setName("player");

playerNode.setFriction(0.1f);

playerNode.setLocalTranslation(new Vector3f(0, 10, 0));

playerNode.addLight(pl);

as fas as I know MeshShape is for static only, (GImpactShape is the one for dynamic)

Empire - does what work - the code looks the same as i posted!



So MeshShape is for static only - i.e my terrain - dynamic mesh collision shape for moving things!? Like my board surely?