Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Adding Camera to Scene

    Scheduled Pinned Locked Moved SDK Help
    15 Posts 0 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

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

      On 27/05/2008 at 04:57, xxxxxxxx wrote:

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

      ---------
      Hello

      I am trying to add a camera to a scene, but I get multiples of cameras.
      It seems my function call InsertCamera(op->GetDocument()); within GetVirtualObjects is called multiple times. How can avoid this multiple insertion ?
      May I use an Execute Method beside GetVirtualObjects ? When is it called ?

      Bool CLODDY4D::InsertCamera(BaseDocument *doc){
          CameraObject *cam = (CameraObject* )BaseObject::Alloc(Ocamera);
           doc->InsertObject(cam, NULL, NULL,FALSE);
           EventAdd();
           return TRUE;
      }

      Cheers
      Sascha

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

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

        On 27/05/2008 at 05:00, xxxxxxxx wrote:

        You must not add objects to a document within GetVirtualObjects().

        cheers,
        Matthias

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          On 27/05/2008 at 06:47, xxxxxxxx wrote:

          I understand. Thanks for this hint.

          But how do I avoid the memory leak using
          CameraObject *cam = (CameraObject* )BaseObject::Alloc(Ocamera); alone within GetVirtualObjects() ?

          Is it possible to create a camera there like a cube or a spline ? If not, where to do this ?

          Cheers

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

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

            On 29/05/2008 at 04:57, xxxxxxxx wrote:

            Hmm,

            does nobody use cameraobjects ?

            Cheers

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

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

              On 29/05/2008 at 06:03, xxxxxxxx wrote:

              I am not sure, what are you trying to achieve? Object plugins are for creating new object types (generators, deformers, effectors etc.).

              cheers,
              Matthias

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

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

                On 29/05/2008 at 06:18, xxxxxxxx wrote:

                Okay, I got that.

                The achievement is to gain access to the camera's region of interest (that what the camera can see) leading to derive some kind of view-dependency.

                As mentioned in another thread refinement will occur on an object by splitting edges and connecting new polygons in dependence of the viewing of the camera - the result should be, that the refinement is in the camera's visible area greater than at the back of the object - what the cam cannot see (cause it is hidden by the polygons facing towards the camera). I am not sure about using the EditorCamera for this via BaseDraw...

                Cheers
                Sascha

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

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

                  On 29/05/2008 at 06:24, xxxxxxxx wrote:

                  Ok, then the best way I think would be to get the editor camera from the active BaseDraw or alternatively use a Link field in your object's description where you can drag a custom camera.

                  cheers,
                  Matthias

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

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

                    On 29/05/2008 at 09:42, xxxxxxxx wrote:

                    Is it possible to map the BaseDraw-View to an animateable custom camera automatically? Otherwise the link field would be the alternative...

                    Cheers

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

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

                      On 30/05/2008 at 00:25, xxxxxxxx wrote:

                      Just check for a scene camera with GetSceneCamera() and if NULL use GetEditorCamera(). This way you can use an own camera or just use the editor camera.

                      Also it's probably a good idea to obtain the BaseDraw with GetRenderBaseDraw().

                      cheers,
                      Matthias

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

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

                        On 30/05/2008 at 12:46, xxxxxxxx wrote:

                        Hey all

                        I use this now:
                             BaseDraw *draw = doc->GetRenderBaseDraw();
                             BaseObject *cam = draw->GetEditorCamera();

                        It seems this can only be mapped to a BaseObject.
                        I wonder how to change the objects position.
                        BaseContainer *cn = cam->GetDataInstance();
                        cn->SetVector(???,Vector(0,1000,-5000));
                        Which ID should be set here if this works to change its position ?

                        If there's no chance creating a targeted camere or sth like this, i should use the link field, cause the editorcam cannot be animated. I just wanted to doff some activities from the user.

                        Cheers

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

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

                          On 30/05/2008 at 14:36, xxxxxxxx wrote:

                          You could just use cam->SetPos(Vector(0,1000,-5000))? 😉

                          1 Reply Last reply Reply Quote 0
                          • H Offline
                            Helper
                            last edited by

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

                            On 31/05/2008 at 06:51, xxxxxxxx wrote:

                            Hmm, I don't know why i overlooked that ?!

                            Okay right now, I create a scene camera manually before executing my plugin :

                            > \> BaseDocument \*doc = op->GetDocument(); \>           BaseDraw \*draw = doc->GetRenderBaseDraw(); \>           BaseObject \*cam = draw->GetSceneCamera(doc); \>           if(!cam) cam = draw->GetEditorCamera(); \> \>           LONG x= cam->GetPos().x; \>           LONG y= cam->GetPos().y; \>           LONG z= cam->GetPos().z; \>           GePrint("X: "+LongToString(x)+", Y: "+LongToString(y)+", Z: "+LongToString(z)); \>

                            So far this works - thanks to you.

                            I wonder if it is possible to create a targeted scene camera before the other steps in my plugin...
                            Cheers

                            1 Reply Last reply Reply Quote 0
                            • H Offline
                              Helper
                              last edited by

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

                              On 31/05/2008 at 11:36, xxxxxxxx wrote:

                              Watch your value types. The values are Real. For quicker access, you can go like this (for instance) :

                              > Vector cpos = cam->GetPos();
                              > GePrint("X: "+RealToString(cpos.x)+", Y: "+RealToString(cpos.y)+", Z: "+RealToString(cpos.z));

                              You can use LongToString() and the Real will be converted to Long printing integer values nonetheless.

                              As for the targeted scene camera, I think that you will need to construct this yourself. Just requires two additions to the camera object: a null object and a Target Expression tag added to the camera object. You will need to set the "Target Object" link field on the tag to link the camera to the null object.

                              You do this by getting the tag's BaseContainer and setting the appropriate ID:

                              > BaseObject* nobj = BaseObject::Alloc(Onull);
                              > if (!nobj) return FALSE; // error condition
                              > doc->InsertObject(nobj, NULL, NULL, FALSE);
                              > // You may need to use BaseTag::Alloc(Ttargetexpression) and cam->InsertTag(ttag) if MakeTag() doesn't work.
                              > BaseTag* ttag = cam->MakeTag(Ttargetexpression);
                              > if (!ttag) return FALSE; // error condition
                              > ttag->GetDataInstance()->SetLink(TARGETEXPRESSIONTAG_LINK, nobj);

                              1 Reply Last reply Reply Quote 0
                              • H Offline
                                Helper
                                last edited by

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

                                On 02/06/2008 at 03:31, xxxxxxxx wrote:

                                Hey Robert,

                                thanks for this advice. You are absolutely right. I forgot, that Vector uses Real datatype.

                                Hmm... afaik doc->InsertObject() is not allowed inside a GetVirtualObjects()-function ?! I am still operating on my generator plugin...
                                I am afraid I have very less knowledge about execution priority of functions within plugins

                                In atom.cpp Recurse() is called within GetVirtualObjects() without producing multiple objects on redraw, what I can't understand. The boolean variable "dirty" is set to false in GetVirtualObjects() and given to Recurse() but it never changes... I have no idea how to bring more than one object into the document when using a generator plugin. Perhaps I should port everything to a command plugin... *sigh*

                                Edit:
                                Well using a command plugin everything works so far. *great happyness*
                                But just for knowledge, how can more objects than the generated one be "inserted" in GetVirtualObjects()

                                Thanks to you all 🙂

                                Cheers
                                Sascha

                                1 Reply Last reply Reply Quote 0
                                • H Offline
                                  Helper
                                  last edited by

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

                                  On 10/06/2008 at 08:07, xxxxxxxx wrote:

                                  Hey again, sorry for pushing this one to the top again, but I recently recognized an issue with my camera set into the scene i do not understand.

                                  As a few know, I am developing a plugin calculating a planets surface via CLOD depending on the view point.

                                  In this post I asked for adding a camera to a scene via code.
                                  This is done. The camera is allocated and insterted into the document.
                                  Using these two lines
                                  BaseDraw *draw = doc->GetRenderBaseDraw();
                                  draw->SetSceneCamera(cam);

                                  I am able to look through my camera. So far so good.

                                  When my calculation ends, it seems they've been made from looking through the default editor's view and not the camera's view. Did I miss to set something for my camera or the base draw ?

                                  Cheers
                                  Sascha

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post