Norbyte / lslib

Tools for manipulating Divinity Original Sin and Baldur's Gate 3 files
MIT License
720 stars 133 forks source link

Support for Diablo 2: Resurrected GR2 (.model) #67

Open IVENEND opened 3 years ago

IVENEND commented 3 years ago

Hi Mr.Norbyte.

Not sure if I should post it here, but as I have seen you add support for other games's GR2, I would try my luck here.

A new games called Diablo 2: Resurrected also use a kind of GR2 format models, but named as .model, it can be open with Granny Viewer 2.11.8. According to informations in the Granny Viewer, the .model files are exported through Granny Standard exporter, SDK version 2.12.0.5

Here is some example files: https://drive.google.com/file/d/1M70iiRA3A3YOOzbspk6Ixsvq8zOBYboM/view

Is it possible for you to add import/export support of Diablo 2: Resurrected GR2 (.model)? It would greatly promote modding of this game.

Thanks.

Ivenend

Norbyte commented 3 years ago

Hi,

The link you sent seems to be restricted (can't open it as I don't have access).

IVENEND commented 3 years ago

Hi,

The link you sent seems to be restricted (can't open it as I don't have access).

@Norbyte

Sorry, please try one of these links: https://drive.google.com/file/d/1M70iiRA3A3YOOzbspk6Ixsvq8zOBYboM/view https://www.dropbox.com/sh/c4i8hjym4hav6p9/AABJ0oIewt3w-TIiONcF5SROa?dl=0

Norbyte commented 3 years ago

I added support for the D2 vertex formats in feb8350d2ef952c5ee6024090821d270de45c661; i.e. converting from GR2 to DAE should work now. Converting back to GR2 is trickier, as the game packs a lot of texture/material related metadata in the GR2 file that has to be exported/imported somehow.

IVENEND commented 3 years ago

I added support for the D2 vertex formats in feb8350; i.e. converting from GR2 to DAE should work now. Converting back to GR2 is trickier, as the game packs a lot of texture/material related metadata in the GR2 file that has to be exported/imported somehow.

Thanks for your work. It is a bit disappointed that converting back to .model (GR2) isn't possible, but at least it is a good start for D2R modding.

BTW, is the project buildable by myself or I should wait for your release? I tried to build LSTools.sln in Visual Studio but fail, just wonder if it is my problem or the project isn't buildable.

Edit: sorry, just read that there are requirements to build the project.

IVENEND commented 3 years ago

@Norbyte

I built the tool by myself.

Importing a .GR2 from D2R and export it to DAE works fine. But trying to import a previously exported DAE, I got this error: https://i.imgur.com/x2qQWUB.png

Just wonder if that works as intended (as you said "Converting back to GR2 is trickier"), or I did something wrong when compling the tool so I got this error.

I'm testing this model btw: https://drive.google.com/file/d/1M70iiRA3A3YOOzbspk6Ixsvq8zOBYboM/view

eezstreet commented 3 years ago

I added support for the D2 vertex formats in feb8350d2ef952c5ee6024090821d270de45c661; i.e. converting from GR2 to DAE should work now. Converting back to GR2 is trickier, as the game packs a lot of texture/material related metadata in the GR2 file that has to be exported/imported somehow.

Can you give some more specific details? It is possible that it is linked to game files that are external to the model themselves. We're still trying to figure all of this out.

Norbyte commented 3 years ago

To be more specific: GR2 has a fixed format, however for each object it supports "ExtendedData" nodes where the game can stuff whatever customizations it wants. In the case of D2, the ExtendedData looks like this:

Material extended data:

