Position Values within the Cinema 4D Global Matrix

letellierCinema 4DLeave a Comment

The Global and Local Matrixes within Cinema 4D can be both lifesavers and death eaters at the same time. A recent project forced me to learn more about them, and I thought I’d pass along some of that knowledge to you.

The first thing I discovered was that you can can convert a Normal Vector into a matrix by use of the Vector2Matrix xpresso node found within the xpresso nodelist under New Node –> Xpresso –> Calculate. Robert Leger has a fantastic guide on the node, which you can find here.

But a problem quickly arose: when I set this new matrix as the Global Matrix of an object, the object locked itself to the origin of my scene (position 0,0,0).

After spending many hours consulting the C4D Python help guide and experimenting on my own, I figured out both the cause of the problem and a method of fixing it.

In Cinema 4D, a matrix is composed of three vectors named V1, V2, and V3. When used as a Global or Local Matrix, these three vectors contain the rotation and scale values associated with the object. In addition, every Global and Local Matrix contains a fourth Vector called ‘Offset’ (abbreviated as ‘off’); this Vector contains the position values of the object.

Therefore, if one converts a normal vector to a matrix, and wishes to use said matrix as the global matrix, the Offset Vector needs to be changed.

To accomplish this task, I created the Matrix Splice xpresso node.


The node is very easy to use: first, feed your current matrix to the ‘Matrix’ input of the node, then feed the Global Position value you’d like to splice into the matrix into the ‘Position’ input. Your new and improved Matrix can be accessed from the “New Matrix” output tab.

Download link:
Matrix Splice Python Node

To install on OS X, drop the XMA file into the following location: User  –> Library –> Preferences –> MAXON –> Cinema 4D [Your Version] –> Library –> xgroup.

Once it’s placed in that folder, you can access the node within your Xpresso Editor window by clicking on File (the ‘File’ button in your Xpresso window, not the ‘File” button located at the top left of your monitor) –> Load X-group.

If you have any trouble with it, let me know.


Luke

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *