Jump to content
The Dark Mod Forums

ASE Export Script for Dark Radiant


rich_is_bored

Recommended Posts

I've been working on an ASE export script on and off over the past few days and now have something to show for it. The script needs to be placed in the DarkRadiant/scripts/commands folder to show up in the scripts menu.

 

Download

 

It iterates over everything selected and exports all brushes and patches.

 

This should make vertex blending terrain a cinch. Just construct terrain however you please, export it, load it into a modeling program and vertex paint it.

Edited by rich_is_bored
  • Like 2
Link to comment
Share on other sites

I've been working on an ASE export script on and off over the past few days and now have something to show for it. The script needs to be placed in the DarkRadiant/scripts/commands folder to show up in the scripts menu.

 

Download

 

It iterates over everything selected and exports all brushes and patches.

 

This should make vertex blending terrain a cinch. Just construct terrain however you please, export it, load it into a modeling program and vertex paint it.

 

Hm, would it possible to somehow mark the textures to be used and let the exporter vertex-paint it? That would save the "use a modeling program" step, which poses quite a big challange to a lot of users.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

If you're willing to sacrifice per-vertex control then yes the script could be adapted to skip the "use a modeling program" step by looking at the material applied to each face, interpolating vertex colors where there are seams, and exporting a material shader based on the two in use.

 

But that's a very condensed version of the process under ideal conditions. In practice such a script would be very complicated and time consuming to write. If we both started today, you'd probably know how to vertex paint before I finished writing the script.

Link to comment
Share on other sites

If you're willing to sacrifice per-vertex control then yes the script could be adapted to skip the "use a modeling program" step by looking at the material applied to each face, interpolating vertex colors where there are seams, and exporting a material shader based on the two in use.

 

But that's a very condensed version of the process under ideal conditions. In practice such a script would be very complicated and time consuming to write. If we both started today, you'd probably know how to vertex paint before I finished writing the script.

 

Erm, I am trying to use blender for several years now and never got beyond the "install it and try to load a model" step :)

  • Like 1

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

Erm, I am trying to use blender for several years now and never got beyond the "install it and try to load a model" step :)

Have you seen my tutorial i posted in this thread?

 

http://forums.thedarkmod.com/topic/10726-blender-for-beginners/page__st__75__p__211417entry211417

 

 

Link to file: http://www.fileshost.com/download.php?id=F02584AD1

 

 

It's only a model...

Link to comment
Share on other sites

 

Looking at it, but I am not sure I want to repeat Fidcals experience ;) But who knows what a week ill at home can create ;)

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

  • 1 month later...

If you're willing to sacrifice per-vertex control then yes the script could be adapted to skip the "use a modeling program" step by looking at the material applied to each face, interpolating vertex colors where there are seams, and exporting a material shader based on the two in use.

 

But that's a very condensed version of the process under ideal conditions. In practice such a script would be very complicated and time consuming to write. If we both started today, you'd probably know how to vertex paint before I finished writing the script.

Except that that one script could help thousands to "skip the modeling" who would otherwise each have to learn it individually (which the vast majority won't). :)

 

Anyway, it sounds awesome; I hope you haven't closed that idea off completely.

Link to comment
Share on other sites

^ Hm, also I can't seem to get the script to work. Just tried it out with DR 1.3.0 SVN build (a couple of weeks old) and 2/2 separate tries, neither DR nor Blender 2.49b could open either file properly. DR gave me a placeholder entity instead of the walls and arch I exported, and Blender said it couldn't open it because it wasn't a valid blender file. I don't know if it's a lacking python issue (can Blender import ASE natively yet?), but since it didn't work in DR either, I guess maybe not. Confused. (all the more push for "skip the modeler step" :))

 

Compiled with Python version 2.6.2.

'import site' failed; use -v for traceback

Checking for installed Python... No installed Python found.

Only built-in modules are available. Some scripts may not run.

Continuing happily.

In BPY_call_importloader(name=D:\test_ase2.ase)

 

[EOL]

Link to comment
Share on other sites

