I have a texture that is randomly created with a BitmapExpression at the start of a level, and I apply a @RefreshContent on it and everything is working fine... Until I used that texture on the same model spawned several times on the scene. I expect each models to have different textures, but the last content refresh is the only texture existing. So I was thinking I had to put that Bitmap in the Definitions of the model, just like variables and meshes, but it just crashes.
So I'm stuck against the logic here.
Is this possible to do? And I think I'll have the same problem afterwards with Named RanderTransformGroup inside the OnRender of the Model...
I made a very simple non-working (crashing) example:
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZExpression>
<Expression>
<![CDATA[for (int i=0; i<16; i++)
{
model m = createModel(ModelCube);
m.CubeColor = vector3(rnd(),rnd(),rnd());
m.Scale = 0.4;
m.Position = vector3(random(0,8), random(0,6), -random(10,6));
TempColor = CubeColor;
@RefreshContent(Component: BitmapColor);
}]]>
</Expression>
</ZExpression>
</OnLoaded>
<Content>
<Model Name="ModelCube">
<Definitions>
<Variable Name="CubeColor" Type="7"/>
<Material Name="Material1">
<Textures>
<MaterialTexture Texture="BitmapColor" TexCoords="1"/>
</Textures>
</Material>
<Bitmap Name="BitmapColor" Width="16" Height="16">
<Producers>
<BitmapExpression>
<Expression>
<![CDATA[Pixel.R = CurrentModel.CubeColor.X;
Pixel.G = CurrentModel.CubeColor.Y;
Pixel.B = CurrentModel.CubeColor.Z;
/*
Pixel.R = TempColor.X;
Pixel.G = TempColor.Y;
Pixel.B = TempColor.Z;
*/]]>
</Expression>
</BitmapExpression>
</Producers>
</Bitmap>
</Definitions>
<OnRender>
<UseMaterial Material="Material1"/>
<RenderMesh Mesh="MeshCube"/>
</OnRender>
</Model>
<Mesh Name="MeshCube">
<Producers>
<MeshBox/>
</Producers>
</Mesh>
<Variable Name="TempColor" Type="7"/>
</Content>
</ZApplication>