Infact i've tryed ^^ but when i load a model:
-Line 62,in noepyLoadModel
load_single_model(data, mdlList)
-Line 50, in load_single_model
parser.parser_file()
-Line 124, in parse_file
idstring = self.inFile.readyBytes(12)
AttributeError: 'SanaeParser' object has no attribute 'inFile'
Important information: this site is currently scheduled to go offline indefinitely by December 1st 2023.
If you wish to donate to attempt the preservation of tools and software somewhere else before it goes down, check the GoFundMe
If you wish to donate to attempt the preservation of tools and software somewhere else before it goes down, check the GoFundMe
scarlet legacy fail import with noesis
-
finale00
- M-M-M-Monster veteran

- Posts: 2382
- Joined: Sat Apr 09, 2011 1:22 am
- Has thanked: 170 times
- Been thanked: 307 times
Re: scarlet legacy fail import with noesis
That means it is expecting an attribute called self.inFile, which you probably deleted.
So you shouldn't delete it.
So you shouldn't delete it.
-
Drawing
- mega-veteran

- Posts: 283
- Joined: Wed Jan 11, 2012 10:21 pm
- Has thanked: 43 times
- Been thanked: 17 times
Re: scarlet legacy fail import with noesis
This is your py now:
I added the line "self.inFile = NoeBitStream(data)" that before i had deleted but now the plugin said:
-Line 62,in noepyLoadModel
load_single_model(data, mdlList)
-Line 50, in load_single_model
parser.parser_file()
-Line 129, in parse_file
meshName = self.read_name()
-line 75, in read_name
return self.noeStrFromBytes(self.inFile.readUint())
AttributeError: ' SanaeParser' object has no attribute 'noeStrFromBytes'
Code: Select all
from inc_noesis import *
import noesis
import rapi
import os
MODE = 0
def registerNoesisTypes():
handle = noesis.register("Silkroad Online", ".bms")
noesis.setHandlerTypeCheck(handle, noepyCheckType)
noesis.setHandlerLoadModel(handle, noepyLoadModel) #see also noepyLoadModelRPG
noesis.logPopup()
return 1
#check if it's this type based on the data
def noepyCheckType(data):
if len(data) < 12:
return 0
bs = NoeBitStream(data)
if bs.readBytes(12).decode("ASCII") != "JMXVBMS 0110":
return 0
return 1
def load_all_models(mdlList):
'''Load all models'''
#carry over from previous models
matList = []
texList = []
dirPath = rapi.getDirForFilePath(rapi.getInputName())
fileList = [file for file in os.listdir(dirPath) if file.lower().endswith(".bms")]
for file in fileList:
f = open(dirPath + file, 'rb')
data2 = f.read()
parser = SanaeParser(data2)
parser.parse_file()
matList.extend(parser.matList)
texList.extend(parser.texList)
mdl = rapi.rpgConstructModel()
mdl.setModelMaterials(NoeModelMaterials(texList, matList))
mdlList.append(mdl)
def load_single_model(data, mdlList):
'''Loads a single model. For testing purposes'''
parser = SanaeParser(data)
parser.parse_file()
mdl = rapi.rpgConstructModel()
mdl.setModelMaterials(NoeModelMaterials(parser.texList, parser.matList))
mdlList.append(mdl)
def noepyLoadModel(data, mdlList):
'''Load the model'''
ctx = rapi.rpgCreateContext()
if MODE == 1:
load_all_models(mdlList)
else:
load_single_model(data, mdlList)
return 1
class SanaeParser(object):
def __init__(self, data):
self.inFile = NoeBitStream(data)
self.texList = []
self.matList = []
def read_name(self):
return self.noeStrFromBytes(self.inFile.readUInt())
def parse_vertices(self, numVerts, vertType):
if vertType == 0:
vertBuff = self.inFile.readBytes(44*numVerts)
rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 44, 0)
rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 44, 12)
rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 44, 24)
elif vertType == 1024:
vertBuff = self.inFile.readBytes(52*numVerts)
rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 52, 0)
rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 52, 12)
rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 52, 24)
def parse_faces(self, numIdx):
idxBuff = self.inFile.readBytes(2*numIdx)
rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
def parse_bones(self, numBones, numVerts):
for i in range(numBones):
boneName = self.read_name()
if numBones:
for i in range(numVerts):
b1 = self.inFile.readByte()
w1 = self.inFile.readUShort()
b2 = self.inFile.readByte()
w2 = self.inFile.readUShort()
def load_texture(self, matName):
#texPath, ext = os.path.splitext(self.abspath.replace("mesh", "mtrl"))
#f = open(texPath + ".ddj")
try:
f = open(self.basename + ".ddj", 'rb')
f.seek(20)
tex = rapi.loadTexByHandler(f.read(), ".dds")
if tex is not None:
tex.name = matName
self.texList.append(tex)
material = NoeMaterial(matName, matName)
self.matList.append(material)
except:
pass
def parse_file(self):
idstring = self.inFile.readBytes(12)
offVerts, offBones, offFaces, unkOff1, unkOff2, ofsbbox, unkOff4, \
unk1, unk2, unkOff5, unk3, unk4, unk5, vertType, unk7 \
= self.inFile.read('15L')
meshName = self.read_name()
matName = self.read_name()
self.inFile.readUInt()
self.inFile.seek(offVerts)
numVerts = self.inFile.readUInt()
self.parse_vertices(numVerts, vertType)
self.inFile.seek(offBones)
numBones = self.inFile.readUInt()
self.parse_bones(numBones, numVerts)
self.inFile.seek(offFaces)
numFaces = self.inFile.readUInt()
rapi.rpgSetMaterial(matName)
self.parse_faces(numFaces*3)
self.load_texture(matName)I added the line "self.inFile = NoeBitStream(data)" that before i had deleted but now the plugin said:
-Line 62,in noepyLoadModel
load_single_model(data, mdlList)
-Line 50, in load_single_model
parser.parser_file()
-Line 129, in parse_file
meshName = self.read_name()
-line 75, in read_name
return self.noeStrFromBytes(self.inFile.readUint())
AttributeError: ' SanaeParser' object has no attribute 'noeStrFromBytes'
-
finale00
- M-M-M-Monster veteran