I did a few searches but cant really figure what vertex painting does, or why is it better than uv/paint? How is it used in terrains? diffuse maps are applied over that? or does it tell how diffuses apply/and blend? I imagine it like Unwrapping and painting without the unwrap procedure.

Link to comment
Share on other sites

I did a few searches but cant really figure what vertex painting does, or why is it better than uv/paint? How is it used in terrains? diffuse maps are applied over that? or does it tell how diffuses apply/and blend? I imagine it like Unwrapping and painting without the unwrap procedure.

 

If I remember correctly then it's like being able to crossfade multiple textures on a single mesh. Good for fading between grass and a dirt road on terrain for example.

 

 

 

Link to comment
Share on other sites

Yup, its to do with blending.

 

The advantage is that vertex painting is quite fast to do and once you have done it you only need one material declared for the blend. So you dont need to make special UV's and have them added as materials with a finite scale, instead you can take two already made darkmod textures and say "when the vertex is this colour, use this texture", and if the colours change it automatically blends them, a bit like terrain/texture splatting.

Link to comment
Share on other sites

So brush/patch gets exported, vertex paint happens in modeling program(?1?),model is set so it uses the material set up with the blended textures, get it back to doom3(?2?).

 

?1?: how many colors / surfaces can be used? And how does the surface react on blended parts? The material with the blends has its own surfacetype defined that is used on the whole i guess?

 

?2?: does vertex paint info get stored in .obj too?

Link to comment
Share on other sites

I can't speak for how the script works with any version of DarkRadiant currently in SVN. I assume most users are using the pre-compiled version hosted on the website. It's currently at 1.2.2.

 

Anyway, I did notice a small bug with the script and I have corrected it. The link in the first page has been updated.

 

Setting up the script is simple. ase_export.py goes in your DarkRadiant/scripts/commands folder. Once placed there it should appear as a menu item under Scripts the next time DarkRadiant is started.

 

Then it's simply a matter of selecting the geometry you want to export, typing a filename and selecting a directory. You can verify that it worked by viewing the resulting ASE in a text editor. Here's just a small sample of what you should be seeing in the file...

 

