thanks Vip..
in few days i'm going to share all the things i've done with ode about boats and ships...
i can't find the way to set the longitudinal and lateral friction to an ode object.. i see the friction demo, the boxes with difenent values..
the only command i find to set friction is this "dGeomContactSetMu(ode\geom,count*0.5)"
i found in the manual, point "7.3.7 Contact" the things i could use, but i dont understand it yet...
about the hull, it floats perfectly on the water, but i found that it doesnt matter to dinamycs if the ship is going forward or side...
i think is because the ode must take all surface under water to make friction. maybe i can find the way to simulate hydrodinamic if i find the way to set friction direction...
thanks for the help, is good that you are available to discuss these topics...
im posting a modification of the water demo, to see the thing about friction...
im a naval technician, in school we calculate all data about ships using the cube of dimension of hull, frontal surface , to hydrodynamic friction, like cars...
; ###################################################################################################
; # JV-ODE - Water Demo #
; # Code by Jim Williams (VIP3R) #
; # Devious Codeworks - Copyright © 2007 #
; ###################################################################################################
AppTitle "JV-ODE - Water Demo"
Include "JV-ODE.bb"
Graphics3D 800,600,0,2
Type ODEGeom
Field body
Field geom
Field mesh
End Type
; ###################################################################################################
; ### Setup ODE
Global World=dWorldCreate()
Global Space=dHashSpaceCreate(0)
Global ContactGroup=dJointGroupCreate(0)
dWorldSetAutoDisableFlag(World,1)
dWorldSetGravity(World,0,-0.98,0)
dContactSetMode(dContactSlip1)
dContactSetMu(0.5)
; ### Create light
Global Light=CreateLight()
RotateEntity Light,45,-90,0
LightColor Light,255,255,255
AmbientLight 130,130,130
; ### Create camera
Global Camera=CreateCamera()
CameraClsColor Camera,0,0,0
CameraRange Camera,1,1000
PositionEntity Camera,0,45,-70
RotateEntity Camera,30,0,0
; ### Create plane
dCreatePlane(Space,0,1,0,0)
Plane=CreatePlane()
EntityAlpha Plane,0.8
PlaneTexture=CreateTexture(128,128,9)
ClsColor 0,200,80
Cls
Color 255,255,255
Rect 0,0,64,64,1
Rect 64,64,64,64,1
CopyRect 0,0,128,128,0,0,BackBuffer(),TextureBuffer(PlaneTexture)
ScaleTexture PlaneTexture,20,20
EntityTexture Plane,PlaneTexture,0,0
Mirror=CreateMirror()
; ###################################################################################################
; ### Create water
limite_agua =500
water_friction# = .09 ; ### Water friction
ode.ODEGeom=New ODEGeom
ode\geom=dCreateBox(Space,limite_agua,15,limite_agua)
dGeomSetRotation(ode\geom,0,0,0)
dGeomSetPosition(ode\geom,0,7.5,0)
dGeomContactSetMode(ode\geom,dContactBounce+dContactSoftCFM)
dGeomContactSetBounce(ode\geom,0.6) ; ### Water bounce
dGeomContactSetSoftCFM(ode\geom,0.8) ; ### Water density
dGeomContactSetMu(ode\geom,water_friction)
ode\mesh=CreateCube()
ScaleMesh ode\mesh,(limite_agua*.5),7.5,(limite_agua*.5)
EntityColor ode\mesh,0,100,200
EntityAlpha ode\mesh,0.7
EntityShininess ode\mesh,0.7
;Crear objeto de prueba
x_ancho# = 5
x_alto# = 3
x_largo# = 20
x_mass# = 40
x_friccion# =10
ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,19,45,0)
dBodySetPosition(ode\body,0,10,00)
mass=dMassCreate()
dMassSetBoxTotal(mass,x_mass#,x_ancho,x_alto,x_largo)
dBodySetMass(ode\body,mass)
dMassDestroy(mass)
dBodySetAutoDisableFlag(ode\body,0)
ode\geom=dCreatebox(Space,x_ancho,x_alto,x_largo)
CGeom=ode\geom
dGeomSetBody(ode\geom,ode\body)
dGeomContactSetMu(ode\geom,x_friccion#)
ode\mesh=Createcube()
scaleentity ode\mesh,x_ancho*.5,x_alto*.5,x_largo *.5
EntityColor ode\mesh,250,100,0
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.1
vgiro# = a_timon# = velocidad# = potencia# = a_timon# = 0
; ###################################################################################################
While Not KeyHit(1)
f#=.34 ; variable to incresse the factor to push
f2#=4 ; factor to incress the turn
fx#=sin(entityyaw#(ode\mesh))*potencia*f ;find vector direction to push the ship
fz#=-cos(entityyaw#(ode\mesh))*potencia*f
dbodyaddtorque (ode\body,0,-a_timon * f2#,0) ;apply to turn
dbodyaddforce (ode\body,fx,0,fz) ;apply to push the objet
pointentity camera,ode\mesh
if keydown(200) and potencia < 100 then potencia=potencia + 1
if keydown(208) and potencia > -60 then potencia=potencia - 1
if keydown(205) and a_timon >-60 then a_timon = a_timon - 1
if keydown(203) and a_timon < 60 then a_timon = a_timon + 1
PTime=MilliSecs()
If MilliSecs()-Timer>700
Timer=MilliSecs()
End If
UpdateGeoms()
dSpaceCollide(Space,World,ContactGroup)
dWorldQuickStep(World,0.1)
dJointGroupEmpty(ContactGroup)
PhysicsTime#=MilliSecs()-PTime
UpdateWorld
RenderWorld
Text 0,0,"JV-ODE Version "+dGetVersion()
Text 0,15,"Physics Time:"+PhysicsTime
text 0,40,"UP & DOWN to go forward."
text 0,60,"LEFT & RIGHT to turn"
Flip
Wend
dJointGroupDestroy(ContactGroup)
dSpaceDestroy(Space)
dWorldDestroy(World)
dCloseODE()
End
Function UpdateGeoms()
For ode.ODEGeom=Each ODEGeom
RotateEntity ode\mesh,dGeomGetPitch#(ode\geom),dGeomGetYaw#(ode\geom),dGeomGetRoll#(ode\geom)
PositionEntity ode\mesh,dGeomGetPositionX#(ode\geom),dGeomGetPositionY#(ode\geom),dGeomGetPositionZ#(ode\geom)
Next
End Function
i going to keep trying to make it work, gladly i'm going to share all things i learn about naval emulation with ode...
regards..
Santiago