- Posts: 2382
- Joined: Sat Apr 09, 2011 1:22 am
- Has thanked: 170 times
- Been thanked: 307 times
Re: scarlet legacy fail import with noesis
noeStrFromBytes is part of inc_noesis, so you don't need self.
-
Drawing
- mega-veteran

- Posts: 283
- Joined: Wed Jan 11, 2012 10:21 pm
- Has thanked: 43 times
- Been thanked: 17 times
Re: scarlet legacy fail import with noesis
this is the line:
What self do i've to delete?
Code: Select all
return self.noeStrFromBytes(self.inFile.readUInt())-
Demonsangel
- mega-veteran

- Posts: 241
- Joined: Fri Aug 05, 2011 9:31 pm
- Location: Antwerp
- Has thanked: 13 times
- Been thanked: 41 times
Re: scarlet legacy fail import with noesis
I'm guessing it has to be
That is if the self.inFile.readUInt() is the length of the namestring.
Code: Select all
return noeStrFromBytes(self.inFile.readBytes(self.inFile.readUInt()))
-
Drawing
- mega-veteran

- Posts: 283
- Joined: Wed Jan 11, 2012 10:21 pm
- Has thanked: 43 times
- Been thanked: 17 times
Re: scarlet legacy fail import with noesis
Yeeeeeeeeeeeeeah!
Thanks to both! Thanks a lot !
This is the noesis py importer for silkroad if someone had needed it
Thanks to both! Thanks a lot !
This is the noesis py importer for silkroad if someone had needed it
Code: Select all
from inc_noesis import *
import noesis
import rapi
import os
MODE = 0
def registerNoesisTypes():
handle = noesis.register("Silkroad Online", ".bms")
noesis.setHandlerTypeCheck(handle, noepyCheckType)
noesis.setHandlerLoadModel(handle, noepyLoadModel) #see also noepyLoadModelRPG
noesis.logPopup()
return 1
#check if it's this type based on the data
def noepyCheckType(data):
if len(data) < 12:
return 0
bs = NoeBitStream(data)
if bs.readBytes(12).decode("ASCII") != "JMXVBMS 0110":
return 0
return 1
def load_all_models(mdlList):
'''Load all models'''
#carry over from previous models
matList = []
texList = []
dirPath = rapi.getDirForFilePath(rapi.getInputName())
fileList = [file for file in os.listdir(dirPath) if file.lower().endswith(".bms")]
for file in fileList:
f = open(dirPath + file, 'rb')
data2 = f.read()
parser = SanaeParser(data2)
parser.parse_file()
matList.extend(parser.matList)
texList.extend(parser.texList)
mdl = rapi.rpgConstructModel()
mdl.setModelMaterials(NoeModelMaterials(texList, matList))
mdlList.append(mdl)
def load_single_model(data, mdlList):
'''Loads a single model. For testing purposes'''
parser = SanaeParser(data)
parser.parse_file()
mdl = rapi.rpgConstructModel()
mdl.setModelMaterials(NoeModelMaterials(parser.texList, parser.matList))
mdlList.append(mdl)
def noepyLoadModel(data, mdlList):
'''Load the model'''
ctx = rapi.rpgCreateContext()
if MODE == 1:
load_all_models(mdlList)
else:
load_single_model(data, mdlList)
return 1
class SanaeParser(object):
def __init__(self, data):
self.inFile = NoeBitStream(data)
self.texList = []
self.matList = []
def read_name(self):
return noeStrFromBytes(self.inFile.readBytes(self.inFile.readUInt()))
def parse_vertices(self, numVerts, vertType):
if vertType == 0:
vertBuff = self.inFile.readBytes(44*numVerts)
rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 44, 0)
rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 44, 12)
rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 44, 24)
elif vertType == 1024:
vertBuff = self.inFile.readBytes(52*numVerts)
rapi.rpgBindPositionBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 52, 0)
rapi.rpgBindNormalBufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 52, 12)
rapi.rpgBindUV1BufferOfs(vertBuff, noesis.RPGEODATA_FLOAT, 52, 24)
def parse_faces(self, numIdx):
idxBuff = self.inFile.readBytes(2*numIdx)
rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, numIdx, noesis.RPGEO_TRIANGLE, 1)
def parse_bones(self, numBones, numVerts):
for i in range(numBones):
boneName = self.read_name()
if numBones:
for i in range(numVerts):
b1 = self.inFile.readByte()
w1 = self.inFile.readUShort()
b2 = self.inFile.readByte()
w2 = self.inFile.readUShort()
def load_texture(self, matName):
#texPath, ext = os.path.splitext(self.abspath.replace("mesh", "mtrl"))
#f = open(texPath + ".ddj")
try:
f = open(self.basename + ".ddj", 'rb')
f.seek(20)
tex = rapi.loadTexByHandler(f.read(), ".dds")
if tex is not None:
tex.name = matName
self.texList.append(tex)
material = NoeMaterial(matName, matName)
self.matList.append(material)
except:
pass
def parse_file(self):
idstring = self.inFile.readBytes(12)
offVerts, offBones, offFaces, unkOff1, unkOff2, ofsbbox, unkOff4, \
unk1, unk2, unkOff5, unk3, unk4, unk5, vertType, unk7 \
= self.inFile.read('15L')
meshName = self.read_name()
matName = self.read_name()
self.inFile.readUInt()
self.inFile.seek(offVerts)
numVerts = self.inFile.readUInt()
self.parse_vertices(numVerts, vertType)
self.inFile.seek(offBones)
numBones = self.inFile.readUInt()
self.parse_bones(numBones, numVerts)
self.inFile.seek(offFaces)
numFaces = self.inFile.readUInt()
rapi.rpgSetMaterial(matName)
self.parse_faces(numFaces*3)
self.load_texture(matName)