Help with Matrix



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

    On 29/05/2010 at 10:26, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11.5 
    Platform:      Mac OSX  ; 
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    I'm struggling with dot syntax... Could somebody give me some guidance as to what I'm doing wrong...?

    I'm just trying to store the cube's X position.

    main(doc,op)
    {
    var cube=doc->FindObject("Cube");
    var cubeX = cube.x;
    }



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

    On 29/05/2010 at 10:49, xxxxxxxx wrote:

    You've skipped a step. You must get the position from your object.

      
    var cube = doc->FindObject("Cube"); // this is just what object you want to use   
    var cubeposition = cube->GetPosition(); // This is the local position, vectors x y z.   
    var cubeposX = cubeposition.x; // Her you pick the x vector   
    

    Do read the basicsin the 9.5 COFFEE SDK
    (Found under "Older SDK" at Support Downloads)
    Most of the ideas behind programming is very well described in it.

    Cheers
    Lennart



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

    On 29/05/2010 at 11:05, xxxxxxxx wrote:

    I see...

    Would you be able to help me with something else...?

    I'm trying to keep a null aligned to a spline using an offset specified in a user data field. When I move and rotate the spline, the null doesn't stay aligned because I can't figure out how to input the correct Matrix details. I know this would be simple in Xpresso, but I'm trying to learn COFFEE. I do have the SDK, but it can be difficult to find the answers at times. I would be really grateful for any pointers...

    main(doc,op)
    {
    var spline=doc->FindObject("Spline");
    var point=doc->FindObject("point");

    var offsetAmount=spline#ID_USERDATA:1;
    var offset=spline->GetSplinePoint(offsetAmount,0);

    point->SetPosition(offset);
    }



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

    On 30/05/2010 at 06:28, xxxxxxxx wrote:

    This would be the basics for that. Your position along the spline need to be
    converted into Global space.
    Note that there is no easy way to get a deformed position.
    Also, do check the Init() function in the SDK if you want/need to do any calculations on the spline.

    Cheers
    Lennart

      
    main(doc,op)   
    {   
    var spline = doc->FindObject("Spline");   
    if(!spline) return; // Not found   
    var Cube = doc->FindObject("Cube");   
    if(!Cube) return; // Not found   
      
    var offsetAmount = spline#ID_USERDATA:1;   
    var offset = spline->GetSplinePoint(offsetAmount,0); // The local position along the spline   
        offset = spline->GetMg()->GetMulP(offset);// Get the global offset position   
      
    var CubeM = Cube->GetMg(); // Get the Cube matrix   
        CubeM->SetV0(offset); // Load new position (your offset) into Cube matrix   
        Cube->SetMg(CubeM);    // Reload the edited matrix back to Cube   
    }   
    


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

    On 30/05/2010 at 10:59, xxxxxxxx wrote:

    Thanks a lot Lennart, I've been through your help and it's working just as i wanted. You've given me some really good pointers.
    Benek


Log in to reply