Versions Compared

Key

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

...

Code Block
languagecpp
linenumberstrue
CextensionManager* extensionManager = CextensionManager::instance();
CgeometryProceduralExtension* geomProcExtension = extensionManager->createGeometryProceduralExtension( "MaxwellParticles" );
//Get the extension container. When using this method of getting the container,
//nearly all parameters have default values, and there is no need to explicitly set them.
MXparamList* particlesParams = geomProcExtension->getExtensionData();

//Fill the required data
char* filename = "/home/rocco/Emitter01_00023.bin";
particlesParams->setString( "FileName", filename );

//Enable loading particle vorticity data
byte load = 1;
particlesParams->setByte( "Load particle Vorticity", load );

//These two numbers can be obtained parsing the particles file or all the particles sequence
//They're needed to map the values of vorticities from 0.0 to 1.0 to access the texture.
float minV = 0.0;
float maxV = 23.67;
particlesParams->setFloat( "Min Vorticity", minV );
particlesParams->setFloat( "Max Vorticity", maxV );

//Add the procedural object to the scene
Cmaxwell::Cobject obj = scene->createGeometryProceduralObject( "My Particles", particlesParams );

//Let´s add a uv channel...
dword uvIndex; //returned uv channel index. Use this index in the texture map properties to access its uvs
byte isOk = obj.addChannelUVW( uvIndex ); // uvIndex will be set to the actual uv channel number of the object.
//...and set it to a custom UV generator, 17, in this case, vorticity modulus
obj.generateCustomUVW( uvIndex, 17 );

//Now assign a material and set the first BSDF reflectance0º color a texture driven by uv channel 'uvIndex'
//This uv channel, since it is a one-scalar valued channel, stores its value in the U coordinate.

...