Is there some reason why this shouldn't work or am i doing something wrong?
Here is the code
// Project: test222
// Created: 20-05-17
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "test222" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
create3DPhysicsWorld()
//Set3DPhysicsGravity(0, 10, 0)
obj = createobjectSphere(60, 16, 16)
setobjectposition(obj, 0, 100, 0)
SetObjectColor(obj, 0xff, 0, 0, 0xff)
Create3DPhysicsDynamicBody(obj)
SetObjectShapeSphere(obj)
SetObject3DPhysicsCanSleep(obj, 0)
SetCameraPosition(1, 0, 200, -300)
SetCameraLookAt(1, 0, 0, 0, 0)
container = CreateABox()
x as float
y as float
do
if GetPointerPressed()
x = GetPointerX()
y = GetPointerY()
endif
if GetPointerState()
RotateObjectLocalX(container, (GetPointerY() - y) * -0.1)
RotateObjectLocalY(container, (GetPointerX() - X) * -0.1)
y = GetPointerY()
x = GetPointerX()
endif
print("Click and drag to rotate the box")
Step3DPhysicsWorld()
Sync()
loop
function CreateABox()
sides as integer[]
side as integer
base as integer
pos as integer
rot as integer
size as integer
x as float
y as float
z as float
base = CreateObjectBox(100, 5, 100)
SetObjectPosition(base, 0, 0, 0)
SetObjectColor(base, 0, 0xff, 0, 0xff)
sides.insert(base)
side = CreateObjectBox(100, 100, 5)
SetObjectPosition(side, 0, 53, -53)
FixObjectToObject(side, base)
sides.insert(side)
side = CreateObjectBox(100, 100, 5)
SetObjectPosition(side, 0, 53, 53)
FixObjectToObject(side, base)
sides.insert(side)
side = CreateObjectBox(5, 100, 100)
SetObjectPosition(side, 53, 53, 0)
FixObjectToObject(side, base)
sides.insert(side)
side = CreateObjectBox(5, 100, 100)
SetObjectPosition(side, -53, 53, 0)
FixObjectToObject(side, base)
sides.insert(side)
Create3DPhysicsKinematicBody(base)
SetObjectShapeCompound(base)
pos = CreateVector3(0, 0, 0)
rot = CreateVector3(0, 0, 0)
size = CreateVector3(0, 0, 0)
for i=0 to sides.length
SetVector3(pos, GetObjectX(sides[i]), GetObjectY(sides[i]), GetObjectZ(sides[i]))
SetVector3(rot, 0, 0, 0)
x = (GetObjectSizeMaxX(sides[i]) - GetObjectSizeMinX(sides[i])) * 0.5
y = (GetObjectSizeMaxY(sides[i]) - GetObjectSizeMinY(sides[i])) * 0.5
z = (GetObjectSizeMaxZ(sides[i]) - GetObjectSizeMinZ(sides[i])) * 0.5
SetVector3(size, x, y, z)
AddObjectShapeBox(base, pos, rot, size)
next
endfunction base