caching: Int32
frozen: Int32
nodeState: Int32
nodeState: Int32
uvCoord: Reference <struct 000214C8>
uCoord: Real32
vCoord: Real32
uvFilterSize: Reference <struct 000214C8>
filter: Real32
filterOffset: Real32
invert: Int32
alphaIsLuminance: Int32
colorGain: Real32[3]
colorGainR: Real32
colorGainG: Real32
colorGainB: Real32
colorOffset: Real32[3]
colorOffsetR: Real32
colorOffsetG: Real32
colorOffsetB: Real32
alphaGain: Real32
alphaOffset: Real32
defaultColor: Real32[3]
defaultColorR: Real32
defaultColorG: Real32
defaultColorB: Real32
outColor: Real32[3]
outColorR: Real32
outColorG: Real32
outColorB: Real32
outAlpha: Real32
fileTextureName: String
disableFileLoad: Int32
useFrameExtension: Int32
frameExtension: Int32
frameOffset: Int32
useHardwareTextureCycling: Int32
startCycleExtension: Int32
endCycleExtension: Int32
byCycleIncrement: Int32
filterType: Int32
filterType: Int32
filterWidth: Real32
preFilter: Int32
preFilterRadius: Real32
useCache: Int32
useMaximumRes: Int32
uvTilingMode: Int32
uvTilingMode: Int32
baseExplicitUvTilePosition: Real32[2]
baseExplicitUvTilePositionU: Real32
baseExplicitUvTilePositionV: Real32
uvTileProxyQuality: Int32
uvTileProxyQuality: Int32
coverage: Reference <struct 000214C8>
translateFrame: Reference <struct 000214C8>
rotateFrame: Reference <struct 000214C8>
mirrorU: Reference <struct 000214C8>
mirrorV: Reference <struct 000214C8>
stagger: Reference <struct 000214C8>
wrapU: Reference <struct 000214C8>
wrapV: Reference <struct 000214C8>
repeatUV: Reference <struct 000214C8>
offset: Reference <struct 000214C8>
rotateUV: Reference <struct 000214C8>
noiseUV: Reference <struct 000214C8>
noiseU: Real32
noiseV: Real32
vertexCameraOne: Reference <struct 000214C8>
vertexUvOne: Reference <struct 000214C8>
vertexUvTwo: Reference <struct 000214C8>
vertexUvThree: Reference <struct 000214C8>
exposure: Real32
ptexFilterType: Int32
ptexFilterType: Int32
ptexFilterWidth: Real32
ptexFilterBlur: Real32
ptexFilterSharpness: Real32
ptexFilterInterpolateLevels: Int32
colorSpace: String
ignoreColorSpaceFileRules: Int32
workingSpace: Reference <struct 000214C8>
colorManagementEnabled: Reference <struct 000214C8>
colorManagementConfigFileEnabled: Reference <struct 000214C8>
colorManagementConfigFilePath: Reference <struct 000214C8>
outSize: Real32[2]
outTransparency: Real32[3]
outTransparencyR: Real32
outTransparencyG: Real32
outTransparencyB: Real32
typeName: String

Material map extended data:

caching: Int32
frozen: Int32
nodeState: Int32
nodeState: Int32
cmEnabled: Int32
configFileEnabled: Int32
configFilePath: String
viewTransformName: String
workingSpaceName: String
defaultInputSpaceName: String
outputTransformEnabled: Int32
outputTransformUseColorConversion: Int32
playblastOutputTransformEnabled: Int32
playblastOutputTransformUseColorConversion: Int32
outputUseViewTransform: Int32
playblastOutputUseViewTransform: Int32
outputTransformName: String
playblastOutputTransformName: String
typeName: String

Bone extended data:

