Strange Behavior

Started by Gatobot14, April 06, 2016, 04:04:53 AM

Previous topic - Next topic

Gatobot14

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 




EgonOlsen

#1
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?

Gatobot14

here is the code for copy


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..



   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);
}



EgonOlsen

Looks fine at first glance. Can you provide me with a text case? Which version of jPCT are you using?

Gatobot14

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