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.

Program Announcements / [DBPro] TERSCULPT

Author
Message
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Apr 2008 09:52
Sorry, been busy the last week helping my brother move house. Will hopefully get a look tonight or tomorrow.


less is more, but if less is more how you keeping score?
Omega gamer 89
17
Years of Service
User Offline
Joined: 10th Sep 2007
Location: Pittsburgh, PA
Posted: 30th Apr 2008 19:28
@VAN B:
Did you get a chance to look at my file? Were you able to recreate that error message?

...but I am the ferret king!!!! BWAHAHAHAHAHAHA!!!! tremble before my ferret minions!

Soroki
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: United States
Posted: 18th May 2008 17:21
This is VERY nice Van B! : ) I've been looking for a terrain editor and I am short on money at the moment. Thanks for this!

"I can't install things to my D:\ drive. Can you help me?"
"Just delete system32.dll. It should work fine after that"
luke escude
17
Years of Service
User Offline
Joined: 9th Sep 2007
Location: Right Behind You
Posted: 20th May 2008 00:43 Edited at: 20th May 2008 00:44
Hey, Van B, I have a question. The Terrain, is it a matrix, or a series of plane objects aligned like a grid?

If it's a matrix - How do you select an individual matrix tile to raise it up, or manipulate it?

It it's a plane-grid - Same question, and how do you make it affect the tiles around the selected grid square?

Vector3 3D World Creator - By Luke Escude
http://www.lujogames.com/luke/vector3/vector3.html
Inspire
17
Years of Service
User Offline
Joined: 23rd Dec 2006
Location: Rochester, NY
Posted: 20th May 2008 02:26
I thought that it use memblocks...

luke escude
17
Years of Service
User Offline
Joined: 9th Sep 2007
Location: Right Behind You
Posted: 20th May 2008 03:27
Well, that doesn't exactly help, because I have no clue what a memblock is, nor what it does... I took a look at the code in Tersculpt, and saw that the terrain is actually a plain object consisting of many 32x32 or 16x16 subdivisions... All I don't know is, how to manipulate the vertices

Vector3 3D World Creator - By Luke Escude
http://www.lujogames.com/luke/vector3/vector3.html
Uncle Sam
19
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 20th May 2008 07:00
Van B this is so sweet! You rule!

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th May 2008 12:08
Soroki, Sam, thanks .

Luke,
There are a couple of different methods that can be used to display a Tersculpt terrain. There's a big plate shaped mesh that has LOD, this is probably best for top down engines, there is also one that uses a single object made from several 16x16 grid plains, these are repositioned and moulded in a way that allows them to conserve resources - only the limbs that need it are updated. The second method is called 'Tiled' and is better for FPS games where a long view distance is needed.
Both methods use pretty much the same system to mould to the terrain. Using the vertex adjustment system, each limb is repositioned then each vertex get's it's position set to suit a heightmap array. It's not what I would call easy, but the vertex manipulation commands are well worth learning, there's lots of tricks that can be done. The UV coordinates of each vertex are also adjusted and texturing is done through a shader, using 2 mask images which are UV mapped onto the terrain based on vertex X and Z location. The shader then uses these masks as a reference for the actual textures that are used.

I have been working on a small demo, using Kevil's fog-enabled terrain shader, and Evolved's Fresnel water shader - looks really cool but there's a couple of things I want to do to it before releasing. I also have an idea for compacted level files which I want to look into. Will hopefully get all this done by mid June.


less is more, but if less is more how you keeping score?
luke escude
17
Years of Service
User Offline
Joined: 9th Sep 2007
Location: Right Behind You
Posted: 21st May 2008 00:54
Hello! I have found the vertex manipulation commands, but have no clue where to start. I can get a count of all the vertices, but how to select an individual vertex I really don't know how to do... The vertices are loaded from a .X plain object that has subdivided 32x32 squares.

Vector3 3D World Creator - By Luke Escude
http://www.lujogames.com/luke/vector3/vector3.html
Uncle Sam
19
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 21st May 2008 06:56 Edited at: 21st May 2008 06:57
Ok, a couple little problems:

1. You can't add any new textures, so you have to replace the old ones and name them the same.
2. Somehow it looks different than the editor when you export it and load it into DBP.
3. I also sometimes get an unknown image error when exporting the AT texture.

It's still a great program and I'll definitely use it, it just has a couple small flaws.

