Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (Martin_HH, steyr, alibaba), 509 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Requesting Help With Zero Gravity Motion #293072
10/09/09 06:41
10/09/09 06:41
Joined: Oct 2009
Posts: 8
L
Lance Offline OP
Newbie
Lance  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 8
Good evening, everyone. I'm currently working on a script to move a spaceship around the screen in 3d space. Currently, I have rotations set up, along with a drifting momentum code. IE, she'll spin until you fire your thrusters to counter the spin and such. I even managed to set up a command to zero the pitch, yaw and roll of the spacecraft.

Vectors are something that I admittedly don't understand just yet. I beat a new shape into my forehead with the desk just getting this far laugh I'm running into trouble with another ability I am trying to set up. At the moment, I'm trying to create a command that will zero the translations along a particular heading. IE, if the ship is facing a given direction, but travelling in another, this command would use vector thrusters to get rid of the horizontal and vertical motion differences between the travel path and the true heading of the object. It would, however, leave the forward/backward motion alone.

The code that I do have (which is regrettably unavailable, as I am at work) seems to zero y and z motion and preserve x motion. Unfortunately, this is according to the world coordinates system, and the object only ever zeros according to that. Needless to say, this is not quite what I was hoping to achieve.

As vectors are, at this point, the bane of my existence, I was wondering if anyone could explain - rather than revising code - just how these kinds of conversions are supposed to work. IE, using the local rotation of an object, and gleaning from that, which way it is facing, how fast it is going, etc. I want to stay away from the physics engine for this part, as that kind of thing would likely be tedious once you have a bunch of objects moving around.

I'm only working with one object in relation to the world origin at the moment. Ideally however, I would like to eventually make it so that these operations (zero translation, heading, opening/closing speeds and such) will work with a given target, allowing you to freely drift with them and such.

That is clearly down the line, as I have to get more comfortable working with vectors, angles and the like before I can go about doing such things. I've looked through the manual and the c-lite workshops. Unfortunately, it doesn't quite help me wrap my brain around vectors just yet. What this novel-long-debut-post essentially mounts up to is this: Does anyone have another way of explaining vectors and their operations in order to help me figure out this silly little problem I'm running into?

Look forward to hearing from all you lite-c programmers out there!
-Lance

Re: Requesting Help With Zero Gravity Motion [Re: Lance] #293082
10/09/09 08:33
10/09/09 08:33
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
First of all, welcome aboard. You're in for stormy seas... grin

Forgive me if i jump around a bit, but Im OK at describing things, but pretty horrible at thinking in a straight line.

Firstly, you need to be aware that "vector"s in 3DGS is a pretty badly used term in any documentation, and in this forum.
This is because in 3DGS, the VECTOR type is really just a set of three variables, of type VAR, tied together.

So they get used for storing colors, angles, 3d positions, 3d velocities, and quite a few other 'chunks' of data.
And this community, myself included, tend to lump them together under the heading "vectors".
LATER ON you will find there are specific types for many of the above 'chunks', but we will still call them vectors.
This is because, for the most part, they behave the same as actual VECTORs, and almost all engine functions
continue to treat them all the same.
And some of us 'dirtier' programmers continue to use the VECTOR type, even thought types like COLOR and ANGLE exist.

So you may need to go outside the 3DGS community to come to grips with the concepts of vector maths and EULER angles.
I know I had to. No 3DGS tutorials or documentation helped me at all.
It got something to do with the shape of my brain, Im sure.

So hit the Google on anything to do with 3D spacial-manipulations.
3d modelling software tutorials worked well for me, especially the lightwave ones.
You dont need the program in question, just read their first few tutorials on the concepts of 3D space and
its manipulation and measurement. Eventually you'll find one that suits you.

And thats just to get you started.... hehehe.
I think its a little hard to try to explain vectors better than that without diagrams, and I cant do them.

But if you have any more specific questions about vectors, ask away.
I will endeavour to answer as best I can.
And if I cant help, someone else will. This is, Ive found, a VERY helpful forum community.

Best of luck, and see you around...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Requesting Help With Zero Gravity Motion [Re: EvilSOB] #293128
10/09/09 13:42
10/09/09 13:42
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline
Senior Member
sadsack  Offline
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
go here lost in thought is a good frind, here put this up for me.

