Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Login
    1. Home
    2. HerzogVonWiesel
    • Profile
    • Following 0
    • Followers 0
    • Topics 4
    • Posts 13
    • Best 1
    • Controversial 0
    • Groups 0

    HerzogVonWiesel

    @HerzogVonWiesel

    4
    Reputation
    8
    Profile views
    13
    Posts
    0
    Followers
    0
    Following
    Joined Last Online
    Website jeromestephan.de Location Potsdam, Germany

    HerzogVonWiesel Unfollow Follow

    Best posts made by HerzogVonWiesel

    • Free plugin: TexToMatO - Über Texture Importer

      TexToMatO is a powerful texture to material converter for Redshift in Cinema4D.

      Have you ever had the pleasure of creating materials from texture sets, one by one, each time doing the same thing over and over again? connecting the roughness to a ramp, setting it to colorspace raw, connecting it to the roughness input; then the normal map, set it to raw, connect it to a bump node... it goes on and on.
      Or even worse, a "tex" folder from a past project, with all kinds of textures and the naming schemes of the textures are all over the place?

      TexToMatO uses regular expressions to create materials from a given folder, making sure to read in each texture as its correct kind, setting it to the right colorspace, maybe adding needed nodes in-between (ramp, bump map, etc.) and connecting it to the right material input.

      It can also work on already existing materials; for example, when importing .fbx files it often only imports the base texture, not the roughness and all other maps. TexToMatO will take care of all of that - superfast!

      fc291255-22da-4543-a5bd-2c645b67987d-image.png

      Installation

      • Unzip TexToMatO into your plugins folder of Cinema 4D. (below are examples)
        • Windows: C:\Users\USERNAME\AppData\Roaming\MAXON\CINEMA 4D VERSION\plugins\
        • Mac: /Users/USERNAME/Library/Preferences/MAXON/CINEMA 4D VERSION/plugins/
      • Make sure there is no TexToMatO folder inside of the plugins/TexToMatO folder
      • You can then open TexToMatO by going to Extensions -> TexToMatO
        • You can add a shortcut to open TexToMatO in your layout for easier access!

      Features

      TexToMatO has two modes: Either you can import all textures inside a folder to create new materials for each set from scratch, or you can import missing textures in selected materials (which often occur after importing .fbx files for example).

      • Import all textures from folder
      • Import textures from base in material : Searches for an already existing texture in the selected materials and finds the missing ones from the texture folder
        • Derive texture folder from base : If OFF, you can specify which folder to read the textures from instead of automatically deriving it from the base texture in the material
        • Delete base texture in material: Deletes the already existing texture in the material to not end up with duplicate texture nodes.
        • Rename material based on texture: Renames the material to the base texture's base name.

      • Normal options
        • Flip Y : Toggles the option to flip the Y channel of the normal. This is useful when working with DirectX vs. OpenGL normal maps.
        • Use Legacy Bump : If you see any artifacting with the normal maps, toggle this option.

      • MultiTexture : Textures from game files often pack multiple textures into a single one by using the RGB channels. With this option you can specify which texture is used to pack the textures, and what texture is in which channel. TexToMatO will connect it accordingly.

      • Miscellaneous
        • Use Sprite node for opacity : You can decide whether the opacity texture gets plugged into the Standard Material's opacity channel or whether it should be used as a sprite node (more efficient, but only binary opacity).
        • Use case-insensitive regex (be careful not to match too much with that though)

      • Regex options
        *Use custom regex: Manage your own custom, additional regex you can add for your version of the plugin: maybe you have some interesting channel names in your studio?

      • Preferences
        • Automatically add Color Correct nodes to color textures (Albedo & Translucency)
        • Automatically add Triplanar nodes to all textures
        • Whether to connect AO to overall tint or multiplying it with Albedo in a color layer

      • Additional Features
        • All texture nodes can be managed at once with SCALE, OFFSET and ROTATION nodes added to the graph
        • Submit Bugs and Feedback easily with a form
        • Once you import one or more textures, all settings are saved and are there for you when you need them (well, and restart C4D)
          • No worries, you can easily reset them to default in the preferences menu should you want to!

      Check it out on Gumroad to support this project and me!

      Have fun and keep on creating!

      • Jérôme



      Small demo video

      posted in General Talk
      HerzogVonWieselH
      HerzogVonWiesel

    Latest posts made by HerzogVonWiesel

    • RE: Calculate Rigid Transform Matrix to match two identical objects

      @ferdinand you are amazing!
      Thank you so much for your help, this is it. Now only remains the last step until my script to automatically recognize and replace duplicate objects with instances is complete: The UI. But that should be a quick one.

      Thank you so much for your help again Ferdinand, you are a saint. Have a superb week and best wishes from Potsdam!

      • Jerome
      posted in Cinema 4D SDK
      HerzogVonWieselH
      HerzogVonWiesel
    • RE: Calculate Rigid Transform Matrix to match two identical objects

      Hi @ferdinand !

      I've looked through the examples and used them as a base, as well as consulted the Manual a few times, so I'm sharing my current, not working solution:

      def ConstructMatrixFromPolygon(polygon: c4d.CPolygon, object: c4d.PointObject) -> c4d.Matrix:
          # get the points of the polygon
          a = object.GetPoint(polygon.a)
          b = object.GetPoint(polygon.b)
          c = object.GetPoint(polygon.c)
          e1 = b - a
          e2 = c - a
      
          z = e1.GetNormalized()
          temp = e2.Cross(z)
          y = z.Cross(temp).GetNormalized()
          x = y.Cross(z).GetNormalized()
      
          return c4d.Matrix(off=a, v1=x, v2=y, v3=z)
      
      def TransferAxisTo(node: c4d.PointObject, target: c4d.PointObject) -> None:
          """Transforms the points of #node such that they are the same w.r.t. their coordinate system 
          as the points in target are w.r.t. their coordinate system 
          while keeping its coordinate system in place.
      
          Args:
              node
              target
          """
          if not isinstance(node, c4d.PointObject):
              raise TypeError(f"Expected {c4d.PointObject} for {node}.")
      
          # Get the global matrix of #node and #target which are the absolute transforms, i.e., absolute
          # coordinate systems which govern these two objects.
          mgNode = node.GetMg()
          mgTarget = target.GetMg()
      
          # Get the document of #node.
          nodeDoc = node.GetDocument()
          if nodeDoc is None:
              raise RuntimeError(f"'{node.GetName()}' is not attached to a document.")
      
          # Open an undo stack for the changes and add an undo item for the point and matrix changes.
          if not nodeDoc.StartUndo():
              raise RuntimeError("Could not open undo stack.")
      
          if not nodeDoc.AddUndo(c4d.UNDOTYPE_CHANGE, node):
              raise RuntimeError("Could not add undo item.")
          
          polygonNode = node.GetPolygon(0)
          polygonTarget = target.GetPolygon(0)
      
          m1 = ConstructMatrixFromPolygon(polygonNode, node)
          m2 = ConstructMatrixFromPolygon(polygonTarget, target)
      
          mgDeltaTarget = ~mgTarget * m2
          mgDeltaNode = ~mgNode * m1
          mgDelta = mgDeltaNode * ~mgDeltaTarget
      
          node.SetAllPoints([p * mgDelta for p in node.GetAllPoints()])
          node.Message(c4d.MSG_UPDATE)
      
          return
      

      I tried to do it as you described in your post, with the example code as a base: I sketched the transforms on paper to visualize them for myself; that's how I came up with the mgDelta and mgDeltaXs.

      Still, as I said, it's not really working; so if you see any glaring issues I'd love to hear them!

      Cheers, Jerome

      PS: Did I understand correctly that Matrix Multiplication is left-bound in C4D? Such that X * Y * Z = Z(Y(X)) ?

      posted in Cinema 4D SDK
      HerzogVonWieselH
      HerzogVonWiesel
    • RE: Calculate Rigid Transform Matrix to match two identical objects

      Thanks @ferdinand !

      That really cleared up a lot for me. I think I now know how to apply the transforms and in which order, though it seems the missing piece seems to be how to construct the matrix from the object's polygon: I didn't quite understand your process, what do you mean by frame? I'm thinking of the "classic" way of taking two edges of the polygon, calculating an orthogonal vector of those and then we have our new base vectors of the matrix (and then concatenate that with the transform to point a); Yeah, I don't think that's the best way to do it, so I'd love to get clarification on that!

      • Jerome
      posted in Cinema 4D SDK
      HerzogVonWieselH
      HerzogVonWiesel
    • RE: Calculate Rigid Transform Matrix to match two identical objects

      Thank you so much for the response @ferdinand !

      I'll attach 2 pictures to show what I'm talking about.

      15a2ef4c-ea47-4c0f-a033-f1bd148ab067-image.png
      It is the same object, but the anchor point is somewhere else compared to the points of the geo (on top of being somewhere else globally); so when I create an instance of the second object with a reference to the first object and set the global Matrix transform to the matrix transform of the object I replaced by an instance, I get the following (instead of the instance overlaying perfectly):

      dd96d456-ab4c-4c9b-a4d3-24dd94b30388-image.png

      As you said, I could pick a polygon for both objects (since I assume the topology to be the same, even if the points and object could be positioned / rotated differently) and try to derive the needed transform that way; though then I'm a little lost as to how to calculate it and apply it (to the points or the instance? First on the points, then the inverse on the instance object? I'm not sure as you can see).
      EDIT: Alright, so we probably want obj1_instance.SetMg(obj2.GetMg()), and then apply DeltaMg to the points of obj1_instance, where DeltaMg = difference between polygon1_obj1 and obj1.GetMg() + difference between polygon1_obj2 and obj2.GetMg() (or something like that, just trying to make sense here)

      Thing is, I'm also unsure of what the C4D SDK already has implemented that we could use for this problem, and I don't think we need to manually get up with every function in plain python.

      Thanks again for your help already ferdinand!

      posted in Cinema 4D SDK
      HerzogVonWieselH
      HerzogVonWiesel
    • Calculate Rigid Transform Matrix to match two identical objects

      Hey there!

      For the following scenario: I have two identical objects obj1 and obj2. I can get these matrices for the objects with built-in functions getMg and SetMg. However, even if I obj2.setMg(obj1.getMg), they may still not overlap since the anchor point may be located differently relative to the points themselves (which I can get using obj.getAllPoints). How would I create a Matrix m to obj2.setMg(m) such that the objects overlap?

      I know that I need to created a rigid / euler transform matrix since no scaling or shearing is needed, however it seems that all solutions for that require solving a linear linear matrix equation; which is often done using numpy which we don't have in c4d.

      So: Am I maybe overlooking something that's already in the SDK, or do I need to reimplement the equation solving in plain python to calculate the rigid transform?

      Any help appreciated!

      • Jerome
      posted in Cinema 4D SDK
      HerzogVonWieselH
      HerzogVonWiesel
    • Free plugin: TexToMatO - Über Texture Importer

      TexToMatO is a powerful texture to material converter for Redshift in Cinema4D.

      Have you ever had the pleasure of creating materials from texture sets, one by one, each time doing the same thing over and over again? connecting the roughness to a ramp, setting it to colorspace raw, connecting it to the roughness input; then the normal map, set it to raw, connect it to a bump node... it goes on and on.
      Or even worse, a "tex" folder from a past project, with all kinds of textures and the naming schemes of the textures are all over the place?

      TexToMatO uses regular expressions to create materials from a given folder, making sure to read in each texture as its correct kind, setting it to the right colorspace, maybe adding needed nodes in-between (ramp, bump map, etc.) and connecting it to the right material input.

      It can also work on already existing materials; for example, when importing .fbx files it often only imports the base texture, not the roughness and all other maps. TexToMatO will take care of all of that - superfast!

      fc291255-22da-4543-a5bd-2c645b67987d-image.png

      Installation

      • Unzip TexToMatO into your plugins folder of Cinema 4D. (below are examples)
        • Windows: C:\Users\USERNAME\AppData\Roaming\MAXON\CINEMA 4D VERSION\plugins\
        • Mac: /Users/USERNAME/Library/Preferences/MAXON/CINEMA 4D VERSION/plugins/
      • Make sure there is no TexToMatO folder inside of the plugins/TexToMatO folder
      • You can then open TexToMatO by going to Extensions -> TexToMatO
        • You can add a shortcut to open TexToMatO in your layout for easier access!

      Features

      TexToMatO has two modes: Either you can import all textures inside a folder to create new materials for each set from scratch, or you can import missing textures in selected materials (which often occur after importing .fbx files for example).

      • Import all textures from folder
      • Import textures from base in material : Searches for an already existing texture in the selected materials and finds the missing ones from the texture folder
        • Derive texture folder from base : If OFF, you can specify which folder to read the textures from instead of automatically deriving it from the base texture in the material
        • Delete base texture in material: Deletes the already existing texture in the material to not end up with duplicate texture nodes.
        • Rename material based on texture: Renames the material to the base texture's base name.

      • Normal options
        • Flip Y : Toggles the option to flip the Y channel of the normal. This is useful when working with DirectX vs. OpenGL normal maps.
        • Use Legacy Bump : If you see any artifacting with the normal maps, toggle this option.

      • MultiTexture : Textures from game files often pack multiple textures into a single one by using the RGB channels. With this option you can specify which texture is used to pack the textures, and what texture is in which channel. TexToMatO will connect it accordingly.

      • Miscellaneous
        • Use Sprite node for opacity : You can decide whether the opacity texture gets plugged into the Standard Material's opacity channel or whether it should be used as a sprite node (more efficient, but only binary opacity).
        • Use case-insensitive regex (be careful not to match too much with that though)

      • Regex options
        *Use custom regex: Manage your own custom, additional regex you can add for your version of the plugin: maybe you have some interesting channel names in your studio?

      • Preferences
        • Automatically add Color Correct nodes to color textures (Albedo & Translucency)
        • Automatically add Triplanar nodes to all textures
        • Whether to connect AO to overall tint or multiplying it with Albedo in a color layer

      • Additional Features
        • All texture nodes can be managed at once with SCALE, OFFSET and ROTATION nodes added to the graph
        • Submit Bugs and Feedback easily with a form
        • Once you import one or more textures, all settings are saved and are there for you when you need them (well, and restart C4D)
          • No worries, you can easily reset them to default in the preferences menu should you want to!

      Check it out on Gumroad to support this project and me!

      Have fun and keep on creating!

      • Jérôme



      Small demo video

      posted in General Talk
      HerzogVonWieselH
      HerzogVonWiesel
    • RE: Send message from Modal dialog to Async (main) dialog

      Solved it!

      def decodeMessage(message): # As taken from https://developers.maxon.net/docs/py/2023_2/manuals/misc/python3_migration.html
          pythonapi.PyCapsule_GetPointer.restype = c_int
          pythonapi.PyCapsule_GetPointer.argtypes = [py_object]
          return pythonapi.PyCapsule_GetPointer(message.GetVoid(c4d.BFM_CORE_PAR1), None)
      

      Thanks to these two links:
      https://developers.maxon.net/forum/topic/8098/10538_specialeventadd-data/2
      https://developers.maxon.net/docs/py/2023_2/manuals/misc/python3_migration.html

      posted in Cinema 4D SDK
      HerzogVonWieselH
      HerzogVonWiesel
    • Send message from Modal dialog to Async (main) dialog

      Hi there!

      Currently running into an issue that seems a little bit like a noob question, but with my main dialog, I open another Modal dialog to edit some settings. Now, I'd like to click a button in the Modal dialog, which should send the message id of clicking that button to the main async dialog.

      How would I do that? Thank you!

      posted in Cinema 4D SDK python sdk
      HerzogVonWieselH
      HerzogVonWiesel
    • RE: How to Dynamically Change the Size of Dialog Window

      Thank you again @ferdinand !

      Sad that resizing windows is not a possibility. Would've been nice to have the options pop up once you toggle the extra options on! Now I've implemented them as a modal dialogue so you can choose them and close it again.

      Thank you for your help!

      posted in Cinema 4D SDK
      HerzogVonWieselH
      HerzogVonWiesel
    • How to Dynamically Change the Size of Dialog Window

      Thank you @ferdinand !

      While you're here, for this script I'd love to implement a toggle-able option and I've come so far as to hide the elements that are affected, however the dialog won't resize to the new, smaller size no matter what I do. I've tried LayoutChanged, different initializations for the dialog and a lot of googling.. is it even possible? How would I best go about doing this so the plugin window doesn't start up with a big empty blob where the extra options would be?

      Thank you in advance!

      be833c9e-0a71-491a-b047-73505c6d192e-image.png
      a9422d05-0a4f-4646-a933-62907eba8ae2-image.png

      posted in Cinema 4D SDK 2023 python
      HerzogVonWieselH
      HerzogVonWiesel