Topic: Blender to .mod scripts are there any working?  (Read 33005 times)

0 Members and 1 Guest are viewing this topic.

Offline FoaS_XC

  • Photorps, Sammiches, woot woot.
  • Global Moderator
  • Commander
  • *
  • Posts: 4571
  • Gender: Male
    • Robinomicon
Re: Blender to .mod scripts are there any working?
« Reply #200 on: November 15, 2010, 05:47:23 pm »
Quote
I may end up using bones as in milkshape... what object are hardpoints labelled from in max again?

Dummy objects.
Robinomicon
"When I was 5 years old, my mom always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down “happy.” They told me I didn’t understand the assignment and I told them they didn’t understand life."

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #201 on: November 15, 2010, 06:01:56 pm »
Cool... I'll play with both solutions later.

For now the sheild.mod is rather interesting. It choked my import script. The PNTS block is present but empty!  :o  (edit: oh wait, not such a shock... its a sheild needs no named points... and the script only chokes cuz I try and print the last one...)
Quote
C:\Users\user\Documents\blender255\shield\shield.mod
modHdrTag: MDLS
modHdrFileSize: 37900
modHdrVersion: 512
modHdrRadius: 7.383409
modHdrTotalLODs: 1
modHdrLODHyst: 5.000000
modHdrLODTrans:
(0.0, 45.0, 90.0, 135.0, 180.0)
modChnkTag: STRS
modChnkSize: 1
modStrSizePadded: 4
modStrList:
['', '', '', '', '']
modChnkTag: MATS
modChnkSize: 28
modMtsFlags:
['000010']
(last)modMts:
(4282895360, 0.0, 0.0, 0.0, 0, 0)
modChnkTag: PNTS
modChnkSize: 0
modPtsNum: 0
(last)modPts:
Traceback (most recent call last):
  File "Text", line 262, in execute
  File "Text", line 97, in import_mod
IndexError: list index out of range

One material flagged as gourad shaded, that's it. No texture...? (empty strings confirms)

but that first value in the materials structure which I thought was the "COLORREF" (bit depth?) which I was reading as an unsigned int but it appears to be a float? Though I'm looking at some color structures defined in the max3 importer ... hmmm marstone might be able to figure that one... I think it might be an RGB value stored oddly...
« Last Edit: November 15, 2010, 06:12:52 pm by Bonk »

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #202 on: November 15, 2010, 06:31:15 pm »
I think that COLORREF structure miust be defined in the max API... good lord... where am I going to find a copy of the max3 api? I might get lucky with the right google search...

Looking at that additive teapot naturally makes me think Thol.  :)  But I don't think we should get our hopes up... bah enough speculation... I'll set the flag on a material and test it in game here at some point...

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #203 on: November 15, 2010, 09:08:43 pm »
Oh yeah, the Max3 .mod import code I am working from... (posted elsewhere too I think... and the max4 code should be out there somewhere...) ... as mentioned. (I think the gmax one was compiled from the max4 code with a few tweaks)




Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Blender to .mod scripts are there any working?
« Reply #204 on: November 15, 2010, 11:57:29 pm »
Colorref should be a color mask/format that the color for the image is in. I haven't found where in the code it is used tho beyond being read in (will look more). will look more to see if it is something in the format but not implemented.
The smell of printer ink in the morning,
Tis the smell of programming.

Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Blender to .mod scripts are there any working?
« Reply #205 on: November 16, 2010, 12:15:51 am »
Looking in the export code. They use the rgb function to set fcolor so it is a mask for the color in the image and probably not used as the set it to 24 bit color in the code and our modders say they can't get the engine to use it.

*edit*
Looking deeper in export code. They just flat set all fcolor the same so probably not used in the engine.
The smell of printer ink in the morning,
Tis the smell of programming.

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #206 on: November 16, 2010, 06:16:21 am »
I'd buy that except for the different value in the shield.mod... as up till then it was like 16million in all the files I looked at so I assumed it was a colour depth value. But the sheild.mod value makes no sense by that interpretation. I have this sneaking suspicion that it is a colour mask stored as an RGB uchar triplet encoded into 4 bytes. Or something like that... a feature used in the game engine but not implemented for user built models.

I guess I better start looking at the exporter code too.

