Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
firstline1
linenumberstrue
class CubeExampleExtension : public CgeometryLoaderExtension
{
  
 // Macro for burocracy, parameters: extension name, main class in the extension, and the version number
 DECLARE_EXTENSION_METHODS( "CubeExample", CubeExampleExtension, 1 )
public:
 //declare internal variables for calculation, it must include at least variables for storing extensionData values 
 double cubeSize;
 
 CubeExampleExtension()
 {
   // create here the editable values of the extensions, they can be modified when used, 
   // getExtensionData returns the internal MxParamList to create new fields
   // check MxParamList for all possibilities of types creation

    //create parameter with name, default value, minimum value and maximum value
    getExtensionData()->createDouble( "Cube size", 1.0, 0, 1000 );
 }
 
 ~CubeExampleExtension() 
 {
  //not needed to implement since we don't reserve memory. 
 }
 
 bool initialize()
 {
   //We must at least copy the extensionData values to internal variables, this will be called usually just one time,
   //before maxwell needs it, and never during render time. All the heavy work must be done here.
   getExtensionData()->getDouble( "Cube size", cubeSize );//Get the parameter value and store it before using it
   return true;
 }
 
 bool loadMesh( Cmaxwell::Cobject &cube )
 {
   ...
   // CgeometryLoaderExtension method, will be explained in the corresponding chapter 
  ...
 } 
 
 bool getBoundingBox( Cvector &bmin, Cvector& bmax)
 { 
   ...
   // CgeometryLoaderExtension method, will be explained in the corresponding chapter 
   ... 
 }
}