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.

DarkBASIC Professional Discussion / Heightmap Terrain Brush + Conform/Mold Plain Object to Matrix Surface Help

Author
Message
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 26th Dec 2007 07:58 Edited at: 26th Dec 2007 08:04
I hope this thread can be used as a learning tool for those with wishing to tackle the same thing as me. I know for a fact that there are a few programmers over in the "Creating a Level Editor" thread that would love this thread (See: http://forum.thegamecreators.com/?m=forum_view&t=108410&b=1)

I'm at the stage in my level editor to where I need to be able to edit the heights of different points on a matrix. I've already made a randomized matrix (for bumpy test) in which a sphere, thanks to 2D to 3D coordinate translation, is able to be controlled over the terrain like a real editor, rising and falling over the grooves. (Short demonstration on my humble WIP Editor here: http://screencast.com/t/MIFzOdQfD)

But real editors use a circular brush to edit several vertex's at a time, depending on the brush size/type... not a 3D Sphere jumping from one vert to another, adjusting one vert at a time. Not only that, but ideally I would like to have TWO circles. The further apart to two circles are in diameter, the more of a rounded out mound you get. See pictures for example:

One Circle (More of plateau effect)(Circle Size can be changed):

Two Circles (More of a mound effect)(keep in mind both circle sizes can be changed):

My problem is that I don't know how to make a brush in which I can move around the matrix to edit it in the first place! Oddly, this seems like the most challenging part so far of the editor; not the raising or lowering of a single vertex on a matrix, but making a brush in general as well as raising different vertex's different heights!

To give you a good idea of what I'm shooting for, take a look at Van B's picture of his editor.

Lovely isn't it? Got to admire the mans work

But anyway. I figure the best way to go about this is to make a plain, alpha texture it, make the plain conform to it's current position over the matrix (HELP), and then be able to move the plain around with the mouse while riding over the terrain (because it's the mouse cursor while in terrain edit mode).

But, I guess a more important question to answer first would be, could a texture detect how many verts are inside of it? And another problem, a circle made on a texture can't really be made smaller/larger like a brush could it? The circle that will be textured to the plain needs to be adjustable in size because, well, because it's the height brush for the matrix.

How will using a texture of a circle on a plain PLUS the fact that it could be circles of different sizes be used in a calculation to see how many verts are within the circles diameter, and then go on to adjust them differently?

When I think about it like that, I think I might be going about this problem wrong; that a textured plain isn't the right way.

Please guide me through this process

Quite a few people could learn from this thread, especially the crew over in the "Creating a Level Editor" Thread. Even if the topic covered here isn't exactly what the future visitor needs, I'm sure some of the grueling programming in ahead will be useful to someone!

Thanks for the help in advance.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 26th Dec 2007 10:55
well if your "pick verts" tool is just a pain/mesh textured with a circle image then its should be fairly easy/straight forward to figure out which verts are going to be manipulated.

first you need to find the closest vertice to the center of your pick tool. (the size of the pick tool is just the radius of the texture from one edge to the next length wize, assuming you have a circular texture stretching from one end of the ploy to the other) anyways if your doing an elipse you need to calculate differently. (Im just assuming your going to be using a circle)

second you need to find this verts location and then use some kinda distance function, and check all verts to see if they are within your radius and then you store all these into an array, or you could just do something like this.

pseudo code.......
all_verts = how many in your mesh
for vert = 1 to all_verts
get_vert = close vertice
if distance is < 100

move vertice up/down - distance from center
or /distance from center, or whatever.

endif

next vert

well you dont have to use a circle but its easy when combined with a distance forumla and an offset.

or you could just make a memblock or memory grid.

say you have a mesh that contains 1000 vertices.

so you make memory for type int or word cause you only need 256 bytes here. or more precision you could just float it and really get to position stuff. but I find that 256 is more than sufficent.

well anyways, each chunk of memory would represent a height. so say all vertices at location 1,1 would be memory location 1 and vertas at 1,2 would be memory location 2 and so on and so forth. The point is this method is way easier and faster then the above mentioned method. say you want to take your pick object, you just translate its location to the appropiate locations in your memory that you already have allocated and then just set it to a height. then you have a handy function that just checks when this memory has been changed or even a simple update function that you call when you click the mouse to move the verts. So easy. Simple as pie right.

Well I dont know if that helps or leaves you more confused, but it makes sense to me and this is how I would and have done this. I prefer to just use a bitmap and just color it and it updates in real time, but thats just the way with these things, more than one way to skin a cat right?

Good Luck.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 26th Dec 2007 14:54
Hey David W - How Are you man? I haven't heard from you in awhile - good to see you online and I hope you had a good Holiday!

Just something to think about Sid. I've noticed in some Editors, they use "Bitmap" Brushes. Kinda like a Height Map. The Center of the bitmap is the center "vert". And by using the data in the "bitmap" brush - you can make a system where you can literally use MSPAINT to design your brushs, Square, Sphere, Crater, Bumpy, whatever.... couple that with a technique - like using the "heights" unadultered, applying random noise where there is color on the brush, (Round Random noise for example..perlin, whatever) ... You then just check your verts as they related to the bitmap - of course to have different size brushes - you can use the same bitmaps with a little careful planning - and using floats - the same way one can use a height map of any size on any size terrain - just need to do some basic math.

bitmapwidth divided by brush width = AMount to increment each loop step accross a row in the bitmap. (Use Floats)

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Dec 2007 16:10
Hi Sid, glad you like my pretty editor screenshot .

Your on the right track with this stuff already, but I thought I would drop in some pointers as to how I do things.

Firstly, I use a small matrix as my brush object, using PICK OBJECT I get the 3D location of the mouse pointer and stick my brush object there, then I mould it to the terrain using the heightmap, in my case it's called Ter(x,y). I have a function that returns the ground height at any 3D location based on the heightmap array. This is a very fast method and I always advise people do the same - especially when you start making a lot of height checks.
I use different images for different sized brushes, going from 1 to 10 tiles wide, that way you can add a grid or whatever you like really - maybe even a compass so you know what way your pointing. I actually have a second cursor object that I use to show those funky height lines on terrain, don't recall the proper name for them but it does help guage the terrain.

To adjust the height of my terrain I use the following code... I think it's quite easy to follow, I like how it's working on my terrain at least, especially the flatten bit - like I'll make a big mountain then flatten chunks of it then smooth it all off and it makes quite organic terrains but still giving control.



My terrain is 512x512, and I use a 100 unit wide tile.

Anyhoo, I plan to upload my editor source as is, before I adapt it to my game project, so that people can do the same. It actually uses a terrain shader based on Green Gandalfs, gives 6 textures, and has it's own lighting system. Just want to neaten it up and make a nice example terrain.


less is more, but if less is more how you keeping score?
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 26th Dec 2007 19:22
Ahh... So you will be releasing the shader you modified? May I please get that fx file early? I only have the 4 texture one ... and if you say no - I'll have to figure out fx files - if you say yes - I'd be mighty grateful.

I'm trying to find one that is light weight. Also - I'm personally still struggling with: Shader or Not. I keep thinking there has to be a way to blend multiple layers of texture without a shader - maybe a decent pixel shader would work - or some other means. I KNOW DirectX can to TRUE texture splatting. I've seen it in BlitzBasic - and specifically in T.Ed. Terrain Editor. But for DB you need double the poly count. And how about dramping the light map over the whole object without using the built in ligth map shader?

Those are the tricky things for me. Green Gandalf's Shader for 4 textures - 3 + alpha layer for roads - brings FPS down in big scenes - that without the shader running - go much faster. The way it can do hills and all is cool but the seams are a bit depressing.

I think you, Van B, actually I think it was you - talked about how you can use alpha in the vertex color fields in a mesh - to do something like that... maybe there is a FVF that not only does 8 textures of UV per vertex , but also 8 "Vertex" color fields per vertex - so you can define color (and or alpha/opacity) of each texture level for a given poly.

Dunno - that's where I'm at. I Don't want Seams, I want culling, I want poly reduction algorythms built in - but what I want and what I finally go with - are two different things.(Something workable, fast, decent, good to build my game on).

Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 27th Dec 2007 06:55
Wow, thanks for the help everyone

Unfortunately, I've been busy with work all day yesterday and part of today.

After reading all that I guess you could say I'm more clear on the theory, but a lot more confused on execution. I'll give things a try tonight after work and post my efforts... how ever good/bad they may be lol.

Bitmap brushes... hmmm... interesting idea there. So it's pretty much a heightmap looking bitmap, but only in the shape of, lets say, a photoshop brush? Sounds pretty cool.

Sorry to cut things short for now, I'd like to respond to more of your comments but I have to go. Early start tomorrow *sigh*. Like I said though, thanks for the comments thus far and I'll report back tomorrow evening.
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 28th Dec 2007 03:24 Edited at: 28th Dec 2007 06:38
Quote: "Firstly, I use a small matrix as my brush object, using PICK OBJECT I get the 3D location of the mouse pointer and stick my brush object there"


Got that done :
Trust me, their are two matrix's there, and the top one is the 'brush' and it does move along the heights of the terrain. It's hard to tell though because I'm not using any textures just yet.

Quote: "then I mould it to the terrain using the heightmap, in my case it's called Ter(x,y). I have a function that returns the ground height at any 3D location based on the heightmap array. This is a very fast method and I always advise people do the same - especially when you start making a lot of height checks."


Okay, so what your saying is that I should make an array of where the height every single one of my vertex's are... so I should be using the get terrain height command and save all that info in an array. Should I check ALL the vertex's on that matrix? Or only the ones over the cursor/brush? How would I even check that distance before making the check for the height of terrain underneath?? AH!

Quote: "I use different images for different sized brushes, going from 1 to 10 tiles wide, that way you can add a grid or whatever you like really"


WHAT? If your using a matrix... and then texturing it with your brush image using a bitmap... how do you shape the matrix to wear when you use it conforms to the brush? Hear me out before you call me noob. In my book, all you can do is set the transparency of the matrix texture... but just doing that isn't good enough because I need to check all the vertex's under the brush matrix against the terrain matrix... I guess my real question is: How do I know which vertex's on the brush bitmap belong to the vertex's of the texture on the matrix and not ones that are alpha'd out on the matrix... because a matrix is square and my brushes won't be...

Get what I'm confused on? Or am I just talking crazy... lol. It's possible, like I said, I'm new to 3DMath commands completely.

Thanks for the help in advance.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Dec 2007 15:41
That's where the BITMAP "Height map looking" Brushes come into play. ita a SQUARE - but you only work the VERT in question if it has color. You use the COLOR to determine how much "effect" that "piece" or "square" of the brush has on the terrain below it.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Dec 2007 15:47
Ahh, see I get a bit rambolic and hard to understand .

I store all the heights in an array, then use that data to create the terrain for a given location on the heightmap. I use a linear interpolation height check to give a very fast ground height function:

Remember that Ter(x,y) is my heightmap array and is 100x100 units wide.


My brush object is textured straight down with a sorta grid with a square in the middle, and a circle to show the brush radius - this is stored as 10 different images and I retexture to show the appropriate brush radius. I just use the returned coordinates from Pick Object as the centre point then mould the whole lot to the terrain heightmap, plus a little so theres no Z fighting.

When painting the terrain I use the same returned coordinate but I figure out where on the mask texture the user has clicked, then I perform the 2D texture drawing stuff based on the location on the image. I think you looking at dropping brushes onto the terrain, like you might have a little image of a heightmap for a volcano - I'd store the image as an array, then make the clicked location the centre, and paste it onto the heightmap directly, like maybe even check for blend pixels. This is something I plan to do, maybe we can put our heads together and get a neat system for that.

Incidently, after spending half an hour making a fairly crap terrain I realised just how long it's gonna take, so I've added a random terrain generator, seems to work quite well - but it means that I can release this thing soon, should be uploaded tonight at some point.


less is more, but if less is more how you keeping score?
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Dec 2007 17:26
Van - You have done a great job on that Sir. Myself and obviously others are all hammering on various terrain'ish projects - and your's is looking fab!

Super Smash
18
Years of Service
User Offline
Joined: 4th Jul 2005
Location: At my computer
Posted: 29th Dec 2007 02:04 Edited at: 29th Dec 2007 17:07
i had to face the same thing with my editor, but what i did, is i had the user "select" the verticies they wanted to raise or lower, then with the mouse left click or right click and the terrain would raise and lower.
a small pic of what i mean


I rule you all
-SuperSmashcz
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 29th Dec 2007 22:55 Edited at: 29th Dec 2007 23:01
I wasn't going to post this initially, but why not. This is where I am at with it now.

To control the camera, hold down the right mouse button to look/move around. Move with the arrow keys.



If you look at the threedmouse() function, this is currently where I am stuck. Van B, I'm trying to follow your instructions but I'm still getting lost.

As you see at remark "`Make array of terrain heightmap", I make an array of all the terrain heights in the ter(x,y) array, just like you said, but I'm not sure what your 'getheight#(x#,z#)' function does if you have the ter(x,y) array getting the heights... I'm interested in what you said here though because you say it's a really fast way of doing a height check. Your getheight#(x#,z#) function is just kinda of floating in my program alone right now, until I know what to do with it.

I'm now thinking about how I can grab certain height positions out of the ter(x,y) array (the ones that are currently under the cursor matrix on the terrain) and then set my cursor matrix height to them. I'm lost on this too.

Any help would be welcome
Dr Schnitzengruber
16
Years of Service
User Offline
Joined: 19th Jul 2007
Location: C:/Projects/failed/ schnitzengruber
Posted: 30th Dec 2007 02:56
Me wants to know(from Van B or someone who knows)

I tried to make a editor but couldn't find out how to blend the textures without crashing the computer. I tried a memblock blending technique but it took 2 minutes to blend the textures and tiling them onto the matrix was a pain that resulted in not enough video memory. How do you get that cool blending effect?

jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Dec 2007 03:56 Edited at: 30th Dec 2007 04:02
One Way? Shaders. Green Gandalf made one I like that you may find interesting - I don't think he'll mind me posting it here. (If so, I'll remove it) See Attached. This is his v4 Terrain Blending Demo. He has others - one with BumpMapping. They Look Great - but I have a slow PC so the shader brings FPS to a crawl.

[edit]...didn't mean to submit yet.....

The other thing I was going to say is "You were one the Right Track" at least for "None-Realtime" blending.

I'd be curious to look at your blend code to see why it took minutes.

Note though - Pixar and other graphics houses.. SET UP their scenes... and get them all set up - and then the REAL rendering occurs which takes a ton of time to process, but once its processed, its done. Having a texture blender - that can SAVE its results for later use (regardless how long it takes to make em) - is a Good thing! When you load the final product - its ready to go!

Attachments

Login to view attachments
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 30th Dec 2007 19:42 Edited at: 30th Dec 2007 19:43
Ah ha! I think I've got what I need to do now. Finally... I'm a bit slow on the uptake when it comes to complex stuff like this but after putting it on the backburner for a day or two, I think I understand now.

Correct me if I am wrong.

So, this ter(x,y) array stores the heights of all the points on my terrain (the matrix) at x and y. Since the x and y are coordinates for locating a particular location on the grid, all I need to do is find my cursor position in relation to the array's x and y, and then grab the x and y coordinates from my array and add my cursors radius to them in every direction... scrolling through each point from the cursor location out to the end of my cursor.

Right?

For statements will bring much happiness during this procedure.
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 31st Dec 2007 00:10 Edited at: 31st Dec 2007 00:21
I'm pretty much frustrated with this now. I'm pretty sure the way I explained it above is the right way, but I have yet to break through with any code.

My big problems I want to tackle are finding which points on the matrix are within my cursors range, molding the cursor to those points heights, and then from there go on to moving the points according to the brush.

I don't know how, by using the ter(x,y) array, that I can magically pinpoint which group of points are under my cursor.

Could someone lend me a hand on molding the cursor to the terrain? I'm desperately lost.

Edit: Would any of this be easier with memblock matrices?
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Dec 2007 00:28
Sid... Make a MEsh in memory... say 10x10 verts . Set Uv's so you can drape your cursor texture across the whole thing. Make it transparent... Make the position center in the middle.

Don't think MESH for a minute. You can do the whole "Pick Vector" stuff constantly or just use it to "find the closest Vert in your landscape. Shoot - if it helps... make a bunch of little cubes pistioned where all your "terrain" verts are - and use pick object like that. Then use that X,Y as a set of variables for where your cursor is... say right DRAG... makes it so the X,Y changes and as it changes, grab the positions, and put your cursor there.

Quote: "My big problems I want to tackle are finding which points on the matrix are within my cursors range,"
- Cheat ... use the little cubes trick maybe - pick object would work then.

Quote: "molding the cursor to those points heights"

Once its there, you can start a loop 5left and 5 up from your x,y, and then adjust the heights of each vert in your cursor to match the terrain mesh...perhaps + 10 or something... ....

Quote: "and then from there go on to moving the points according to the brush"
add/sub tract the amounts from each vert.

I haven't done this myself YET but I'm getting there - I'm doing TExture Blending at the moment and need to get back to it but when I saw your post I had to try and make a suggestion to help ya maybe arrive at an idea - or better - someone pipes up and says my ideas are not the right way and explains it for you!

Man I hope you get this! You've made some great progress over all so far!

david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 31st Dec 2007 02:36
well the verts in a terrain mesh are all uniform and grouped together.

simply make a list of all groups. record what verts share what cords and you can simply just access the group instead of every vert its like taking 1 out of 3 then only accessing 1 instead of 3 so you save 2/3 the search time to determine the proper verts
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Dec 2007 03:11
Hey David - Where ya been? I've been wondering about you - Could you email me - I have a question for ya

Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 31st Dec 2007 06:53 Edited at: 31st Dec 2007 06:59
Ok, I feel like forward motion is being made... slow, but forward. I'm excited about this memblock matrix thing. It sounds a lot more useful than a regular matrix.

Time for some memblock questions though. I've searched high and low for examples and explanations but they are surprisingly hard to come by. I think I've hit every memblock thread here . I found a few good examples that did some cool stuff, but they weren't commented very well, so I have some questions. This is just a practice memblock program.

The questions are commented in the code:


I'm flying in the dark here. I've figured out a few things as far as what numbers mean what, but I'm not sure. Most of this code has been taken out of examples I've found. Unfortunately, thats the only way I could find anything out about them and applying them to memblock matrices.

And then after that, whats the procedure for writing the vertex's? I see a lot of "writevectordata(mem,pos,(x-1.0)*tilesizex#(mem),0.000,(z-1.0)*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),0.000,1.000)"
ahead of me and don't know what all those x-1's and 0.000 or 1.000 mean. Normals again?

And, when you 'normalize' a matrix, does that mean making sure all the vertex are facing the right way? For example, when I fly underneath a matrix, it disappears, is this because the normals are pointing up?

Thanks for your time
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 31st Dec 2007 06:59 Edited at: 31st Dec 2007 07:03
Have you tired to start with just making a triangle?

Im not doubting you, I know you got skills, what I am saying is that sometimes taking code that others have written gets you into jams like this because you dont understand what exactly has to happen and why it has to happen.

I have some simple make triangle from a memblock code here that is easy to understand but I think its from the code snippets board so you probably already have it. But it never hurts to ask if you would still like it?


EDIT. Anyways why even mess with memblocks once your terrain is created. Why not just use the vertexdata commands? I am not trying to question your reasons I just dont understand them?


edit again. It seems alot of your question can be anwsered simply by looking up and at the fvf format that is required to build this memblock mesh.
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 31st Dec 2007 07:04 Edited at: 31st Dec 2007 07:04
Wow, quick reply lol.

Is this it? http://forum.thegamecreators.com/?m=forum_view&t=87105&b=7

If it is... *sigh* I mean I saw it... but it was hard to follow. There are a lot of run on sentences in his writing and he got me turned around quite fast. I'll take another look at it though. I think I'd understand it the same though if I grasped this memblock matrix stuff though.

Thanks for the reply.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 31st Dec 2007 07:08 Edited at: 31st Dec 2007 07:09
ya that is the one I was refering to lol.

edit. well since I am here already I have time to help. anyways, what have you done so far? and what methods have you used to accomplish this. and what do you need to do and what methods do you plan to use to accomplish that?
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 31st Dec 2007 07:21
Maybe it's because it's 1:20AM and I'm so tired I can finally sit still, but reading this again for the 10th time is making me understand things a bit more.

Thanks for the suggestion david w. I'll go through this again and report back tomorrow with what I learned and any questions.
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 31st Dec 2007 08:20 Edited at: 31st Dec 2007 08:22
Lol, I just finished the tutorial again and this time everything clicked. It's been so hard to concentrate around here lately... for christmas my family purchased a karaoke machine, and for the past two days it's been hours upon hours of really bad karaoke... try to learn memblocks during that and you'll be a nervous wreck! It was funny for the first 2 hours, but after that it was like... ok... enough ricky martin, lmao . But with it being so early in the morning, I was finally able to grasp the basics.

Sometime soon I'll be putting those 'basics' to use and see if I can't get a matrix going. I'm not to sure when I'll be able to post again, as it's new years eve tomorrow, but I'm eager to try this stuff out.

Some things I've been wondering though, is if it's possible to have a wireframe mesh... I don't think so because it looks like you have to set the vertex color no matter what.

Also, his tutorial didn't cover normals because he didn't know how to do them. Could someone elaborate on what their role is and how to calculate them?
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Dec 2007 08:31
Here is a c++ snip but it might document things a little - it look bad at first glance....

I'll explain: First Part - Set's up two triangles, but in a loop to make a "matrix". Next Part ---tons of numbers? Ignore - its a IMAGe I was making in ram, and will again, as I just ironed out a bug that will allow it.

You may see some stuff with PIXELGRID - ignore - that's for my texture blender.

Memblock to Mesh - then Mesh to be copied into as many limbs as necessary to get said tiles.

I didn't give this to cram C++ down your throat - so watch the flames guys - I did so because it has comments near many values that might help connect the dots for you when you compare stuff.

I'm still learning this stuff to.

David W - this is that mesh stuff I use




jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Dec 2007 08:50
Note: SetObjectNormals function I hear is messed for big stuff in DBPro - my Experience in DarkGDK is it's not worth even calling! At least on homebrew meshs - TONS or DirectX errors, code Bogs to a crawl... just BAD. BEtter figure out a way to do it your self.


Note these samples ALL use functions that get the correct info etc. Technique 2 kinda has a smaple of this... basically - finding adjacent verts. I'd hate to try and do it in a 3d modeling program for something not GRID like!

Technique 1 - DBC Matrix Example Ported to C++


Technique 2 - My Final - has FlatShading first, then goes back and tries (seems to work) average the normals of adjacent verts - this makes edges less sharp and flat looking... of course low res stuff always looks flat but you all know this...


Technique 3 - Flat Shading Only - the foundation I built technique 2 with - (I know not in order... because my original 2 was so bad - I just reused the function call name ) TParkin helped a lot with this one - so did Pharoseer.



And Technique 4 - My Famous upside down and backward shadows - Actually a Tparkin/Pharoseer theory port to C++ sorta... and I think it went wrong because I "Wind" my poly backwards, note I tried various tweaks to "fix" it but I never go it ... so I just have it - its DARK looking... like a sunset... only lights part of hills... looks neat enough to keep though



jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Dec 2007 15:46
Sorry about all the psots they seem relevant - that's only reason emboldended, best of all - I fixed a hard to notice bug in Technique 2 and 3 - (The Flat Shading!... Because of how my untrained self) Wound Poly Triangle 2 of each face (Two Triangles make a square) I noticed on flat ground, these were visible - like snake scales or something - this HAD to be orientation based issue with the normals getting normalized or something - well I got rid of them in Technique 3 - and then moved the change with a big cut-n-paste to Technique 2 - now everything is more uniform and all is right with the world!....um this 3d world

Technique 2 fixed up


Technique 3 - flat shading


Hope my posts are ok with you Sid Sinister - just trying to give you a brain dump as I'm working/learning similair stuff right now!

Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 31st Dec 2007 17:27 Edited at: 31st Dec 2007 17:33
Wow, lot to take in here. Thanks for all the examples, they are pretty nice .

Quote: "36=Size of Vertex Struct?"


Slayer93's guide says that the 36 equals the size of one vertex in the memblock, 12 equals the memblock size minus the first 3 dwords (since it's just memblock setup) and then it gets multiplied by the number of verts you'll have in the end. You probably already knew that though lol

Quote: "First Part - Set's up two triangles, but in a loop to make a "matrix""


Wouldn't this mean that there are double the amount of needed vertices at every vertex location? I thought a saw a thread on vertex wielding while searching around last night, is that what that thread was about? It looked like... pretty hardcore stuff lol. I think it might be a pain in the but if I do leave them like that because every time I go to raise a point on the grid, I'll have to grab two 4 vertex's per point... right? Actually, thats just if I don't make a backface for each poly too... otherwise I'd have to grab 8 vertex's per point!

About limbs: I saw a lot of 'limbs' in your code. Can you explain this? Limbs weren't in any of the examples thus far, so I have no idea whats going on. Are you using limbs so you can make your own culling system? How do you assign a... actually I'm not even sure what you assign it to in the first place but, how do you make something a limb? Why?

About normals: Thanks for all the technique's there, I don't really have a clue what they do or how they should be manipulated right now, but once I found I'm sure I'll be looking to your code for examples.

I don't have time today to apply what I've learned, it being new years eve and all, but tomorrow morning I might have something up. Thanks for all the help Jason =]