I can probably get the model textured skipping some of this unknown stuff, but I want to figure out as much as I can about the format and how it works. If we're going to do a set of import/export scripts I want it done right. Blender has a future. But we have limitations so we'll do the best we can.

Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Blender to .mod scripts are there any working?
« Reply #207 on: November 16, 2010, 06:30:32 am »
Well, that is what it is. It is a color mask, but the exporter (at least for 3ds v3 just uses the same mask so it should be 0xFFF0. Maybe some exporters do it differently.
The smell of printer ink in the morning,
Tis the smell of programming.

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #208 on: November 16, 2010, 07:02:13 am »
Interesting. Thanks for the input. I got all excited when I got the mesh up, but man, slogging through this part is slow...

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #209 on: November 16, 2010, 07:29:16 am »
More awake now. second coffee... I see... the 3ds exported .mods will have it set to FF FF FF 00 ...(255,255,255,0) (RGB white - but the fourth byte...?) makes sense I guess.

The fColor value for the one material in shield.mod:  00 CC 47 FF  .... well now what's that fourth byte... alpha? saturation? (0,204,71,255) does that make sense as a colour mask for the shield?

Is there something different about the packing of that mod? While the control.mod that FoaS gave me does not choke my script the shield mod does... and neither have named points.. hmmm... aha it is different... it appears the max exporter does not create an empty PNTS block if there are no named points... yet the shield .mod has one. Conclusion: created with different/earlier/manual tools.

Ahh... versions... I've been looking at OP models exclusively... I should start throwing stock EAW and SFC1 .mods in the testing mix... I'll learn more. I bet the sheild.mod is an EAW/SFC1 carryover...

Waiiit a minute.... release dates... Max3 vs Max4 vs SFC1/EAW/OP ... I think I need to establish the timeline relationship.
« Last Edit: November 16, 2010, 07:46:22 am by Bonk »

Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Blender to .mod scripts are there any working?
« Reply #210 on: November 16, 2010, 07:48:44 am »
Ah, if it is from that early then it might have format options that have been changed or tweeked as the game developed.
The smell of printer ink in the morning,
Tis the smell of programming.

Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Blender to .mod scripts are there any working?
« Reply #211 on: November 19, 2010, 02:21:14 am »
Grr, back to the problem I had last time. Wrapping my head around how blender holds materials and textures internally.

I can get the information from the .mod file but need to get it into the blender structures (haven't found the structure layouts in the manual pages yet). Got some of it down but just anough to be confusing. More reading and searching to go. 
The smell of printer ink in the morning,
Tis the smell of programming.

Offline FoaS_XC

  • Photorps, Sammiches, woot woot.
  • Global Moderator
  • Commander
  • *
  • Posts: 4571
  • Gender: Male
    • Robinomicon
Re: Blender to .mod scripts are there any working?
« Reply #212 on: November 19, 2010, 03:57:37 am »
Now there I cannot help you
Robinomicon
"When I was 5 years old, my mom always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down “happy.” They told me I didn’t understand the assignment and I told them they didn’t understand life."

Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Blender to .mod scripts are there any working?
« Reply #213 on: November 19, 2010, 04:30:36 am »
Yeah, I know. If the programmers done a good job, it all should be hidden behind the interface from artists.

If I can't find it in the docs might have to download the source and find it there. But I have faith they documented the api somewhere.

Other option is to go into the scripting interface while running blender and check the structures there, bleh.
The smell of printer ink in the morning,
Tis the smell of programming.

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #214 on: November 19, 2010, 07:11:01 am »
Ah uhndastand. That's pretty much where I'm at.  Slowly getting it lined up with stuff like:

Code: [Select]
    # new mesh, vertices and faces
    mod_obj = bpy.data.meshes.new(name)
    mod_obj.vertices.add(modMeshes[0][0])
    # print (modMeshes[0][0])
   
    mod_obj.vertices.foreach_set("co", modMeshes[0][2])
    # mod_obj.vertices.foreach_set("normal", modMeshes[0][2])
   
    # print (modMeshes[0][2])
    mod_obj.faces.add(modMeshes[0][1])
    # print (modMeshes[0][1])
    # mod_obj.faces.foreach_set("vertices_raw", modMeshes[0][4])
    mod_obj.faces.foreach_set("vertices", modMeshes[0][4])
 

    i = 0
    for Mtl in modMts[:]:
        matdata = bpy.data.materials.new("mat")
        # Color,fAmbient,fDiffuse,fEmittance,TexID,TexNameOffset(,TexID,TexNameOffset)
        matdata.ambient = Mtl[1]
        matdata.diffuse_intensity = Mtl[2]
        matdata.emit = Mtl[3]
        # matdata.active_texture
        # matdata.texture_slots
        if modMtsFlags[i][5] == "1":
            texdata = mod_obj.uv_textures.new()
            texdata.uv = *tough part goes here*
            matdata.active_texture = texdata
        mod_obj.materials.append(matdata)
        i += 1
       
    # mod_obj.faces.foreach_set("material_index", modMeshes[0][3])
    # mod_obj.faces.foreach_set("normal", modMeshes[0][4])

I think at a certain point the knowledge will snowball and we'll get it.

http://www.blender.org/documentation/250PythonDoc/contents.html  (docs I've been using for 2.55 - need to drill down many layers end up with dozens of tabs open)

Links to info on scripting in both versions:
http://wiki.blender.org/index.php/Extensions:Py/Scripts

The 2.5 docs seem to be more user-friendly. I've been spending a lot of time here:
http://www.blender.org/documentation/250PythonDoc/bpy.types.Mesh.html#bpy.types.Mesh
and here:
http://www.blender.org/documentation/250PythonDoc/bpy.types.MeshTextureFace.html#bpy.types.MeshTextureFace

Yeah, I know. If the programmers done a good job, it all should be hidden behind the interface from artists.

Interestingly, in 2.55 almost every single UI element has a tooltip popup that describes the relevant python object - not much use to me yet as the script has not come that far, but for UI interaction and debuggin it might be nice...

2.5 also makes dumping script debug data easier...
Code: [Select]
print(dir(bpy.data)).meshes
.materials
.textures... etc.
« Last Edit: November 19, 2010, 07:38:49 am by Bonk »

Offline Scottish Andy

  • First Officer of the Good Ship Kusanagi
  • Lt. Commander
  • *
  • Posts: 1086
  • Gender: Male
  • New and improved.
    • Starbase 23
Re: Blender to .mod scripts are there any working?
« Reply #215 on: February 02, 2012, 11:27:27 am »
Hello all,

I've started playing around with Blender and I still have my Milkshape. I was wondering if Blender has the ability to import SFC's .MOD files? I am not interested in exporting a Blender model into .MOD for playing in the game, but I would like to compose gorgeous Hi-Res shots of some of the gorgeous and inspired models created for this game.

Thanks.
Come visit me at:  www.Starbase23.net

The Senior Service rocks! Rule, Britannia!

The Doctor: "Must be a spatio-temporal hyperlink."
Mickey: "Wot's that?"
The Doctor: "No idea. Just made it up. Didn't want to say 'Magic Door'."
- Doctor Who: The Woman in the Fireplace (S02E04)

2288

Offline Kreeargh

  • Retired.
  • Lt. Commander
  • *
  • Posts: 1476
  • Gender: Male
  • Life is as is worth only what you learn from it!
Re: Blender to .mod scripts are there any working?
« Reply #216 on: February 02, 2012, 11:50:18 pm »
Hello all,

I've started playing around with Blender and I still have my Milkshape. I was wondering if Blender has the ability to import SFC's .MOD files? I am not interested in exporting a Blender model into .MOD for playing in the game, but I would like to compose gorgeous Hi-Res shots of some of the gorgeous and inspired models created for this game.

Thanks.
Sad to say but It dont work, not yet that I know about. With hope and the all mighty coder soon will be a real issue?!!!???
Time for life!

Offline marstone

  • Because I can
  • Commander
  • *
  • Posts: 3014
  • Gender: Male
  • G.E.C.K. - The best kit to have
    • Ramblings on the Q3, blog
Re: Blender to .mod scripts are there any working?
« Reply #217 on: February 03, 2012, 02:00:52 am »
yeah, sorry.  I was working on the blender script to import .mod.  Ran into stuff I couldn't figure out at the time (how to do the textures on import).  I got it so it will bring in the mesh, but doesn't have the texture on it yet.

Have lots of projects being worked on will see if I can get back on this one in the near future, but can't say when.
The smell of printer ink in the morning,
Tis the smell of programming.

Offline atheorhaven

  • Lt. Commander
  • *
  • Posts: 1770
    • Mare Imbrium Shipyards
Re: Blender to .mod scripts are there any working?
« Reply #218 on: February 05, 2012, 09:20:29 pm »
yeah, sorry.  I was working on the blender script to import .mod.  Ran into stuff I couldn't figure out at the time (how to do the textures on import).  I got it so it will bring in the mesh, but doesn't have the texture on it yet.

Have lots of projects being worked on will see if I can get back on this one in the near future, but can't say when.

If it will bring in the mesh, does it also retain the UV mappings, or are they stripped with the textures?

And as a thought, I don't suppose comparing the plugins for something that may be more complete (.3ds maybe?) for Blender against a similar import script for Max or Milkshape would help?  And I don't suppose anyone still has Chris' (Assimsoft's) old import/export stuff (AssimView) around anymore?  Darkdrone?  :)
..ooOOoo..totally useless information..ooOOoo..

Mare Imbrium Shipyards - http://mareimbrium.webhop.net

Don't bother checking out my website for the most recent updates, because I've
been too lazy to update it!  Check Battleclinic!

Offline Kreeargh

  • Retired.
  • Lt. Commander
  • *
  • Posts: 1476
  • Gender: Male
  • Life is as is worth only what you learn from it!
Re: Blender to .mod scripts are there any working?
« Reply #219 on: February 05, 2012, 10:33:25 pm »
yeah, sorry.  I was working on the blender script to import .mod.  Ran into stuff I couldn't figure out at the time (how to do the textures on import).  I got it so it will bring in the mesh, but doesn't have the texture on it yet.

Have lots of projects being worked on will see if I can get back on this one in the near future, but can't say when.

If the mesh is importing all good!  :notworthy: :thumbsup: Gmax or milkshape can map the model if needed.
What Type of mesh was tested tris or quads?   
Import blender to .mod more usefull than the export from.mod .
« Last Edit: February 06, 2012, 12:10:58 am by Kreeargh »
Time for life!