Join also our Discord channel! Click here.
CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
-
- veteran
- Posts: 80
- Joined: Sun May 19, 2013 12:55 am
- Has thanked: 84 times
- Been thanked: 2 times
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
please don't get mad a me for bump such an old thread.
i was just curious if anybody out there still got the blender script to import
.sm3 files with bones intact.
if this bump is somehow against the rules because i only did it because of
a request, i apologize.
if anyone here still have the script, give me a shout via pm.
thank you!
i was just curious if anybody out there still got the blender script to import
.sm3 files with bones intact.
if this bump is somehow against the rules because i only did it because of
a request, i apologize.
if anyone here still have the script, give me a shout via pm.
thank you!
- TaylorMouse
- ultra-veteran
- Posts: 335
- Joined: Mon Sep 26, 2011 12:51 pm
- Has thanked: 11 times
- Been thanked: 79 times
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Hi guys, I don't have blender, and I'm not planning on downloading it either, I do have 3DS Max and would like to ask if there is a file format described on the .sm3 format for the PC version ?
or maybe have the blender script in readable text instead of having it encrypted in the blender format.
Thnx
T.
or maybe have the blender script in readable text instead of having it encrypted in the blender format.
Thnx
T.
- TaylorMouse
- ultra-veteran
- Posts: 335
- Joined: Mon Sep 26, 2011 12:51 pm
- Has thanked: 11 times
- Been thanked: 79 times
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Yes, I finally figured out the model structure, the static one meshed models where easy, but this one const me a few time my sleep.
Still need to add the automatic assignment of the materials, but it looks like it will be just a matter of time
Once that is done, I'll upload the max script
This is only for the PC version.

T.
Still need to add the automatic assignment of the materials, but it looks like it will be just a matter of time
Once that is done, I'll upload the max script
This is only for the PC version.

T.
-
- ultra-veteran
- Posts: 423
- Joined: Mon Aug 11, 2008 11:30 pm
- Has thanked: 27 times
- Been thanked: 15 times
- shakotay2
- MEGAVETERAN
- Posts: 3184
- Joined: Fri Apr 20, 2012 9:24 am
- Location: Nexus, searching for Jim Kirk
- Has thanked: 871 times
- Been thanked: 1751 times
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Sry, I read this thread too late. Here's the py script from Mariusz Szkaradek, my blender script heroTaylorMouse wrote:Still need to add the automatic assignment of the materials, but it looks like it will be just a matter of time

