Bi-Directional Rotation

Blitz3D Forums/Blitz3D Beginners Area/Bi-Directional Rotation

Nathaniel(Posted 2007) [#1]
How do I steer (yaw) a wheel and spin it (pitch) at the same time without making it "wobble?" I've tried using pivots and parenting them to the wheel, but that doesn't work.

It's the same idea as using "TranslateEntity" to move a object while turning it.

Thanks


Stevie G(Posted 2007) [#2]
Something like this? See example code I posted further down the thread ...

http://www.blitzbasic.com/Community/posts.php?topic=45936#511351


Nathaniel(Posted 2007) [#3]
Thanks Stevie. I was using "TurnEntity" instead of "Rotateentity"--I think that was the problem.


chwaga(Posted 2007) [#4]
if that doesnt work, I found that roll can mess things up, so i just constantly set roll to 0


Nathaniel(Posted 2007) [#5]
@chwaga
Thanks for the heads up, but I have no need to rotate the tire in the roll axis.

@Stevie
Is that the same (obviously not as complicated) base you used for your 3D Verlet engine?

@Everyone
Works great now!


Stevie G(Posted 2007) [#6]

@Stevie
Is that the same (obviously not as complicated) base you used for your 3D Verlet engine?



Not really - it's just a wee bit unrealistic don't you think ;)


Nathaniel(Posted 2007) [#7]
Not really - it's just a wee bit unrealistic don't you think ;)
Especially because you can turn without moving forward :)


Nathaniel(Posted 2007) [#8]
Another question while on the subject of vehicles:

How is realistic collision between wheels (with shocks) and the terrain done?
AlignToVector
seems the closest command to what I'm looking for. It still won't work in a world with ramps (or hills) due to the fact that it only aligns to one axis.


Stevie G(Posted 2007) [#9]

How is realistic collision between wheels (with shocks) and the terrain done?



If you're talking about suspension then you'll need to look into spring physics.

To align the chassis to the wheels when on any terrain ( hills / ramps etc.. ) you can use align to vector on both the pitch and roll axes. See the driver demo in 3d samples for an example.

Stevie


Nathaniel(Posted 2007) [#10]
I don't think I understand the AlignToVector command. The docs aren't very clear on how it works and there isn't currently an example. What does vectorX, vectorY, and vectorZ, tell the compiler?

Thanks for the help.


Stevie G(Posted 2007) [#11]
Eh .. the vector which you want to align the axis to.


...........
..........2
...........
1..........



Say point 1 is the left tyres and point 2 is the right tyres, looking from behind the vehicle.

The vector pointing from p1 to p2 is ..

V\x = p2\x - p1\x
V\y = p2\y - p1\z
V\z = p2\z - p1\z

To align the x ( roll axis ) of the chassis to this vector use ...

Aligntovector Chassis, Vx, Vy, Vz, 1

Like I said - look at the driver example in the 3d samples folder.

Stevie


Nathaniel(Posted 2007) [#12]
So "driver" averages of the wheels' positions to find the position of the chassis? I understand why it aligns it twice, but why does it calculate the center of the chassis using two different methods?
zx#=(EntityX( wheels[2],True )+EntityX( wheels[4],True ))/2
zx=zx-(EntityX( wheels[1],True )+EntityX( wheels[3],True ))/2
zy#=(EntityY( wheels[2],True )+EntityY( wheels[4],True ))/2
zy=zy-(EntityY( wheels[1],True )+EntityY( wheels[3],True ))/2
zz#=(EntityZ( wheels[2],True )+EntityZ( wheels[4],True ))/2
zz=zz-(EntityZ( wheels[1],True )+EntityZ( wheels[3],True ))/2
AlignToVector car,zx,zy,zz,1
As apposed to:
zx#=(EntityX( wheels[1],True )+EntityX( wheels[2],True ))/2
zx=zx-(EntityX( wheels[3],True )+EntityX( wheels[4],True ))/2
zy#=(EntityY( wheels[1],True )+EntityY( wheels[2],True ))/2
zy=zy-(EntityY( wheels[3],True )+EntityY( wheels[4],True ))/2
zz#=(EntityZ( wheels[1],True )+EntityZ( wheels[2],True ))/2
zz=zz-(EntityZ( wheels[3],True )+EntityZ( wheels[4],True ))/2
AlignToVector car,zx,zy,zz,3

Thanks for clearing this up Stevie!


Nathaniel(Posted 2007) [#13]
Mmmm...
Stevie hasn't posted in the forums for several days...


Stevie G(Posted 2007) [#14]
Sorry, I didn't realise I was your personal tutor ;)

Imagine this image ...


1.....2
.......
.......
3.....4



Neither alignment methods are finding the center of the chassis. The first works out the vector from midpoint of wheel 1&3 to midpoint of 2&4, the second works out the vector from midpoint of 3&4 to midpoint of 1&2.

It's quite logical if you think about it. For example, you could align the x-axis solely based on a vector from wheel 1 to wheel 2 but ..... using the average of the left wheels and right wheels makes the alignment smoother when you consider it will be rare for all 4 wheels to be touching the ground

Stevie


Nathaniel(Posted 2007) [#15]
Sorry, I didn't realise I was your personal tutor ;)
Heh :)
I think you're one of the only (active) knowledgeable blitzers on this topic.

It makes sense to find the average of the left and right wheels...


My lack of understanding relates to the internal processes of the command.
I'm under the impression that the Entity is aligned to the vector positions given, on top of the entity it's colliding with (the landscape). Correct?

Thanks for all the constructive help.


Nathaniel(Posted 2007) [#16]
Ah, I think I understand now (after doing a test):

The "vector" values in the "AlignToVector" command are the 1-dimesional deferences inbetween the wheels.

Is this correct?



Now how does "AlignToVector" know to align to the car to the terrain? Does "Collisions" take care of that?

Thanks again...


Stevie G(Posted 2007) [#17]

The "vector" values in the "AlignToVector" command are the 1-dimesional deferences inbetween the wheels.

Is this correct?



Pretty much.


Now how does "AlignToVector" know to align to the car to the terrain? Does "Collisions" take care of that?



Blitz collisions prevent penetration with the terrain so the wheels are always sitting just on top or above. Strictly speaking you're not aligning the car to the terrain, you are aligning the car to the wheels. The result gives the impression of alignment with the terrain.


Nathaniel(Posted 2007) [#18]
:O

Now this finally makes sense!


This method makes the suspension system easier to control (and code) because I can manipulate the differences inbetween the wheels to make it look like the car is bouncing/rocking. Right?


Thank you for all of your help, Stevie!


Stevie G(Posted 2007) [#19]
Glad to help.