XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Tue Aug 22, 2017 12:02 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Tue May 13, 2014 12:06 am 
Offline
advanced
User avatar

Joined: Sat Oct 30, 2010 1:39 pm
Posts: 58
Has thanked: 18 times
Have thanks: 9 times














You can make the ads go away by registering

I know this may sound dumb but i got lost in the very first steps.

I just did this:

Code:
#Noesis Python model import+export test module, imports/exports some data from/to a made-up format

from inc_noesis import *

import noesis

#rapi methods should only be used during handler callbacks
import rapi

#registerNoesisTypes is called by Noesis to allow the script to register formats.
#Do not implement this function in script files unless you want them to be dedicated format modules!
def registerNoesisTypes():
   handle = noesis.register("S4 League", ".scn")
   noesis.setHandlerTypeCheck(handle, noepyCheckType)
   noesis.setHandlerLoadModel(handle, noepyLoadModel) #see also noepyLoadModelRPG
   #noesis.setHandlerWriteModel(handle, noepyWriteModel)
   #noesis.setHandlerWriteAnim(handle, noepyWriteAnim)

   noesis.logPopup()
   print("The log can be useful for catching debug prints from preview loads.\nBut don't leave it on when you release your script, or it will probably annoy people.")
   return 1


#check if it's this type based on the data
def noepyCheckType(data):
   bs = NoeBitStream(data)
   if bs.readInt() != 0x01000000 :
      return 0
   return 1

#load the model
def noepyLoadModel(data, mdlList):
   ctx = rapi.rpgCreateContext()
   bs = NoeBitStream(data)
   rapi.rpgClearBufferBinds()
   hdrInfo = bs.read("i")
   print(hdrInfo)   
   return 1


Not a big deal, just trying to read an int and in the guide it said it was going to be written in the output log, but only this shows up:

Image

I think it has something to do with the header reading, but i don't know what to do.

I'm not sure if this is supposed to happen, since the images from the tutorial are missing and i'm not sure if i should continue or not.

I know this is one of those mistakes that will make you be ashamed for life, but i don't know what is wrong, i'm sorry :(

File i'm trying to read is attached in the post


Attachments:


You do not have the required permissions to view the files attached to this post. Register to gain access.



Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Tue May 13, 2014 7:10 am 
Offline
M-M-M-Monster veteran
M-M-M-Monster veteran
User avatar

Joined: Fri Apr 20, 2012 9:24 am
Posts: 2096
Has thanked: 405 times
Have thanks: 1058 times
use this line:
if bs.readInt() != 0x00000001 :

because the signature 01 00 00 00 in the header is little endian.

_________________
Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip

"We are Microsoft. You will be assimilated. Resistance is Futile."


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Wed May 14, 2014 2:46 am 
Offline
advanced
User avatar

Joined: Sat Oct 30, 2010 1:39 pm
Posts: 58
Has thanked: 18 times
Have thanks: 9 times
Thank you for your help shakotay2, once again you got me out of this nooby issues :erm:

I got another question, how does the Vertex Buff actually works? Since in the guide they use the following:

Code:
VertBuff = bs.readBytes(VCount[0] * 0x58)
   rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, 88, 0)
   rapi.rpgCommitTriangles(None, noesis.RPGEODATA_USHORT, VCount[0], noesis.RPGEO_POINTS, 1)
   mdl = rapi.rpgConstructModel()
   mdlList.append(mdl)         #important, don't forget to put your loaded model in the mdlList


I don't really know what a vertex with a size of 88 bytes meant, so i started trying random numbers until one worked, which was 24.

Image
Using sword.scn
(Vertex count: 0x0986, after that there are 345 floats and the int that tells you the faces, which is positioned at 0x19B6, in this case are 282 faces)


the bad thing for this is that the number of the vertices, faces, uvs, etc are between the buffers, so the only way to be able to continue to get the number of faces is by using 0x04 instead of 0x18

So my question is, since the coordinates are made by floats,and since floats are 4 bytes, should i use 4 or should i use 24 and go back to the position of the faces count?, because if i do the last thing i said using FaceBuff = bs.readBytes(FCount[0] * 2) the following result appears:

Image

Thanks in advance again ^^


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Thu May 15, 2014 1:48 pm 
Offline
M-M-M-Monster veteran
M-M-M-Monster veteran
User avatar

