>I need to get a object in 3D space to visually match the position of
>mouse in 2D space.

Well, of course, there are infinitely many positions in 3D space that
match the 2D mouse position. Which do you want? One in a plane
perpendicular to the camera's forward vector? Some other plane? On
the surface of a hemisphere?

Basically, you can just take the line between the camera position and
the point in the Hither plane indicated by the mouse, and intersect
this line with whatever shape you want to get your final 3D position.
But you do have to choose what that shape should be.

>I need to scale the movement of the 2D point by some factor in order
>for the 3D point to keep up with where the mouse actually is.
>
>I can not just move the object in 3D space.
>Im actually moving the 2D points and recreating the objects on the
>fly as needed.

Hmm, I didn't entirely follow you here, so if the above doesn't hit
the nail on the head, let me know and I'll try again.

>At 1:49 PM -0600 1/20/04, Chris Dillman wrote:
>
>>I need to get a object in 3D space to visually match the position
>>of mouse in 2D space.
>
>Well, of course, there are infinitely many positions in 3D space
>that match the 2D mouse position. Which do you want? One in a
>plane perpendicular to the camera's forward vector?

Yes.

>
>Basically, you can just take the line between the camera position
>and the point in the Hither plane indicated by the mouse, and
>intersect this line with whatever shape you want to get your final
>3D position. But you do have to choose what that shape should be.

I think Im lost here.

>
>>I need to scale the movement of the 2D point by some factor in
>>order for the 3D point to keep up with where the mouse actually is.
>>
>>I can not just move the object in 3D space.
>>Im actually moving the 2D points and recreating the objects on the
>>fly as needed.
>
>Hmm, I didn't entirely follow you here, so if the above doesn't hit
>the nail on the head, let me know and I'll try again.

Hm maybe I should describe the process of what is going on here.
That might make it clearer about what I need to do.

The 3D space is set up so that there is a 1x1 pixel mapping ala Joes 3D FAQ.

Im taking a series of points in a polygon in 2D space.
For each point I make a 3D object that represents it.

I then place these points into 3D space.

Now I want to drag these 3D points around so that they visually show
up where the mouse is.

>At 3:32 PM -0600 1/20/04, Chris Dillman wrote:
>
>>>Well, of course, there are infinitely many positions in 3D space
>>>that match the 2D mouse position. Which do you want? One in a
>>>plane perpendicular to the camera's forward vector?
>>
>>Yes.
>
>Ah, OK. So you want to take the equations used to convert from 2D
>to 3D coordinates for your 3D-sprite-sorta-thingy, and solve them
>for world coordinates given screen coordinates.

Reading how you phrased it Im not sure if that is it or not.

BUT...

1. this is for the paving stone project.

2. I think I will need what you said above for the level editor etc
for the tactics engine.

>
>That *should* be just a bit of algebra, but if it's not coming
>together, let me know and I'll try to help. I've done this in the
>past, but I don't have a good example handy.

I keep thinking it should be some easy trig.
But so far I have failed to implement anything that works.

So if you find the time to work on the problem that would be wonderful.

>At 3:32 PM -0600 1/20/04, Chris Dillman wrote:
>
>>>Well, of course, there are infinitely many positions in 3D space
>>>that match the 2D mouse position. Which do you want? One in a
>>>plane perpendicular to the camera's forward vector?
>>
>>Yes.
>
>Ah, OK. So you want to take the equations used to convert from 2D
>to 3D coordinates for your 3D-sprite-sorta-thingy, and solve them
>for world coordinates given screen coordinates.
>
>That *should* be just a bit of algebra, but if it's not coming
>together, let me know and I'll try to help. I've done this in the
>past, but I don't have a good example handy.

>Damn Im still getting no wear on this.
>
>Joe if you get the time can you look into it?

OK, let's see what I can dig up. ...Here we go:

Function ScreenToWorld(view as Rb3DSpace, X as Integer, Y As Integer)
As Vector3D
// Find the point in 3D space represented by the given
// point in the 2D rendering.
Dim dist As Double
Dim screenPos As Vector3D

That gives you a position within the Hither plane that corresponds to
the given X and Y.

Additionally, you may find this useful:

Function ScreenToYPlaneIntercept(view As Rb3DSpace, planeY as Double,
X as Integer, Y As Integer) As Vector3D
// Find the place at which a ray through the X,Y point in the
// given view would intercept a horizontal plane at planeY.

if v.y = 0 then
return nil // our ray is parallel to the floor, never intersects it
end if

t = -(Q.y - planeY) / V.y
return Q.Plus(V.Times(t))

End Function

This finds the position in a plane perpendicular to the Y axis, which
is in line with a given X and Y on screen. Useful if you're placing
or dragging items on a floor, and your floor is a Y plane.

Finally, if you need something even more general, here's the
intersection of an arbitrary plane with a line through two points
(for example, the camera position and a point found via ScreenToWorld
above):

Function PlaneIntersection(planeNormal As Vector3D, planeD As Double,
p0 As Vector3D, p1 As Vector3D) As Vector3D
// Find the intersection of the line from p0 to p1 with the given plane.