need help

Blitz3D Forums/Blitz3D Beginners Area/need help

Smurfpuss(Posted 2010) [#1]
how do i make so i can delet the tiles i made amd is it a possibility to use a texture file whit tiles textures to texture the cubes

Global G_grid_cell_size# = 1.0

Graphics3D 800, 600, 0, 2

Type TObj
Field mesh ; Holds the handle to an entity
Field x#,z# ; Holds a random value
End Type



Global G_camera = CreateCamera()
CameraZoom G_camera, 0.8
TurnEntity G_camera, 90.0, 0.0, 0.0
MoveEntity G_camera, 0.0, 0.0, -20.0

temp.TObj = New TObj
temp\mesh = CreateCube()
;gcube = CreateCube()
EntityPickMode temp\mesh, 2
;EntityPickMode gcube, 2


temp\mesh= CreateCube()


texture=LoadTexture("test.bmp")
;EntityTexture G_cube,texture
EntityTexture temp\mesh,texture
;EntityTexture gcube,texture
Global G_grid = Creategrid()
EntityPickMode G_grid, 2

Global G_picked_entity

SetBuffer BackBuffer()

Repeat



pickedent = CameraPick( G_camera, MouseX(), MouseY() )

If PickedEnt

x# = Floor( PickedX() / G_grid_cell_size# ) * G_grid_cell_size#
z# = Floor( PickedZ() / G_grid_cell_size# ) * G_grid_cell_size#

EndIf

;Local PickedEnt, EntName$, EntityInstance.TObj

If KeyDown(203) Then MoveEntity G_camera, -1, 0, 0
If KeyDown(205) Then MoveEntity G_camera, 1, 0, 0
If KeyDown(200) Then MoveEntity G_camera, 0, 1, 0
If KeyDown(208) Then MoveEntity G_camera, 0, -1, 0
If KeyDown(201) Then MoveEntity G_camera, 0, 0, 1
If KeyDown(209) Then MoveEntity G_camera, 0, 0, -1
If KeyDown(57) Then
removeobject(temp\mesh)
EndIf


If MouseHit(1) Then
PickedEnt = CameraPick(G_camera, MouseX(), MouseY())
;temp\mesh= CreateCube()
CopyEntity(temp\mesh)
PositionEntity temp\mesh, x#, 0, z#
EntityTexture temp\mesh, texture


End If

If MouseHit(2) Then
PickedEnt = CameraPick(G_camera, MouseX(), MouseY())

If PickedEnt Then


Else
EndIf

End If



UpdateWorld
RenderWorld
Text 10,0,"FPS: "+G_cube
Text 10,10,"x: "+x
Text 10,20,"y: "+z
Text 10, 30, "Tris rendered: " + TrisRendered()
Text 10,40,"name: "+ EntName$
Text 10,50,"entity: "+ PickedEnt




Flip
Delay( 1 )

Until KeyHit( 1 )

End



Function CreateGrid()
; -- Create grid texture.
Local i, x, y
Local grid_2d_tex = CreateTexture ( 256, 256, 11 )
SetBuffer TextureBuffer ( grid_2d_tex )
For i = 0 To 4
Rect i, i, 256 - i - i, 256 - i - i, False
Next
For y = 5 To 250
For x = 5 To 250
WritePixel x, y, 0
Next
Next
;^^^^^^
; -- Create 2D grid.
Local grid_2D = CreatePlane ()
EntityTexture grid_2D, grid_2d_tex
EntityFX grid_2D, 9
;^^^^^^
Return grid_2D
End Function

Function FindObject.TObj(mesh )
; Search through all TObj instances
For temp.TObj = Each TObj
; When the given Entity-handle matches the entity-handle that was stored in the TObj instance, return the TObj instance
If temp\mesh = mesh Then Return temp
Next
End Function


Ross C(Posted 2010) [#2]
Can you possibly explain your problem a little better? Can't make much sense of what you wrote, sorry!

Last edited 2010


Matty(Posted 2010) [#3]
Looking through your code you've got memory leaks everywhere. You create objects but don't store the handle (temp\mesh for example)..

There's a lot that is wrong with it and I'm not sure where to start.


Smurfpuss(Posted 2010) [#4]
well thats prob whats wrong sins when ever i try using free entity to remove one cube i get error