Author Topic: Strange Behavior  (Read 2774 times)

Offline Gatobot14

  • int
  • **
  • Posts: 64
    • View Profile
Strange Behavior
« on: April 06, 2016, 04:04:53 am »
Hi egon
i dont know what im missing here, i have a blueprint object , then i make a copy of this object with new Object3D(blueprint,true)
then i assign a texture(from a texture atlas) and move uv coordinates with setTextureMatrix, after that i make another copy from blueprint , assign the same texture atlas and move texture coordinates , but when i added the second object to the world , the texture of first object changes to the texture of second object...

im using a textures atlas for both objects, thats the reason why i use setTextureMatrix i belive that clonned objects are sharing texture coordiates, but again im not sure what im doing, both objects are compiled(), and also i have use new Object3D(blueprint,false) with no difference

thanks in advance 




Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Strange Behavior
« Reply #1 on: April 06, 2016, 08:31:00 am »
Can you please post the part of the code that does the cloning/compiling/building!?

Edit: Is there any chance that you are using the same texture matrix on both?
« Last Edit: April 06, 2016, 08:51:31 am by EgonOlsen »

Offline Gatobot14

  • int
  • **
  • Posts: 64
    • View Profile
Re: Strange Behavior
« Reply #2 on: April 06, 2016, 10:32:28 pm »
here is the code for copy

Code: [Select]
public GProp duplicate(){

Object3D[] f=new Object3D[s+1];

f[0]=new Object3D(data[0],true);//with true or false the result its the same
f[0].setName(data[0].getName()+":"+f[0].getID());
f[0].compile();
 
if(s==0){return new GProp(f);}

f[1]=new Object3D(data[1],true);//with true or false the result its the same
f[1].setName(data[1].getName()+":"+f[1].getID());
f[1].compile();

return new GProp(f);
}


the texture part..

Code: [Select]

   public void setSkinState(GMosaic msc, String alias, Object3D obj){//

    if(msc==null){return;}
   
int index=msc.existAlias(alias);

if(index>msc.getMax()){return;}

int x=index%msc.getGWidth();
int y=index/msc.getGWidth();
float u=0.249f;//msc.getTWidth();

obj.setTexture(msc.getName());

Matrix texMat=new Matrix();
texMat.scalarMul(u);
texMat.translate(u*x, u*y, 0);

obj.setTextureMatrix(texMat);
}


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Strange Behavior
« Reply #3 on: April 07, 2016, 09:56:30 am »
Looks fine at first glance. Can you provide me with a text case? Which version of jPCT are you using?

Offline Gatobot14

  • int
  • **
  • Posts: 64
    • View Profile
Re: Strange Behavior
« Reply #4 on: April 08, 2016, 01:22:41 am »
Hi egon, while making the test case i discovered the problem was when i was assigning the texture, thought it was the clonning part...  thank you very much for your great support