Hello Forum knights and lords
Decided to share one of some projects I have been working on since AppGameKit 2.0 was released , I waited for so long for 3d Physics once it was out I had to do some exercises with it
Sometimes I just play this and put it on a different screen then my main one ( got 3 ) and just let it be...
This project contains :
3d Physics
Render to Images
I'm pondering about releasing the code , well lets see what you thinking about it.
cause I know if one of you shader wizards Shader It , it will probably be even better.
FPS - reduced to 120 cause of game capture app... about 500 - 400 fps on my end.
P.s - Don't forget to see it under 720p.
Code released
///////////////////////////////////////// 3d Physics Demo //////////////////////////
///////////////////////////////////////// AGK 2.015d or better etc //////////////
///////////////////////////////////////// Created by Haliop ////////////////////////
///////////////////////////////////////// There is much more work to do /////
///////////////////////////////////////// here and i may have mistaken //////
///////////////////////////////////////// in somplaces, however it is very cool :D /////
/* ENJOY */
SetSyncRate( 0, 0 )
SetWindowTitle( " Smoother Physics ")
SetWindowSize( 1680,1050, 0 )
Create3DPhysicsWorld(193.0)
Set3DPhysicsGravity( 0, -193/19.3, 0 )
global numofballs as integer // the total Number of Diamonds
numofballs = 100 // number of maximum diamonds , i think multhitreading is not working well with the current stage of 3d physics
global timer1 as integer
type ActionTimer
delay as integer
time as integer
endtype
global cTime as actionTimer
cTime.delay = 75
// set display properties
VW = 1680
VH = 1050
SetVirtualResolution( VW,VH)
SetOrientationAllowed( 1, 1, 1, 1 )
SetCameraPosition( 1, 0, 100, 2500 )
SetCameraLookAt( 1, 0, -500, 0, 0 )
SetCameraRange(1,1,50000)
type elevator
id as integer
seq as integer
var1 as float
var2 as float
var3 as float
var4 as float
lightID as integer
loffsetY as float
loffsetX as float
offsetZ as float
endtype
type Diamond
id as integer
a as float
r as float
g as float
b as float
orga as float
trail as integer
light as integer
lightRad as float
lightDec as float
lightR as float
lightG as float
lightB as float
endtype
Dim Sphere[ numofballs ] as diamond
global dim oBox[500] as integer
global dim eBox[5] as elevator
global dim ramps[8] as integer
global currentObox as integer
//buidling the machines , didnt really cared about the id's just wanted to create them as in the final outcome only 2 remains dynamic all other ids dose not matter anymore..
fi = -1
r# = 0
g# = 0
b# = 0
for j = 14 to -1 step -1
//function CreateBox(px#,py#,pz#,sX#,sy#,sz#,aX#,ay#,az#,r,g,b,a,er,eg,eb,phys,physR,tran)
r# = r# +8
g# = g# + 8
if j > 0 and j < 8
CreateBox(-50 *fi,-(125*j),0,400,4,90,0,0,-10*fi,255,35,35,125,0,0,0,1,0.75,1)
ramps[j] = obox[currentObox]
elseif j = 8
CreateBox(-50 *fi,-(125*j),0,400,4,90,0,0,-10*fi,255,35,35,125,0,0,0,1,0.75,1)
ramps[j] = obox[currentObox]
endif
CreateBox(0,5-(100*j) ,50,500,4,100,90,0,0,r#,G#,255,100,0,0,0,1,0.75,1)
CreateBox(0,5-(100*j) ,-50,500,4,100,90,0,0,r#,g#,255,100,0,0,0,1,0.75,1)
fi = fi * -1
next j
// Elevator Tunnel
r# = 0
g# = 0
b# = 0
for j = 14 to -1 step -1
r# = r# + 8
g#= g# + 8
CreateBox(-300,5- (100 *j),50,100,25,100,90,0,0,r#,g#,255,135,0,0,0,1,0.75,1)
CreateBox(-300,5- (100 *j),-50,100,25,100,90,0,0,r#,g#,255,135,0,0,0,1,0.75,1)
CreateBox(-350,5- (100 *j),0,100,25,100,90,90,0,r#,g#,255,135,0,0,0,1,0.75,1)
if j <> 8 and j > 0
CreateBox(-250,5- (100 *j),0,100,1,100,90,90,0,r#,g#,255,135,0,0,0,1,0.75,1)
endif
fi = fi * -1
next j
// closing the upper Wind and Elevetor tunnel
CreateBox(-300,5- (150 *-1),0,100,25,100,0,0,0,r#,g#,255,135,0,0,0,1,0.75,1)
CreateBox(300,5- (150 *-1),0,100,25,100,0,0,0,r#,g#,255,135,0,0,0,1,0.75,1)
// /Wind Tunnel
r# = 0
g# = 0
b# = 0
c# = 25/7
c1# = 0.0
for j = 14 to -1 step -1
r# = r# + 8
g#= g# + 8
if j = 14
CreateBox(300,5- (100 *j),50,100,1,100,90,0,0,r#,g#,255,135,0,0,0,1,0.75,1)
CreateBox(300,5- (100 *j),-50,100,1,100,90,0,0,r#,g#,255,135,0,0,0,1,0.75,1)
else
c1# = c1# + c#
if c1# > 25 then c1# = 25
CreateBox(300,5- (100 *j),50,100,c1#,100,90,0,0,r#,g#,255,135,0,0,0,1,0.75,1)
CreateBox(300,5- (100 *j),-50,100,c1#,100,90,0,0,r#,g#,255,135,0,0,0,1,0.75,1)
endif
CreateBox(350,5- (100 *j),0,100,25,100,90,90,0,r#,g#,255,135,0,0,0,1,0.75,1)
if j > 0 and j < 13
CreateBox(250,5- (100 *j),0,100,1,100,90,90,0,r#,g#,255,135,0,0,0,1,0.75,1)
endif
fi = fi * -1
next j
// wind tunnel reflector with an angle so instead of flying down the diamonds will bounce back to the main space
CreateBox(300,130,0,125,1,100,0,0,-27.5,r#,g#,255,100,0,0,0,1,0.75,1)
currentlight = 1
// 2 Dynamic 3d Physics Objects - Elevator
CreateBox(-300,5- (100 *13),0,115,10,115,0,0,0,255,35,35,175,0,0,0,1,0.75,1)
eBox[1].id = obox[currentoBox]
eBox[1].lightID = currentlight
CurrentE = currentObox
OrgE = currentObox
CreateBox(-300,5- (100 *13),0,115,10,115,0,0,0,255,35,35,175,0,0,0,1,0.75,1)
eBox[2].id = oBox[currentoBox]
inc currentlight
eBox[2].lightid = currentlight
eBox[1].seq = 1
// creating lights for both elevators
CreatePointLight(1,-300,5- (100 *13),0,350,7500,7500,7500)
SetPointLightMode(1,0)
CreatePointLight(2,-300,5- (100 *13),0,350,7500,7500,7500)
SetPointLightMode(2,0)
// closing the machine's bottom
CreateBox(50,-1350,0,650,10,100,0,0,-15,255,35,35,100,0,0,0,1,0.75,1)
// Adding a Cylinder to the Wind and Elevator Tunnel for graphics ... hehe
tun = 1
for k =1 to 2
for j = 14 to 0 step -1
CreateBox(tun*300,-1350+j*100,-55,100,25,10,0,0,0,150,35,35,255,0,0,0,1,0.75,1)
CreateBox(tun*300,-1350+j*100,55,100,25,10,0,0,0,150,35,35,255,0,0,0,1,0.75,1)
CreateBox(tun*(300+60),-1350+j*100,0,25,25,125,0,0,0,150,35,35,255,0,0,0,1,0.75,1)
next j
tun = tun * -1
next k
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SetSyncRate( 0, 0)
thisBall = 0
seq = 1
p# = GetObjectY(oBox[currentE])
p1# = GetOBjectY(oBox[currentE])
ebox[1].var1 = p#
ebox[2].var1 = p#
pt = 1
ft# = 0
//currentE = 1
eAng# = 0
liftP# = 0
camera_Angle# = 0
camera_DistanceX# = GetCameraZ(1)*-1 + -50
camera_DistanceZ# = GetCameraZ(1)*-1 + -50
rampsyAngle# = 0
rampsT = 1
sx# = 1
sy# = 1
sz# = 1
// some rendering ? lets make a shadow for the diamonds :D
global ShadowImg as integer
global shadowImg2 as integer
global DiamondImg as integer
global ShadowObject as integer // might be sprite
global shadowObject2 as integer
global DiamondObject as integer
global BackObject as integer
BackImg = CreateRenderImage(2048,2048,0,0)
DiamondImg = CreateRenderImage(2048,2048,0,0)
ShadowImg = CreateRenderImage(2048,2048,0,0)
ShadowImg2 = CreateRenderImage(2048,2048,0,0)
//BackObject = CreateObjectQuad()
//DiamondObject = CreateObjectQuad()
//ShadowObject = CreateObjectQuad()
//ShadowObject2 = CreateObjectQuad()
BackObject = CreateObjectPlane(GetVirtualWidth(),GetVirtualHeight())
DiamondObject = CreateObjectPlane(GetVirtualWidth(),GetVirtualHeight())
ShadowObject = CreateObjectPlane(GetVirtualWidth(),GetVirtualHeight())
ShadowObject2 = CreateObjectPlane(GetVirtualWidth(),GetVirtualHeight())
SetObjectTransparency(backobject,1)
SetObjectTransparency(dIamondobject,1)
SetObjectTransparency(ShadowObject,1)
SetObjectTransparency(ShadowObject2,1)
SetObjectLightMode(shadowOBject,0)
SetObjectLightMode(shadowOBject2,0)
SetObjectLightMode(backOBject,0)
SetObjectLightMode(diamondOBject,0)
shadowR = 255
shadowG = 255
shadowB = 255
SetOBjectColor(ShadowObject2,shadowR,shadowG,shadowB,255)
SetOBjectColor(ShadowObject,shadowR-50,shadowG-50,shadowB-50,255)
SetOBjectColor(DiamondObject,255,255,255,500)
SetOBjectColor(backObject,255,255,255,255)
//SetObjectColorEmissive(backObject,255,0,0)
//SetObjectColorEmissive(shadowObject,0,0,0)
SetObjectScale(shadowObject2,2.25,2.25,2.25)
SetObjectScale(shadowObject,2.25,2.25,2.25)
SetObjectScale(backObject,2.25,2.25,2.25)
SetObjectScale(diamondObject,2.25,2.25,2.25)
SetObjectPosition(ShadowObject2,0,-500,0)
SetObjectPosition(ShadowObject,0,-500,0)
SetObjectPosition(diamondObject,0,-500,0)
SetObjectPosition(backObject,0,-500,0)
SetObjectVisible(shadowOBject2,0)
SetObjectVisible(shadowOBject,0)
SetObjectVisible(BackOBject,0)
SetObjectVisible(DiamondOBject,0)
shadow_MX# = 0
shadow_MY# = 0
shadow_MZ# = 0
Shadow_MXUP =1
w = 1
spherecreated = 0
global RotationX as float
RotationX = 0
global windTunnelPower as float
global timestoclean as integer
global currentclean as integer
global shadowAlpha as float
global shadowAlphaT as integer
shadowAlpha =1
shadowAlphaT = 1
timestoclean = 175
cs = 1
cleaningtime = 0
cleaningTimeT as ActionTimer
cleaningTimeT.delay = 25
s1 = 0
shadow_x# = 0
shadow_z# = 0
shadow_a# = 0
shadow_scale# = 2.25
s_dist# = 50
backcaptured = 0
//CreatePointLight( 1, 0,-500,0,1000, 10000, 10000, 10000 )
dRenderNow = 1
sRenderNow = 1
bRenderNow = 1
cs = 1 // Shadow Cycle Render
RenderTimes = 2
pointerX# = 0
pointerY# = 0
pointerLastX# = 0
pointerLastY# = 0
pointerMoveX# = 0
pointerMoveY# = 0
SetRawMousePosition(VW/2,VH/2)
SetSunActive(0)
SetSunColor(255,255,255)
SetAmbientColor(255,255,255)
sunX# = 0
sunY# = 0
sunZ# = 0
global dim rLights[10] as integer
global dim rlightsTi[10] as ActionTimer
for i = 1 to 10
rlightsTi[i].delay = 78
CreatePointLight(i+10,0,0,0,50,2550,2550,2550)
SetPointLightMode(i+10,0)
next i
do
pointerLastX# = pointerX#
pointerLastY# = pointerY#
pointerX# = GeTPointerX()
pointerY# = GetPointerY()
pointerMoveX# = pointerX# - pointerLastX#
pointerMoveY# = pointerY# - pointerLastY#
//clearScreen()
inc dREnderNow
if dRenderNow = renderTimes
SetRenderToImage(DiamondImg,0)
ClearScreen()
endif
windTunnelPower = 1.0
for i =1 to 10 // rlights loop
rindex = random(1,numofballs)
SetPointLightPosition(i+10,GetObjectX(sphere[rindex].id),GetObjectY(sphere[rindex].id),GetOBjectZ(sphere[rindex].id))
//Set
next i
for i = 1 to numofballs
if sphere[i].id > 0
if sphere[i].light > 0
SetPointLightPosition(sphere[i].light,getobjectX(sphere[i].id),getobjectY(sphere[i].id),getobjectZ(sphere[i].id))
if sphere[i].lightRad > 1
SetPointLightRadius(sphere[i].light,sphere[i].lightRad)
sphere[i].lightRad = sphere[i].lightRad - sphere[i].lightDec *ft#
//SetPointLightColor(sphere[i].light,random(1,255)*100,random(1,255)*100,random(1,255)*100)
//sphere[i].lightr = sphere[i].lightr+ sphere[i].r/10 * ft#
//sphere[i].lightg = sphere[i].lightg+ sphere[i].g/10 * ft#
//sphere[i].lightb = sphere[i].lightb+ sphere[i].b/10* ft#
//sphere[i].orgA = sphere[i].orgA + 100 * ft#
//SetObjectColorEmissive(sphere[i].id,sphere[i].lightr,sphere[i].lightg,sphere[i].lightb)
//SetObjectColor(sphere[i].id,sphere[i].r,sphere[i].g,sphere[i].b,sphere[i].orgA)
else
DeletePointLight(sphere[i].light)
sphere[i].light = 0
endif
endif
if dREnderNow = rendertimes
SetObjectVisible(sphere[i].id,1)
drawObject(sphere[i].id)
if sphere[i].trail = 0 then SetObjectVisible(sphere[i].id,0)
endif
if GetOBjectX(sphere[i].id) > 300 and GetOBjectX(sphere[i].id) < 400 and GetObjectZ(sphere[i].id) > -50 and GetobjectZ(sphere[i].id) < 50 and GetObjectY(sphere[i].id) < -500
if sphere[i].light = 0
inc currentlight
sphere[i].light = currentlight
sphere[i].lightDec = 50
sphere[i].lightRad = random(125,150)*2.5
CreatePointLight(sphere[i].light,GetObjectX(sphere[i].id),GetObjectY(sphere[i].id),GetObjectZ(sphere[i].id),sphere[i].lightRad,sphere[i].r*10,sphere[i].g*10,sphere[i].b*10)
SetPointLightMode(sphere[i].light,1)
endif
if sphere[i].trail = 0
sphere[i].a = sphere[i].orga /2
sphere[i].trail = 1
SetObject3DPhysicsLinearVelocity( sphere[i].id, 0, random(10000,25000),0,random(3500+windtunnelPOwer,6000+windTunnelPower))
WindTunnelPower = WindTunnelPower + 0.5
endif
elseif GetOBjectX(sphere[i].id) < -300 and GetOBjectX(sphere[i].id) > -400 and GetObjectZ(sphere[i].id) > -50 and GetobjectZ(sphere[i].id) < 50 and GetObjectY(sphere[i].id) < -1200
// if sphere[i].light = 0
// inc currentlight
// sphere[i].light = currentlight
// sphere[i].lightRad = random(50,150)
// sphere[i].lightDec = 10.0
// CreatePointLight(sphere[i].light,GetObjectX(sphere[i].id),GetObjectY(sphere[i].id),GetObjectZ(sphere[i].id),sphere[i].lightRad,sphere[i].r*1000,sphere[i].g*1000,sphere[i].b*1000)
// SetPointLightMode(sphere[i].light,0)
// endif
elseif GetobjectY(sphere[i].id) < -1450
//sphere[i].trail = 1
Delete3DPhysicsBody( Sphere[ i ].id )
SetObjectPosition( Sphere[ i ].id, random2( -100, 50 ), random( 500,700 ), random2(-15,5) )
Create3DPhysicsDynamicBody( Sphere[ i ].id )
SetObjectShapeSphere( Sphere[ i ].id )
SetObject3DPhysicsRollingFriction( Sphere[ i ].id, 0 )
SetObject3DPhysicsRestitution( Sphere[ i ].id, 0.25 )
endif
elseif sphere[i].id = 0
if cTime.delay + cTime.time < TIMER1
//sphere[i].trail = 1
r = random(1,3)
//if i = 1
//sphere[i].id = CreateObjectPlane(random(5,15),random(5,15))
//else
// sphere[i].id = CloneObject(sphere[1].id)
//endif
multi1# = 1.75
if r = 1
sphere[i].id = CreateObjectSphere(random(10,15)*multi1#,random(8,16),random(8,16))
elseif r = 2
sphere[i].id = CreateObjectBox(random(10,15)*multi1#,random(5,15)*multi1#,random(5,15)*multi1#)
elseif r = 3
sphere[i].id = CreateObjectCone(random(10,15)*multi1#,random(8,16),random(8,16))
elseif r = 4
sphere[i].id = CreateObjectPlane(random(10,15)*multi1#,random(10,15)*multi1#)
endif
sphere[i].r = random(1,255)
sphere[i].g = random(1,255)
sphere[i].b = random(1,255)
sphere[i].a = random(75,255)
sphere[i].orga = sphere[i].a
//SetObjectTransparency(sphere[i],1)
SetObjectColor(sphere[i].id,sphere[i].r,sphere[i].g,sphere[i].b,sphere[i].a)
SetObjectTransparency(sphere[i].id,1)
SetObjectPosition( Sphere[ i ].id, random2( -150, 50 ), random( 500, 700 ), random( -5, 5 ) )
//if i = 1
Create3DPhysicsDynamicBody( Sphere[ i ].id )
SetObject3DPhysicsMass(sphere[i].id,50)
//if r = 1
SetObjectShapeSphere( Sphere[ i ].id )
//elseif r = 2
//SetObjectShapeBox( Sphere[ i ].id )
//elseif r = 3
//SetObjectShapeCone( Sphere[ i ].id ,1)
//endif
SetObject3DPhysicsRollingFriction( Sphere[ i ].id, 0 )
SetObject3DPhysicsRestitution( Sphere[ i ].id, 0.35 )
//endif
cTime.time = TIMER1
inc spherecreated
//if sphere[i].light = 0
//inc currentlight
//sphere[i].light = currentlight
//sphere[i].lightDec = 17.5
//sphere[i].lightRad = 25
//CreatePointLight(sphere[i].light,GetObjectX(sphere[i].id),GetObjectY(sphere[i].id),GetObjectZ(sphere[i].id),sphere[i].lightRad,sphere[i].r*100,sphere[i].g*100,sphere[i].b*100)
//SetPointLightMode(sphere[i].light,1)
//endif
//SetObjectVisible(Sphere[i],0)
endif
endif
next i
if dRenderNow = rendertimes
dRenderNow = 0
SetObjectImage(DiamondObject,DiamondImg,0)
endif
render()
inc sRenderNow
if sRenderNow = rendertimes
sRenderNow = 0
cs = cs * -1
if cs = 1
SetRenderToImage(ShadowImg,0)
else
SetRenderToImage(ShadowImg2,0)
endif
for i = 1 to numofballs
if sphere[i].trail = 1
sphere[i].a = sphere[i].a - 15*rendertimes * ft#
SetobjectColor(sphere[i].id,sphere[i].r,sphere[i].g,sphere[i].b,sphere[i].a)
if sphere[i].a < 0
sphere[i].trail = 0
sphere[i].a = sphere[i].orga
//DeletePointLight(sphere[i].light)
endif
rr = random(-1,1)
SetObjectScale(sphere[i].id,1.25 + random(1,100) *0.01*rr,1.25+ random(1,100) *0.01*rr,1.25+random(1,100) *0.01*rr)
drawObject(sphere[i].id)
//drawObject(sphere[i].id)
setobjectvisible(sphere[i].id,0)
SetObjectColor(sphere[i].id,sphere[i].r,sphere[i].g,sphere[i].b,sphere[i].orga)
SetObjectScale(sphere[i].id,1,1,1)
endif
next i
if cs = 1
SetObjectImage(ShadowObject,ShadowImg,0)
else
SetObjectImage(ShadowObject2,ShadowImg2,0)
endif
endif
render()
//SetObjectVisible(shadowImg,0)
inc bRenderNow
if bRenderNow = rendertimes
SetRenderToImage(BackImg,0)
ClearScreen()
/*
inc currentclean
if timestoclean < currentclean
currentclean = 0
print("AHSDH")
ClearScreen()
endif
*/
for i = 1 to currentObox
if Obox[i] > 0
SetObjectVisible(obox[i],1)
DrawObject(obox[i])
SetObjectVisible(obox[i],0)
endif
next i
//inc backcaptured
bRenderNow = 0
render()
SetObjectimage(backOBject,BackImg,0)
endif
if rampsYangle# > 15 or rampsYAngle# < -15
rampsT = rampsT * -1
rampsYAngle# = 15 *rampsT * -1
endif
rampsyAngle# = rampsYAngle# + 35*ft# * rampsT
aza = 1
for i =1 to 8
//SetObjectVisible(ramps[i],1)
SetObjectRotation(ramps[i],rampsyangle#*aza,GetObjectAngleY(ramps[i]),GetObjectAngleZ(ramps[i]))
//DrawObject(ramps[i])
//SetObjectVisible(ramps[i],0)
aza = aza *-1
next i
camera_angle# = camera_angle# - rotationX *ft#
if PointerMoveX# <> 0
RotationX = RotationX+ (PointerMoveX# * (ft#* 0.787))*1250
endif
if RotationX <>0
RotationX = RotationX - RotationX*4.787*ft#
endif
camera_x# = sin(camera_angle#) * camera_distanceZ#
camera_z# = cos(camera_angle#) * camera_distanceZ#
SetCameraPosition(1,camera_x#,500,camera_z#)
SetCameraLookAt(1,0,-525,0,0)
SetObjectLookAt(diamondOBject,camera_x#,500,camera_z#,0)
SetObjectLookAt(ShadowOBject2,camera_x#,500,camera_z#,0)
SetObjectLookAt(ShadowOBject,camera_x#,500,camera_z#,0)
SetObjectLookAt(backOBject,camera_x#,500,camera_z#,0)
Camera_distanceZ# = camera_distanceZ# - PointerMoveY# * ft# *1000
shadow_a# = shadow_a# + 550 * ft#
shadow_x# = sin(shadow_a#) * s_dist#
shadow_z# = cos(shadow_a#) * s_dist#
//SetRenderToScreen()
//SetObjectPosition(shadowObject,shadow_X#,GetObjectY(shadowObject),GetOBjectZ(shadowOBject))
//SetPointLightPosition(1,shadow_x#,500,shadow_z#)
//shadow_x# = sin(-shadow_a#) * s_dist#
//shadow_z# = cos(-shadow_a#) * s_dist#
//SetObjectPosition(shadowObject2,shadow_X#,GetObjectY(shadowObject2),GetOBjectZ(shadowOBject2))
ft# = GetFrameTime()
timer1 = GetMilliseconds()
for i = 1 to 2
SetPointLightPosition(ebox[i].lightID,GetObjectX(eBox[i].id),GetObjectY(eBox[i].id)+5,GetOBjectZ(eBox[i].id))
if eBox[i].seq = 1
ebox[i].var1 = ebox[i].var1 + ebox[i].var2 *ft#
ebox[i].var2 = ebox[i].var2 + 0.175
if ebox[i].var1 > 0
eBox[i].seq = 2
endif
SetObjectPosition(eBox[i].id,-300,ebox[i].var1,0)
elseif eBox[i].seq = 2
ebox[i].var1 = ebox[i].var1 -50 * ft#
if ebox[i].var1 < -45
eBox[i].seq = 3
endif
SetObjectRotation(eBox[i].id,0,0,ebox[i].var1)
elseif eBox[i].seq = 3
ebox[i].var1= ebox[i].var1 + 25 * ft#
if ebox[i].var1 > 0
eBox[i].seq = 4
ebox[i].var1= GetObjectY(eBox[i].id)
if eBox[i+1].id > 0
if eBox[i+1].seq = 0
eBox[i+1].seq = 1
ebox[i+1].var1 = GetObjectY(eBox[i+1].id)
ebox[i+1].var2 = 0
ebox[i+1].var3 = 1
endif
elseif eBox[i-1].id > 0
if eBox[i-1].seq = 0
eBox[i-1].seq = 1
ebox[i-1].var1 = GetObjectY(eBox[i-1].id)
ebox[i-1].var2 = 0
ebox[i-1].var3 = 1
endif
endif
endif
SetObjectRotation(eBox[i].id,0,0,ebox[i].var1)
elseif eBox[i].seq = 4
if ebox[i].var3 > 0.1
ebox[i].var3 = ebox[i].var3 - 0.787 *ft#
SetObjectScale(eBox[i].id,sx#,sy#,ebox[i].var3)
SetObjectPosition(eBox[i].id,GetObjectX(eBox[i].id),GetObjectY(eBox[i].id),GetOBjectZ(eBox[i].id)+0.787 *78.7*ft#)
else
eBox[i].seq = 5
endif
elseif eBox[i].seq = 5
ebox[i].var1 = ebox[i].var1- 500 * ft#
if p1# > GetObjectY(eBox[i].id)-50
ebox[i].seq = 6
//p# = 0
endif
SetObjectPosition(eBox[i].id,-300,ebox[i].var1,GetObjectZ(eBox[i].id))
elseif eBox[i].seq = 6
if ebox[i].var3 < 1
ebox[i].var3 = ebox[i].var3 + 0.787 *ft#
SetObjectScale(eBox[i].id,sx#,sy#,ebox[i].var3)
SetObjectPosition(eBox[i].id,GetObjectX(eBox[i].id),GetObjectY(eBox[i].id),GetOBjectZ(eBox[i].id)-0.787 *78.7*ft#)
else
eBox[i].seq = 0
ebox[i].var1 = GetObjectY(eBox[i].id)
ebox[i].var2 = 0
ebox[i].var3 = 1
SetObjectRotation(eBox[i].id,0,0,0)
endif
endif
next i
//if seq < 2
//eAng# = eAng#+25* ft#
//SetObjectRotation(oBox[currentE],GetObjectAngleX(oBox[currentE]),eAng#,GetObjectAnglez(oBox[currentE]))
//endif
inc thisball
if thisball > numofballs
thisball = 0
endif
//update(0.02)
nextball = numofballs - (thisball+5)
if nextball < 0
nextball = 5-(nextball*-1)
else
nextball = 5
endif
// for i = 1 to currentObox
// SetObjectVisible(oBox[i],1)
// drawObject(oBox[i])
// SetOBjectVisible(oBox[i],0)
// next i
//render()
// rendering diamons on another render
//shadow_scale# = shadow_scale#+ 0.001 * ft# * shadowAlphaT
//0
//setObjectScale(ShadowObject,shadow_scale#,shadow_scale#,shadow_Scale#)
shadowAlpha = shadowAlpha +100 * ft# *shadowAlphaT
if shadowAlphaT = -1 then shadowAlpha = shadowAlpha + 250 * ft# *shadowAlphaT
if shadowAlpha > 100 or shadowAlpha <0
inc cleaningtime
if shadowAlphaT = 1
ShadowAlpha = 100
SetRenderToImage(ShadowImg2,0)
ClearScreen()
render()
setRenderToScreen()
endif
if shadowAlphaT = -1
ShadowAlpha = 0
SetRenderToImage(ShadowImg,0)
ClearScreen()
render()
setRenderToScreen()
endif
shadowAlphaT = shadowAlphaT * -1
endif
SetObjectColor(ShadowObject,shadowR,shadowG,shadowB,shadowAlpha)
SetObjectColor(ShadowObject2,shadowR,shadowG,shadowB,100 - shadowAlpha)
SetRenderToScreen()
Print( ScreenFPS() )
// print(a)
if GetPointerState() = 1
//drawOBject(ShadowObject)
//SetObjectVisible(ShadowObject,0)
shadow_MX#= shadow_MX# + 0.0001 * Shadow_MXUP
if shadow_MX# > 0.05 or shadow_MX# < -0.05
shadow_MXUP = shadow_MXUP * -1
else
SetObjectPOSition(ShadowObject,GetObjectX(ShadowObject)+shadow_MX#,GetObjectY(ShadowObject)-shadow_MX#*7,GetObjectZ(shadowOBject))
endif
endif
//ClearScreen()
//if timestoclean = 1
//SetObjectColor(ShadowObject,shadowR,shadowG,shadowB,shadowAlpha)
//SetObjectColor(diamondObject,255,255,255,255)
//else
//SetObjectColor(diamondObject,255,255,255,shadowAlpha)
//endif
//DraWObject(BackObject)
SetObjectVisible(ShadowObject,1)
drawOBject(shadowObject)
SetOBjectVisible(shadowOBject,0)
SetObjectVisible(ShadowObject2,1)
drawOBject(shadowObject2)
SetOBjectVisible(shadowOBject2,0)
SetObjectVisible(diamondObject,1)
drawOBject(DiamondObject)
SetOBjectVisible(diamondOBject,0)
SetObjectVisible(backobject,1)
DraWObject(BackObject)
SetObjectVisible(backObject,0)
Step3DPhysicsWorld()
render()
swap()
loop
function CreateBox(px#,py#,pz#,sX#,sy#,sz#,aX#,ay#,az#,r,g,b,a,er,eg,eb,phys,physR,tran)
inc currentObox
id = 0
id = CreateObjectBox( sx#, sy#, sz# )
SetObjectColor(id,r,g,b,a-50)
SetObjectColorEmissive(id,r,g,b)
SetObjectTransparency(id,tran)
Create3DPhysicsKinematicBody( id )
SetObject3DPhysicsRestitution( id, physR) // 0.75
SetObjectShapeBox( id)
SetObjectRotation(id,ax#,ay#,az#)
SetObjectPosition( id, px#,py#,pz# ) // bottom
SetOBjectVisible(id,0)
SetObjectLightMode(id,1)
oBox[currentObox] = id
endfunction