Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Creating Spheres

    SDK Help
    0
    31
    15.6k
    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
      Helper
      last edited by

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

      On 07/11/2009 at 18:12, xxxxxxxx wrote:

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

      ---------
      Hey everyone,

      I would like to have 3 spheres created when the user clicks a button in the attributes manager. How would I go about inserting spheres in to the scene?

      Thanks a lot,

      ~Shawn

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

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

        On 07/11/2009 at 21:32, xxxxxxxx wrote:

        // NodeData.Message   
        //*---------------------------------------------------------------------------*   
        Bool MyPlugin::Message(GeListNode* node, LONG type, void* data)   
        //*---------------------------------------------------------------------------*   
        {   
             if (!node)     return FALSE;   
             if (type == MSG_DESCRIPTION_COMMAND)   
                  return MsgCommand(static_cast<DescriptionCommand*>(data), static_cast<BaseObject*>(node));   
             return TRUE;   
        }   
        // MyPlugin.MsgCommand   
        //*---------------------------------------------------------------------------*   
        Bool MyPlugin::MsgCommand(DescriptionCommand* dc, BaseObject* op)   
        //*---------------------------------------------------------------------------*   
        {   
             if (!dc)     return TRUE;   
             LONG id =     dc->id[0].id;   
             if (id == MAKESPHERES) // Use your button's ID here   
             {   
                  BaseDocument*     doc =     op->GetDocument();   
                  doc->StartUndo();   
                  BaseObject*          sop;   
                  sop =                         BaseObject::Alloc(Osphere);   
                  if (sop)                    doc->InsertObject(sop, NULL, NULL, FALSE);   
                  sop =                         BaseObject::Alloc(Osphere);   
                  if (sop)                    doc->InsertObject(sop, NULL, NULL, FALSE);   
                  sop =                         BaseObject::Alloc(Osphere);   
                  if (sop)                    doc->InsertObject(sop, NULL, NULL, FALSE);   
                  doc->EndUndo();   
             }   
             return TRUE;   
        }
        

        Look into the Resource/Modules/Objects/res/description/Osphere.res file for the properties of the Sphere primitive if you want to set them as well.

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

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

          On 08/11/2009 at 04:20, xxxxxxxx wrote:

          Great thanks robert,   Now I would like to make those three spheres children of my object plugin. I assume I will need to put something else instead of the NULL in the second argument of each insertObject()..   could you tell me what that is?

          Thanks,

          ~SHawn

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

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

            On 08/11/2009 at 04:50, xxxxxxxx wrote:

            If you look into the SDK documentation, it sais:

            void InsertObject(BaseObject* op, BaseObject* parent, BaseObject* pred, Bool checknames = TRUE);

            So, you just pass a pointer to your plugin object as 'parent'.

            Cheers,
            Jack

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

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

              On 08/11/2009 at 04:58, xxxxxxxx wrote:

              Thanks Jack,

              I figured it out..

              ~Shawn

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

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

                On 08/11/2009 at 15:11, xxxxxxxx wrote:

                Okay so now I have my spheres added and have changed some parameters. How do I create 3 new materials apply each material to each of the spheres?

                Thanks,

                ~SHawn

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

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

                  On 08/11/2009 at 15:27, xxxxxxxx wrote:

                  Here's a pared-down function that I use in one of my plugins:

                  // Create TextureTag+Material   
                  //*---------------------------------------------------------------------------*   
                  Bool MyPlugin::CreateMatSelection(BaseObject* baseObject, const String& name, const Bool& uvw)   
                  //*---------------------------------------------------------------------------*   
                  {   
                       // Texture Tag   
                       texTag =          TextureTag::Alloc();   
                       if (!texTag)     FALSE;   
                       baseObject->InsertTag(texTag);   
                       doc->AddUndo(UNDO_NEW, texTag);   
                       texTag->SetName(name);   
                       // Example of setting texture projection   
                       //texTag->SetParameter(DescLevel(TEXTURETAG_PROJECTION), (uvw)?GeData(TEXTURETAG_PROJECTION_UVW) :GeData(TEXTURETAG_PROJECTION_FLAT), 0L);   
                    
                       // Material   
                       Material*          material =     Material::Alloc();   
                       if (!material)     return FALSE;   
                       doc->InsertMaterial(material, NULL, TRUE);   
                       doc->AddUndo(UNDO_NEW, material);   
                       material->SetName(name);   
                    
                       // Setup   
                       texTag->SetMaterial(material);   
                       return TRUE;   
                  }
                  

                  To set up the material channels (Color, Specular, Reflection, etc.), you'll need to look at BaseMaterial::GetChannel(), Material::SetChannelState(), and BaseChannel for particular settings. Most of the Material channel attributes are set via the Material using SetParameter.

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

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

                    On 09/11/2009 at 18:18, xxxxxxxx wrote:

                    When I insert a material using doc->InsertMaterial(material, NULL, TRUE);
                    how can I then keep track of a specific material and change its parameters using specific parameter descriptions within my plugin. For example, I want to be able to control the glow amount of a specific material using a slider bar within the attributes of my plugin.   How do I identify a specific material that I have inserted?

                    Thanks,

                    ~Shawn

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

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

                      On 10/11/2009 at 02:55, xxxxxxxx wrote:

                      okay.. scratch that..   instead,   how do I remove the three spheres and materials that I have created from the scene?

                      Thanks,

                      ~Shawn

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

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

                        On 10/11/2009 at 20:28, xxxxxxxx wrote:

                        Here's what I have so far.. Everything is doing what I want and almost everything is going well..   My problem is, when I try to delete the object or when I click on any control other than ENABLE_ATMOSPHERE, C4D freezes up and crashed..   Can anyone tell me why this is happening?

                        Here's my code

                          
                        /////////////////////////////////////////////////////////////   
                        // Planet   
                          
                        #include "c4d.h"   
                        #include "c4d_symbols.h"   
                        #include "oplanet.h"   
                        #include "c4d_basetag.h"   
                        #include "c4d_basematerial.h"   
                          
                        // be sure to use a unique ID obtained from www.plugincafe.com   
                        #define ID_PLANET_OBJECT 1024532   
                          
                        class Planet : public ObjectData   
                        {   
                             public:   
                                  virtual Bool Init(GeListNode *node);   
                                  virtual Bool GetDEnabling(GeListNode *node, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc);   
                                  virtual Bool Message(GeListNode *node, LONG type, void *t_data);   
                                            Bool CreatePlanet(DescriptionCommand* dc, BaseObject* op);   
                                            Bool UpdatePlanet(DescriptionCommand* dc, BaseObject* op);   
                          
                                            static NodeData *Alloc(void) { return gNew Planet;}   
                          
                                  TextureTag* surfaceTextTag;   
                                  TextureTag* cloudsTextTag;   
                                  TextureTag* atmTextTag;   
                          
                                  BaseObject* surface;   
                                  Material* surfaceMat;   
                                  BaseObject* clouds;   
                                  Material* cloudsMat;   
                                  BaseObject* atmosphere;   
                                  Material* atmosphereMat;   
                          
                                  Bool planetCreated;   
                                  LONG test;   
                        };   
                          
                        // initialize settings   
                        Bool Planet::Init(GeListNode *node)   
                        {     //Called when a new instance of the node plugin has been allocated. You can use this function to for example fill the BaseContainer of the connected node with default values:   
                                
                             BaseContainer* bc = ((BaseObject* )node)->GetDataInstance();   
                             if (!bc)   
                             return false;   
                          
                             bc->SetBool(ENABLE_CRATERS, TRUE);   
                             bc->SetBool(ENABLE_ATMOSPHERE, TRUE);   
                             bc->SetBool(HAS_RINGS, FALSE);   
                          
                             planetCreated = FALSE;   
                             test = 0;   
                          
                             return TRUE;   
                        }   
                          
                          
                        Bool Planet::GetDEnabling(GeListNode *node, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc)   
                        {        
                             // Enable/disable our parameters   
                             BaseContainer *bc=((BaseList2D* )node)->GetDataInstance();   
                             BaseObject* op = static_cast<BaseTag*>(node)->GetObject();   
                          
                             switch (id[0].id)   
                             {        
                                  case SURFACE_PRESETS:   
                                       if (op)   
                                       {     if (bc->GetBool(USE_PRESET)==TRUE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                                     
                                  case CRATER_AMOUNT:   
                                       if (op)   
                                       {     if (bc->GetBool(ENABLE_CRATERS)==TRUE&&bc-;>GetBool(USE_PRESET)==FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case CRATER_SIZE:   
                                       if (op)   
                                       {     if (bc->GetBool(ENABLE_CRATERS)==TRUE&&bc-;>GetBool(USE_PRESET)==FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case SURFACE_MAP:   
                                       if (op)   
                                       {     if (bc->GetBool(USE_PRESET)==FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case ELEVATION_MAP:   
                                       if (op)   
                                       {     if (bc->GetBool(USE_PRESET)==FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case ELEVATION_STRENGTH:   
                                       if (op)   
                                       {     if (bc->GetBool(USE_PRESET)==FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case ENABLE_CRATERS:   
                                       if (op)   
                                       {     if (bc->GetBool(USE_PRESET)==FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case CLOUD_MAP:   
                                       if (op)   
                                       {     if (bc->GetBool(USE_PRESET2)==FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case CLOUD_BRIGHTNESS:   
                                       if (op)   
                                       {     if (bc->GetBool(USE_PRESET2)==FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case CLOUD_THICKNESS:   
                                       if (op)   
                                       {     if (bc->GetBool(USE_PRESET2)==FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case CLOUD_PRESETS:   
                                       if (op)   
                                       {     if (bc->GetBool(USE_PRESET2)==TRUE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case ATMOSPHERIC_COLOR:   
                                       if (op)   
                                       {     if (bc->GetBool(ENABLE_ATMOSPHERE)==TRUE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case ATMOSPHERIC_BRIGHTNESS:   
                                       if (op)   
                                       {     if (bc->GetBool(ENABLE_ATMOSPHERE)==TRUE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case ATMOSPHERIC_GLOW:   
                                       if (op)   
                                       {     if (bc->GetBool(ENABLE_ATMOSPHERE)==TRUE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case RING_COLOR:   
                                       if (op)   
                                       {     if (bc->GetBool(HAS_RINGS)==TRUE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                                  case CREATE_PLANET:   
                                       if (op)   
                                       {     if (planetCreated == FALSE)   
                                       {    return TRUE;   
                                       }   
                                       else   
                                       {    return FALSE;   
                                       }   
                                       }   
                          
                             }   
                             return TRUE;   
                        }   
                          
                          
                          
                        Bool Planet::Message(GeListNode *node, LONG type, void *t_data)   
                        {        
                          
                             if (!node)     return FALSE;   
                          
                             if (type == MSG_DESCRIPTION_COMMAND)   
                          
                                  return CreatePlanet(static_cast<DescriptionCommand*>(t_data), static_cast<BaseObject*>(node));   
                          
                          
                              if (type == MSG_DESCRIPTION_CHECKUPDATE)   
                              {   
                                     
                                   return UpdatePlanet(static_cast<DescriptionCommand*>(t_data), static_cast<BaseObject*>(node));   
                              }   
                              
                              return TRUE;   
                          
                        }   
                          
                          
                        Bool Planet::CreatePlanet(DescriptionCommand* dc, BaseObject* op)   
                          
                        {   
                                
                            if (!dc)   
                                  return TRUE;   
                             if (!op)   
                                  return FALSE;   
                          
                          
                            LONG id =     dc->id[0].id;   
                          
                                  //declarations   
                                  surfaceTextTag = TextureTag::Alloc();   
                                  cloudsTextTag = TextureTag::Alloc();   
                                  atmTextTag = TextureTag::Alloc();   
                          
                                  atmosphere = BaseObject::Alloc(Osphere);   
                                  atmosphereMat = Material::Alloc();   
                          
                                  clouds = BaseObject::Alloc(Osphere);   
                                  cloudsMat = Material::Alloc();   
                          
                                  surface = BaseObject::Alloc(Osphere);   
                                  surfaceMat = Material::Alloc();   
                                     
                                  BaseDocument* doc = op->GetDocument();   
                                  doc->StartUndo();   
                                     
                                  if (!doc)   
                                       return FALSE;   
                          
                                  BaseObject* prnt = doc->GetActiveObject();   
                                     
                                  BaseTag* tp = BaseTag::Alloc(Tphong);   
                          
                             //If Create Planet button is pressed...   
                             if (id == CREATE_PLANET)   
                                
                            {   
                            /////////create the atmosphere sphere//////////////////////////////////////////////////////   
                                  atmosphere->SetName("Atmosphere");   
                                  atmosphereMat->SetName ("Atmosphere");   
                                  atmosphere->SetParameter(PRIM_SPHERE_RAD,200.8,NULL);   
                          
                          
                            /////////create and insert the clouds sphere///////////////////////////////////////////////   
                                  clouds->SetName("Clouds");   
                                  cloudsMat->SetName ("Clouds");   
                                  clouds->SetParameter(PRIM_SPHERE_RAD,200.4,NULL);   
                                  clouds->InsertTag(tp,0);//phong tag   
                                  clouds->InsertTag(cloudsTextTag,0);   
                                  cloudsTextTag->SetMaterial(cloudsMat);   
                                  doc->InsertMaterial(cloudsMat,NULL,TRUE);   
                                  
                                  if (clouds) doc->InsertObject(clouds, prnt, NULL, FALSE);   
                                  GePrint("Clouds Created");   
                          
                            /////////create and insert the surface sphere///////////////////////////////////////////////   
                                  surface->SetName("Surface");   
                                  surfaceMat->SetName ("Surface");   
                                  surface->SetParameter(PRIM_SPHERE_RAD,200,NULL);   
                                  surface->InsertTag(tp,0);//phong tag   
                                  surface->InsertTag(surfaceTextTag,0);   
                                  surfaceTextTag->SetMaterial(surfaceMat);   
                                  doc->InsertMaterial(surfaceMat,NULL,TRUE);   
                          
                                  if (surface) doc->InsertObject(surface, prnt, NULL, FALSE);   
                                  GePrint("Surface Created");   
                          
                                  //A planet was created   
                                  planetCreated = TRUE;   
                          
                                doc->EndUndo();   
                                
                            }   
                          
                                  return TRUE;   
                        }   
                          
                          
                        Bool Planet::UpdatePlanet(DescriptionCommand* dc, BaseObject* op)   
                          
                        {   
                                 if (!dc)   
                                       return TRUE;   
                                  if (!op)   
                                       return FALSE;   
                          
                                  BaseDocument* doc = op->GetDocument();   
                                  doc->StartUndo();   
                          
                                  if (!doc)   
                                       return FALSE;   
                          
                                  BaseObject* prnt = doc->GetActiveObject();   
                                     
                                  BaseTag* tp = BaseTag::Alloc(Tphong);   
                          
                             //Enable-Disable Atmosphere/////////////////////////////////////////////////////////   
                             if (op->GetDataInstance()->GetBool(ENABLE_ATMOSPHERE)==TRUE)   
                             {   
                                  atmosphere->InsertTag(tp,0); //phong tag   
                                  atmosphere->InsertTag(atmTextTag,0);   
                                  atmTextTag->SetMaterial(atmosphereMat);   
                                  doc->InsertMaterial(atmosphereMat,NULL,TRUE);   
                                
                                  if (atmosphere) doc->InsertObject(atmosphere, prnt, NULL, FALSE);   
                                  GePrint("Atmosphere Created");   
                                     
                                  atmosphereMat->SetChannelState(CHANNEL_TRANSPARENCY,TRUE);   
                                  atmosphereMat->SetChannelState(CHANNEL_GLOW,TRUE);   
                                  atmosphereMat->Update(TRUE,TRUE);   
                                  GePrint("Atmosphere Enabled");   
                             }   
                             else   
                             {   
                                  atmosphereMat->SetChannelState(CHANNEL_GLOW,FALSE);   
                                  GePrint("Atmosphere Disabled");   
                                  if (atmosphere) atmosphere->Remove();   
                                  if (atmosphereMat) atmosphereMat->Remove();   
                                  if (atmTextTag) atmTextTag->Remove();        
                             }   
                             /////////////////////////////////////////////////////////////////////////////////////   
                          
                                
                             atmosphereMat->SetParameter(MATERIAL_GLOW_OUTERSTRENGTH,op->GetDataInstance()->GetReal(ATMOSPHERIC_BRIGHTNESS),NULL);   
                          
                                  return TRUE;   
                        }   
                          
                          
                        Bool RegisterPlanet(void)   
                        {   
                             // decide by name if the plugin shall be registered - just for user convenience   
                             GePrint("-----------------------------------------------------------------------------------------");   
                             GePrint("Planet X Generator 1.0 - Copyright 2009 - Shawn Foster");   
                             GePrint("-----------------------------------------------------------------------------------------");   
                             String name=GeLoadString(IDS_PLANET_OBJECT); if (!name.Content()) return TRUE;   
                             return RegisterObjectPlugin(ID_PLANET_OBJECT,name,OBJECT_GENERATOR|OBJECT_INPUT,Planet::Alloc,"oplanet","Planet.tif",0);   
                        }   
                        

                        Thanks in advance....

                        ~Shawn

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

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

                          On 12/11/2009 at 09:23, xxxxxxxx wrote:

                          Does anyone see any problems that would cause C4D to crash in my code?

                          Thanks,

                          ~Shawn

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

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

                            On 12/11/2009 at 11:43, xxxxxxxx wrote:

                            I'd do it this way. Note the allocation checks, checks for existence, and the check for 'doc' before doc->StartUndo(). Also, not sure if this is your intention, but once you remove the objects from the document, if they are no longer necessary, you still need to free them - otherwise subsequent allocations into those pointers will leave unfreed/unreferenced objects in memory!

                            Unfortunately, this is one reason that I don't have a great love of C/C++ - the programmer takes control of all memory management as well as tracking pointer validation.

                            /////////////////////////////////////////////////////////////   
                            // Planet   
                              
                            #include "c4d.h"   
                            #include "c4d_symbols.h"   
                            #include "oplanet.h"   
                            #include "c4d_basetag.h"   
                            #include "c4d_basematerial.h"   
                              
                            // be sure to use a unique ID obtained from www.plugincafe.com   
                            #define ID_PLANET_OBJECT 1024532   
                              
                            class Planet : public ObjectData   
                            {   
                                 public:   
                                      virtual Bool Init(GeListNode *node);   
                                      virtual Bool GetDEnabling(GeListNode *node, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc);   
                                      virtual Bool Message(GeListNode *node, LONG type, void *t_data);   
                                      Bool CreatePlanet(DescriptionCommand* dc, BaseObject* op);   
                                      Bool UpdatePlanet(DescriptionCommand* dc, BaseObject* op);   
                                      static NodeData *Alloc(void) { return gNew Planet;}   
                              
                                      TextureTag* surfaceTextTag;   
                                      TextureTag* cloudsTextTag;   
                                      TextureTag* atmTextTag;   
                                      BaseObject* surface;   
                                      Material* surfaceMat;   
                                      BaseObject* clouds;   
                                      Material* cloudsMat;   
                                      BaseObject* atmosphere;   
                                      Material* atmosphereMat;   
                                      Bool planetCreated;   
                                      LONG test;   
                            };   
                              
                            // initialize settings   
                            Bool Planet::Init(GeListNode *node)   
                            {   
                                 //Called when a new instance of the node plugin has been allocated. You can use this function to for example fill the BaseContainer of the connected node with default values:   
                                 BaseContainer* bc = ((BaseObject* )node)->GetDataInstance();   
                                 if (!bc)     return false;   
                                 bc->SetBool(ENABLE_CRATERS, TRUE);   
                                 bc->SetBool(ENABLE_ATMOSPHERE, TRUE);   
                                 bc->SetBool(HAS_RINGS, FALSE);   
                                 planetCreated = FALSE;   
                                 test = 0;   
                                 return TRUE;   
                            }   
                            Bool Planet::GetDEnabling(GeListNode *node, const DescID &id;,GeData &t;_data,LONG flags,const BaseContainer *itemdesc)   
                            {        
                                 // Enable/disable our parameters   
                                 BaseContainer *bc=((BaseList2D* )node)->GetDataInstance();   
                                 BaseObject* op = static_cast<BaseTag*>(node)->GetObject();   
                                 if (!op)          return FALSE;   
                                 switch (id[0].id)   
                                 {   
                                      case SURFACE_PRESETS:   
                                           return bc->GetBool(USE_PRESET);   
                                      case CRATER_AMOUNT:   
                                           if (bc->GetBool(ENABLE_CRATERS)&&!bc->GetBool(USE_PRESET))     return TRUE;   
                                      case CRATER_SIZE:   
                                           if (bc->GetBool(ENABLE_CRATERS)&&!bc->GetBool(USE_PRESET))     return TRUE;   
                                      case SURFACE_MAP:   
                                           return !bc->GetBool(USE_PRESET);   
                                      case ELEVATION_MAP:   
                                           return !bc->GetBool(USE_PRESET);   
                                      case ELEVATION_STRENGTH:   
                                           return !bc->GetBool(USE_PRESET);   
                                      case ENABLE_CRATERS:   
                                           return !bc->GetBool(USE_PRESET);   
                                      case CLOUD_MAP:   
                                           return !bc->GetBool(USE_PRESET2);   
                                      case CLOUD_BRIGHTNESS:   
                                           return !bc->GetBool(USE_PRESET2);   
                                      case CLOUD_THICKNESS:   
                                           return !bc->GetBool(USE_PRESET2);   
                                      case CLOUD_PRESETS:   
                                           return bc->GetBool(USE_PRESET2);   
                                      case ATMOSPHERIC_COLOR:   
                                           return bc->GetBool(ENABLE_ATMOSPHERE);   
                                      case ATMOSPHERIC_BRIGHTNESS:   
                                           return bc->GetBool(ENABLE_ATMOSPHERE);   
                                      case ATMOSPHERIC_GLOW:   
                                           return bc->GetBool(ENABLE_ATMOSPHERE);   
                                      case RING_COLOR:   
                                           return bc->GetBool(HAS_RINGS);   
                                      case CREATE_PLANET:   
                                           return !planetCreated;   
                                 }   
                                 return TRUE;   
                            }   
                            Bool Planet::Message(GeListNode *node, LONG type, void *t_data)   
                            {        
                                 if (!node)     return FALSE;   
                                 if (type == MSG_DESCRIPTION_COMMAND)   
                                      return CreatePlanet(static_cast<DescriptionCommand*>(t_data), static_cast<BaseObject*>(node));   
                                 if (type == MSG_DESCRIPTION_CHECKUPDATE)   
                                      return UpdatePlanet(static_cast<DescriptionCommand*>(t_data), static_cast<BaseObject*>(node));   
                                 return TRUE;   
                            }   
                            Bool Planet::CreatePlanet(DescriptionCommand* dc, BaseObject* op)   
                            {   
                                 if (!dc)      return TRUE;   
                                 if (!op)      return FALSE;   
                                 LONG id =     dc->id[0].id;   
                              
                                 //declarations   
                                 surfaceTextTag = TextureTag::Alloc();   
                                 if (!surfaceTextTag)     return FALSE;   
                                 cloudsTextTag = TextureTag::Alloc();   
                                 if (!cloudsTextTag)     return FALSE;   
                                 atmTextTag = TextureTag::Alloc();   
                                 if (!atmTextTag)     return FALSE;   
                                 atmosphere = BaseObject::Alloc(Osphere);   
                                 if (!atmosphere)     return FALSE;   
                                 atmosphereMat = Material::Alloc();   
                                 if (!atmosphereMat)     return FALSE;   
                                 clouds = BaseObject::Alloc(Osphere);   
                                 if (!clouds)     return FALSE;   
                                 cloudsMat = Material::Alloc();   
                                 if (!cloudsMat)     return FALSE;   
                                 surface = BaseObject::Alloc(Osphere);   
                                 if (!surface)     return FALSE;   
                                 surfaceMat = Material::Alloc();   
                                 if (!surfaceMat)     return FALSE;   
                                 BaseDocument* doc = op->GetDocument();   
                                 if (!doc)     return FALSE;   
                                 doc->StartUndo();   
                              
                                 BaseObject* prnt = doc->GetActiveObject();   
                                 BaseTag* tp = BaseTag::Alloc(Tphong);   
                                 if (!tp)          return FALSE;   
                                 //If Create Planet button is pressed...   
                                 if (id == CREATE_PLANET)   
                                 {   
                                      /////////create the atmosphere sphere//////////////////////////////////////////////////////   
                                      atmosphere->SetName("Atmosphere");        
                                      atmosphereMat->SetName ("Atmosphere");   
                                      atmosphere->SetParameter(PRIM_SPHERE_RAD,200.8,NULL);   
                                      /////////create and insert the clouds sphere///////////////////////////////////////////////   
                                      clouds->SetName("Clouds");   
                                      cloudsMat->SetName ("Clouds");   
                                      clouds->SetParameter(PRIM_SPHERE_RAD,200.4,NULL);   
                                      clouds->InsertTag(tp,0);//phong tag   
                                      clouds->InsertTag(cloudsTextTag,0);   
                                      cloudsTextTag->SetMaterial(cloudsMat);   
                                      doc->InsertMaterial(cloudsMat,NULL,TRUE);   
                                      if (clouds) doc->InsertObject(clouds, prnt, NULL, FALSE);   
                                      GePrint("Clouds Created");   
                                      /////////create and insert the surface sphere///////////////////////////////////////////////   
                                      surface->SetName("Surface");   
                                      surfaceMat->SetName ("Surface");   
                                      surface->SetParameter(PRIM_SPHERE_RAD,200,NULL);   
                                      surface->InsertTag(tp,0);//phong tag   
                                      surface->InsertTag(surfaceTextTag,0);   
                                      surfaceTextTag->SetMaterial(surfaceMat);   
                                      doc->InsertMaterial(surfaceMat,NULL,TRUE);   
                                      if (surface) doc->InsertObject(surface, prnt, NULL, FALSE);   
                                      GePrint("Surface Created");   
                                      //A planet was created   
                                      planetCreated = TRUE;   
                                      doc->EndUndo();   
                                 }   
                                 return TRUE;   
                            }   
                            Bool Planet::UpdatePlanet(DescriptionCommand* dc, BaseObject* op)   
                            {   
                                 if (!dc) return TRUE;   
                                 if (!op) return FALSE;   
                                    
                                 BaseDocument* doc = op->GetDocument();   
                                 if (!doc)     return FALSE;   
                                 doc->StartUndo();   
                                 BaseObject* prnt = doc->GetActiveObject();   
                                 BaseTag* tp = BaseTag::Alloc(Tphong);   
                                 if (!tp)     return FALSE;   
                                 //Enable-Disable Atmosphere/////////////////////////////////////////////////////////   
                                 if (op->GetDataInstance()->GetBool(ENABLE_ATMOSPHERE)==TRUE)   
                                 {   
                                      if (atmTextTag)   
                                      {   
                                           if (atmosphere)     atmosphere->InsertTag(atmTextTag,0);   
                                           atmTextTag->SetMaterial(atmosphereMat);   
                                      }   
                                      if (atmosphereMat)   
                                      {   
                                           doc->InsertMaterial(atmosphereMat,NULL,TRUE);   
                                           atmosphereMat->SetChannelState(CHANNEL_TRANSPARENCY,TRUE);   
                                           atmosphereMat->SetChannelState(CHANNEL_GLOW,TRUE);   
                                           atmosphereMat->Update(TRUE,TRUE);   
                                      }   
                                      if (atmosphere)   
                                      {   
                                           atmosphere->InsertTag(tp,0); //phong tag   
                                           doc->InsertObject(atmosphere, prnt, NULL, FALSE);   
                                      }   
                                      GePrint("Atmosphere Created");   
                                      GePrint("Atmosphere Enabled");   
                                 }   
                                 else   
                                 {   
                                      if (atmosphere) atmosphere->Remove();   
                                      if (atmosphereMat)   
                                      {   
                                           atmosphereMat->SetChannelState(CHANNEL_GLOW,FALSE);   
                                           GePrint("Atmosphere Disabled");   
                                           atmosphereMat->Remove();   
                                      }   
                                      if (atmTextTag) atmTextTag->Remove();   
                                 }   
                                 /////////////////////////////////////////////////////////////////////////////////////   
                                 if (atmosphereMat)     atmosphereMat->SetParameter(MATERIAL_GLOW_OUTERSTRENGTH,op->GetDataInstance()->GetReal(ATMOSPHERIC_BRIGHTNESS),NULL);   
                                 return TRUE;   
                            }   
                            Bool RegisterPlanet(void)   
                            {   
                                  // decide by name if the plugin shall be registered - just for user convenience   
                                  GePrint("-----------------------------------------------------------------------------------------");   
                                  GePrint("Planet X Generator 1.0 - Copyright 2009 - Shawn Foster");   
                                  GePrint("-----------------------------------------------------------------------------------------");   
                                  String name=GeLoadString(IDS_PLANET_OBJECT); if (!name.Content()) return TRUE;   
                                  return RegisterObjectPlugin(ID_PLANET_OBJECT,name,OBJECT_GENERATOR|OBJECT_INPUT,Planet::Alloc,"oplanet","Planet.tif",0);   
                            }
                            
                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

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

                              On 12/11/2009 at 12:14, xxxxxxxx wrote:

                              I also notice that there is no doc->EndUndo() in UpdatePlanet() and no AddUndo()s either. Maybe you should comment out the doc->StartUndo() until it is needed.

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

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

                                On 12/11/2009 at 15:53, xxxxxxxx wrote:

                                Thanks Robert,,, I have decided that in the UpdatePlanet function I am going to use GetDown, GetNext, and GetFirstMaterial to reference the materials and objects in the scene.

                                I am running in to one problem though...

                                The GetFirstMaterial() function is derived from the BaseMaterial, but my materials are from the Material Class.. Is it possible to use GetFirstMaterial on materials from the Material class?

                                ~Shawn

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

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

                                  On 12/11/2009 at 16:14, xxxxxxxx wrote:

                                  You should be able to up-cast the BaseMaterial* returned by GetFirstMaterial() to Material* without any issues. Just use a C cast (Material* ) or a C++ one static_cast_<_material*_>_

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

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

                                    On 12/11/2009 at 19:38, xxxxxxxx wrote:

                                    Could you give me a code snippet of how that would look?

                                    Thanks,

                                    ~Shawn

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

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

                                      On 12/11/2009 at 19:54, xxxxxxxx wrote:

                                      // supposing that we're looking for the surfaceMat   
                                      for (BaseMaterial* mat = doc->GetFirstMaterial(); mat; mat = mat->GetNext())   
                                      {   
                                           if (mat->GetName() == "whatever")   
                                           {   
                                                surfaceMat = static_cast<Material*>(mat);   
                                                break;   
                                           }   
                                      }
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • H
                                        Helper
                                        last edited by

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

                                        On 13/11/2009 at 06:49, xxxxxxxx wrote:

                                        great thanks Robert...

                                        Now I need to change the fresnel settings of the color channel on a material.    so I am trying to use

                                        atmosphereMat->SetParameter(MATERIAL_COLOR_SHADER,?,NULL);

                                        But i am not sure what to put in the ? part....     or do I need to use a different constant other than MATERIAL_COLOR_SHADER?

                                        ~Shawn

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

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

                                          On 13/11/2009 at 15:48, xxxxxxxx wrote:

                                          I would expect that you should be able to get away with:

                                          atmosphereMat->SetParameter(MATERIAL_COLOR_SHADER,GeData(shader),NULL);

                                          where shader is a pointer to the shader being added to the SHADERLINK.

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

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

                                            On 13/11/2009 at 15:53, xxxxxxxx wrote:

                                            so would that shader be (Xfresnel) ?

                                            ~Shawn

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