Quote: "I have tried to types of convex shapes and if I place a dynamic object directly above they both fail to work"
1:HOOP TOSS The idea is to be able to throw a hoop over a bottle and it should fall down over the bottle
function hoopTossLoad()
DeleteAllObjects()
DeleteAllImages()
loadObject(taurusObj,"taurus.obj")
//SetObjectScalePermanent(taurusObj,1.2,1.2,1.2)
SetObjectPosition(taurusObj,-200,4,40)
Create3DPhysicsDynamicBody(taurusObj )
SetObjectShapeConvexHull(taurusObj)
LoadObject(playerObj,"cannon3.3ds")
SetObjectPosition(playerObj,0,2,-50)
SetObjectScale(playerObj,.5,.5,.5)
LoadImage(cannonImg,"cannon.png")
SetObjectImage(playerObj,cannonImg,0)
//SetObjectVisible(playerObj,0)
If GetObjectExists(awningObj) then DeleteObject(awningObj)
LoadObject(awningObj,"awning.obj")
SetObjectTransparency(awningobj, 1)
loadImage(awningImg,"awning.png")
SetObjectimage(awningObj,awningImg,0)
SetImageWrapU(awningImg,1)
SetImageWrapv(awningImg,1)
SetObjectUVScale(awningObj,0,1,1)
LoadObject(fenceObj,"fence.obj")
loadImage(fenceImg,"fence.png")
SetObjectimage(fenceObj,fenceImg,0)
SetImageWrapU(fenceImg,1)
SetImageWrapv(fenceImg,1)
SetObjectUVScale(fenceObj,0,1,1)
LoadObject(frameObj1,"frame.3ds")
If GetImageExists(frameImg1) then DeleteImage(frameImg1)
loadImage(frameImg1,"frame1.png")
SetObjectPosition(frameObj1,0,0,1)
SetObjectimage(frameObj1,frameImg1,0)
LoadObject(frameObj2,"frame.3ds")
SetObjectPosition(frameObj2,32,0,1)
loadImage(frameImg2,"frame2.png")
SetImageWrapU(frameImg2,1)
SetImageWrapv(frameImg2,1)
SetObjectimage(frameObj2,frameImg2,0)
SetObjectUVScale(frameObj2,0,1,1)
CreateObjectBox(tableObj,30,4,80)
SetObjectPosition(tableObj,0,-4,10)
SetObjectImage(tableObj,frameImg1,0)
Create3DPhysicsStaticBody(tableObj)
SetObjectShapeBox(tableObj)
CreateObjectBox(floorObj,150,1,150)
SetObjectPosition(floorObj,0,-8,10)
Create3DPhysicsStaticBody(floorObj)
SetObjectShapeBox(floorObj)
sync()
hoopSetThemUp()
endfunction
function hoopTossPlay()
bowlTime#=0:cannonShots=0:bowlScore=0
do
//duckshoot()
VectorX# = Get3DVectorXFromScreen( GetPointerX(), GetPointerY() )
VectorY# = Get3DVectorYFromScreen( GetPointerX(), GetPointerY() )
VectorZ# = Get3DVectorZFromScreen( GetPointerX(), GetPointerY()*2 )
// get a vector that points in the direction the camera is looking
VectorX2# = Get3DVectorXFromScreen( GetVirtualWidth()/2.0, GetVirtualHeight()/2.0 )
VectorY2# = Get3DVectorYFromScreen( GetVirtualWidth()/2.0, GetVirtualHeight()/2.0 )
VectorZ2# = Get3DVectorZFromScreen( GetVirtualWidth()/2.0, GetVirtualHeight()/2.0 )
// normalise Vector in the direction of Vector2
Dot# = VectorX#*VectorX2# + VectorY#*VectorY2# + VectorZ#*VectorZ2#
if ( Dot# > 0 )
VectorX# = VectorX# / Dot#
VectorY# = VectorY# / Dot#
VectorZ# = VectorZ# / Dot#
endif
WorldX# = VectorX# * Depth# + GetCameraX(1)
WorldY# = VectorY# * Depth# + GetCameraY(1)
WorldZ# = VectorZ# * Depth# + GetCameraZ(1)
SetObjectLookAt(playerObj,WorldX#,WorldY#,WorldZ#,0)
//SetObjectRotation(playerObj,Angle_x#,Angle_y#,GetObjectAngleZ(playerObj))
if GetPointerPressed()
bowlTime#=timer():inc cannonShots
hoopToss( 300.0, 20.0,4.0)
endif
ammount=myBullet.length
for num=ammount to 0 step -1
//hit=checkCollision(myBullet[num].ID)
if (myBullet[num].time)+bulletLife<timer() //or hit=100
DeleteObject(myBullet[num].ID)
myBullet.remove(num)
dec bulletCount
endif
next num
KnockedOver=0
if (timer()-bowlTime#)> 1
//bowlScore=bowlScore+(KnockedOver*10)
//hoopSetThemUp() :bowlTime#=0:ResetTimer()
//digitalScoreBoard(bowlScore)
endif
if GetRawKeyState(38)=1 Then MoveCameraLocalZ(1,1)
if GetRawKeyState(40)=1 Then MoveCameraLocalZ(1,-1)
if GetRawKeyState(39)=1 Then MoveCameraLocalX(1,1)
if GetRawKeyState(37)=1 Then MoveCameraLocalX(1,-1)
sync()
Step3DPhysicsWorld()
loop
endfunction
function hoopToss( initialSpeed as float, mass as float, size as float)
//To move dynamic physics bodies we need to apply velocity to the physics body.
gunPositionVec= CreateVector3(GetObjectWorldX(playerObj),GetObjectWorldY(playerObj)+camOff_y#,GetObjectWorldZ(playerObj)) //im using the camera position as the gun position
//Create a tempory projectile block to calculate movement vectors of bullets
projectileDirBox as integer
projectileDirBox = CreateObjectBox( 1.0, 1.0, 1.0 )
SetObjectPosition( projectileDirBox, GetVector3X( gunPositionVec ), GetVector3Y( gunPositionVec ), GetVector3Z( gunPositionVec ) )
setobjectrotation(projectiledirbox,GetObjectWorldAngleX(playerObj),GetObjectWorldAngleY(playerObj),GetObjectWorldAngleZ(playerObj))
MoveObjectLocalZ( projectileDirBox, 1.0 )
projectileDirVec = CreateVector3( GetobjectWorldX( projectileDirBox )-GetVector3X( gunPositionVec ), GetobjectWorldY( projectileDirBox )-GetVector3Y( gunPositionVec ), GetobjectWorldZ( projectileDirBox )-GetVector3Z( gunPositionVec ) )
DeleteObject( projectileDirBox )
throwBall as integer
throwBall = CloneObject(taurusObj)
SetObjectColor( throwBall, 255, 0,0,255 )
SetObjectPosition( throwBall, GetVector3X( gunPositionVec ), GetVector3Y( gunPositionVec ), GetVector3Z( gunPositionVec ) )
SetObjectRotation(throwBall,GetObjectAngleX(playerObj),GetObjectAngleY(playerObj),GetObjectAngleZ(playerObj))
//3D Physics code
Create3DPhysicsDynamicBody( throwBall )
SetObjectShapeConvexHull( throwBall )
SetObject3DPhysicsMass( throwBall, mass )
SetObject3DPhysicsLinearVelocity( throwBall, projectileDirVec, initialSpeed )
//SetObject3DPhysicsFriction( throwBall, 0.8 )
//SetObject3DPhysicsRollingFriction( throwBall, 0.7 )
//SetObject3DPhysicsCanSleep(throwBall,0)
myItem as bullet
myItem.ID = throwBall //the object id of the bullet
myItem.time = timer() //timer is used to set there life time as bullets will die off after so long
myBullet.insert(myItem) //update bullet arrow as there is unlimeted bullets
inc bulletCount //used for a bullet counter to check if theyve timed out or not
deletevector3(projectileDirVec)
deletevector3(gunPositionVec)
endfunction
function hoopSetThemUp()
If getObjectExists(bottleObj1) then DeleteObject(bottleObj1)
LoadObject(bottleObj1,"bottle2.obj")
SetObjectScalePermanent(bottleObj1,4,4,4)
SetObjectPosition(bottleObj1,-5,0,40)
SetObjectColor(bottleObj1,100,100,100,150)
//RotateObjectLocalZ(bottleObj1,90)
SetObjectTransparency(bottleObj1,1)
Create3DPhysicsDynamicBody(bottleObj1)
SetObject3DPhysicsMass(bottleObj1, 1000.0 )
SetObject3DPhysicsFriction(bottleObj1, 1 )
If getObjectExists(bottleObj2) then DeleteObject(bottleObj2)
CloneObject(bottleObj2,bottleObj1)
SetObjectPosition(bottleObj2,5,0,40)
Create3DPhysicsDynamicBody(bottleObj2)
SetObject3DPhysicsMass(bottleObj2, 1000.0 )
SetObject3DPhysicsFriction(bottleObj2, 1)
If getObjectExists(bottleObj3) then DeleteObject(bottleObj3)
CloneObject(bottleObj3,bottleObj1)
SetObjectPosition(bottleObj3,-5,0,10)
Create3DPhysicsDynamicBody(bottleObj3)
SetObject3DPhysicsMass(bottleObj3, 1000.0 )
SetObject3DPhysicsFriction(bottleObj3, 1 )
If getObjectExists(bottleObj4) then DeleteObject(bottleObj4)
CloneObject(bottleObj4,bottleObj1)
SetObjectPosition(bottleObj4,5,0,10)
Create3DPhysicsDynamicBody(bottleObj4)
SetObject3DPhysicsMass(bottleObj4, 100.0 )
SetObject3DPhysicsFriction(bottleObj4, 1 )
If getObjectExists(bottleObj5) then DeleteObject(bottleObj5)
CloneObject(bottleObj5,bottleObj1)
SetObjectPosition(bottleObj5,-5,0,-10)
Create3DPhysicsDynamicBody(bottleObj5)
SetObject3DPhysicsMass(bottleObj5, 1000.0 )
SetObject3DPhysicsFriction(bottleObj5, 1 )
If getObjectExists(bottleObj6) then DeleteObject(bottleObj6)
CloneObject(bottleObj6,bottleObj1)
SetObjectPosition(bottleObj6,5,0,-10)
Create3DPhysicsDynamicBody(bottleObj6)
SetObject3DPhysicsMass(bottleObj6, 1000.0 )
SetObject3DPhysicsFriction(bottleObj6, 1 )
endfunction
DUNNY TOSS The idea is to be able to throw a ball into the dunny bowl
function toiletTossLoad()
DeleteAllObjects()
DeleteAllImages()
//loadObject(taurusObj,"taurus.obj")
//SetObjectScalePermanent(taurusObj,1.2,1.2,1.2)
//SetObjectPosition(taurusObj,-200,4,40)
//Create3DPhysicsDynamicBody(taurusObj )
//SetObjectShapeConvexHull(taurusObj)
LoadObject(playerObj,"cannon3.3ds")
SetObjectPosition(playerObj,0,2,-50)
SetObjectScale(playerObj,.5,.5,.5)
LoadImage(cannonImg,"cannon.png")
SetObjectImage(playerObj,cannonImg,0)
//SetObjectVisible(playerObj,0)
If GetObjectExists(awningObj) then DeleteObject(awningObj)
LoadObject(awningObj,"awning.obj")
SetObjectTransparency(awningobj, 1)
loadImage(awningImg,"awning.png")
SetObjectimage(awningObj,awningImg,0)
SetImageWrapU(awningImg,1)
SetImageWrapv(awningImg,1)
SetObjectUVScale(awningObj,0,1,1)
LoadObject(fenceObj,"fence.obj")
loadImage(fenceImg,"fence.png")
SetObjectimage(fenceObj,fenceImg,0)
SetImageWrapU(fenceImg,1)
SetImageWrapv(fenceImg,1)
SetObjectUVScale(fenceObj,0,1,1)
LoadObject(frameObj1,"frame.3ds")
If GetImageExists(frameImg1) then DeleteImage(frameImg1)
loadImage(frameImg1,"frame1.png")
SetObjectPosition(frameObj1,0,0,1)
SetObjectimage(frameObj1,frameImg1,0)
LoadObject(frameObj2,"frame.3ds")
SetObjectPosition(frameObj2,32,0,1)
loadImage(frameImg2,"frame2.png")
SetImageWrapU(frameImg2,1)
SetImageWrapv(frameImg2,1)
SetObjectimage(frameObj2,frameImg2,0)
SetObjectUVScale(frameObj2,0,1,1)
CreateObjectBox(tableObj,30,4,80)
SetObjectPosition(tableObj,0,-4,10)
SetObjectImage(tableObj,frameImg1,0)
Create3DPhysicsStaticBody(tableObj)
SetObjectShapeBox(tableObj)
CreateObjectBox(floorObj,150,1,150)
SetObjectPosition(floorObj,0,-8,10)
Create3DPhysicsStaticBody(floorObj)
SetObjectShapeBox(floorObj)
sync()
toiletSetThemUp()
Set3DPhysicsGravity(0,-10,0)
endfunction
function toiletTossPlay()
bowlTime#=0:cannonShots=0:bowlScore=0
do
//duckshoot()
VectorX# = Get3DVectorXFromScreen( GetPointerX(), GetPointerY() )
VectorY# = Get3DVectorYFromScreen( GetPointerX(), GetPointerY() )
VectorZ# = Get3DVectorZFromScreen( GetPointerX(), GetPointerY()*2 )
// get a vector that points in the direction the camera is looking
VectorX2# = Get3DVectorXFromScreen( GetVirtualWidth()/2.0, GetVirtualHeight()/2.0 )
VectorY2# = Get3DVectorYFromScreen( GetVirtualWidth()/2.0, GetVirtualHeight()/2.0 )
VectorZ2# = Get3DVectorZFromScreen( GetVirtualWidth()/2.0, GetVirtualHeight()/2.0 )
// normalise Vector in the direction of Vector2
Dot# = VectorX#*VectorX2# + VectorY#*VectorY2# + VectorZ#*VectorZ2#
if ( Dot# > 0 )
VectorX# = VectorX# / Dot#
VectorY# = VectorY# / Dot#
VectorZ# = VectorZ# / Dot#
endif
WorldX# = VectorX# * Depth# + GetCameraX(1)
WorldY# = VectorY# * Depth# + GetCameraY(1)
WorldZ# = VectorZ# * Depth# + GetCameraZ(1)
SetObjectLookAt(playerObj,WorldX#,WorldY#,WorldZ#,0)
//SetObjectRotation(playerObj,Angle_x#,Angle_y#,GetObjectAngleZ(playerObj))
if GetPointerPressed()
bowlTime#=timer():inc cannonShots
toiletToss( 300.0, 20.0,2.0)
endif
ammount=myBullet.length
for num=ammount to 0 step -1
//hit=checkCollision(myBullet[num].ID)
if (myBullet[num].time)+bulletLife<timer() //or hit=100
DeleteObject(myBullet[num].ID)
myBullet.remove(num)
dec bulletCount
endif
next num
KnockedOver=0
if (timer()-bowlTime#)> 1
//bowlScore=bowlScore+(KnockedOver*10)
//hoopSetThemUp() :bowlTime#=0:ResetTimer()
//digitalScoreBoard(bowlScore)
endif
if GetRawKeyState(38)=1 Then MoveCameraLocalZ(1,1)
if GetRawKeyState(40)=1 Then MoveCameraLocalZ(1,-1)
if GetRawKeyState(39)=1 Then MoveCameraLocalX(1,1)
if GetRawKeyState(37)=1 Then MoveCameraLocalX(1,-1)
sync()
Step3DPhysicsWorld()
loop
endfunction
function toiletToss( initialSpeed as float, mass as float, size as float)
//To move dynamic physics bodies we need to apply velocity to the physics body.
gunPositionVec= CreateVector3(GetObjectWorldX(playerObj),GetObjectWorldY(playerObj)+camOff_y#,GetObjectWorldZ(playerObj)) //im using the camera position as the gun position
//Create a tempory projectile block to calculate movement vectors of bullets
projectileDirBox as integer
projectileDirBox = CreateObjectBox( 1.0, 1.0, 1.0 )
SetObjectPosition( projectileDirBox, GetVector3X( gunPositionVec ), GetVector3Y( gunPositionVec ), GetVector3Z( gunPositionVec ) )
setobjectrotation(projectiledirbox,GetObjectWorldAngleX(playerObj),GetObjectWorldAngleY(playerObj),GetObjectWorldAngleZ(playerObj))
MoveObjectLocalZ( projectileDirBox, 1.0 )
projectileDirVec = CreateVector3( GetobjectWorldX( projectileDirBox )-GetVector3X( gunPositionVec ), GetobjectWorldY( projectileDirBox )-GetVector3Y( gunPositionVec ), GetobjectWorldZ( projectileDirBox )-GetVector3Z( gunPositionVec ) )
DeleteObject( projectileDirBox )
throwBall as integer
throwBall = CreateObjectSphere(size, 16, 32 )
SetObjectColor( throwBall, 255, 0,0,255 )
SetObjectPosition( throwBall, GetVector3X( gunPositionVec ), GetVector3Y( gunPositionVec ), GetVector3Z( gunPositionVec ) )
SetObjectRotation(throwBall,GetObjectAngleX(playerObj),GetObjectAngleY(playerObj),GetObjectAngleZ(playerObj))
//3D Physics code
Create3DPhysicsDynamicBody( throwBall )
SetObjectShapeSphere(throwBall)
SetObject3DPhysicsMass( throwBall, mass )
SetObject3DPhysicsLinearVelocity( throwBall, projectileDirVec, initialSpeed )
//SetObject3DPhysicsFriction( throwBall, 0.8 )
//SetObject3DPhysicsRollingFriction( throwBall, 0.7 )
//SetObject3DPhysicsCanSleep(throwBall,0)
myItem as bullet
myItem.ID = throwBall //the object id of the bullet
myItem.time = timer() //timer is used to set there life time as bullets will die off after so long
myBullet.insert(myItem) //update bullet arrow as there is unlimeted bullets
inc bulletCount //used for a bullet counter to check if theyve timed out or not
deletevector3(projectileDirVec)
deletevector3(gunPositionVec)
endfunction
function toiletSetThemUp()
If getObjectExists(toiletObj) then DeleteObject(toiletObj)
LoadObject(toiletObj,"toilet.obj")
SetObjectScalePermanent(toiletObj,4,4,4)
SetObjectPosition(toiletObj,0,7,20)
SetObjectColor(toiletObj,255,255,255,100)
SetObjectTransparency(toiletObj,1)
RotateObjectLocalY(toiletObj,180)
Create3DPhysicsDynamicBody(toiletObj)
//SetObjectShapeConvexHull(toiletObj)
SetObject3DPhysicsMass(toiletObj, 1000.0 )
SetObject3DPhysicsFriction(toiletObj, 1 )
endfunction
They both fail when I try and place a dynamic object just above
About
With the hoop toss it tries to get a torus object over a cylinder
With the dunny toss I try to get a sphere object into the dunny bowl
Things ive Tried
SetObjectShapeConvexHull(obj) on the torus and the dunny and the balls
Quote: "Really not sure what is wrong any help would be greatly Appreciated

"
The Bottle Object http://users.tpg.com.au/subarpk/bottle2.obj
The Dunny Object http://users.tpg.com.au/subarpk/toilet.obj
The Hoop http://users.tpg.com.au/subarpk/taurus.obj
Quote: "As windows tries to view them in the browser you could copy to notepad and save or save target as should also work"
fubar