AtomR
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 22nd May 2008 13:14 Edited at: 22nd May 2008 13:31
I really like this terrain system and i've been looking carefully at the code to learn how it does what it does and i think i've gotten most of it. One thing i need, though, is to have the textures repeat themselves a lot more often coz my camera is going to be placed very close to the ground. That is easy, i thought, but the truth is proving to be a challenge. Now that i've read your previous post, VanB, i see that maybe its because the uv texturing is handled by the shader and so its useless to change uv coords on the main dbp code.
In my mind i had 2 options on how to handle it. One is to use scale object texture to scale each of the layers of the textures. The other is to go directly to the part where the uv coords are being set on the memblock and change them directly there. I've tried both and in both cases i can't affect any of the layers individually. I can only affect layer 0 but that affects ALL the layers including layers 6 and 7 that shouldn't be affected coz they hold the information on what texture goes where X_x What should i do? should i go directly to the shader and change the tiling there? How would i do that? I haven't got a clue on how shaders work. Appreciate the help if u got it.

-Edit-

Hehe. I've managed to play around with the .fx file and it wasn't that hard. I just hadn't even bothered looking at it until u mentioned it in your post.
The default value is
float2 repeatScale = {128.0, 128.0};
So i multiplied it by 100 to see obvious results and it works.
float2 repeatScale = {128.0*100.0, 128.0*100.0};

Thx

Take care
AtomR
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd May 2008 13:29
Don't be afraid of the shader - it's quite clear when you open it up where you need to adjust the texture scales, in fact I'll dig back a bit and find Kevil's version of the shader so I can show you...

Right near the start of the .FX file, this line:

float2 repeatScale = {128.0, 128.0};

This means that the texture is repeated 128x128 times over a 512x512 terrain, or in human terms, the textures fit 4x4 tiles. So if you want the textures to be more detailed, set that to 256.0 and they'll fit 2x2 tiles instead, twice as detailed.


Sam,
I've fixed the image error in the version I'm using, which I'll release soon. The advanced terrain export will only ever look a bit like the editor. Firstly, it uses a generated texture instead of several tileable textures, so it would only look like the editor if you used the shader on the advanced terrain - I will make another example on how to do this. The other factor is that AT can't really handle massive terrains, so it is scaled down to half the resolution. I mean, if I use 512x512 when exporting the heightmap, AT can't handle it for some reason.
I plan to look into the texture swapping problem, but really this all boils down to a new file format for the terrains - will have an export/import for the existing format of course, but I will need to be able to specify what textures are used and the current file format does not support this. But, I will be adding the compression idea to the new format, so it'll mean much smaller level files, I think I can cut down on the heightmap data by around 70%, not sure about the texturing data yet.

Don't know what Sid is upto with the object placement stuff, but hopefully he could migrate it over to the new version, assuming he's still working on it.


less is more, but if less is more how you keeping score?
AtomR
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 22nd May 2008 13:51
Damn ur fast. Thx for the quick reply but as u said "don't be afraid of the shader." ^^

What made me take notice of that value was

float4 baseColour = tex2D(detailSample1, repeatScale * In.UV) * rgbaColours.r;
baseColour += tex2D(detailSample2, repeatScale * In.UV) * rgbaColours.g;
baseColour += tex2D(detailSample3, repeatScale * In.UV) * rgbaColours.b;
baseColour += tex2D(detailSample4, repeatScale * In.UV) * rgbaColoursb.r;
baseColour += tex2D(detailSample5, repeatScale * In.UV) * rgbaColoursb.g;
baseColour += tex2D(detailSample6, repeatScale * In.UV) * rgbaColoursb.b;

I saw the repeatScale and decided to look where that value came from. I've added a unique repeatscale value for each layer in the fx file. Any way that we can affect that value through darkbasic?
I want to make a level editor starting from this terrain editor and would be cool if we could change the scale of the textures directly in the editor.

Take care
AtomR
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd May 2008 14:06
That should be quite straightforward, maybe just make a unique scale value for each texture, like:

float2 repeatScaleA = {128.0, 128.0};
float2 repeatScaleB = {128.0, 128.0};
float2 repeatScaleC = {128.0, 128.0};
float2 repeatScaleD = {128.0, 128.0};
float2 repeatScaleE = {128.0, 128.0};
float2 repeatScaleF = {128.0, 128.0};

I'm not sure how to change these in DBPro, but I will look into it - I also want to do this with the fog settings, so I'll try and set this up for the update.


less is more, but if less is more how you keeping score?
AtomR
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 22nd May 2008 14:21
I've looked it up.

PERFORM CHECKLIST FOR EFFECT VALUES 10
for i = 1 to checklist quantity()
text 0,i*20,checklist string$(i)
next i

With this code you can see all the constants that can be altered in realtime with the commands

SET EFFECT CONSTANT FLOAT
SET EFFECT CONSTANT BOOLEAN
SET EFFECT CONSTANT INTEGER
SET EFFECT CONSTANT VECTOR
SET EFFECT CONSTANT MATRIX

So that makes it very easy to alter uv mapping in realtime.

Take care
AtomR
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd May 2008 14:28
Cool - this means I can easily have 1 massive base colour texture, setting the scale to 1 so that it covers the whole terrain. I might even have an option to generate this image. What I was planning is having this base layer get bluer when the corresponding height is <0, this should give a decent impression of depth when using water effects.


