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 Discussion / Rail Camera

Author
Message
smhillis
18
Years of Service
User Offline
Joined: 10th Oct 2006
Location:
Posted: 11th Oct 2006 05:15
Hoping someone could help me with implementing a camera on "rails"
were I pre determine its path ,lightgun games, cutscenes etc..

The best I can come up with is embedding each camera direction/angle movement into a for loop and then another loop for the next movement and so on. This would amount to hundreds of for loops or so, depending on the length of the scene.

Does anyone know of a better way to do this?

Thank you
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Oct 2006 14:46
You see, a comon technique for AI is waypoint system. But this technique could also be used for the camera. If you write a function, that uses for example data statements, and make the camera go smoothly from one point to another then you'll have a nice "rail" effect like you want.

Ofcourse, this isn't AI, so more information will be needed. Like rotation, movement, coordinates etc.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 14th Oct 2006 12:40 Edited at: 14th Oct 2006 23:50
smhillis,

I believe that Sven B's idea with an added curvature calculation between each waypoint would be a great way to create a rail effect. Maybe Bezier curves! I will check around the web and see what I can come up with. Sounds like a project needed to be learned.

[EDIT] CLICK HERE to go to an excellent page and an excellent visual model of a method for bezier curve calculation. I am spending a bit of time to see what kind of multiusable rail system I might be able to create with these concepts.
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 15th Oct 2006 03:39 Edited at: 15th Oct 2006 03:45
Well, I have the base for a simple quadratic bezier curve calculator. However, the program does not function fully correctly, yet. I believe this is due to the sin and cos maths, in which I have never learned except by experimentation in DBC.

I will try to work the bugs out of the program and get it operating correctly by the end of the night. After this is functional I will move onto making it more dynamic, as to say that I wish to program a designable rail system, for use with anything that takes coordinates, like the camera object or any other object...etc. I would also like to investigate 3D bezier curves, which shouldn;t be too tricky after the simplistics are understood by me.

I also wish to enable a curve to be converted into a waypoint system at any given resolution, for any programs that can sacrafice some smoothness for effieciency. Then last bu not least, implemeting a vector system, which should be a breeze, for object rotation along the curve.

Until I fix these bugs, maybe anyone would like to help the process out. My code so far is below. The code is a little messy due to it being a roughdraft. However, I commented throughout and used variable names(where plausible) in place of hardcode values, which should make the program a little easier to understand. Also, check out the link I posted last, it is the idea I am trying to mimic.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Oct 2006 06:45
A bezier curve is an interesting approach to waypoint creation. It definately would allow finite limits in creating the curve to have a certain proportional representation.

Another approach might be to start with a 2d screen that has some x and y dimensions, say 100x100.

Use the mouse and click and drag it across the screen. Whereever the mouse is clicked, the x and y coordinates are recorded in an array. Translate this array to a matrix and scale it up based on it's size. Plot the the x and y from the array to the matrix x and z and you have your railcam path.

Add a speed control, rotation and orientation to the camera and voila.

Enjoy your day.
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 15th Oct 2006 09:33 Edited at: 15th Oct 2006 11:23
Latch,

I'll have my revised code up and running in just a bit. I have always wanted to approach bezier curves, or any type of curve at that. Reason being, there are a wide variety of problems in which they can be used to udertake them.

Where has smhillis been...?
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 15th Oct 2006 10:31 Edited at: 15th Oct 2006 10:54
Alrighty, the first test is finnished...a quadratic bezier curve calculator.



Next, I will try to implement higher-order bezier curves. This, and a goal towards an understaning of creating a connectable bezier curve path.

So far this seems to have started out on the correct foot, unlike most projects I begin.
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 15th Oct 2006 10:59
*Update*

Curve resolution can be adjusted by the value given at line #15...

...along with chaning line #73 to...

However, segmentstepincrease#, for now, must be set to a multiple that is clearly divisible by 1.00. Later on, in the coming days I will get or create a function for rounding any number to its rightful value.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Oct 2006 16:23
@smhillis
Sorry for stepping on your thread...

@CreamPie
I'm not up on my quadratic curves, or my conic equations, but looking at your code, I seem some equations that look like they apply to ellipses.

Now I could be way off on this, so correct me if I am wrong. Looking at your code, it looks to me like you are switching the Y and X components... what I mean is, in the following equations:



it looks to me like you are calculating X with sin and Y with cosine. It's hard to tell because you identify your variables in terms of basepoint, quadpoint, etc instead of x and y in the names of the variables so it's hard to track down.

I looked further in the program and saw your function for calculating the angle. You use atanfull() and you have x in the first position and y in the second. Correct me if I'm wrong, but I'll bet when you ran the first simulation you were confused because the curve went off the page or in an opposite direction... I bet you originally had X calculated with cos and Y calculated with sin, but you were able to correct the behavior by switching the sin and cos.

The reason I suspect this is because I had all kinds of problems calculating polar coordinates, directions, angles, curves, etc. using atanfull(). I had to review C to find what the problem was. What I discovered, in order for atanfull() to match cos(), sin(), tan() and the other trig functions, you have to switch the x and the y position. It will then calculate correctly. So, when you write



To behave with the other trig functions (and general maths) you would write:



This will prevent you from switching the x = r*cos(theta) y = r*cos(theta) generality when calculating arcs.

Hopefully this is useful to you. Here's a "proof" that I ran to test atanfull() against other trig functions:



and here's a link to when I discovered the problem

http://forum.thegamecreators.com/?m=forum_view&t=88216&b=7

Enjoy your day.
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 15th Oct 2006 19:30
Latch,

Very good information there. Thank you for the input. I am in a hurry right now, but will post later, hopefully with an update to the curve calulator.
smhillis
18
Years of Service
User Offline
Joined: 10th Oct 2006
Location:
Posted: 16th Oct 2006 01:35
Sorry for the late response. I am somewhat new to 3D programming and this topic is a little advanced for me right now. However I have been studying the links you provided and I am extremely impressed with your simulation. Hope to learn more as I study your source code.
CreamPie
18
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 19th Oct 2006 08:50 Edited at: 19th Oct 2006 08:51
smhillis,

I appreciate the reverance, and am sorry for taking over the topic. The project is definitely just a simulation. Unfortunately, I do not understand the bezier curve formula(s), but this method seems to be working so far.

I have sprung several ideas from this experiment, and soon wish to open up a thread in the WIP. However, I must first come to my next milestone, which is to create a set of functions that can create, edit, delete and control a bezier path. These functions can be combined with another's program, enabling for an array of features.

However, I will explain the ideas later on when I open up the thread. I will post here when I open the thread, just in case anyone would like to know.

Smhillis, I am still fully active in this topic thread of yours. So, I will be posting updates to you of anything I can figure out, and will explain what I have time to.

Login to post a reply

Server time is: 2025-05-25 22:45:41
Your offset time is: 2025-05-25 22:45:41