Just print out the index you're trying to get and the size of your list...
Maybe you're just parsing the file wrong.
Important information: this site is currently scheduled to go offline indefinitely by end of the year.
dino and aliens msh files
-
- advanced
- Posts: 75
- Joined: Sat Oct 30, 2010 11:57 am
- Has thanked: 1 time
- Been thanked: 5 times
Re: dino and aliens msh files
this how shakotay2 imported texture coordinates?
for ms3d files is yes:
as it will be for .msh files?
just do not know how to write it in a script
for ms3d files is yes:
Code: Select all
# read triangles
faces = []
uvs = []
for i in xrange(numTriangles):
# skip flags
file.read(2)
# read indices (faces)
faces.append(struct.unpack("HHH", file.read(3*2)))
# read normals
normals = struct.unpack("fffffffff", file.read(3*3*4))
# read texture coordinates
s = struct.unpack("fff", file.read(3*4))
t = struct.unpack("fff", file.read(3*4))
# store texture coordinates
uvs.append([[s[0], 1-t[0]], [s[1], 1-t[1]], [s[2], 1-t[2]]])
if faces[-1][2] == 0: # Cant have zero at the third index
faces[-1] = faces[-1][1], faces[-1][2], faces[-1][0]
uvs[-1] = uvs[-1][1], uvs[-1][2], uvs[-1][0]
# skip smooth group
file.read(1)
# skip group
file.read(1)
# add the faces to the mesh
mesh.faces.extend(faces)
# set texture coordinates
for i in xrange(numTriangles):
mesh.faces[i].uv = [Vector(uvs[i][0]), Vector(uvs[i][1]), Vector(uvs[i][2])]
just do not know how to write it in a script
- shakotay2
- MEGAVETERAN
- Posts: 4285
- Joined: Fri Apr 20, 2012 9:24 am
- Location: Nexus, searching for Jim Kirk
- Has thanked: 1147 times
- Been thanked: 2242 times
Re: dino and aliens msh files
1) did you integrate some debugging lines into your script like recommended by finale00?
2) I'm not very familiar with python script but I made some changes to your script
(including some "print" commands for a debug output to the blender console).
Tested box.msh: 4 of the 6 textured sides of the cube are ok, two are not.
Don't have more time to solve this but I think you should do it.
2) I'm not very familiar with python script but I made some changes to your script
(including some "print" commands for a debug output to the blender console).
Tested box.msh: 4 of the 6 textured sides of the cube are ok, two are not.
Don't have more time to solve this but I think you should do it.
Code: Select all
#!BPY
"""
Name: 'Dino and Aliens2 (.msh)...'
Blender: 249
Group: 'Import'
"""
__author= "Boguslaw Radomski"
__version__= "0.01"
__bpydoc__ = """\
Dino and Aliens msh importer by Boguslaw Radomski
This script imports a Dino and Aliens msh files to Blender.
Note, This loads mesh objects only, materials and animations are not supported yet.
I do not know how to read material from a file and add support to Blender.
"""
# ***** GPL LICENSE *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
#
# --------------------------------------------------------------------------
# importing modules
import Blender
import struct
from Blender.Mathutils import Vector
# imports a msh file to the current scene
def load_msh(filename):
# get scene
scn = Blender.Scene.GetCurrent()
if scn == None:
return "No scene to import to!"
Blender.Window.WaitCursor(1)
# open the file
file = open(filename, 'rb')
# read id to check if the file is a dino and aliens msh file
id = file.read(3)
if id != 'MSH':
print 'this is not MSH file'
return
file.seek(29,0)
# Create the mesh
scn.objects.selected = []
mesh = Blender.Mesh.New("name")
meshOb = scn.objects.new(mesh)
# read the number of vertices
numVerts = struct.unpack('L', file.read(4))[0]
# read number of triangles
numTriangles = struct.unpack('L', file.read(4))[0]
# read vertices
verts = []
for i in xrange(numVerts):
verts.append(struct.unpack('fff', file.read(3*4)))
# add the vertices to the mesh
mesh.verts.extend(verts)
# read triangles
faces = []
for i in xrange(numTriangles):
# read indices (faces)
faces.append(struct.unpack('iii', file.read(3*4)))
# add the faces to the mesh
mesh.faces.extend(faces)
#--- shakotay2 start ----------------------------
uvs = []
# read texture coordinates
for i in xrange(numTriangles):
s = struct.unpack("ff", file.read(2*4))
t = struct.unpack("ff", file.read(2*4))
u = struct.unpack("ff", file.read(2*4))
print s
print t
print u
print '\n'
# store texture coordinates
uvs.append([[s[0], s[1]], [t[0], t[1]], [u[0], u[1]]])
# set texture coordinates
for i in xrange(numTriangles):
mesh.faces[i].uv = [Vector(uvs[i][0]), Vector(uvs[i][1]), Vector(uvs[i][2])]
print i
print Vector(uvs[i][0])
print Vector(uvs[i][1])
print Vector(uvs[i][2])
print '\n'
#--- shakotay2 end ---------------------------------
Blender.Window.WaitCursor(0)
# refresh the view
Blender.Redraw()
# close the file
file.close()
Blender.Window.FileSelector(load_msh, 'import msh', '*.msh')
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
-
- advanced
- Posts: 75
- Joined: Sat Oct 30, 2010 11:57 am
- Has thanked: 1 time
- Been thanked: 5 times
Re: dino and aliens msh files
thanks it works
can in this way i will be know how to do
animation can for the time being leave
but topic yet not closed
can in this way i will be know how to do
animation can for the time being leave
but topic yet not closed
Last edited by Bogus on Sat Sep 01, 2012 10:47 am, edited 2 times in total.
- shakotay2
- MEGAVETERAN
- Posts: 4285
- Joined: Fri Apr 20, 2012 9:24 am
- Location: Nexus, searching for Jim Kirk
- Has thanked: 1147 times
- Been thanked: 2242 times
Re: dino and aliens msh files
I don't think so;Bogus wrote:whether this possible that at the beginning msh files is bone?
could you please give an example?
You can find strings like "Bip01", "Spine", "L ForeArm", "R Foot" etc. in the *.skl files.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
-
- advanced
- Posts: 75
- Joined: Sat Oct 30, 2010 11:57 am
- Has thanked: 1 time
- Been thanked: 5 times
Re: dino and aliens msh files
ananas.msh, yabloko_0,25.msh, yabloko_0,5.msh and yabloko_1.msh
the characters are also animated, but are in skl files
i do not know where they are vertices and faces a little i was looking for
script can alone write
the characters are also animated, but are in skl files
i do not know where they are vertices and faces a little i was looking for
script can alone write
- shakotay2
- MEGAVETERAN
- Posts: 4285
- Joined: Fri Apr 20, 2012 9:24 am
- Location: Nexus, searching for Jim Kirk
- Has thanked: 1147 times
- Been thanked: 2242 times
Re: dino and aliens msh files
The structure of ananas.msh looks like this:
# 120 vertices
# 1. 0x25:
v 0.353530 0.739885 2.152248
v 0.641311 0.889165 3.350888
v 1.046994 0.941949 4.351346
...
v -1.456776 0.804483 -3.482513
v -0.897434 1.574350 -3.482513
v 0.007599 1.868413 -3.482513
v 0.007599 0.328678 -3.888980
# 591 face Indices (197 faces)
# 2. 0x5c5:
f 48 57 56
f 58 57 49
f 49 59 58
...
f 80 81 95
f 97 90 82
f 81 82 90
# (vertex related) face index min/max: 1 / 120
# texture related face indices: 1..591 (not in the file)
# Texture coords
# 0xf01
vt 0.676453 0.304822
vt 0.469777 0.162897
vt 0.677072 0.072721
...
vt 0.620055 0.368678
vt 0.452570 0.264222
vt 0.676453 0.304822
# last address= 0x2178
File size is 0x2179;
so no animation/skinning related data in there.
Same with yabloko_1.msh.
The fruits are rotating only?
This doesn't require an animation file; perhaps they're just changing
the angle of the fruits via its rotation matrix .
# 120 vertices
# 1. 0x25:
v 0.353530 0.739885 2.152248
v 0.641311 0.889165 3.350888
v 1.046994 0.941949 4.351346
...
v -1.456776 0.804483 -3.482513
v -0.897434 1.574350 -3.482513
v 0.007599 1.868413 -3.482513
v 0.007599 0.328678 -3.888980
# 591 face Indices (197 faces)
# 2. 0x5c5:
f 48 57 56
f 58 57 49
f 49 59 58
...
f 80 81 95
f 97 90 82
f 81 82 90
# (vertex related) face index min/max: 1 / 120
# texture related face indices: 1..591 (not in the file)
# Texture coords
# 0xf01
vt 0.676453 0.304822
vt 0.469777 0.162897
vt 0.677072 0.072721
...
vt 0.620055 0.368678
vt 0.452570 0.264222
vt 0.676453 0.304822
# last address= 0x2178
File size is 0x2179;
so no animation/skinning related data in there.
Same with yabloko_1.msh.
The fruits are rotating only?
This doesn't require an animation file; perhaps they're just changing
the angle of the fruits via its rotation matrix .
Last edited by shakotay2 on Sat Sep 01, 2012 12:08 pm, edited 1 time in total.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
- shakotay2
- MEGAVETERAN
- Posts: 4285
- Joined: Fri Apr 20, 2012 9:24 am
- Location: Nexus, searching for Jim Kirk
- Has thanked: 1147 times
- Been thanked: 2242 times
Re: dino and aliens msh files
There is only one way to prove this: you'll have to change some bytes (the 0x80 for example)
and look whether the rotation of the corresponding fruits slows down or accelerates.
(I would be surprised - but you know: "you never know..." )
And you'll have to repack the *.msh to a *.dat file again, I think.
(Didn't try this so far; so don't know whether it works.)
and look whether the rotation of the corresponding fruits slows down or accelerates.
(I would be surprised - but you know: "you never know..." )
And you'll have to repack the *.msh to a *.dat file again, I think.
(Didn't try this so far; so don't know whether it works.)
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"