Hopefully the next time I post I'll have a working matrix mesh!
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Dec 2007 19:43
Your Welcome - Glad to help - its a lot to take in - I'm still learning!

Vertext Structure Size.... Depends on the FVF Format. I guess you OR these bits together to make up a FVF format:

C++ with Hexadecimal


And same but translated to decimal


Depending on the FLAGS, and the fact that a float is 4 bytes (DWORD Size) um... You can Calculate the Header Size.

Got Vetex positions? (You probaby should!) Add 12
For Normals? Add 12 more bytes to header size. etc. Forget color - thinks is 4bytes per vertex... I forget....

Welding? Yes - I understand the concept - but the FVF format doesn't seem to allow for it. Moving one vert would be nice, but I think TRUE Welds are when you can pass the same coordinate LESS TIMES and the routine building the mesh knows how to draw from what info you DID give - and the "Rules" for THAT optimaized POLY maker... Like Triaanle STRIPS.... and Triangle Fans... But I won't pretend to know how or to really care at this point.

Is it a pain geting the adjacent verts? YES. But - (I should wrap mine up better) ---but if you wrap those basics ... then you can trweat them like Welded Verts....that's what I do. I set Height with MyMesh->SetVertHeight(X,Z,NewHeight); <-- that routine does all the adjacent stuff.

