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

Noesis Create NoeBone from Pos, Rot, Scl?

Coders and would-be coders alike, this is the place to talk about programming.
Post Reply
dgl
ultra-n00b
Posts: 4
Joined: Thu Mar 28, 2019 6:32 am
Has thanked: 3 times

Noesis Create NoeBone from Pos, Rot, Scl?

Post by dgl »

I have a bone format that is stored as position, rotation, and scale as vectors. I'm looking over the NoeBone and NoeMat functions, but I don't see an clear way to create a NoeBone from these transformations.

Code: Select all

		self.bs.seek(self.header['boneOffset'], NOESEEK_ABS)
		for i in range (0, self.header['boneCount']):
			id = self.bs.readShort()
			parentId = self.bs.readShort()

			pos = NoeVec3([
				self.bs.readFloat(),
				self.bs.readFloat(),
				self.bs.readFloat()
			])

			rot = NoeVec3([
				self.bs.readFloat(),
				self.bs.readFloat(),
				self.bs.readFloat()
			])

			scl = NoeVec3([
				self.bs.readFloat(),
				self.bs.readFloat(),
				self.bs.readFloat()
			])

			# How to Generate NoeMat43?
chrrox
Moderator
Posts: 2602
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1422 times

Re: Noesis Create NoeBone from Pos, Rot, Scl?

Post by chrrox »

Just look in the python folder at the file inc_noesis.py
then find the starting data type like for instance
class NoeQuat
you can see it being initialized
quat = (0.0, 0.0, 0.0, 1.0)
and the option
toMat43
so you could do
myQuat = NoeQuat().toMat43()
then set the position with
myQuat[3] = [x,y,z]
dgl
ultra-n00b
Posts: 4
Joined: Thu Mar 28, 2019 6:32 am
Has thanked: 3 times

Re: Noesis Create NoeBone from Pos, Rot, Scl?

Post by dgl »

Thanks for the reply. From reading through the source code, I was starting to suspect that was the expected approach. Suspicions confirmed, but the implementation turned out pretty simple.

Code: Select all

		self.bs.seek(self.header['boneOffset'], NOESEEK_ABS)
		for i in range (0, self.header['boneCount']):
			id = self.bs.readShort()
			parentId = self.bs.readShort()

			pos = NoeVec3.fromBytes(self.bs.readBytes(0x0c))
			rot = NoeAngles.fromBytes(self.bs.readBytes(0x0c))
			scl = NoeVec3.fromBytes(self.bs.readBytes(0x0c))

			name = "bone_%03d" % id
			parentName = "bone_%03d" % parentId

			mat = rot.toMat43()
			mat[3] = pos;
			mat[0][0] = scl[0]
			mat[1][1] = scl[1]
			mat[2][2] = scl[2]

			if i == 0:
				bone = NoeBone(id, name, mat)
			else:
				bone = NoeBone(id, name, mat, parentName, parentId)
			self.bones.append(bone)
Looks like NoeAngle has the option to be converted into a NoeMat43 as well, so from there it's just a matter of setting the position and scale.
Post Reply