less is more, but if less is more how you keeping score?
AtomR
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 22nd May 2008 15:08 Edited at: 22nd May 2008 15:10
Indeed. And even have the same textures having diferent tones of color which should add and even bigger ammount of variability in the terrain (i.e, snowy grass). Will u add an extra layer for that?

I've attached the two memblock images that control where the layers show their textures. I'm confused. From your code memblock 10's RGB values control textures 1, 2 and 3. Memblock 11's RGB control textures 4,5 and 6. That much is straight forward. But memblock 10 is also the shadow map? Why is the shadow map in purple and does it still affect the textures in layers 1, 2, 3 if its on the same bitmap? sry to nag but i want my editor to make shadow map of trees and object etc so i need to know.

Take care
AtomR

Attachments

Login to view attachments
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd May 2008 15:28 Edited at: 22nd May 2008 15:30
Ahh, the shadows are set by changing the first array element of the image array. Like there's an array that is 1024x1024x7, and this is really the mask data, so 0 is the shadow control, then 1 is texture 1, 2 is texture 2 etc etc. The shadowing is actually applied to both images, as it's more like a multiplier for each colour element - I think image 2 there is very black because textures 4,5 and 6 are not used very much.

As long as you set element 0 then it should adjust the images to suit - 0 would be fully dark and 255 would be fully bright. When moulding terrain the shadow layer is updated automatically, that way it could even be used to shade objects, just by checking the corresponding array location - this could even be done on a vertex basis using vertex diffuse on static objects.

It can actually do a more detailed shadow rendering but I'm not overly happy with it, it tends to make things really dark, but that would be a good place to calculate object shadows too, perhaps with a point to point collision check. It's hard to envisage how this would all work together without having object placement in the editor as it stands.


less is more, but if less is more how you keeping score?
AtomR
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 22nd May 2008 17:19
AAAAHHHHH! OFC!!! DUH!!! The purple is the grass that is painted all over the terrain with shading applied to it X_X eheh thx

I was going to control object shading by the shadow map. based on the object's position on the map i'd check the colour of the shadow
in the bit map and apply shading accordingly. I got my work cutout for me with that array.

I intend to have object placement in my level editor so that things are all edited nice and accuratelly. And after object are placed do a shadow map. Don't ask me how. I haven't thought that far ahead yet X_x

Take care
AtomR
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd May 2008 18:09 Edited at: 22nd May 2008 18:17
Doing point to point shadow rendering is actually a lot more straightforward than I thought it would be, ages ago I did this on an advanced terrain texture, and the results are so much better than standard, unrendered terrains.

Tersculpt cheats with the shadow calculating right now, it assumes the light comes from 1 direction over the whole terrain, so it can simply check the height of 2 corresponding locations and work out shading for it.

If I was doing it properly, I'd have a sun in a skybox, then I'd step through each pixel on the mask images, like...

For z=0 to 1023
For x=0 to 1023
tx#=x*50.0
tz#=z*50.0
ty#=getheight#(tx#,tz#)
Next x
Next z

This would step through each pixel on the mask, and work out the 3D position of the terrain, in TX#, TY# and TZ#. With this, you could do a collision check between the T# position and the major light source, and if there is a collision with an object, shade that pixel, with something like...

map(x,z,0)=0

You could of course work out the distance between the collision point and the T# position and even the sun, then use this to decide how dark to shade that pixel, this could mean some very accurate shadow rendering, especially if the mask resolution was increased.


Something else I've thought about is shadow depth. It would be possible to have an extra array with the actual depth of the shadow at each pixel, right now it's only 2D because it's purely visual, but imagine if there's a deep pit in your terrain, it might be completely shaded at the bottom, but then how would you know whether or not to shade the object . By recording the shadow depth, it would be a simple check of the Y position on an object. Going back to vertex colouring, if the shadow depth was available, it could shade only the vertexes in the shade. Kinda like a proper vertex lightmap but once that can be quickly calculated.


less is more, but if less is more how you keeping score?
AtomR
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 22nd May 2008 19:37
That is how i was thinking it could be done but what i can't get my head around is how to achieve proper shading of trees with transparent textures since colision would be checked against invisible plains.

Take care
AtomR
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd May 2008 20:48
If you have DarkPhysics, the line intersect check in that can return the UV coord of the collision, which in turn could be used to check whether that part of the texture is transparent.

The other, extremely slow option is to use the camera, like position it at the sun, point it at each terrain position and move forward so the camera is close to the terrain, then check the pixel in the middle of the screen with the terrain shown and with it hidden. If the pixel from each case is the same colour, then it's a collision (so to speak). This would be incredibly slow, very accurate, but it might be the sort of thing you'd have to run overnight!.


