Today I was playing with noise3 to create a scrolling height map. And while the effect looks cool for water, it visually doesn't work at all for still mountains...
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="Heightmap" ClearColor="0 0 0 1" AmbientLightColor="0.6353 0.6353 0.6353 1" FrameRateStyle="1" ScreenMode="0" CameraPosition="0 100 120" CameraRotation="0.1 0 0" LightPosition="0 0 0" ViewportRatio="3" CustomViewportRatio="1.6667" ClipFar="800" MouseVisible="255" FileVersion="2" AndroidPackageName="com.rado1.PhysicsDemo2">
<OnLoaded>
<ZLibrary Comment="Globals">
<Source>
<![CDATA[// VARIABLES
float TerrainGenOffset;
float Time;]]>
</Source>
</ZLibrary>
<ZExpression Comment="Init">
<Expression>
<![CDATA[// init random seed
setRandomSeed(getSystemTime());
// create terrain
Time = 0;
TerrainGenOffset = rnd()*100;
@RefreshContent(Component: TerrainMesh);]]>
</Expression>
</ZExpression>
</OnLoaded>
<OnUpdate>
<ZExpression>
<Expression>
<![CDATA[//
Time += App.DeltaTime * 0.8;
@RefreshContent(Component: TerrainMesh);]]>
</Expression>
</ZExpression>
</OnUpdate>
<OnRender>
<RenderTransformGroup Name="Ground" Scale="60 60 20" Rotate="-0.25 0 0">
<Children>
<UseMaterial Material="TerrainMaterial"/>
<RenderMesh Mesh="TerrainMesh"/>
</Children>
</RenderTransformGroup>
</OnRender>
<Lights>
<Light Position="20 50 20" Color="1 1 0 1" SpotDirection="0 -1 0" SpotCutoff="0"/>
</Lights>
<Content>
<Mesh Name="TerrainMesh">
<Producers>
<MeshBox XCount="16" YCount="16" Grid2DOnly="255"/>
<MeshExpression VertexColors="255">
<Expression>
<![CDATA[
float h = (1 - cos(v.X * 1.8)) * (noise3(v.X * 4, v.Y * 2 + Time, TerrainGenOffset) * 4.0 + 1.0);
v.Z = h;
c.R = h+0.2;
c.G = h/2;
c.B = h/2;]]>
</Expression>
</MeshExpression>
</Producers>
</Mesh>
<Material Name="TerrainMaterial" Shading="1" Color="1 1 1 0.5" SpecularColor="0 0 0 1" EmissionColor="0 0 0 1" DrawBackFace="255"/>
</Content>
</ZApplication>
I was thinking of dropping height maps one after another on the Z axis and moving their Z position for real, just like any other objects in my game. But how can I make them connect properly?
Or maybe just one height map, that scroll on Z axis, and when it reaches a certain position, I reset it's Z position and scroll the heightmap as I already do by a certain amount? That seems better...
Also, is @RefreshContent(Component: TerrainMesh); demanding?