*3DSMAX_ASCIIEXPORT	200
*COMMENT "Dark Radiant ASCII Scene Export (*.ase) v0.0.1"
*SCENE {
*SCENE_FILENAME "unnamed.map"
*SCENE_FIRSTFRAME 0
*SCENE_LASTFRAME 100
*SCENE_FRAMESPEED 30
*SCENE_TICKSPERFRAME 160
*SCENE_BACKGROUND_STATIC 0.0000	0.0000	0.0000
*SCENE_AMBIENT_STATIC 0.0000	0.0000	0.0000
}
*MATERIAL_LIST {
*MATERIAL_COUNT 1
*MATERIAL 0 {
	*MATERIAL_NAME "_default"
	*MATERIAL_CLASS "Standard"
	*MATERIAL_AMBIENT 0.5882	0.5882	0.5882
	*MATERIAL_DIFFUSE 0.5882	0.5882	0.5882
	*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
	*MATERIAL_SHINE 0.1000
	*MATERIAL_SHINESTRENGTH 0.0000
	*MATERIAL_TRANSPARENCY 0.0000

 

As for importing it into a modeling application, I have been working on an import script for Blender 2.5. The discussion thread for that is here.

 

@_Atti_:

 

If you're blending between two materials you use greyscale values. Black represents one texture. White represents the other. Values in between represent a mixture of both textures.

 

Color tinting is also possible in which case you can use any color you like. The texture applied to the model will be tinted based on the vertex colors in game.

 

I'm not sure how surfacetypes and sounds are handled on vertex blended surfaces. A member of the mod team will need to comment on that.

 

I don't think OBJ format supports vertex colors. I can't find any documentation suggesting it does. At any rate, you can't use OBJ format in the Doom 3 engine. Only ASE and LWO can be used for static meshes.

Link to comment
Share on other sites

Okay, I installed DR 1.2.2 and the new script, and Blender 2.5 alpha 2 and the importer.

 

The export from DR works, and the import to Blender works (afaict). I cannot re-open the file in DR. Perhaps I'm doing something wrong. I'm just dropping the ASE in our folders and browsing to it like any other model, but I don't recall if there's anything else I must do to set it up first. Can you confirm that you can export ASE and then open it right back up in DR as a model? Not sure what to make of that, since ASE works otherwise. Damn, I guess we're kinda up the creek without a Blender ASE export at this time.

 

Big kudos on this Rich; this is a huge development for TDM mapping (and DR and Blender in general).

 

Edit: BTW, the script seems fine with 1.3.0 as well.

 

 

OT: holy moly the Blender interface has finally changed/updated! (for the better or worse, I don't know!) :blink:

Link to comment
Share on other sites

Nope that's not it. The DR export script converts all geometry to triangles.

 

It never occurred to me to try exporting and then importing entirely within DR. I've always tested this in conjunction with Blender.

 

At any rate I've experienced the same problem. However, it does give a clue in the console.

 

PICO_ERROR: No ASE material exists with id 1
PICO_ERROR: No ASE material exists with id 1
PICO_ERROR: Could not find material/submaterial for id 1/0
PicoModelLoader: Could not load model << models/test/test.ase

 

Apparently DR doesn't like when material id's start at zero. So I opened the file in a text editor and changed...

 

	*MATERIAL 0 {

 

... to ...

 

	*MATERIAL 1 {

 

... and it loaded up without error but not without problems. It appears the normals are inverted and I don't see a texture applied.

 

Oh well I'll sort the bugs out soon enough. Thanks for testing it.

Link to comment
Share on other sites

I've updated the script. The link in the first post has changed.

 

The normals for brushes were inverted and UV coordinates were flipped along the V axis. This along with the "No ASE material exists with id 1" error has been corrected.

 

I have discovered one other issue with textures that I will need to address but the script is mostly functional in it's current state.

 

It seems Doom 3 does not handle textures applied per face. Instead it falls back to textures applied per object. This isn't an issue with patches as you can't apply multiple textures to them. However, it is possible to texture brushes on a per-face basis.

 

I'll need to revise how I'm handling brushes to account for this. Until that happens everything exported will be using the same texture.

  • Like 1
Link to comment
Share on other sites

@rich: some feedback on the script

 

The Good:

Success in DR! See image. I created the brushes, exported, and immediately reopened as a model in DR 1.3.0. The result is happiness.

post-58-127505776696_thumb.jpg

 

The Bad:

The resulting ASE won't import successfully to Blender 2.5 alpha 2. It is shown as the rectangle (and I had to scale it down immensely). Interestingly, the proper working (give or take) arch model shown is from the previous version of your script. So I guess something busted along the way.

post-58-127505815965_thumb.jpg

 

And a couple of suggestions:

-The export Save dialog doesn't query confirm for overwrite of existing files. Fine as is, but users will have to be really careful not to clobber files of same name. Better if it confirmed (if that's possible).

 

-I was unable to name an exported model with the character "o" in it; apparently the dialog is not trapping some hotkeys used by DR. IOW, attempting to export a model as "bob" resulted in a file named "b.ase", and the console (shortcut for "o") opened up. Interestingly, "s" was not a problem (shortcut for surface inspector), so I'm not sure why it is some hotkeys and not others...

Link to comment
Share on other sites

I'm not too concerned with the Blender import script at the moment but point taken. I'll address the problem once I've got this script in a more finalized state.

 

Adding a confirmation dialog to prevent people from overwriting files won't be an issue.

 

As for the dialog not trapping key presses, that is out of my control. I guess I need to file a Dark Radiant bug report.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • Ansome

      Finally got my PC back from the shop after my SSD got corrupted a week ago and damaged my motherboard. Scary stuff, but thank goodness it happened right after two months of FM development instead of wiping all my work before I could release it. New SSD, repaired Motherboard and BIOS, and we're ready to start working on my second FM with some added version control in the cloud just to be safe!
      · 0 replies
    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
×
×
  • Create New...