• WaterComponent (Components\WaterComponent.cs) 
    • In SampleScene.cs, in the LoadWater() function you’ll find where we load the water for the sample scene.
    • Just like any other entity, we first create the entity, and give it a name.
    • For the sample scene we simply create a water plane that is the same size as the map. So we send a message (MsgGetTerrainProperties) to the terrain so we can determine the map dimensions. We pass in the length and width of the water plane into the WaterComponent constructor.
      WaterComponent waterComp = new WaterComponent(newEntity, size, size, "Material/Water");

      The first parameter of any component is the entity it is attached to. The next two parameters are the width and length of the water plane, in this case we have a square map, so length and width are the same. Finally, we pass a material to the water.
    • If you wanted to load the water dynamically and wanted the tide movement like you see in the sample you would also have to give the water a ConstantMovementComponent. This component allows for wave like position changes for any Entity. In this case, we update the water’s position to simulate a tide. This component is simple enough that is isn’t really worth going over in this tutorial. Basically this component listens for the MsgSetConstantMovement message, which lets you give parameters for how this entity will move. Set your MovementVector parameter to (0, 1, 0), your Frequency parameter to 20.0f, and your Amplitude parameter to 5.0f.
    • To see how the tidal movement is done through a component definition XML file open up 'Content/Entities/ComponentDefinitions/ConstantMovement/WaterTideMovement.xml'

Last edited Jan 5, 2012 at 4:42 AM by LordIkon, version 1

Comments

No comments yet.