It's tricky no doubt.

Good Luck - I'm currently trying to make a SHADERLESS SHADER!!!!

Jason P Sage - Too Ignorant about shaders to write them? His PC to Slow? Whatever the reason.. Jason P Sage has gone rebel - and is part of the ANTI-SHADER League.... whose mission is to acheive Beautiful GFX whereever possible without SHADERS!

Seriously - I need to WATCH Shader Overhead - they are so neat - but WHAM to the FPS... Saving them for water, and Maybe Wind across Folliage in the distance or something.

Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 1st Jan 2008 22:06 Edited at: 2nd Jan 2008 04:05
What am I doing wrong here that I'm not seeing anything?



Edit: If this works, why doesn't mine?

Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 2nd Jan 2008 04:40 Edited at: 2nd Jan 2008 06:31
YES - BOOOOOYAH GOT IT WORKING!!!



The problem was I had write memblock dword mem_numb, 8, poly * 3 set to write memblock dword mem_numb, 8, totalsize!!!

Ok, short lived celebration, because now I'm onto the wonderful world of editing it...

Oh, and somethings bother me... Should I only be getting 25ish FPS from this? My computer specs are Pentium D 2.8Ghz, 1Gig RAM, X1300 AGP. Someone made a much larger terrain on these forums yet still managed to pull a nice fps, what am I doing wrong? Here's what I'm talking about in case your wondering... http://forum.thegamecreators.com/?m=forum_view&t=77038&b=6

