How to turn a QTS terrain into a mesh?

Blitz3D Forums/Blitz3D Beginners Area/How to turn a QTS terrain into a mesh?

Guy Fawkes(Posted 2011) [#1]
How do you turn a QTS terrain into a mesh with nodes, hierarchy, textures, mats, and the like?

I tried to save my QTS (Terragen TER file) terrain in Blitz3D, but it's not finding any nodes, etc..

I used WriteBB3D.

Here's the functions, globals, and dims.

b3dfile.bb:



inc/qts.bb:



QTS_TerrainWriter.bb:



Yes, it uses BlitzTiles by KrisChan. (Credit: KrisChan) :)

Thanks!

EDIT: If you need an example, download BlitzTiles, then add the WriteBB3D function, the Dims, and the Globals in the correct places in BlitzTiles.bb, then call the c_surfs = and the for loop UNDER c_surfs inside of BT_InitTerrain() when it is loaded so it auto saves.

Last edited 2011


stayne(Posted 2011) [#2]
QTS_TPatch\mesh is what you are looking for. They are created during load time.


Guy Fawkes(Posted 2011) [#3]
thanks @stayne


Guy Fawkes(Posted 2011) [#4]
that didnt work, @stayne


Guy Fawkes(Posted 2011) [#5]
it didn't even find \mesh as a type, mate :/


Gabriel(Posted 2011) [#6]
Then I suggest you reread what Stayne told you and then reread what you've done instead, because the include file above clearly shows that mesh is a member of QTS_TPatch.

EDIT: And the variable after the slash is the field, not the type.

Last edited 2011


Krischan(Posted 2011) [#7]
You're lucky - I added a save mesh function for test purposes to my BlitzTiles code a few weeks ago - it's not cleaned up but seems to be working (I remember there was still a problem, guess it was the normal seams problem between the tile seams but I'm not sure).

Just add/overwrite a BlitzTiles installation with the following files in its root folder. Run the blitztiles.bb and when the scene comes up there should be a new subfolder "B3D/" containing the mesh and the according texture tiles. You can test this saved mesh with the "test.bb" using BlitzSky:

blitztiles.bb
blitzsky.bb
b3dfile.bb
test.bb

Oh, and you need to create the B3D subfolder yourself or you will get a MAV. And it is only working with 8x8 Tiles now, must be rewritten for other tile numbers (or you'll get weird mesh->texture alignments).

I added the call WriteBB3D("B3D/terrain.b3d",BT_Tiles) to the BT_TextureTiles() Function which saves the mesh - the textures are saved in the function BT_CutColorMap(). And you need the updated BlitzSky.bb for the test.bb. I only tested it with the Monkey Island scene - if I missed a file please update this thread, can't test it right now.

Another way is - if you own the full version of L3DT - the newest beta contains a save tiled mesh function, so you could create the mesh without Blitztiles in L3DT only.

Last edited 2011


Guy Fawkes(Posted 2011) [#8]
thanks, krischan! :)

much appreciated :)


Guy Fawkes(Posted 2011) [#9]
@krischan, how would you fix the seams, and the texture?

Or does L3DT do this for you?


Guy Fawkes(Posted 2011) [#10]
@Krischan: Ok, I have written some decrypt functions for you to be able to read the Blitz3D terrain file that it writes. It now ALSO writes a decrypted .txt version of the ENTIRE mesh, and not only that, ALSO explains which value belongs to what, such as VertexXCoordinate(#1)=1.0.

Etc.

Last edited 2011


Guy Fawkes(Posted 2011) [#11]
blitztiles.bb:
http://www.mediafire.com/?60kxkosmr708n8j

b3dfile.bb:
http://www.mediafire.com/?ur8lj0y1odsojeh

EDIT: Sorry for the double post. I didn't realize the files were too big to put in a codebox ><

Last edited 2011


Krischan(Posted 2011) [#12]
For the seams - I stopped working at this point - but I think it could be done by aligning the opposite tile seams / normals (if they match or it's getting complex) - not sure if I really want to code that as L3DT can do it as I mentioned before (and L3DT imports Terragen, too :-) I must look in my messy code archive, I think I coded such a seam fix before in another situation but dunno where it is...

Last edited 2011


Guy Fawkes(Posted 2011) [#13]
@KrisChan, I'm at work now, so I can't test it, but when I get home, if you want me to test the seams fix, I can! :)

Thanks again! :)

P.S. I hope u liked the decryption code! :)


Guy Fawkes(Posted 2011) [#14]
@Krischan, no sweat. I did the work of searching for the seam fix for you :)

It's in post #52 at THIS link:

http://blitzbasic.com/Community/posts.php?topic=84809#973131
Hope that helps! :)

~Rez


Gabriel(Posted 2011) [#15]
I did the work of searching for the seam fix for you :)

My hero.


Guy Fawkes(Posted 2011) [#16]
Lmao!


Who was John Galt?(Posted 2011) [#17]
@Rez... looks like you are actually putting some work in this time. This is a positive step forward, and I'm not just saying that because I got a slap on the wrist from the mods. Keep it up and you will see results.


Guy Fawkes(Posted 2011) [#18]
Thanks, John. Now see? Why can't it ALWAYS be that way? :)


Guy Fawkes(Posted 2011) [#19]
Here's the code, @Krischan. :)



Now all's you gotta do is implement it into the WriteBB3D function :)


Hotshot2005(Posted 2011) [#20]
Well done for putting your mind into it :)


Guy Fawkes(Posted 2011) [#21]
Thanks, @Hotshot :)


Krischan(Posted 2011) [#22]
The problem are not the texture seams, it's the vertex normals. I think I can add a Fixchunks Functions to align the normals, must find some time for this, but I'm too busy right now.


Guy Fawkes(Posted 2011) [#23]
ok cool :) While we're at it, can we fix the texture problem too when you get some time? :)


Krischan(Posted 2011) [#24]
Oh damn damn damn what a *$%43q3l bug. After searching two hours for a solution I can't believe it that didn't see that before. The solution is THAT simple:

just uncommented the UpdateNormals call in the WriteMesh function and everything is fine. The Normals are already calculated correct and the damn Updatenormals destroyed them. phew...

I uploaded the corrected blitztiles.bb to the same location, so just overwrite it again and everything should be fine.

Except one bug I found searching for this bug. I'm no expert at the B3D format but my B3D write function writes a strange B3D file. It opens without any problem in Ultimate Unwrap 3D and even in Blitz3D, but my saved mesh has only one surface (Countsurfaces) and when I save the same mesh in Ultimate Unwrap 3D it has 64 surfaces. But I dunno why. Any suggestions?


Guy Fawkes(Posted 2011) [#25]
I HATE that! x) LOL!

Um, try to use the decrypt function I gave you in an earlier post above these comments. :)

It writes out the ENTIRE B3D mesh AS WELL as writing the ENTIRE mesh in a human readable form, and inserts it into a text file! :)

Simply call DecryptBB3D under WriteBB3D and it will work JUST fine :)

the parameters of DecryptBB3D are the same as WriteBB3D :)

Last edited 2011


Guy Fawkes(Posted 2011) [#26]
Just download these new b3dfile.bb, blitztile.bb, and test.bb files.

I updated them to work correctly, and uncommented UpdateNormals mesh, but that STILL didn't work...

b3dfile.bb:

http://www.mediafire.com/?f8rmd4epnp271ys
blitztiles.bb:

http://www.mediafire.com/?hzkgjh82u788wwy

test.bb:

http://www.mediafire.com/?hvwsvu4vbb6bwyh

EDIT:

ALSO, here's what it's doing to both my terrain AND my textures on the terrain:



If you could fix this texture problem and seam problem, that would be GREAT! :)

Hope this helps! :)

~Rez

Last edited 2011


Guy Fawkes(Posted 2011) [#27]
Here's an image from Blitztile of my level Azurelake:



Why is it doing this? T_T

The size of my ter file is 1025

The size of my heightmap is 1025

The size of my texturemap is 1024

The size of my colormap is 1024

Here's what's in azurelake.ini:



Is it something I did?

If so, what is it? and why?

Last edited 2011


Krischan(Posted 2011) [#28]
To find a solution, I need the whole azurelake map with all files in a ZIP file (ter, colormap, texture, ini)


Guy Fawkes(Posted 2011) [#29]
Ok. here it is:

http://www.mediafire.com/?yxv2ocoivwyv9dn


Guy Fawkes(Posted 2011) [#30]
Is that enough? Or do you need more?


Krischan(Posted 2011) [#31]
Sorry Rez but I can't find any flaw, see yourself:



Did you modify the BlitzTiles.bb? By the way - the colormap must match the terragen size - it should be 1025x1025 instead of 1024x1024 - it represents the vertex colors. And the texture has a flaw - you can clearly see some horizontal / vertical lines there.


Guy Fawkes(Posted 2011) [#32]
i see. well if u go into flight mode and go high into the sky for a while, then look back down, u'll CLEARLY see the seams glitch :)


Guy Fawkes(Posted 2011) [#33]
Here's what it looks like with the seams glitch




Kryzon(Posted 2011) [#34]
Try calling UpdateNormals() on this mesh, after finishing building it up. This seam is caused by lighting.


Guy Fawkes(Posted 2011) [#35]
Nope. still didn't work.




Kryzon(Posted 2011) [#36]
Is 'mesh' composed of several smaller meshes\tiles? if so you'll have to iterate through each one of them and call UpdateNormals().


Guy Fawkes(Posted 2011) [#37]
Not sure. I can't seem to find where it BUILDS the actual mesh.


Krischan(Posted 2011) [#38]
If you compare our both screenshots, your minimap seems to be messed up but I can't explain why (looks distorted).

Anyway, try this file, it includes all source and data with your map and I don't see any seams there. I changed only one setting: from 8 tiles to 2 tiles - your texture / terragen file wasn't THAT large to use 8x8 tiles here.

If this is not working it must be an error with your system/configuration.

http://www.mediafire.com/?baohszil48xxvcc


Guy Fawkes(Posted 2011) [#39]
its still doing it >< both with test.bb AND blitztiles.bb ><




Guy Fawkes(Posted 2011) [#40]
do u need the files again?


Guy Fawkes(Posted 2011) [#41]
Any luck with the terrain code fix?


JustLuke(Posted 2011) [#42]
Sorry to hijack this thread, but your attitude sucks, Rez.

I've been browsing these forums over the last few weeks and not only have you had several obnoxious temper tantrums, you've also thrown around homophobic and racist comments. Despicable.

A few of your recent gems from two separate discussion topics:

U still dont learn do u? u MUST be mexican ;)

Don't let the door hit ya where the good lord split ya, "Gay fried chicken" ;)

What the heck is wrong with you?

People have been banned for far less and I really don't know why you or your comments are allowed to remain here. You need help, Rez, but the problems that you should look at fixing lay within yourself rather than within your code.


Graythe(Posted 2011) [#43]
A personal theory is that we have a Chupacabre in our midst. Everyone has tried to help but it's like trying to fill a quantum singularity by pouring angel delight into it.


stayne(Posted 2011) [#44]
It's amazing how one person can come into a tightly-knit community and wreak havoc. It's really discouraging that he can get away with it for so long. Makes me want to drink...


Who was John Galt?(Posted 2011) [#45]
+1 to JustLuke.

I can't help but laugh when some of those who reprimanded me for calling him on his antics are now on the receiving end. He definitely seems to enjoy some kind of special grace here, for reasons which escape me.


Graythe(Posted 2011) [#46]
It does though go to show the enormous lengths that people here will go to in order to help people complete projects. It's all the more amazing because, as far as I'm aware, no-one gets paid a bean to do that.

At first I did think that you (@John) were taking a hard line towards someone with a few learning difficulties but after reading up on the history it's all too easy to comprehend your stance. At no time did you become abusive or resort to improper language and always tried to give the guy sound advice as did others. The greatest shame is that the chap completely failed to take any advice to heart because if the tremendous energies evidenced by the repeated attempts to obtain free code were channelled into programming then the guy would probably, eventually, make something of worth. I think you deserve some kind of medal.


Who was John Galt?(Posted 2011) [#47]
Haha.... medal? Well thankyou Graythe, but I don't delude myself that I'm any angel, and others here are far more patient and helpful than me.

I do have my moments, though. I can understand how my actions could be misperceived by those like yourself without a handle on the history. The strange thing is that some of his most ardent supporters are all too aware of that history.


Graythe(Posted 2011) [#48]
Well, something may have been learned otherwise we would have had another tantrum. Well done.


stayne(Posted 2011) [#49]
Learned...or modded.