Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Mouse to rotate around an object?

Author
Message
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 21st Oct 2010 01:37
How would I do this? I want the mouse to be able to rotate around then object on the Y axis only, so the mouse cant make it move up or in or out on left and right around my sphere (object 1)

Current code:


Always program as if the person maintaining your program is a psychopath that knows where you live
Dodga
14
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 21st Oct 2010 09:54
You need to change your dbPositionCamera to

dbPositionCamera(dbCameraPositionX()+dbCos(dbObjectAngleY(1)-75), y-75, dbCameraPositionZ()+dbSin(dbObjectAngleY(1)-75));

dbPointCamera(X, y, z);

This uses some trig to place the camera based on the objects angle, then points it at the object.

I'm assuming this is what you wanted, this gives you the typical third person perspective.

Rotating the object with the mouse would be something like this:

int mousmove;

mousemove=dbMouseMouseX();
dbYRotateObject(1, dbObjectAngleY(1)+mousemove);
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 22nd Oct 2010 02:25 Edited at: 22nd Oct 2010 02:26
Thanks I tried this in my loop and I cant move my camera:
//Camera

I do not want to be able to rotate the object, ONLY the camera. its kinda working but it glitches.

Always program as if the person maintaining your program is a psychopath that knows where you live
Dodga
14
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 22nd Oct 2010 05:14
Okay, sorry about that, try:
beginning of program:
float mousemove;

dbPositionCamera(dbObjectPositionX(1)+dbCos(mousemove)*75, y-75, dbObjectPositionZ(1)+dbSin(mousemove)*75);
dbPointCamera(x,y,z);
mousemove=mousemove+dbMouseMoveX();

Take out: You dont wanna rotate the camera, we need to rotate the angle on which the sin and cos is cast.
//dbYRotateCamera(0, dbObjectAngleY(1)+mousemove);

Login to post a reply

Server time is: 2024-11-19 16:41:52
Your offset time is: 2024-11-19 16:41:52