Skip to content

Axial Limitation Tracking Constraint

Psymon edited this page Oct 16, 2023 · 4 revisions

Quick Overview

The angular transformation on the ctc is actually setting the plane on which the rotations will happen (XY of the final coordinate system), however the vector formed by the mod3 skeleton determines the point that the rotating system tracks. If the point isn't on the plane however, the system will be tracking on one additional axis. it's hard to explain but if you only apply the rotation on the ctc without editing the mod3 it's very easy to tell what's happening if you know this in advance.

In this sense one simply has to set the x basis vector of the ctc node to point to the next bone in the chain, it rotates around the z basis vector of the ctc node orientation, and you give it a range by rotating it around different values of the z

Tutorial

Start with a 2 bone chain where the child is above the parent on the Z axis and matches on the other two dimensions

[Image 1]

Start with the two node chain where the base node has the -90,YY,90 transform (YY defines the angular limits of the rotation around our axis, values of 0 and 180 make it so it can only rotate in one direction (clockwise or anticlockwise), 90 means it can do a full turn in either direction, values around 45 are recommended to avoid some degenerate behavior though, 90° can have issues reorienting itself at times.

[Image 2]

Translate (it's important to TRANSLATE, NOT ROTATE the parent, TRANSLATE the children instead) the child bone such that it aligns with the axis of rotation.

[Image 3]

Notice how the parent is still in an untransformed coordinate basis

[Image 4]
[Image 5]
[Image 6]

Identify a rotation such that it transform the vertical children setup into this new setup.

[Image 7]

In this cause it's a 90° rotation on the Y axis. HOWEVER don't save the mod3 like this we just want the value we'll revert it We just want to identify which is the equivalent Angular transform that corresponds to our previous translation
[Image 8]
[Image 9]
We revert the MOD3 to just be a translation but on the CTC
[Image 10]
We apply this transformation.
We can get the final rotation matrix we'll be using on the ctc by running this command while selecting the rotated frame:

bpy.context.active_object.matrix_world

In our example we'd get this (the rotation matrix for the 90 degree rotation on the Y axis)

>>> bpy.context.active_object.matrix_world
Matrix(((0, -1, 0, 0),
        (1, 0, 0, 0.19413000345230103),
        (0, 0, 1, 51.91337966918945),
        (0, 0, 0, 1)))

We ignore the translation component (the last column) leaving us with

Matrix(((0, -1, 0, 0),
        (1, 0, 0, 0),
        (0, 0, 1, 0),
        (0, 0, 0, 1)))

Remember in the ctc it's defined by columns so in this case it'd be 0,1,0,0], [1,0,0,0], [0,0,1,0], [0,0,0,1, alternatively, using this code:

import struct

def serializeMatrix(m):
    m = m.copy()
    m[0][3] = 0
    m[1][3] = 0
    m[2][3] = 0
    b = struct.pack("ffffffffffffffff", *[m[i][j] for j in range(4) for i in range(4)])
    print(''.join(map(lambda x: "%02x"%x,b)))
    
sm = lambda : serializeMatrix(bpy.context.active_object.matrix_world)

and calling

sm()

we get

>>> sm()
6e21a2330400803f0000000000000000040080bf6e21a233000000000000000000000000000000000000803f000000000000000000000000000000000000803f

and can just copy paste that directly to the ctc to the node's transform matrix.

Developments within the CTC toolbox allow this process to be helped along with GUI operations, this considerably simplify the above process. This operations are the alignment and projective alignment operators on the ctc frames.

General Tutorials

General Tutorials

Animation Tutorials

Animation Tutorials

Audio Tutorials:

Audio Tutorials

IDs:

File & In Game IDs

Model Tutorials:

Model Tutorials

Effects Tutorials:

EFX Tutorials

FSM Tutorials

FSM Editing

MRL3 Tutorials:

MRL3 Tutorials

NPC Editing:

NPC Editing

Map Editing:

Map Editing

Plugins and Memory Editing:

Plugins and Memory Editing

Quest Editing:

Quest Editing

Monster AI Editing:

Monster AI Editing

Texture Tutorials:

General Texture Tutorials
Specific Texture Tutorials

TIML Editing

TIML Editing

Asterisk's Plugin Notes:

Asterisk's Plugin Notes

Miscellaneous Tutorials:

Miscellaneous Tutorials

Outdated Tutorials:

Outdated Tutorials
Clone this wiki locally