Quote: "You must have the debug renderer set up wrong, see the example where you said it was working and be sure you do exactly the same as that."
its your advanced vehicle example code
did only change the mesh and x file
can you post an screenie for what it looks like?
this is what i see:
Rem Project: Vehicles Advanced
Rem Created: Monday, June 18, 2012
Rem ***** Main Source File *****
//-- If you have not looked at the basic vehicle example it is
//-- advised that you do that first.
//-- This adds some extra handling measures, I would not advise trying to
//-- setup your own vehicle by follwing this exactly. You can use this
//-- as a guide after you have a basic setup complete.
//-- This example is limited to keyboard control, you would handle some
//-- things differently with a controller or wheel but this example should
//-- still help.
global groundID = 1
global carID = 2
global tempObjectID = 3
global wheel1ID = 4
global wheel2ID = 5
global wheel3ID = 6
global wheel4ID = 7
wheelAngle# as float = 20.0
maxAngle# as float = 30.0
steerMax# as float = 30.0 //maxAngle# // we can change this on the fly depending on speed(stop rolling/sliding)
wheelTurnSpeed# as float = 1.0
wheelReturnSpeed# as float = 1.0
wheelTorque# as float = 0.0
power# as float = 350.0
minDownForce# as float = 75.0
downForceFactor# as float = 1.0
hullDamping# as float = 0.4
hullSpeed# as float = 0.0
wheelContacts = 0
velocity# as float = 0.0
//-- currentStiff is the tire grip which is
//-- manipulated for a sliding hand brake turn.
currentStiff# as float = 1000000.0
//-- Max velocity is a variable used to help limit steering, it is the velocity that steering
//-- will stop being limited.
maxVelocity# as float = 45.0
//-- Suspension
//-- Spring and damper can be anything, if your vehicle is 10 times heavier(or has more downforce applied)
//-- then the spring may need to be 10 times more powerful.
travel# as float = 0.15
spring# as float = 45.0
damper# as float = 45.0
target# as float = 0.5 // value between 0-1 (0.5 - sit wheel in centre of suspension)
sync on
sync rate 60
autocam off
position camera 10000, 100, 10000
point camera 0, 0, 0
set camera range 0.1, 100000
//-- Load media
load image "Media/F1 Car/f1car.dds", 2
load object "Media/F1 Car/H-F1 Car-Move.x", carID
//load object "Media/TestLevel/TestLevel.dbo", groundID
load object "Media/TestLevel/vloerb.x", groundID
//scale object groundID, 15, 15, 15
texture object carID, 2
//-- Physics
DYN START
DYN SET PARAMETER NX_VISUALIZATION_SCALE, 1.0
DYN SET PARAMETER NX_VISUALIZE_COLLISION_SHAPES, 1.0
DYN SET GRAVITY 0.0, -9.8 * 2, 0.0
//-- Non bouncy material(does not affect wheels)
DYN MAKE MATERIAL 1, 0.01, 0.5, 0.5
//-- Ground
//DYN LOAD TRIANGLE MESH "Media/TestLevel/TestLevel_15%.TMESH", 1
DYN LOAD TRIANGLE MESH "Media/TestLevel/vloerb.TMESH", 1
DYN MAKE TRIANGLE MESH groundID, 1
DYN SET MATERIAL groundID, 0, 1
//-- Physics Hull
//-- Here we turn the whole object(Hull and wheels) into
//-- a single mesh so we can cook a convex mesh to represent the hull.
//-- We then apply the cooked convex mesh to the real car object.
tempMeshID = 1
make mesh from object tempMeshID, carID
make object tempObjectID, tempMeshID, 0
scale object tempObjectID, 90, 90, 90
DYN COOK CONVEX MESH tempObjectID, 1
DYN MAKE CONVEX MESH carID, 1, 1.0
//-- Raise physics hull off the ground a little
DYN SHAPE SET LOC POS carID, 0, 0, 0.05, 0
//-- Altering centre of mass can change handling and stability
DYN SET CMASS LOC POS carID, 0, 0.2, 1.5
DYN SET LINEAR DAMPING carID, hullDamping#
DYN SET ANGULAR DAMPING carID, hullDamping#
DYN SET MATERIAL carID, 0, 1
delete object tempObjectID
delete mesh tempMeshID
//-- Separate Wheels
//-- Wheel limbs are 2, 3, 4 and 6
make object from limb wheel1ID, carID, 2
make object from limb wheel2ID, carID, 3
make object from limb wheel3ID, carID, 4
make object from limb wheel4ID, carID, 6
//-- Position new wheel objects to limb positions(important when creating fixed joints)
Position Object wheel1ID, Limb Position X(carID, 2), Limb Position Y(carID, 2), Limb Position Z(carID, 2)
Position Object wheel2ID, Limb Position X(carID, 3), Limb Position Y(carID, 3), Limb Position Z(carID, 3)
Position Object wheel3ID, Limb Position X(carID, 4), Limb Position Y(carID, 4), Limb Position Z(carID, 4)
Position Object wheel4ID, Limb Position X(carID, 6), Limb Position Y(carID, 6), Limb Position Z(carID, 6)
//-- Create physics wheel shapes
DYN MAKE WHEEL wheel1ID, 1.0
DYN MAKE WHEEL wheel2ID, 1.0
DYN MAKE WHEEL wheel3ID, 1.0
DYN MAKE WHEEL wheel4ID, 1.0
//-- Suspension
DYN WHEEL SET SUSPENSION TRAVEL wheel1ID, 0, travel#
DYN WHEEL SET SUSPENSION TRAVEL wheel2ID, 0, travel#
DYN WHEEL SET SUSPENSION TRAVEL wheel3ID, 0, travel#
DYN WHEEL SET SUSPENSION TRAVEL wheel4ID, 0, travel#
DYN WHEEL SET SUSPENSION SPRING wheel1ID, 0, spring# * 6, damper# * 6, target# //back - more weight
DYN WHEEL SET SUSPENSION SPRING wheel2ID, 0, spring# * 6, damper# * 6, target# //back - more weight
DYN WHEEL SET SUSPENSION SPRING wheel3ID, 0, spring#, damper#, target# //front - less weight
DYN WHEEL SET SUSPENSION SPRING wheel4ID, 0, spring#, damper#, target# //fromt - less weight
//-- Remove wheels
//-- We can now remove the wheels from the vehicle.
//-- Remove highest limb first, working down.
Remove Limb carID, 6
Remove Limb carID, 4
Remove Limb carID, 3
Remove Limb carID, 2
//-- Create fixed joints to fix wheels to hull
makeJointFixed(1, carID, wheel1ID)
makeJointFixed(2, carID, wheel2ID)
makeJointFixed(3, carID, wheel3ID)
makeJointFixed(4, carID, wheel4ID)
resetObject(carID)
resetObject(wheel1ID)
resetObject(wheel2ID)
resetObject(wheel3ID)
resetObject(wheel4ID)
DYN SIMULATE
do
DYN FETCH RESULTS
DYN UPDATE
//-- Extra wheel positioning(suspension, steer and spin) is updated seperate.
//-- The main reason is that you can add this yourself making
//-- it flexible. This also gives you the opportunity not to
//-- update the wheels if the vehcle is far away or off screen.
DYN WHEEL UPDATE wheel1ID, 0
DYN WHEEL UPDATE wheel2ID, 0
DYN WHEEL UPDATE wheel3ID, 0
DYN WHEEL UPDATE wheel4ID, 0
//APPLY FORCES
//-- How many wheels are on the ground.
wheelContacts = DYN WHEEL GET CONTACT(wheel1ID, 0) + DYN WHEEL GET CONTACT(wheel2ID, 0) + DYN WHEEL GET CONTACT(wheel3ID, 0) + DYN WHEEL GET CONTACT(wheel4ID, 0)
//-- Get speed
v = Make Vector3(1)
DYN GET LINEAR VELOCITY carID, 1
hullSpeed# = Sqrt(X Vector3(1) * X Vector3(1) + Y Vector3(1) * Y Vector3(1) + Z Vector3(1) * Z Vector3(1))
v = Delete Vector3(1)
//--STEER
// The faster we go the less we can steer
steerMax# = maxAngle# - ((hullSpeed# * (maxAngle# / maxVelocity#)))
if steerMax# < 1.5
steerMax# = 1.5
endif
// Limit wheel angle
if wheelAngle# > steerMax#
wheelAngle# = steerMax#
endif
if wheelAngle# < -steerMax#
wheelAngle# = -steerMax#
endif
// KEYS
// Power
wheelTorque# = 0
if UpKey()
wheelTorque# = -power#
endif
if SpaceKey()
wheelTorque# = power# / 2.0
endif
// Turn
if LeftKey()
wheelAngle# = wheelAngle# - wheelTurnSpeed#
endif
if RightKey()
wheelAngle# = wheelAngle# + wheelTurnSpeed#
endif
if RightKey() = 0 and LeftKey() = 0
wheelAngle# = wheelAngle# * 0.75
endif
// We shall turn the front wheels only and add power to the rear wheels only.
DYN WHEEL SET MOTOR TORQUE wheel1ID, 0, wheelTorque#
DYN WHEEL SET MOTOR TORQUE wheel2ID, 0, wheelTorque#
DYN WHEEL SET MOTOR TORQUE wheel3ID, 0, wheelTorque#
DYN WHEEL SET MOTOR TORQUE wheel4ID, 0, wheelTorque#
DYN WHEEL SET STEER ANGLE wheel3ID, 0, wheelAngle#
DYN WHEEL SET STEER ANGLE wheel4ID, 0, wheelAngle#
// DownForce
// Adding downforce is a good way to increase vehicle grip and make the car more
// responsive.
// We first apply a mimumum amount,
// We apply more the faster the vehicle is moving(real world affect of a spoiler)
// This only gets added if touching ground, this is to be sure the car does not fall too fast
// when in the air.
DYN ADD LOCAL FORCE carID, 0, -minDownForce# -(hullSpeed# * wheelContacts * downForceFactor#), 0
//HAND BRAKE
brakeTorque# = 0.0
if DownKey()
//-- lower grip
currentStiff# = 1000.0;
//-- apply brakes
brakeTorque# = 50.0;
//-- extra spin if needed(related to how much the car is turning)
DYN ADD LOCAL TORQUE carID, 0, wheelAngle# * (hullSpeed# / 4), 0
endif
if DownKey() = 0 and currentStiff# < 1000000.0
//return to full grip gradually
currentStiff# = currentStiff# * 1.25
endif
DYN MAKE TIRE FUNC DESC 1
DYN TIRE FUNC DESC SET STIFFNESS FACTOR 1, currentStiff#
DYN WHEEL SET LAT TIRE FORCE FUNC wheel1ID, 0, 1
DYN WHEEL SET LAT TIRE FORCE FUNC wheel2ID, 0, 1
DYN WHEEL SET LAT TIRE FORCE FUNC wheel3ID, 0, 1
DYN WHEEL SET LAT TIRE FORCE FUNC wheel4ID, 0, 1
DYN DELETE TIRE FUNC DESC 1
DYN WHEEL SET BRAKE TORQUE wheel1ID, 0, brakeTorque#
DYN WHEEL SET BRAKE TORQUE wheel2ID, 0, brakeTorque#
DYN WHEEL SET BRAKE TORQUE wheel3ID, 0, brakeTorque#
DYN WHEEL SET BRAKE TORQUE wheel4ID, 0, brakeTorque#
if returnkey()
resetObject(carID)
resetObject(wheel1ID)
resetObject(wheel2ID)
resetObject(wheel3ID)
resetObject(wheel4ID)
endif
DYN DEBUG RENDER
DYN SIMULATE
//-- Camera
//-- Utility camera function allowing you to follow the vehicle
//-- with some smoothing.
//-- Third person
DYN UTIL SET CAMERA TO OBJECT 0, carID, 0, 3.0, 5.0, 0, 0, 0, 0.1
//-- Top down
//DYN UTIL SET CAMERA TO OBJECT 0, carID, 0, 40, 0.0, 0, 0, -5.0, 0.1
//-- First person
//DYN UTIL SET CAMERA TO OBJECT 0, carID, 0, 1, -0.5, 0, 0, -5.0, 0.75
//Set Camera To Object Orientation carID
//Turn Camera Left 180
displayInfo(hullSpeed#)
sync
loop
DYN FETCH RESULTS
DYN STOP
function resetObject(objectID)
DYN SET POSITION objectID, 0, 10, -100
DYN SET ROTATION objectID, 0, 180, 0
DYN SET LINEAR MOMENTUM objectID, 0, 0, 0
DYN SET ANGULAR MOMENTUM objectID, 0, 0, 0
endfunction
function makeJointFixed(jointID, objectA, objectB)
//-- Create descriptor data structure.
DYN MAKE JOINT DESC 1
//-- Locked motion relative to joint position.
DYN JOINT DESC SET MOTION X 1, 0
DYN JOINT DESC SET MOTION Y 1, 0
DYN JOINT DESC SET MOTION Z 1, 0
//-- Locked rotation also.
DYN JOINT DESC SET SWING1 MOTION 1, 0
DYN JOINT DESC SET SWING2 MOTION 1, 0
DYN JOINT DESC SET TWIST MOTION 1, 0
//-- What actors are involved?
DYN JOINT DESC SET ACTOR A 1, objectA
DYN JOINT DESC SET ACTOR B 1, objectB
//-- Must set this after actors have been set.
//-- Location of anchor can be anything for a fixed joint.
DYN JOINT DESC SET GLOBAL ANCHOR 1, 0, 0, 0
//-- Create joint.
DYN MAKE JOINT jointID, 1
//-- No longer need descriptor.
DYN DELETE JOINT DESC 1
endfunction
function displayInfo(speed#)
y = 0
spacing = 15
Text 0, y, "Turn - Left/Right Arrow"
y = y + spacing
Text 0, y, "Throttle - Up Arrow"
y = y + spacing
Text 0, y, "Hand Brake - Down Arrow"
y = y + spacing
Text 0, y, "Reverse - Space Key"
y = y + spacing
Text 0, y, "Reset Vehicle - Return Key"
y = y + spacing
Text 0, y, "Speed = "
Text 128, y, str$(speed# * 3)
Center Text 320, 460, "Dark Dynamix Vehicle"
endfunction