EDIT: Any idea why my friend can't see the terrain when he runs it? He sees the blue background but can't seem to find the terrain, even after he's looked around with the mouse.

EDIT EDIT: Code Revised to look cooler =]
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 2nd Jan 2008 07:23
congrats and the reason is probably cause the poly count is so high.

it runs at only 72fps and I have 3800+ X2, 512mb x1950xtx.
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 2nd Jan 2008 07:43 Edited at: 2nd Jan 2008 08:45
I might try my hand at culling, I've seen a few pretty useful threads around. What I don't understand is how that guy from the thread in my above post achieved a much bigger map than I did and got a better fps than I did...

I'm thinking about weilding my vertex's together, as I've found some pretty neat code I think I'll be able to port over to mine. I am making a texture painter for my memblock matrix in the future and was wondering would wielding the verts cause any problems? Would setting the uv coordinates to stretch across the entire object be a bad thing for a texture painter?

And, as far as my cursor and comforming to the terrain goes, I was told to texture my terrain with the cursor image and then use the mouse to scroll the texture around the terrain... how exactly does one move a textured image around an object? Especially without messing up terrain textures that are underneath the brush texture? And would wielding affect any of this as well?

Thank you for your time
dj blackdragon3710
19
Years of Service
User Offline
Joined: 5th Nov 2004
Location: In LaLa land
Posted: 2nd Jan 2008 19:50
Ehh... I get over 1000 FPS, 0 poly's drawn and the cam doesn't move... The FPS is only because nothing is happening I'm sure of that, but I'm still trying to figure out exactly why nothing is being drawn to my screen.

