[C#/C++] Create water volumes by code

Hello everyone,

I'm a CryEngine newbie (worked with XNA/MonoGame in the past) and would appreciate some input.
For my current project I need to create water volumes via code. Is that possible?

It even seems to be impossible to me to access an existing water volume in the level to modify it by code,
as it's not an entity. How would I achieve that?
Or can I even "spawn" custom volumes (with a custom EntityComponent maybe)?

In a perfect scenario I'd have a class/entity which has the following properties:
- a few Vector3's which define a polygon/shape which is the surface
- material used
- flow direction (or flow map)
and I just need to spawn few of these (I don't need that entity in the sandbox btw).

Do I need to create everything from scratch or is it possible to create water volumes via the API?

Thanks in advance
Last edited by LInsoDeTeh on Mon May 04, 2020 3:43 pm, edited 1 time in total.

Re: [C#] Create water volumes by code

Nobody able to give me a hint?

I am not looking for complete solutions, just a hint how to do it.
Can it be done with C++? If so, how?

All I need is an option to create a water volume from an array of Vector3 programmatically.

I've been researching on this for a few weeks now without a result.
Any help appreciated. Thank you :-)

Re: [C#/C++] Create water volumes by code

Unfortunately this is not possible in C#.

AFAIK you need to generate your own render object for Water Volumes without using entities.
If you can use C++, you may want to look at how Sandbox creates the Water Volumes if a water volume is indeed what you want to achieve.
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Re: [C#/C++] Create water volumes by code

Thank you very much for the hint!
Finally got it done as needed :-)

Actually this is all the code needed, in case anyone wants to do it, too
(plain commands - did not encapsulate in classes for my needs yet):

Code: Select all

const std::vector<Vec3> vertices{ { 200, 200, 20 }, { 300, 200, 20 }, { 300, 300, 20 }, { 200, 300, 20 } }; IMaterial* material = gEnv->p3DEngine->GetMaterialManager()->FindMaterial("materials/water/watervolumes/rapids"); Plane fogPlane = Plane(Vec3(0, 0, 1), vertices[0]); IWaterVolumeRenderNode* waterRenderNode = static_cast<IWaterVolumeRenderNode*>(gEnv->p3DEngine->CreateRenderNode(eERType_WaterVolume)); waterRenderNode->SetVolumeDepth(10.0); waterRenderNode->SetStreamSpeed(1.0); waterRenderNode->SetPhysParams(1000, 1000); waterRenderNode->SetFogDensity(0.5); waterRenderNode->SetFogColor({ 0.2, 0.3, 0.3 }); waterRenderNode->SetFogColorAffectedBySun(true); waterRenderNode->SetFogShadowing(0.5); waterRenderNode->SetCapFogAtVolumeDepth(false); waterRenderNode->SetCaustics(true); waterRenderNode->SetCausticIntensity(1.0); waterRenderNode->SetCausticTiling(1.0); waterRenderNode->SetCausticHeight(0.5); waterRenderNode->CreateArea(99, &vertices[0], vertices.size(), Vec2(1, 1), fogPlane, true); waterRenderNode->Physicalize(); waterRenderNode->SetMaterial(material);
Thanks again and cheers!

Re: [C#/C++] Create water volumes by code

I know this is not the Showcase section of the board and I'll definitely showcase my project when it's more advanced, but I wanted to share why I need custom water volumes (including shaders, flow directions, fog and physics) such as custom trees (affected by wind, etc.):

I am working on a SpeedBoat racing game with a track editor. Players can create their own tracks from a set of blocks (like TrackMania), so I can't create the water volumes in the Sandbox, as the tracks are not levels in CryEngine terminology.
But I wanted to use as much of the physics and rendering capabilities of CryEngine as possible, so I'll only model the static parts of the track-block and generate trees and water volumes by code - because it's already there.

Here are two pictures of an early prototype version (only two block types - one straight and one corner - with very abstract testing shapes), so you can see how I can combine entities and water/tree render nodes to form a physically working track for my SpeedBoats. Nothing of this has been placed in the Sandbox, it's all generated by code.
More in the Showcase, when I have more stuff to show.

Image Image

Re: [C#/C++] Create water volumes by code

Glad you managed to find a solution!
I am very interested to see how this project evolves, please keep us up to date :).

If you have plans to release this game, we highly recommend registering your game with us - this way we may be able to give advice or even a little marketing support when the time comes if you allow it ;).
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Who is online

Users browsing this forum: No registered users and 1 guest