http://www.mapmasterz.com/lit/VectorsCHM.chm


I have A7 Commercial .............. Now I just need to learn how to use it

Re: Requesting Help With Zero Gravity Motion [Re: EvilSOB] #294098
10/16/09 09:13
10/16/09 09:13
Joined: Oct 2009
Posts: 8
L
Lance Offline OP
Newbie
Lance  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 8
Good evening again!

@sadsack - Thank you very much for the link laugh Bit by bit, it's getting a little more clear as I go along laugh

@EvilSOB - Well I've been digging through the 'net, and so far it seems pretty straightforward. I've been working with 3ds max for about the past 12 years. I've never had any trouble working with that program - though I admit I've never even touched the scripting language for it.

That being said, I guess I'm mostly having trouble figuring out how the game engine interprets things. I've noticed that c_move has seperate movement vectors based on world coordinates and local movement vectors based on the orientation of the object. The way the code works so far is, based on keyboard input, it adjusts the speeds of rotation one way or the other. So far, the rotation code seems to work just fine. The movement code is only working along the forward / backward motion of the object. I've been using a heavily modified (see: hacked to pieces by an amateur) version of the space flight workshop by Vertex and threw it into the 10th workshop level to control the fighter. The only thing a key press changes is the value of a given vector. After the key press has been checked, it continues on and processes the c_move and c_rotate values each frame. Ultimately I'm trying to figure out the best way (order) to do the calculations in order to figure out how to move the fighter. I do have code, and will post it when I get up later this afternoon.

As far as multiplayer and such, is it easier / faster on the network sync to use your own coding for vectors, or the physics engine to control all of the entities in a given level?

Problem is, I spend most of my time modeling. I'm still learning how to code (bloody clueless atm). Do you have any tips on how I can break down each of these problems (freely moving about in space) to figure out how to code this darned thing?

Re: Requesting Help With Zero Gravity Motion [Re: Lance] #294099
10/16/09 10:00
10/16/09 10:00
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Sounds to me like you have the right backgound knowledge from your 3DS works.
The scripting part of 3DS was pretty horrible anyway and would not really have helped.

Your practice project sounds to be going in the right direction, I think...
But you keep jumping back and forth talking about c_move and physics.
Please be clear on this..
C_move movement and Physics movement are largely exclusive.
3DGS supports both, but VERY seldom on the same object.
If you 'specify' an object to be a 'physics entity' then c_move etc no longer works on it.
I can explain further if you wish.

Assuming you continue down the c_move path, which is my sugestion for a zero-G environment,
then it sounds like your doing well. I cant really see your concern.
Use vector/s to accumulate the keypresses into, and use those vector/s in the
c_rotate and then c-move functions.
I see no problem, and their order isnt too important, and you can swap them if you want.
I cant see it making much difference in 'handling' either.

As for the multi-player issue... Thats out of my league.
But an educated guess would be to stick to your own vector calculations, and pass the results.
Just in case the specs of the client PC make the physics a bit off due to framerate.

Best of luck...

PS : If it sounds like Im against physics, I am a bit. Its tricky to get right,
still performs poorly, and a space sim wont be using "real" physics anyway...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Requesting Help With Zero Gravity Motion [Re: EvilSOB] #294103
10/16/09 10:28
10/16/09 10:28
Joined: Oct 2009
Posts: 8
L
Lance Offline OP
Newbie
Lance  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 8
With regards to physics, very true. It can be fun in max - IF you get it right. If you don't, well... sometimes the results themselves are hilarious, but rarely are they ever useful.

I am intending to stick with the c_move and c_rotate evaluations at this point. I just need to figure out how to work with the vectors, I guess. It's getting my brain wrapped around the math, I think. That's likely where I'm running into trouble. IE, figuring out the difference between velocities along the object's local x, y and z coordinates versus he object orientation. How to take the world coordinate values and compare them to local values, etc. I tried to put in a manual vector for the local portion of c_move, but it only ended up making it behave more like a race car, rather than influencing the drift. I dunno if that makes any sense.

Just to see if I have this right - the object pan, tilt and roll values are according to the world coordinate system, I believe... so if that is true, is there another value that determines the vectors of the object orientation itself?

