Jump to content


Photo

3d Mouse Orbit


  • Please log in to reply
2 replies to this topic

#1 starfire_64

starfire_64

    Galactic Flame

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

Posted 20 March 2012 - 07:52 PM

Hello, everyone!

I got help for dragging around a 2D view, and now I modified it for 3D! Here is the code:


Create Event
global.camera_distance=200
  global.camera_updown=40
  global.camera_direction=45

End Step Event
if(mouse_check_button_pressed(mb_left))
{
	xs = window_mouse_get_x()*.2;
	ys = window_mouse_get_y()*.4;
}

if(mouse_check_button(mb_left))
{
	xe= window_mouse_get_x()*.3;
	ye= window_mouse_get_y()*.4;
	global.camera_direction += xs-xe;
	global.camera_updown += ys-ye;
	xs = xe;
	ys = ye;	
	if global.camera_direction < 1 then {global.camera_direction = 1}
	if global.camera_updown < 1 then {global.camera_updown = 1}
	if global.camera_direction > room_width-760 then {global.camera_direction = room_width-760}
	if global.camera_updown > room_height-500 then {global.camera_updown = room_height-500}

}

Draw Event
{
 // SET CAMERA PROJECTION
  // FROM CAMERA X,Y,Z
   xf=room_width/2+lengthdir_x(global.camera_distance,global.camera_direction)
   yf=room_height/2+lengthdir_y(global.camera_distance,global.camera_direction)
   zf=global.camera_updown
  // TO PLAYER X,Y,Z
   xt=room_width/2
   yt=room_height/2
   zt=0
  d3d_set_projection(xf,yf,zf,	xt,yt,zt,   0,0,1);
 // SET COLOR AND TRANSPARENCY
  draw_set_alpha(1);
  draw_set_color(c_white);
   // DRAW FLOOR
 }

Original Topic

Edited by starfire_64, 20 March 2012 - 07:53 PM.

  • 0

#2 epicpiedude

epicpiedude

    Artist/GameDeveloper

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

Posted 11 July 2012 - 12:41 PM

deserves a bump!
  • 0

#3 justwilliambrown

justwilliambrown

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8.1

Posted 11 September 2012 - 05:47 AM

Really didn't help. Made al my walls disappear and no gain =(. Sorry, but it didn't help. DX
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users