There's a function def read_materials():
but in my experience using blender (2.49b) helps to get a full understanding of a script's working methods. (Yes, it's a very old blender version but it's a python 2 script I guess.)
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."
- TaylorMouse
- ultra-veteran
- Posts: 335
- Joined: Mon Sep 26, 2011 12:51 pm
- Has thanked: 11 times
- Been thanked: 79 times
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Thnx shakotay2 , but I believe it is not for the PC version, cause I looked at the script ( through Blender) and it has some serous changes compared to the PC version. :/
Anyway still need to work on it cause not all of the models work... yet
T.
Anyway still need to work on it cause not all of the models work... yet
T.
- TaylorMouse
- ultra-veteran
- Posts: 335
- Joined: Mon Sep 26, 2011 12:51 pm
- Has thanked: 11 times
- Been thanked: 79 times
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Here is the script that imports (almost) all of the models
T.
Code: Select all
fn ReadZeroString binaryStream =
(
local loop = true
local str = ""
while (loop) do
(
var = readByte binaryStream
if (var == 0) then
(
loop = false
)
else
(
str += Bit.IntAsChar(var)
)
)
str
)
fn ReadBytes binaryStream bytesToRead =
(
for b=1 to bytesToRead do readbyte binaryStream
)
struct MyMaterial
(
MaterialName,
Type,
TypeName,
DiffuseText,
NormalText,
SpecularText
)
fn CreateMesh stream pos =
(
fseek stream pos #seek_set
MD3D = ReadZeroString stream
fseek stream 11 #seek_cur
meshName = ReadZeroString stream
/* Faces */
faces =#()
nbrFaces = readLong stream
indicesChunckSize = readLong stream
for f=1 to nbrFaces do
(
f1 = readshort stream + 1
f2 = readshort stream + 1
f3 = readshort stream + 1
append faces[f1, f3, f2] --> not zero based !!
)
LFVF = ReadZeroString stream
/* Vertices */
verts=#()
uvs=#()
groups=#()
fseek stream 15 #seek_cur
TEX1TGX = ReadZeroString stream
s1 = readshort stream
s2 = readshort stream
chunkSize = readshort stream
s4 = readshort stream
nbrVertices = readshort stream
s6 = readshort stream
for v=1 to nbrVertices do
(
offset = chunkSize
v1 = readfloat stream
v2 = readfloat stream
v3 = readfloat stream
append verts [ v1, v3, v2 ] --> 12 bytes
fseek stream 12 #seek_cur
offset = offset - 24
u = readfloat stream
v = readfloat stream
w = readfloat stream
append uvs [u,1-v,0]
offset = offset - 12
fseek stream offset #seek_cur
)
--print (ftell stream)
matId = readlong stream
unk2 = readlong stream
unk3 = readlong stream
for k=1 to matId do readshort stream
unk1 = readlong stream
--format "unk1:% unk2:% unk3:% \n" unk1 unk2 unk3
--Format "Material ID = %\n" matId
Format "Building mesh '%' please wait...\n" meshName
theMesh = MESH NAME:meshName VERTICES:verts FACES:faces TVERTS:uvs
meshOp.setMapSupport theMesh 1 true
for t = 1 to verts.count do
meshop.setMapVert theMesh 1 t uvs[t]
theMesh.material = meditMaterials[1]
update theMesh
)
fn ImportMeshesOnly =
(
clearlistener()
testFile = getOpenFileName \
caption:"Castlevania Lords of Shadow" \
types:"Castlevania Model File(*.sm3)|*.sm3" \
historyCategory:"CastlevaniaObjectPresets"
if (testFile == undefined) then return undefined
filePath = getFilenamePath testFile
print filePath
/* Open the file in binary mode */
stream = fOpen testFile "rb"
fseek stream 0 #seek_end
fileLength = ftell stream
fseek stream 0 #seek_set
search = "MD3D"
positions = #()
char1 = bit.intAsChar( readbyte stream )
char2 = bit.intAsChar( readbyte stream )
char3 = bit.intAsChar( readbyte stream )
char4 = bit.intAsChar( readbyte stream )
str = char1 + char2 + char3 + char4
print "Reading file "
for i=1 to fileLength do
(
pos = 0
if( str == search) then
(
format "Mesh found (%)\n" pos
pos = ftell stream
append positions (pos - 4)
)
char1 = char2
char2 = char3
char3 = char4
b = readbyte stream
if(b == undefined) then exit
char4 = bit.intAsChar( b )
str = char1 + char2 + char3 + char4
)
/* read the materials */
fseek stream 48 #seek_set
iniAvailable = readlong stream
if(iniAvailable == 1) then
(
fseek stream 64 #seek_set
nbrInis = readlong stream
--print nbrInis
for ini=1 to nbrInis do
(
readlong stream --> namelength
property = ReadZeroString stream
--format "%\n" (property)
)
)
fseek stream 84 #seek_cur
/*
Read material for this model chunk = 240
*/
Materials=#()
nbrMaterials = readlong stream
--format "Materials = %\n" nbrMaterials
for m=1 to nbrMaterials do
(
MAT = ReadZeroString stream
fseek stream 12 #seek_cur
materialName = ReadZeroString stream
fseek stream 56 #seek_cur
readlong stream --> namelength
materialType = ReadZeroString stream
phantomName = ""
if(materialType == "Standard") then
(
fseek stream 16 #seek_cur
)
else --> Phantom or Blend
(
readlong stream
phantomName = ReadZeroString stream
fseek stream 12 #seek_cur
)
readlong stream --> namelength
textureName = ReadZeroString stream
/* TODO : check if the file exists without the .alpha, if it doesn't check if it exists with, this also means that there is an opacity layer */
textureName = tolower textureName
trimmed = "dds\\" + substring (getFilenameFile textureName) 1 ( (getFilenameFile textureName).count - 1 )
/* DIFFUSE TEXTURE */
textureDiffuse = filePath + "dds\\" + getFilenameFile textureName + ".alpha.dds"
diffuseAlphaFound = true --> diffuse map contains an alpha layer that needs to be used
if( DoesFileExist (textureDiffuse) == false) then
(
diffuseAlphaFound = false
textureDiffuse = filePath + "dds\\" + getFilenameFile textureName + ".dds"
if( DoesFileExist (textureDiffuse) == false) then
textureDiffuse = "" --> NOT FOUND !
)
/* NORMAL MAP */
textureNormal = filePath + trimmed + "b.dds"
if( DoesFileExist (textureNormal) == false) then textureNormal = "" --> NOT FOUND !
/* SPECULAR MAP*/
textureSpecular = filePath + trimmed + "s.alpha.dds"
specularAlpaMapFound = true
if( DoesFileExist (textureSpecular) == false) then
(
specularAlpaMapFound = false
textureSpecular = filePath + "dds\\" + getFilenameFile textureName + "s.dds"
if( DoesFileExist (textureSpecular) == false) then
textureSpecular = "" --> NOT FOUND !
)
/* Clean up the material editor first */
for i=1 to 24 do
(
meditMaterials[i] = Standard()
mname = i as string + " - Default"
meditMaterials[i].name = mname
)
/* PUT THE MAT TO THE MAT LIB*/
if( m < 25) then
(
meditMaterials[m] = Standard()
meditMaterials[m].name = getFilenameFile textureName
if(textureDiffuse != "") then
(
meditMaterials[m].diffuseMapEnable = on
meditMaterials[m].diffuseMap = Bitmaptexture fileName:textureDiffuse
)
if(diffuseAlphaFound) then
(
meditMaterials[m].opacitymap = Bitmaptexture fileName:textureDiffuse
meditMaterials[m].opacitymap.monooutput = 1
)
if(textureNormal != "" ) then
(
meditMaterials[m].bumpMapEnable = on
meditMaterials[m].bumpMapAmount = 40
normal = Normal_Bump ()
normal.normal_map = BitmapTexture fileName:textureNormal
meditMaterials[m].bumpMap = normal
)
if(textureSpecular != "") then
(
meditMaterials[m].specularMap = Bitmaptexture fileName:textureSpecular
meditMaterials[m].specularLevel = 50
)
showTextureMap meditMaterials[m] true
)
/* add the material to the array */
mat = MyMaterial "" materialType phantomName textureDiffuse textureNormal textureSpecular
append Materials mat
fseek stream 63 #seek_cur
)
print Materials
/* build and draw the meshes */
format "\nCreating meshes\n"
for i=1 to positions.count do
(
CreateMesh stream positions[i]
)
fclose stream
format "Number of meshes found: % \n" positions.count
)
GC()
clearlistener()
max select all
max delete
ImportMeshesOnly()
max zoomext sel all
--clearlistener()
format "DONE\n"
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Anyc chance for na updated version of this script for Castlevania Lords of Shadow 2? 