Joined: Fri Apr 20, 2012 9:24 am
Posts: 2096
Has thanked: 405 times
Have thanks: 1058 times
didn't get exactly what you mean.
use this for sword.scn (and only sword.scn):
Code:
#Noesis Python model import+export test module, imports/exports some data from/to a made-up format

from inc_noesis import *

import noesis

#rapi methods should only be used during handler callbacks
import rapi

#registerNoesisTypes is called by Noesis to allow the script to register formats.
#Do not implement this function in script files unless you want them to be dedicated format modules!
def registerNoesisTypes():
   handle = noesis.register("S4 League", ".scn")
   noesis.setHandlerTypeCheck(handle, noepyCheckType)
   noesis.setHandlerLoadModel(handle, noepyLoadModel) #see also noepyLoadModelRPG
   #noesis.setHandlerWriteModel(handle, noepyWriteModel)
   #noesis.setHandlerWriteAnim(handle, noepyWriteAnim)

   noesis.logPopup()
   print("The log can be useful for catching debug prints from preview loads.\nBut don't leave it on when you release your script, or it will probably annoy people.")
   return 1


#check if it's this type based on the data
def noepyCheckType(data):
   bs = NoeBitStream(data)
   if bs.readInt() != 0x00000001 :
      return 0
   return 1


#load the model
def noepyLoadModel(data, mdlList):
   ctx = rapi.rpgCreateContext()
   bs = NoeBitStream(data)
   rapi.rpgClearBufferBinds()
   hdrInfo = bs.read("i")
   print(hdrInfo)   
   # works for sword.scn only!
   bs.seek(0x982, NOESEEK_ABS)  #Seek to counts
   facesCount = bs.read("i")   # faces count
   vertsCount = bs.read("i")
   VertBuff = bs.readBytes(vertsCount[0] * 12)
   facesCount2 = bs.read("i")   # faces count again
   print(facesCount2)
   if facesCount2!=facesCount:
      print("error: 2nd facesCount doesn't match!")
      return 1
   idxBuff = bs.readBytes(facesCount[0] *2 *3)
   rapi.rpgBindPositionBufferOfs(VertBuff, noesis.RPGEODATA_FLOAT, 12, 0)
   #rapi.rpgCommitTriangles(None, noesis.RPGEODATA_USHORT, facesCount[0], noesis.RPGEO_POINTS, 1)
   rapi.rpgCommitTriangles(idxBuff, noesis.RPGEODATA_USHORT, facesCount[0]*3, noesis.RPGEO_TRIANGLE, 1)
   mdl = rapi.rpgConstructModel()
   mdlList.append(mdl)          #important, don't forget to put your loaded model in the mdlList

   return 1
it's just a quick hack - I'm not familiar with Noesis.

