OGL in Editor?



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

    On 29/06/2006 at 23:28, xxxxxxxx wrote:

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

    ---------
    Hi,

    is it possible to incorporate my own OpenGL preview in the editor? Can I get access to the OGL frame?



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

    On 03/07/2006 at 10:53, xxxxxxxx wrote:

    I do not think that this is possible, but I will ask the developers if there is a way and get back to you.



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

    On 03/07/2006 at 10:55, xxxxxxxx wrote:

    Thanks Mikael!



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

    On 03/07/2006 at 12:11, xxxxxxxx wrote:

    According to the developers it's possible to use OpenGL draw functions in any plugin ::Draw() function. Everything (context creation, activate context, swapping buffers) is done by Cinema. The plugin only needs to call the draw functions. Of course you need to first check if OpenGL is activated in CINEMA 4D.



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

    On 03/07/2006 at 12:21, xxxxxxxx wrote:

    Great, thanks Mikael! :)



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

    On 04/07/2006 at 02:10, xxxxxxxx wrote:

    Oh. Thats good news!

    regards
    /Filip



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

    On 09/09/2006 at 13:05, xxxxxxxx wrote:

    | User Information: Cinema 4D Version:   9,6 
    Platform:   Windows XP SP2  ; 
    Language(s) :     C++  ;   Compiler:  VS 6 SP6
    --------- Excuse me. Can you show some example, how to do it. I try write OGL commands inside "::Draw" method of my plugin. But it cause some linking errors. Which libraries should I include? When I include <gl/gl.h> I recieve linking error message:

        
        
        d:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
      
    d:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers   
    d:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
    

    This is my plugin. I use workspace settings from cinema4dsdk example.

      
    #include <gl/gl.h>  
    #include <gl/glu.h> #include "c4d.h"  
    #include "c4d_symbols.h"  
    #include "lib_modeling.h"  
    #include "lib_ngon.h"  
    #include "O_AMa_ChamferDeformer.h"   
    Bool Compare_pBaseObjects( BaseObject *Ob, BaseObject *cacheOb)  
    {  
     while( cacheOb)  
     {  
      if( Ob == cacheOb)  
       return TRUE ;  
      else  
       cacheOb = cacheOb->GetCacheParent() ;  
     }  
     return FALSE ;  
    } class AMaChamDefor : public ObjectData   
    {  
    public:  
     virtual Bool Init(GeListNode *node);  virtual Bool Message    (GeListNode *node, LONG type, void *data);  
     virtual Bool GetDEnabling( GeListNode* node, const DescID& id, GeData& t_data, LONG flags, const BaseContainer* itemdesc) ;  
     virtual Bool GetDDescription( GeListNode* node, Description* description, LONG& flags) ;  
     virtual Bool ModifyObject   (PluginObject *op, BaseDocument *doc, BaseObject *mod, const Matrix &op_mg, const Matrix &mod_mg, Real lod, LONG flags, BaseThread *thread);  
     virtual Bool Draw (PluginObject *op, LONG type, BaseDraw *bd, BaseDrawHelp *bh) ;  static NodeData *Alloc(void) { return gNew AMaChamDefor; }  
    }; Bool AMaChamDefor::Init(GeListNode *node)  
    {   
     BaseObject  *op   = (BaseObject* )node;  
     BaseContainer *data = op->GetDataInstance();  
       
     data->SetLong( AMa_CHAMFERDEFORMER_SELECTIONMODE, AMa_CHAMFERDEFORMER_SELMO_SSET) ;  
     data->SetLong( AMa_CHAMFERDEFORMER_NUM_FIRSTS_SS, 1) ;  
     data->SetBool( AMa_CHAMFERDEFORMER_USE_ADD_SS, FALSE) ;  
     data->SetLong( AMa_CHAMFERDEFORMER_ADD_SS_NUMBER, 1) ;  
     data->SetBool( AMa_CHAMFERDEFORMER_FILT_OPEN_E, FALSE) ;  
     data->SetReal( AMa_CHAMFERDEFORMER_RADIUS, 5.0) ;  
     data->SetReal( AMa_CHAMFERDEFORMER_VARIANCE, 0.0) ;  
     data->SetLong( AMa_CHAMFERDEFORMER_SUBDIVISION, 0) ;  
     data->SetBool( AMa_CHAMFERDEFORMER_CREATENGONS, TRUE) ;  
     data->SetLong( AMa_CHAMFERDEFORMER_MODE, AMa_CHAMFERDEFORMER_MODE_BEZIER) ;  
     AutoAlloc<SplineData> falloffspline ;  
     if( ! falloffspline)  
      return FALSE ;  
     falloffspline->InsertKnot( 0.0, 0.0) ;  
     falloffspline->InsertKnot( 0.441, 0.742) ;  
     falloffspline->InsertKnot( 1.0, 1.0 ) ;  
     falloffspline->SetRound( 0.34) ;  
     data->SetData( AMa_CHAMFERDEFORMER_PATH, GeData(CUSTOMDATATYPE_SPLINE, falloffspline)) ;  
     data->SetReal( AMa_CHAMFERDEFORMER_EXTRUSION, 6.0) ;  
     data->SetReal( AMa_CHAMFERDEFORMER_EXTRU_VARI, 0.0) ;  
       
     return TRUE;  
    } Bool AMaChamDefor::Message( GeListNode *node, LONG type, void *data)  
    {  
     if ( type == MSG_MENUPREPARE)  
     {  
      ( static_cast<BaseObject*>( node))->SetDeformMode( TRUE) ;  
     }  
     return TRUE ;  
    } Bool AMaChamDefor::GetDEnabling( GeListNode* node, const DescID& id, GeData& t_data, LONG flags,   
            const BaseContainer* itemdesc)  
    {  
     switch( id[0].id)  
     {  
      case AMa_CHAMFERDEFORMER_EXTRUSION:  
      case AMa_CHAMFERDEFORMER_EXTRU_VARI:  
      case AMa_CHAMFERDEFORMER_PATH:  
      {  
       BaseObject *op   = static_cast<BaseObject*>( node) ;  
       BaseContainer *data = op->GetDataInstance() ;  
       return ( data->GetLong( AMa_CHAMFERDEFORMER_MODE) == AMa_CHAMFERDEFORMER_MODE_USER) ;  
      }  
     }  
     return ObjectData::GetDEnabling( node, id, t_data, flags, itemdesc) ;  
    } Bool AMaChamDefor::GetDDescription( GeListNode *node, Description *description, LONG &flags)  
    {   
     if( ! description || ! node)   
      return FALSE;   
     if( ! description->LoadDescription( node->GetType()))   
      return FALSE;  
     AutoAlloc<AtomArray> ar;   
     if( ! ar)   
      return FALSE;   
       
     BaseObject *op   = static_cast<BaseObject*>( node) ;  
     BaseContainer *bc, *data = op->GetDataInstance() ;  
     ar->Append( static_cast<C4DAtom*>(node));  
       
     if( data->GetLong( AMa_CHAMFERDEFORMER_SELECTIONMODE) != AMa_CHAMFERDEFORMER_SELMO_SSET)  
     {  
      //LONG hh = data->GetLong( AMa_CHAMFERDEFORMER_MODE) ;  
      bc = description->GetParameterI( DescLevel( AMa_CHAMFERDEFORMER_NUM_FIRSTS_SS), ar) ;  
      if( bc)  
       bc->SetBool( DESC_HIDE, TRUE) ;   
     }  if( ! data->GetBool( AMa_CHAMFERDEFORMER_USE_ADD_SS))  
     {  
      bc = description->GetParameterI( DescLevel( AMa_CHAMFERDEFORMER_ADD_SS_NUMBER), ar) ;  
      if( bc)  
       bc->SetBool( DESC_HIDE, TRUE) ;  
      for( LONG i=0; i<10; i++)  
      {  
       bc = description->GetParameterI( DescLevel( AMa_CHAMFERDEFORMER_ADDITI_SSET_0 + i), ar) ;  
       if( bc)  
        bc->SetBool( DESC_HIDE, TRUE) ;  
      }  
     }  
     else  
     {  
      LONG tmpAddSSNum = data->GetBool( AMa_CHAMFERDEFORMER_ADD_SS_NUMBER) ;  
      for( LONG i=tmpAddSSNum; i<10; i++)  
      {  
       bc = description->GetParameterI( DescLevel( AMa_CHAMFERDEFORMER_ADDITI_SSET_0 + i), ar) ;  
       if( bc)  
        bc->SetBool( DESC_HIDE, TRUE) ;  
      }  
     }  
       
     if( data->GetLong( AMa_CHAMFERDEFORMER_MODE) != AMa_CHAMFERDEFORMER_MODE_USER)  
     {  
      bc = description->GetParameterI( DescLevel( AMa_CHAMFERDEFORMER_PATH), ar) ;  
      if( bc)  
       bc->SetBool( DESC_HIDE, TRUE) ;   
      bc = description->GetParameterI( DescLevel( AMa_CHAMFERDEFORMER_EXTRUSION), ar) ;  
      if( bc)  
       bc->SetBool( DESC_HIDE, TRUE) ;  
      bc = description->GetParameterI( DescLevel( AMa_CHAMFERDEFORMER_EXTRU_VARI), ar) ;  
      if( bc)  
       bc->SetBool( DESC_HIDE, TRUE) ;  
     }  flags |= DESCFLAGS_DESC_LOADED ;  
     return ObjectData::GetDDescription( node, description, flags) ;  
    } Bool AMaChamDefor::ModifyObject(PluginObject *mod, BaseDocument *doc, BaseObject *op, const Matrix &op_mg,   
           const Matrix &mod_mg, Real lod, LONG flags, BaseThread *thread)  
    {  
     if ( ! op->IsInstanceOf( Opolygon))   
      return TRUE ;  
     PolygonObject* obj = ToPoly( op) ;  
     BaseSelect *selE = obj->GetEdgeS() ;  
     BaseContainer *data = mod->GetDataInstance() ;   
     Bool SelectionWillBeAdded = FALSE ;  
     if( data->GetBool( AMa_CHAMFERDEFORMER_USE_ADD_SS))  
      SelectionWillBeAdded = TRUE ;  
       
     switch( data->GetLong( AMa_CHAMFERDEFORMER_SELECTIONMODE))  
     {  
      case AMa_CHAMFERDEFORMER_SELMO_SSET:  
      {  
       SelectionTag *TagEdgSel ;  
       LONG tmpFirstSSNum = data->GetLong( AMa_CHAMFERDEFORMER_NUM_FIRSTS_SS) ;  
       for( LONG i=0; i<tmpFirstSSNum; i++)  
       {  
        TagEdgSel = static_cast<SelectionTag*>( obj->GetTag( Tedgeselection, i)) ;  
        if( ! TagEdgSel)  
        {  
         if( i == 0 && SelectionWillBeAdded)  
         {  
          selE->DeselectAll() ;  
          break ;  
         }  
         else  
          return TRUE ;  
        }  
        else  
        {  
         if( i == 0)  
          TagEdgSel->GetBaseSelect()->CopyTo( selE) ;  
         else  
          selE->Merge( TagEdgSel->GetBaseSelect()) ;   
        }  
       }  
       break ;  
      }  
      case AMa_CHAMFERDEFORMER_SELMO_SEL:  
       break ;  
      case AMa_CHAMFERDEFORMER_SELMO_PHO:  
      {  
       BaseSelect *selPho = obj->GetPhongBreak() ;  
       if( selPho->GetCount() == 0)  
       {  
        if( SelectionWillBeAdded)  
        {  
         selE->DeselectAll() ;  
         break ;  
        }  
        else  
         return TRUE ;  
       }  
       else  
       {  
        selPho->CopyTo( selE) ;  
        break ;  
       }  
      }  
      case AMa_CHAMFERDEFORMER_SELMO_ALL:  
      {  
       selE->SelectAll( 0, obj->GetPolygonCount() * 4 - 1) ;  
       break ;  
      }  
     }  
       
     if( data->GetBool( AMa_CHAMFERDEFORMER_USE_ADD_SS))  
     {  
      SelectionTag *TagEdgSel ;  
      LONG tmpAddSSNum = data->GetLong( AMa_CHAMFERDEFORMER_ADD_SS_NUMBER) ;  
      for( LONG i=0; i<tmpAddSSNum; i++)  
      {  
       TagEdgSel = static_cast<SelectionTag*>(   
            data->GetLink( AMa_CHAMFERDEFORMER_ADDITI_SSET_0 + i, doc)) ;  
       if( TagEdgSel && Compare_pBaseObjects( TagEdgSel->GetObject(), op))  
        selE->Merge( TagEdgSel->GetBaseSelect()) ;  
      }  
     }  
       
     if( selE->GetCount() == 0)  
        return TRUE ;  if( data->GetBool( AMa_CHAMFERDEFORMER_FILT_OPEN_E))  
     {  
      LONG i, PCnt, ECnt, P_ofE, eInP, a, b, fP, sP ;  
      Neighbor nbr ;  
      PolyInfo *p_PInf ;  
      CPolygon* p_P = obj->GetPolygon() ;  
      PCnt = obj->GetPolygonCount() ;  
      ECnt = PCnt * 4 ;  
      nbr.Init( obj->GetPointCount(), p_P, PCnt, NULL) ;  
      UCHAR *ar_selE = selE->ToArray( ECnt) ;  
      for( i=0; i<ECnt; i++)  
      {  
       if( ! ar_selE[i])  
        continue ;  
         
       eInP = i % 4 ;  
       P_ofE = (i - eInP) / 4 ;  
       p_PInf = nbr.GetPolyInfo( P_ofE) ;  
       switch( eInP)  
       {  
        case 0:  
        {  
         a = p_P[P_ofE].a ;  
         b = p_P[P_ofE].b ;  
         break ;  
        }  
        case 1:  
        {  
         a = p_P[P_ofE].b ;  
         b = p_P[P_ofE].c ;  
         break ;  
        }  
        case 2:  
        {  
         a = p_P[P_ofE].c ;  
         b = p_P[P_ofE].d ;  
         break ;  
        }  
        case 3:  
        {  
         a = p_P[P_ofE].d ;  
         b = p_P[P_ofE].a ;  
         break ;  
        }  
       }  
       nbr.GetEdgePolys( a, b, &fP, &sP) ;  
       if( fP < 0 || sP < 0)  
        selE->Deselect( i) ;  
      }  
      GeFree( ar_selE) ;  
     }  BaseContainer bc;  
     bc.SetReal( MDATA_BEVEL_OFFSET2, data->GetReal( AMa_CHAMFERDEFORMER_RADIUS)) ;  
     bc.SetReal( MDATA_BEVEL_VARIANCE2, data->GetReal( AMa_CHAMFERDEFORMER_VARIANCE)) ;  
     bc.SetLong( MDATA_BEVEL_SUBDIVISION, data->GetLong( AMa_CHAMFERDEFORMER_SUBDIVISION)) ;  
     bc.SetBool( MDATA_BEVEL_CREATENGONS, data->GetBool( AMa_CHAMFERDEFORMER_CREATENGONS)) ;  
     LONG C4D_Bevel_Mode ;  
     switch( data->GetLong( AMa_CHAMFERDEFORMER_MODE))  
     {  
      case AMa_CHAMFERDEFORMER_MODE_LINEAR:  
       C4D_Bevel_Mode = MDATA_BEVEL_MODE_LINEAR ;  
       break ;  
      case AMa_CHAMFERDEFORMER_MODE_CONVEX:  
       C4D_Bevel_Mode = MDATA_BEVEL_MODE_OUTER_CIRCLE ;  
       break ;  
      case AMa_CHAMFERDEFORMER_MODE_CONCAVE:  
       C4D_Bevel_Mode = MDATA_BEVEL_MODE_INNER_CIRCLE ;  
       break ;  
      case AMa_CHAMFERDEFORMER_MODE_BEZIER:  
       C4D_Bevel_Mode = MDATA_BEVEL_MODE_BEZIER ;  
       break ;  
      case AMa_CHAMFERDEFORMER_MODE_USER:  
       C4D_Bevel_Mode = MDATA_BEVEL_MODE_USER ;  
       break ;  
     }  
     bc.SetLong( MDATA_BEVEL_MODE, C4D_Bevel_Mode) ;  
     bc.SetData( MDATA_BEVEL_PATH, ( data->GetData( AMa_CHAMFERDEFORMER_PATH))) ;  
     bc.SetReal( MDATA_BEVEL_OFFSET1, data->GetReal( AMa_CHAMFERDEFORMER_EXTRUSION)) ;  
     bc.SetReal( MDATA_BEVEL_VARIANCE1, data->GetReal( AMa_CHAMFERDEFORMER_EXTRU_VARI)) ;  
     ModelingCommandData cd ;  
     cd.doc = doc ;  
     cd.bc = &bc ;  
     cd.op = obj ;  
     cd.mode = MODIFY_EDGESELECTION ;  
     cd.arr = NULL ;  
     if ( ! SendModelingCommand( ID_MODELING_BEVEL_TOOL, cd))   
      return FALSE ;  
     op->Message(MSG_UPDATE) ;  
     return TRUE ;  
    } Bool AMaChamDefor::Draw(PluginObject *op, LONG type, BaseDraw *bd, BaseDrawHelp *bh)  
    {  
     Real SCREEN_WIDTH = 800, SCREEN_HEIGHT = 600, u =1, v = 1 ;  if (type==DRAWPASS_OBJECT)  
     {   
      glBegin(GL_TRIANGLE_STRIP) ;  
       glTexCoord2f( 0, 0);  
       glVertex3f( 0, 0, 1.0);  
       glTexCoord2f( u, 0);  
       glVertex3f( SCREEN_WIDTH, 0, 1.0);  
       glTexCoord2f( 0, v);  
       glVertex3f( 0, SCREEN_HEIGHT, 1.0);  
       glTexCoord2f( u, v);  
       glVertex3f( SCREEN_WIDTH, SCREEN_HEIGHT, 1.0);  
      glEnd();  
     }  return TRUE ;   
    } #define ID_AMa_CHAMFER_DEFORMER 1020211 // be sure to use a unique ID obtained from [www.plugincafe.com](http://www.plugincafe.com) Bool Register_AMa_Deformer(void)  
    {  
     String name=GeLoadString(IDS_AMaCHAMFER_MENU_NAME);   
     if( ! name.Content())   
      return TRUE ;  
     return RegisterObjectPlugin( ID_AMa_CHAMFER_DEFORMER, name, OBJECT_MODIFIER,  
       AMaChamDefor::Alloc, "O_AMa_ChamferDeformer",  
       "AMa_ChamferDeformer.tif", "AMa_ChamferDeformer_Small.tif", 0) ;  
    }
    
    



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

    On 10/09/2006 at 11:09, xxxxxxxx wrote:

    I have used direct OpenGL access from ::Draw() function inside my GLSL plugins.
    It is only important if you will cnange settings to call glPushAttrib() before do something with OpenGL and then glPopAttrib() after to restore C4D internal OpenGL settings.
    I have used glew.h to accees OpenGL.
    The only big problem for me was to port it to Mac...

    One question, how to proper test if OpenGL is activated?



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

    On 11/09/2006 at 11:44, xxxxxxxx wrote:

    Thank you.
    All works well.



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

    On 12/11/2006 at 05:07, xxxxxxxx wrote:

    Hey,

    just for reference, you must include windows.h before including the gl headers to get rid of these compiler errors.



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

    On 12/11/2006 at 05:49, xxxxxxxx wrote:

    And another problem (wow this is really f**ked up :)

    I get unresolved external errors for the OpenGL calls I am using.

    LNK2019 unresolved external symbol __imp__glBlendFunc@8 referenced in function "public: virtual int __thiscall

    The libs (Opengl32.lib,Glu32.lib) and includes (gl.h,glu.h) are however correctly assigned in the compiler settings (and I also checked the OpenGL website which states that this should fix the link errors) and Opengl32.dll is also in the system path.

    Does anybody have a clue why it´s not working? Is there a compiler setting I need to add or so?


Log in to reply