less is more, but if less is more how you keeping score?
Uncle Sam
19
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 22nd May 2008 22:27
Ok, Thanks. Do you think it would work easier if you found a way to simply make it export to .x or something?

AtomR
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 23rd May 2008 13:23
HMMMM i guess i'll have to use that slow method since i don't have dark physics. You're very ingineous VanB.

However i'll not use a specific position for light source. I'll just decide the angle of the light then do a colision check with a far enough point relative to the vertex i'm shading. The sun is far away from earth enough that light arrives on earth in virtually paralel lines. From the same point, shadows would get distorted in the distance. See pic for what i mean.

One question. I don't have Dark Lights. Would darlights work with this shader?

Take care
AtomR

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 24th May 2008 06:32
Sparky's has ray tracing too... Should help with the shadow thing also.

Soroki
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: United States
Posted: 24th May 2008 16:17
I like the look by the screenshots but for some reason I get something weird when I try and use it. See attached screenshot.

Whenever I try and edit also, I get a large white box around the brush grid too. I am running Windows Vista 32 bit, ATI Radeon 9800, 2 GB ram. I don't know if my card and Vista are all that compatible though, my PC will crash randomly due to some graphics card "infinite loop" problem. It runs games quite well, I just don't know why it won't work with the editor.

"I can't install things to my D:\ drive. Can you help me?"
"Just delete system32.dll. It should work fine after that"

Attachments

Login to view attachments
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th May 2008 22:15
I think that must be an issue with Vista, the shader and/or your graphics card driver. I use an nVidia 7950GX2 on XP, I guess GG is still using a FX5200, it could be the shader is designed more for nVidia cards.


less is more, but if less is more how you keeping score?
Aertic
17
Years of Service
User Offline
Joined: 2nd Jul 2007
Location: United Kingdom
Posted: 25th May 2008 05:23
Wow, this is quite cool VanB, I'll be using this most of the time

The admiral
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 27th May 2008 05:24
Im wondering is there anyway I could make one vast lanscape with this and only show the closest sections? Because my world needs to be free flowing in real time and quite large yet only one map can be made with the editor at the moment and then how would i deal with the seams??

The admiral
The Wilderbeast
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location: UK
Posted: 31st May 2008 15:53
You could make a giant one in the editor (which is easy), then export the heightmap and AT Colourmap and using something like paint split it into equal segments. Then you have your giant landscape, but split into manageable chunks.

Dark Fire
16
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 25th Jul 2008 05:50
Wow, cool program. How did you paint the terrain? I was curious to try and recreate it for painting directly on an object.

Dark Fire
Gen
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 26th Jul 2008 04:55
Quote: "I think that must be an issue with Vista, the shader and/or your graphics card driver. I use an nVidia 7950GX2 on XP, I guess GG is still using a FX5200, it could be the shader is designed more for nVidia cards."


I'm running Vista and have had no problems... I'd say its more driver/hardware related

Windows Vista Ultimate SP1, AMD Phenom 9850 @ 2.8GHz, 4GB PC8500 RAM, 3x ATI Radeon HD 3870's 512 MB
Windows XP Pro SP2, AMD Athlon XP 3200+, 1GB Dual Channel PC3200 RAM, ATI Radeon X1650 Pro 512 MB
CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 20th Sep 2008 21:01
I'm gonna have some fun with this thing.....

Dark Fire
16
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 12th Oct 2008 06:44 Edited at: 12th Oct 2008 22:21
I am very interested on learning how you created several concepts in your program. I would like to ask for your permission to add them in my project and if you would help be a bit with learning how they work.

If you could help it would be greatly appriciated.

The project can be found Here.

Looking though the source I couldn't find the answer to the following questions.

I have some questions about how you created tersculpt:
- How did you create a white circle on the objects surface?
- Did you use a function to determine the bounds that the vertexs? If so can you post the code?
- How did you smooth out an area in the white circle?

Note: I am developing this project in a modular format.

Posting some code to reference to would be very helpful.

Thanks for any help!

Dark Fire
CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 12th Oct 2008 17:25
The Source code's in the download.....

Dark Fire
16
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 12th Oct 2008 20:58 Edited at: 12th Oct 2008 21:03
@coffeegrunt - I know. It is just very hard for me to understand some things in the code.

Dark Fire
Sid Sinister
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 12th Oct 2008 21:10
I don't think Van looks in here very often. You might have to email him to get him to respond.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Oct 2008 21:16
Hmmm.... I'm going out on a limb here - but I think coffeegrunt might be thinking what I am... let me explain (CoffeeGrunt please corerct me where I'm wrong in my assumptions while I took the liberty to form this response to "Dark Fire")

First off DarkFire - I'm personally glad you are undergoing this project! Good Stuff.

Second - although "Technically" it might not be necessary - sometimes careful phrasing can make the difference between honey and vinegar in reference to "You Can Get More Bees with Honey than with vinegar."