(Maybe it's a good idea to edit further questions into your previous post?
So not to spam chrrox' tutorial.)

_________________
Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip

"We are Microsoft. You will be assimilated. Resistance is Futile."


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Thu Jun 19, 2014 5:24 pm 
Offline
M-M-M-Monster veteran
M-M-M-Monster veteran

Joined: Sat Apr 09, 2011 1:22 am
Posts: 2387
Has thanked: 170 times
Have thanks: 277 times
You should bump chrrox's tutorial as much as you can.

_________________
Model Import Plugins/Scripts

Noesis Plugins | Reference files

Reference
Guide to 3D model reversal | 3D glossary


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Sun Sep 28, 2014 7:43 pm 
Offline
ultra-n00b

Joined: Sun Sep 28, 2014 7:31 pm
Posts: 9
Has thanked: 0 time
Have thanks: 0 time
Thanks for the tutorial! Time to dust off my python skills (and indenting!)


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Thu Oct 30, 2014 10:28 am 
Offline
beginner

Joined: Sat Feb 19, 2011 1:18 am
Posts: 37
Has thanked: 4 times
Have thanks: 10 times
anyone have images for this this tutorial ?

thx ...


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Thu Jun 25, 2015 10:17 am 
Offline
advanced

Joined: Sat Oct 11, 2014 10:29 pm
Posts: 46
Has thanked: 2 times
Have thanks: 1 time
Hello. i just began writing a script for a game and i think i got the wrong header because i get this error:
Image

http://sta.sh/21xrx3h6mxxn?edit=1 - these are the model and the script,anyone able to tell me what's wrong and how to fix it?


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Thu Jun 25, 2015 10:33 am 
Offline
Moderator
User avatar

Joined: Sun May 18, 2008 3:01 pm
Posts: 2431
Has thanked: 56 times
Have thanks: 1175 times
the string you are showing is not ascii and its not 16 bytes long.
try something like

NOEPY_HEADER = 0x334D430A

#check if it's this type based on the data
def noepyCheckType(data):
bs = NoeBitStream(data)
if len(data) < 4:
return 0
if bs.readUInt() != NOEPY_HEADER:
return 0


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Thu Jun 25, 2015 10:42 am 
Offline
advanced

Joined: Sat Oct 11, 2014 10:29 pm
Posts: 46
Has thanked: 2 times
Have thanks: 1 time
It gives me an other error this time Image
It's my first time writing a noesis plugin, so I'm a little bit lost here, sorry


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Thu Jun 25, 2015 11:00 am 
Offline
Moderator
User avatar

Joined: Sun May 18, 2008 3:01 pm
Posts: 2431
Has thanked: 56 times
Have thanks: 1175 times
Here is a start for you.


Attachments:


You do not have the required permissions to view the files attached to this post. Register to gain access.



Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Thu Jun 25, 2015 11:23 am 
Offline
advanced

Joined: Sat Oct 11, 2014 10:29 pm
Posts: 46
Has thanked: 2 times
Have thanks: 1 time
Thank you so much, i hope there won't be any more problems ^^'


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Fri Apr 29, 2016 12:58 am 
Offline
VIP member
VIP member

Joined: Wed Nov 05, 2008 12:16 pm
Posts: 842
Has thanked: 1806 times
Have thanks: 437 times
finale00 wrote:
There are several ways to go to different positions of a file (eg: seeking)

They are typically seeking from
-beginning of the file (absolute offset) eg: seek_abs
-current position (relative offset) eg: seek_curr
-end of file (seeking backwards)


So what is the correct syntax in Noesis for seeking to an offset from the end of a file?
i have been trying something like bs.seek(-44, 2) without success. :(

_________________
Noesis
Hex2obj
QuickBMS
TextureFinder
Unity Assets Bundle Extractor


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Fri Apr 29, 2016 4:32 am 
Offline
M-M-M-Monster veteran
M-M-M-Monster veteran
User avatar

Joined: Fri Apr 20, 2012 9:24 am
Posts: 2096
Has thanked: 405 times
Have thanks: 1058 times
"2" is ony valid when using import os, I guess - since there's
NOESEEK_ABS = 0 and NOESEEK_REL = 1 only.

I tried such (import os required)
Code:
   fileName= 'G:\test.txt'

   statinfo = os.stat(fileName)
   print("statinfo, file size: ", statinfo.st_size)
   fsize= statinfo.st_size
   with open(fileName, "rb") as f:
       #f.seek(fsize-11, os.SEEK_SET)
       f.seek(-11, 2)
       a= f.read()
       print("a: ", a)

where test.txt is an ASCII file, opened in binary mode (to avoid weird outputs from print())
Both f.seek lines worked - if you use f.seek(-11, 2) you don't need to get the file size!

But I dunno how to get the filename via rapi, when the file is opened in the Noesis file explorer -

bs = NoeBitStream(data)
bs.seek(-11, 2) didn't work.

_________________
Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip

"We are Microsoft. You will be assimilated. Resistance is Futile."


Top
 Profile  
 
 Post subject: Re: Noesis tutorial Basic Model
PostPosted: Sat Apr 30, 2016 1:18 am 
Offline
VIP member
VIP member

Joined: Wed Nov 05, 2008 12:16 pm
Posts: 842
Has thanked: 1806 times
Have thanks: 437 times
Okay thanks, i hoped there was something simple i was overlooking like NOESEEK_END i could use. i don't know enough about programming to make work what you have there. i will have to find another way :(

editx2
okay this works :D
Code:
    bs.seek(len(data) - 0x2C, NOESEEK_ABS) #goto 44 bytes from end of file

_________________
Noesis
Hex2obj
QuickBMS
TextureFinder
Unity Assets Bundle Extractor


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group