- TaylorMouse
- ultra-veteran
- Posts: 335
- Joined: Mon Sep 26, 2011 12:51 pm
- Has thanked: 11 times
- Been thanked: 79 times
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Don't have the game (yet) so...
did you try using this script?
T
did you try using this script?
T
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Cheers for the reply,
Yup I did it stops here:
str += Bit.IntAsChar(var)
Yup I did it stops here:
str += Bit.IntAsChar(var)
-
- beginner
- Posts: 38
- Joined: Sat Oct 16, 2010 1:27 pm
- Has thanked: 1 time
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Karpati wrote:I added the Mercury Steam .sm3 loader module to 3D Object Converter v4.427
[url]http://www.kz_3d.tvn.hu/mercury_steam.jpg[/url]
I uploaded the converted Wavefront .obj/mtl files:
[url]http://www.kz_3d.tvn.hu/mercury_steam.zip[/url]
Is this possible to do for LOS2? it works for los1, reverie and ressurection ps3 files! As you can see you did this once and this is a really nice feature. I requested this a long time ago! In LOS2 almost all dds textures are located in other folders than the model foldres so its hard to track down dds files, but in this way it is easy to see exactly what the name of the dds texture file is. if this is possible to make again, then, please make it so. Thank You!!!
You do not have the required permissions to view the files attached to this post.
-
- beginner
- Posts: 38
- Joined: Sat Oct 16, 2010 1:27 pm
- Has thanked: 1 time
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
has enyone found a way to import level models from los2 in the correct spots? for example where things should be placed and/or oriented? And one other thing, how to know exactly witch level models to import to complete a specific level?
- zardalu
- veteran
- Posts: 98
- Joined: Sat Sep 13, 2008 3:13 pm
- Has thanked: 5 times
- Been thanked: 13 times
- Contact:
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
The origin of the level models as exported by Karpati's 3D Object Converter is maintained such that they are automatically positioned properly when you import them into another program (for example, Deep Exploration). So for example, if you look in the noblequart folder and load 000carm.obj, 001carm.obj, 002carm,obj, etc into Deep Exploration, the rooms will show up linked together as they do in the game. I just referred back to the game in order to assign the correct textures. This took me a little while, but now I have the levels completely textured. The required materials are stored in the sm3 file associated with each msh file, so you can figure it out pretty easily from there. Not the most efficient way to do things, but it works.unlimited32 wrote:has enyone found a way to import level models from los2 in the correct spots? for example where things should be placed and/or oriented? And one other thing, how to know exactly witch level models to import to complete a specific level?
As far as the object placement of things like furniture, candles, interactive objects, etc, you would also need to refer to the game for that (ie screenshots or alt tab). At least for now.