.setMesh(Object3D obj) doesn't carry the UV coords

Started by orange451, May 09, 2012, 03:54:07 AM

Previous topic - Next topic

orange451

In a project I'm doing, I need to use the .setMesh() method on an Object3D object, and the paremeter passed into the .setMesh() is the mesh (.getMesh()) of another object3D object.
basically:
object2.setMesh(object1.getMesh());

However, when I applied a texture to object2, I found that object2's UV coords are all at 0,0 on the UV map.

Any ideas?

EgonOlsen

Yes. That's because uv-mapping is part of the Object3D, not of the Mesh. If you want to clone these, you should rather do something like


Object3D clone=new Object3D(bluePrint, true);

orange451

the only problem, which I probably should have mentioned, is that I created a new class, called Model. Model extends Object3D. Using the way you just provided wont work, because you can't cast the Object3D class D:

EgonOlsen

I fail to see the problem. You could simply use that constructor in the constructor of Model. I'm always doing it that way.

orange451

Then everytime I create the Model object, I need to reload the model, rather than just copy it from the already existing model.

EgonOlsen

No, you don't. I don't really get the problem...You can load the model once, store it somewhere and then do something like


public class Model {

      public Model() {
           super(<your model blueprint comes here>, true);
           ....
      }

}