Author Topic: .setMesh(Object3D obj) doesn't carry the UV coords  (Read 3451 times)

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
.setMesh(Object3D obj) doesn't carry the UV coords
« on: May 09, 2012, 03:54:07 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: .setMesh(Object3D obj) doesn't carry the UV coords
« Reply #1 on: May 09, 2012, 07:03:30 am »
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

Code: [Select]
Object3D clone=new Object3D(bluePrint, true);

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: .setMesh(Object3D obj) doesn't carry the UV coords
« Reply #2 on: May 09, 2012, 01:44:39 pm »
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:

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: .setMesh(Object3D obj) doesn't carry the UV coords
« Reply #3 on: May 09, 2012, 04:57:00 pm »
I fail to see the problem. You could simply use that constructor in the constructor of Model. I'm always doing it that way.

Offline orange451

  • byte
  • *
  • Posts: 19
    • View Profile
Re: .setMesh(Object3D obj) doesn't carry the UV coords
« Reply #4 on: May 09, 2012, 05:15:42 pm »
Then everytime I create the Model object, I need to reload the model, rather than just copy it from the already existing model.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: .setMesh(Object3D obj) doesn't carry the UV coords
« Reply #5 on: May 09, 2012, 08:45:02 pm »
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

Code: [Select]
public class Model {

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

}