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.

DarkBASIC Professional Discussion / Limiting viewing angle with this code

Author
Message
Jediam
14
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 16th Jun 2012 01:46
Hello,

I am hoping someone could tell me how to modify this code so I can limit the viewing angle +- 45 degrees along the x-axis. This comes from Dark Physics.

If the player object(3) is limited to rotating between +- 45 degrees, so should the camera which is attached to it. I thought it would be as simple as limiting CameraAngleX# to a wrapvalue of 45 but this doesn't seem to work. The curveangle parameters are (destination angle, original angle, transition speed). As an example, if the OldCamAngleX# and CameraAngleX# are 0, and the mousemovey value increases, so should CameraAngleX# by its wrapvalue. The player object(3) should now rotate along the x-axis its curveangle (which is the transition distance between the OldCamAngleX# and "updated"CameraAngleX#)So if the xrotate object can be limited to +- 45 degrees, this might solve the problem. If I were to take the wrapvalue of the curveangle and limit the curveangle to 45 degrees...I don't know. I could use some help. Thank you.
Jediam
14
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 16th Jun 2012 04:46
I wound up solving the problem with this code:

If you wish to adjust the limiting angle, just adjust the WrapAngle variable. Take Care
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Jun 2012 13:22 Edited at: 16th Jun 2012 13:23
Btw, this is know as Clamping. To clamp a value so it doesn't go beyond it's limits. If you have IanM's Matrix plugin it's worth investing in for all the added maths commands and not just that, it a plugin that you must get cause some things are just impossible to do in DBP without it. Then you can do this:

CameraAngleX# = clamp(CameraAngleX#,-WrapAngle,WrapAngle)

I remember age's ago before there was this command I wrote my own function. It's a bit mad:



Join or Support!
Jediam
14
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 16th Jun 2012 15:49
Thanks for the code and info Sasuke. My guess is that the clamp() command is only available in IanM's Matrix plugin; I haven't seen it within DBP's native command set (unless I just missed it).

Login to post a reply

Server time is: 2026-07-07 15:09:28
Your offset time is: 2026-07-07 15:09:28