• Advertisement


This topic is now archived and is closed to further replies.

Urgent! Need reply asap...

This topic is 5717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sorry if this is blunt but i really need a solution to this problem quickly. Here''s the question: I am trying to create a function that captures the vertexes contained within a mouse''s selection field. Basically what i do is I drag the mouse across an area, and it does a check to find out if the vertexes (which are glfloats) are contained within the area i dragged across. Here is how I went about: 1. records the first mouse down X,Y coordinates 2. records the X,Y coordinates when mouse up 3. passes to a function the 4 coordinates. Note: The scale mode of the picturebox is PIXELS. (This is vb, but you can give me c++ solutions) Now I am in desperate need of a way to convert the 4 cordinates from pixels to the floats of the 3d world cordinates. For example, the pixel for the oldX mouse cordinate is 300. I need the formula or a way to convert that 300 to a float as used in the 3d world data files. If you still do not understand, here is the solution that I got which doesn''t quite cut out.
''this is for the top down viewport 
Public Sub Check(oldX As GLfloat, oldY As GLfloat, _
    newX As GLfloat, newY As GLfloat)

    picRight = Form1.picCamera.ScaleLeft + Form1.picCamera.ScaleWidth
    picBottom = Form1.picCamera.ScaleTop + Form1.picCamera.ScaleHeight

    ''this is to center the x and y cord
    oldX = oldX - (picRight / 2)
    oldY = picBottom / 2 - oldY
    newX = newX - (picBottom / 2)
    newY = picBottom / 2 - newY
    ''this working is supposed to do the conversion
    oldX = 2 * (oldX + Look(1).x / 2)
    oldY = 2 * (oldY - Look(1).z / 2)
    newX = 2 * (newX + Look(1).x / 2)
    newY = 2 * (newY - Look(1).z / 2)

however I end up with large results like -111 or 52, which can''t work well with the tiny 3d cords like 0 or -1. Your help is greatly appreciated.

Share this post

Link to post
Share on other sites
it''s an assignment due in a few hours. and i still can''t figure it out. but it''s ok i''m not forcing anyone to answer.

Share this post

Link to post
Share on other sites
Oooh! thanks. i''ve found an alternative (which isn''t very applicable) i just divide the result by 100 which gives around the same wavelength of figures as the 3d coords

Share this post

Link to post
Share on other sites

  • Advertisement