cant use Dims?

Blitz3D Forums/Blitz3D Programming/cant use Dims?

sting(Posted 2005) [#1]
Alright. for this little tidbit I was working on a small app to see scale sizes to help me program. I got confused because I tried to make a bunch of cubes and couldnt seem to use entity pick on the cubes if they were in a Dim. This is ok with me but I also created a plain cube like normal and couldnt pick that until I commented out everything to do with the Dim cubes. I couldnt even pick the plane with those things around.
Below is the working code where i can pick the regular cube. you can test the error if you uncomment the blocks where it says to.
Thanks.


Graphics3D 800,600,32,2
AppTitle "Scale Test"
SetBuffer BackBuffer()
;Dim cubeg(5)                                   ;uncomment this block
;Global n# = 1
;Global d# = 6
;Global b = 1
;For x=1 To 3
;	cubeg(x)=CreateCube()
;	ScaleEntity cubeg(x),n#/d#,n#,n#/d#
;	EntityColor cubeg(x),255,50,50
;	EntityPickMode cubeg(x),2
;	n#=n#+1
;Next
;n#=5
;For x=4 To 5
;	n#=n#*b
;	cubeg(x)=CreateCube()
;	ScaleEntity cubeg(x),n#/d#,n#,n#/d#
;	EntityColor cubeg(x),255,50,50
;	EntityPickMode cubeg(x),2
;	b=b+1
;Next

cube=CreateCube() 
EntityPickMode cube,2
ScaleEntity cube,1,1,1
EntityColor cube,255,250,50
PositionEntity cube,8,1,-8

Global camera=CreateCamera():EntityRadius camera,5
PositionEntity camera,7,4,-10
CameraViewport camera,0,0,800,600
CameraFogMode camera,1
CameraFogRange camera,8,20
CameraFogColor camera,0,0,0
CameraClsColor camera,0,0,0
;n#=1                                            ;uncomment this block 
;b=1
;For x=1 To 5
;	PositionEntity cubeg(x),b,0,0
;	b=b+x
;Next 
light=CreateLight()                                   ;standard light
RotateEntity light,90,0,0 

plane=CreatePlane()                                    ;standard plane
EntityPickMode plane,2
EntityColor plane,50,200,100
;grass_tex=LoadTexture( "media/wcrate.jpg" ) 
;EntityTexture plane,grass_tex



;Global vv#

While Not KeyDown(1)                          ;exit on Ecs
	If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0         ;controls
	If KeyDown( 203 )=True Then TurnEntity camera,0,1,0 
	If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.05 
	If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.05
	If KeyDown( 15 )=True Then vv#=vv#+1                       ;tab and Q to change a spacific value not used
	If KeyDown( 16 )=True Then vv#=vv#-1
	If MouseHit(1)=True Then CameraPick(camera,MouseX(),MouseY())     ;pick
	RenderWorld
;	Text 0,0,"Nearest entity to Cubey: "+EntityPick(cube,vv#)
;	Text 0,20,"vv="+vv#
;	Text 0,30,"----------"
	Text 0,40,"PickedX: "+PickedX#()          ;text from some example
	Text 0,60,"PickedY: "+PickedY#() 
	Text 0,80,"PickedZ: "+PickedZ#() 
	Text 0,100,"PickedNX: "+PickedNX#() 
	Text 0,120,"PickedNY: "+PickedNY#() 
	Text 0,140,"PickedNZ: "+PickedNZ#() 
	Text 0,160,"PickedTime: "+PickedTime#() 
	Text 0,180,"PickedEntity: "+PickedEntity()
	If PickedEntity()=cube Then        ;test if it can return a pick
		End
	EndIf

	Flip
Wend
End 



Sledge(Posted 2005) [#2]
Most of this works fine. You are having problems because in the commented-out stuff at the bottom you destroy the result of the CameraPick before you compare it to see if the program should exit. You do this by calling EntityPick, which sets a new PickedEntity, but there is nothing "ahead" of the picking cube due to the position of the array'ed objects. Translate the picking cube along the x-axis with a nice big range and you will see it start to pick the objects in front of it.

Here, this will report which of the array'ed objects is "ahead" of the yellow cube and allow clicking on the yellow cube to exit:



sting(Posted 2005) [#3]
Thanks this helps alot with one of my questions. But im still wondering why I can use my Mouse to pick and return the PickedEntity() ID of the plane and the yellow cube alone. But when there are simply more cubes (the red ones) I cant get it to return the PickedEntity()ID.


Sledge(Posted 2005) [#4]
You should be able to. Here is a quick edit that constantly returns the entity picked by the mouse. Yellow cube still exits.




sting(Posted 2005) [#5]
Ok i see. Its an order thing. Thanks.