Yes all arrays are globals (note i use types-see expl below)
Yes moveentity moves the entity whichever way its facing.
And translateentity moves the entity to world coords.
This is how I do my 3d code. I use everything as a type.
Try This to store your mesh info.
;first define the type and approx fields
type player
field model
field x
field y
field z
field rot
;then to create a new player
p.player=new player
p\model=copyentity(player_entity) ;assuming you have a model
p\x#=0; or whever the models starting
p\y#=0
p\z#=0
p\rot=0 ;starts off facing its normal position
Heres a quick little program defining collisions, mesh/model movement, keyboard controls, and bullet firing. Create image/image buffer, rotation controls, adding meshes manually, etc. I think this code is pretty well documented and easy to follow, good luck
Yes moveentity moves the entity whichever way its facing.
And translateentity moves the entity to world coords.
This is how I do my 3d code. I use everything as a type.
Try This to store your mesh info.
;first define the type and approx fields
type player
field model
field x
field y
field z
field rot
;then to create a new player
p.player=new player
p\model=copyentity(player_entity) ;assuming you have a model
p\x#=0; or whever the models starting
p\y#=0
p\z#=0
p\rot=0 ;starts off facing its normal position
Heres a quick little program defining collisions, mesh/model movement, keyboard controls, and bullet firing. Create image/image buffer, rotation controls, adding meshes manually, etc. I think this code is pretty well documented and easy to follow, good luck
;note i didn't use p.player in this code Graphics3D 400,300,16,3 ;change to 1 for faster SetBuffer BackBuffer() ;Set Collision Types as Constants Const Type_player=1 Const Type_wall=2 light=CreateLight() RotateEntity light,90,0,0;rotate the light, puts the light at 0,0,0 and makes stuff visible ;Create Base Bullet model and resizes it bullx=CreateSphere() ScaleEntity bullx,.5,.5,.5 HideEntity bullx ;hides it, this one will not be seen ;create player fighter model=CreateCube() EntityType model,1 EntityRadius model,1.25 PositionEntity model,40,1,5 cam=CreateCamera() PositionEntity cam,40,3,1 ;attach the camera pivot pivot=CreatePivot() EntityParent pivot,model EntityParent cam,model ;create a generic checkboard texture used on walls and floor both=need some color tex=CreateTexture( 256,256 ) ;set the texturebuffer to draw on such texture and makes a checkerboard type look SetBuffer TextureBuffer( tex ) Color 255,0,0 For x=0 To 256 Step 32 For y=0 To 256 Step 32 Rect x,y,16,16 Next Next ;reset buffer SetBuffer BackBuffer() Cls ;create the floor by addingvertexes etc manually Arena=CreateMesh() Afloor=CreateSurface(Arena) v1=AddVertex (afloor,0,0,100,0,1) v2=AddVertex (afloor,100,0,100,1,1) v3=AddVertex (afloor,100,0,0,1,0) v4=AddVertex (afloor,0,0,0,0,0) tri=AddTriangle(afloor,v1,v2,v3) tri2=AddTriangle(afloor,v1,v3,v4) EntityTexture arena,tex EntityRadius arena,1 EntityType arena,Type_floor ;and the four sequential walls nwall=CreateMesh() nFloor=CreateSurface(nwall) v1=AddVertex (nFloor,0,10,0,0,1) v2=AddVertex (nFloor,0,10,100,1,1) v3=AddVertex (nFloor,0,0,100,1,0) v4=AddVertex (nFloor,0,0,0,0,0) tri=AddTriangle(nFloor,v1,v2,v3) tri2=AddTriangle(nFloor,v1,v3,v4) afloor=LoadTexture("c:\blitz\checker2.bmp") EntityTexture nwall,tex EntityRadius nwall,1 EntityType nwall,2 UpdateNormals(nwall) swall=CreateMesh() sFloor=CreateSurface(swall) v1=AddVertex (sfloor,100,10,100,0,1) v2=AddVertex (sfloor,100,10,0,1,1) v3=AddVertex (sfloor,100,0,0,1,0) v4=AddVertex (sfloor,100,0,100,0,0) tri=AddTriangle(sfloor,v1,v2,v3) tri2=AddTriangle(sfloor,v1,v3,v4) EntityTexture swall,tex EntityRadius swall,1 EntityType swall,2 UpdateNormals(swall) wwall=CreateMesh() wfloor=CreateSurface(wwall) v1=AddVertex (wfloor,0,10,100,0,1) v2=AddVertex (wfloor,100,10,100,1,1) v3=AddVertex (wfloor,100,0,100,1,0) v4=AddVertex (wfloor,0,0,100,0,0) tri=AddTriangle(wfloor,v1,v2,v3) tri2=AddTriangle(wfloor,v1,v3,v4) EntityTexture wwall,tex EntityRadius wwall,1 EntityType wwall,2 UpdateNormals(wwall) ewall=CreateMesh() efloor=CreateSurface(ewall) v1=AddVertex (efloor,100,10,0,0,1) v2=AddVertex (efloor,0,10,0,1,1) v3=AddVertex (efloor,0,0,0,1,0) v4=AddVertex (efloor,100,0,0,0,0) tri=AddTriangle(efloor,v1,v2,v3) tri2=AddTriangle(efloor,v1,v3,v4) EntityTexture ewall,tex EntityRadius ewall,1 EntityType ewall,2 ;update the rest of the normals for light,etc UpdateNormals(ewall) UpdateNormals(arena) UpdateNormals(model) ;enable collisions between player and wall ;note since the player model is moving, if you did collisions 2,1,2,2 it wouldn't work Collisions 1,2,2,2 While Not KeyHit(1) ;Check NewFire If KeyDown(57)=True Then ;change If keydown(57) to If keyhit(57) for noncontinous firing ;if fired Create a new bullet and position it at players location b.bullet=New bullet b\model=CopyEntity(bullx) ax#=EntityX(model) ay#=EntityY(model) az#=EntityZ(model) PositionEntity b\model,ax#,ay#,az# TurnEntity b\model,0,rot#,0 MoveEntity b\model,0,0,3 b\dur=50 ;after dur is over, bullet disappears EndIf ;Read KeyCommands ;if keyhit(205)=true then ;exchange this and next line, keydown will fire almost constatly If KeyDown( 205 )=True Then rot#=rot#-5 TurnEntity model,0,-5,0 ;next line stores rotation of player model If rot#<0 Then rot#=Rot#+360 EndIf If KeyDown( 203 )=True Then rot#=rot#+5 TurnEntity model,0,5,0 If rot#>360 Then rot#=rot#-360 EndIf If KeyDown( 208 )=True Then MoveEntity model,0,0,-1 If KeyDown( 200 )=True Then MoveEntity model,0,0,1 ;Update Each Bullet For b.bullet=Each bullet MoveEntity b\model,0,0,3 b\dur=b\dur-1 If b\dur<0 Then FreeEntity b\model Delete b ;deletes b.bullet all fields EndIf Next ;check collisions UpdateWorld ;show the world as it is now RenderWorld ;I never Did Add life! Text 10,10,"Life: "+life Flip Wend ClearWorld() End Type bullet Field model Field dur ;if dur ends bullet disapppears End Type end type