<< Lightflow C API sample ball3 戻る Lightflow C API sample cloud >>

Lightflow C API sample lights

main4.cpp
#includeの両側に半角スペースが入っています。

#include < Lightflow/LfLocalSceneProxy.h >

int main()
{
LfLocalSceneProxy* s = new LfLocalSceneProxy();
LfArgList list;
LfTransform trs;

list.Reset();
list << "position" << LfPoint( 4.0, -6.0, -5.0 );
list << "color" << LfColor( 200.0, 200.0, 200.0 );
s->LightOn( s->NewLight( "point", list ) );

list.Reset();
list << "position" << LfPoint( -7.5, -6.0, 2.0 );
list << "color" << LfColor( 300.0, 150.0, 150.0 );
LfInt light1 = s->NewLight( "point", list );

list.Reset();
list << "position" << LfPoint( -2.0, 0.0, 8.0 );
list << "color" << LfColor( 150.0, 300.0, 150.0 );
LfInt light2 = s->NewLight( "point", list );

list.Reset();
list << "position" << LfPoint( 8.0, -6.0, 5.0 );
list << "color" << LfColor( 150.0, 150.0, 300.0 );
LfInt light3 = s->NewLight( "point", list );


s->LightBegin();
s->LightOn( light1 );

list.Reset();
list << "ka" << LfColor( 0.1, 0.1, 0.1 );
list << "kc" << LfColor( 1, 1, 1 );
list << "kd" << 0.5;
list << "km" << 0.1;
LfInt plastic1 = s->NewMaterial( "standard", list );

s->LightEnd();

s->LightBegin();
s->LightOn( light2 );

list.Reset();
list << "ka" << LfColor( 0.1, 0.1, 0.1 );
list << "kc" << LfColor( 1, 1, 1 );
list << "kd" << 0.5;
list << "km" << 0.1;
LfInt plastic2 = s->NewMaterial( "standard", list );

s->LightEnd();

s->LightBegin();
s->LightOn( light3 );

list.Reset();
list << "ka" << LfColor( 0.1, 0.1, 0.1 );
list << "kc" << LfColor( 1, 1, 1 );
list << "kd" << 0.5;
list << "km" << 0.1;
LfInt plastic3 = s->NewMaterial( "standard", list );

s->LightEnd();


s->TransformBegin( trs.Translation( LfVector3( -2.0, 0, 0 ) ) );

s->MaterialBegin( plastic1 );

list.Reset();
list << "radius" << 1.0;
s->AddObject( s->NewObject( "sphere", list ) );

s->MaterialEnd();

s->TransformEnd();


s->MaterialBegin( plastic2 );

list.Reset();
list << "radius" << 1.0;
s->AddObject( s->NewObject( "sphere", list ) );

s->MaterialEnd();


s->TransformBegin( trs.Translation( LfVector3( 2.0, 0, 0 ) ) );

s->MaterialBegin( plastic3 );

list.Reset();
list << "radius" << 1.0;
s->AddObject( s->NewObject( "sphere", list ) );

s->MaterialEnd();

s->TransformEnd();


list.Reset();
list << "file" << "lights.tga";
LfInt saver = s->NewImager( "tga-saver", list );

s->ImagerBegin( saver );

list.Reset();
list << "eye" << LfPoint( 0, -4, 0 );
list << "aim" << LfPoint( 0, 0, 0 );
list << "fov" << atan( 0.5 / 0.75 )*2.0;
LfInt camera = s->NewCamera( "pinhole", list );

s->ImagerEnd();

s->Render( camera, 300, 300 );

delete s;
}


$ /usr/local/gcc-2.95/bin/g++ -I ./include -lLightflow main4.cpp -o simplescene4
$ ./simplescene4
$ convert lights.tga lights.jpg
$ eog lights.jpg
lights.jpg
  • -
  • -

<< Lightflow C API sample ball3 戻る Lightflow C API sample cloud >>