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

0 Members and 2 Guests are viewing this topic.

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #140 on: November 11, 2010, 09:23:36 am »
Check my edits above. I think I have it sorted.

"VTX header" (actually, whole block):
Code: [Select]
    modVtxTag, \
    modVtxSize \
    = struct.unpack("<4si", file.read(8))
    modVtxStart = file.tell() 
    print ("modVtxTag: " + modVtxTag.decode("ascii"))
    print ("modVtxSize: %d" % modVtxSize)
   
    modVtx = list()
    while (file.tell() - modVtxStart < modModVerticesNum*12):
        modVtx.append(struct.unpack("<fff", file.read(12)))
    print ("modVtx: ")
    print (modVtx)

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #141 on: November 11, 2010, 09:27:56 am »
Lol, see, I still have the vertices*12 in there when it can just be the size read from the same VTXS block instead of the number of verts stored in the parent geometry block. Lots of redundancy in this file format.

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 #142 on: November 11, 2010, 09:32:21 am »
'tis looks right to me.  does this seem to read it all or missing some still?
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 #143 on: November 11, 2010, 09:42:08 am »
Lol, see, I still have the vertices*12 in there when it can just be the size read from the same VTXS block instead of the number of verts stored in the parent geometry block. Lots of redundancy in this file format.

it has redundancies but it also allows the skipping of any part you want because it store the size of each block.  Thus you can just skip over if you don't want that information now.
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 #144 on: November 11, 2010, 09:44:55 am »
now myself, instead of checking where in the file I am to see if I read anough, I might have gone with a counter and counted the number of verts read in instead.
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 #145 on: November 11, 2010, 09:59:17 am »
Have fun Bonk, I'm off to work (2nd job).  Looking forward to seeing how you have done.
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 #146 on: November 11, 2010, 10:02:19 am »
I'm more of a "start at the beginning and when you come to the end, stop" kind of guy... (very procedural and not so o.o)

I have the all the blocks sorted out, now just to loop through each LOD properly and I'll have all the data to build the model.

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #147 on: November 11, 2010, 10:05:12 am »
now myself, instead of checking where in the file I am to see if I read anough, I might have gone with a counter and counted the number of verts read in instead.

I went with this option oddly only to avoid the inadequacies of the for control structure in python (or until I grasp what they call.. umm "List Comprehensions"... yeah that's it... possibly where I will end up for a control structure)

Oh right I suppose I  can count manually in each loop, I suppose that would be more efficient than calling back the file position? (maybe not though, as the var is already there, why create another to store the same info...? - as I expect the file.tell function just returns the position value, nothing more...)

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Blender to .mod scripts are there any working?
« Reply #148 on: November 11, 2010, 12:21:58 pm »
Almost got all the data in... I am having to count manually in places as I loop through because of variable object sizes. ;)  Just the LOD loop left.

Though after the trouble I went to to parse the strings out, they're probably best left as a bytestring blob since the named points and polies reference them by hex offset. Easy enough.
« Last Edit: November 11, 2010, 12:34:59 pm 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 #149 on: November 11, 2010, 12:50:59 pm »
would agree with the byteblob thingie.  Would probably be easier to reference that way.

Now also, add in a check to make sure that each block is actually there.  Since you can't be sure if each block will be used (that way you don't just eat the head of the block and assume it is the one you want, never want to assume)
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 #150 on: November 11, 2010, 01:58:35 pm »
Alrighty Bonk + Marstone,

Here is a basic no-nonsense MOD file. It has a single object in it - a cube. I have listed up the XYZ, UVW, and Material data that is involved in it.

Code: [Select]
XYZ coordinates
------------------
[-50,-50,0]
[50,-50,0]
[-50,50,0]
[50,50,0]
[-50,-50,100]
[50,-50,100]
[-50,50,100]
[50,50,100]

UVW coordinates
-----------------
[33.9291,66.0709,0]
[66.0709,66.0709,0]
[33.9291,33.9291,0]
[66.0709,33.9291,0]
[1,66.8582,0]
[33.1418,66.8582,0]
[1,99,0]
[33.1418,99,0]
[33.9291,1,0]
[66.0709,1,0]
[33.9291,33.1418,0]
[66.0709,33.1418,0]
[66.8582,1,0]
[99,1,0]
[66.8582,33.1418,0]
[99,33.1418,0]
[33.1418,33.9291,0]
[1,33.9291,0]
[33.1418,66.0709,0]
[1,66.0709,0]
[33.1418,1,0]
[1,1,0]
[33.1418,33.1418,0]
[1,33.1418,0]

Face 1, 2, and 3 use MatID 1
Face 4, 5, and 6 use MatID 2

Material = Super_Mat
 - Submaterial 1 = Material_Able
 - - Diffuse Map = Map_Yankee
 - Submaterial 2 = Material_Baker
 - - Diffuse Map = Map_Zulu
 - - Self-Illumination Map = Map_Whiskey

Let me know if there is more information you need or if you want a specific criteria in another MOD file.
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 #151 on: November 11, 2010, 02:12:53 pm »
could you save it in a 3DS format also for a comparing how to import it?
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 #152 on: November 11, 2010, 02:14:44 pm »
You're going to have to fix the texture name, but here it is :)
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 #153 on: November 11, 2010, 02:15:41 pm »
Now also, add in a check to make sure that each block is actually there.  Since you can't be sure if each block will be used (that way you don't just eat the head of the block and assume it is the one you want, never want to assume)

Right. I think the only block that could be missing from a model is the named points block? Or how about a model with no textures? A few samples of those kind of variations would be good.

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 #154 on: November 11, 2010, 02:16:51 pm »
Forgive the ignorance, but what is a Named Points block?
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 #155 on: November 11, 2010, 02:21:34 pm »
Thanks FoaS! :thumbsup:

5 LOD transitions but only one mesh? (are those 3ds max exporter defaults perhaps) LOD count is right though

My decoding choked on the materials flags... (not sure why, the file is probably fine) I think because I'm not adding the flags up right...

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 #156 on: November 11, 2010, 02:22:01 pm »
No LODs in that model.
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 #157 on: November 11, 2010, 02:22:56 pm »
the named points are the hardpoints and hit locations on the ship. IIRC
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 #158 on: November 11, 2010, 02:23:57 pm »
k, rgr that. That MOD also does not have hardpoints or hit locations - Tried to keep it as simple as possible. I can add or remove stuff as you'd like. Want a no-texture version?
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 #159 on: November 11, 2010, 02:25:44 pm »
the named points are the hardpoints and hit locations on the ship. IIRC

Yes.

k, rgr that. That MOD also does not have hardpoints or hit locations - Tried to keep it as simple as possible. I can add or remove stuff as you'd like. Want a no-texture version?

A whole buncha variations would be awesome if it is not too much trouble. With this... without that...