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] Easy 3D Water With Waves Functions (Uses VertexData)

Author
Message
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 27th Aug 2010 17:25 Edited at: 27th Aug 2010 17:42
These functions allow you to easily create water with simple waves controlled by the SIN() and VertexData commands in your game. They require IanM's Matrix1 Plugins (specifically plugin #18). You can create as many water objects as you want.

Uncapped I get around 338FPS at 64 detail and 1680x1050x32 resolution.

Here are the functions:


Here is how to use them:
Step 1: Copy and paste the functions above into your code after your main loop.

Step 2: Whenever you want to make the water object, call the VDW_MakeWater( Object Number, XSize, ZSize, Detail ) function. This function will return a value, which you should store in a variable for later (see the examples if this is confusing). You can treat this object like any other object, which means you can texture it however you want.

Step 3: In your main loop, to make the water look all wavy you need to call the VDW_UpdateWater( Object Number, Wave Speed, Wave Height, Wave Count, Vertex Count ) function. For the vertex count parameter, just write the variable that you set in Step 2.

That's it! You're ready to have wavy water in your game .

*****************************
Each Function Explained:
*****************************

VDW_Setup()
***Sets up the system and creates the required global variables/arrays.

Vertex Count (Return Value)=VDW_MakeWater( Object Number, XSize, ZSize, Detail )
***Creats a water object.
*Vertex Count- This value is returned by the function and it says how many verticies the object has. Store it in a variable for the update function.
-Object Number- The object number that you want the water object to use.
-XSize- The size of your water object along the X AXIS.
-ZSize- The size of your water object along the Z AXIS.
-Detail- How detailed the water object is. (Controls how many rows/columns of verticies it has). Lower detail means better performance while higher detail means smoother water. 32-64 are decent numbers for this, but play around with it!

VDW_UpdateWater( Object Number, Wave Speed, Wave Height, Wave Count, Vertex Count )
***Updates a water object.
-Object Number- The object number that you want the water object to use.
-Wave Speed- The speed at which the waves move through the water. This value is specified in degrees so it is independent of the object's size.
-Wave Height- The height of the waves. The top of a wave will be at this height and the bottom of the wave will be at negative this height.
-Wave Count- The number of waves in the water. Waves are evenly spaced.
-Vertex Count

VDW_NoSinUpdateWater( Object Number, Wave Speed, Wave Height, Wave Count, Vertex Count )
***Same as the VDW_UpdateWater command only it uses a Sin array instead of the Sin() command.

VDW_SetWaterWaveOffset( Offset )
***[This function is not required to make the system work.] Changes the offset of the waves. Use this to manually control the speed of the water waves. Any VDW_UpdateWater() functions called after this will use this value. To make sure no Wave Speed is added to this number when setting it manually, set the Wave Speed to 0 in your VDW_UpateWater() functions.
-Offset- The angle offset (0-360). The faster you increase this value, the faster the waves will scroll.

Examples:
Main Example:


Simplest Example:



Feel free to expand on them if you like, the concept is actually quite simple


Guns, cinematics, stealth, items and more!
Stormwire
13
Years of Service
User Offline
Joined: 3rd Sep 2010
Location:
Posted: 25th Nov 2010 21:11
Great share! Thanks. Gonna mess around with this for the rest of the night
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 27th Nov 2010 18:14
Seems nice, could you upload a video??

Srry about my english im from sweeden
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 4th Dec 2010 01:14
@Stormwire: Thanks, I'm glad you enjoyed it

@The Zoq2: I might... you don't need any media to run it though all you have to do is copy/paste it into DBP...


Guns, cinematics, stealth, items and more!
GreenDixy
15
Years of Service
User Offline
Joined: 24th Jul 2008
Location: Toronto
Posted: 9th Jan 2011 08:46 Edited at: 9th Jan 2011 08:48
hey i was just trying out your code and when i run it i get this error



this is the line it is giving the error



i know it is probably something simple but i cannot figure it out

thanks

edit nvm forgot to reinstall Matrix1 when i formated computer sorry about the post

======================================

GreenDixy Productions http://GreenDixy.Com
gwheycs62egydws
14
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 13th Jan 2011 11:57
hi

ya the same problem came up for me

it seems to want anther set

Compilation Failed. Parameter for 'MAKE OBJECT PLANE' do not match 'Object Number, Width, Height' at line 102.

If a thought is Just a thought ~ so whats the main thought ?
SH4773R
14
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 14th Jan 2011 04:14
works 4 me
gwheycs62egydws
14
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 14th Jan 2011 04:45
umm what version of DBP are you running ?

I've got 7.5 well 1.075

If a thought is Just a thought ~ so whats the main thought ?
gwheycs62egydws
14
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 14th Jan 2011 04:56 Edited at: 14th Jan 2011 04:59
umm according to the command there should be 4 peaces of data

but it has 6 and the word "Detail" 2 times

and what is the ,274 number for ?

this line seemed to work

line 53
make object plane obj,XSize#,ZSize#,Detail

give or DBP Crashes on me for anther reason not related

If a thought is Just a thought ~ so whats the main thought ?
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 17th Jan 2011 04:27
Resourceful -
Quote: "They require IanM's Matrix1 Plugins (specifically plugin #18)."
gwheycs62egydws
14
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 17th Jan 2011 04:35
humm that would explain that ;oP

If a thought is Just a thought ~ so whats the main thought ?
gwheycs62egydws
14
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 19th Mar 2011 05:24
some of the Matrix1 Plug-in's majorly conflict with other additions

and in some case since DBP has been expanded
on it's own are redundant

I had a bug with the Bluegui but it seems a word change
fixed the problem and all the examples work

If a thought is Just a thought ~ so whats the main thought ?
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 22nd Mar 2011 01:45
I get "can't locate MSVC71 .dll" anybody know what dll that is?
renny

Life is not fair, so deal with it.
http://www.gusroundtable.com/
gwheycs62egydws
14
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 22nd Mar 2011 09:57
I did a full system search on my hard drive and it was not found ;oP

I know I have seen it and had it as part of all the code I have
collected

If a thought is Just a thought ~ so whats the main thought ?
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 22nd Mar 2011 21:40
I got it to work, if anyone have thos problem go here

http://www.dll-files.com/dllindex/dll-files.shtml?msvcp71

renny

Life is not fair, so deal with it.
http://www.gusroundtable.com/

Login to post a reply

Server time is: 2024-04-23 12:51:10
Your offset time is: 2024-04-23 12:51:10