<<<<<Used to be "djblackdragon" with being registered in January, 2003, no matter what it says on the left<<<<<
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 2nd Jan 2008 21:20
I'm not sure what your computer's deal is, but it works here, it works on my other computer and my laptop and it looks like david w ran it just fine as well. Anyone have any ideas? Anyone else having problems?

Arg... ok... I still need help on the main purpose of this thread, to make a cursor that moves over the terrain but stays molded. Now, I know we've been over all this before, but I'm still not getting it.

There are a couple different ways I have thought of, but have no clue how to program.

1. Make a built in matrix 10x10, adjust verts as it travels over terrain. Set texture to see through so the grid is transparent. Texture it again with an adjustable brush image.
problems? a)adjusting verts b)texturing something twice

2. Make a plain 10x10, adjust verts as it travels over terrain. Set texture to see through so the grid is transparent. Texture it again with an adjustable brush image.
problems? a)adjusting verts b)texturing something twice

3. Make another memblock matrix 10x10, adjust verts as it travels over terrain. Set texture to see through so the grid is transparent. Texture it again with an adjustable brush image.
problems? a)adjusting verts b)texturing something twice

4. Just texture the terrain with the brush image to begin with. Problems? a) I need to be able to scale the brush texture... b)Can a texture be moved around like a cursor?? c) How can I find out what verts I'm by (based on brush bitmap) with just a texture??

