Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - [Matrix1] Object Terrains With Meta-data Tiles

Author
Message
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th May 2013 05:17 Edited at: 23rd Jun 2013 20:34
---- Requires Matrix1
---- Uses VertexData, Memblock and Vector3 Commands

Known issue: Some PCs might display nothing on the screen at first; just move forward, for some reason DBP's culling system thinks the terrain is not in the screen.

This snippet features a surface object I am using in my game. Here it is being used as a terrain which has event handling and shaders in mind. The terrain is broken down into a series of limbs and has meta-data such as walking speed and item drops for tiles in the terrain.

Rather than being a huge single limb in-explicitly described object, the surface is defined as an array of limbs that can be treated individually, given seperate shaders and properties. You can also apply a single shader to the whole object and supply separate textures for each tile.

The surface can be used as water by animating the vertices in the loop. The smoothness of the generated mesh can be improved by increasing the Quality variable, increasing the size of the height map and making use of Vector3 interpolation commands or vertex shaders. The tiles are not simply single polygons, but sub-terrains, so realism can be simulated effectively.

To create LOD, create two or more surfaces at different levels of detail and either convert limbs to objects, then use the Add Lod To Object command; or you can keep the limbs intact and manually fade transition the limbs nearest to high quality, and the limbs far away in low quality.

The example features a simple game of search and find. There are some hidden objects located in the map. The walking movement demonstrates variable walk speeds and object intersection. Each tile could also implement footfall sounds. Crouch is activated by pressing spacebar.

It would be a good idea to cook the mesh using a PhysX plugin to perform hardware accelerated collision; creating a low poly surface to act as a hidden collision object.

Post up any comments or suggestions.






MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 27th May 2013 08:33
Well done! I would think this merited some sort of DBPro Master badge or something!

Just saying

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 29th May 2013 14:12
Lol, thanks; I hope people make use of it.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Jun 2013 13:02 Edited at: 14th Jun 2013 13:09
There seems to be a minor camera positioning/culling issue. When I first tried it all I could see was this:



I then tried again and after moving the camera a bit the terrain was suddenly visible. Haven't found anything yet. How do we "find" objects? Do we have to just be able to see them or do we click on them or what? [I know I could read through the code but ... ]

Edit After a bit of experimenting the culling problem seems to be an initialisation problem - as soon as I move the camera back the terrain appears but not if I only move forward or turn the camera (which is probably what I did the first time).

Attachments

Login to view attachments
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 14th Jun 2013 13:53 Edited at: 25th Jun 2013 19:22
I have seen this problem once before; I assumed because the object is so huge; the culling system appears to hide the object assuming that it is not on screen.

It will be a while before I can continue with this task. When I get round to using this technique I will try to implement some kind of a rule which prevents the object from being hidden automatically.

Note to self: Try CALCULATE OBJECT BOUNDS

gwheycs62egydws
14
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 19th Aug 2013 23:28
@Chris Tate

impressive ;o)

it seems with any idea there are odds and ends
we did not think would happen ;oP

it's just the nature of programing a new thought

to move side ways - is to move forward
Since a Strait line gets thin fast
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Aug 2013 21:05
Thanks. I've not gotten round to making proper use of this yet, but when I do I will post up the improved code. Unless someone doesn't beat me to it.

Login to post a reply

Server time is: 2024-03-29 15:27:18
Your offset time is: 2024-03-29 15:27:18