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
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. codysorgenfrey
    • Profile
    • Following 0
    • Followers 0
    • Topics 6
    • Posts 17
    • Best 1
    • Controversial 0
    • Groups 0

    codysorgenfrey

    @codysorgenfrey

    1
    Reputation
    142
    Profile views
    17
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    codysorgenfrey Unfollow Follow

    Best posts made by codysorgenfrey

    • Bug in mograph python effector default state R20

      When you use a mograph python effector switched to "full control" mode by default it doesn't work because of the absence of a falloff field. It took me awhile to figure out why my custom effectors didn't work coming from R18 to R20.

      I would suggested updating the boilerplate in the effector when switching to full control mode to check for a falloff if that's possible. If not maybe fall back to commented out version for with falloff and without?

      posted in Cinema 4D SDK r20 python
      codysorgenfreyC
      codysorgenfrey

    Latest posts made by codysorgenfrey

    • RE: Rotate object around world axis regardless of orientation

      Thanks so much @ferdinand! You all at Maxon are the best. Sorry my code is a shit show, just a quick hack at a rolling cube rig.

      For anyone in the future looking for this solution here's what I needed:

          # Rolling
          distTraveled = pos - PREV_POS
          numRevs.x = (distTraveled.x / circumfrence.x)
          numRevs.z = (distTraveled.z / circumfrence.z)
          outRot = numRevs * c4d.utils.DegToRad(360.0)
          objMx = rotObj.GetMl()
          worldXInLocal = ~objMx * c4d.Vector(1, 0, 0)
          worldZInLocal = ~objMx * c4d.Vector(0, 0, 1)
          xTrans = c4d.utils.RotAxisToMatrix(worldXInLocal, -outRot.z)
          zTrans = c4d.utils.RotAxisToMatrix(worldZInLocal, outRot.x)
          rotObj.SetMl(objMx * xTrans * zTrans)
      

      I needed the cube to be able to roll the correct way regardless of orientation. Admittedly this was a simple matrix transform issue that anyone who actually understood graphics programming would've known. (LOL not me)

      Here's the full scene for anyone interested. test_cube_roll.c4d

      posted in General Talk
      codysorgenfreyC
      codysorgenfrey
    • Rotate object around world axis regardless of orientation

      Hello!

      I'm having a hard time wrapping my brain around this script I'm trying to write.

      I want to rotate a cube along the floor in the direction that it's being animated. The problem I'm running into is that I need to be able to specify the rotation around the world axis (just like how the rotate tool does) so that when the cube is oriented in any direction, I can still rotate properly with the animation.

      Here's some pseudo code and a screen grab. Any help would be greatly appreciated!

      # Rolling
      distTraveled = pos - PREV_POS
      numRevs.x = (distTraveled.x / circumfrence.x)
      numRevs.z = (distTraveled.z / circumfrence.z)
      outRot = numRevs * c4d.utils.DegToRad(360.0)
      objMx = rotObj.GetMl()
      rotMx = c4d.utils.MatrixRotY(-outRot.z) * c4d.utils.MatrixRotZ(outRot.x)
      rotObj.SetMl(objMx * rotMx)
      

      https://microsoft-my.sharepoint-df.com/✌/p/cosorgen/ESTEQCvARE1Nn4F3qnKfCC8B1nahC5Y3iHhSvgOtkhO0DQ?e=xhrNCK

      This code almost works, but some of the time the cube rotates the wrong direction (although on the right axis).

      posted in General Talk python
      codysorgenfreyC
      codysorgenfrey
    • RE: FontData BaseContainer IDs

      I was actually able to get what I need through GeClipMap's GetFontDescription().

      Thanks!

      posted in Cinema 4D SDK
      codysorgenfreyC
      codysorgenfrey
    • FontData BaseContainer IDs

      Re: [python] SetFont not working

      @m_adam Thank you so much for this example of setting the FontData of a MoText. Would you mind showing me where I can figure out what each ID is setting?

      500: Font Family?
      501: ?
      502: Font Weight?
      503: ?
      509: Font family again?
      508: Font postscript name?

      Any help would be much appreciated!

      posted in Cinema 4D SDK python r20
      codysorgenfreyC
      codysorgenfrey
    • RE: Bug in mograph python effector default state R20

      Hey @m_adam thanks for getting back to me. I'm on R20.059.

      Here's the default python effector when switched to full control. I haven't touched anything. As you can see it does nothing even though it's supposed to be lifting each clone up 100cm.

      If you set the last parameter in the md.SetArray() function to False. It will work.

      python_effector_demo_01.c4d

      posted in Cinema 4D SDK
      codysorgenfreyC
      codysorgenfrey
    • Bug in mograph python effector default state R20

      When you use a mograph python effector switched to "full control" mode by default it doesn't work because of the absence of a falloff field. It took me awhile to figure out why my custom effectors didn't work coming from R18 to R20.

      I would suggested updating the boilerplate in the effector when switching to full control mode to check for a falloff if that's possible. If not maybe fall back to commented out version for with falloff and without?

      posted in Cinema 4D SDK r20 python
      codysorgenfreyC
      codysorgenfrey
    • RE: Getting MoData in GVO of a ObjectData Plugin

      @m_adam thanks so much for all your help on this!

      posted in Cinema 4D SDK
      codysorgenfreyC
      codysorgenfrey
    • RE: Getting MoData in GVO of a ObjectData Plugin

      @m_adam I'm finally getting around to implementing this fix, and it's working really well except for it's alway rebuilding the cache, GetAndCheckHeirarchyClone is always saying the input object is dirty.

      Is this how it's supposed to work?

      posted in Cinema 4D SDK
      codysorgenfreyC
      codysorgenfrey
    • RE: Sample a shader in 3D space in GVO

      Thanks @r_gigante that's what I thought.

      posted in Cinema 4D SDK
      codysorgenfreyC
      codysorgenfrey
    • Sample a shader in 3D space in GVO

      Hello,

      What's the proper way to sample a shader (noise, gradient, etc.) in 3D space without a given VolumeData object?

      I understand how to map the ChannelData's p (uvw) parameter to my object's uvw coordinates, but how do I sample in a way that works like Mograph's shader effector works?

      When I sample a noise, and put my objects uvw coordinates in the ChannelData object, if I switch the noise to "World Space", that doesn't work obviously, cause i'm still sampling in texture space in the code. Do you have to manually check that parameter in the BaseShader object?

      See simplified code:

      BaseObject* GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
      {
          GeData           myData;
          Bool             cacheDirty, dirty, frameUpdate;
          BaseObject       *outObject, *customShape;
          BaseShader       *shader;
          BaseDocument     *doc = hh->GetDocument();
          InitRenderStruct irs(doc);
          
          outObject = BaseObject::Alloc(Onull); // dummy output object
          
          cacheDirty = op->CheckCache(hh);
          dirty = op->IsDirty(DIRTYFLAGS_DATA | DIRTYFLAGS_MATRIX);
          
          op->GetParameter(DescLevel(FROMSHADER_FRAME_UPDATE), myData, DESCFLAGS_GET_0);
          frameUpdate = myData.GetBool();
          
          if (frameUpdate)
          {
              Int32 curFrame = doc->GetTime().GetFrame(doc->GetFps());
              if (curFrame != prevFrame){
                  dirty = true;
                  prevFrame = curFrame;
              }
          }
          
          if (!dirty && !cacheDirty)
          {
              blDelete(outObject);
              return op->GetCache();
          }
          
          op->GetParameter(DescLevel(FROMSHADER_SHADER), myData, DESCFLAGS_GET_0);
          shader = (BaseShader *)myData.GetLink(doc);
          
          if (!shader)
              goto error;
          
          StatusSetSpin();
          
          customShape = BaseObject::Alloc(Ocube);
          customShape->SetParameter(DescLevel(PRIM_CUBE_LEN), GeData(Vector(shapeSize)), DESCFLAGS_SET_0);
          customShape = MakeEditable(customShape, doc, true);
          
          if (!customShape)
              goto error;
          
          if (shader->InitRender(irs) != INITRENDERRESULT_OK)
              goto error;
          
          if (!helper->grid)
              return false;
          
          StatusSetText("Sampling Noise");
          
          Vector rad = customShape->GetRad();
          
          for ( ; iter; ++iter)
          {
              ChannelData cd;
      
              cd.off = 0;
              cd.scale = 0;
              cd.t = time;
              cd.texflag = CALC_TEXINFO(0, CHANNEL_COLOR);
              cd.d = Vector(1, 1, 1);
              cd.n = Vector(0, 1, 0);
              cd.vd = nullptr;
              Vector pos = iter.getPos();
              Vector worldPos = op->GetMg() * Vector(pos.x(), pos.y(), pos.z());
              Float min = 1 - ((rad.x + rad.y + rad.z) / 3);
              Float max = ((rad.x + rad.y + rad.z) / 3);
              cd.p = Vector((c4dPos.x - min) / (max - min),
                            (c4dPos.y - min) / (max - min),
                            (c4dPos.z - min) / (max - min));
      
              Vector col = shader->Sample(&cd);
              Float luma = 0.2126 * col.x + 0.7152 * col.y + 0.0722 * col.z; // calc luminence
              iter.setValue(luma);
          }
          
          shader->FreeRender();
          
          StatusClear();
          
          customShape->InsertUnder(outObject);
          
          return outObject;
          
      error:
          blDelete(outObject);
          StatusClear();
          return nullptr;
      }
      
      
      posted in Cinema 4D SDK c++ windows macos r19 sdk classic api
      codysorgenfreyC
      codysorgenfrey