Please help, I'm frustrated and out of ideas once again.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 3rd Jan 2008 02:09
Yes. I have have an idea. I've seen some video cards just REFUSE to render stuff that fills up their video Ram.

This made me realize that for any game I release I NEED both code to check ALL graphics capabilities, check for hardware like joysticks if I can BEFORE trying to use them, and to check for shader support AND the ability to select various stuff just because the user wants to.

Personally I like programs that do this - sometimes I want pretty, other times I want FAST AS HELL game play no lag etc... so - I'd start backing your code down a little during dev for your friend - maybe a few booleans variables you can set for now that disable the fancy stuff... compile - give to friend - turn back on for yourself during dev time

Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 3rd Jan 2008 03:30 Edited at: 3rd Jan 2008 03:38
Yeah, Him and I will work through it backwards. I'm not sure of any hardware checks I can do, as no shaders are involved in that code so... But I'll keep the advice handy in the future.

Any advice for my brush problem though? I know you've covered it above... but I'm still confused.


The questions again are:

I'm thinking about weilding my vertex's together, as I've found some pretty neat code I think I'll be able to port over to mine. I am making a texture painter for my memblock matrix in the future and was wondering would wielding the verts cause any problems? Would setting the uv coordinates to stretch across the entire object be a bad thing for a texture painter?

And, as far as my cursor and comforming to the terrain goes, I was told to texture my terrain with the cursor image and then use the mouse to scroll the texture around the terrain... how exactly does one move a textured image around an object? Especially without messing up terrain textures that are underneath the brush texture? And would wielding affect any of this as well?

AND

Arg... ok... I still need help on the main purpose of this thread, to make a cursor that moves over the terrain but stays molded. Now, I know we've been over all this before, but I'm still not getting it.

