Author Topic: Scene .SCO Toolset - heightmap converters, object placers, and texture importers! Oh my!  (Read 9663 times)

0 Members and 1 Guest are viewing this topic.

Disgrntld

  • Regular
  • *
    • View Profile
  • Faction: Neutral
Hey guys, I'm trying to define a scene terrain mesh from a heightmap. According to mbmodwiki.ollclan.eu/Scene, the SCO file contains information such as how the terrain mesh is modified. Does it have to modify the terrain mesh or can I use the SCO file to flat out define a terrain mesh (e.g. from my heightmap)?

Attempting to satiate my curiosities about the mysterious SCO format, I've managed to parse it using the code at mbmodwiki.ollclan.eu/SceneObj. I then added a hill to the La Haye Sainte scene using the default editor. My train of thought was to parse and compare the two SCOs and see what changed. Well even with a relatively small change the SCO files diverged significantly, so I was wondering if anyone knows how to define a scene's terrain mesh from a heightmap?

EDIT: Solved. Changing title.
« Last Edit: April 06, 2012, 07:44:35 PM by Disgrntld »

cmpxchg8b

  • Modder++
  • Grandmaster Knight
  • *
  • Master of rglPool
    • View Profile
  • Faction: Vaegir
  • MP nick: cmp
  • M&BWBWF&SNW
Re: Scene terrain mesh from heightmap
« Reply #1 on: March 26, 2012, 11:28:41 AM »
No, you can't use the SCO file to define a terrain mesh. The terrain mesh is defined from the terrain code in scenes.txt, and the SCO file can only change it.
What you can do is use a completely flat terrain code and then alter the elevation in the SCO file based on a heightmap.
Warband Script Enhancer v3.2.0 - additional operations, game scripts and triggers for Warband modders

Disgrntld

  • Regular
  • *
    • View Profile
  • Faction: Neutral
Re: Scene terrain mesh from heightmap
« Reply #2 on: March 26, 2012, 11:53:48 AM »
Thanks for the reply, that wiki seems to be filled with predominantly your contributions and it's already been very helpful.

Would you mind explaining how the SCO represents modifications to the terrain code? I assume the mesh is first generated procedurally from the code and then each alteration is stored somewhere in the SCO. I don't think the alteration is stored as a mission_object_t as I didn't see the number change after drawing some hills, and neither ai_mesh_t nor ground_paint_t seem like appropriate places (though they did change).

cmpxchg8b

  • Modder++
  • Grandmaster Knight
  • *
  • Master of rglPool
    • View Profile
  • Faction: Vaegir
  • MP nick: cmp
  • M&BWBWF&SNW
Re: Scene terrain mesh from heightmap
« Reply #3 on: March 26, 2012, 12:05:31 PM »
It's ground paint. If you look at my C example in the wiki, there are several layers of ground paint. Most are what you'd think they are (paint), but there is a layer with a special ground spec no (GROUND_PAINT_ELEVATION_MAGIC) that describes height difference from the procedurally generate terrain.
Warband Script Enhancer v3.2.0 - additional operations, game scripts and triggers for Warband modders

Disgrntld

  • Regular
  • *
    • View Profile
  • Faction: Neutral
Re: Scene terrain mesh from heightmap
« Reply #4 on: March 26, 2012, 12:09:07 PM »
Awesome, thank you so much!

Swyter

  • Master Knight
  • *
  • »Star Wars Conquest Dev Team Leader
    • View Profile
    • [my tiny homepage]
  • Faction: Swadian
  • MP nick: Sareth | Swyter
  • M&BWBWF&S
Re: Scene terrain mesh from heightmap
« Reply #5 on: March 27, 2012, 03:18:27 PM »
Glad that the wiki helped.
Let me know if you want me to emphasize in more obscure areas of modding.

Disgrntld

  • Regular
  • *
    • View Profile
  • Faction: Neutral
Re: Scene terrain mesh from heightmap
« Reply #6 on: March 31, 2012, 03:09:14 PM »
Got this working with y'all's help (textures too): http://steamcommunity.com/id/disgrntld/screenshot/594714782049253346

Here's the scoWriter I made to use in conjunction with scoReader. I also made a few small changes to scoReader, so that's why it's a tarball: http://dl.dropbox.com/u/70112191/scoUtils.tar.bz2

The bundle still has some problems, specifically AI meshes, but I figure those are easier made inside the editor anyway so I probably won't invest the time to fix them.

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Scene terrain mesh from heightmap
« Reply #7 on: April 01, 2012, 02:27:10 PM »
I'd be very interested in testing this, as I'd much rather do some bitmap edits than have to jack around in the ingame editor, but it failed to compile under VS 2010. 

