Daraan on 2/8/2013 at 15:31
###########
NEW!!!: (
http://www.ttlg.com/forums/showthread.php?t=142103&p=2319620&viewfull=0#post2319620) GotTo Post New Ultimate Edition v3.11
#############
Old Stuff:
This is also a tutorial I worked on four months ago but didn't published it as well.
In this tutorial I want to explain to you how you can create an water object with animated surface textures including flow effect.
For those who ask themselves why should I use an object based water. The answer is simple because it's an object and so you can move it, attach other object and and and.
For those who think isn't that old stuff? I ask back is it really?
Sure it's possible to have an animated object and it's possible to have a flow effect using conveyors but can you have both effects together? Conveyors with animated textures is sadly not possible or is it?
Well yes it is and I explain how you can do that :D (or is there maybe another way?)
So in the end we will have
an object which looks like brush water with flow effect.Furthermore I explain how you can apply velocity to the player while hes in the water and how you basically build a movable water surface.
To achieve this we make use of the render pass feature of NewDark via using .mtl files.
In a smaller tutorial I explained how to make animated replacement textures. Check it out here: (
http://www.ttlg.com/forums/showthread.php?t=142102) Link
How to create an animated and flowing Water ObjectFirst if you just want a static none flowing water. You should stop reading here and use the search function because that is old stuff;)
--Table of content--
0.) Introduction
1.) How does it work
2.) Preparations
3.) Version A - Copy&Paste the conveyor method
4.) Version B - Water on custom objects
5.) Make it better & Some notes
-Possible Problems
-NVFakeWater(+bug description)
-Apply velocity to player
-How to rise water + fixing problems with shallow water (very helpful, read it)
6.) Demo
7.) More brush features. [Not finished yet]
________________________
0.) IntroductionThis method works with the render pass feature of NewDark. It is very powerful and you can create various effects with it. As I wrote above I made this tutorial 4 months ago and I can't remember everything but I know I wrote everything down I found out, thats why this tutorial is a bit longer than necessary.
My goal is it to create an object water which comes as close as possible as brush water the NVFakeWater script (included in NVScript.osm) is a big help for it. Thanks to NamelessVoice for creating it (even if it has an annoying but - which I will explain later and tell you a work around.) I explained the basics on how to create simple objects but as I said my goal is it to make as realistic (brush like) as possible means water stims, velocity to player and objects and points I have forgotten at the moment. Until know I didn't succeed in all points but for example add velocity to the player while hes in the water is easily doable.
Note: Nearly everything below this line is 4 months old and I just checked roughly thought it again. So for those who check it please tell me when you find something that is different to understand or mistakes.
There are 2 methods to create object based water (of course both can be used).
Version A - Bitmap&Conveyor Version:
A flat surface which is very easy to customize
Advantages:
+Easy to use
+No size restrictions
Disadvantages:
-Flat
-No different waterout texture
Version B - Object Version:
Animated water flowing on other objects - Includes animated water as replacement texture.
Advantages:
+ Complex Shapes
+ WaterOut Texture
- Animated Replacement Textures
Disadvantages:
- restricted to object size
- Needs more textures & .mtl files
I will also explain to you how this water can behave nearly like real water: You can swim, drown and get moved. Check 5) for these Points
________________________
1.) How does it work?The basic principle behind this "NewWater" is the use of material(.mtl) files and their amazing render pass options. (Oh praised be the builder of NewDark).
We will use conveyors(which can't handle animations itself) and a texture which will animated via the .mtl file.
________________________
2.) Preparations2.0 Maybe get some nice water textures first?
I for example at the moment I use the water vurt made:
Get it here: (
http://www.ttlg.com/forums/showthread.php?t=140160)
--------
2.1 It's very important that we
don't use terrain textures in \fam so copy every water texture you want to use - you find them in: \fam\waterhw\
and paste them in another folder for example:
tex\textures
You can basically past them wherever you like but putting them in tex will keep your obj or bitmap folder less cramped.
For the following I will make an example for the blin water type saved in tex\textures you have to do the same steps for your textures respectively.
--------
2.2 Now we need for every water type a representative texture
Copy blin + blin.mtl(if you have that) and paste it into:
bitmap used for Version A
AND
obj\txt16 used for Version B
If you have no .mtl file for your texture create an empty text document and rename it to blin.mtl (or in general YourFirstTexture.mtl)
If you use Version B (custom models or replacement texture) and you want different to use different flow speeds you need additional blinX + blinX.mtl files
More infos look at 2.4
________________________
2.3 The material file Version A
Open one of your .mtl in bitmap file and copy the following lines into it:
force_full_alpha
render_material_only 1
render_pass {
texture *_ 0 "tex\textures\blin"
ani_rate 60
}
env_map 0.03 2 tex\envmaps\vurt_envmap1
-First you have to modify the texture line so that the ".\..\" part fit's your texture location.
-Second you have to check this *_ the star enables animation and the '_' describes your file prefix. I think it's the best if you look at these examples
texture * 3 "tex\blink00" ; will only load "blink00" "blink01" "blink02"
texture * 0 "tex\ledsequence" ; will load "ledsequence" "ledsequence1" "ledsequence2" etc.
texture *_ 0 "tex\ledsequence" ; will load "ledsequence" "ledsequence_1" "ledsequence_2" etc.
texture *_ 0 "tex\ledsequence_" ; will load "ledsequence_" "ledsequence_1" "ledsequence_2" etc.
texture *_ 3 "tex\blink00" ; will only load "blink00" "blink00_1" "blink00_2"
texture *_ 3 "tex\blink00_" ; will only load "blink00_" "blink00_1" "blink00_2"
-env_map is an environmental map used for special effects like reflections I'm using the one vurt provide. Look at 2.0
________________________
2.4 Material file Version B
Open one of your .mtl in obj\txt16 file and copy the following lines into it:
force_full_alpha
render_material_only 1
render_pass {
texture *_ 0 "tex\textures\blin_"
ani_rate 60
uv_mod scale 0.25 0.25
uv_mod scroll 0.25 0
}
env_map 0.03 2 tex\envmaps\vurt_envmap1
-If you didn't read 2.3 read it first.
-uv_mod scale : Scale x y values of your texture 0.25 is the same as brush water. Smaller numbers are the same as zoom in => bigger texture
-uv_mod scroll : This defines the flow speed of your water texture in X and Y direction. 0.25 is equivalent of a flow speed of 4 DromEdUnits (0.5=8DU)
Exactly it is defined as UVTiles per second.
NOTE:
-You need for every different flow speed or scaling another representative texture + .mtl file.
-You can also rotate your object by for example 90° to get the same change on the Y-Axis:p
_______________________
3.) Version A - Copy&Paste the conveyor methodYou already finished most of the work everything that is left is creating our object.
But maybe we should first take a look at the conveyor object from miss16 in Soulforge Cathedral to understand how conveyors work.
You will find it in the object hierarchy under physical\TerrainLike\Conveyor(-2409)\ConvTop20x4(-6429)
We will create our water object with the same setup
3.1) Create your object
-For example create a new archetype at SFX\ and name it FakeWater
-Create another (sub)archetype and name it FakeWaterConv
Do not create it under physical that could generate some problems with jumping in the water like player gets stuck or revives damage from high falls. You can try it's kinda mehh
And now double click on your archetype to edit it
________________________
3.2) Settings
First we will take a lock at the most important settings of conveyors.
3.2.1 Important Settings
1) Shape->Model Name
The standard ConvTop20x4 has convey00 as model BUT convey00 is no model it's actually a texture you can find in res\bitmap.crf
Press Add: Shape->Model Name->blin_
2) Object Size
The object size and tiling can be adjusted very easily it's done via
Renderer->Bitmap Worldscale
•x/y size: This defines how big your object is in DromEd units
For the moment set it to 8x8 or 16x16
•x/y feet per tile:
This defines the scaling of your texture the lower the value the more you zoom out => texture get smaller
The bigger the more you zoom in => bigger texture
Real brush water has approximately a x/y feet of 16 (maybe bit more)
•Check Double Side if you want to bottom side to be rendered as well, only needed if the player can get into the water.
(•Optional check Lit as well do some Objectcast Lightning test and decide if you want it or not)
3) The Flow
Ok finally make it move:
Add Physics->Model->ConveyorVelocity
Since this is just the archetype you might just leave it as 0,0,0
And adjust the flow value on your concrete objects.
Sadly just the X-Value is accepted so you have to rotate your object by 90°.
In this situation be sure to read 5) because there is a bug with the NVFakeWater and if by any chance you can't change the dimensions you can still apply material flow via another texture-> see version B.
3.2.2 Other Settings
Add
-Renderer->Transparency (alpha)
If you want that the player can swim in the water you have to change these as well:
-Physics->Model->Type: OBB
-Physics->Model->Dimensions
You have to adjust the X/Y values so that they match the x/y size from Bitmap Worldscale and the Z value how deep you want to have the water.
Important: You have to set your Offset-Z to -0.5 * Size-Z because the surface is originally the center of you object.
So maybe just use
•Offset-Z = -2
•Size: 16,16,4 for the start
-Physics->Model->Controls
Mark Location+Rotation
-Add S->Scripts: NVFakeWater
This will make your object behave very close to brush water, it makes sounds and you swim+drown :D
Check 5.) For some additional properties and for example how to fix intersections.
Have fun with it
________________________
4.) Version B - Water on custom objectsYou did almost everything in preparations especially in 2.4 Material File
When you create your objects be sure to add the same properties as mentioned above in '3.2.2 Other Settings'
With these material files you can assign your texture on objects with replacement texture and it will be animated.
________________________
5.) Make it better & Some notesa) Possibly problems:a) Intersections
Description: When you have intersections there will be a darker area or wrong render effects
Solution: Move one of the object a bit higher 0.01 and give it this property: Renderer->RenderOrder: PostOpaque 1 (first)
When you have more than 2 objects give the highest PostOpaque 1 and the ones below 2 etc.
b) Getting out
It's sometimes not so easy to climb out of the water you could either try to modify the surface high or even better place some ladders.
----
b) The NVFakeWater scriptThis is a very nice script NamelessVoice made ( if you don't have it download it here: (
http://www.ttlg.com/forums/showthread.php?t=134166) )
it provides very good sound effects:
-Footsteps when only the players feet are in water
-SplashSounds+Slowing down the player when hes walkin in water
-You can swim in the object
-DivingSounds
As might have recognized when you dive in the fake water it feels different from brush water. Thats because brush water darkens your view.
NV solved this with attaching a transparent colored sphere to the players head you will find the model in the demo it's called: InWater.bin (uses InWater.gif)
To use it create another archetype under:
Objects\SFX and name it InWater (
another name won't work!)
And add these properties:
-Shape->Model Name: InWater
-Renderer->Transparency(alpha) 0.3
-SFX->Particels
-Active (check)
-Particle Animation: launch continually
Press Ok.
About Bug in the NV ScriptSadly I experienced a bug with the NVFakeWater it can't handle object rotation. For example a 32x16 object rotated by 90° to a 16x32 will still have it's fake water features(sliming+sound) still like the original 32x16.
In these cases use big enough
square dimensions like 12x12 so that it still works correctly.
Have fun swimming :D
-----
c) The base texture
With the base texture I mean the textures you saved in your bitmap or object folder. They don't need to be the same texture as your imagies in tex\textures
they can as well be a 32x32 transparent texture. The only important thing is that theres a texture with a .mtl file. To save space it would be good idea to replace this images with something smaller.
----
d) Check the material-format.txt in the doc folder to learn more the material files and their overwhelming potential.
----
e) Applying velocity to the playerThat's still a point which is missing and it's not so easy but I will explain to you how you can get at least the player moving. In general you can apply constant speed to the player when you add to him the Physics->Model->Conveyor Velocity ability objects via: Physics\Model\Control.
I tried around applying velocity to objects as well but it's not that easy and until know I haven't found a flawless method. Maybe you can help me and try a bit around as well.
Preparations:(Be sure to have NVScript loaded)
You need a MetaProperty for every different speed (if Metas are new for you go into ObjectHirarchy and seletct ShowTree: Metaproperties at the Top)
Add to each new MetaProperty the Physics->Model->Conveyor Velocity with the values you want to have.
------
Version a - The Room method (has nothing to to with the A,B types in 1-4.)
Useful when your water is mostly immovable and for example active after you pressed a certain switch like the flood canyon in the demo. This method has a limited usage but shouldn't make any problems.
Go again in the ObjectHirarchy and select ShowTree:Rooms
-Select BaseRoom and press Add and name the NewRoom Type: FlowRooms
-Now you're asked if it should be a concrete room -if you don't know what it means press yes.
-Edit FlowRooms and add the following property:
S->Scripts: TrigRoomPlayer
-We need now one concrete room for each velocity. (Write down their numbers we need them 3 steps later)
-Now you can place the room in the world. You got the wrong or default room you can change the type easily. Press create at the bottom of your normal DromEd window and select the correct room type and press the create button on the right.
-But wait how do we add the MetaProperty to the player? For that we need 1 RequireAllTrap(RAT) and 1 Marker for every different room/velocity type.
-Select your RequireAllTraps, press Links and create a ~ControlDevice FROM your RAT TO one of your rooms
-Add the other incoming CD links to your RAT for example from the switch that opens the floodgate
-Make a CD from the RAT to the marker
-Select your marker and add the follwoing properties to it:
S->Script: NVMetaTrap
Editor->DesignNote: NVMetaTrapMeta=XXX;NVMetaTrapMetaTarget=player
For the XXX you have to write either the number of your Metaproperty like -7654 or the "name from object hierarchy" with "
That was it now the player should move on it's own when he enters the water.
___________________
Version b - The object methodUse this for raising/moving water.
-Create your FakeWaterObject
-Open Physics->Model->Attributes and mark Flags: Is EdgeTrigger
-Add S->Scripts: NVTrigOBB
NVMetaTrap
-Add Editor->DesignNote and copy these lines:
NVMetaTrapMeta="FlowMetaXXX";
NVMetaTrapTarget=player;
NVTrigOBBPlayer=1;
NVTrigOBBTDest="[me]";
NVTrigOBBTOn="PlayerSwims";
NVTrigOBBTOff="PlayerLeaves";
NVMetaTrapOn="PlayerSwims";
NVMetaTrapOff="PlayerLeaves"
For the XXX you have to write either the number of your Metaproperty like -7654 or the "name from object hierarchy" with "
NOTE: If you have intersection with more than one water object there could be problems with the InWater-Mask from the NVScript.
Solution: Make one big OBB (invisible) object which will be your water and give the others which will be your surface a dimension of 0 or remove the NVFakeWater script. To do that add S->Scripts clear the fields and check don't inherit. (Sorry after that long time I'm not quite sure what I meant with the "or remove the script part")
____________
f) How to build rising water + shallow fixWith our new water some of you maybe want to have a water which rises from shallow to a specific level under the condition that the player gets flown away when the water is rising. The problem is with our method mentioned above the player moves when just standing on shallow water.
I found various solutions how to fix shallow water but I want to present the best to be more exact I present two solutions for different situations:
When to use which:
•Option A works nearly always only condition is that if the player is in the shallow water it may not be higher than 1.5 units above the ground.(3.5 when the player is not crouching)
•Option B covers the situation of other highs when the player is inside/standing in the water only restriction is that he may not be able to leave the area until he swims.
__________________
1) Preparations:First we need a MetaProperty which enables the flow effect. I named it for example EnableFlowMetas
Add the following property to the MetaProperty:
S->Script: NVMetaTrap2
Yes NVMetaTrap2. You also have to make sure that your water objects don't have this script.
Create your switches/buttons which trigger the movement. I will explain the setup via TerPoints if the player can not see the water surface when you change it you can also move it directly via teliameds TrapMoveRelative script by defined z values.
I don't know what for idea you have in mind so maybe you have to play around with the parts I give you:
Let me know if you have another method.
__________________
Option ACreate your water objects like in the demo with these scripts
-S->Scripts: NVMetaTrap
NVTrigOBB
StdElevator
StopAtWaypoints
Be sure that NVFakeWater is placed on archetype of the object or above. Scripts will get inherited (as well as DesignNotes) so you don't have to set them again and you can delete wahts already written in it when you add a new one.
-Editor->DesignNote:
NVMetaTrapMeta="FlowMeta8X";NVMetaTrap2Meta="FlowMeta8X";NVMetaTrapTarget=player;NVMetaTrap2Target=player;NVTrigOBBPlayer=1; NVTrigOBBTDest="[me]"; NVTrigOBBTOn="PlayerSwims"; NVTrigOBBTOff="PlayerLeaves"; NVMetaTrapOff="PlayerLeaves";NVMetaTrap2Off="PlayerLeaves";NVMetaTrapOn="Null";NVMetaTrap2On="PlayerSwims";
You have to change NVMetaTrapMeta= to either the number of your Metaproperty or the "name" with ". NOTE: You have to write it TWO times.
-Be sure that your object has Physics->Misc->Moving Terrain: False
-If your water starts in a swimable high add Metaproperties->EnableFlowMeta (or the name you choose in Preperations)
__
First I will explain the easy situation with just 2 water highs and below a setup with no limitations.
Elevator Setup:
-Create 2 TerrPoints (fnord->Marker->TerrPoint(-1322) place one at the position where you want to have your shallow water surface and the other at the highest position you want to have.
-Link them together with TPath so that each TerrPoint has a TPath and a ~TPath link to the other - Remember to define the speed in the Links window. Check Path Limit.
-Link (FROM) your water object TO the TerrPoint you want to start with TPathInit (if your water is not at the correct position execute the command reset_moving_terrain
-Create two buttons and ControlDevice(CD) link each one to one of the TerrPoints.
Getting serious: The Markers/Traps
-Create 2 Markers - Best place them asside of the buttons.
-Give both S->Script: NVMetaTrap
-Make a CD link from your buttons to one of the markers
-Link each marker with a CD flavour to your water object
-Now add Editor->DesignNote:
For the raising Marker you need this line:
NVMetaTrapMeta="EnableFlowMetas";NVMetaTrapTarget="&ControlDevice";
For the lowering Marker this one:
NVMetaTrapMeta="EnableFlowMetas";NVMetaTrapTarget="&ControlDevice";NVMetaTrapOff="TurnOn";NVMetaTrapOn="Null";
Again:
The only restriction for Version A is that if you want to raise the water while the player is INSIDE of it then the shallow water should not be higher than 1.5 units above the ground. It can be up to 3.5 above but only when the player is not crouching. I don't know how many players would try it out to crouch in the water and then press the button. I give you these two values it's your decision what to do.
____
Option BUse this when you have a shallow water surface high above 1.5 over the ground and when the player is definitely inside of the water when he triggers it and he may not be able to leave the area until he swims!
The different to version A is that we just apply the player movement automatically and not when he enters the object.
The setup is the same as in A so do this first.
Additionally do this:
-Add to the raising markers a NVMetaTrap2 script, this will enable the player movement automatically.
-Add to the DesignNote this:
-NVMetaTrap2Meta="FlowMeta8X";NVMetaTrap2OnDelay=1000;NVMetaTrap2Target=player
Set the NVMetaTrap2OnDelay (in ms) to a value so that it seems fitting that the player gets flown away, of course it depends on the raising speed of your water
___________________
6) Demo: (
https://www.dropbox.com/s/7zuvizk258djthy/FakeWater.zip) Download Link
It's a bit big because I added vurts water textures to it.
I have a new computer and have no thief installed yet so I can't do a last test if I added all models, textures so if anything is missing please write it so I can add it in the next version. I also know that this demo is not finished yet. For example I wanted to add an example of the setup I have in my map which has - if I remember right - 9! different water highs and two different flows. It used a lot of QVarTraps and stuff, basically just for simple calculations.... Gosh I want a script for that that would be much easier :D
7) Other features [Not finished yet]
Like water stims, applying velocity to objects. These points are up do some degree possible but I haven't found ways to make it work properly in all cases. One if the main problem is that as far as I know you can't get hold the entering object when a PhysEnter is triggered, or can you?
___
Thanks to vurt(textures) and NamelessVoice(NVScript)
Feel free to redistribute.
If you have any question feel free to contact me(Daraan) @ (
www.ttlg.com/forums)