3
« on: January 30, 2019, 05:08:18 pm »
Good day i would like to ask if it is possible to resize the object by y axis or x axis runtime.
Like for example i drag the left side of the cube then the x-axis will expand. something like that.
Any idea or source code.
btw i already use this code.
public void setSize(float scalex, float scaley)
{
demoControl = new ResizerMod(scalex, scaley,1);
planeMesh.setVertexController(demoControl, IVertexController.PRESERVE_SOURCE_MESH);
planeMesh.applyVertexController();
planeMesh.removeVertexController();
}
private static class ResizerMod extends GenericVertexController {
private static final long serialVersionUID = 1L;
float XFactor =1;
float YFactor =1;
float ZFactor =1;
public ResizerMod(float xFactor, float yFactor, float zFactor)
{
this.XFactor = xFactor;
this.YFactor = yFactor;
this.ZFactor = zFactor;
}
public void apply() {
SimpleVector[] s = getSourceMesh();
SimpleVector[] d = getDestinationMesh();
Log.i("vertex", "XFactor="+s[1] + s[2] +" YFactor="+d);
for (int i = 0; i < s.length; i++) {
//d.z = s.z - (10f * ((float) Math.sin(s.x / 50f) + (float) Math.cos(s.y / 50f)));
Log.i("vertex", "old vertex="+i+" x="+ d.x);
Log.i("vertex", "old vertex="+i+" y="+ d.y);
Log.i("vertex", "old vertex="+i+" z="+ d.z);
d.x = s.x*XFactor;
d.y = s.y*YFactor;
d.z = s.z*ZFactor;
Log.i("vertex", "vertex="+i+" x="+ d.x);
Log.i("vertex", "vertex="+i+" y="+ d.y);
Log.i("vertex", "vertex="+i+" z="+ d.z);
}
}
}
but the problem is i can only resize the object at once. please help.