I'm referring to:
Quote: "just like yours except it will have more features and will be developed in a more modular form"


Because your whole message MIGHT be construed in various ways, one of which comes to mind - and even this could be construed as its written non-modularly or a double whammy that the person's code is inept - "Hey - I'm making a better editor than yours, I have your source code, but I can't understand it (because its not modular and/or inept)"

I might of asked this way: "Hey - This editor is awesome! I'm using it for ideas for an editor I'm making! I'm having trouble understanding how you did this and that. Could you tell me any clues about this, or where to look in your code specifically? I've tried and I can't figure it out."

I think we all know the meaning of your question and it certainly isn't outright rude or laced with any malice whatsoever! Perhaps the author is busy and hasn't got back to you, perhaps others who know the code haven't chimed in because they are busy also. Perhaps they all are on this message's thread's "email alert" and elected not to answer. Makes ya wonder...

By being SUPER careful and nice when asking for responses - you can then think without care about unanswered posts:

They ARE to busy or they aren't helpful

Beats "They read my message, clicked delete, and went on with their day"


--Jason

Dark Fire
16
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 12th Oct 2008 22:14 Edited at: 12th Oct 2008 22:26
@jason p sage - Changed. Didn't mean to make it seem like I was stating something a negitive way.

What I actually intended to say:
- I have been trying to create a program like tersculpt
- I haven't been successful.
- Object minipulation has always been hard.
- You have shown a working program.
- I would like to learn from it
- It is hard for me to learn from code unless everything is written out like "ObjectPositionX#" instead of "OX#" and I would like some general explanation to how the code works. It isn't easy for someone to follow someone elses coding style. That is why we ask questions.
- I meant by making my program modular. I meant that I wanted to make my code more modular and was wondering if Van B could post some code in that format or help me create it for that format.
- Help would be very much appreciated.

I would also like to state that I am sorry that it may have been taken a different way and I had to make what I acctually meant extremely clear.

I changed the post to make it sound better.

@ Van B - Let me know if you can help me a bit. I have spend some great amount of time trying to come up with a relativly close examples showing some of the concepts that I mentioned in the above post.

Again here is the questions I asked:
Quote: "I have some questions about how you created tersculpt:
- How did you create a white circle on the objects surface?
- Did you use a function to determine the bounds that the vertexs? If so can you post the code?
- How did you smooth out an area in the white circle?"


If it helps anyone who contributed significantly to my project gets it for free when I am finished. You will also be included in the credits. I haven't mentioned this yet because my project wouldn't be done for a while. It still is a WIP.

Sorry again,

Dark Fire
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Oct 2008 04:43 Edited at: 13th Oct 2008 04:44
Quote: "Didn't mean to make it seem like I was stating something a negitive way.
"
I know

Quote: "I have been trying to create a program like tersculpt"
Haven't we all ? LOL! (Actually I just made a loader form GPS data based on stuff I learned from VisiGoth. I never got to an actual terrain editor myself ... but many have taken this on

Quote: "I haven't been successful"
don't give up! If I were you, based on what you wrote - I'd use VAN's code to learn from and try making one tiny "piece" at a time versus trying to approach it from the bull-in-china shop approach. this isn't exactly a small undertaking!


Quote: " Object manipulation has always been hard"
Like moving stuff around? changing the shape of a loaded object or something like that? Or generally speaking? If any/all of these - you're not alone I personally have HOURS upon HOURS of trial and error... and I ALMOST ALWAYS have a bunch of tiny test programs confirming "questions" I have, that once I understand , I pull the code into the big project

Quote: "You [Van B] have shown a working program"
Yeah he did and a good one too!

Quote: "I would like to learn from it"
Awesome. He'll be happy to read that I'm sure... I'd personally break it - fix - it (just commenting out lines of code - to see what the stuff does, what impact removing something has, removing a whole chunk of code - etc... Literally see what is dependant on what.. experiment, break it into smaller pieces... add tons of comments to it as you go to document what you figure out as you figure it out.

Quote: "It is hard for me to learn from code unless everything is written out like "ObjectPositionX#" instead of "OX#" and I would like some general explanation to how the code works."
That's understandable. Perhaps you can try to firgure out what variables do and do global search-n-replace to make it more readable? As for general explaination of this program, have you read this whole thread though? I recall Van B discussing how he made the "conforming" cursor among other things. Once you know the "theory", reading the code gets a little bit easier.

Quote: "That is why we ask questions"
LOL

Quote: "I meant by making my program modular. I meant that I wanted to make my code more modular..."
Good Plan!

Quote: "... and was wondering if Van B could post some code in that format or help me create it for that format"
He just might! Maybe he'll take some time out and give ya hand. Van B is really cool, no question!

Quote: "Help would be very much appreciated"
Of course

