Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Wheel Rolling
Wheel Rolling
2006-07-09, 6:42 PM #1
I created a cog that makes wheels roll at the correct speed for how fast they travel, but there is some problem with the wheels not being visible at certain angles.


For some reason, when mainwheelangle is between 90-270, the wheel thing just disappears.

.

Code:
// wheel roll stuff

timerdistance = VectorDist(oldpos, GetThingPos(carwheel));	// from the last pulse, find how out how far the wheel has moved
wheelangle = ((3.929752*timerdistance)*360);			// the 3.929752 number is 1/wheelcircumference
oldposfr = GetThingPos(carwheel);				// update the old position for the next pulse
mainwheelangle = mainwheelangle + wheelangle;		// add the new wheel angle difference to the current angle	
while(mainwheelangle > 360)
{
	mainwheelangle = mainwheelangle - 360;	// keep angles within 360
}

						// create a dummy thing to position the wheel to
dummy = FireProjectile(carwheel, projectile, -1, -1, '0 0 0', VectorSet(mainwheelangle, 0, 0), 1.0, 0x20, -1, -1);
TeleportThing(carwheel, dummy);			// put the wheel there
DestroyThing(dummy);				// remove the dummy thing

PrintFlex(mainwheelangle);


Any help will be greatly appreciated.
2006-07-10, 12:21 AM #2
I don't think the vector you are using in FireProjectile is of the form "pitch yaw roll". You may have to use CreateThingAtPos instead of FireProjectile, as it accepts PYR for orientation.

A quick fix, you could always, however, simply change your while{} loop to regulate angle within say, 72 degrees, depending on the symmetry of your wheel. If you have 5 spokes on the wheel texture then 360/5 = 72.

while(mainwheelangle > 72)
{
mainwheelangle = mainwheelangle - 72; // keep angles within 72
}

I think to correctly solve the problem, however, you'll need to use some trig and some more vector functions to get the right look vector.
2006-07-10, 3:36 PM #3
An easier way would be to just use the modulus...

angle_less_than_theta = raw_angle % theta;

Easier and cleaner than a loop, and (at least in cog) does not truncate flex values.


Maybe, fireprojectile's error vec is in pyr/degrees, but only works if <= 90 degrees? (like a 180 degree arc limit, like FirstThingInView has)

I've wanted to play around with that vector, but been too lazy/busy lately.
May the mass times acceleration be with you.
2006-07-10, 6:37 PM #4
It turns out that between 90-270, the fireprojectile object gets rolled 180 degrees. My wheel object was disapearing into the car 3do it was attached to. I hope that can help anyone who fiddles with the fireprojectile vector.

I was thinking of using CreateThingAtPos, but I found out what really happens and just used a flipped wheel 3do for an easier fix.

The % worked great, takes up way less lines now.

Thanks for the thoughts.
2006-07-10, 7:38 PM #5
Come to think of it, in previous experience, FireProjectile always creates objects rightside up. If they would be upside down, JK corrects it.

I tried to make a camera thing once, and had this problem. Kind of disappointing, since I could easily do the correction myself (but not the inverse), but it was an experimental idea anyway.

I played with FireProjectile just now, and, indeed, the error vector is in pyr/degrees (but then we sort of knew that already :P). Anyways, for your entertainment, I'm attaching a demo level of an r5 shooting bryarbolts in a periodic circular pattern. Kind of silly looking, actually ;) :)
Attachment: 13071/createR5.zip (8,460 bytes)
May the mass times acceleration be with you.
2006-07-10, 11:25 PM #6
I always thought the errorvec was just 2d (left right up down) and being added to the offset vector...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-07-11, 1:46 AM #7
It seems the third value in the error vector doesn't do anything.. I just noticed when playing around some more.

↑ Up to the top!