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 / NGC and Advanced Terrain in DBP

Author
Message
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 3rd Nov 2004 11:56
This code breaks terrain up into smaller pieces to use with NGC to get around DBP's bug (limiting make mesh from object to 21844 polys ). There are bugs in the movement at the moment but bullet calcs work and you wouldn't be using the collision for the player anyway as get terrain ground height is too fast. For some reason RESP_SLIDE_NO_SLOPES, RESP_SLIDE_NO_GRAV, and RESP_SLIDE_NO_ACCEL are buggy with terrain objects. It is being investigated. I am also working on ways to speed up the checks (different ways of breaking up the terrain and deactivating and activating terrain objects) though NGC V3.01 seems to be doinga pretty good job checking a 130050 poly object (when all added together). I used the media and part of the code from the Advanced terrain demo and the 3rd person shooter NGC demo. Project file is included along with the .dba just put it in the location with the advanced terrain demo project file along with the NGCollision.dba and NGCollision.dll. Compile and run. If you read the comments throughout the code there are 3 lines which will save the collision objects created to .x files. If you load these into a program such as action3d reducer you can cut the polys in half and if you make a smaller resolution heightmap and reduce the polys you can make that 130050 poly terrain be around 35000 with a little loss in accuracy for a lot of speed. I will be trying to find a way to lower the polys with code but no promises as it may not be very accurate and I may not have much time to work on it. I'll keep updates here when I get them. Code that does the breaking up is in the source box to the right.

Attachments

Login to view attachments
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 3rd Nov 2004 20:04
Good work Haven't looked at the code yet, but sounds promising.

I've been thinking about this too, but haven't done anything about it yet.

I wondered about creating a hidden, simplified terrain for the collision. I don't have the technical know-how to acheive this, but I'm sure it's possible. You could potentially detect plains within the terrain, and eliminate intermediate nodes. For example, any line of points where the angles are constant can be reduced to just the first and last point.

I'll report back when I've had a play with your source.

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 3rd Nov 2004 22:00
Yeah right now I just did a simple rush job to get it working. I am going to get further into it soon I hope. NGC is also going to be looking into this when they get the new system ironed out.

Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 8th Nov 2004 08:15
Played with this a bit more. Basically just made it update the "bullet" once everytime you pressed the spacekey() and changed the player collision with the terrain over to get terrain ground height to increase FPS. New code in the download box in the right.

Attachments

Login to view attachments
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 15th Nov 2004 14:42 Edited at: 27th Nov 2004 00:40
New update. Didn't have as much time as I would wanted to work on this lately (or today) but I have made some changes. I changed the include file for NGC to handle "static meshes". NGC saves its own version of each object. So objects that are hidden for collision use and are never altered (rotate,reposition,scale) once entered into the collision system can safely be deleted to save memory. When you call CollisionTypePRO( object, TYPE, static_mesh_status_flag ) I added an extra flag at the end. A 1 here will delete the object once entered into the collision system a 0 will act like normal objects.
I also changed the collision objects for the terrain to fvf 2 format to save memory. This saves 20 bytes of memory per vertex entered into the collision system over the fvf 274 (default) format. This along with the deleting static meshes saves 52 bytes of memory per vertex in static meshes. In the terrain example thats about 20287800 bytes total. 156 bytes per polygon. I also enclosed a complete NGC 3.01 keywords file with the changes and some commands that were left out of the version they give you (the replacement commands). Will be working on this some more as time permits.

[edit] Forgot to say just put this in the same loaction as the advanced terrain .dbpro example file and run. It uses the media from it. Use mouse1 to "fire" there is a delay of 150ms between firing. Thanks to VanB and Walaber for ideas. Their contributions are listed at the top in comments. Hope this is helpful to someone. Again this is being used for bullet calculations. The get terrain ground height works way faster for slow moving objects (like players). Code files are in the download button to the right.

Attachments

Login to view attachments
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 29th Nov 2004 16:51
Here is the latest update. Nothing fancy just modified it a bit to send all of the data to 1 index instead of breaking it up and modified the NGC include file to allow static meshes from objects or memblocks and it will delete the memblock/object once entered into memory to save memory. The load time is longer than I would like but it has something to do with NGC setting up the object. If you rem out the line setting it up as a collision type it loads straight away. This new modification has better performance though went from going from 97 fps to 40 with the old code to about 97 to 67 with just one index used in the new code. Still sparky's free collision dll is way faster with only dropping 1 to 2 fps with the same check. And his load time is way faster. I'll keep at it when i get time.

Attachments

Login to view attachments
FXTC
20
Years of Service
User Offline
Joined: 3rd Jul 2004
Location: CzechRepublic
Posted: 3rd Jan 2005 23:45
good work

AMD 2,4 512MB RAM,2x200GB hdd,GforceFX5700GT128MB
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 4th Jan 2005 20:27
Thx.

Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 4th Apr 2005 14:29 Edited at: 24th Jul 2005 19:36
With U5.8 this part of the code is no longer needed:



And can be replaced with this:



As make mesh from object now supports more than 65535 verts

[edit] Converted code over to NGC v2.03

http://mapmasterz.com/lit/ngc203_with_advanced_terrain.zip

Login to post a reply

Server time is: 2025-05-19 12:59:39
Your offset time is: 2025-05-19 12:59:39