Skip to content

Commit

Permalink
Merge branch 'develop' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mauserzjeh committed May 22, 2022
2 parents d27f1c0 + 2b91385 commit 9c079f9
Show file tree
Hide file tree
Showing 27 changed files with 482 additions and 197 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
__pycache__/
.vscode
tests/
release/
tests/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "iwi2dds"]
path = iwi2dds
url = [email protected]:mauserzjeh/iwi2dds.git
123 changes: 60 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,74 @@
# Call of Duty asset importer
![GitHub release (latest by date)](https://img.shields.io/github/v/release/mauserzjeh/cod-asset-importer?style=flat-square)
![GitHub all releases](https://img.shields.io/github/downloads/mauserzjeh/cod-asset-importer/total?color=green&style=flat-square)

# Call of Duty asset importer
Blender add-on for importing various Call of Duty assets via the game files.

## Examples
### D3DBSP
<img src="./examples/d3dbsp1.png?raw=true" width="500" height="auto"></img>
<br/>
(overlapping faces and some of the materials need fixes)
<br/>
<br/>

### XModel
<img src="./examples/xmodel1.png?raw=true" width="500" height="auto"></img>
<br/>
<br/>

### IWi
<img src="./examples/iwi1.png?raw=true" width="250" height="auto"></img>
<img src="./examples/iwi2.png?raw=true" width="250" height="auto"></img>
<br/>
<br/>

## Supported assets & features
- Call of Duty 2
- D3DBSP - Compiled map files
- Geometry
- Materials and textures
- Props
- XModel - Compiled models
- Geometry
- Materials and textures
- Skeleton & weights
- Texture - IWi texture
- Texture import
- DXT1, DXT3, DXT5 decoding
- Normal map generation from bump map

<br/>
<br/>
## Installation & setup
First of all, extract all the necessary contents of the .iwd files. Make sure to have the exact same folder structure as they have inside the .iwds.
```
.
├── images/
├── maps/
├── materials/
├── xanim/
├── xmodel/
├── xmodelalias/
├── xmodelparts/
└── xmodelsurfs/
```

- [Download the latest release](https://github.com/mauserzjeh/cod-asset-importer/releases/latest)
- Launch Blender
- `Edit > Preferences > Add-ons > Install`
- Browse to the downloaded .zip file
- Enable the addon by ticking the checkbox in front of its name

## Usage
- Launch Blender
- To see import progress, information and errors
- `Window > Toggle System Console`
- To import a map
- `File > Import > Call of Duty map (d3dbsp)`
- Browse to the map inside the maps folder
- To import a model
- `File > Import > Call of Duty model (xmodel)`
- Browse to the xmodel inside the xmodel folder

## Installation from source

### Requirements
- [Git](https://git-scm.com/)
- [Python 3.8 <=](https://www.python.org/)
- [Go 1.18 <=](https://go.dev/)

### Installation
- Open Git Bash in the folder where you would like to clone the repository
- Clone the repository
```
$ git clone --recurse-submodules [email protected]:mauserzjeh/cod-asset-importer.git
```

- Go to the release folder
```
$ cd cod-asset-importer/release
```

# How to use
## Installation and setup
- Extract the contents of all the .iwd files into a folder
- The folder structure of the extracted assets should look the same as below and mainly these are the most important folders which are required for the add-on to work properly
- Run the release script which will compile iwi2dds.exe and pack all the necessary files into a .zip
```
$ ./release.sh
```

- ```
.
├── images
├── maps
├── materials
├── xanim
├── xmodel
├── xmodelalias
├── xmodelparts
└── xmodelsurfs
```
- Install the add-on for Blender
- Click on Edit and select Preferences
- Click on the Add-ons tab and click on the Install button
- Browse to the .zip file containing the add-on and then click on the Install Add-on button
- If everything is done right, import options should be available in File > Import menu
- Launch Blender
- `Edit > Preferences > Add-ons > Install`
- Browse to the generated .zip file in the release folder
- Enable the addon by ticking the checkbox in front of its name

<br/>
<br/>

## Importing assets
- Click on File menu point and go to the Import menu
- Select Call of Duty map if you would like to import a map
- Browse to the map in the maps folder
- Select Call of Duty xmodel if you would like to import any model
- Browse to the model in the xmodel folder
- Select Call of Duty texture if you would like to import any texture
- Browse to the texture in the images folder
- Set the "Normal map" checkbox to true if you are importing a normal map


Binary file removed examples/d3dbsp1.png
Binary file not shown.
Binary file removed examples/iwi1.png
Binary file not shown.
Binary file removed examples/iwi2.png
Binary file not shown.
Binary file removed examples/xmodel1.png
Binary file not shown.
1 change: 1 addition & 0 deletions iwi2dds
Submodule iwi2dds added at 801aca
1 change: 1 addition & 0 deletions release/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.zip
19 changes: 19 additions & 0 deletions release/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from zipfile import ZipFile
import glob
import os


src = os.path.join(os.pardir, 'src')
cod_asset_importer = 'cod_asset_importer'

with ZipFile('cod_asset_importer.zip', 'w') as zip:
for file in glob.iglob(os.path.join(src, '*.py')):
zip.write(file, os.path.join(cod_asset_importer, os.path.basename(file)))

folders = ['addon', 'assets', 'utils']
for folder in folders:
for file in glob.iglob(os.path.join(src, folder, '*.py')):
zip.write(file, os.path.join(cod_asset_importer, folder, os.path.basename(file)))

zip.write(os.path.join(src, 'bin', 'iwi2dds.exe'), os.path.join(cod_asset_importer, 'bin', 'iwi2dds.exe'))
zip.write(os.path.join(os.pardir, 'LICENSE'), os.path.join(cod_asset_importer, 'LICENSE'))
6 changes: 6 additions & 0 deletions release/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

cd ../iwi2dds
go build -o ../src/bin/iwi2dds.exe
cd ../release
python release.py
20 changes: 11 additions & 9 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"name": "Call of Duty Asset Importer",
"description": "Import various Call of Duty assets",
"author": "Soma Rádóczi",
"version": (0, 0, 1),
"blender": (2, 93, 0),
"version": (2, 0, 0),
"blender": (3, 0, 0),
"location": "File > Import/Export",
"category": "Import-Export",
"warning": "This addon is still in development",
Expand All @@ -24,27 +24,29 @@
"text": "Call of Duty model (xmodel)",
"function": None
},
{
"class": operators.IWiImporter,
"text": "Call of Duty texture (iwi)",
"function": None
}
)


"""
creates a menu function
"""
def menu_function(cls: object, text: str) -> callable:
def menu_func(self, context):
self.layout.operator(cls.bl_idname, text = text)

return menu_func

"""
registers operators into blender
"""
def register():
for operator in operators_list:
bpy.utils.register_class(operator["class"])
operator["function"] = menu_function(operator["class"], operator["text"])
bpy.types.TOPBAR_MT_file_import.append(operator["function"])


"""
unregisters operators from blender
"""
def unregister():
for operator in reversed(operators_list):
bpy.utils.unregister_class(operator["class"])
Expand Down
Loading

0 comments on commit 9c079f9

Please sign in to comment.