Move viewport camera from plugin



  • I'm playing around with an idea for a 3D mouse.

    I have this working Mouse > USB > my macOS app - and just need the last few steps: > Cinema 4D plug-in > Cinema 4D camera/rig rotation

    I'm wondering if I can write a plug-in that takes a set of rotation parameters (in any format, really, quarternion, euler angles, transform) and rotate the camera (or its rig parent node) to look from that angle.

    1. Is that even possible? I looked at the docs, and I could only find direct dragging functions.

    2. Also, what would be a good way to pass in the rotation parameters from my macOS app to the plugin? I'm thinking maybe a websocket. Ideally I'd pass in the rotation 60 times per second, but 15 could probably work, too.



  • So! It looks like this might work for the rotation part, as long as there is a rig node.

    import c4d
    obj = GetCameraRigNode()
    
     def rotate(eulerX, eulerY, eulerZ):
        rot = c4d.Vector(eulerX, eulerY, eulerZ)
        obj.SetAbsRot(rot)
    

    For the transport I'm thinking about running a websockets server which the Python app will connect to and listen for rotation events.

    Unless there's something simpler I could do, like calling a url scheme, or passing parameters to C4D from cocoa.



  • Hi @mortenjust first of all welcome in the plugin cafe community.
    Don't worry since it's your first post, but please next time try to follow these rules:

    Regarding your question, there is no building option in Cinema 4D, so the best way would be to have a TCP/Socket server to communicate across multiple application.

    Finally, in case you are not aware, there is already a plugin for handling 3D mouse called CallieMouse, but is not yet ported in R20, for more information see 3D Mouse Slider Focus

    Cheers,
    Maxime.



  • Sorry if I did something wrong in my post, and thanks for the pointers.

    I made it work using Websocket. It's using augmented reality to orbit the camera live in Cinema. Here's a couple of videos if anyone's interested
    https://vimeo.com/album/5915686



  • wow! i love that.
    great job!