Lots of the same mesh?

Archives Forums/Blitz3D SDK Programming/Lots of the same mesh?

Amon(Posted 2007) [#1]
In 2d I would load an image and draw it several times at array position in a 2d tilemap.

How can i make lots of the same mesh and have different xyz position for it?

Heres what I tried. Psuedo Code
===================

global mymesh =  bbloadmesh(mymesh)

Type Block
field mesh
field x
field y

function create()
local b:block = new block
b.x = Rand(0,800)
b.y = Rand(0,500)
b. mesh = bbCopyMesh(mymesh)
end function

method PosMesh()
bbpositionentity(mesh , x , y, z)
end method

Create 10 Meshes

while not bbkeyhti(blah

for local b:block = eachin blahbooly
b.posmesh
next
wend


Is copymesh the wrong command to use?

Another thing, how do I load a mesh and not have it display until it's created?

Currently when I load a mesh with loadmesh it displays it on screen. I don't want it to do that. I just want to load it and then when I need it draw it. HideEntity hides it, I know.

Thinjk of it like 2d. When you load a 2d image it's not automatically there until it's drawn.


H&K(Posted 2007) [#2]
We so know so little B3D dont we ;)

I think that CopyMesh makes a low/real copy of the Mesh, whilst CopyEntity makes a "Pointer" copy of the entity.

That is CopyMesh takes loads of memory, but CopyEntity doesnt. We probably need a B3D programmer to tell us for sure


(tu) sinu(Posted 2007) [#3]
Use copyentity for simple copies of the entity which you don't plan on using mesh commands on, which actually change the mesh structure ie positionmesh, scalemesh.
This is a quick simple workaround me thinks. bit rusty with bmax

Type block
  global MainMesh = CreateCube()
  field DoRender:int
  field entity:int
  field x:float, y:float, z:float

function create()
  local b:block = new block
  b.x = Rand(0,800)
  b.y = Rand(0,500)
  b. mesh = bbCopyEntity(block.MainMesh);is this right, not    sure you access globals from type this way?
end function

method render(draw = true)
   DoRender = draw
end method

method draw:int()
  if DoRender
    Showentity entity
  else
    hideentity entity
  endif
end method

method PosMesh()
bbpositionentity(entity, x , y, z)
end method

end type

for local b:block = eachin blahbooly
  b.draw()
  b.posmesh
next



edit: i have put a simple loop in but you would need a while/wend with bbupdateworld and bbrenderworld.


Zethrax(Posted 2007) [#4]
What H&K said is correct.


impixi(Posted 2007) [#5]


Currently when I load a mesh with loadmesh it displays it on screen. I don't want it to do that.



Hide it before your first call to RenderWorld.

Import blitz3d.blitz3dsdk

bbBeginBlitz3D()

bbGraphics3D 800,600

Local light=bbCreateLight()
Local camera=bbCreateCamera()
bbPositionEntity camera,0,0,-10

Local master=bbLoadMesh(AppDir + "\visual\sr_tree000.b3d")
bbHideEntity master             '<--*****

'Local copy=bbCopyMesh(master)

While Not bbKeyHit(BBKEY_ESCAPE)

	bbRenderWorld          '<--*****
	
	bbFlip 
	
Wend