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 / How to make the camera move in it's own z-axis?

Author
Message
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 13th Nov 2012 05:32
Whats the best way to move the camera in it's own z-axis independent of it's orientation? I can do it in it's own "x" axis with the "move camera right" (Matrix1 dll) command but I can't find the command or code a working function to do it right.

This is for moving over a terrain with a camera that can change it's viewing angle with the middle mouse button.

Thanks-

Home is where my souped-up computer is...
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 13th Nov 2012 06:15
Have you tried the 'move camera' command? Moving along your own local z-axis is the same as moving forward, the way you're facing. I may have misunderstood the problem though.

"everyone forgets a semi-colon sometimes." - Phaelax
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 13th Nov 2012 11:19
EZ Rotate

That will fix all your rotational problems, there is a basic free version floating on the forums, so you can try that before committing if you are interested in it...

Thinking about it, I should probably look for it too sometime soon...

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 13th Nov 2012 12:41 Edited at: 13th Nov 2012 12:43
It seems you want to move a camera forward, that is not facing forwards.

There are a number of ways to do this; my two prefered methods are:





They both do the same thing, and your camera will look in what ever direction you like, whilst moving in a set direction. Use Terrain ground height to clamp the camera's Y position.

Add some Sin/Cos math to add character bobbling; and some random math to give it mild camera shake.

basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 13th Nov 2012 17:19
it's all good, however, if you have "Matrix1Util plugin 09" then you can have these commands:

move camera right
move camera left
move camera up
move camera down



JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 14th Nov 2012 12:19 Edited at: 14th Nov 2012 12:47
Chris, I am at a loss on how to apply your snippet to my program and have it do what I need for it to do.

Let me re-explain what I need to do.

If I click on the left mouse button, it moves the camera in it's own independent x-asis direction, as well as it's own independent z-axis direction.

I also need for the mouse wheel to zoom in and out of the camera position on the terrain. as well as using the mouse button wheel to rotate around that "focal point" on the terrain.

I thought this would be simple to do in DBPro....but I guess not-

I'm just about at wits end....I would hate to have a project die because of the camera limitations within DBPro.

here's the link to the thread that has the code I am using...

http://forum.thegamecreators.com/?m=forum_view&t=201398&b=1

Home is where my souped-up computer is...
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 14th Nov 2012 14:13 Edited at: 14th Nov 2012 14:17
I seemed to have found a work-around.....I made a "dummy" object and had the camera track that object position. As I rotated the terrain view, I rotated the object in kind so I was able to achieve what I needed.

Whew-

Here's the new code for anyone who cares Just a few more tweaks and I'll have my ideal camera controls for my project-



Home is where my souped-up computer is...
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Nov 2012 19:38 Edited at: 14th Nov 2012 19:42
Ok it seems your view system is more sophisticated than I at first thought.

Using objects and limbs (even particles) to move and rotate cameras, other objects and vectors around is something I tend to do for complex movement systems. It's efficient, easy and concise. If you get into trouble, you could make use of limb and object commands, and track the object as you say; glue to limb is useful for this when dealing with pivot rotation.

You can shorten your code a little and boost performance in a few places, for example:

turn object right 2, XAng+90
move object 2, amount
turn object right 2, XAng-90


can be

Move Object Right 2, amount

Hope it goes well.

JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 15th Nov 2012 05:42
yea chris, I likes my programs nice and sophisticated but the code revision you stated doesn't work as I tried it.

As far as performance, I can deal with that down the road. For now this will do. Besides I only use the camera commands when the appropriate mouse buttons are used.

Home is where my souped-up computer is...
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 15th Nov 2012 10:17 Edited at: 15th Nov 2012 10:39
I think am completely mis-understanding what you are making; the code above is wrong! I did not spot your use of X Angle instead of Y Angle.

Quote: "turn object right 2, XAng+90
move object 2, amount
turn object right 2, XAng-90"


I'm not sure now why the object would need to rotate its Y angle based on its X angle, perhaps post up it in action some time, I want to see what you are doing.

(Note that if your program crashes or you find something strange is going on with angles; you might find that the turn object command is the cause. Use YRotate Object. I've seen turn object cause crashes with glue object active. And turn camera & object does not wrap its angle in degrees 360 degrees, it goes from -90 to 90, see for youself)



JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 16th Nov 2012 05:23
Chris, When I get home from work (I work 7pm to 3:45am) I'll post my newest code after I try your 'YRotate Object" Approach. I'll post the DBPro file and the 2 images that comprise the color and heightmap. If this project makes some real headway, I'll buy the Blitzwerks terrain plugin so my terrain won't be clipped at the top as you will see. Yes, they both are 512x512 wide images.

I already added the use of arrow keys in the code for quick and easy (independent)X/Y movement across the map. So far I like the results.

Home is where my souped-up computer is...
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 16th Nov 2012 12:28
here's the newest code:



I tried the YRotate Objcect command again with no success. I wonder, will DBPro (probably) crash if I "glue" an object to the camera dummy object, or is it if I glue ANY other object togeather with another object besides the dummy camera object?

Home is where my souped-up computer is...
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 16th Nov 2012 12:29
here's the color map attached...

Home is where my souped-up computer is...
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 16th Nov 2012 12:30
here's the heightmap attached...

Home is where my souped-up computer is...
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 18th Nov 2012 11:39 Edited at: 26th Nov 2012 11:22
here's what I have so far with the program. I'll start a new thread on this project if it proceeds further.

Home is where my souped-up computer is...

Login to post a reply

Server time is: 2026-07-08 06:45:35
Your offset time is: 2026-07-08 06:45:35