Cheers for the quick response Sparky, but I think there may still be a problem with overwriting box collision data:
set display mode 800,600,32
sync on
sync rate 0
hide mouse
make object cube 1,20
color object 1,rgb(200,0,0)
setupobject 1,0,2
scale object 1,50,50,50
setupobject 1,0,2
move camera -10
autocam off
`make a bullet marker
make object plain 2,3,3
color object 2,rgb(255,255,255)
hide object 2
do
yrotate camera camera angle y()+(mousemovex()/10.0)
xrotate camera camera angle x()+(mousemovey()/10.0)
if spacekey()=1 and rotatetimer+300<timer()
rotatetimer = timer()
rotate object 1,rnd(359),rnd(359),rnd(359)
rem update our object
updateObject 1
hide object 2
endif
if mouseclick()=1
rem get our simple collision vector
oldx#=camera position x()
oldy#=camera position y()
oldz#=camera position z()
move camera 200
x#=camera position x()
y#=camera position y()
z#=camera position z()
move camera -200
collide=intersectObject(0,0,oldx#,oldy#,oldz#,x#,y#,z#,0)
if collide>0
rem get the collision point
newx#=getStaticCollisionX()
newy#=getStaticCollisionY()
newz#=getStaticCollisionZ()
rem get collision normal
normx#=getCollisionNormalX()
normy#=getCollisionNormalY()
normz#=getCollisionNormalZ()
rem position and point a marker in the right direction
position object 2,newx#+normx#/10.0,newy#+normy#/10.0,newz#+normz#/10.0
point object 2,newx#+normx#,newy#+normy#,newz#+normz#
show object 2
endif
endif
text 0,0,"Move mouse to aim, left click to shoot"
text 0,20,"Press space to randomly rotate objects."
text 0,40,str$(screen fps())
ink rgb(255,0,0),0
circle 400,300,10
dot 400,300
ink rgb(255,255,255),0
sync
loop
end
delete memblock 10
`Don't forget to have at least one memblock command in the source somewhere!
In this demo, a large box is setup with box collision, then scaled to half size, then setup with box collision again. However, the old collision data remains. This works fine for polygon and sphere collision, it's just the box collision.
Also, why is turning dynamic scaling on non-reversable?
Cheers again!
[edit]
Would it be possible have rectangular-raycast commands? eg.
sync on : autocam off
start as float
load object "line.dbo",1
make object sphere 2,2
make object sphere 3,2
make object plain 4,2,4
position object 4,-5,-5,15
point object 4,5,3,30
position object 1,-5,-5,15
point object 1,5,3,30
scale object 1,100,100,dist_find(-5,-5,15,5,3,30)*100
position object 2,-5,-5,15
position object 3,5,3,30
do
if spacekey() then start=0.1 : position object 4,-5,-5,15
move object 4,start
if object position y(4)>3 then position object 4,5,3,30 : start=0
if object position y(4)=3 then text 30,30,"Rectangle didn't collide with anything"
sync
loop
function dist_find(x1#,y1#,z1#,x2#,y2#,z2#)
xd#=x1#-x2#
yd#=y1#-y2#
zd#=z1#-z2#
result#=sqrt((xd#*xd#)+(zd#*zd#))
result#=sqrt((result#*result#)+(yd#*yd#))
endfunction result#
media:
http://eatmuchpie.dbspot.com/line.dbo
example syntax: intersectrectangle(x1,y1,z1,x2,y2,z2,width,height)
[/edit]