Setting data of a camera (from a tag)



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

    On 29/07/2007 at 13:55, xxxxxxxx wrote:

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

    ---------
    Hi,

    I have an expression tag which as attached to a camera. I want the tag to set the camera's target distance, and other parameters.

    In this forum I have read something about getting the active camera and setting its data. But how do I access the data of the camera my tag is located at? in the plugin code, 'op' just returns me a BaseObject, which doesn't offer the attributes I am looking for.

    Thanks for any help!

    Best regards,
    Jack



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

    On 29/07/2007 at 21:54, xxxxxxxx wrote:

    Just check the type for 'op' to make sure it's a camera than cast it:

    if (!op->IsInstanceOf(Ocamera)) // return or something
    CameraObject* cam = static_cast<CameraObject*>(op);
    // Voila, BaseObject op is now a camera. ;)



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

    On 29/07/2007 at 22:27, xxxxxxxx wrote:

    Thanks for the Info! :)

    Wow, that sounds pretty easy. So after that I use "cam" as the camera object, and it has all methods and properties of a BaseCamera (or a RayCamera)?

    Greetings,
    Jack



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

    On 30/07/2007 at 05:35, xxxxxxxx wrote:

    Quote: _So after that I use "cam" as the camera object, and it has all methods and properties of a BaseCamera (or a RayCamera)?
    >
    > * * *
    _


    Yes, it has all methods of the CameraObject class (there is no BaseCamera object).

    cheers,
    Matthias



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

    On 30/07/2007 at 16:04, xxxxxxxx wrote:

    Hm...
    I get an error in this line:

    CameraObject* cam = static_cast<CameraObject*>(op);
    

    Error message:
    error C2065: 'MyCam': nichtdeklarierter Bezeichner

    I thought "CameraObject* cam" IS the declaration?

    Thanks again,
    Jack



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

    On 30/07/2007 at 16:39, xxxxxxxx wrote:

    Where is 'MyCam' coming from? Maybe you have it undeclared but used elsewhere? If the cast gives you trouble, just use the old C-style cast instead:

    CameraObject* cam = (CameraObject* )op;



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

    On 31/07/2007 at 15:05, xxxxxxxx wrote:

    It works now... but another problem:
    I don't find a parameter for setting the "Target Distance" of the camera. How can I access thos depth parameters?

    Thanks again in advance!

    Greetings,
    Jack



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

    On 31/07/2007 at 15:20, xxxxxxxx wrote:

    Target what? Most cameras use a direction vector (eye vector or whatnot) to point the camera which is based on the camera's rotation - there isn't an explicit target and thus no 'target distance'.

    Cameras in C4D are only explicitly targeted when using a Target tag and you could do the simple math of determining the distance from the camera's global origin to the target's global origin in these cases.



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

    On 01/08/2007 at 00:17, xxxxxxxx wrote:

    Yes, I know that. I am writing a plugin that - besides other features - also does targeting. I won't use the normal target expression tag. My target function already works, that's not the problem.

    Anyway, a camera has an attribute "Target distance" which can be found in the depth attributes (used for setting the focus of the DOF). The normal target expression tag can adjust the target distance attribute, I want to do that too, since it would be a very important function in my plugin.

    Best regards,
    Jack



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

    On 01/08/2007 at 03:41, xxxxxxxx wrote:

    Hey Jack,

    look up the ID in the Ocamera.h (or .res) resource file (you find this and also files for all other objects,tags,nodes,videoposts in ..c4dfolder\resource\res\description\)and then simply use cam->GetDataInstance()->SetReal().

    The ID for targetdistance is CAMERAOBJECT_TARGETDISTANCE

    ScoobyDoobyCammyTooly ;-D



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

    On 01/08/2007 at 03:43, xxxxxxxx wrote:

    Btw., the functions in the CameraObject class are only there for convenience, so to make your life easier, but you can still set all the parameters via their corresponding IDs within the BaseContainer directly. Just as a side note as I think that was the initial problem you had...

    Keep going.



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

    On 01/08/2007 at 04:30, xxxxxxxx wrote:

    That may be one of the best tips, thanks Samir! I'll try that.

    Hope to see you in Cologne, btw :)

    Greetings,
    Jack



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

    On 01/08/2007 at 10:42, xxxxxxxx wrote:

    And it works perfectly, thanks again!

    Best regards,
    Jack



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

    On 02/08/2007 at 03:32, xxxxxxxx wrote:

    Nope, I won´t make it to cologne this year due to my diploma unfortunately. :-/ But wish you a good time there, it was very....drunk the last time. ;-)



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

    On 02/08/2007 at 03:40, xxxxxxxx wrote:

    Hehe, yes, I remember the picture of you from last time :-)
    I wish you success with your diploma!!


Log in to reply