Calculate End Position



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/09/2005 at 12:45, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   9.5 
    Platform:   Windows  ;   
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Hi together :-)
    I start my first Scripts in Coffee.
    I have generate Some Bones.
    I wont to generate the new Bone at the end of the other.
    I have read Position and Rotation, and Bonelength.
    How can I calculate the Endposition ?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/09/2005 at 16:10, xxxxxxxx wrote:

    Which end? The end 'anchored' to the parent bone or the other end?

    For the 'other end', you'll need to apply the bone's matrix to a pseudo 'end point' vector. Since all bones start out at the origin pointing down the Z-axis, this point would be (0,0,bonelength).

    Global or Local matrix - depending upon your requirements, the former is a better choice. Otherwise you need to apply the matrices down the bone chain.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/09/2005 at 05:43, xxxxxxxx wrote:

    I want get the Point of the End of the Bone.
    Position+Length in the direction of the angel.
    Global Position.
     
    I thought about it today and my idea is sin(h)*length+PositionX and sin(b)*length+PositionY
    Is there an easier way?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/09/2005 at 06:17, xxxxxxxx wrote:

    The default transformation for all objects is at the origin (0,0,0) with no rotations (0d,0d,0d) and unity scale (1,1,1). When you move/rotate/scale (transform), the object's matrix stores the necessary values to take the object from the default transformation to the new one.

    Sorrily, you're idea does not take into account scale or the 'p' angle rotation. With these, the maths get more complex. This is why matrices are far better to work with.

    I think that the best approach is to get the Global matrix for the bone (to avoid object hierarchy traversal) and multiply it to this temporary 'End Point' vector:

    var endPt = vector(0,0,length) * obj->GetMg();

    What this does is 'apply the matrix' to the Vector 'endPt' causing the point to move/rotate/scale from default to current transform with respect to the bone object. It should then contain the Global X,Y,Z values for the end point for the bone's current location/rotation/scale.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/09/2005 at 08:06, xxxxxxxx wrote:

    main(vdoc,op)
    {
        var Bone = new(BoneObject);
        Bone->SetName("L_Oberarm-Null");
      Bone#BONEOBJECT_NULL=True;
        vdoc->InsertObject(Bone,NULL,NULL);
        var BoneA = new(BoneObject);
        BoneA->SetName("L_Oberarm");
        BoneA->InsertUnder(Bone);
        var BoneB = new(BoneObject);
        BoneB->SetName("L_Unterarm");
      BoneB#ID_BASEOBJECT_POSITION:VECTOR_Z = BoneA#BONEOBJECT_LENGTH;
        BoneB->InsertUnder(BoneA);
        var BoneC = new(BoneObject);
        BoneC->SetName("L_Hand");
      BoneC#ID_BASEOBJECT_POSITION:VECTOR_Z = BoneB#BONEOBJECT_LENGTH;
        BoneC->InsertUnder(BoneB);
    }
     
    This is my Code!
    It works !
    But better I learn how I set Position with Matrix.
    When you can change it per Matrix, maybe I learn it.
     
    I don't know what I must set als length:
    "var endPt = vector(0,0,Bone#BONEOBJECT_LENGTH) * Bone->GetMg();"
    I get an Error at this Line. "Incompatible Values... Vector/Object"



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/09/2005 at 08:40, xxxxxxxx wrote:

    Oops. Being use to C++ SDK, pulled that out of my ... ;)

    Try this instead:

    var endpt = vector(0,0,Bone#BONEOBJECT_LENGTH);
    endpt = Bone->GetMg()->GetMulP(endpt); // Transform it to global coordinates



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/09/2005 at 09:11, xxxxxxxx wrote:

    ahhh :-)
    No more Error is showing.
    Thanks!
    But I dont can check that the position is given by println(endpt);
    Is realy the EndPoint. Is 0,0,200000
    Its right, but is it right when then direction of Bone is change?
    I need a waitposition for Userchanges. For the Bonemashine and for this test.
    When you be so friendly and can help again, please :-)
     
     
    Thanks for this big Help for understand !



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/09/2005 at 12:32, xxxxxxxx wrote:

    Try something like this for text output:

    println(tostring(endpt));
    

    As for watching for user changes, this can only be done in COFFEE if you have a GeDialog. Then you can use CoreMessage() to retrieve general C4D messages outside of your plugin, such as:

      
    MyDialog::CoreMessage(id,msg)  
    {  
         switch (id)  
         {  
              // every time something has changed in the scene refresh my local data  
              case NEW_DOCUMENT:  
              case DOCUMENT_CHANGED:  
              case NEW_ACTIVE_OBJECT:  
              case ACTIVE_OBJECT_CHANGED:  
                   FillGadgets();  
                   break;  
         }  
    }  
    

    This code is from the COFFEE 'IKrecord.cof' example (which can be found in the COFFEER63SDKCHM2005-04-28.chm file or HTML equivalent documentation). So, you may only need to look for ACTIVE_OBJECT_CHANGED and then either check the active object or all of them (especially since a bone may be affecting child bones).



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 26/09/2005 at 15:06, xxxxxxxx wrote:

    I don't get it to run out of the Script Editor.
    Is it realy possible Dialog from Script Editor ?
    Is classes and execute{} useable in scripts in R9.5 ?


Log in to reply