## Noesis Create NoeBone from Pos, Rot, Scl?

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

### Noesis Create NoeBone from Pos, Rot, Scl?

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']):

pos = NoeVec3([
])

rot = NoeVec3([
])

scl = NoeVec3([
])

# How to Generate NoeMat43?
``````

chrrox
Moderator
Posts: 2565
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1312 times

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

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?

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']):

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.