I'm trying to figure out .k2mp model format.
I have problem with face indices, maybe someone could help me with them?
Here's sample character file http://www.mediafire.com/?8cew8426adpzbw8
And here's basic script for this file, it loads sword model. Thanks in advance.
fname = getOpenFileName \
caption:"Open .K2MP from Mesh folder" \
types:"Samurai Shodown Sen Mesh(*.K2MP)|*.K2MP" \
historyCategory:"Samurai Shodown SenObjectPresets"
f = fopen fname "rb"
clearlistener()
Face_array=#()
Vert_array=#()
UV_array=#()
fseek f 0x1A9A #seek_set
vertcount=readlong f
print vertcount
for x = 1 to vertcount/3 do(
vx=readfloat f
vy=readfloat f
vz=readfloat f
append Vert_array[vx,vy,vz]
)
unk1=readshort f
indices=readlong f
print indices
FaceDirection = 1
f1 = Readlong f +1
f2 = Readlong f +1
for i = 3 to indices-1 do (
f3 = Readlong f +1
FaceDirection *= 1
if (f3 != f1) AND (f3 != f2) then (
if FaceDirection > 0 then append Face_array [f1,f2,f3]
else append Face_array [f1,f3,f2]
)
f1 = f2
f2 = f3
)
fseek f 0x6B76 #seek_set
uvcount=readlong f
fseek f 0x6 #seek_cur
for x = 1 to uvcount do(
tu=readfloat f
tv=readfloat f
append UV_array[tu,tv,0]
)
msh = mesh vertices:Vert_array faces:Face_array
msh.numTVerts = UV_array.count
buildTVFaces msh
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]
Karpati, thanks you very much for help Everything works perfect now, I know .k2mp it's container with a lot of models inside. Texture are straight .dds but also grouped in .k2mp file.
You do not have the required permissions to view the files attached to this post.
zaramot wrote:Karpati, thanks you very much for help Everything works perfect now, I know .k2mp it's container with a lot of models inside. Texture are straight .dds but also grouped in .k2mp file.
I really love the Samurai Shodown game, give me lots of memorys, for me the best one its the Samurai Shodown II, afther this game the company fuck the game with RUSH SLASH MODES and back front movement in screen and lots of things to Lost the original game esence, i shure this its Genjuro, hope u can share the characters files i really like them .
fname = getOpenFileName \
caption:"Open .K2MP from Mesh folder" \
types:"Samurai Shodown Sen Mesh(*.K2MP)|*.K2MP" \
historyCategory:"Samurai Shodown SenObjectPresets"
f = fopen fname "rb"
fn ReadFixedString bstream fixedLen =
(
local str = ""
for i = 1 to fixedLen do
(
str += bit.intAsChar (ReadByte bstream #unsigned)
)
str
)
clearlistener()
Face_array=#()
Vert_array=#()
UV_array=#()
--find string "Mesh" remember offset and put it here
fseek f 0x19D4A #seek_set
fseek f 0xE #seek_cur
vertcount=readlong f
print vertcount
for x = 1 to vertcount/3 do(
vx=readfloat f
vy=readfloat f
vz=readfloat f
append Vert_array[vx,vz,vy]
)
unk1=readshort f
count=readlong f
faces=readlong f
print faces
for x = 1 to faces do (
fcount=readlong f
fa=readlong f + 1
fb=readlong f + 1
fc=readlong f + 1
append Face_array [fc,fb,fa]
)
id=readshort f
NameSecSize=readlong f
SecName=ReadFixedString f NameSecSize
fseek f 0xE #seek_cur
ncount=readlong f
print ncount
for x = 1 to ncount/3 do(
n1=readfloat f
n2=readfloat f
n3=readfloat f
)
unk1=readshort f
ncount=readlong f
nfaces=readlong f
print nfaces
for x = 1 to nfaces do (
nfcount=readlong f
na=readlong f + 1
nb=readlong f + 1
nc=readlong f + 1
)
unk2=readshort f
id=readshort f
NameSecSize=readlong f
SecName=ReadFixedString f NameSecSize
fseek f 0xE #seek_cur
uvcount=readlong f
print uvcount
Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
for x = 1 to uvcount/2 do(
tu=readfloat f
tv=readfloat f*-1
append UV_array[tu,tv,0]
)
msh = mesh vertices:Vert_array faces:Face_array
msh.numTVerts = UV_array.count
buildTVFaces msh
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]
fclose f
I will not finish script for this game till distant future, models are very low-poly with low textures and format is bit annoying. Maybe you could import them with tools for DirectX Binary format?! I don't know
[/quote]
??? hmm its too difficult for my kinky brain[/quote]
The DirectX format stores the faces as N-sided polygons:
If 'Number of Vertices in the actual Face'=3 it is a triangle,
If 'Number of Vertices in the actual Face'=4 it is a quadrangle,
etc...
If 'Number of Vertices in the actual Face'=3 you must read 3 long (pointer to the vertex table)
If 'Number of Vertices in the actual Face'=4 you must read 4 long (pointer to the vertex table).
etc...