Disgrntld

  • Regular
  • *
    • View Profile
  • Faction: Neutral
Re: Scene terrain mesh from heightmap
« Reply #8 on: April 01, 2012, 04:28:27 PM »
Hmm, maybe it's the lack of header files for the reader and writer. Try the link again, it's been updated. At least for me, it compiles cleanly with:
Code: [Select]
gcc -Wall -o testWriter testWriter.c scoReader.c scoWriter.c

Swyter

  • Master Knight
  • *
  • »Star Wars Conquest Dev Team Leader
    • View Profile
    • [my tiny homepage]
  • Faction: Swadian
  • MP nick: Sareth | Swyter
  • M&BWBWF&S
Re: Scene terrain mesh from heightmap
« Reply #9 on: April 01, 2012, 04:34:48 PM »
Original message:
You've tidied it up,... nice!
Do you mind if I mirror it on the wiki?


I'm yet to get a working heightmap re-importer.



Hmm, maybe it's the lack of header files for the reader and writer. Try the link again, it's been updated. At least for me, it compiles cleanly with:
Code: [Select]
gcc -Wall -o testWriter testWriter.c scoReader.c scoWriter.c

It compiles perfectly for me too. I'm using TCC. The code is fine.
I've been playing around with it since yesterday. Thank you.

Edit: How many times have you changed your avatar, every time I reload the page it comes with a new cat :)

Disgrntld

  • Regular
  • *
    • View Profile
  • Faction: Neutral
Re: Scene terrain mesh from heightmap
« Reply #10 on: April 01, 2012, 07:22:35 PM »
Go right ahead, I would very much appreciate a mirror!

I plan to post the importer tool once I clean it up, it's currently not utilizing the auto-fill functionality and it's very clunky. I do have an example of procedural object placement though:

(click to show/hide)
That should generate a colosseum that looks like: http://steamcommunity.com/id/disgrntld/screenshot/594714994604098759

Edit #1: Haha, yea, I think the cat pics are an April Fools' Day gag.

Edit #2:
(click to show/hide)
the importer I said I would upload. You should only use this if you want to import textures into your terrain in addition to adjusting the heightmap (Swyter was kind enough to write a lot more polished tool for strictly editing the heightmap that he posted later in this thread). It's purposefully missing tga.h as I don't want to maintain another tarball and this is quite frankly too clunky for most people to use.
« Last Edit: April 06, 2012, 10:55:50 PM by Disgrntld »

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Scene terrain mesh from heightmap
« Reply #11 on: April 01, 2012, 09:59:53 PM »
I'll take a look with TCC when I get a chance in a few days, thanks folks :-)

cmpxchg8b

  • Modder++
  • Grandmaster Knight
  • *
  • Master of rglPool
    • View Profile
  • Faction: Vaegir
  • MP nick: cmp
  • M&BWBWF&SNW
Re: Scene terrain mesh from heightmap
« Reply #12 on: April 01, 2012, 10:07:55 PM »
Yeah it won't compile with VS because their C compiler is utter garbage (unlike the C++ one) and doesn't support C99 features.
Warband Script Enhancer v3.2.0 - additional operations, game scripts and triggers for Warband modders

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Scene terrain mesh from heightmap
« Reply #13 on: April 01, 2012, 10:11:09 PM »
Oh, it's probably just me being a klutzo; I'm sure I could have pushed it into working eventually. 

Just pressed for time atm, I was hoping it was going to be a ready-made tool with a loader UI to feed it a filename at least, I want to test it but I'm having enough trouble finishing the artwork and code atm and running the beta  :lol:

Swyter

  • Master Knight
  • *
  • »Star Wars Conquest Dev Team Leader
    • View Profile
    • [my tiny homepage]
  • Faction: Swadian
  • MP nick: Sareth | Swyter
  • M&BWBWF&S
Re: Scene terrain mesh from heightmap
« Reply #14 on: April 04, 2012, 11:23:54 PM »
Okay, thanks to our new polymorphic friend we can have this:

22KiB | scopng <sceneobj file> <optional png output filename>
(get it) (src) Saves the heightmap in PNG, TGA or BMP. Just change the extension


72KiB | pngsco <sceneobj file> <png input file> <optional sceneobj output>
(get it) (src) Supports PNG, PSD, TGA, GIF, JPG heightmap files as input


Finally, as an extra goodie...

69KiB | psdtopng <input image> <optional png output filename>
(get it) (src) Converts PSD, TGA, GIF, JPG, BMP to PNG. Just drop the file on the program's icon


Let me know if you have any doubt.
Portable C, no external deps.

__________________
PS: I wrote this text the 1st of April, if that makes any sense. This has taken me 3 days to get in a decently working state. After lots of testing.