Hey,
I am curious how to make compiled dynamic objects with custom vertex controller. I haven't found any example on forum or wiki about it, but documentation says that compile(true) method must be used to be able to modify vertexes and touch() method needs to be called everytime when they are changed.
I have created object in following way:
public Ray()
{
super(4);
for (int i = 0; i < VERTEXES.length; ++i)
vertexes[i] = new SimpleVector(VERTEXES[i]);
addTriangle(VERTEXES[HF1], 1, 1, VERTEXES[HT1], 1, 0, VERTEXES[HT2], 0, 0);
addTriangle(VERTEXES[HT2], 0, 0, VERTEXES[HF2], 0, 1, VERTEXES[HF1], 1, 1);
addTriangle(VERTEXES[VF1], 1, 1, VERTEXES[VT1], 1, 0, VERTEXES[VT2], 0, 0);
addTriangle(VERTEXES[VT2], 0, 0, VERTEXES[VF2], 0, 1, VERTEXES[VF1], 1, 1);
setCulling(Object3D.CULLING_DISABLED);
setLighting(Object3D.LIGHTING_NO_LIGHTS);
setTransparency(0);
build();
getMesh().setVertexController(new RayVertexController(),
IVertexController.PRESERVE_SOURCE_MESH);
compile(true);
}
and run periodically following method to change its shape:
public void initialize(SimpleVector from, SimpleVector to, double scale, Color color,
int transparencyMode)
{
setVertexes(from, to, (float) scale);
setAdditionalColor(color);
setTransparencyMode(transparencyMode);
getMesh().applyVertexController();
touch();
setCenter(SimpleVector.ORIGIN);
setOrigin(SimpleVector.ORIGIN);
getRotationMatrix().setIdentity();
setRotationPivot(SimpleVector.ORIGIN);
}
Unfortunatelly I do not see any change on screen, ie. object is always displayed at it initial place (ie. first position that was set).
Is there anything more that needs to be set?
Thanks,
Wojtek
Can you post some log output? Seems actually ok to me at first glance...
In addition, you may want to try the official 1.20 version instead of the 1.21 beta that i uploaded yesterday to see if that behaves any different. I've changed some parts of that code, so maybe i broke something... ???
Wrote myself a test case...something seems to be wrong with applying the changes when using a threaded renderer, which the AWTGLRenderer is. I'll look into it...
Hi,
I have just come from work was going to write it now, but I see you have already reproduced it.
Thanks,
Wojtek
Should be fixed now, the jar has been updated. Please give it a try. In the process, i've removed animateSync() from Object3D, because there should be no need for it anymore.
Works good for me.
Thanks!
Wojtek
I don't understand under which conditions the old code was working at all...but obviously it did, because otherwise i should have noticed this bug earlier.