DebugLog "PickedEntity(): "+String(PICKEDENTITY())
I looked in the MiniB3D.bmx if it was defined, it is, but it doesn't work in any of the examples. Any ideas?
DebugLog "PickedEntity(): "+String(PICKEDENTITY())
DebugLog "PickedEntity(): "+ PICKEDENTITY().toString()seems to do the trick.
Import "MiniB3D.bmx" Strict Local width=1024,height=768,depth=16,mode=1 Graphics3D width,height,depth,mode Local cam:TCamera=CreateCamera() PositionEntity cam,0,5,0 Local light:TLight=CreateLight() RotateEntity light,45,0,0 Local marker:TMesh=CreateSphere() ScaleEntity marker,0.2,0.2,0.2 EntityColor marker,255,0,0 Local mesh:TMesh=Createcube() Local MeshArray:Tmesh[10000] Local size:Int = 16 Local z:Int For Local mm:Int = 0 To size For Local x:Int = 0 To size mesharray[x] = copymesh(mesh) EntityPickMode mesharray[x],2 EntityColor mesharray[x],Rnd(0,255),Rnd(0,150),100+mm PositionEntity mesharray[x] ,(-size/2)*4+x*4,0,(-size/2)*4+z*4 mesharray[x].MeshCullRadius(0.75) Next z:+1 Next ' used by camera code Local mxs#=0 Local mys#=0 Local move#=0.5 MouseXSpeed() ' flush MouseYSpeed() ' flush ' used by fps code Local old_ms=MilliSecs() Local renders Local fps While Not KeyDown(KEY_ESCAPE) If KeyHit(KEY_ENTER) Then DebugStop '' control camera ' mouse look mxs#=mxs#+(MouseXSpeed()/5.0) mys#=mys#+(MouseYSpeed()/5.0) RotateEntity cam,mys#,-mxs#,0 If KeyDown(KEY_SPACE)=False MoveMouse width/2,height/2 MouseXSpeed() ' flush MouseYSpeed() ' flush EndIf ' move camera forwards/backwards/left/right with cursor keys If KeyDown(KEY_W) Or KeyDown(KEY_UP)=True Then MoveEntity cam,0,0,move# ' move camera forward If KeyDown(KEY_S) Or KeyDown(KEY_DOWN)=True Then MoveEntity cam,0,0,-move# ' move camera back If KeyDown(KEY_A) Or KeyDown(KEY_LEFT)=True Then MoveEntity cam,-move#,0,0 ' move camera left If KeyDown(KEY_D) Or KeyDown(KEY_RIGHT)=True Then MoveEntity cam,move#,0,0 ' move camera right '' 'TurnEntity mesh,0,1,0 ' if mousehit then perform camerapick If MouseDown(1) Local pick:TEntity=CameraPick(cam,MouseX(),MouseY()) If pick<>Null DebugLog "Picked!" DebugLog "PickedX(): "+String(PickedX()) DebugLog "PickedY(): "+String(PickedY()) DebugLog "PickedZ(): "+String(PickedZ()) DebugLog "PickedNX(): "+String(PickedNX()) DebugLog "PickedNY(): "+String(PickedNY()) DebugLog "PickedNZ(): "+String(PickedNZ()) DebugLog "PickedTime(): "+String(PickedTime()) DebugLog "PickedEntity(): "+PickedEntity().tostring() DebugLog "PickedSurface(): "+PickedSurface().tostring() DebugLog "PickedTriangle(): "+PickedTriangle() EntityColor PickedEntity(),255,255,0 PositionEntity marker,PickedX(),PickedY(),PickedZ() Else DebugLog "Not Picked" EndIf EndIf RenderWorld renders=renders+1 ' calculate fps If MilliSecs()-old_ms>=1000 old_ms=MilliSecs() fps=renders renders=0 EndIf DebugText 0,0,"FPS: "+String(fps) Flip Wend End Function CreatePlane:TMesh(parent_ent:TEntity=Null,Segments:Int=1) Local mesh:TMesh=TMesh.CreateMesh(parent_ent) Local surf:TSurface=mesh.CreateSurface() surf.AddVertex(-1.0,-1.0,-1.0) surf.AddVertex(-1.0, 1.0,-1.0) surf.AddVertex( 1.0, 1.0,-1.0) surf.AddVertex( 1.0,-1.0,-1.0) surf.VertexNormal(0,0.0,0.0,-1.0) surf.VertexTexCoords(0,0.0,1.0) surf.AddTriangle(0,1,2) surf.AddTriangle(0,2,3) Return mesh End Function
Function PickedEntity:TEntity() Return picked_ent End Function Function PickedSurface:TSurface() Return picked_surface End Function Function PickedTriangle() Return picked_triangle End Function