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 / Problem regarding move camera left from IAN M's plugin

Author
Message
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 20th Nov 2015 12:22
DBPRO compile the code when i am using the following codes: move camera left and move camera right, but the application doesn't run.

Any ideas on how can fix this?

Thank You!
Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 20th Nov 2015 16:36 Edited at: 20th Nov 2015 16:39
If those are the only functions causing the problem. You can use this instead.

MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 20th Nov 2015 17:04
This works extremely well!

Can you explain the code so i better understand it? I am stuck at "rotate camera camID, 0, wrapvalue(sy+90), sz"

Why do we put twice rotate camera?

Thank you very much.
Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 20th Nov 2015 17:29 Edited at: 20th Nov 2015 17:40
The directions right, left, forward and backward are typically on the x/z plain. The Move Camera function will move the camera forward. By rotating it 90 degrees on the y axis then moving the camera the specified distance and then setting the camera angles back, effectively moves the camera right.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 20th Nov 2015 17:43
Actually this may be better.

MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 20th Nov 2015 18:01
I understand partially but i still don't understand fully why rotate camera 0, 0, wrapvalue(cammovy# -90), cammovz# and why rotate camera 0, cammovx#, cammovy#, cammovz# .

why is there -90 and twice.

Sorry for the inconvenience.
Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 20th Nov 2015 18:40
Now I’m confused. Maybe this will help.

MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 23rd Nov 2015 12:55
Yep, thats more like it.

I do have another question, i am controlling the camera using those WASD keys and the mouse through this code:



This is present in multiple functions. Every time when i am exiting one function and it get in another, the camera jumps in other angle instantly when i am pressing the right click mouse button. I want to stay in the same angle when i exited the function.
Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 23rd Nov 2015 18:35
Your function seems sound in itself. If you could work up a quick snippet demonstrating the problem, it would be easier to solve.
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 24th Nov 2015 12:01
Alright, this is the code example with the mouse control over the camera code:

Alex Matei CEO
www.alexmatei.com
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 24th Nov 2015 18:28 Edited at: 24th Nov 2015 18:41
By using "mousemovey() = 0" you are not resetting the movement, so it keeps tracking the movement of your mouse, and when you come back with the rotation of the camera it will jump because the value is big.


try to do this instead:



Remember to set mouseMovX# and mouseMovY# as globals.

Also if you keep aligned "if" "else" and "endif" the code will be more readable.

Edit:

I have also changed the code to add the wrapvalue command so that when the rotation goes over 360 degrees it will restart to count from 0.

Example: 350 +50 will not be 400 degrees (which would be wrong as rotation degrees goes up to 360) but the new value will be 40 degrees.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 24th Nov 2015 18:51
If you are just wanting both scenes to share the same camera angles, you need to make the x# and y# variables global. I have rewritten your code in this snippet demonstrating this solution.



However, if you want to preserve the camera angles for each scene, you’ll need to store the camera angles for each scene globally. Something like this.

MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 24th Nov 2015 20:23
Hello Cescano, Hello, WickedX,

Well, problem solved, thank you for your awesome help!

The problem was as WickedX said, to make x# and y# as globals, i totally forgot about that and that is the simplest and logical explanation, to make them global to read the values throughout the entire application.

Thank You again!
Alex Matei CEO
www.alexmatei.com

Login to post a reply

Server time is: 2024-04-26 21:36:15
Your offset time is: 2024-04-26 21:36:15