Quote: "I would also like to state that I am sorry that it may have been taken a different way and I had to make what I acctually meant extremely clear."
Don't worry at all bro - I was just "learning ya" .. at my job I have to deal with clients/customers quite a bit and there is a bigger consequence at work than a game making forum for sure - and I have to really careful - and I was just sharing my first knee-jerk thought after reading your message - and I ran it by my wife to to see if I was just reading it badly. You didn't do anything "wrong" - I'm just trying put on the table that phrasing is important.

Quote: "I changed the post to make it sound better."
LOL... If you want I'll change all mine and clean all this stuff out so that its "gone" - I WOULD HAVE emailed you then post - Sorry about that - I have folly too - but I didn't see another way to contact you (No IM or Email link).

Quote: "It still is a WIP"


Best of luck! Don't give up!

--Jason

Dark Fire
16
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 13th Oct 2008 04:59 Edited at: 13th Oct 2008 05:04
@jason p sage - I added aim for contacting me. I have a small network on friends on the forums. (Non of them are avaliable anymore) If you would like to talk it would be fun! BTW, do you have an aim account? I tried using your yahoo account name and you seem to be offline.

Quote: "at my job I have to deal with clients/customers quite a bit and there is a bigger consequence at work than a game making forum for sure "


Wait..you have a job doing this???? I would love to do that! That is one thing that is hard to find a good job with game development.

RU actually trying to re-create something like I am?

Anyways, I am trying to get this project done as quick as possible. I have about a year put into this. Most things are in secret.

We are here to learn. I am still a bit of a newbie, but I have a ton of programming experience.

Ok..Enough of that shouldn't post any general stuff on a thread with a topic. lol


@Van B - I would just like to ask if you can give me some idea how to create several of the concepts I have mentioned.

Dark Fire
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Oct 2008 13:47 Edited at: 13th Oct 2008 13:53
Hiys guys, sorry I missed these posts. My code is a mess at the best of times, it is a bit more straightforward though once you know what it's trying to do .

The heightmap is stored in an array called ter(), and the getheight#(x,y) function will return the height at a given 2D location. The terrain is vertex adjusted depending on the heights returned from their X and Z location, so it can use any mesh as a terrain, designed for using LOD meshes, although I find just having lots of patches as limbs on a main terrain object works best.

The cursor is really just a terrain object, it gets textured with a grid and circle, and it's vertex's get molded onto the terrain. Using pick object on the terrain object allows you to work out the 3D location that the mouse pointer is on, like...

