Ruccus:
Quote: "I havent used DBC and Im not too fluent with DBP's native collision commands other than intersect object"
Unfortunately, the problem is that in DBC there is no intersect object command!
Whenever I write anything, I like it to be usable in Classic as well as Pro, so I do it in DBC first. I know a lot of people still use DBC, so I try to support both versions.
Anyway, here's a bit of code to demonstarte what I was thinking about:
Gosub Setup
Do
CX#=CAMERA ANGLE X(): CY#=CAMERA ANGLE Y(): CZ#=CAMERA ANGLE Z()
CX#=Wrapvalue(CX#+mousemovey())
CY#=Wrapvalue(CY#+mousemovex())
Rotate Camera CX#,CY#,CZ#
If MouseClick()=1 Then Move Camera .1
If MouseClick()=2 Then Move Camera -.1
If ScanCode()= 17 Then Move Camera 1
If ScanCode()= 31 Then Move Camera -1
If RightKey() = 1
Repeat
PlayerAngle# = WrapValue(PlayerAngle#+1.0)
YRotate Object 501,PlayerAngle#
YRotate Object 502,PlayerAngle#
Sync
Until RightKey() = 0
Endif
If LeftKey() = 1
Repeat
PlayerAngle# = WrapValue(PlayerAngle#-1.0)
YRotate Object 501,PlayerAngle#
YRotate Object 502,PlayerAngle#
Sync
Until LeftKey() = 0
Endif
If UpKey() = 1
Move Object 501,.1
Position Object 502,Object Position X(501),Object Position Y(501),Object Position Z(501)
Endif
Gh# = Get Ground Height(1,Camera Position X(), Camera Position Z())+1
If Camera Position Y() < Gh# Then Position Camera Camera Position X(), Gh#, Camera Position Z()
RadarAngle# = WrapValue(Object Angle Y(502)+1)
YRotate Object 502,RadarAngle#
ObjInView = Object Collision(502,0): Rem Obj 502 = Sphere 503 = Rotating Arm
Sync
Text 0,0,"FPS: "+Str$(Screen FPS())
Text 0,16,"Visible Trees: "+Str$(SeenTrees)
Text 0,32,"Radar Angle: "+Str$(RadarAngle#)
Text 0,48,"Beam Collision: "+Str$(ObjInView)
Loop
Setup:
Set Display Mode 1024,768,32
Sync On: Sync Rate 0
CLS 0
AutoCam Off
Hide Mouse
Randomize Timer()
Set Ambient Light 30
Set Camera Range 1.0,50000.0
Rem Make Ground
Make Matrix 1,500,500,50,50
Rem Create Texture For Matrix
CREATE BITMAP 1,128,128
CLS RGB(0,100,0)
For N=1 To 1600
Ink RGB(0,Rnd(100)+55,0),0
Dot Rnd(128),Rnd(128)
Next N
Get Image 1,0,0,128,128
PREPARE MATRIX TEXTURE 1,1,1,1
Delete Bitmap 1
Ink RGB(255,255,255),0
For N = 1 To 90
Make Object Cube N,1
Set Object Collision On N
Color Object N,RGB(0,0,255)
TrunkSize = Rnd(50)+100
Scale OBJECT N, TrunkSize, 100, TrunkSize
TreeX = Rnd(100) + 200
TreeZ = Rnd(100) + 200
Position Object N,TreeX,1,TreeZ
Next N
Make Object Cube 501,3: Rem Player
Set Object Collision Off 501
Position Object 501,250,1,250
Color Object 501,RGB(255,0,0)
Ghost Object On 501
Make Object Sphere 502,1: Rem Scanner Pivot
Set Object Collision Off 502
Position Object 502,0,0,0
Make Object Box 503,.1,.1,20: Rem Scanner Beam
Set Object Collision On 503
GLUE OBJECT TO LIMB 503, 502, 0
OFFSET LIMB 503, 0, 0, 0, 10
Position Object 502,250,1,250
Position Camera 250,200,50
Return
Use 'W', 'S' and the mouse (and buttons) to control the camera.
Use the Up, Left and Right cursor keys to move the player (red box) around the screen.
To make matters worse, although you can run the above code in DBC and DBP, they both do different things wrong!
In DBC, when you wander around, no collision is detected at all when you check the glued object (503) for collisions with line:
ObjInView = Object Collision(503,0)
In DBP, strangely, the very same line detects collisions with object 502 (the sphere) - not object 503!
Mr X:
A big sphere wouldn't work because it can't detect a single tree at a time. What is needed is to know exactly how many trees are in the area immediately in front of you - so you know which ones are behind you in order to hide them.
You also have to calculate how far you are away from them, so that once you reach a certain distance from one it can be deleted and it's place in the system freed up ready to hold another one.
In essence, the way I have been thinking about this, if I can get it working, it will effectively be a particle system for trees!
TDK_Man