Versions Compared

Key

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

...

Code Block
languagecpp
themeMidnight
/**
	Polygonal meshes can be created minimally by specifying "P".
    NSI's C++ API provides an easy interface to pass parameters to all NSI
	API calls through the Args class.
*/
NSI::Context nsi;
nsi.Create( "simply polygon", "mesh" );

NSI::ArgumentList mesh_args;
float points[3*4] = { ... /* insert your favorite 4 points here */}; 
mesh_args.Add(
	NSI::Argument::New( "P" )
        ->SetType( NSITypePoint )
        ->SetCount( 4 )
        ->SetValuePointer( const_cast<float*>(points) );
nsi.SetAttribute( "simple polgyon", mesh_args );

...

Code Block
languagecpp
themeFadeToGrey
nsi.Create( "translation", "transform" );
nsi.Connect( "translation", NSI_SCENE_ROOT );
nsi.Connect( "simple polygon", "", "translation", "objects" );

double trs[16] =
{
	1., 0., 0., 0.,
	0., 1., 0., 0.,
	0., 0., 1., 0.,
	0., 1., 0., 1. /* transalte 1 unit in Y */
};

nsi.SetAttribute( "translation",
	NSI::DoubleMatrixArg("transformationmatrix", trs) );

Instacing is as simple as connecting geometry to different attributes (yes, instances of instances  supported).

Assigning Shaders

Shaders are created as any other nodes using the NSICreate API call. They are not assigned directly on geometry but through an intermediate attributes nodes. Having an extra indirection allows for more flexible export as we will see in the following chapters.

...