Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Spotlight: Señor Casaroja's Noesis

General game file tools that are useful for more than one game
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Señor Casaroja's Noesis

Post by finale00 »

I was hoping in that year, I would be able to load up skeletons and animations as well.
Lol. Never found the motivation to go further.
MrAdults
Moderator
Posts: 1007
Joined: Mon Mar 23, 2009 2:57 am
Has thanked: 44 times
Been thanked: 505 times

Re: Señor Casaroja's Noesis

Post by MrAdults »

Oh, you still haven't made a script that handles skeletons? I noticed someone did, in...I forget the game already, it was the thread I just posted in about the bone palettes. It's really not too tough, you just need to create a NoeMat43 to represent the bone matrix and create a NoeBone with it along with the bone name and hierarchy info. Usually games will store bone orientations as quaternion+translation (and sometimes scale too), or a 4x4 matrix. For those you can just use NoeQuat or NoeMat44 and convert directly to NoeMat43. You may also have to transpose the row/column order sometimes. And sometimes games store bones in model space, and sometimes in parent-relative space, so you have to watch out for that too. There's a good bit of stuff to be aware of, but for most games it isn't too tricky, and there are some examples in existing scripts. Let me know if you run into any specific trouble. (or maybe you already let me know and I missed it, I've overlooked a lot of shit in the last few months)

Once you have bones down, animations are usually similar. But games get a lot trickier in storing them. I'm usually not willing to put forth the time investment, unless the game requires the animation data to transform the vertex data, the animation format is simple (like a flat format with little to no compression), or I just really really want those animations.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Señor Casaroja's Noesis

Post by finale00 »

Ya, the concept seems pretty straightforward and how they are stored can be pretty straightforward as well.
I just never actually took the time to sit down, look at the examples, and see what kind of functions I will actually use. The plan was to just grab an existing format and re-write it in noesis since all of the bones are done, but...well I said I'd do that 6 months ago but clearly I haven't done that.

I've looked at max scripts and blender scripts that do a lot of crazy things with the bone transforms and stuff, but ya.

Also, I was reading the titanquest thread where the skeleton was imported and you mentioned something about bone multiplying and bone hierarchy?
Is that something like, given 3 bones and their transforms with the following hierarchy

Code: Select all

Bone 1 - transform1
   Bone 2 - transform2
      Bone 3 - transform3
Where bone 1 is a parent of bone 2, and bone 2 is a parent of bone 3, the transform we apply to bone 3 is (transform1 * transform2 * transform3)?
pixellegolas
ultra-veteran
ultra-veteran
Posts: 423
Joined: Mon Aug 11, 2008 11:30 pm
Has thanked: 27 times
Been thanked: 15 times

Re: Señor Casaroja's Noesis

Post by pixellegolas »

mradults + finale + chrrox should sit down in a room and just make magic. I can just run around and pass out some nice beverage and have that special look when staring at famous people
MrAdults
Moderator
Posts: 1007
Joined: Mon Mar 23, 2009 2:57 am
Has thanked: 44 times
Been thanked: 505 times

Re: Señor Casaroja's Noesis

Post by MrAdults »

Yeah, that's right. Transforms down a skeletal hierarchy are cumulative all the way down the hierarchy. That's what the multiplyBones function does for you, it transforms the bone matrices down the hierarchy and returns the bones with their new matrices set to absolute modelspace matrices which are no longer relative to their parents. (which is the form Noesis expects them in, contrary to animation matrices, which are expected in parent-relative space so that they can be easily stacked and/or applied to any point in the hierarchy along with other hierarchy-based bone modifiers)

Likewise, you can convert a modelspace bone matrix back to parent-relative by just multiplying the modelspace bone matrix with the modelspace inverse bone matrix of the parent.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Señor Casaroja's Noesis

Post by finale00 »

How do I specify texture/animation export format in command-line?

Also it looks like I can't use outFile.tell() without it throwing an exception

Code: Select all

RuntimeError: Attempted to unpack on a write stream
Demonsangel
mega-veteran
mega-veteran
Posts: 241
Joined: Fri Aug 05, 2011 9:31 pm
Location: Antwerp
Has thanked: 13 times
Been thanked: 41 times

Re: Señor Casaroja's Noesis

Post by Demonsangel »

Image
I have a question about applying textures on models when importing.
I followed the tutorial written by in the tutorial section and used the following code:

Code: Select all

for i in range(numParam):
				texLength.append(self.inFile.readUInt())
				texMat.append(self.read_string(texLength[i]))
				texType.append(self.inFile.readUInt())
				if texType[i] ==7:
					length=self.inFile.readUInt()
					texString.append(self.read_string(length))
					texName = texString[i].split('\\')
					texName = texName[-1]
					if rapi.checkFileExists(rapi.getDirForFilePath(rapi.getInputName())+texName):
						print(texName)
					else: print("Not found:",texName)
					material = NoeMaterial(texMat[i],texName)
					rapi.rpgSetMaterial(texMat[i])
					self.matList.append(material)
				elif texType[i] ==9:
					texString.append(self.inFile.read('3f'))
				elif texType[i] ==10:
					texString.append(self.inFile.read('f'))
mdl=rapi.rpgConstructModel()
mdl.setModelMaterials(NoeModelMaterials(self.texList, self.matList))
However the texture never shows up (under mesh0 in the image the material shows up as Material: " ") unless I do

Code: Select all

mdl.meshes[0].setMaterial("baseTexture")
I hardcoded the name here but I hope you get what I mean.

Is the tutorial wrong or am I missing something?
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Señor Casaroja's Noesis

Post by finale00 »

Did you call

Code: Select all

rapi.rpgSetMaterial(matName)
Before committing the triangles?
MrAdults
Moderator
Posts: 1007
Joined: Mon Mar 23, 2009 2:57 am
Has thanked: 44 times
Been thanked: 505 times

Re: Señor Casaroja's Noesis

Post by MrAdults »

finale00: -imgoutex ".img" -animoutex ".anm" (but they have the problem of not being able to distinguish between formats that have the same extension, I need to fix that at some point... for the time being if that becomes a problem for you in development, you can just add a 2 to your extension string or something) Also, side note, it's probably a lot faster development-wise to just run the interface and bind a shortcut to "Reload plugins" to reload your scripts when you make changes. It should take less initialization time than command line mode, and you don't have to load the output file up separately to see your results. Not that you should change your existing workflow if you really like it, I just prefer to work that way myself when I'm writing Python scripts.

That exception was only there primarily for read attempts on write streams, I didn't even consider tell/seek/etc. I just removed it in the new version, so update and you should be fine.

Demonsangel: Your "rapi.rpgSetMaterial(texMat)" call is in the wrong place. That function should be called before you commit triangles to say "This is the material you should use with these triangles I'm about to feed you." Seems like you didn't actually paste the code where you're feeding the triangles in though.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Señor Casaroja's Noesis

Post by finale00 »

Alright it works.

Ya, I use reload plugins when writing importers.
For export, I just use command-line cause it's faster to test.

The format I'm exporting to does not support dds (choices I have are bmp, tga, or png).
This actually leads to several issues and design decisions when I'm writing plugins.

First, if my source format uses dds files, then I'm going to have to convert them to a usable format.

Now, if they're stored with the model data, then it's ok I will create Tex objects during the parsing and can tell noesis to export them as png.

If they're stored separately in like the local folder or even a completely different place, I will most likely be referencing them and so they won't be exported.

Second is the texName that the materials reference. They will usually give the tex path or the tex name, with their .dds extension. If I am going to be converting to some other format, I will need to update all of the materials accordingly. This is not a real issue because I can hardcode my exporter to say "dds? Ok, then let's just rename it and update the material accordingly".

But the other issue is that when I load a dds file into noesis and then export it as png, it just appends ".png" to the texName, so you suddenly have "myTex.dds.png". When someone's converting them manually, they might use something like imageMagick and just output all of the files as "myTex.png".

Now, I have to make a decision between appending the extension to the texName, or replacing the dds extension with the png in my exporter. Or do some rough checks to determine which one is available.

And then there's the question of *where* the texture is actually stored.
Some games I just tell people to place the texture in the same folder as the model because that's how they were organized in the first place.

Other games, where they have a whole bunch of textures stored in one folder, I just say to just make it a subfolder in the model directory. This would then require some path parsing on my end lol

Seems like it'll take some effort to think about how to go about dealing with the textures.
Demonsangel
mega-veteran
mega-veteran
Posts: 241
Joined: Fri Aug 05, 2011 9:31 pm
Location: Antwerp
Has thanked: 13 times
Been thanked: 41 times

Re: Señor Casaroja's Noesis

Post by Demonsangel »

Well, that makes sense I guess.
MrAdults
Moderator
Posts: 1007
Joined: Mon Mar 23, 2009 2:57 am
Has thanked: 44 times
Been thanked: 505 times

Re: Señor Casaroja's Noesis

Post by MrAdults »

Short answer is, try it, and see what you have to do to make it work. You seem to be overthinking the problem to the point of self-defeat. :) The process is likely to differ based on the texture requirements of the output format, as well as how that format maps materials to textures, if it needs or optionally supports extension names in its own texture paths at all, and a variety of other things. No universal naming convention for textures can support every export format, so you're going to have to do some path cleanup in most cases either way. I can also expose Noesis_LoadTexturesForModel to the Python API at some point to make gathering simpler, although as already mentioned, there's going to be a lot of memory overhead. But it doesn't seem like you're to the point of even worrying about that yet, because you're still working with external textures.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Señor Casaroja's Noesis