There are a couple different ways I have thought of, but have no clue how to program.

1. Make a built in matrix 10x10, adjust verts as it travels over terrain. Set texture to see through so the grid is transparent. Texture it again with an adjustable brush image.
problems? a)adjusting verts b)texturing something twice

2. Make a plain 10x10, adjust verts as it travels over terrain. Set texture to see through so the grid is transparent. Texture it again with an adjustable brush image.
problems? a)adjusting verts b)texturing something twice

3. Make another memblock matrix 10x10, adjust verts as it travels over terrain. Set texture to see through so the grid is transparent. Texture it again with an adjustable brush image.
problems? a)adjusting verts b)texturing something twice

4. Just texture the terrain with the brush image to begin with. Problems? a) I need to be able to scale the brush texture... b)Can a texture be moved around like a cursor?? c) How can I find out what verts I'm by (based on brush bitmap) with just a texture??

Please help, I'm frustrated and out of ideas once again.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 3rd Jan 2008 04:08
Just make an array of little cubes, and position them to the positions of the vets around the cursor... no? Then you see a floating "half cubes" each doing a vert? Would that "Get-r-Dun!"??

I like VanB's cursor too - and think its great - but maybe just reexamine this from the start. Can you find the CENTER VERT that the mouse is clicked over ... or when mouse buton (lefT) is down? If Yes.. you're 50% there

Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 3rd Jan 2008 08:46
MAN - I wrote this whole thing then closed Firefox by accident and lost it all... bah, well, I rewrote it lol.

Yeah, I like Van B's system as well, which is why I'm trying to emulate his brushing technique, as well as the molding part. How he does it STILL eludes me, but I think I finally have an idea.

I've been avoiding using an actual heightmap thus far, but I think I'm going to need one, especially if I use bitmap brushes (Ok... how many of you are smacking me for having not used a heightmap up to this point?).

Well, anyway, here's my idea, and maybe this is how Van B does it and I finally caught on.

As far as molding the brush object to the terrain goes: Take my terrain heightmap, take my bitmap brush, grab the brushes size off the corresponding x and y position on the heightmap, grab the image and then take that image and cycle through the rgb values and set each vertex on my brush object according to that bit of data from the heightmap.

As far as raising verts: While I have that lovely data from the molding in my hands, I can then use that in addition to my brush style/strength and paste the bitmap brush image to the heightmap, adding on the already existing rgb values so you can build on top of a hill and what not.

Think that will work? Is that what you've been trying to tell me all that time?? Lol.

@Van B: If your still following along here, how does my new idea compare to your system now?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 3rd Jan 2008 11:52
Really I'd advise against using a byte heightmap, as they are very blocky, I mean I always end up smoothing basic heightmaps anyway, but I think your as well to stick with standard integers.

I should have really finished with the editor example by now but stuff keeps getting in the way. I hope to get it done before the weekend.

The thing is, once I had my heightmap array in place and my height check function, making the terrain mould to it is easy, and with that moulding the cursor mesh is easy as well. I can see why you would want to weld it, I'm sure I did that then saved the mesh as a DBO, but I'm sure everything will fall into place once you get a heightmap system in there.


less is more, but if less is more how you keeping score?
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 3rd Jan 2008 18:11
Bah! Dang it. I thought I was onto something with all that.

Are they still blocky after something like box filtering? The problem with that is I wouldn't be able to have sharp cliffs in area, because it smooths the whole thing... but, actually I just thought of this; I could only apply that algorithm to the area on the height map the brush image grabs the image from/edits, not the whole heightmap...

But, I don't think any of that is possible if I don't use a heightmap like that.

Anywho, I'm suppose to have a conversation with Jason today about this subject. In the meantime, I'm going to continue researching different avenues and wait eagerly for the release of your source.
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 3rd Jan 2008 20:22
Just got off the phone with Jason and I think I understand how to do all of this a lot better =]

Van, I understand your concern with it being blocky now, but I think I have a way to prevent that, thanks to Jason.

I'll be using a color heightmap to begin with, so that helps, but before I go adjusting verts to the values of my heightmap, I'll convert those values into floats and multiply them by the scale of things (also a float). After I get done with that, I should have a fairly diverse set of numbers, making things not blocky. See below code for a short example.



Same concept for the brush as well, only when I go to raise verts, I ADD the existing value of that pixel on to the brush strength value and write the new values and refresh the heightmap and mesh.



Some other things we talked about where welding vertices together and how to check if it's doing anything which is basically just getting the memblock size, because it should be smaller after the weilding. So I'll to try that code again later and see if it does anything.

@Jason: I think I asked you about whether stretching the uv data over the whole object would be a bad thing while talking about the wielding... in which you responded to yes, you wouldn't want to do that... right?


The last thing we talked about was Limbs... I'm not sure if I'm going to make the switch yet, but it sounds like a really good idea , especially because of the culling aspect. What I'm trying to keep in mind if I do make the switch is does the way I raise/lower verts change at all, and does using limbs affect how things get textured with my future texture painter? I'll have to look more into those both.

But now! It's time for a nap, because thinking about this has pretty much tired me out, so... I'll get started on things after my nap haha =]
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 3rd Jan 2008 21:29
Quote: "I think I understand how to do all of this a lot better"

Cool

Quote: "I should have a fairly diverse set of numbers, making things not blocky. See below code for a short example."



Ok... You Totally get what I was telling you, but I'm not POSITVE about the Byte Order... meaning... b+(g*256)+(r*65536) OR r+(g*256)+(b*65536) ADDITIONALLY - The RGB(r,g,b) might give you the Same number doing this for you! (Though I personally like having the individual Bytes (I mean it could even be G+(b*256)+(r*65536) - I don't know - and I won't until I make a image by hand in memory using JUST RED - convert to image and look to see if its red, green, or blue....

