Amon Posted November 8, 2011 Share Posted November 8, 2011 Greetings all! Using BlitzMax is it better, within a type, to have a Field mesh:TMesh and use LoadMeshGMF for each instance or would it be better to load the mesh once then copy it for each instance? Ta! Quote Windows 7 Ultimate 64 bit - ATI Radeon HD 5750 - 6GB DDR2 Ram - Intel Core2Quad : Dev Languages Used :- BlitzMax - Leadwerks. May the sky never fall on your head. Link to comment Share on other sites More sharing options...
Josh Posted November 8, 2011 Share Posted November 8, 2011 Just call LoadMesh() as many times as you like, and the engine will automatically instance them. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Amon Posted November 8, 2011 Author Share Posted November 8, 2011 Just call LoadMesh() as many times as you like, and the engine will automatically instance them. Nice! Quote Windows 7 Ultimate 64 bit - ATI Radeon HD 5750 - 6GB DDR2 Ram - Intel Core2Quad : Dev Languages Used :- BlitzMax - Leadwerks. May the sky never fall on your head. Link to comment Share on other sites More sharing options...
Amon Posted November 8, 2011 Author Share Posted November 8, 2011 Greetings, again! I would like to create lots of instances of my mesh but also randomize the material applied to the mesh. Code posted below, if anyone can point me to the right direction I would appreciate it, thanks. Secondly, TEntity? If I Load a mesh using either of the Load commands i.e. LoadMeshGMF, LoadMesh etc, am I right in thinking they inherit from TEntity automatically? If not then how would I go about using LoadMeshGMF or LoadMesh and create its TEntity? Thanks! SuperStrict Framework leadwerks.ENGINE Local world:TWorld Local gbuffer:TBuffer Local camera:TCamera Local Light:TLight GCSetMode(2) RegisterAbstractPath( "C:/Apps/Coding/Leadwerks Engine SDK" ) RegisterAbstractPath("Y:/Coding/Leadwerks/GunGore/data/models") AppTitle = "Test Graphics(800, 600) SeedRnd MilliSecs() Type tZombie Field v:TVec3 Field m:TMesh Field te:TEntity Field dead:Int Field mat:Int Field mat1:TMaterial = LoadMaterial("abstract::zombie_1.mat") Field mat2:TMaterial = LoadMaterial("abstract::zombie_2.mat") Field mat3:TMaterial = LoadMaterial("abstract::zombie_3.mat") Field mat4:TMaterial = LoadMaterial("abstract::zombie_4.mat") Field mat5:TMaterial = LoadMaterial("abstract::zombie_5.mat") Global zList:TList Function CreateZombie(xloc:Float, yloc:Float, zloc:Float, maxzombies:Int) If Not zList:TList Then zList:TList = CreateList() For Local xi:Int = 0 Until maxzombies Local z:tZombie = New tZombie z.m = LoadMeshGMF("abstract::zombie1.gmf") z.mat = Rand(1, 5) If z.mat = 1 Then PaintEntity(z.m, z.mat1) If z.mat = 2 Then PaintEntity(z.m, z.mat2) If z.mat = 3 Then PaintEntity(z.m, z.mat3) If z.mat = 4 Then PaintEntity(z.m, z.mat4) If z.mat = 5 Then PaintEntity(z.m, z.mat5) z.v = New TVec3 z.dead = 0 z.v.x = xloc z.v.y = yloc z.v.z = zloc zList.AddLast(z) Next End Function Method SetZPosition() PositionEntity(m, [v.x, v.y, v.z]) End Method End Type world=CreateWorld() If Not world RuntimeError "Failed to create world." gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_DEPTH|BUFFER_COLOR0|BUFFER_COLOR1|BUFFER_COLOR2) camera = CreateCamera() PositionEntity camera, [0.0, 5.0, -2.0] Light = CreateDirectionalLight() RotateEntity Light, [45.0, 45.0, 45.0] SetLightRange(Light, 100.0) tZombie.CreateZombie(Rnd(-10.0, 10.0), 0.0, Rnd(0.0, 20.0), 10) For Local z:tZombie = EachIn tZombie.zList z.SetZPosition Next Repeat If KeyHit(KEY_ESCAPE) Exit If AppTerminate() Exit UpdateAppTime() UpdateWorld(AppSpeed()) SetBuffer(gbuffer) RenderWorld() SetBuffer(BackBuffer()) RenderLights(gbuffer) Flip(0) Forever gbuffer=Null FreeEntity light GCCollect() End Quote Windows 7 Ultimate 64 bit - ATI Radeon HD 5750 - 6GB DDR2 Ram - Intel Core2Quad : Dev Languages Used :- BlitzMax - Leadwerks. May the sky never fall on your head. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.