base model usage question

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
Posts: 4
Joined: Sat Mar 07, 2020 12:36 am

base model usage question

Post by sky_haihai » Mon Mar 09, 2020 6:02 am

does anyone have an example of the usage of baseModel?
the problem i have is: say there is a model named "base" and two other models named "player" and "enemy" which both use "base" as their base models. If I want to change the player's renderMesh component which is located inside "base" when pressing a key, what should I do? I tried changing the value of the Mesh by calling MyRender.Mesh=MyMesh, but soon realized when MyRender is outside of the player model, changing its value doesn't affect the one in the current "clone", as the ZGE help says. However, this doesn't match my expectation, because when i test this for variables they change separately between "player" and "enemy" model...why component value can't while variables can?
Or maybe basemodel is useful for variables only?
can anyone please explain? thanks a lot
Last edited by sky_haihai on Mon Mar 09, 2020 4:30 pm, edited 1 time in total.

User avatar
Posts: 426
Joined: Sat Feb 15, 2014 9:54 am

Re: base model usage question

Post by rrTea » Mon Mar 09, 2020 7:46 am

It depends on the context, but just as an illustration here is a simple way of setting the mesh you want to show in the base model, basically move the RenderMesh component to Definitions…

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
    <SpawnModel Model="Enemy1" Position="-4 0 0"/>
    <SpawnModel Model="Enemy2" Position="4 0 0"/>
    <Model Name="base_Enemy">
        <RenderMesh Name="rMesh_Body"/>
<![CDATA[if ( frac(App.Time + CurrentModel.Personality)<0.5 )
   rMesh_Body.Mesh = Mesh1;
   rMesh_Body.Mesh = Mesh2;
        <UseMaterial Material="Material1"/>
        <CallComponent Component="rMesh_Body"/>
    <Model Name="Enemy1" BaseModel="base_Enemy" RotationVelocity="0 0 0.1"/>
    <Model Name="Enemy2" BaseModel="base_Enemy" RotationVelocity="0 0 -0.1"/>
    <Material Name="Material1"/>
    <Mesh Name="Mesh1">
        <MeshBox Grid2DOnly="255"/>
    <Mesh Name="Mesh2">
        <MeshBox XCount="10" YCount="10" Grid2DOnly="255"/>
        <MeshNoise NoiseSpeed="1 1 1" NoiseScale="1 1 1"/>
You can also do it with States too (in the Base model). I'm a bit confused by the idea of using the same base for Player and Enemy models, but I guess it depends on your project.

Posts: 4
Joined: Sat Mar 07, 2020 12:36 am

Re: base model usage question

Post by sky_haihai » Mon Mar 09, 2020 4:35 pm

Thank you !! problem solved

Post Reply