Skip to content

Commit

Permalink
Elu models, custom normals, logging, formatting, version code, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Krunklehorn committed Apr 21, 2022
1 parent 2aa192c commit fed19c6
Show file tree
Hide file tree
Showing 7 changed files with 1,008 additions and 114 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ Please report bugs and unimplemented features to: ***Krunk#6051***

RaGEZONE thread: ***https://forum.ragezone.com/f496/io_scene_gzrs2-blender-3-1-map-1204327/***

[***DOWNLOAD v0.8.1***](https://github.com/Krunklehorn/io-scene-gzrs2/releases/download/v0.8.1/io_scene_gzrs2_v0.8.1.zip)
[***DOWNLOAD v0.8.2***](https://github.com/Krunklehorn/io-scene-gzrs2/releases/download/v0.8.2/io_scene_gzrs2_v0.8.2.zip)


# Recent Updates

* Fixed silent fail when attempting to hide BspBounds collection
* Fixed double dds extension causing issues parsing some texture paths
* (Very) basic .elu support, no .ani parsing or skinned meshes yet
* tested on all models loaded in vanilla GunZ maps
* some issues with orientation on a case-by-case basis (Factory, Mansion, Halloween Town etc.)
* Map geometry now actually truly does load custom normals this time I promise
* Added new switches for logging information to the console


# Current Features
Expand Down Expand Up @@ -42,8 +45,8 @@ RaGEZONE thread: ***https://forum.ragezone.com/f496/io_scene_gzrs2-blender-3-1-m
* quest maps and community maps have not been tested at all yet
* some alpha textures have white halos in render mode (Town)
* collision mesh and occlusion planes appear black in render mode (just disable them for now)
* some maps don't have a corresponding dummy for each object (is this information stored elsewhere?)
* textures are only searched for in the surrounding map folders, there may be other locations but I don't know yet
* some .elu models are oriented incorrectly. (Factory, Mansion, Halloween Town etc.)


![Preview](meta/preview_220327_1.jpg)
Expand Down
51 changes: 48 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
bl_info = {
"name": "GZRS2 Format",
"author": "Krunklehorn",
"version": (0, 8, 1),
"version": (0, 8, 2),
"blender": (3, 1, 0),
"location": "File > Import",
"description": "GunZ: The Duel RealSpace2.0 map import for geometry, models, materials, lights and more.",
Expand Down Expand Up @@ -49,6 +49,12 @@ class ImportGZRS2(Operator, ImportHelper):
default = True
)

panelLogging: BoolProperty(
name = "Logging",
description = "Log details to the console.",
default = False
)

convertUnits: BoolProperty(
name = "Convert Units",
description = "Convert location data from centimeters to meters.",
Expand Down Expand Up @@ -81,7 +87,7 @@ class ImportGZRS2(Operator, ImportHelper):

doDummies: BoolProperty(
name = "Dummies",
description = "Import lense flares, spawn points and more as empties.",
description = "Import cameras, lense flares, spawn points and more as empties.",
default = True
)

Expand Down Expand Up @@ -127,6 +133,24 @@ class ImportGZRS2(Operator, ImportHelper):
default = True
)

logEluHeaders: BoolProperty(
name = "Elu Headers",
description = "Log ELU header data.",
default = True
)

logEluMats: BoolProperty(
name = "Elu Materials",
description = "Log ELU material data.",
default = True
)

logEluMeshNodes: BoolProperty(
name = "Elu Mesh Nodes",
description = "Log ELU mesh node data.",
default = True
)

def draw(self, context):
pass

Expand Down Expand Up @@ -182,10 +206,31 @@ def draw(self, context):
layout.prop(operator, "doLightDrivers")
layout.prop(operator, "doFogDriver")

class GZRS2_PT_Import_Logging(Panel):
bl_space_type = "FILE_BROWSER"
bl_region_type = "TOOL_PROPS"
bl_label = "Logging"
bl_parent_id = "FILE_PT_operator"

def draw_header(self, context):
self.layout.prop(context.space_data.active_operator, "panelLogging", text = "")

def draw(self, context):
layout = self.layout
operator = context.space_data.active_operator

layout.use_property_split = True
layout.use_property_decorate = False
layout.enabled = operator.panelLogging
layout.prop(operator, "logEluHeaders")
layout.prop(operator, "logEluMats")
layout.prop(operator, "logEluMeshNodes")

classes = (
ImportGZRS2,
GZRS2_PT_Import_Main,
GZRS2_PT_Import_Drivers
GZRS2_PT_Import_Drivers,
GZRS2_PT_Import_Logging
)

def menu_func_import(self, context):
Expand Down
102 changes: 94 additions & 8 deletions classes_gzrs2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from dataclasses import dataclass, field
from typing import Any

import bpy, mathutils
from bpy.types import Material, ShaderNode, Mesh, Object
from dataclasses import dataclass, field
from mathutils import Vector

@dataclass
Expand All @@ -18,9 +20,12 @@ class GZRS2State:
bspVerts: list = field(default_factory = list)
bspPolys: list = field(default_factory = list)
colVerts: list = field(default_factory = list)
eluMats: list = field(default_factory = list)
eluMeshNodes: list = field(default_factory = list)

blMats: list = field(default_factory = list)
blMeshes: list = field(default_factory = list)
blProps: list = field(default_factory = list)

blColMat: Material = None
blColGeo: Mesh = None
Expand Down Expand Up @@ -49,13 +54,94 @@ class GZRS2State:

@dataclass
class BspVertex:
pos: Vector
nor: Vector
uv: Vector
pos: Vector = (0, 0, 0)
nor: Vector = (0, 0, 0)
uv: Vector = (0, 0)

@dataclass
class BspPolyData:
materialID: int
drawFlags: int
vertexCount: int
firstVertex: int
materialID: int = 0
drawFlags: int = 0
vertexCount: int = 0
firstVertex: int = 0

@dataclass
class EluMaterial:
matID: int = 0
subMatID: int = 0
ambient: Vector = (0, 0, 0, 0)
diffuse: Vector = (0, 0, 0, 0)
specular: Vector = (0, 0, 0, 0)
power: float = 0.0
subMatCount: int = 0
texPath: str = ""
alphaPath: str = ""
twosided: bool = False
additive: bool = False
alphatest: int = 0
isAlphaMap: bool = False
isDiffuseMap: bool = False
texName: str = ""
texBase: str = ""
texExt: str = ""
texDir: str = ""
isAniTex: bool = False
frameCount: int = 0
frameSpeed: int = 0
frameGap: float = 0.0

@dataclass
class EluMeshNode:
meshID: int = 0
matID: int = 0
parentMesh: Any = None
baseMesh: Any = None
meshName: str = ""
parentName: str = ""
baseMatrix: Vector = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
etcMatrix: Vector = None
apScale: Vector = None
rotAxis: Vector = None
scaleAxis: Vector = None
rotAngle: float = None
scaleAngle: float = None
partsType: str = None # "eq_parts_etc"
partsPosInfoType: str = None # "eq_parts_pos_info_etc"
cutParts: str = None # "cut_parts_upper_body"
lookAtParts: str = None # "lookat_parts_etc"
weaponDummyType: str = None # "weapon_dummy_etc"
alphaSortValue: float = 0.0
vertices: list = None
minVertex: Vector = (0, 0, 0)
maxVertex: Vector = (0, 0, 0)
faces: list = None
normals: list = None
vertexColors: list = None
physInfos: list = None
isDummy: bool = False
isDummyMesh: bool = False
isWeaponMesh: bool = False
isCollisionMesh: bool = False
isPhysMesh: bool = False
isClothMesh: bool = False

@dataclass
class EluFace:
index: tuple = field(default_factory = tuple)
uv: tuple = field(default_factory = tuple)
matID: int = 0
sigID: int = -1
normal: Vector = (0, 0, 0)

@dataclass
class EluNormalInfo:
faceNormal: Vector = (0, 0, 0)
vertexNormals: tuple = field(default_factory = tuple)

@dataclass
class EluPhysInfo:
parentName: tuple = field(default_factory = tuple)
parentID: tuple = field(default_factory = tuple)
weight: tuple = field(default_factory = tuple)
offset: tuple = field(default_factory = tuple)
num: int = 0
27 changes: 27 additions & 0 deletions constants_gzrs2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,30 @@
AS_SPHERE = 0x02
AS_2D = 0x10
AS_3D = 0x20

ELU_ID = 0x0107f060
ELU_11 = 0x11 # GunZ: The Duel
ELU_5001 = 0x5001
ELU_5002 = 0x5002
ELU_5003 = 0x5003
ELU_5004 = 0x5004
ELU_5005 = 0x5005
ELU_5006 = 0x5006
ELU_5007 = 0x5007
ELU_5008 = 0x5008 # GunZ: The Second Duel, RaiderZ
ELU_500A = 0x500A
ELU_500B = 0x500B
ELU_500C = 0x500C
ELU_500E = 0x500E
ELU_500F = 0x500F
ELU_5012 = 0x5012 # EluLoader.cpp
ELU_5013 = 0x5013

ELU_VERSIONS = [ ELU_11, ELU_5001, ELU_5002, ELU_5003, ELU_5004, ELU_5005, ELU_5006, ELU_5007,
ELU_5008, ELU_500A, ELU_500B, ELU_500C, ELU_500E, ELU_500F, ELU_5012, ELU_5013 ]

ELU_SUPPORTED_VERSIONS = [ ELU_5005, ELU_5006, ELU_5007 ]

ELU_NAME_LENGTH = 40
ELU_PATH_LENGTH = 256
ELU_PHYS_KEYS = 4
Loading

0 comments on commit fed19c6

Please sign in to comment.