Author Topic: Compiled dynamic objects  (Read 4236 times)

Offline Wojtek

  • int
  • **
  • Posts: 62
    • View Profile
Compiled dynamic objects
« on: April 21, 2010, 10:54:44 pm »
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:
Code: [Select]
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:

Code: [Select]
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Compiled dynamic objects
« Reply #1 on: April 21, 2010, 11:39:35 pm »
Can you post some log output? Seems actually ok to me at first glance...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Compiled dynamic objects
« Reply #2 on: April 22, 2010, 07:16:56 am »
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... ???
« Last Edit: April 22, 2010, 10:19:04 am by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Compiled dynamic objects
« Reply #3 on: April 22, 2010, 03:03:29 pm »
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...

Offline Wojtek

  • int
  • **
  • Posts: 62
    • View Profile
Re: Compiled dynamic objects
« Reply #4 on: April 22, 2010, 07:29:33 pm »
Hi,

I have just come from work was going to write it now, but I see you have already reproduced it.

Thanks,
Wojtek

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Compiled dynamic objects
« Reply #5 on: April 22, 2010, 08:47:21 pm »
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.

Offline Wojtek

  • int
  • **
  • Posts: 62
    • View Profile
Re: Compiled dynamic objects
« Reply #6 on: April 22, 2010, 09:18:48 pm »
Works good for me.

Thanks!
Wojtek

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Compiled dynamic objects
« Reply #7 on: April 23, 2010, 08:00:40 am »
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.