Post by finale00 »

Here's a model with some quads.
I could break them into triangles I suppose, but well if I could parse them as quads why not lol

Then again apparently I can create polygons with like 8 sides and the format doesn't care so I guess I'll have to break those into tris...

Do I have to set some option to get it to render properly?
I've included the parser. Parse_faces is the method of interest.

Some of the models only show half of it. Looking at the format, it uses a "mirror" attribute to indicate that it should mirror the vertices. Can we do something like this in noesis? Or, is there a fast way to just create the vertices? Like it's mirrored on the z-axis (err...or maybe x-axis not sure), so I would just multiply the corresponding z- (or x-) value by -1 to get it on the other side of the axis.

btw the parser fails if there are non-ascii characters.
Can I specify the encoding to use when calling readline? I'm going to be using readline often with text files. Since MQO format is a japanese tool I can expect any non-ascii characters to be in japanese (otherwise metasequoia doesn't actually recognize it)

readline handles different end-of-line characters correctly I'm guessing (\n, \r\n, etc)?

And for immediate mode, the readme says the values are not normalized for me. How does that affect how I do things? I usually just toss everything into separate lists and then index into them according to the various indices. The vertices are usually correct, but the normals and UV's are almost always off.
You do not have the required permissions to view the files attached to this post.
MrAdults
Moderator
Posts: 1007
Joined: Mon Mar 23, 2009 2:57 am
Has thanked: 44 times
Been thanked: 505 times

