I had to ask online like you! I'll post a clip:
`---------------------------------------------------------------------------- Get TERRAIN PITCH-N-ROLL
` Use object finder to Get "TANK's" pitch in degrees relative to current
` direction its facing. Note this Works Providing TANK Facing correct direction
` Prior to Call.
position object gc.objAngleFinder,garTank(i).rNewC.X#, garTank(i).rNewC.Y#,garTank(i).rNewC.Z#
rotate object gc.objAngleFinder,0,0,0
Turn Object Right gc.objAngleFinder, garTank(i).AngleY#
` Move to front of tank
Move object gc.objAngleFinder,8
FrontY#=GroundHeight#(object position x(gc.objAngleFinder), object position z(gc.objAngleFinder))
` Move to back of tank
Move object gc.objAngleFinder,-16
BackY#=GroundHeight#(object position x(gc.objAngleFinder), object position z(gc.objAngleFinder))
` Move back to center to prepare For Left-n-Right
Move object gc.objAngleFinder,8
` Move object to Left
turn object Left gc.objAngleFinder,90
Move object gc.objAngleFinder,5.5
LeftY#=GroundHeight#(object position x(gc.objAngleFinder), object position z(gc.objAngleFinder))
` Move object to Right of tank
Move object gc.objAngleFinder, -11
RightY#=GroundHeight#(object position x(gc.objAngleFinder), object position z(gc.objAngleFinder))
garTank(i).OldRoll#=garTank(i).RollAngle#
garTank(i).OldPitch#=garTank(i).PitchAngle#
garTank(i).RollAngle# = 90 - ATANFULL(11, LeftY#-RightY#)
garTank(i).PitchAngle# = 90 - ATANFULL(16, FrontY#-BackY#)
`---------------------------------------------------------------------------- Get TERRAIN PITCH-N-ROLL
Rotate Object garTank(i).objHighPoly, 0, 0, 0
Turn Object Right garTank(i).objHighPoly, garTank(i).AngleY#
Roll Object Right garTank(i).objHighPoly,garTank(i).RollAngle#
Pitch Object Up garTank(i).objHighPoly,garTank(i).PitchAngle#
SC_UpdateObject garTank(i).objHighPoly
Note, that's not a complete "Solution" and I'm hoping the code is readable.
Someone gave me some C++ code and I ported it to DarkBasic. What is happening is that I Basically start at the tank's 0,0,0 position, and rotate it right 0-360 degrees (whatever way its facing). then I measure the ground height in front of the tank, and then in back.
FrontHeight#=GroundHeight([in front of tank])
BackHeight#=GroundHeight([in back of tank])
Then I return to center (0,0,0) then I move to left of tank....
LeftHeight#=GroundHeight([Left side of tank])
RightHeight#=GroundHeight([Right side of tank])
Then baciscally the Atanfull stuff looks at the FrontHeight# and BackHeight# as well as the distance between them (length of tank) and pitches the tank that way... the same is repeated for the left and right and the tank is rolled. This is how it can be done without a physics engine.
Does that help a bit? You should try to figure it out. It feels really good when you see it Tilt the wrong way, then rotate the wrong way... you stare and repair and it finally hugs the terrain...not perfect perfect but dam well something to be proud of! Its a blast!