Page 4 of 5
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Fri Jun 07, 2013 3:17 pm
by TheMask85
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!
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Fri Jun 07, 2013 5:52 pm
by lumekano
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Fri Jun 07, 2013 6:14 pm
by TheMask85
thank you so much!
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Sat Aug 31, 2013 10:30 pm
by TaylorMouse
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.
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Thu Sep 05, 2013 10:18 pm
by TaylorMouse
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.
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Fri Sep 06, 2013 5:09 pm
by pixellegolas
pro!
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Fri Sep 06, 2013 6:16 pm
by shakotay2
TaylorMouse wrote:Still need to add the automatic assignment of the materials, but it looks like it will be just a matter of time
Sry, I read this thread too late. Here's the py script from Mariusz Szkaradek, my blender script hero

:
http://www.uploadmb.com/dw.php?id=1378487497
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.)
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Fri Sep 06, 2013 10:57 pm
by TaylorMouse
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.
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Thu Sep 12, 2013 9:41 pm
by TaylorMouse
Here is the script that imports (almost) all of the models
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"
T.
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Tue Mar 04, 2014 9:34 pm
by matreco
Anyc chance for na updated version of this script for Castlevania Lords of Shadow 2?

Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Wed Mar 05, 2014 11:07 pm
by TaylorMouse
Don't have the game (yet) so...
did you try using this script?
T
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Fri Mar 07, 2014 4:30 am
by matreco
Cheers for the reply,
Yup I did it stops here:
str += Bit.IntAsChar(var)
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Sat Mar 08, 2014 1:38 pm
by unlimited32
Untitled-1.jpg
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!!!
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Mon Mar 10, 2014 4:00 pm
by unlimited32
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?
Re: CASTLEVANIA LORDS OF SHADOW "HOW TO EXTRACT MESHES"?
Posted: Mon Mar 10, 2014 6:43 pm
by zardalu
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?
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.
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.