Large update,
Got rid of the collision for now, just while I fix other stuff..
The raycasting went fine till I had to find the points of the intersection, at first I thought it was pretty easy, but for some reason it wasn't, and I still need to muck around a bit more before I get the Y coords right...
anyway, here's a demo of what it was do:
Uses custom vectors to calculate the speed, my own raycasting (which shows a red circle where it intersects), and it shows the distance between you and the large object, using some little things I added used only for distances, I might make them use vectors, but that would mean I would have to make the user create the vectors first, which is quite impractical, so I'm a bit stuck
Demo:
`Setup
ZStandardSetup() :` #include "Zee-Physics V2.dba"
`Create car
ZCreateCube(1) : ZSetupObject(1)
ZScaleObj(1,40,30,50) : ZSetMass(1,100)
ZAddDrag(1,0.98,0.98,0.98) : ZAddATrac(1,0.98,0.98,0.98)
ZAddBrake(1,0.8,0.8,0.8)
`Create Level
Make Matrix 1,10000,10000,35,35
`Create Object to play with
ZCreateCapsule(10) : ZScaleObj(10,1000,1000,1000) : ZSetAng(10,90,30,0)
ZSetPos(10,5000,0,5000)
`Create Vectors/Rays/Lines
ZMakeVector3(1)
ZCreateRay(1)
ZCreateDistLine(1)
`Create Object to show intersection
ZCreateSphere(2,20,20) : ZScaleObj(2,30,30,30)
color object 2,rgb(255,0,0)
set object ambient 1,0
`**Main Loop**
Do
`Controls
If Upkey()=1 then ZPushFor(1,100) else ZDepleatForce(1)
If Leftkey()=1 then ZAddTorque(1,0,-8,0)
If Rightkey()=1 then ZAddTorque(1,0,8,0)
If Leftkey()=0 and Rightkey()=0 then ZDepleatTorque(1)
If ControlKey()=1 then ZEnableBrake(1)
`Switch between earth and space
If Spacekey()=0 then mode=1 else mode=0
if mode=1
ZEnableDrag(1) : ZEnableATrac(1)
mode$="Earth"
else
mode$="Space"
Endif
`Update Physics
ZUpdateCalc(1,1) : ZUpdateObj(1)
`Camera
ca#=curveangle(ZGetAngY(1),ca#,20.0)
cx#=ZGetPosX(1)-Sin(ca#)*600 : Cz#=ZGetPosZ(1)-Cos(ca#)*600 : cy#=ZGetPosY(1)+300
Position Camera cx#,cy#,cz# : Point camera ZGetPosX(1),ZGetPosY(1),ZGetPosZ(1)
`User Prompt
Ink rgb(0,255,0),0
text 10,730,"Use Space to switch between Earth mode and Space Mode"
text 10,750,"Current Mode: "+mode$
`Use Vectors to calculate Speed
ZSetVector3(1,ZGetVelX(1),ZGetVelY(1),ZGetVelZ(1))
Speed#=ZVectorLength3(1)
`Use ray to calculate distance to intersection
IDist#=ZCastRay(1,ZGetPosX(1),ZGetPosY(1)+16,ZGetPosZ(1),0,ZGetAngY(1),0x7fffffff,10)
ZCalcRayInt(1)
ZSetPos(2,ZGetRayIntX(1),ZGetRayIntY(1),ZGetRayIntZ(1))
`Use Distance Line to calculate distance
ZPositionDistLine1(1,ZGetPosX(1),ZGetPosY(1),ZGetPosZ(1))
ZPositionDistLine2(1,Object Position X(10),Object Position Y(10),Object Position Z(10))
Dist#=ZGetDistance(1)
`Show data
Text 10,10,"FPS: "+ZGetFPS()
Text 10,50,"Speed: "+str$(speed#)
Text 10,70,"Distance from object: "+str$(dist#)
Text 10,90,"Distance to Intersection: "+str$(IDist#)
text 10,110,"Int X: "+str$(ZGetRayIntX(1))
text 10,130,"Int Y: "+str$(ZGetRayIntY(1))
text 10,150,"Int Z: "+str$(ZGetRayIntZ(1))
`**End loop**
Sync
Loop
`**Functions**
Function ZStart()
Global T as integer
T=Timer()
Endfunction
Function ZStandardSetup()
Sync on : Sync rate 60
Set display mode 1024,768,16 : Hide Mouse
Set Window On : Maximize Window
Autocam off : Set Camera Range 1,0x7fffffff
Color Backdrop RGB(0,0,0)
ZStart()
Endfunction
Function ZGetVersion()
v$="Zee-Physics V2"
Endfunction v$
Function ZGetFPS()
f$=Str$(Screen FPS())
Endfunction f$
Function ZGetTime()
time=Timer()-T
Endfunction time
Function ZGetTimeInSec()
sec=(Timer()-T)/1000
Endfunction sec
Function ZSetupObject(o)
Dim ObjGrav(o) as Float : Dim ObjMass(o) as Float : Dim ObjWeight(o) as Float
Dim Ground(o) as Float : Dim ObjDrop(o) as Float
Dim PosX(o) as Float : Dim PosY(o) as Float : Dim Posz(o) as Float
Dim OldPosX(o) as Float : Dim OldPosY(o) as Float : Dim OldPosZ(o) as Float
Dim AngX(o) as Float : Dim AngY(o) as Float : Dim AngZ(o) as Float
Dim OldAngX(o) as Float : Dim OldAngY(o) as Float : Dim OldAngZ(o) as Float
Dim MoveAngX(o) as Float : Dim MoveAngY(o) as Float : Dim MoveAngZ(o) as Float
Dim DragFX(o) as Float : Dim DragFY(o) as Float : Dim DragFZ(o) as Float
Dim BrakFX(o) as Float : Dim BrakFY(o) as Float : Dim BrakFZ(o) as Float
Dim BrakAFX(o) as Float : Dim BrakAFY(o) as Float : Dim BrakAFZ(o) as Float
Dim TracFX(o) as Float : Dim TracFY(o) as Float : Dim TracFZ(o) as Float
Dim TracAFX(o) as Float : Dim TracAFY(o) as Float : Dim TracAFZ(o) as Float
Dim AngFX(o) as Float : Dim AngFY(o) as Float : Dim AngFZ(o) as Float
Dim AngVX(o) as Float : Dim AngVY(o) as Float : Dim AngVZ(o) as Float
Dim AngAX(o) as Float : Dim AngAY(o) as Float : Dim AngAZ(o) as Float
Dim ObjFX(o) as Float : Dim ObjFY(o) as Float : Dim ObjFZ(o) as Float
Dim ObjVX(o) as Float : Dim ObjVY(o) as Float : Dim ObjVZ(o) as Float
Dim ObjAX(o) as Float : Dim ObjAY(o) as Float : Dim ObjAZ(o) as Float
Dim ObjDX(o) as Float : Dim ObjDY(o) as Float : Dim ObjDZ(o) as Float
Dim ObjOX(o) as Float : Dim ObjOY(o) as Float : Dim ObjOZ(o) as Float
Dim ObjF(o) as Float : Dim ObjS(o) as Float : Dim AngF(o) as Float
Dim MoveT(o) : Dim MoveD(o) as Float : Dim MoveA(o) as Float
Endfunction
Function ZSetGrav(o,grav as float)
ObjGrav(o)=grav
Endfunction
Function ZSetMass(o,mass as float)
ObjMass(o)=mass
Endfunction
Function ZWeighObj(o)
ObjWeight(o)=ObjMass(o)*ObjGrav(o)
Endfunction
Function ZAddForce(o,x as float,y as float,z as float)
ObjFX(o)=x : ObjFY(o)=y : ObjFZ(o)=z
Endfunction
Function ZAddTorque(o,x as float, y as float, z as float)
AngFX(o)=x : AngFY(o)=y : AngFZ(o)=z
Endfunction
Function ZAddDrag(o,x as float,y as float,z as float)
DragFX(o)=x : DragFY(o)=y : DragFZ(o)=z
Endfunction
Function ZAddTrac(o,x as float,y as float,z as float)
TracFX(o)=x : TracFY(o)=y : TracFZ(o)=z
Endfunction
Function ZAddATrac(o,x as float,y as float,z as float)
TracAFX(o)=x : TracAFY(o)=y : TracAFZ(o)=z
Endfunction
Function ZAddBrake(o,x as float, y as float, z as float)
BrakFX(o)=x : BrakFY(o)=y : BrakFZ(o)=z
Endfunction
Function ZAddABrake(o,x as float, y as float, z as float)
BrakAFX(o)=x : BrakAFY(o)=y : BrakAFZ(o)=z
Endfunction
Function ZDepleatForce(o)
ZAddForce(o,0.0,0.0,0.0)
Endfunction
Function ZDepleatTorque(o)
ZAddTorque(o,0.0,0.0,0.0)
Endfunction
Function ZDepleatDrag(o)
ZAddDrag(o,1.0,1.0,1.0)
Endfunction
Function ZDepleatTrac(o)
ZAddTrac(o,1.0,1.0,1.0)
Endfunction
Function ZDepleatATrac(o)
ZAddATrac(o,1.0,1.0,1.0)
Endfunction
Function ZDepleatBrake(o)
ZAddbrake(o,1.0,1.0,1.0)
Endfunction
Function ZDepleatABrake(o)
ZAddABrake(o,1.0,1.0,1.0)
Endfunction
Function ZEnableDrag(o)
ObjVX(o)=ObjVX(o)*DragFX(o)
ObjVY(o)=ObjVY(o)*DragFY(o)
ObjVZ(o)=ObjVZ(o)*DragFZ(o)
Endfunction
Function ZEnableBrake(o)
ObjVX(o)=ObjVX(o)*BrakFX(o)
ObjVY(o)=ObjVY(o)*BrakFY(o)
ObjVZ(o)=ObjVZ(o)*BrakFZ(o)
ZAddForce(o,0,0,0)
Endfunction
Function ZEnableABrake(o)
AngVX(o)=AngVX(o)*BrakAFX(o)
AngVY(o)=AngVY(o)*BrakAFY(o)
AngVZ(o)=AngVZ(o)*BrakAFZ(o)
Endfunction
Function ZEnableTrac(o)
ObjVX(o)=ObjVX(o)*TracFX(o)
ObjVY(o)=ObjVY(o)*TracFY(o)
ObjVZ(o)=ObjVZ(o)*TracFZ(o)
Endfunction
Function ZEnableATrac(o)
AngVX(o)=AngVX(o)*TracAFX(o)
AngVY(o)=AngVY(o)*TracAFY(o)
AngVZ(o)=AngVZ(o)*TracAFZ(o)
Endfunction
Function ZEnableGravity(o)
If PosY(o)>Ground(o)
ObjDrop(o)=ObjWeight(o)
else
ObjDrop(o)=ObjDrop(o)*0.0
Endif
Endfunction
Function ZEnableAll(o)
If DragFX(o)>0 or DragFY(o)>0 or DragFZ(o)>0 then ZEnableDrag(o)
If BrakFX(o)>0 or BrakFY(o)>0 or BrakFZ(o)>0 then ZEnableBrake(o)
If BrakAFX(o)>0 or BrakAFY(o)>0 or BrakAFZ(o)>0 then ZEnableABrake(o)
If TracFX(o)>0 or TracFY(o)>0 or TracFZ(o)>0 then ZEnableTrac(o)
If TracAFX(o)>0 or TracAFY(o)>0 or TracAFZ(o)>0 then ZEnableATrac(o)
ZEnableGravity(o)
Endfunction
Function ZPushOnLine(o,x as float,y as float,frc as float)
ZAddForce(o,(sin(y)*cos(x))*frc,-sin(x)*frc,(cos(y)*cos(x))*frc)
Endfunction
Function ZMoveOnLine(o,x as float,y as float,spd as float)
ZMoveObj(o,(sin(y)*cos(x))*spd,-sin(x)*spd,(cos(y)*cos(x))*spd)
Endfunction
Function ZPushFor(o,frc)
ZAddForce(o,(sin(angY(o))*cos(angX(o)))*frc,-sin(angX(o))*frc,(cos(angY(o))*cos(angX(o)))*frc)
Endfunction
Function ZMoveFor(o,spd)
ZAddForce(o,(sin(angY(o))*cos(angX(o)))*spd,-sin(angX(o))*spd,(cos(angY(o))*cos(angX(o)))*spd)
Endfunction
Function ZMoveObj(o,x as float,y as float,z as float)
ObjVX(o)=x : ObjVY(o)=x : ObjVZ(o)=x
Endfunction
Function ZTurnObj(o,x as float,y as float,z as float)
AngVX(o)=x : AngVY(o)=x : AngVZ(o)=x
Endfunction
Function ZAccObj(o,x as float,y as float,z as float)
ObjAX(o)=x : ObjAY(o)=x : ObjAZ(o)=x
Endfunction
Function ZSpinObj(o,x as float,y as float,z as float)
AngAX(o)=x : AngAY(o)=x : AngAZ(o)=x
Endfunction
Function ZSetGroundHeight(o,height as float)
Ground(o)=height
Endfunction
Function ZCalcDir(o)
ObjDX(o)=Sin(AngY(o))*Cos(AngX(o))
ObjDY(o)=-Sin(AngX(o))
ObjDZ(o)=Cos(AngY(o))*Cos(AngX(o))
Endfunction
Function ZCalcAcc(o)
ObjAX(o)=ObjFX(o)/ObjMass(o)
ObjAY(o)=(abs(ObjDrop(o)-ObjFY(o))*-1)/ObjMass(o)
ObjAZ(o)=ObjFZ(o)/ObjMass(o)
Endfunction
Function ZCalcVel(o)
ObjVX(o)=ObjVX(o)+ObjAX(o)
ObjVY(o)=ObjVY(o)+ObjAY(o)
ObjVZ(o)=ObjVZ(o)+ObjAZ(o)
Endfunction
Function ZCalcSpeed(o)
ObjS(o)=sqrt(ObjVX(o)^2+ObjVY(o)^2+ObjVZ(o)^2)
speed#=ObjS(o)
Endfunction speed#
Function ZCalcNewPos(o,mode)
if Mode=1
PosX(o)=PosX(o)+ObjVX(o)+(ObjDX(o)*ObjOX(o))
PosY(o)=PosY(o)+ObjVY(o)+(ObjDY(o)*ObjOY(o))
PosZ(o)=PosZ(o)+ObjVZ(o)+(ObjDZ(o)*ObjOZ(o))
endif
If Mode=2
ZCalcSpeed(o)
PosX(o)=PosX(o)+(ObjDX(o)*ObjS(o))+(ObjDX(o)*ObjOX(o))
PosY(o)=PosY(o)+(ObjDY(o)*ObjS(o))+(ObjDY(o)*ObjOY(o))
PosZ(o)=PosZ(o)+(ObjDZ(o)*ObjS(o))+(ObjDZ(o)*ObjOZ(o))
endif
Endfunction
Function ZCalcAAcc(o)
AngAX(o)=AngFX(o)/ObjMass(o)
AngAY(o)=AngFY(o)/ObjMass(o)
AngAZ(o)=AngFZ(o)/ObjMass(o)
Endfunction
Function ZCalcAVel(o)
AngVX(o)=AngVX(o)+AngAX(o)
AngVY(o)=AngVY(o)+AngAY(o)
AngVZ(o)=AngVZ(o)+AngAZ(o)
Endfunction
Function ZCalcNewAng(o)
AngX(o)=AngX(o)+AngVX(o)
AngY(o)=AngY(o)+AngVY(o)
AngZ(o)=AngZ(o)+AngVZ(o)
Endfunction
Function ZUpdateCalc(o,mode)
ZCalcDir(o) : ZCalcSpeed(o)
ZCalcAcc(o) : ZCalcVel(o)
ZCalcAAcc(o) : ZCalcAVel(o)
ZCalcNewPos(o,mode) : ZCalcNewAng(o)
Endfunction
Function ZUpdatePos(o)
ZSetPos(o,PosX(o),PosY(o),PosZ(o))
Endfunction
Function ZUpdateAng(o)
ZSetAng(o,AngX(o),AngY(o),AngZ(o))
Endfunction
Function ZUpdateObj(o)
ZUpdatePos(o) : ZUpdateAng(o)
Endfunction
Function ZSetPos(o, x as float, y as float, z as float)
Position object o,x,y,z
Endfunction
Function ZSetAng(o, x as float, y as float, z as float)
Rotate Object o,x,y,z
Endfunction
Function ZFixAng(o)
Fix Object Pivot o
Endfunction
Function ZCreateCube(o)
Make object cube o,100
Endfunction
Function ZCreateSphere(o,rows,columns)
Make object sphere o,100,rows,columns
Endfunction
function ZCreateCylinder(o)
s=100 : longitude=50
h# = sin(180.0 / longitude) * (s/2) : w# = cos(180.0 / longitude) * (s/2)
make object triangle o, 0,s/2,0, w#,s/2,h#, w#,s/2,-h#
make mesh from object o,o : delete object o
make object triangle o, 0,-s/2,0, w#,-s/2,-h#, w#,-s/2,h#
add limb o,1,o : delete mesh o
make mesh from object o,o : delete object o
make object triangle o, w#,s/2,-h#, w#,s/2,h#, w#,-s/2,h#
add limb o,1,o : delete mesh o
make mesh from object o,o : delete object o
make object triangle o, w#,-s/2,h#, w#,-s/2,-h#, w#,s/2,-h#
add limb o,1,o : delete mesh o
make mesh from object o,o
for x = 1 to longitude - 1
add limb o,x+1,o : rotate limb o,x+1, 0, 360.0/longitude*x, 0
next x
endfunction
function ZCreateCone(o)
s=100 : longitude=50
h# = sin(180.0 / longitude) * (s/2) : w# = cos(180.0 / longitude) * (s/2)
make object triangle o, 0,s/2,0, w#,-s/2.0,h#, w#,-s/2,-h#
make mesh from object o,o : delete object o
make object triangle o, 0,-s/2,0, w#,-s/2,-h#, w#,-s/2,h#
add limb o,1,o : delete mesh o
make mesh from object o,o
for x = 1 to longitude - 1
add limb o,x + 1,o : rotate limb o,x+1,0,360.0/longitude*x,0
next x
endfunction
Function ZCreateCapsule(o)
ZCreateCylinder(o)
make mesh from object o,o : delete object o
ZCreateSphere(o,30,30)
make mesh from object o+1,o : delete object o
ZCreateSphere(o,30,30)
make mesh from object o+2,o : delete object o
make object plain o,1,1
add limb o,1,o
add limb o,2,o+1
add limb o,3,o+2
offset limb o,2,0,-50,0
offset limb o,3,0,50,0
make mesh from object o+3,o : delete object o
delete mesh o : delete mesh o+1 : delete mesh o+2
make object o,o+3,0
Endfunction
Function ZScaleObj(o, x as float, y as float, z as float)
scale object o,x,y,z
Endfunction
Function ZMakeVector2(vec)
Dim VecX(vec) as float : Dim VecY(vec) as Float
Dim VecL(vec) as float
Endfunction
Function ZMakeVector3(vec)
Dim VecX(vec) as float : Dim VecY(vec) as Float : Dim VecZ(vec) as Float
Dim VecL(vec) as float
Endfunction
Function ZMakeVector4(vec)
Dim VecX(vec) as float : Dim VecY(vec) as Float : Dim VecZ(vec) as Float : Dim VecW(vec) as Float
Dim VecL(vec) as float
Endfunction
Function ZSetVector2(vec,x as float, y as float)
VecX(vec)=x : VecY(vec)=y
Endfunction
Function ZSetVector3(vec,x as float, y as float, z as float)
VecX(vec)=x : VecY(vec)=y : VecZ(vec)=z
Endfunction
Function ZSetVector4(vec,x as float, y as float, z as float, w as float)
VecX(vec)=x : VecY(vec)=y : VecZ(vec)=z : VecW(vec)=w
Endfunction
Function ZAddVector2(vr,v1,v2)
VecX(vr)=VecX(v1)+VecX(v2)
VecY(vr)=VecY(v1)+VecY(v2)
Endfunction
Function ZAddVector3(vr,v1,v2)
VecX(vr)=VecX(v1)+VecX(v2)
VecY(vr)=VecY(v1)+VecY(v2)
VecZ(vr)=VecZ(v1)+VecZ(v2)
Endfunction
Function ZAddVector4(vr,v1,v2)
VecX(vr)=VecX(v1)+VecX(v2)
VecY(vr)=VecY(v1)+VecY(v2)
VecZ(vr)=VecZ(v1)+VecZ(v2)
VecW(vr)=VecW(v1)+VecW(v2)
Endfunction
Function ZSubVector2(vr,v1,v2)
VecX(vr)=VecX(v1)-VecX(v2)
VecY(vr)=VecY(v1)-VecY(v2)
Endfunction
Function ZSubVector3(vr,v1,v2)
VecX(vr)=VecX(v1)-VecX(v2)
VecY(vr)=VecY(v1)-VecY(v2)
VecZ(vr)=VecZ(v1)-VecZ(v2)
Endfunction
Function ZSubVector4(vr,v1,v2)
VecX(vr)=VecX(v1)-VecX(v2)
VecY(vr)=VecY(v1)-VecY(v2)
VecZ(vr)=VecZ(v1)-VecZ(v2)
VecW(vr)=VecW(v1)-VecW(v2)
Endfunction
Function ZXVector(vec)
x#=VecX(vec)
Endfunction x#
Function ZYVector(vec)
y#=VecY(vec)
Endfunction y#
Function ZZVector(vec)
z#=VecZ(vec)
Endfunction z#
Function ZWVector(vec)
w#=VecW(vec)
Endfunction w#
Function ZVectorLength2(vec)
VecL(vec)=sqrt(VecX(vec)^2+VecY(vec)^2)
l#=VecL(vec)
Endfunction l#
Function ZVectorLength3(vec)
VecL(vec)=sqrt(VecX(vec)^2+VecY(vec)^2+VecZ(vec)^2)
l#=VecL(vec)
Endfunction l#
Function ZVectorLength4(vec)
VecL(vec)=sqrt(VecX(vec)^2+VecY(vec)^2+VecZ(vec)^2+VecW(vec)^2)
l#=VecL(vec)
Endfunction l#
Function ZCreateRay(ray)
Dim RayX1(ray) as float : Dim RayX2(ray) as float
Dim RayY1(ray) as float : Dim RayY2(ray) as float
Dim RayZ1(ray) as float : Dim RayZ2(ray) as float
Dim RayIX(ray) as float : Dim RayIY(ray) as float : Dim RayIZ(ray) as float
Dim rayD(ray) as float
Endfunction
Function ZPositionRay1(ray, x as float, y as float, z as float)
RayX1(ray)=x : RayY1(ray)=y : RayZ1(ray)=z
Endfunction
Function ZPositionRay2(ray, x as float, y as float, z as float)
RayX2(ray)=x : RayY2(ray)=y : RayZ2(ray)=z
Endfunction
Function ZShootRay(ray,obj)
RayD(ray)=Intersect Object(obj,rayx1(ray),rayy1(ray),rayz1(ray),rayx2(ray),rayy2(ray),rayz2(ray))
local d as float
d=RayD(ray)
Endfunction d
Function ZCastRay(ray, x as float, y as float, z as float, ax as float, ay as float, r as float,obj)
RayX1(ray)=x : RayY1(ray)=y : RayZ1(ray)=z
RayX2(ray)=RayX1(ray)+((sin(ay)*cos(ax))*r)
RayY2(ray)=RayY1(ray)-(sin(ax)*r)
RayZ2(ray)=RayZ1(ray)+((cos(ay)*cos(ax))*r)
d#=ZShootRay(ray,obj)
Endfunction d#
Function ZCalcRayInt(ray)
local ax as float : local ay as float
ax=atanfull(RayY1(ray)-RayY2(ray),RayZ1(ray)-RayZ2(ray))
ay=atanfull(RayX1(ray)-RayX2(ray),RayZ1(ray)-RayZ2(ray))
ax=wrapvalue(ax) : ay=wrapvalue(ay)
If ay>=0 and ay<90 then aya#=180
if ay>90 and ay<180 then aya#=0
if ay>180 and ay<270 then aya#=0
if ay>270 and ay<360 then aya#=180
RayIX(ray) = RayX1(ray) + ((Sin(ay+aya#) * Cos(ax+axa#))*RayD(ray))
RayIY(ray) = RayY1(ray) - (Sin(ax+axa#)*RayD(ray))
RayIZ(ray) = RayZ1(ray) + ((Cos(ay+aya#) * Cos(ax+axa#))*RayD(ray))
Endfunction
Function ZGetRayIntX(ray)
x#=RayIX(ray)
Endfunction x#
Function ZGetRayIntY(ray)
y#=RayIY(ray)
Endfunction y#
Function ZGetRayIntZ(ray)
z#=RayIZ(ray)
Endfunction z#
Function ZCreateDistLine(Lin)
Dim DLinX1(Lin) as float : Dim DLinX2(Lin) as float
Dim DLinY1(Lin) as float : Dim DLinY2(Lin) as float
Dim DLinZ1(Lin) as float : Dim DLinZ2(Lin) as float
Dim DLinD(Lin) as float
Endfunction
Function ZPositionDistline1(lin,x as float,y as float, z as float)
DLinX1(lin)=x : DLinY1(lin)=y : DLinZ1(lin)=z
Endfunction
Function ZPositionDistline2(lin,x as float,y as float, z as float)
DLinX2(lin)=x : DLinY2(lin)=y : DLinZ2(lin)=z
Endfunction
Function ZGetDistance(lin)
DLinD(lin)=Sqrt((DLinX2(lin)-DLinX1(lin))^2+(DLinY2(lin)-DLinY1(lin))^2+(DLinZ2(lin)-DLinZ1(lin))^2)
d#=DLinD(lin)
Endfunction d#
Function ZGetPosX(Obj)
x# = PosX(obj)
Endfunction x#
Function ZGetPosY(Obj)
y# = PosY(obj)
Endfunction y#
Function ZGetPosZ(Obj)
z# = PosZ(obj)
Endfunction z#
Function ZGetOldPosX(Obj)
x#=ZGetPosX(obj)-ZGetVelX(obj)
Endfunction x#
Function ZGetOldPosY(Obj)
y#=ZGetPosY(obj)-ZGetVelY(obj)
Endfunction y#
Function ZGetOldPosZ(Obj)
z#=ZGetPosZ(obj)-ZGetVelZ(obj)
Endfunction z#
Function ZGetAngX(Obj)
x# = Wrapvalue(AngX(obj))
Endfunction x#
Function ZGetAngY(Obj)
y# = Wrapvalue(AngY(obj))
Endfunction y#
Function ZGetAngZ(Obj)
z# = Wrapvalue(AngZ(obj))
Endfunction z#
Function ZGetOldAngX(Obj)
x#=ZGetAngX(Obj)-ZGetAngVelX(Obj)
Endfunction x#
Function ZGetOldAngY(Obj)
y#=ZGetAngY(Obj)-ZGetAngVelY(Obj)
Endfunction y#
Function ZGetOldAngZ(Obj)
z#=ZGetAngZ(Obj)-ZGetAngVelZ(Obj)
Endfunction z#
Function ZGetVelX(Obj)
x#=ObjVX(Obj)
Endfunction x#
Function ZGetVelY(Obj)
y#=ObjVY(Obj)
Endfunction y#
Function ZGetVelZ(Obj)
z#=ObjVZ(Obj)
Endfunction z#
Function ZGetAccX(Obj)
x#=ObjAX(Obj)
Endfunction x#
Function ZGetAccY(Obj)
y#=ObjAY(Obj)
Endfunction y#
Function ZGetAccZ(Obj)
z#=ObjAZ(Obj)
Endfunction z#
Function ZGetAngVelX(Obj)
x#=AngVX(Obj)
Endfunction x#
Function ZGetAngVelY(Obj)
y#=AngVY(Obj)
Endfunction y#
Function ZGetAngVelZ(Obj)
z#=AngVZ(Obj)
Endfunction z#
Function ZGetAngAccX(Obj)
x#=AngAX(Obj)
Endfunction x#
Function ZGetAngAccY(Obj)
y#=AngAY(Obj)
Endfunction y#
Function ZGetAngAccZ(Obj)
z#=AngAZ(Obj)
Endfunction z#
Function ZGetDirX(obj)
x#=ObjDX(1)
Endfunction x#
Function ZGetDirY(obj)
y#=ObjDY(1)
Endfunction y#
Function ZGetDirZ(obj)
z#=ObjDZ(1)
Endfunction z#
Function ZGetXDist(o1,o2)
x#=abs(object position x(o1)-object position x(o2))
Endfunction x#
Function ZGetYDist(o1,o2)
y#=abs(object position y(o1)-object position y(o2))
Endfunction y#
Function ZGetZDist(o1,o2)
z#=abs(object position z(o1)-object position z(o2))
Endfunction z#
Function ZGetMoveTime(Obj)
If ObjS(Obj)>0.9
MoveT(Obj)=MoveT(Obj)+1
else
MoveT(Obj)=MoveT(Obj)*0.0
Endif
Mt#=MoveT(Obj)
Endfunction Mt#
Function ZGetMoveDist(Obj)
MoveD(Obj)=abs(ZCalcSpeed(Obj)*ZGetmoveTime(obj))
Md#=MoveD(Obj)
Endfunction Md#
Functions: (already added into demo)
Function ZStart()
Global T as integer
T=Timer()
Endfunction
Function ZStandardSetup()
Sync on : Sync rate 60
Set display mode 1024,768,16 : Hide Mouse
Set Window On : Maximize Window
Autocam off : Set Camera Range 1,0x7fffffff
Color Backdrop RGB(0,0,0)
ZStart()
Endfunction
Function ZGetVersion()
v$="Zee-Physics V2"
Endfunction v$
Function ZGetFPS()
f$=Str$(Screen FPS())
Endfunction f$
Function ZGetTime()
time=Timer()-T
Endfunction time
Function ZGetTimeInSec()
sec=(Timer()-T)/1000
Endfunction sec
Function ZSetupObject(o)
Dim ObjGrav(o) as Float : Dim ObjMass(o) as Float : Dim ObjWeight(o) as Float
Dim Ground(o) as Float : Dim ObjDrop(o) as Float
Dim PosX(o) as Float : Dim PosY(o) as Float : Dim Posz(o) as Float
Dim OldPosX(o) as Float : Dim OldPosY(o) as Float : Dim OldPosZ(o) as Float
Dim AngX(o) as Float : Dim AngY(o) as Float : Dim AngZ(o) as Float
Dim OldAngX(o) as Float : Dim OldAngY(o) as Float : Dim OldAngZ(o) as Float
Dim MoveAngX(o) as Float : Dim MoveAngY(o) as Float : Dim MoveAngZ(o) as Float
Dim DragFX(o) as Float : Dim DragFY(o) as Float : Dim DragFZ(o) as Float
Dim BrakFX(o) as Float : Dim BrakFY(o) as Float : Dim BrakFZ(o) as Float
Dim BrakAFX(o) as Float : Dim BrakAFY(o) as Float : Dim BrakAFZ(o) as Float
Dim TracFX(o) as Float : Dim TracFY(o) as Float : Dim TracFZ(o) as Float
Dim TracAFX(o) as Float : Dim TracAFY(o) as Float : Dim TracAFZ(o) as Float
Dim AngFX(o) as Float : Dim AngFY(o) as Float : Dim AngFZ(o) as Float
Dim AngVX(o) as Float : Dim AngVY(o) as Float : Dim AngVZ(o) as Float
Dim AngAX(o) as Float : Dim AngAY(o) as Float : Dim AngAZ(o) as Float
Dim ObjFX(o) as Float : Dim ObjFY(o) as Float : Dim ObjFZ(o) as Float
Dim ObjVX(o) as Float : Dim ObjVY(o) as Float : Dim ObjVZ(o) as Float
Dim ObjAX(o) as Float : Dim ObjAY(o) as Float : Dim ObjAZ(o) as Float
Dim ObjDX(o) as Float : Dim ObjDY(o) as Float : Dim ObjDZ(o) as Float
Dim ObjOX(o) as Float : Dim ObjOY(o) as Float : Dim ObjOZ(o) as Float
Dim ObjF(o) as Float : Dim ObjS(o) as Float : Dim AngF(o) as Float
Dim MoveT(o) : Dim MoveD(o) as Float : Dim MoveA(o) as Float
Endfunction
Function ZSetGrav(o,grav as float)
ObjGrav(o)=grav
Endfunction
Function ZSetMass(o,mass as float)
ObjMass(o)=mass
Endfunction
Function ZWeighObj(o)
ObjWeight(o)=ObjMass(o)*ObjGrav(o)
Endfunction
Function ZAddForce(o,x as float,y as float,z as float)
ObjFX(o)=x : ObjFY(o)=y : ObjFZ(o)=z
Endfunction
Function ZAddTorque(o,x as float, y as float, z as float)
AngFX(o)=x : AngFY(o)=y : AngFZ(o)=z
Endfunction
Function ZAddDrag(o,x as float,y as float,z as float)
DragFX(o)=x : DragFY(o)=y : DragFZ(o)=z
Endfunction
Function ZAddTrac(o,x as float,y as float,z as float)
TracFX(o)=x : TracFY(o)=y : TracFZ(o)=z
Endfunction
Function ZAddATrac(o,x as float,y as float,z as float)
TracAFX(o)=x : TracAFY(o)=y : TracAFZ(o)=z
Endfunction
Function ZAddBrake(o,x as float, y as float, z as float)
BrakFX(o)=x : BrakFY(o)=y : BrakFZ(o)=z
Endfunction
Function ZAddABrake(o,x as float, y as float, z as float)
BrakAFX(o)=x : BrakAFY(o)=y : BrakAFZ(o)=z
Endfunction
Function ZDepleatForce(o)
ZAddForce(o,0.0,0.0,0.0)
Endfunction
Function ZDepleatTorque(o)
ZAddTorque(o,0.0,0.0,0.0)
Endfunction
Function ZDepleatDrag(o)
ZAddDrag(o,1.0,1.0,1.0)
Endfunction
Function ZDepleatTrac(o)
ZAddTrac(o,1.0,1.0,1.0)
Endfunction
Function ZDepleatATrac(o)
ZAddATrac(o,1.0,1.0,1.0)
Endfunction
Function ZDepleatBrake(o)
ZAddbrake(o,1.0,1.0,1.0)
Endfunction
Function ZDepleatABrake(o)
ZAddABrake(o,1.0,1.0,1.0)
Endfunction
Function ZEnableDrag(o)
ObjVX(o)=ObjVX(o)*DragFX(o)
ObjVY(o)=ObjVY(o)*DragFY(o)
ObjVZ(o)=ObjVZ(o)*DragFZ(o)
Endfunction
Function ZEnableBrake(o)
ObjVX(o)=ObjVX(o)*BrakFX(o)
ObjVY(o)=ObjVY(o)*BrakFY(o)
ObjVZ(o)=ObjVZ(o)*BrakFZ(o)
ZAddForce(o,0,0,0)
Endfunction
Function ZEnableABrake(o)
AngVX(o)=AngVX(o)*BrakAFX(o)
AngVY(o)=AngVY(o)*BrakAFY(o)
AngVZ(o)=AngVZ(o)*BrakAFZ(o)
Endfunction
Function ZEnableTrac(o)
ObjVX(o)=ObjVX(o)*TracFX(o)
ObjVY(o)=ObjVY(o)*TracFY(o)
ObjVZ(o)=ObjVZ(o)*TracFZ(o)
Endfunction
Function ZEnableATrac(o)
AngVX(o)=AngVX(o)*TracAFX(o)
AngVY(o)=AngVY(o)*TracAFY(o)
AngVZ(o)=AngVZ(o)*TracAFZ(o)
Endfunction
Function ZEnableGravity(o)
If PosY(o)>Ground(o)
ObjDrop(o)=ObjWeight(o)
else
ObjDrop(o)=ObjDrop(o)*0.0
Endif
Endfunction
Function ZEnableAll(o)
If DragFX(o)>0 or DragFY(o)>0 or DragFZ(o)>0 then ZEnableDrag(o)
If BrakFX(o)>0 or BrakFY(o)>0 or BrakFZ(o)>0 then ZEnableBrake(o)
If BrakAFX(o)>0 or BrakAFY(o)>0 or BrakAFZ(o)>0 then ZEnableABrake(o)
If TracFX(o)>0 or TracFY(o)>0 or TracFZ(o)>0 then ZEnableTrac(o)
If TracAFX(o)>0 or TracAFY(o)>0 or TracAFZ(o)>0 then ZEnableATrac(o)
ZEnableGravity(o)
Endfunction
Function ZPushOnLine(o,x as float,y as float,frc as float)
ZAddForce(o,(sin(y)*cos(x))*frc,-sin(x)*frc,(cos(y)*cos(x))*frc)
Endfunction
Function ZMoveOnLine(o,x as float,y as float,spd as float)
ZMoveObj(o,(sin(y)*cos(x))*spd,-sin(x)*spd,(cos(y)*cos(x))*spd)
Endfunction
Function ZPushFor(o,frc)
ZAddForce(o,(sin(angY(o))*cos(angX(o)))*frc,-sin(angX(o))*frc,(cos(angY(o))*cos(angX(o)))*frc)
Endfunction
Function ZMoveFor(o,spd)
ZAddForce(o,(sin(angY(o))*cos(angX(o)))*spd,-sin(angX(o))*spd,(cos(angY(o))*cos(angX(o)))*spd)
Endfunction
Function ZMoveObj(o,x as float,y as float,z as float)
ObjVX(o)=x : ObjVY(o)=x : ObjVZ(o)=x
Endfunction
Function ZTurnObj(o,x as float,y as float,z as float)
AngVX(o)=x : AngVY(o)=x : AngVZ(o)=x
Endfunction
Function ZAccObj(o,x as float,y as float,z as float)
ObjAX(o)=x : ObjAY(o)=x : ObjAZ(o)=x
Endfunction
Function ZSpinObj(o,x as float,y as float,z as float)
AngAX(o)=x : AngAY(o)=x : AngAZ(o)=x
Endfunction
Function ZSetGroundHeight(o,height as float)
Ground(o)=height
Endfunction
Function ZCalcDir(o)
ObjDX(o)=Sin(AngY(o))*Cos(AngX(o))
ObjDY(o)=-Sin(AngX(o))
ObjDZ(o)=Cos(AngY(o))*Cos(AngX(o))
Endfunction
Function ZCalcAcc(o)
ObjAX(o)=ObjFX(o)/ObjMass(o)
ObjAY(o)=(abs(ObjDrop(o)-ObjFY(o))*-1)/ObjMass(o)
ObjAZ(o)=ObjFZ(o)/ObjMass(o)
Endfunction
Function ZCalcVel(o)
ObjVX(o)=ObjVX(o)+ObjAX(o)
ObjVY(o)=ObjVY(o)+ObjAY(o)
ObjVZ(o)=ObjVZ(o)+ObjAZ(o)
Endfunction
Function ZCalcSpeed(o)
ObjS(o)=sqrt(ObjVX(o)^2+ObjVY(o)^2+ObjVZ(o)^2)
speed#=ObjS(o)
Endfunction speed#
Function ZCalcNewPos(o,mode)
if Mode=1
PosX(o)=PosX(o)+ObjVX(o)+(ObjDX(o)*ObjOX(o))
PosY(o)=PosY(o)+ObjVY(o)+(ObjDY(o)*ObjOY(o))
PosZ(o)=PosZ(o)+ObjVZ(o)+(ObjDZ(o)*ObjOZ(o))
endif
If Mode=2
ZCalcSpeed(o)
PosX(o)=PosX(o)+(ObjDX(o)*ObjS(o))+(ObjDX(o)*ObjOX(o))
PosY(o)=PosY(o)+(ObjDY(o)*ObjS(o))+(ObjDY(o)*ObjOY(o))
PosZ(o)=PosZ(o)+(ObjDZ(o)*ObjS(o))+(ObjDZ(o)*ObjOZ(o))
endif
Endfunction
Function ZCalcAAcc(o)
AngAX(o)=AngFX(o)/ObjMass(o)
AngAY(o)=AngFY(o)/ObjMass(o)
AngAZ(o)=AngFZ(o)/ObjMass(o)
Endfunction
Function ZCalcAVel(o)
AngVX(o)=AngVX(o)+AngAX(o)
AngVY(o)=AngVY(o)+AngAY(o)
AngVZ(o)=AngVZ(o)+AngAZ(o)
Endfunction
Function ZCalcNewAng(o)
AngX(o)=AngX(o)+AngVX(o)
AngY(o)=AngY(o)+AngVY(o)
AngZ(o)=AngZ(o)+AngVZ(o)
Endfunction
Function ZUpdateCalc(o,mode)
ZCalcDir(o) : ZCalcSpeed(o)
ZCalcAcc(o) : ZCalcVel(o)
ZCalcAAcc(o) : ZCalcAVel(o)
ZCalcNewPos(o,mode) : ZCalcNewAng(o)
Endfunction
Function ZUpdatePos(o)
ZSetPos(o,PosX(o),PosY(o),PosZ(o))
Endfunction
Function ZUpdateAng(o)
ZSetAng(o,AngX(o),AngY(o),AngZ(o))
Endfunction
Function ZUpdateObj(o)
ZUpdatePos(o) : ZUpdateAng(o)
Endfunction
Function ZSetPos(o, x as float, y as float, z as float)
Position object o,x,y,z
Endfunction
Function ZSetAng(o, x as float, y as float, z as float)
Rotate Object o,x,y,z
Endfunction
Function ZFixAng(o)
Fix Object Pivot o
Endfunction
Function ZCreateCube(o)
Make object cube o,100
Endfunction
Function ZCreateSphere(o,rows,columns)
Make object sphere o,100,rows,columns
Endfunction
function ZCreateCylinder(o)
s=100 : longitude=50
h# = sin(180.0 / longitude) * (s/2) : w# = cos(180.0 / longitude) * (s/2)
make object triangle o, 0,s/2,0, w#,s/2,h#, w#,s/2,-h#
make mesh from object o,o : delete object o
make object triangle o, 0,-s/2,0, w#,-s/2,-h#, w#,-s/2,h#
add limb o,1,o : delete mesh o
make mesh from object o,o : delete object o
make object triangle o, w#,s/2,-h#, w#,s/2,h#, w#,-s/2,h#
add limb o,1,o : delete mesh o
make mesh from object o,o : delete object o
make object triangle o, w#,-s/2,h#, w#,-s/2,-h#, w#,s/2,-h#
add limb o,1,o : delete mesh o
make mesh from object o,o
for x = 1 to longitude - 1
add limb o,x+1,o : rotate limb o,x+1, 0, 360.0/longitude*x, 0
next x
endfunction
function ZCreateCone(o)
s=100 : longitude=50
h# = sin(180.0 / longitude) * (s/2) : w# = cos(180.0 / longitude) * (s/2)
make object triangle o, 0,s/2,0, w#,-s/2.0,h#, w#,-s/2,-h#
make mesh from object o,o : delete object o
make object triangle o, 0,-s/2,0, w#,-s/2,-h#, w#,-s/2,h#
add limb o,1,o : delete mesh o
make mesh from object o,o
for x = 1 to longitude - 1
add limb o,x + 1,o : rotate limb o,x+1,0,360.0/longitude*x,0
next x
endfunction
Function ZCreateCapsule(o)
ZCreateCylinder(o)
make mesh from object o,o : delete object o
ZCreateSphere(o,30,30)
make mesh from object o+1,o : delete object o
ZCreateSphere(o,30,30)
make mesh from object o+2,o : delete object o
make object plain o,1,1
add limb o,1,o
add limb o,2,o+1
add limb o,3,o+2
offset limb o,2,0,-50,0
offset limb o,3,0,50,0
make mesh from object o+3,o : delete object o
delete mesh o : delete mesh o+1 : delete mesh o+2
make object o,o+3,0
Endfunction
Function ZScaleObj(o, x as float, y as float, z as float)
scale object o,x,y,z
Endfunction
Function ZMakeVector2(vec)
Dim VecX(vec) as float : Dim VecY(vec) as Float
Dim VecL(vec) as float
Endfunction
Function ZMakeVector3(vec)
Dim VecX(vec) as float : Dim VecY(vec) as Float : Dim VecZ(vec) as Float
Dim VecL(vec) as float
Endfunction
Function ZMakeVector4(vec)
Dim VecX(vec) as float : Dim VecY(vec) as Float : Dim VecZ(vec) as Float : Dim VecW(vec) as Float
Dim VecL(vec) as float
Endfunction
Function ZSetVector2(vec,x as float, y as float)
VecX(vec)=x : VecY(vec)=y
Endfunction
Function ZSetVector3(vec,x as float, y as float, z as float)
VecX(vec)=x : VecY(vec)=y : VecZ(vec)=z
Endfunction
Function ZSetVector4(vec,x as float, y as float, z as float, w as float)
VecX(vec)=x : VecY(vec)=y : VecZ(vec)=z : VecW(vec)=w
Endfunction
Function ZAddVector2(vr,v1,v2)
VecX(vr)=VecX(v1)+VecX(v2)
VecY(vr)=VecY(v1)+VecY(v2)
Endfunction
Function ZAddVector3(vr,v1,v2)
VecX(vr)=VecX(v1)+VecX(v2)
VecY(vr)=VecY(v1)+VecY(v2)
VecZ(vr)=VecZ(v1)+VecZ(v2)
Endfunction
Function ZAddVector4(vr,v1,v2)
VecX(vr)=VecX(v1)+VecX(v2)
VecY(vr)=VecY(v1)+VecY(v2)
VecZ(vr)=VecZ(v1)+VecZ(v2)
VecW(vr)=VecW(v1)+VecW(v2)
Endfunction
Function ZSubVector2(vr,v1,v2)
VecX(vr)=VecX(v1)-VecX(v2)
VecY(vr)=VecY(v1)-VecY(v2)
Endfunction
Function ZSubVector3(vr,v1,v2)
VecX(vr)=VecX(v1)-VecX(v2)
VecY(vr)=VecY(v1)-VecY(v2)
VecZ(vr)=VecZ(v1)-VecZ(v2)
Endfunction
Function ZSubVector4(vr,v1,v2)
VecX(vr)=VecX(v1)-VecX(v2)
VecY(vr)=VecY(v1)-VecY(v2)
VecZ(vr)=VecZ(v1)-VecZ(v2)
VecW(vr)=VecW(v1)-VecW(v2)
Endfunction
Function ZXVector(vec)
x#=VecX(vec)
Endfunction x#
Function ZYVector(vec)
y#=VecY(vec)
Endfunction y#
Function ZZVector(vec)
z#=VecZ(vec)
Endfunction z#
Function ZWVector(vec)
w#=VecW(vec)
Endfunction w#
Function ZVectorLength2(vec)
VecL(vec)=sqrt(VecX(vec)^2+VecY(vec)^2)
l#=VecL(vec)
Endfunction l#
Function ZVectorLength3(vec)
VecL(vec)=sqrt(VecX(vec)^2+VecY(vec)^2+VecZ(vec)^2)
l#=VecL(vec)
Endfunction l#
Function ZVectorLength4(vec)
VecL(vec)=sqrt(VecX(vec)^2+VecY(vec)^2+VecZ(vec)^2+VecW(vec)^2)
l#=VecL(vec)
Endfunction l#
Function ZCreateRay(ray)
Dim RayX1(ray) as float : Dim RayX2(ray) as float
Dim RayY1(ray) as float : Dim RayY2(ray) as float
Dim RayZ1(ray) as float : Dim RayZ2(ray) as float
Dim RayIX(ray) as float : Dim RayIY(ray) as float : Dim RayIZ(ray) as float
Dim rayD(ray) as float
Endfunction
Function ZPositionRay1(ray, x as float, y as float, z as float)
RayX1(ray)=x : RayY1(ray)=y : RayZ1(ray)=z
Endfunction
Function ZPositionRay2(ray, x as float, y as float, z as float)
RayX2(ray)=x : RayY2(ray)=y : RayZ2(ray)=z
Endfunction
Function ZShootRay(ray,obj)
RayD(ray)=Intersect Object(obj,rayx1(ray),rayy1(ray),rayz1(ray),rayx2(ray),rayy2(ray),rayz2(ray))
local d as float
d=RayD(ray)
Endfunction d
Function ZCastRay(ray, x as float, y as float, z as float, ax as float, ay as float, r as float,obj)
RayX1(ray)=x : RayY1(ray)=y : RayZ1(ray)=z
RayX2(ray)=RayX1(ray)+((sin(ay)*cos(ax))*r)
RayY2(ray)=RayY1(ray)-(sin(ax)*r)
RayZ2(ray)=RayZ1(ray)+((cos(ay)*cos(ax))*r)
d#=ZShootRay(ray,obj)
Endfunction d#
Function ZCalcRayInt(ray)
local ax as float : local ay as float
ax=atanfull(RayY1(ray)-RayY2(ray),RayZ1(ray)-RayZ2(ray))
ay=atanfull(RayX1(ray)-RayX2(ray),RayZ1(ray)-RayZ2(ray))
ax=wrapvalue(ax) : ay=wrapvalue(ay)
If ay>=0 and ay<90 then aya#=180
if ay>90 and ay<180 then aya#=0
if ay>180 and ay<270 then aya#=0
if ay>270 and ay<360 then aya#=180
RayIX(ray) = RayX1(ray) + ((Sin(ay+aya#) * Cos(ax+axa#))*RayD(ray))
RayIY(ray) = RayY1(ray) - (Sin(ax+axa#)*RayD(ray))
RayIZ(ray) = RayZ1(ray) + ((Cos(ay+aya#) * Cos(ax+axa#))*RayD(ray))
Endfunction
Function ZGetRayIntX(ray)
x#=RayIX(ray)
Endfunction x#
Function ZGetRayIntY(ray)
y#=RayIY(ray)
Endfunction y#
Function ZGetRayIntZ(ray)
z#=RayIZ(ray)
Endfunction z#
Function ZCreateDistLine(Lin)
Dim DLinX1(Lin) as float : Dim DLinX2(Lin) as float
Dim DLinY1(Lin) as float : Dim DLinY2(Lin) as float
Dim DLinZ1(Lin) as float : Dim DLinZ2(Lin) as float
Dim DLinD(Lin) as float
Endfunction
Function ZPositionDistline1(lin,x as float,y as float, z as float)
DLinX1(lin)=x : DLinY1(lin)=y : DLinZ1(lin)=z
Endfunction
Function ZPositionDistline2(lin,x as float,y as float, z as float)
DLinX2(lin)=x : DLinY2(lin)=y : DLinZ2(lin)=z
Endfunction
Function ZGetDistance(lin)
DLinD(lin)=Sqrt((DLinX2(lin)-DLinX1(lin))^2+(DLinY2(lin)-DLinY1(lin))^2+(DLinZ2(lin)-DLinZ1(lin))^2)
d#=DLinD(lin)
Endfunction d#
Function ZGetPosX(Obj)
x# = PosX(obj)
Endfunction x#
Function ZGetPosY(Obj)
y# = PosY(obj)
Endfunction y#
Function ZGetPosZ(Obj)
z# = PosZ(obj)
Endfunction z#
Function ZGetOldPosX(Obj)
x#=ZGetPosX(obj)-ZGetVelX(obj)
Endfunction x#
Function ZGetOldPosY(Obj)
y#=ZGetPosY(obj)-ZGetVelY(obj)
Endfunction y#
Function ZGetOldPosZ(Obj)
z#=ZGetPosZ(obj)-ZGetVelZ(obj)
Endfunction z#
Function ZGetAngX(Obj)
x# = Wrapvalue(AngX(obj))
Endfunction x#
Function ZGetAngY(Obj)
y# = Wrapvalue(AngY(obj))
Endfunction y#
Function ZGetAngZ(Obj)
z# = Wrapvalue(AngZ(obj))
Endfunction z#
Function ZGetOldAngX(Obj)
x#=ZGetAngX(Obj)-ZGetAngVelX(Obj)
Endfunction x#
Function ZGetOldAngY(Obj)
y#=ZGetAngY(Obj)-ZGetAngVelY(Obj)
Endfunction y#
Function ZGetOldAngZ(Obj)
z#=ZGetAngZ(Obj)-ZGetAngVelZ(Obj)
Endfunction z#
Function ZGetVelX(Obj)
x#=ObjVX(Obj)
Endfunction x#
Function ZGetVelY(Obj)
y#=ObjVY(Obj)
Endfunction y#
Function ZGetVelZ(Obj)
z#=ObjVZ(Obj)
Endfunction z#
Function ZGetAccX(Obj)
x#=ObjAX(Obj)
Endfunction x#
Function ZGetAccY(Obj)
y#=ObjAY(Obj)
Endfunction y#
Function ZGetAccZ(Obj)
z#=ObjAZ(Obj)
Endfunction z#
Function ZGetAngVelX(Obj)
x#=AngVX(Obj)
Endfunction x#
Function ZGetAngVelY(Obj)
y#=AngVY(Obj)
Endfunction y#
Function ZGetAngVelZ(Obj)
z#=AngVZ(Obj)
Endfunction z#
Function ZGetAngAccX(Obj)
x#=AngAX(Obj)
Endfunction x#
Function ZGetAngAccY(Obj)
y#=AngAY(Obj)
Endfunction y#
Function ZGetAngAccZ(Obj)
z#=AngAZ(Obj)
Endfunction z#
Function ZGetDirX(obj)
x#=ObjDX(1)
Endfunction x#
Function ZGetDirY(obj)
y#=ObjDY(1)
Endfunction y#
Function ZGetDirZ(obj)
z#=ObjDZ(1)
Endfunction z#
Function ZGetXDist(o1,o2)
x#=abs(object position x(o1)-object position x(o2))
Endfunction x#
Function ZGetYDist(o1,o2)
y#=abs(object position y(o1)-object position y(o2))
Endfunction y#
Function ZGetZDist(o1,o2)
z#=abs(object position z(o1)-object position z(o2))
Endfunction z#
Function ZGetMoveTime(Obj)
If ObjS(Obj)>0.9
MoveT(Obj)=MoveT(Obj)+1
else
MoveT(Obj)=MoveT(Obj)*0.0
Endif
Mt#=MoveT(Obj)
Endfunction Mt#
Function ZGetMoveDist(Obj)
MoveD(Obj)=abs(ZCalcSpeed(Obj)*ZGetmoveTime(obj))
Md#=MoveD(Obj)
Endfunction Md#
And also I've included the updated keywords file, enjoy..