www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: gamenewer on January 06, 2015, 11:41:48 am

Title: How to caculate the screen position?
Post by: gamenewer on January 06, 2015, 11:41:48 am
Hello , I use a picture to show my question.  I use framebuffer.blit  to show a far scene in my game, as red part in picture, the far scene position at the road end ( maybe not the end , as far as see ,hope you can see my mean). My question is : How to caculate the Y position?(as blue line show in picture),  Thanks ! :)
Title: Re: How to caculate the screen position?
Post by: EgonOlsen on January 06, 2015, 05:29:40 pm
http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Interact2D.html (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Interact2D.html) has some methods to do such things. In your case, you might want to look at the project3D2D-methods.
Title: Re: How to caculate the screen position?
Post by: gamenewer on January 07, 2015, 01:05:34 am
Thank you Egon, I try use this method :project3D2D(Camera camera, FrameBuffer buffer, SimpleVector vertex), I only know the  y=0  of  the vertex parameter, becuse  the road  place on the groud( y = 0),  I have no idea  how to set the  parameter vertex.  Could you help me ? Thanks !
Title: Re: How to caculate the screen position?
Post by: gamenewer on January 08, 2015, 01:59:27 am
Any one help me?  thanks   ;)
Title: Re: How to caculate the screen position?
Post by: EgonOlsen on January 08, 2015, 08:29:08 am
You need some vertex at the end of the road. Either take it from the mesh or create it out of the data that http://www.jpct.net/doc/com/threed/jpct/Mesh.html#getBoundingBox() (http://www.jpct.net/doc/com/threed/jpct/Mesh.html#getBoundingBox()) returns.
Title: Re: How to caculate the screen position?
Post by: gamenewer on January 08, 2015, 09:04:26 am
Oh , thanks , The road is closed,  the view position changed every frame, should I  create vertex  every frame?
Title: Re: How to caculate the screen position?
Post by: EgonOlsen on January 08, 2015, 09:50:22 am
Is that needed? The actual screen position of the end doesn't really change, or does it?
Title: Re: How to caculate the screen position?
Post by: gamenewer on January 08, 2015, 10:11:41 am
I show a picture, fisrt at  point  1 , the end at  the end_1 , if at the point 2 , the end at the end_2 .Yes, the actual screen position of the end doesn't really change, but  I don't  know   how to get the  correct vertex .
Title: Re: How to caculate the screen position?
Post by: EgonOlsen on January 09, 2015, 05:36:54 pm
Either choose a pragmatic solution and create a backdrop image that will still look good when there's a small gap between the road and the city scene or you could simply iterate once over all vertices after setting up the scene and the camera, project everything into 2D and choose the max y value of all.
Title: Re: How to caculate the screen position?
Post by: gamenewer on January 10, 2015, 12:50:59 am
A backdrop image may be a simple solution, i will try ajust y position  for diffrent  device screen size