General Category > General Anim8or Forum
WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
Water Music:
Sorry I never got back to you on that, but my idea of a vacation is to lock myself away in a workshop for 2 weeks doing metalwork.
Quick stolen answer:
"If we define pitch=0 as horizontal (z=0) and yaw as counter-clockwise from the x axis, then the direction vector will be
x = cos(yaw)*cos(pitch)
y = sin(yaw)*cos(pitch)
z = sin(pitch)"
And I'll add to that that in 3d math the length of your vector will be L^2=x^2+y^2+z^2 - the 2d equivalent is a^2=b^2+c^2 for right-angle triangles. So you can use that to convert your vector to a normal vector of length 1 and then multiply for the speed of your object.
If you want to add gravity or wind, etc. then it is a simple matter of adding an acceleration vector to your velocity vector in gradual increments (for example, if you wanted to add a simple gravity vector you would add a vector of 0(x) -9.8m(y) 0(z) every second - breaking it into fractions, of course).
Just keep in mind to keep the speed of your object separate from the frequency of your game loops. Which is to say that if I am playing 60fps and my friend is playing at 30fps the I shouldn't see rockets flying twice as fast as my friend does - relativistic physics notwithstanding.
I hope this helps :)
PS Quick correction: I've verified that the stolen formula, above, gives you a vector of length 1 so you won't need correct the length to get a normal vector
cooldude234:
Cool, what kind of metal work do you do?
radx = ((Yaw)+90)*3.14/180;
rady = ((Pitch)+90)*3.14/180;
rady2 = ((Pitch) / 180 * 3.141592654f);
Note that this is just converting to radians... or degrees, I cant remember
rayx -= sin (radx)*(sin(rady)*2.5);
rayz += cos (radx)*(sin(rady)*2.5);
rayy -= sin(rady2)*2.5;
And this is the closest (by closest, I mean the best result I could come up with that still does not work) I got to getting the ray to work, but when the yaw gets closer to being 0 the pitch of the ray is multiplied more and more.
Thus meaning if you are slightly looking up and the more you look to the 0 of the yaw, then more the ray looks up
(NOTE: it is multiplying the pitch and not adding, cause it is not noticeable until you are near the 0 of the yaw)
I tried the one you gave, it still doesn't work.
About the gravity and wind, I already know all that, although I do not store my velocity variables in a vector, though I should under the objects name, box.xvel etc etc. and I probably will do that, but not right now. And gravity is the most simplest (unless if you want to planetary gravity were its just not pulling you "down", which I have also done, just in 2d)
And for you last thingy, I know what you mean, first off you have to limit the fps (frame rates per second, not first person shooter) and also you could make a dynamic fps limiter which depending on your fps count, depends on how fast the world objects move (really tedious to implement but cool once again, also have done it in the past), But usually those factors are usually only done with, when you use networking and the host is usually the machine that doesn't lag.
*phew* that's a lot of writing, I got to learn to summarize
Water Music:
Without going into too much trig, I can say that your second formula works out to be the same as the one I quoted - with the obvious exceptions that you've scaled it from a normal vector to a vector of length 2.5 and you are using a different base orientation. That one is just fine and shouldn't be causing you any problems.
In your first set, where you are converting to radians, your rady2 formula is ambiguously parsed. Depending on how your code is being assembled the value could be (pitch/180)*pi or pitch/(180*pi), so I'd recommend a pair of brackets to be sure - with the first one being correct. That difference can affect your vector length, so maybe start there and see if it helps.
ps currently I'm working on a Mongolian helmet, a Lithuanian helmet, and a pair of gauntlets.
cooldude234:
absolutely nothing changed.
So if your saying the that the second half is correct (which is where I thought the problem was), then I guess there's a lot of work to be done. Cause I have no clue whats going on anymore.
On the bright side, I fixed my billboarding issue. It turns out that y axis while rotating the quad was inverted, so there is now officially billboarding implemented. So I can now continue with making the particle systems structure.
So, what else do you think could be causing this issue music waters (the ray tracing one, I know I just bounced back between two different things :P )?
TheRetroZombie:
Thanks, even though I couldn't get that silly box man game to work, hopefully I'll get a second try.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version