Jump to content

Different colored boxes


Game Producer
 Share

Recommended Posts

I was wondering how big deal would it be to have like 100 box objects in a screen, but somehow change their color so that I don't need to create additional materials. Is there good way to do this?

(I'm thinking procedural creature creation... where creature would be made of boxes and each individual box might have different colors....)

 

I was also wondering if this would increase memory consumption?

 

Thanks in advance

 

(Was there demo about this? I searched forums but could not find one)

Intel Dual Core 3GHz / GeForce GTS 450 - 1024 MB / Driver ver 267.59 / 8 GB RAM / Win 7 - 64 bit / LE2.50 / BMAX 1.48

game producer blog - Dead Wake Zombie Game powered by Leadwerks Engine

Twitter - Unfollow me

Link to comment
Share on other sites

Holy smokes, EntityColor seems to do the trick:

http://www.leadwerks.com/werkspace/page/Documentation/le2/_/command-reference/entities/entitycolor-r139

 

(thanks macklebee for help via chat)

Intel Dual Core 3GHz / GeForce GTS 450 - 1024 MB / Driver ver 267.59 / 8 GB RAM / Win 7 - 64 bit / LE2.50 / BMAX 1.48

game producer blog - Dead Wake Zombie Game powered by Leadwerks Engine

Twitter - Unfollow me

Link to comment
Share on other sites

LUA example by macklebee:

 

require("Scripts/constants/engine_const")
require("Scripts/math/math")
RegisterAbstractPath("")        
Graphics(800,600)        

fw=CreateFramework()        
fw.main.camera:SetPosition(Vec3(0,1,-5))
camerapitch=fw.main.camera.rotation.x
camerayaw=fw.main.camera.rotation.y

light = CreateDirectionalLight()
light:SetRotation(Vec3(45,45,0))

material=LoadMaterial("abstract::cobblestones.mat")
boxphy = CreateBodyBox(1,1,1)
box=CreateCube(boxphy)
boxphy:SetMass(1)
boxphy:SetCollisionType(1)
box:Paint(material)

groundphy = CreateBodyBox(100,1,100)
ground=CreateCube(groundphy)
ground:SetScale(Vec3(100,1,100))
groundphy:SetPosition(Vec3(0,-2,0))
groundphy:SetCollisionType(2)
ground:Paint(material)

cubephy = {}
for i = 1, 99 do
cubephy[i] = boxphy:Copy(1)
local cube = cubephy[i]:GetChild(1)
cube:SetColor(Vec4(math.random(255)/255,math.random(255)/255,math.random(255)/255,1))
cubephy[i]:SetPosition(Vec3(math.random(10),i,math.random(10)))
end

SetStats(2)
HideMouse()
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)
while KeyHit(KEY_ESCAPE)==0 do   
gx = Round(GraphicsWidth()/2)        
       gy = Round(GraphicsHeight()/2)        
       dx = Curve((MouseX()-gx)/4,dx,3/AppSpeed())        
       dy = Curve((MouseY()-gy)/4,dy,3/AppSpeed())        
       MoveMouse(gx,gy) 
camerapitch = camerapitch+dy        
       camerayaw = camerayaw-dx        
       fw.main.camera:SetRotation(Vec3(camerapitch,camerayaw,0))
move = Curve((KeyDown(KEY_W)-KeyDown(KEY_S)),move,3/AppSpeed())        
       strafe = Curve((KeyDown(KEY_D)-KeyDown(KEY_A)),strafe,3/AppSpeed())      
MoveEntity(fw.main.camera,Vec3(strafe/10,0,move/10))

fw:Update()
fw:Render()
collectgarbage(collect)
Flip(1)
end
ShowMouse()[

Intel Dual Core 3GHz / GeForce GTS 450 - 1024 MB / Driver ver 267.59 / 8 GB RAM / Win 7 - 64 bit / LE2.50 / BMAX 1.48

game producer blog - Dead Wake Zombie Game powered by Leadwerks Engine

Twitter - Unfollow me

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...