AnimateObject query



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

    On 16/02/2005 at 05:27, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8 
    Platform:   Windows  ; Mac  ;  Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
        Hi all,
    I want to see point level animation data for an object at a particular time.

    It seems that I can use:

    doc->SetTime(BaseTime(123.0));
    doc->AnimateDocument(NULL, false, true);
    pnt = obj->GetPoint();

    But, this animates the whole document.

    Alternatively I could use:
    doc->AnimateObject(obj, BaseTime(123.0), 0);
    pnt = obj->GetPoint();

    This seems to work fine and only updates the object I'm interested in.
    However, the documentation says "The caller owns the pointed object." 'obj' in this case.

    Since 'obj' is already in 'doc', then C4D owns it not me.
    If I create a new object, then I own it, but it then has nothing to do with 'doc'.

    Please confirm that if 'obj' is an object in 'doc', I can safely use AniomateObject on it.
    If not, please explain how I can own an object and have it in a document at the same time.

    Finally, both of these approaches require me to animate the object(s) back to the 'real' curent time after I've done this. This is inefficient.
    Is there a more direct way of getting the point data for an object for a particular frame, or is this the way to do it?

    Thanks for your help.

    Cheers - Steve



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

    On 16/02/2005 at 07:19, xxxxxxxx wrote:

    If you look carefully, it doesn't say 'obj', does it?

    It says:

    void AnimateObject(BaseList2D* op, const BaseTime & time, LONG flags)

    A BaseList2D is a lower-level class that could be just about any animatable feature. This needs to be part of the document, yes. But I wouldn't go this way about it.

    Why are you using AnimateDocument() to get to the PLA key for an object?

    To get to a PLA key at a specific time for a specific object, seems that you want to get the BaseObject* of the obj, get the appropriate Track for it (see BaseList2D::GetTrack() and FindTrack()), get the appropriate Sequence from the Track, then the appropriate PLA Key(s) from the Sequence.

    You can check the time range covered by the Sequence with GetT1() and GetT2(). And you can find a key at a particular time using Sequence::FindKey(const BaseTime& time) once you have the Sequence from the Track from the Object. :)



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

    On 16/02/2005 at 08:09, xxxxxxxx wrote:

    Hi Robert,
    Thanks for the pointers - though I'm still not there yet...

    I was trying AnimateDocument and AnimateObject because they appeared to be what I needed to use to get at the data I'm looking for - namely the vertex position data for an object at any given point in time. Note, I am not trying to read the keyframe data itself, I'm trying to get at the resulting interpolated vertex position data - regardless of whether there is a keyframe or not.

    Following your suggestion I can do this (pointer checking omitted) :-

    BaseTrack* track = obj->FindTrack(Spla);
    BaseSequence* seq = track->FindSequence(BaseTime(123.0));
    BaseKey* key = seq->FindKey(BaseTime(123.0));
    PLAKey* plaKey = static_cast<PLAKey*>(key);
    VariableTag* tag = plaKey->GetPointTag();
    Vector* pnt = static_cast<Vector*>(tag->GetDataAddress());

    Which gets me from my original object 'obj', to the point data at a particular time - which is what I want, BUT this will only work if I have a keyframe at the time I'm interested in.

    Now I could interpolate between the keyframes myself, but surely I can just ask C4D to do that for me since it's doing that anyway?

    The two liner using AnimateObject that I originally posted seems to do the job, but I'm not sure if it is safe due to the ownership issue in the docs.

    You are correct that the documentation doesn't say object, it says 'BaseList2D*'. But that doesn't answer the question of how it can be in the document, but also be owned by the caller. It's one or the other isn't it?

    Or am I misunderstanding the meaning of 'ownership' as used in the documentation?
    My understanding is that I have ownership of an object if I am expected to free it when I'm done. C4D has ownership if it has been inserted into the document.

    Cheers - Steve



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

    On 16/02/2005 at 08:54, xxxxxxxx wrote:

    Hi Steve,

    Alright. Using the object's values won't work. ;) An object's position, scale, rotation values do not change during animation. These are static values for transformations.

    All animated values need to be extracted from the object's tracks. If you need a specific time which has no key, you will need to get the two nearest keys that bound the desired time and interpolate. If you want a specific key near the time, you need to BaseSequence::GetFirstKey() and GetKeyCount(), then loop through the sequence's keys checking for the nearest time with Key::GetTime(). Actually, you'll need to do this to find two keys that bound an unkeyed time as well.

    As for interpolation, there is probably a way to get that from the SDK, but I don't know how to go about it. Check out GetKeyValue() and AnimValue in the docs, which may help. The problem with PLA Keys is that they represent an array of Vector deltas, so the interpolation type and data will need to be applied to every point!

    Regarding the 'ownership' issue, I don't understand this either. The BaseList2D* should be one retrieved from the BaseDocument, so you don't have ownership, the document does. You just have a pointer to the node. This looks like one for Mikael. :)


Log in to reply