Re: Señor Casaroja's Noesis

Post by MrAdults »

I'm not sure what you're asking... if you have a model with quads instead of triangles, you can just use RPGEO_QUAD instead of RPGEO_TRIANGLE. Or did you mean you're trying to export quads? Converting triangles to quads is silly, but if the format requires it you could do that, and just use a degenerate edge for leftover triangles that can't be combined into quads. If it's in reality polygons and not quads then you can just convert triangles directly to polygons, it's not an issue at all.

No, I don't plan to support mirroring natively in Noesis, it's too much of a rare/specialcase thing to justify maintaining the functionality. If you want to import a format that uses mirroring, you have to mirror the geometry yourself. (multiplying by -1 on the given axis would do that yeah, or use a transform matrix for it and the RPG system will do it for you) If you want to export to it, I would just not use that functionality and not flag any verts as mirrored when exporting to the format.

readline like the other bitstream string functions assumes multibyte and not widechar strings. It was just something I added for chrrox's convenience, and all it does is parse to the next \n or end of string. It doesn't care about \r. If you want more advanced functionality, you'll have to handle parsing the string buffer yourself with existing python libs, using readBytes/writeBytes to get the data out/in.

For immediate mode, if the coordinates you're feeding in need to be scaled/biased, you have to do that yourself.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Señor Casaroja's Noesis

Post by finale00 »

For the quads, I mean when I render it, it doesn't look right when I just use RPGEO_QUAD lol
Wasn't sure if there was an option for quads though (at least, I don't see one in the docs)

Image

So far there doesn't seem to be a very convenient way to handle formats that are inherently in text (in python anyways). Unless text parsing and binary parsing is pretty much the same thing?
Post Reply