How to color an imported 3ds mesh?
Posted: Fri Feb 07, 2020 6:52 pm
Hi everyone, it's been a long time since I played ZGE. So I'm back to basics...
I'm trying to color an imported 3DS mesh directly in ZGE.
This mesh is already colored using vertex colors.
I tried UseMaterial and RenderSetColor without success. In the example below, how could I color my cube while pressing the spacebar?
Am I obliged to use textures for that?
Thanks for your help
I'm trying to color an imported 3DS mesh directly in ZGE.
This mesh is already colored using vertex colors.
I tried UseMaterial and RenderSetColor without success. In the example below, how could I color my cube while pressing the spacebar?
Am I obliged to use textures for that?
Thanks for your help
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<SpawnModel Model="CubeModel" SpawnStyle="1"/>
</OnLoaded>
<OnUpdate>
<ZExpression Expression="CubeHit = 0;"/>
<KeyPress CharCode="32">
<OnPressed>
<ZExpression Expression="CubeHit = 1;"/>
</OnPressed>
</KeyPress>
</OnUpdate>
<Content>
<Mesh Name="BoxMesh">
<Producers>
<MeshImport HasVertexColors="1">
<MeshData>
<![CDATA[789C9D8CC10D80300C0353103FFEECD10598A6733047A76113E8086C600CA14ADA278E4E8E1C2B8B88CCA460DB0FF2F809AC072904AF581075C56735B74CA9F2B9DDAD613FFC777FAF5B908100414699C89FFD42EA06312AF9F34E29B5B0D4928D1B1414A9E7]]>
</MeshData>
</MeshImport>
</Producers>
</Mesh>
<Model Name="CubeModel" Rotation="1.897 2.5127 2.2678" RotationVelocity="0.0605 0.0289 0.047">
<OnSpawn>
<ZExpression Expression="CurrentModel.RotationVelocity = rnd() * 0.1;"/>
</OnSpawn>
<OnRender>
<Condition Comment="Is Cube Hit?" Expression="return CubeHit == 1;">
<OnTrue>
<UseMaterial Material="RedMaterial"/>
<RenderSetColor Color="1 0 0 1"/>
<RenderTransform Scale="1.1 1.1 1.1"/>
</OnTrue>
<OnFalse>
<UseMaterial Material="FlatMaterial"/>
</OnFalse>
</Condition>
<RenderMesh Mesh="BoxMesh"/>
</OnRender>
</Model>
<Material Name="RedMaterial" Shading="1" Color="1 0 0 1"/>
<Material Name="FlatMaterial" Shading="1"/>
<Variable Name="CubeHit" Type="1"/>
</Content>
</ZApplication>