Re: Requesting Help With Zero Gravity Motion [Re: Lance] #294105
10/16/09 11:17
10/16/09 11:17
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Thats right, pan-tilt-roll are an objects rotation in relation to the 'universe'.

This is the part where you are getting lost I would guess. It IS tricky.
You have to keep putting your mental POV in different places to get this part.
So we will stick with the concepts of 'universe' and 'spaceship' for context.
For now will will stick with an un-moving ship, and progress from there as each new concept is understood.

The ship only has one orientation, that is its pan/til/roll. (Ill abbreviate this to PTR)
Because from the POV of the universe, the ship has a PTR. That it the PTR 'values' of the ship.

But, from the POV of the ship, its own PTR (in relation to itself) is always zero.
And just to confuse things, it is the universe that 'appears' to have a PTR in relation to the ship,
even though it hasnt moved, hell, it cant move, its a universe...
So in reality, the ship has a PTR in relation to the universe. No other rotational vectors are possible.


Do you get that? Weve got to get this bit right before we can progress,
and in my humble opinion, as a teacher, I suck!


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Requesting Help With Zero Gravity Motion [Re: EvilSOB] #294185
10/16/09 20:45
10/16/09 20:45
Joined: Oct 2009
Posts: 8
L
Lance Offline OP
Newbie
Lance  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 8
I wouldn't be too hard on yoruself laugh You're doing good so far. I get what you're saying. So for sake of arguement, let's say the speed along the world x coordinate is going to be 1.0. This is all well and understood as long as your nose is pointed straight in that direction. Now, if you stick your nose down and to the left, the ship's forward velocity isn't going to be 1 anymore, because it's no longer facing the same direction. Its PTR will be 0 to itself, but let's say the pan is 25, tilt is -10. The local velocity for the ship's y and z directions would be sharing part of that overall 1 unit of velocity according to those angles... and so I would have to figure out what those portions of speed would be in order to work with them.

Gah... I feel like I'm trying to write out one of those old high school math problems. Sad part is, that's probably exactly what I'll need to do to get the results I want laugh

Re: Requesting Help With Zero Gravity Motion [Re: Lance] #294197
10/16/09 21:56
10/16/09 21:56
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Yes, its exactly the sort of maths problem school tortured us with.

And you do understand the difference between relative and ablsolute rotations/positons, good.
(I had to check, sorry)

Now, to clarify, the c-move/c-rotate functions are not physics related.
They are single 'step' functions, so if you apply a single c-move,
it will only move that distance/direction and then stop, until the next c_move.
No momentum effects, thats why there is no storage vector for velocity, the
objects have NO velocity as such. So we'll need to synthesize it.
We will concentrate on movement-with-momentum first, so leave your rotations as is for now.

To do so, we will create an absolute-velocity vector to store our current 'drift' in.
We can create a local vector in the ship action, or just use 3 skills of the ship entity.
(skills is preferred, and I can elaborate on this if you wish)
Then to get our ship moving, as before, we accumulate our thrust key-presses into a vector,
we will call this our 'thrust' vector.
Note: The thrust vector will be combining key-strokes and adding them to the vector in a
RELATVE fashion. ie. If w==forwards then we add 100 to its X component.(Same as you are already doing I assume)

BUT, we no longer apply the value directly to the c_move. We need to work it a bit first.
Firstly, we rotate this thrust vector by the PTR of the ship, so the thrust vector becomes
an absolute thrust-vector rather than a relative thrust-vector.
You do this using the "vec_rotate()" function. eg vec_rotate(thrust.x, my.pan);

Once youve got this vector, just as a test, put it into the c_move in the absolute parameter
rather than the relative one, and your ship should perform EXACTLY like it does now...

Once youve done that, let me know, or hit me with more question...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Requesting Help With Zero Gravity Motion [Re: EvilSOB] #294211
10/17/09 03:58
10/17/09 03:58
Joined: Oct 2009
Posts: 8
L
Lance Offline OP
Newbie
Lance  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 8
I am curious about the skills definitions, actually. I noticed those were being used in the original code, but I had to comment them out. Apparently the syntax for them has changed since Vertex's code was released.

Are the skills more or less like defined variables, things like ammo and such, or are they linked to the entity in some predetermined manner? IE, skill1 will always be the entity's x heading, or something like that?

Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1