caching: Int32
frozen: Int32
nodeState: Int32
nodeState: Int32
blackBox: Int32
rmbCommand: String
templateName: String
templatePath: String
viewName: String
iconName: String
viewMode: Int32
viewMode: Int32
templateVersion: Int32
uiTreatment: Int32
uiTreatment: Int32
customTreatment: String
creator: String
creationDate: String
containerType: String
boundingBox: Reference <struct 00024BC8>
boundingBoxMin: Real32[3]
boundingBoxMinX: Real32
boundingBoxMinY: Real32
boundingBoxMinZ: Real32
boundingBoxMax: Real32[3]
boundingBoxMaxX: Real32
boundingBoxMaxY: Real32
boundingBoxMaxZ: Real32
boundingBoxSize: Real32[3]
boundingBoxSizeX: Real32
boundingBoxSizeY: Real32
boundingBoxSizeZ: Real32
center: Real32[3]
boundingBoxCenterX: Real32
boundingBoxCenterY: Real32
boundingBoxCenterZ: Real32
matrix: Real32[16]
inverseMatrix: Real32[16]
visibility: Int32
intermediateObject: Int32
template: Int32
ghosting: Int32
objectColorRGB: Real32[3]
objectColorR: Real32
objectColorG: Real32
objectColorB: Real32
wireColorRGB: Real32[3]
wireColorR: Real32
wireColorG: Real32
wireColorB: Real32
useObjectColor: Int32
useObjectColor: Int32
objectColor: Int32
drawOverride: Reference <struct 00024C78>
overrideDisplayType: Int32
overrideDisplayType: Int32
overrideLevelOfDetail: Int32
overrideLevelOfDetail: Int32
overrideShading: Int32
overrideTexturing: Int32
overridePlayback: Int32
overrideEnabled: Int32
overrideVisibility: Int32
hideOnPlayback: Int32
overrideRGBColors: Int32
overrideColor: Int32
overrideColorRGB: Real32[3]
overrideColorR: Real32
overrideColorG: Real32
overrideColorB: Real32
lodVisibility: Int32
selectionChildHighlighting: Int32
renderInfo: Reference <struct 00024EE0>
identification: Int32
layerRenderable: Int32
layerOverrideColor: Int32
ghostingControl: Int32
ghostingControl: Int32
ghostCustomSteps: Reference <struct 00024F90>
ghostPreSteps: Int32
ghostPostSteps: Int32
ghostStepSize: Int32
ghostColorPreA: Real32
ghostColorPre: Real32[3]
ghostColorPreR: Real32
ghostColorPreG: Real32
ghostColorPreB: Real32
ghostColorPostA: Real32
ghostColorPost: Real32[3]
ghostColorPostR: Real32
ghostColorPostG: Real32
ghostColorPostB: Real32
ghostRangeStart: Real32
ghostRangeEnd: Real32
hiddenInOutliner: Int32
useOutlinerColor: Int32
outlinerColor: Real32[3]
outlinerColorR: Real32
outlinerColorG: Real32
outlinerColorB: Real32
translate: Real32[3]
translateX: Real32
translateY: Real32
translateZ: Real32
rotate: Real32[3]
rotateX: Real32
rotateY: Real32
rotateZ: Real32
rotateOrder: Int32
rotateOrder: Int32
scale: Real32[3]
scaleX: Real32
scaleY: Real32
scaleZ: Real32
shear: Real32[3]
shearXY: Real32
shearXZ: Real32
shearYZ: Real32
rotatePivot: Real32[3]
rotatePivotX: Real32
rotatePivotY: Real32
rotatePivotZ: Real32
rotatePivotTranslate: Real32[3]
rotatePivotTranslateX: Real32
rotatePivotTranslateY: Real32
rotatePivotTranslateZ: Real32
scalePivot: Real32[3]
scalePivotX: Real32
scalePivotY: Real32
scalePivotZ: Real32
scalePivotTranslate: Real32[3]
scalePivotTranslateX: Real32
scalePivotTranslateY: Real32
scalePivotTranslateZ: Real32
rotateAxis: Real32[3]
rotateAxisX: Real32
rotateAxisY: Real32
rotateAxisZ: Real32
transMinusRotatePivot: Real32[3]
transMinusRotatePivotX: Real32
transMinusRotatePivotY: Real32
transMinusRotatePivotZ: Real32
minTransLimit: Real32[3]
minTransXLimit: Real32
minTransYLimit: Real32
minTransZLimit: Real32
maxTransLimit: Real32[3]
maxTransXLimit: Real32
maxTransYLimit: Real32
maxTransZLimit: Real32
minTransLimitEnable: Reference <struct 00025040>
minTransXLimitEnable: Int32
minTransYLimitEnable: Int32
minTransZLimitEnable: Int32
maxTransLimitEnable: Reference <struct 000250F0>
maxTransXLimitEnable: Int32
maxTransYLimitEnable: Int32
maxTransZLimitEnable: Int32
minRotLimit: Real32[3]
minRotXLimit: Real32
minRotYLimit: Real32
minRotZLimit: Real32
maxRotLimit: Real32[3]
maxRotXLimit: Real32
maxRotYLimit: Real32
maxRotZLimit: Real32
minRotLimitEnable: Reference <struct 000251A0>
minRotXLimitEnable: Int32
minRotYLimitEnable: Int32
minRotZLimitEnable: Int32
maxRotLimitEnable: Reference <struct 00025250>
maxRotXLimitEnable: Int32
maxRotYLimitEnable: Int32
maxRotZLimitEnable: Int32
minScaleLimit: Real32[3]
minScaleXLimit: Real32
minScaleYLimit: Real32
minScaleZLimit: Real32
maxScaleLimit: Real32[3]
maxScaleXLimit: Real32
maxScaleYLimit: Real32
maxScaleZLimit: Real32
minScaleLimitEnable: Reference <struct 00025300>
minScaleXLimitEnable: Int32
minScaleYLimitEnable: Int32
minScaleZLimitEnable: Int32
maxScaleLimitEnable: Reference <struct 000253B0>
maxScaleXLimitEnable: Int32
maxScaleYLimitEnable: Int32
maxScaleZLimitEnable: Int32
xformMatrix: Real32[16]
selectHandle: Real32[3]
selectHandleX: Real32
selectHandleY: Real32
selectHandleZ: Real32
inheritsTransform: Int32
displayHandle: Int32
displayScalePivot: Int32
displayRotatePivot: Int32
displayLocalAxis: Int32
dynamics: Int32
showManipDefault: Int32
showManipDefault: Int32
rotateQuaternion: Real32[4]
rotateQuaternionX: Real32
rotateQuaternionY: Real32
rotateQuaternionZ: Real32
rotateQuaternionW: Real32
rotationInterpolation: Int32
rotationInterpolation: Int32

