if (heapSize < 20000000) then
heapSize = 40000000 -- allow ~ 40 MB instead of just 7.5 MB. Prevents "Runtime Error: Out of scripter memory"
fname = GetOpenFileName caption:"Open Clare3d Model File" types:"Clare3d Model File(*.c3m)|*.c3m"
f = fopen fname "rb" --open file in read only format
p = getFilenamePath fname
fseek f 0x20 #seek_set
Count1 = readlong f
Null1 = readlong f
Count2 = readlong f
Null2 = readlong f
Null3 = readlong f
Null4 = readlong f
Count3 = readlong f
MeshNumber = readlong f
VertCount = readlong f
FaceCount = readlong f
fn readword fstream = (
return (readshort fstream #unsigned)
)
VertexOffset = ftell f
fseek f (0x20 * VertCount)#seek_cur
FaceOffset = ftell f
fseek f (0x2 * FaceCount)#seek_cur
TableOffset = ftell f
for aa = 1 to MeshNumber do (
Vert_array = #() --define arrays for verts, normals, UV and Faces
Normal_array = #()
UV_array = #()
Face_array = #()
Mesh_array = #()
fseek f TableOffset #seek_set
fseek f 0x44 #seek_cur
VertOffsetAdd = readlong f
FaceOffsetAdd = readlong f
VertCountAdd = readlong f
FaceCountAdd = readlong f
float1 = readfloat f
float2 = readfloat f
float3 = readfloat f
Null1 = readlong f
Null2 = readlong f
DiffuseTexture = readstring f
skipbytes = 0x20 - DiffuseTexture.count - 1
fseek f skipbytes #seek_cur
fseek f 0x20 #seek_cur
append Mesh_array VertOffsetAdd
append Mesh_array FaceOffsetAdd
append Mesh_array VertCountAdd
append Mesh_array FaceCountAdd
append Mesh_array DiffuseTexture
TableOffset = ftell f
fseek f ((Mesh_array[1] * 0x20) + VertexOffset)#seek_set
for i = 1 to Mesh_array[3] Do (
vx = readfloat f --read xyz coordinates
vy = readfloat f
vz = readfloat f
append Vert_array [vx,vy,vz] --save verts to Vert_array
--since UV in Max are in point3 format, so we add 0 for z value
nx = readlong f --read Normal ??
ny = readlong f
nz = readlong f
append Normal_array [nx,ny,nz] --save normals to Normal_array
tu = readfloat f --read UV float value
tv = (readfloat f) * -1
append UV_array [tu,tv,0] --save UVs to UV_array
)
fseek f ((Mesh_array[2] * 0x2) + FaceOffset)#seek_set
for i = 1 to Mesh_array[4] / 3 Do (
f1 = (readword f) + 1 --read face indices, games are start form 0, but Max start from 1
f2 = (readword f) + 1 --so we add 1 to each index
f3 = (readword f) + 1
append Face_array [f1,f2,f3] --save faces to Face_array
)
msh = mesh vertices:Vert_array faces:Face_array
msh.numTVerts = UV_array.count
buildTVFaces msh
msh.material = meditMaterials[aa]
meditMaterials[aa].name = Mesh_array[5]
meditMaterials[aa].diffuseMap = Bitmaptexture fileName:(p + Mesh_array[5] + ".dds")
meditMaterials[aa].opacityMap = copy meditMaterials[aa].diffuseMap
meditMaterials[aa].diffuseMap.alphaSource = 2
meditMaterials[aa].opacityMap.monoOutput = 1
meditMaterials[aa].opacityMapEnable = on
for j = 1 to UV_array.count do setTVert msh j UV_array[j]
for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
for j = 1 to Normal_array.count do setNormal msh j Normal_array[j]
)
actionMan.executeAction 0 "40021" -- Selection: Select All
modPanel.addModToSelection (Normalmodifier ()) ui:on
$Object01.modifiers[#Normal].flip = on
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
clearSelection()
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
fclose f --close file
sorry, on the link for download Client are much errors, you need an Korea Pass for registering, but 1% of europe people has that, chroox can you send us an link to download the Client for unpacking that ?
or can you upload on mega or other upload company!
chrrox wrote:Here is a max script to import these models I only tested it on this model I attached here so if it does not work on other models let me know.
Max script save into a text document and give it the extension .ms
if (heapSize < 20000000) then
heapSize = 40000000 -- allow ~ 40 MB instead of just 7.5 MB. Prevents "Runtime Error: Out of scripter memory"
fname = GetOpenFileName caption:"Open Clare3d Model File" types:"Clare3d Model File(*.c3m)|*.c3m"
f = fopen fname "rb" --open file in read only format
p = getFilenamePath fname
fseek f 0x20 #seek_set
Count1 = readlong f
Null1 = readlong f
Count2 = readlong f
Null2 = readlong f
Null3 = readlong f
Null4 = readlong f
Count3 = readlong f
MeshNumber = readlong f
VertCount = readlong f
FaceCount = readlong f
fn readword fstream = (
return (readshort fstream #unsigned)
)
VertexOffset = ftell f
fseek f (0x20 * VertCount)#seek_cur
FaceOffset = ftell f
fseek f (0x2 * FaceCount)#seek_cur
TableOffset = ftell f
for aa = 1 to MeshNumber do (
Vert_array = #() --define arrays for verts, normals, UV and Faces
Normal_array = #()
UV_array = #()
Face_array = #()
Mesh_array = #()
fseek f TableOffset #seek_set
fseek f 0x44 #seek_cur
VertOffsetAdd = readlong f
FaceOffsetAdd = readlong f
VertCountAdd = readlong f
FaceCountAdd = readlong f
float1 = readfloat f
float2 = readfloat f
float3 = readfloat f
Null1 = readlong f
Null2 = readlong f
DiffuseTexture = readstring f
skipbytes = 0x20 - DiffuseTexture.count - 1
fseek f skipbytes #seek_cur
fseek f 0x20 #seek_cur
append Mesh_array VertOffsetAdd
append Mesh_array FaceOffsetAdd
append Mesh_array VertCountAdd
append Mesh_array FaceCountAdd
append Mesh_array DiffuseTexture
TableOffset = ftell f
fseek f ((Mesh_array[1] * 0x20) + VertexOffset)#seek_set
for i = 1 to Mesh_array[3] Do (
vx = readfloat f --read xyz coordinates
vy = readfloat f
vz = readfloat f
append Vert_array [vx,vy,vz] --save verts to Vert_array
--since UV in Max are in point3 format, so we add 0 for z value
nx = readlong f --read Normal ??
ny = readlong f
nz = readlong f
append Normal_array [nx,ny,nz] --save normals to Normal_array
tu = readfloat f --read UV float value
tv = (readfloat f) * -1
append UV_array [tu,tv,0] --save UVs to UV_array
)
fseek f ((Mesh_array[2] * 0x2) + FaceOffset)#seek_set
for i = 1 to Mesh_array[4] / 3 Do (
f1 = (readword f) + 1 --read face indices, games are start form 0, but Max start from 1
f2 = (readword f) + 1 --so we add 1 to each index
f3 = (readword f) + 1
append Face_array [f1,f2,f3] --save faces to Face_array
)
msh = mesh vertices:Vert_array faces:Face_array
msh.numTVerts = UV_array.count
buildTVFaces msh
msh.material = meditMaterials[aa]
meditMaterials[aa].name = Mesh_array[5]
meditMaterials[aa].diffuseMap = Bitmaptexture fileName:(p + Mesh_array[5] + ".dds")
meditMaterials[aa].opacityMap = copy meditMaterials[aa].diffuseMap
meditMaterials[aa].diffuseMap.alphaSource = 2
meditMaterials[aa].opacityMap.monoOutput = 1
meditMaterials[aa].opacityMapEnable = on
for j = 1 to UV_array.count do setTVert msh j UV_array[j]
for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
for j = 1 to Normal_array.count do setNormal msh j Normal_array[j]
)
actionMan.executeAction 0 "40021" -- Selection: Select All
modPanel.addModToSelection (Normalmodifier ()) ui:on
$Object01.modifiers[#Normal].flip = on
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
clearSelection()
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
fclose f --close file
Good news, thank you, Szkaradek123, the script is very good, we import model GMD files, but note that not all of the GMD is a model file, thanks again, Szkaradek123
# Game: 三国之天
# Package: pfs
# by Fatduck Jun 2014
# script for QuickBMS http://quickbms.aluigi.org
idstring "XGFILESYSTEM\0"
get RESEND asize
savepos RESPOS
do
goto RESPOS
get ukn0 long
get RESTYPE long
getdstring RESNAME 0x100
get CSIZE long
get USIZE long
get ukn00 long
get NEXTOFS long
get DATAFLAG long
savepos RESPOS
if DATAFLAG == 1
clog RESNAME RESPOS CSIZE USIZE
endif
math RESPOS += CSIZE
while RESPOS < RESEND