Game Development Community

Spherical Body of Water?

by Alan Neads · in Torque 3D Professional · 04/24/2012 (5:47 pm) · 6 replies

How would one go about implementing a spherical body of water? Such as one for a planet. Sorry if this is pretty basic, but I've never really found the documentation for Torque that handy... :s.

About the author

I live and breathe coding

Recent Threads


#1
04/24/2012 (8:59 pm)
Do you need the planet just look like it's a water world from afar, or do you mean a physical ball of water, like a waterblock? For the former you need only use textures for the water. As for the latter I'm afraid I have no idea. But it sounds a bit hopeful.
#2
04/24/2012 (9:02 pm)
I was thinking I could use a sphere model and just apply animated textures to it, but if there are other ways to do it, I'm all ears.
#3
04/25/2012 (4:52 pm)
Nah that's probably going to be fine. Don't forget a cloud layer, though. Also, you won't need to animate it. Does the water look animated when you fly over it in a plane?
#4
04/25/2012 (5:09 pm)
If all you need is the appearance of a spherical body of water, then a spherical model with some animated materials should be fine... then use various 'shells' on top of that for landmasses and/or clouds.

If you needed to actually interact with the water (swimming) you could approximate the effects of buoyancy and pressure through the use of physical zones -- there's a Resource by Orion Elenzil to add vorticity and radial forces to p-zones.

Bill Vee discusses his attempts to create spherical terrains in TGEa and his progression of those techniques to create spherical water objects in his blogs. Might be worth a read for some ideas.
#5
04/26/2012 (9:36 am)
The things Bill Vee was doing is very similar to what I want to do. If anyone knows of resources to allow terrain mapping to cylinders or even 6 sides cubes that look spherical, I would be greatly thankful.

@Micheal Thanks for that info :).

@Dan Yeah, unless I'm able to actually find a possible way to create the water like that. If I could get Bill Vee's source I may be able to port from TGEA to T3D.

#6
04/26/2012 (11:11 am)
This blog has a convenient cube-to-sphere mapping that provides minimal distortion. The coordinates *must* be between -1.0 to 1.0 for this particular mapping to work.

I've tested a hack that deforms the terrain vertices using that mapping and it works out.

Make sure you add the height after doing the conversion though (so zSphere = zMapped + height) where zMapped is the z coordinate that comes out after the conversion from the mapping. You can set the z coordinate to 1.0 before doing the mapping since you're adding the height anyway.

It's a bit tricky to get it working right from what I've found. You may have to play with it a bunch to get it to do what you want.

For the water, you *may* be able to modify WaterPlane to use this sort of mapping so that you get an "infinite" spherical water body. You'd probably have to play with the reflections to get them looking right and possibly the underlying code in order to make it seamless.