The gluUnProject should just be used to translate the coordinates of
your finger on the screen (x1,y1,z1), where z1 is 0...1, to a 3d
coordinate in your Kube space (x2,y2,z2).

You calculate it for z1=0 and z1=1, which gives you two coordinates in
Kube space, a line:
unproject(x1,y1,0) --> (Sx2,Sy2,Sz2) (start of line)
unproject(x1,y1,1) --> (Ex2,Ey2,Ez2) (end of line)

Then you have to calculate which squares your line (Sx2,Sy2,Sz2) -->
(Ex2,Ey2,Ez2) intersects.

The intersection point that is closest to your finger (i.e. when
moving from (Sx2,Sy2,Sz2) to (Ex2,Ey2,Ez2), the first point that is
intersecting), is the square your finger is touching. Don't count
squares that are facing away from you, if you have such squares (using
normals of the plane in which the square lies).

Brush up on your math from high-school :=) :
Figure out how to calculate a point that is the intersection of a line
and a plane.
Then limit this plane to just a square.

The 3d Kube coordinates of your squares are the ones in your vertex-
buffer..

On Jun 18, 10:30 pm, quill <quill...@163.com> wrote:
> Hi Boston,
> I failed with both GLU.gluUnProject or your gluUnProject.
> Maybe there is something wrong with my polygon coordinates. In fact,
> the polygon is just a square, which is the face of a small cube. I get
> the coordinates from GLWord.mVertexBuffer(such as mVertexBuffer.get(0)/
> 65536.0), is this coordinates the same kind with that which I got from
> gluUnProject? Are they both belongs to object coordinates?
>
> On Jun 19, 12:21 am, Streets Of Boston <flyingdutc...@gmail.com>
> wrote:
>
>
>
> > Yes, you are on the right track. :-)
> > However, i could not get gluUnProject to work. I wrote my own:
> >  http://groups.google.com/group/android-developers/browse_frm/thread/9...
> >   (see messages no. 6 and 8)
>
> > On Jun 18, 4:21 am, quill <quill...@163.com> wrote:
>
> > > Thank you Nightwolf.
> > > I want to choose the Kube when I touch on the Kube face in order to
> > > rotate Kube.
> > > My idea is:
> > > 1. to get vertices of Kube to compose a polygon(2D);
> > > 2. judge if the touch point locates in the polygon;
> > > As you said, the cube coordinates is not modified, so I use
> > > gluunproject() to change touch point coordinates(x, y, 0) in order to
> > > map window coordinates to object coordinates, and then I judged if the
> > > new touch point coordinates locates in the polygon. Am I on the right
> > > way?
>
> > > On Jun 18, 11:59 am, Nightwolf <mikh...@gmail.com> wrote:
>
> > > > Cube coordinates are stored in vertices array in Cube.java.
> > > > Rotating effect is achieved via model view matrix modification
> > > > (glTranslate and glRotate commands). Original vertex data isn't
> > > > modified.
>
> > > > On Jun 17, 8:30 pm, quill <quill...@163.com> wrote:
>
> > > > > Hi all,
> > > > > I'm modifying Kube(api demo) to a game, does anyone who know how to
> > > > > get the vertice coodinates of Kube? From the source code in api demo,
> > > > > I think GLWorld.mVertexBuffer may save the vertice coodinates after
> > > > > rotate the Kube, but I was wrong, the infomation in mVertexBuffer
> > > > > always remains the same.- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to