Is it possible to use a single Tmesh object for multiple displayed objects? Since I have several identical objects, I'd like to load just one mesh and texture, then position and rotate it several times to stand for each of the objects. Is this possible, or do I need a separate Tmesh object loaded for each object I'm displaying?
Using one mesh for multiple objects?
BlitzMax Modules Forums/MiniB3D/Using one mesh for multiple objects?Is it possible to use a single Tmesh object for multiple displayed objects?
Yes, if your objects use the same texture. Example:
SuperStrict Import sidesign.minib3d SeedRnd MilliSecs() Graphics3D 1024, 768, 32 Local camera:TCamera = CreateCamera() AmbientLight 255, 255, 255 'Local master:TMesh = LoadMesh("rock001/rock001.b3d") Local master:TMesh = CreateCube() HideEntity master Local layer:TMesh = CreateMesh() Local num_objs:Int = 500 For Local n:Int = 1 To num_objs Local temp_obj:TMesh = CopyMesh(master) ScaleMesh temp_obj, Rnd(5.0, 10.0), Rnd(5.0, 10.0), Rnd(5.0, 10.0) RotateMesh temp_obj, 0.0, Rnd(0.0, 360.0), 0.0 PositionMesh temp_obj, Rnd(-500.0, 500.0), -55.0, (MeshDepth(temp_obj) * 2) + Rnd(0.0, 1000.0) AddMesh temp_obj, layer FreeEntity temp_obj Next Local renders:Int, old_ms:Int, fps:Int While Not KeyHit(KEY_ESCAPE) UpdateWorld RenderWorld renders = renders + 1 If MilliSecs() -old_ms >= 1000 old_ms = MilliSecs() fps = renders renders = 0 EndIf Text 5, 5, FPS + " fps" Flip False Wend End
AddMesh is the notable command. See the Blitz3D docs for its limitations.
Thanks!