www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: madhava.s on February 10, 2013, 04:38:29 am

Title: PolyLine update
Post by: madhava.s on February 10, 2013, 04:38:29 am
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
Code: [Select]
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
Code: [Select]
line1.update(new SimpleVector[]{toy.getTransformedCenter(),toy3.getTransformedCenter()});
[attachment deleted by admin]
Title: Re: PolyLine update
Post by: EgonOlsen on February 10, 2013, 10:26:50 am
I'll look into it...
Title: Re: PolyLine update
Post by: EgonOlsen on February 10, 2013, 12:39:40 pm
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.
Title: Re: PolyLine update
Post by: madhava.s on February 11, 2013, 06:40:52 am
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]
Title: Re: PolyLine update
Post by: EgonOlsen on February 11, 2013, 08:30:37 pm
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 (http://jpct.de/download/beta/jpct.jar)
Title: Re: PolyLine update
Post by: madhava.s on February 14, 2013, 03:31:46 pm
Thanks Egon,
  Works fine tried with latest and Beta both of them work.