The important thing is the understanding of the bits, nybbles, bytes, and how these are stacked in memory... and most importantly - with all this vertice and color and float stuff - you have a good handle on what memory REALLY is.... The most flexible UDT you could ever have! (Until you get some math wrong and grab the wrong data


Quote: "@Jason: I think I asked you about whether stretching the uv data over the whole object would be a bad thing while talking about the wielding... in which you responded to yes, you wouldn't want to do that... right?"


Actually... I was trying to convey the problem I am having that I hope to solve tonight (With Van B's Suggestion as a matter of fact) is to try changing some of the "TEXTURING MODE" flags...

In other words - Right now... you have one mesh, no limbs. So, when you get the UV's correct... IT will look AWESOME! However by having it all as one (non-limbed) Mesh... The possibility of LOD and Frustrum culling techniques to maintain a HIGH FPS is sort of limited.

By having limbs you can do the frustrum culling and maybe get fancy with LOD - BUT that's what I'm doing... and I PERSONALLY am having a UV issue potentially... but not because the math is rocket science... according Van B - it might just be that DB is trying to "Smooth" my edges and I really need that off.... I want it to not have any bleeding from one edge to another. And BTW - if this TEXTURE flag thing doesn't help, I have SCALING and OFFSET's built into my UV "Stretching accross whole mesh" function, so I can manually "adjust" things until I get rid of the "bleed-thru".



Have a Great Nap!


Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 5th Jan 2008 04:42
I'm working on changing my terrain creation code to use limbs... except I just thought of something... If I create my terrain using limbs... how do I adjust each vert?

Limbs are impossible with editable terrain aren't they...

Please Confirm.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 5th Jan 2008 05:28
you can access the verts of each limb you just have to cycle through them. Its not that hard. There are a number of ways to make this happen. Your not out of options ok.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 5th Jan 2008 06:07
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 5th Jan 2008 06:11
Crud, well thats one more thing to cycle through... *sigh*

I just looked up the limb commands and saw the whole lock vertexdata for limb command. Not sure how to use that, but I'll look it up tomorrow. The whole thing with locking the vertexdata though is that it's pretty slow, correct?

I'm just looking for a way to boost my fps, and culling was the first thing that came to mind. I'm not sure why my program only gets 23FPS, but I do know it's not acceptable.

Why does this guy's code produce larget terrains and keep a nice FPS compared to mine?

http://forum.thegamecreators.com/?m=forum_view&t=77038&b=6
Sid Sinister
18
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 7th Jan 2008 23:14
Unfortunately, my month off from school is over and I'm back at the grind once again... so, I'm not sure how much time I can dedicate to what I'm trying to do right now. Hopefully I can revisit this often enough to keep the information fresh in my head, but my priority is to my school.

It's not like I'm going to disappear for a while, it's just this stuff requires me to think about it for hours and spend large amounts of time trying to code it. So... yeah. Lol.

But before this thread dies off, I have some comments/questions.

In another thread found here Van B was talking about how he prefers avoiding using the tiles when texturing. Instead, it seems like he textures the whole terrain object and then uses shaders and a mask texture to make it look like he tiles each, well, tile on the memblock matrix.

I thought this was pretty interesting, and might be the avenue I go. Jason, it seems like you take the opposite approach: Texture each tile itself, and you've encountered problems there (but have fixed them).

Anywho. My to do list for the future looks like this:
1. Figure out why my memblock matrix code is so damn slow. I wish someone could answer this because I haven't the slightest idea.

2. Convert my memblock matrix code to use limbs. The only reason I'm doing this is to potentially save FPS.

3. Using the procedure of heightmaps described a few posts ago by me, make my brush matrix conform to the terrain matrix.

4. Make my brush matrix able to manipulate the terrain using bitmap brushes.

5. Start on a texture painter.

It's a long road ahead of me...
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Jan 2008 17:04
I feel your pain on the LONG journey business.

I Personally am not using a Memblock for my heights - but I'm not working on an editor where I NEED THEM redily available all the time either.

You see, the Memblock is great as a fast REFERENCE for "How High is X,Y (20,34)???" It's Also Great for Scanning these values to do a Smoothing etc.... But NOTE - To get it all BACK to your MEsh there is two ways: One at a time - copy the new height data to the mesh, or Do it all in one fell swoop.


You asked why its slow. My GUESS is that because you are reading from the MEMBLOCK, Manipulating the data, Copying the results BACK to the MemBlock and Then Going out to the VERT so you can SAVE the Change (so you can see it)..... Well... Sounds like a lot of work doesn't it?

It does to me. Memblock heights faster than direct Vert Access? Depends what you're doing. If My description describes the steps you take while moving a brush around and "Drawing" (modifying height of verts) then maybe you just access the mesh and call it a day.

Nice thing about a memblock - besides others previously cited - is that it only have the HEIGHT values (Having all three coords in memblock would defeat what I'm about to say) so you can load/save a terrain with JUST the MEMBLOCK, and a few numbers:

float Distance Between Verts X
float Distance Between Verts Z
float Terrain Position X
float Terrain Position Z

I haven't tested but procedurally "recreating" a saved mesh like this MIGHT be faster than loading a DirectX cuz there is less data to read - though if manhanding the mesh is slower than letting the Direct.X loader handle this - then my point is kinda moot.

Login to post a reply

Server time is: 2024-05-18 05:38:15
Your offset time is: 2024-05-18 05:38:15