Jump to content


Photo

Please help?


  • Please log in to reply
7 replies to this topic

#1 JohnnyK

JohnnyK

    GMC Member

  • GMC Member
  • 16 posts
  • Version:Unknown

Posted 04 June 2012 - 03:32 AM

How do I make a 3d floor turn to point toward the mouse...
also how do I fix it where the mouse isn't so bad off in 3d mode. Like you can slightly move the mouse but the mouse coordinates go miles out of the way... Please help
  • 0

#2 AlaskaGames

AlaskaGames

    TheGameCreator

  • GMC Member
  • 35 posts
  • Version:GM8.1

Posted 04 June 2012 - 03:36 AM

How do I make a 3d floor turn to point toward the mouse...
also how do I fix it where the mouse isn't so bad off in 3d mode. Like you can slightly move the mouse but the mouse coordinates go miles out of the way... Please help



How do you make a 3d floor turn towards the mouse?
  • 0

#3 Shasoos

Shasoos

    Dead Fish Lover

  • GMC Member
  • 397 posts
  • Version:GM:Studio

Posted 04 June 2012 - 08:38 AM

How do you make a 3d floor turn towards the mouse?
  • 0

#4 JohnnyK

JohnnyK

    GMC Member

  • GMC Member
  • 16 posts
  • Version:Unknown

Posted 04 June 2012 - 12:18 PM

How do you make a 3d floor turn towards the mouse?

Yes. Im making a top down 3d game with a 2d character and Im using d3d_draw_floor to draw that character, but he needs top turn to face the mouse...
  • 0

#5 Follomania

Follomania

    Unum Mirabile

  • GMC Member
  • 445 posts
  • Version:GM:Studio

Posted 05 June 2012 - 07:44 PM

Use the d3d_transform_add_* functions. If you look in the manual, you'll find all the transformations you'll need, as well as how to use them. You're probably going to want to rotate on the z-axis, if you're doing a top-down. Don't forget to use d3d_transform_add_translation()!
As far as the mouse coordinates go, mouse_x and mouse_y simply give you the cursors coordinates relative to the window on your screen plus the coordinates of the active view. They are not related at all to what is being drawn in the window. If your mouse remains in the center of the screen, then it's very simple to get the coordinates of where you're pointing to with the mouse

/*
xfrom, yfrom, zfrom, xto, yto, and zto are the corresponding arguments in d3d_set_projection()
*/
CamDist = sqrt(sqr(xto-xfrom) + sqr(yto-yfrom) + sqr(zto-zfrom))    /*Get the camera's directional vector's length*/
ZDist = zfrom/((zto-zfrom)/CamDist)    /*Get the z-component in the camera's directional vector, normalize it, and use it to find how many times you add it to itself to get to z = 0*/
MouseX = (xto-xfrom)/CamDist * ZDist + xfrom   /*Get the x-component of the camera's directional vector, normalize it, multiply it by the number of times we calculated above, and add it to the camera's looking location*/
MouseY = (yto-yfrom)/CamDist * ZDist + yfrom    /*Same as above, but with y*/

If your mouse is not located in the center of the window, you'll need to use Yourself's 2d-to-3d conversion scripts. Just search for them, and you'll find them. They're pretty common.
  • 0

#6 BattleRifle BR55

BattleRifle BR55

    Moo

  • GMC Member
  • 8249 posts
  • Version:GM7

Posted 05 June 2012 - 10:18 PM

If your 3D floor won't do anything special, you can just draw a sprite on the ground and rotate it like you would in 2D. You just have to use depth to control its z height.
  • 0

#7 Follomania

Follomania

    Unum Mirabile

  • GMC Member
  • 445 posts
  • Version:GM:Studio

Posted 05 June 2012 - 11:07 PM

That would work as well. If you're uncertain with depth, you can use d3d_transform_add_translation(0, 0, Z), to move it up to where you want it.
  • 0

#8 JohnnyK

JohnnyK

    GMC Member

  • GMC Member
  • 16 posts
  • Version:Unknown

Posted 06 August 2012 - 01:48 AM

Ok ... Im new at d3d and I have NO clue what any of this means
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users