pick=PICK OBJECT(mx,my,100,100)
if pick>0
curx#=camera position x()+get pick vector x()
curz#=camera position z()+get pick vector z()
update_cursor(curx#,curz#)
if cammode=0 then gosub RTS_cam
endif
if mb=1 then gosub tool

This would check MX and MY (the mouse pointer position) against object 100 (the terrain object), and then store the 2D location in curx# and cury# (the cursor). The update_cursor() function will mold the cursor mesh to the terrain.

If you click the mouse, then the tool subroutine is called, which does all the height adjusting and painting.

Each brush mode is handled in the tool subroutine, and each indice in the ter array is affected depending on the distance to the cursor center point. So...

` Work out the array location of the cursor
cx=int(curx#/100)
cz=int(curz#/100)
` And the real snapped location
curx=cx*100
curz=cz*100

` Now the area the cursor covers in the ter() array
st_x=cx-1-cursize
st_z=cz-1-cursize
en_x=cx+1+cursize
en_z=cz+1+cursize
` Work out the real size of the cursor
brush_range#=(cursize*100.0)+100.0
` Step through the area the cursor covers
for xx=st_x to en_x
for zz=st_z to en_z
` Work out the distance between the current XX,ZZ location and the center of cursor
vr#=dist#(xx*100.0,zz*100.0,curx#,curz#)
` Now make it a 0.0-1.0 multiplier
brush_v#=vr#/brush_range#
if brush_v#<1.0
if brushmode=1 or brushmode=7 `Raise
ter(xx,zz)=ter(xx,zz)+((1.0-brush_v#)*15.0*elapsed#)
stamp_ter_update(xx,zz,1)
endif
endif
next zz
next xx

So raising the terrain is done directly in the tool sub, by adding to the ter() array depending on the brush size.

Smoothing the terrain is a bit more involved...

if brushmode=4 `Smooth
hh#=0
for ang=0 to 360 step 90 hh#=hh#+(getheight#(curx+(sin(ang)*200.0),curz+(cos(ang)*200.0))-ter(xx,zz))
next ang ter(xx,zz)=ter(xx,zz)+((hh#/100.0)*(1.0-brush_v#)*elapsed#)
stamp_ter_update(xx,zz,1)
endif

That is similar to raising terrain, except it checks the surrounding heights and uses that to determine how much to modify the height by. This is also depending on cursor size of course, usually it's just a case of multiplying by (1.0-brush_v#).

When painting the textures on, the same principle is used except instead of modifying the ter() array, it's modifying the map() array, which is like a bitmap but with an element for each texture layer. The map() array is updated then periodically it will update the textures through memblocks.

I will try and watch this thread from now on, so any more queries just post them here and I'll explain as best I can.

Tersculpt2 is shaping up, one major change to the way it works is that now it uses a texture as a colour base, so there's only 5 textures to play with - but, you can paste sprites and paint directly onto the terrain now. Attached a screenie to proove that it is being worked on. The object placement isn't properly in yet, but the terrain painting works a treat.


Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Oct 2008 15:31
DarkFire - Told ya he was cool!

I haven't jumped On Aim because I've just been busy as all get out on my Web Server. I dusted it off after a year - and I'm continuing it. Its a combination of a Web Server and a Web Application system like PHP - but not scripted. It can be run as CGI (So you can use with Apache, IIS, etc. And just use as an alternative to scripted web programming - like PHP - as it truly compiles to binary... or use it as a complete web server + this same ability - to literally compile your customizations/apps directly into the web server itself. Has ODBC and MySQL native stuff built it too LOL - Oh an runs on Linux and M$ - but I digress)


Van B, I tried to look at the pic - "View" is broke - but I think that is a forum thing if you don't upload on the intial post - but the download worked - but I couldn't view the pic - at least with M$ photo/fax viewer.

Glad you're working on a new version Van B - this editor got a lot of deserved attention! I just wish DBP GDK supported alpha blending more efficiently - I'm curious how you handled that - I'm thinking shader.

--Jason

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Oct 2008 15:38 Edited at: 13th Oct 2008 16:23
Damn lossless JPG's

Uploading a png version...

All the terrain blending is handled with a shader, something we had Green Gandalf cook up a while ago when trying different terrain techniques. It uses 2 mask images and 6 textures, it also supports shading as each texture is assigned a colour element in the mask images. As long as GDK supports the shader then it should be possible to convert the engine tests to GDK. Might even be faster as there's probably better ways to update the terrain mesh in GDK.


Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
Dark Fire
16
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 13th Oct 2008 16:34 Edited at: 13th Oct 2008 23:37
@jason p sage - Jump on aim when you can.

@Van B - Thanks a ton I have been trying to figure this out for some time now. Your the greatest! Also, wow you did add a lot! Let me know when you have an update. I would love to see what new stuff you added.

If you are interested I would give you a licence of Dark Chaos if you could re-write Tersculpt in a modular format. Talk to me though email if you would like to do this and you can decide if it is worth it.

I just have a few more questions:

Quote: "if brushmode=4 `Smooth
hh#=0
for ang=0 to 360 step 90 hh#=hh#+(getheight#(curx+(sin(ang)*200.0),curz+(cos(ang)*200.0))-ter(xx,zz))
next ang ter(xx,zz)=ter(xx,zz)+((hh#/100.0)*(1.0-brush_v#)*elapsed#)
stamp_ter_update(xx,zz,1)
endif"


(- ter(xx,zz)) does what to the y value in the function getheight() ?

"hh#=hh#+(getheight#(curx+(sin(ang)*200.0),curz+(cos(ang)*200.0))-ter(xx,zz))" Does this line mean that you are going around the cirum. of the circle (represented graphically as the cursor)?

Then wouldn't you have to dec 200 by 1 to get each coord in the circle? ("sin(ang)*200.0")

"step 90" why would you skip the angle 90? Isn't the purpose to go around the entire circum. of the circle?

Quote: "` Work out the array location of the cursor
cx=int(curx#/100)
cz=int(curz#/100)
` And the real snapped location
curx=cx*100
curz=cz*100

` Now the area the cursor covers in the ter() array
st_x=cx-1-cursize
st_z=cz-1-cursize
en_x=cx+1+cursize
en_z=cz+1+cursize
` Work out the real size of the cursor
brush_range#=(cursize*100.0)+100.0
` Step through the area the cursor covers
for xx=st_x to en_x
for zz=st_z to en_z
` Work out the distance between the current XX,ZZ location and the center of cursor
vr#=dist#(xx*100.0,zz*100.0,curx#,curz#)
` Now make it a 0.0-1.0 multiplier
brush_v#=vr#/brush_range#
if brush_v#<1.0
if brushmode=1 or brushmode=7 `Raise
ter(xx,zz)=ter(xx,zz)+((1.0-brush_v#)*15.0*elapsed#)
stamp_ter_update(xx,zz,1)
endif
endif
next zz
next xx"


curx and curz - why is this needed?
CurX#, CurY# is the center point of the cursor? (Based off of this line: "vr#=dist#(xx*100.0,zz*100.0,curx#,curz#)")

Thanks,

Dark Fire
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Oct 2008 21:00
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Oct 2008 21:25
When it smooths the terrain, it checks the circumference in steps of 90 degrees, that's what the 'step 90' is for. Really all that is needed is to get the height of the 4 sides in comparison to the height that is changing. It adds up all the height differences between the current map location and the ones at the front, back, and both sides. Then once it adds up all the differences it will be divided by 200 in this case, then that is applied to ter(). If the surrounding points are mostly above the current position, then ter() would be increased.

The curx and curz integers are just there for tools that need to snap to a grid location, don't recall that any of the current tools use it, but it will be used for snapping blocks onto the terrain grid.
Curx#, y# and z# is the center point of the cursor in 3D.

Cheers Jason, no idea how long it'll take me to finish but it's shaping up nicely.


Health, Ammo, and bacon and eggs!
Dark Fire
16
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 13th Oct 2008 23:42 Edited at: 13th Oct 2008 23:43
@ Van B - Thanks a ton for that. I change my last post because I quickly wrote it in between class...

Here is what I mean:
Quote: "If you are interested I would give you a licence of Dark Chaos if you could re-write Tersculpt in a modular format. Talk to me though email if you would like to do this and you can decide if it is worth it"


If you would like to then it would really help me. If completed I would give you a licence to Dark Chaos and if the project doesn't go so well then I have some alternatives such as really good classes Framework for Filemapping, FTP, and security user registration.

If you are interested I would give you the rest of the details for what to expect for Dark Chaos. I am doing the same for a few more people. I just am waiting till the project progresses enough.

If not then that is fine. I will just start from scratch and add your name into the credits of my program.

I am looking forward to hear from you.

Dark Fire
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 14th Oct 2008 00:05
Sadly Terrsculpt is already 3rd in my priority list, so really I've no idea when it will be done, but one thing is for sure is that it'll only get more complex. I'm really not sure how well it would lend itself to being modular.


Health, Ammo, and bacon and eggs!
Dark Fire
16
Years of Service
User Offline
Joined: 23rd Jun 2008
Location: In the code you write
Posted: 14th Oct 2008 00:29 Edited at: 15th Oct 2008 19:23
@Van B - Understandable! I will just start from scratch. I will still add your name to the credits of my program. Which leads me to my next question: How do you want me to display your name logo for TerSculpt? If you want to code a quick thing to display in 3D that is fine too!

Edit: (Update)
- I have the 32x32 plain loaded and indexed in an array
- Raise height by 100 to make sure it work and it did

Now all I have to do is create a function that raises a bunch of point using sine.

Questions:

Could you help me understand how that works? (I still couldn't figure it out. Could you explain it more?) I don't need anything code specific. I just need a basic idea of how the height value is calculated for each point and which points are included.

I noticed that the number 100 came up a lot. Is that the width, depth of the plain?

For raising some points in the circle do you use the distance from the center point (CurX#,Y#,Z#) * rising speed?

Quote: "st_x=cx-1-cursize
st_z=cz-1-cursize
en_x=cx+1+cursize
en_z=cz+1+cursize
` Work out the real size of the cursor
brush_range#=(cursize*100.0)+100.0
` Step through the area the cursor covers
for xx=st_x to en_x
for zz=st_z to en_z
` Work out the distance between the current XX,ZZ location and the center of cursor
vr#=dist#(xx*100.0,zz*100.0,curx#,curz#)
` Now make it a 0.0-1.0 multiplier
brush_v#=vr#/brush_range#
if brush_v#<1.0
if brushmode=1 or brushmode=7 `Raise
ter(xx,zz)=ter(xx,zz)+((1.0-brush_v#)*15.0*elapsed#)
stamp_ter_update(xx,zz,1)
endif
endif
next zz
next xx"


(st_x to en_x and st_z to en_z) Wouldn't this be a rising a rectangle instead of a circle or does the distance account for the raising value being very small? (Close to 0)

I kinda figured out what is means:
st_x = Left side of rectangle, en_x = Right side of rectangle
st_z = Bottom side of rectangle, en_z = Top side of rectangle

Am I right?

I think it may have to do with this check:
Quote: "brush_v#=vr#/brush_range#
if brush_v#<1.0"


Where if the value is less then 1 then it won't update that point. Right?

brush_v# = (distance from center) / (?)

Quote: "brush_range#=(cursize*100.0)+100.0"

What does this calculate?

Quote: "ter(xx,zz)=ter(xx,zz)+((1.0-brush_v#)*15.0*elapsed#)"

This seems to determine the height at that point. What I don't understand is how it is calculated. First what is elapsed#? Why is the number 15 important? Is that the speed?

Quote: "(1.0-brush_v#) "

Also, what does this mean exactly?

It would be greatly appreciated!

Thanks,

Dark Fire

Login to post a reply

Server time is: 2024-11-23 14:22:12
Your offset time is: 2024-11-23 14:22:12