jPCT - a 3d engine for Java > Bugs

CloneObject and lighting

(1/1)

acorn98:
Not sure if this is a bug, but I have a template object3D that I use to spawn new 'enemies', like this:

              enemy = enemyTemplate.cloneObject();
             
              enemy.translate(0, 0, 0);
              enemy.setTranslationMatrix(new Matrix());
              enemy.setLighting(Object3D.LIGHTING_ALL_ENABLED);
                           
              theWorld.addObject(enemy);

The problem is, my enemies don't seem to react to light sources at all.

The enemy model was created in MAX and uses default diffuse colours (I don't manually texture them after importing with the load3ds method). Have I missed something obvious?

Thanks..

EgonOlsen:
Have you called build() on them, i.e.


--- Code: ---enemyTemplate.build();
--- End code ---

acorn98:
That's fixed it. Thanks.

EgonOlsen:
Calling build() on anything that isn't a dummy object is required in almost every case (or call World.buildAllObjects()...but that can only build the objects that have already been attached to the world). I thought about handling this internally, but there are too many places in the code, where a correctly "builded" object is required, so this would result in a gazillion of "if (!hasBeenBuild) {this.build();} in the code and that's quite ugly.
Another problem is, that the engine can't decide if it's a good time to build an object or not.
That's why it's up to the user to call build(). However, calling build on the template is sufficient. There's no need to call it on cloned objects because they inherit the mesh data from the source.

Navigation

[0] Message Index

Go to full version