Model extended data:

MaterialSets: ReferenceToArray <struct 0002569C>
needsSingleJointSkinning: Int32
bbMin: Real32[3]
bbMax: Real32[3]
meshRenderLayer: Int32
ReflectivePlanes: ReferenceToArray <struct 0002574C>
VertexScale: Real32

GR2 global extended data:

isMeshFlipbook: Int32
modelType: UInt32
eezstreet commented 3 years ago

Some of this stuff is definitely artist defined data, such as ghost* (these most likely control properties of "Ghostly" champion monsters and ethereal items). But for some others, I'm not totally sure. Would it help if we gave more examples of models? It might be worthwhile for us to create a tool to iterate over all the models and find any common data.

shalzuth commented 3 years ago

Does lslib provide a method for the user to input this data to create a .gr2, and is it possible to preserve/read this data out of .gr2?

Norbyte commented 3 years ago

Would it help if we gave more examples of models?

A skinned model (i.e. character) and animation .gr2 files would be helpful. Also I'd probably need the game .exe to see which attributes are actually being used by the game.

Does lslib provide a method for the user to input this data to create a .gr2, and is it possible to preserve/read this data out of .gr2?

It's possible but I'd have to add support for it since typed gr2 structures must be mapped in code.

IVENEND commented 3 years ago

Would it help if we gave more examples of models?

A skinned model (i.e. character) and animation .gr2 files would be helpful. Also I'd probably need the game .exe to see which attributes are actually being used by the game.

Does lslib provide a method for the user to input this data to create a .gr2, and is it possible to preserve/read this data out of .gr2?

It's possible but I'd have to add support for it since typed gr2 structures must be mapped in code.

skinned models (uploaded by othe people): https://www.mediafire.com/file/ubml1rk25gm9cl6/enemy.rar/file

exe: https://drive.google.com/file/d/18x3BxnF1a5QogHHMizODnujHSx8XeBmx/view?usp=sharing

IVENEND commented 3 years ago

@Norbyte

Zee (CucFlavius) shared some information of D2R models and textures, maybe these could help?

https://github.com/CucFlavius/Zee-010-Templates/blob/main/DiabloIIResurrected_Model.bt https://github.com/CucFlavius/Zee-010-Templates/blob/main/DiabloIIResurrected_Model_MainSection.bt https://github.com/CucFlavius/Zee-010-Templates/blob/main/DiabloIIResurrected_Shader.bt https://github.com/CucFlavius/Zee-010-Templates/blob/main/DiabloIIResurrected_Texture.bt

milonie commented 2 years ago

i know this is old, but is there a chance that the issues will be fixed? the modding community really needs this...

deadjack133 commented 2 years ago

With blizzards removing tcp/ip only reason to play D2R is good singleplayer mods that would be impossible without mod tools. Please, if you have time, try to fix this issue with reimporting.

Norbyte commented 2 years ago

Hi,

I plan to look at D2R models, but I'm unfortunately quite busy so I'm not sure when I will get around to it.

deadjack133 commented 2 years ago

Hi,

I plan to look at D2R models, but I'm unfortunately quite busy so I'm not sure when I will get around to it.

Thank you, men

KonesB commented 2 years ago

Is it possible to create a tool that converts to model file?

ghost commented 2 years ago

Hello @Norbyte ,

Hope all is well!

I know you are quite busy but please let us know if you had some time to look into this? The whole Diablo 2 Resurrected modding community is depending on your work here. I mean no matter how good the re-textured mods are - they are not able to achieve a signifficant progress without beeing able to backport the edited models in the game. Please kindly let us know?

Regards

pastuh commented 2 years ago

So... how to convert edited D2:R model from .fbx back to .model & .texture ?

ghost commented 2 years ago

So... how to convert edited D2:R model from .fbx back to .model & .texture ?

Hello @pastuh

I hope that @Norbyte will be able to check & resolve this soon enough...

Soukmancer commented 1 year ago

Any news on this front?