SUBSIM Radio Room Forums

SUBSIM Radio Room Forums (https://www.subsim.com/radioroom/index.php)
-   SH4 Mods Workshop (https://www.subsim.com/radioroom/forumdisplay.php?f=219)
-   -   [TEC] Import/export 3D models to/from game using S3D. (https://www.subsim.com/radioroom/showthread.php?t=135177)

skwasjer 04-16-2008 03:42 AM

[TEC] Import/export 3D models to/from game using S3D.
 
See the S3D thread for download info: http://www.subsim.com/radioroom/showthread.php?t=119571


This thread will explain all the settings, how to set up the model (with UV-channels) in 3ds Max, and how to get models back into the game.


Export to WaveFront Object file (.OBJ)
  1. In S3D, select the model you wish to export.
  2. Go to the menu: File > Export > 3D model
  3. Choose the WaveFront Object (*.obj) file filter, and then type a file name to save to (or use the default, suggested name). Click 'Save'.
  4. Before actually saving anything the Export settings dialog will appear. All the settings by default are set to work with 3ds Max. Verify your settings so they look like this screenshot below.

    Note: other 3D studio's may require different settings.

    http://sh4.skwas.net/manual/models/1-export.jpg
  5. Make sure the Save to .UVW radiobutton is checked. If you are using another 3D studio, you probably want to use the other radio button to save extra .OBJ files instead of .UVW files.
  6. In the list view you will see a file name for each map channel that the model contains. Note that the first channel can NOT be deselected. This is the main file which contains both the geometry, as well as the first map channel (diffuse). All the other map channels will use a similar file name as the first one. The added part in the filename indicates it contains the uv-data for channel x. (-uv2 = channel 2, -uv3 = channel 3). You can not change these file names, S3D does this for you.
  7. Click export to save the .OBJ file, each .UVW file (if available), and a .MTL file. Note that you will not be asked to overwrite a file if it already exists. Keep that in mind so that you do not accidentally overwrite a file that you need and haven't backed up.
Import into 3ds Max
  1. Go to the menu: File > Import...
  2. Select the .OBJ file previously exported with S3D and click Open.
  3. Verify your import settings match the screenshot below:

    http://sh4.skwas.net/manual/models/2-max_import.jpg
    • The 'Rotate model' must be unchecked. Otherwise, the model will point upwards.
    • 'Texture coordinates' must obviously be on.
    • The 'Normals' checkbox should be selected. If the to be imported model has normals (interiors do for example, ships don't) this ensures you import them as well. If the model doesn't have them, this option does nothing, so it's best to leave it on.
    • 'Use materials' must be on, but you don't have to specify the actual file.
  4. Click OK to import the model.
  5. Press render and see if you get the model rendered properly using the diffuse map. Sometimes, S3D has problems finding the correct texture, or exports a texture file name with extension .TGA, but the game may only have a .DDS. In this case, the render will fail. You should correct the materials and point them to the right texture yourself in this case.
  6. To add extra UV-data to the model do the following steps, for EACH next map channel:
    1. Select the imported model
    2. Click the menu Modifiers > UV Coordinates > Unwrap UVW. A new 'Unwrap UVW' modifier is added to the modifier stack.
    3. In the parameters of the new modifier, change the map channel to the index you are about to add. If you have previously exported -uv2, set map channel 2, etc.

      http://sh4.skwas.net/manual/models/3-unwrapUVW.jpg
    4. After changing the map channel, you will be asked:

      http://sh4.skwas.net/manual/models/4-confirmUVW.jpg

      Click 'Yes'
    5. Now click the 'Load' button, just above the field where you changed the map channel. You can now select the .UVW file that you want to load into this map channel.
    6. All that you have to do now, is modify the materials that come with the model, and include extra texture maps that use the newly imported map channel data. If you have come this far, you probably know how to do this yourself so I'll leave this out of this walkthrough.
That's it. Model import with S3D is posted below, and the steps are pretty much similar. Just reversed.

Now, if you don't have 3ds Max, or want to try the alternative approach using extra OBJ-files per map channel, the idea is similar. Import the main OBJ-file into the scene. Then, one by one, import each next OBJ-file (with the next map channel). Copy the UVW-data from the 2nd imported OBJ-file to the original model, and once you're done delete the extra models.

If anyone wants to write a guide for other 3D software, please do!

skwasjer 04-16-2008 03:43 AM

To import a 3D model in the game, the steps are similar to my previous post, but this time, we move in reverse.

I'm assuming you have collapsed the modifier stack, and/or created new map channels or changed uv-data in 3ds Max.


Export to WaveFront Object file (.OBJ) from 3ds Max

The .OBJ file format can only be used to store one map channel (the 1st one). If our model has more than one channel, we also have to export one or more .UVW files to hold the UV-data for the other channels.

First, we export the .OBJ file. This is pretty simple and you may have done it before, however I'm going to describe it step by step anyway.
  1. Go to the menu File > Export...
  2. Select the WaveFront Object (*.obj) file filter, type a file name, and click 'Save'
  3. Before actually saving anything the OBJ exporter dialog will appear. Verify your settings so they look like this screenshot below.

    Note: other 3D studio's may require different settings.

    http://sh4.skwas.net/manual/models/5-max_export.jpg

    Explanation of settings
    1. 'Use materials' must be enabled. Otherwise, S3D will not know which face uses what material.
    2. 'Create material library' may be enabled. As long as an .MTL exists with the same name as the .OBJ file you can leave this unchecked, but otherwise you should have it checked. If the .OBJ-file is not linked to a .MTL-file, S3D can't import it.
    3. 'Rotate model' should be unchecked
    4. For faces, select 'Triangles'. Both the game and S3D only support this.
    5. We obviously want 'Texture coordinates' checked
    6. Some game models need normals, others don't. My general rule of thumb is to export the normals (so have it checked). S3D will warn you if you replace a model that has no normals with one that does. It also warns you if it is the other way around. In S3D you can decide whether to skip normals as well.
    7. No smoothing groups
    8. # of Digits, set it relatively high. Around 10 is fine. This ensures S3D can optimize the UV table better after loading additional map channels from .UVW/.OBJ files, and also reduces the change for anomolies ingame.
    9. Compress numbers, only affects file size, so 'yes'.
  4. Press 'OK' to save the .OBJ file.
  5. Now, for each additional map channel, we want to export the UV-data. To do this we add a temporary new Unwrap UVW modifier. Select the model. Click the menu Modifiers > UV Coordinates > Unwrap UVW. A new 'Unwrap UVW' modifier is added to the modifier stack.
  6. Now, for each map channel (except the 1st one) follow these steps:
    1. In the parameters of the temporary modifier, change the map channel to the index you want to export. By default the 1st channel is specified, but we don't need to export this channel (it's already in the .OBJ file). So change the channel to 2, 3, etc.

      http://sh4.skwas.net/manual/models/3-unwrapUVW.jpg
    2. After changing the map channel, you will be asked:

      http://sh4.skwas.net/manual/models/4-confirmUVW.jpg

      Click 'Yes'. The changes that are lost are not the actual UV-data, so don't worry about the message too much.
    3. Click the 'Save' button, just above the field where you changed the map channel.
    4. Specify the filename where you want to save the UVW-data to. It is important that you use the exact filename together with a postfix indicating the map channel. For example, if the .obj file saved earlier is saved as test.obj, for channel 2 append '-uv2' to the filename to make test-uv2.uvw, for channel 3 append '-uv3' to the filename to make test-uv3.uvw, etc. This is VERY important, otherwise S3D won't find the files.
    5. Once you have saved the map channel, move back to the first step for additional map channels. You can reuse this temporary modifier for all channels.
  7. Once done, delete the modifier. Now, we are done in 3ds Max and can import the model into the game
Import into game with S3D
  1. Open the .DAT file and select the model which you want to replace.
  2. Go to the menu: File > Import > 3D model
  3. Choose the WaveFront Object (*.obj) file filter, and select the .OBJ file you want to import. Click 'Open'.
  4. The .OBJ file is now quickly scanned for available objects, after which the Import settings dialog will appear. All the settings by default are set to work with 3ds Max. Verify your settings so they look like this screenshot below.

    Note: depending on the 3D studio used to export, different settings may be required.

    http://sh4.skwas.net/manual/models/6-import.jpg

    Explanation of settings
    1. Import texture coordinates, yes
    2. Import vertex normals checked. If the model you are about to replace contains no normals, and the model you are to import does, you will receive a warning (and you may choose to skip).

      http://sh4.skwas.net/manual/models/7-normalwarning1.jpg

      If the opposite is true, you will also receive a warning.

      http://sh4.skwas.net/manual/models/8-normalwarning2.jpg

      If you know for sure no normals are needed, you may uncheck this option. But it's easier to leave it enabled so you don't forget about this and get the warnings.
    3. Flip coordinate system must be true to flip the Y/Z axes.
    4. Face winding should be left as is.
    5. 'Use materials' must be checked so S3D knows which faces use which material.
    6. If the .OBJ file contains more than one object, select the one you want to import.
    7. If you have exported .UVW files from 3ds Max, you must select the first radio button. If you have exported additional .OBJ files, select the 2nd radiobutton.
  5. Before clicking 'OK', verify all the required map channels are listed in the list view. Now, click 'OK'.
  6. S3D will be crunching some numbers, and that's about it. Model imported. Save, enable mod and test in game!
For those that don't use 3ds Max, and want to use additional .OBJ files to import the extra UV-channels, the methods are similar. Just save an OBJ-file for each map-channel (you must copy the UV-data to the 1st channel before exporting), and follow the 'Import into game with S3D' steps above.

keltos01 04-16-2008 05:31 AM

error : an item with the same key has already been added
 
what is this ? when I try to export my ijn tower

http://img227.imageshack.us/img227/2...eycopieut3.jpg

skwasjer 04-16-2008 05:42 AM

heh, the first bug, but uhm, I'm noticing TWO channels with index 1. That is WRONG. Somewhere along the line that model got fubared. Did you import it with S3D as well (I doubt it, it shouldn't allow this to happen), or have you imported it previously with Pack3D? If yes, then it's not really S3D's fault.

Send me the .DAT, I can try to provide a 'graceful' workaround/warning...

keltos01 04-16-2008 05:44 AM

out of range
 
when I tried to export the torpedo typ V 3d model (to modify into a Kaiten) :
http://img234.imageshack.us/img234/7...e1copiezf7.jpg

keltos01 04-16-2008 05:45 AM

fubar
 
I can email you the .dat, pm me where I should , and thanks !

skwasjer 04-16-2008 05:49 AM

Check the 'About box' in S3D ;)


Don't let these errors put anyone down, plenty of models do work, and maybe these are odd scenario's. I've tested dozens of models myself, and it worked for me every time. I'll have a look at these issues asap...

skwasjer 04-16-2008 05:54 AM

Btw, I've just exported all the torpedoes succesfully myself (stock 1.5). Send me that .DAT as well, because its obviously a modded one. And by the looks of that shot, the stock torpedoes don't have a map channel 3, so that model must be fubared as well... You are probably doing something wrong here or using tools that corrupt the models (this may be S3D as well of course, but I can't put a finger on it).

[edit] Come to think. I think you have used the raw chunk import/export functionality incorrectly. Some of the settings for this are a bit of a black box and I suspect you have those settings wrong. I have posted a walkthrough for this some time ago as well, I'll look it up

PS: please put bug reports in S3D thread, not here...

Xantrokoles 04-16-2008 07:05 AM

Skwasjer, you are the best!

We Germans really underrated u Dutsch!:p

Keep up this great job:up:

Anvart 04-17-2008 04:40 AM

I think, that this stuff is not new for Skwasjer, but for other people it can be useful...
Limited WaveFront Obj format:
common http://www.fileformat.info/format/all.htm
http://www.faqs.org/faqs/graphics/fi...rt3/index.html ... but i can't :nope:
http://www.royriggs.com/obj.html
http://en.wikipedia.org/wiki/Obj
http://en.wikipedia.org/wiki/MeshLab
http://www.martinreddy.net/gfx/3d/OBJ.spec (more seriouse) ... ;)
the same http://orion.math.iastate.edu/burkar...obj_format.txt
something with ObjLib http://www.cs.kuleuven.ac.be/~ares/l...1/doc/OBJ.spec
............................. http://www.cs.kuleuven.ac.be/~ares/libobj/index.html
may be ... or not ... http://www.fileformat.info/format/wavefrontobj/
not bad http://www.okino.com/conv/imp_wave.htm
;) 4u http://www.wotsit.org/list.asp?fc=2
http://www.nacse.org/~moorchri/vwrl/...mat_specs.html for Java 3D, but ... as example ...
for other cases ... http://www.filedudes.com/OBJ_Import_...oad-31719.html
??? :o http://obj.alienpicks.com/
... and so on ...

skwasjer 04-17-2008 07:08 AM

Yea nice :up:

There's alot of useful resources available online regarding the OBJ-format. I have used some of those 'old' pages myself many years back as well :smug:

AVGWarhawk 04-17-2008 11:58 AM

Nice work!! Your editor has saved a lot of time for the modders. Hats off!

LukeFF 04-29-2008 01:44 PM

I just followed this procedure to export a ship model, and 3DS Max is telling it cannot import it. Is there something I'm doing wrong?

http://img.photobucket.com/albums/v2...FF/SH4/S3D.jpg

skwasjer 04-29-2008 07:07 PM

By the looks of the settings, no. I will need to know which ship model you tried, and if it's a modded one, I also need the dat-file. I can't verify it otherwise.

LukeFF 04-29-2008 09:45 PM

Quote:

Originally Posted by skwasjer
By the looks of the settings, no. I will need to know which ship model you tried, and if it's a modded one, I also need the dat-file. I can't verify it otherwise.

It's the Kinposan, one of the stock ships.


All times are GMT -5. The time now is 11:00 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 1995- 2019 Subsim