Change views



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

    On 21/07/2010 at 02:40, xxxxxxxx wrote:

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

    ---------
    Hi all,

    I would like to switch from views to views (Perspective, Parralel, Left, Right...). I have a pointer on the active BaseDraw but the method GetNext/Pred (which belongs to a parent class BaseList2D) doesn't seem to work... Even if I get the next/pred view, how can I set it to the current one ?

    Thanks!



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

    On 22/07/2010 at 06:07, xxxxxxxx wrote:

    Problem solved. I use a trick to do that, first I switch the camera projection with SetProjection and then I change the camera global matrix so it looks like the right view. Everything works perfectly, the last problem is the display ! It actually keeps the current display ("Gouraud Shading" by default) and I would like to change it to "Lines".

    I've found the way but I need a reference on the display settings which is available in a ToolData plugin... The display settings are in the struct :

    struct ControlDisplayStruct { public: LONG displaymode; Bool backface_culling; Bool editmode; Vector* vertex_color; };
    

    and the reference is available in the DisplayControl method (ToolData)

    virtual Bool DisplayControl(BaseDocument* doc, BaseObject* op, BaseObject* chainstart, BaseDraw* bd, BaseDrawHelp* bh, ControlDisplayStruct& cds);
    

    The problem is my Plugin is a SceneHookData... Is there any other way to change the display settings without having to switch my plugin parent class ?



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

    On 22/07/2010 at 07:07, xxxxxxxx wrote:

    It seems you are already doing it correctly.

    In any case this is how I would change the viewports projection.

      
    BaseDraw *bd = doc->GetActiveBaseDraw();  
      
    CameraObject *cam = (CameraObject* )bd->GetSceneCamera(doc);  
      
    if (!cam) cam = (CameraObject* )bd->GetEditorCamera();  
    if (!cam) return FALSE;  
      
    // change the camera projection, pass the projection ID  
    cam->SetProjection(Pfront);  
      
    cam->Message(MSG_UPDATE);  
      
    EventAdd();  
    

    As for accessing the view's parameters have a look at the BaseDraw method GeData GetParameterData(LONG id). There you can pass the ID to one of the view's parameters. They can be found in dbasedraw.h.

    cheers,
    Matthias



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

    On 22/07/2010 at 07:45, xxxxxxxx wrote:

    Thank you so much ! It seems to be the method I've been searching for. Could you tell me more about GeData ? For exemple if I get :

    GeData data = baseDraw->GetParameterData(BASEDRAW_SDISPLAY_HIDDENLINE);
    

    What exactly will contain data, and how can I change it ? I suppose I'll use then SetParameter. What will be the GeData so I can put HiddenLine on (it's off by default) ?



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

    On 22/07/2010 at 08:10, xxxxxxxx wrote:

    I've been searching and I think I might be very close :

    baseDraw->SetParameter(DescLevel(BASEDRAW_SDISPLAY_HIDDENLINE),GeData(TRUE),0);
    

    The problem is dbasedraw.h doesn't precise the type of the GeData for BASEDRAW_SDISPLAY_HIDDENLINE. I guess it's a Bool but it doesn't seem to work...



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

    On 22/07/2010 at 09:19, xxxxxxxx wrote:

    Ah, I see, you want to change the settings. I will have a look at it tomorrow.

    cheers,
    Matthias



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

    On 23/07/2010 at 06:04, xxxxxxxx wrote:

    Ok, I had another look at the issue.

    It's actually not necessary to chang ethe camera itself. You can set all this in the BaseDraw itself.

    Here an example which switches the current active view to Front and Hidden Line.

      
    BaseDraw *bd = doc->GetActiveBaseDraw();  
      
    bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION), GeData(BASEDRAW_PROJECTION_FRONT), 0);  
    bd->SetParameter(DescLevel(BASEDRAW_DATA_SDISPLAYACTIVE), GeData(BASEDRAW_SDISPLAY_HIDDENLINE), 0);  
      
    bd->Message(MSG_UPDATE);  
      
    EventAdd();  
    

    Have a look at the dbasedraw.res file for the IDs and which data types they are. In the above example both parameters are LONG. You can also see this in the viewport's configuration settings in the Attribute manager.

    cheers, Matthias



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

    On 23/07/2010 at 06:39, xxxxxxxx wrote:

    Thank you so much Matthias ! It works perfectly ;)


Log in to reply