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.

Newcomers DBPro Corner / changing camera axis?

Author
Message
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 18th Oct 2006 16:03
Using dbpro

I am wanting to move the camera using the scroll wheel on the z axis to zoom in or out on an object.

This is easily accomplished. however when i change the angle of the camera to the matrix x or y axis and scroll it still moves in the predetermined way along the original z axis how do i change the axis of the camera so i can zoom in on an object no mater where the camera is or what direction its pointing. and please dont confuse this with me wanting an object to move toward the camera i am wanting the camera to change axis so i can move it along the new axis.
hope this was explanitory kinda hard to describe


so this as an example i want the camera to be able to move toward the object no matter witch way its facing

A child's dream never dies.
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 18th Oct 2006 16:53 Edited at: 18th Oct 2006 16:54
You could use the "move camera" command. But that would not create a system that switch axis, but it create a zooming effect.

I hope you find this code usefull (I manipulated yours a bit):
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 18th Oct 2006 17:09
Well that is kinda the entire point of my post. I know how to move a camera in several ways just need to know how to change its axes relative to position but thanks for the input all is appreciated

A child's dream never dies.
Zergei
19
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 18th Oct 2006 23:35 Edited at: 18th Oct 2006 23:36
Use algebra...



As you'll be zooming, the values you know are the following:

h - > hypothenus or something like that. Its the real distance in a 2d plane between your object and the camera, and it's along the x and z axis in this case.
90° -> this always the same and not used....

a or b -> if YOU are to use this angles, then yes, one or the other you should know it, if not, no worries, we can figure them out.

values to discover...

x and z -> the distance in x and z from the object to the camera, basically it would be object position x(o)+x and object position z(o)+z to find the position of the camera.

How to solve it... many ways, specially depending of wich angle a or b you using. If none, then its the same but with 1 more calculation before it.

x = cos(a)*h or x = sin(b)*h
z = sin(a)*h or z = cos(b)*h

If a and b are unknown values, then do this before the x and z calcs...

a = atanfull( object position x(o)-camera position x(c) , object position z(o)-camera position z(c))

b = 90 - a

A little example...



As you can see, a# represents the angle an it's independient from the cameras angle, even thought i told the camera to point to the object, it shows that you can change the camera's angles and it will still zoom to the object. To this you can also work around to also include the Y axis, it's basically the same...

Further on my stuff at...

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-27 05:28:20
Your offset time is: 2024-11-27 05:28:20