www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: orange451 on May 09, 2012, 03:54:07 am

Title: .setMesh(Object3D obj) doesn't carry the UV coords
Post by: orange451 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?
Title: Re: .setMesh(Object3D obj) doesn't carry the UV coords
Post by: EgonOlsen 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);
Title: Re: .setMesh(Object3D obj) doesn't carry the UV coords
Post by: orange451 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:
Title: Re: .setMesh(Object3D obj) doesn't carry the UV coords
Post by: EgonOlsen 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.
Title: Re: .setMesh(Object3D obj) doesn't carry the UV coords
Post by: orange451 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.
Title: Re: .setMesh(Object3D obj) doesn't carry the UV coords
Post by: EgonOlsen 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);
           ....
      }

}