Jump to content


Photo

How do I make a 3D object move?


  • Please log in to reply
8 replies to this topic

#1 antonrules

antonrules

    GMC Member

  • New Member
  • 13 posts
  • Version:Unknown

Posted 30 August 2011 - 12:08 AM

I'm trying to learn how to make a basic 3D game. I have my camera set up and i can load external models. My question is, how do i make a D3D model move? I've searched hard but can't find any tutorials on the subject. Please help.

EDIT: Its a top view 3D shooter.

Edited by antonrules, 30 August 2011 - 08:56 PM.

  • 0

#2 jhett6

jhett6

    GMC Member

  • New Member
  • 54 posts

Posted 30 August 2011 - 12:26 AM

do you mean like actually move??? or animated???
  • 0

#3 antonrules

antonrules

    GMC Member

  • New Member
  • 13 posts
  • Version:Unknown

Posted 30 August 2011 - 04:24 PM

do you mean like actually move??? or animated???

Move, pressing the arrow keys will move it forward, backwards, left, and right. And it will face it's movement direction.
  • 0

#4 antonrules

antonrules

    GMC Member

  • New Member
  • 13 posts
  • Version:Unknown

Posted 30 August 2011 - 04:26 PM

Movement is up to you. When you draw the model with d3d_model_draw the arguments allow you to specify the x, y, z LOCATION of the object which can be used to calculate it's MOVEMENT. The object can also be rotated around the origin of its transform as well to animate it. But this appears too complicated for you atm, so I suggest you go back and learn allot more about how GM works in the 2nd dimension or if you are really bold take a crack at the 3D fps tutorial on the YYG's site here.

I already made several 2D games. And I'm not sure but I think that 3D movement requires "transformations"?
  • 0

#5 Glance

Glance

    GMC Member

  • GMC Member
  • 323 posts
  • Version:GM8

Posted 30 August 2011 - 04:32 PM

You would only need transformations if you wanted the object to rotate. In what you described above you probably want something like this:
d3d_transform_set_identity();
d3d_transform_add_rotation_z(direction);
d3d_transform_add_translation(x,y,z);
//draw the 3D object here, make sure you draw it at (0,0,0)
//example drawing a cube:
d3d_draw_block(-8,-8,0,8,8,16,-1,1,1);
d3d_transform_set_identity();

If you want to know how to actually change the x, y, and z when a user presses a keyboard key, then you should learn how to do that in 2D before trying it in 3D because it's pretty much exactly the same.
  • 1

#6 Sinaz

Sinaz

    MCP Killer

  • Retired Staff
  • 2751 posts
  • Version:GM8

Posted 30 August 2011 - 06:30 PM

I'm trying to learn how to make a basic 3D game. I have my camera set up and i can load external models. My question is, how do i make a D3D model move? I've searched hard but can't find any tutorials on the subject. Please help.

EDIT: Its a top view 3D shooter.

In your searches... how did you miss the pinned "FAQ - Recommended Topic List" at the top of this forum?

http://gmc.yoyogames.com/index.php?showtopic=166081
  • 0

#7 programmmer5

programmmer5

    GMC Member

  • GMC Member
  • 359 posts

Posted 30 August 2011 - 06:33 PM

Movement is up to you. When you draw the model with d3d_model_draw the arguments allow you to specify the x, y, z LOCATION of the object which can be used to calculate it's MOVEMENT. The object can also be rotated around the origin of its transform as well to animate it. But this appears too complicated for you atm, so I suggest you go back and learn allot more about how GM works in the 2nd dimension or if you are really bold take a crack at the 3D fps tutorial on the YYG's site here.

So basically it's the same as 2D.

Or if you want.

X=x+4
X=x-4

Y=y+4
y=y-4

In the arrow key press event
  • 0

#8 antonrules

antonrules

    GMC Member

  • New Member
  • 13 posts
  • Version:Unknown

Posted 30 August 2011 - 08:55 PM

You would only need transformations if you wanted the object to rotate. In what you described above you probably want something like this:

d3d_transform_set_identity();
d3d_transform_add_rotation_z(direction);
d3d_transform_add_translation(x,y,z);
//draw the 3D object here, make sure you draw it at (0,0,0)
//example drawing a cube:
d3d_draw_block(-8,-8,0,8,8,16,-1,1,1);
d3d_transform_set_identity();

If you want to know how to actually change the x, y, and z when a user presses a keyboard key, then you should learn how to do that in 2D before trying it in 3D because it's pretty much exactly the same.

Thanks, it got my model moving.
  • 0

#9 Glance

Glance

    GMC Member

  • GMC Member
  • 323 posts
  • Version:GM8

Posted 30 August 2011 - 09:10 PM

Thanks, it got my model moving.


Glad to help :)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users