PolyLine update

Started by madhava.s, February 10, 2013, 04:38:29 AM

Previous topic - Next topic

madhava.s

I'm using PolyLine to draw line between 2 cubes. But updating the position of polyline after cubes are translated& rotated isnot taking effect.

Initial set up -- works fine
bounds=toy.getMesh().getBoundingBox();
                SimpleVector vec1=SimpleVector.create(
                        (bounds[0]+bounds[1])/2,
                        (bounds[2]+bounds[3])/2,
                        (bounds[4]+bounds[5])/2
                        );
                bounds=toy3.getMesh().getBoundingBox();
                SimpleVector vec2=SimpleVector.create(
                        (bounds[0]+bounds[1])/2,
                        (bounds[2]+bounds[3])/2,
                        (bounds[4]+bounds[5])/2
                        );
Polyline line1=new Polyline(new SimpleVector[]{vec1,vec2}, Color.GREEN);


Code used to update line position
line1.update(new SimpleVector[]{toy.getTransformedCenter(),toy3.getTransformedCenter()});

[attachment deleted by admin]

EgonOlsen


EgonOlsen

Works just fine for me and looking at the Polyline code, i can't see any reason why it shoudn't work. I don't get your example anyway...why are you creating a Polyline with the center of the bounding boxes in world space (which will most likely be both 0,0,0) and update them with the transformed center afterwards? And what's wrong with the screen shot? It looks exactly like what i would expect this code to do.

madhava.s

I'm creating a plane on which cubes are added as children. When user drags mouse  from one cube to other a line is drawn between them. Plane is rotatable. When plane is rotated cubes rotate with them, but not poly line, hence tried to update polyline. It din't work looks as in below image. Is there any way I can add polyline as child to plane ?

[attachment deleted by admin]

EgonOlsen

Quote from: madhava.s on February 11, 2013, 06:40:52 AM
Is there any way I can add polyline as child to plane ?
No. Your way to update it seems fine to me and i can't reproduce this problem. The update()-method works fine for me. Please try the latest beta and see if that helps: http://jpct.de/download/beta/jpct.jar

madhava.s

Thanks Egon,
  Works fine tried with latest and Beta both of them work.