class App_Extrusion: public BaseDemo
{
public:
App_Extrusion(): mTest(0) {}
void showSimplePipe()
{
const int sides = 24;
const float radius = 1.0f;
for(int i=0; i<sides; ++i)
{
float t = (float)i/sides*
vl::fPi*2.0f;
}
sceneManager()->tree()->addActor( geom.
get(), effect.
get(),
NULL );
}
void showFancyArch()
{
const int sides = 4;
const float radius = 1.0f;
for(int i=0; i<sides; ++i)
{
float t = (float)i/sides*
vl::fPi*2.0f;
}
for(int j=0; j<640; ++j)
{
float t = (float)j/(640-1)*
vl::fPi;
}
{
}
{
}
sceneManager()->tree()->addActor( geom.
get(), effect.
get(),
NULL );
}
void showVortex()
{
const int lati = 128;
for(int i=0; i<lati; ++i)
{
float t = (float)i/lati*
vl::fPi*2.0f+3.14159365f/2.0f;
extrusion.
silhouette().back() *= 2.0f + fabs(
sin(t*8.0f)*2.0f-1.0f)*0.1f;
}
float freq = 5.0f;
float width = 10.0f;
const int size = 250;
for(int i=0; i<size; ++i)
{
float t = (float)i/(size-1);
s = 5.0f*s + 0.5f*(1.0f-s);
}
for(int i=0; i<size-2; ++i)
{
float t = (float)i/(size-2-1);
vl::fvec4 c = vl::yellow*t + vl::blue*(1.0f-t);
}
{
}
sceneManager()->tree()->addActor( extr.
get(), effect.
get(),
NULL );
}
void showNail()
{
float diam = 1.0f;
int segments = 500;
for(int i=0; i<segments; ++i)
{
float t = (float)i/(segments-1);
}
for(int i=0; i<segments-2; ++i)
{
float t = (float)i/(segments-2-1);
vl::fvec4 c = vl::gold * t + vl::royalblue*(1.0f-t);
}
for(int i=0; i<segments-2; ++i)
{
float t = (float)i/(segments-2-1);
}
for(int i=0; i<segments-2; ++i)
{
float t = (float)i/(segments-2-1);
}
sceneManager()->tree()->addActor( geom.
get(), effect.
get(),
NULL );
}
void showPath(
const std::vector<vl::fvec3>& ctrl_points,
const vl::fvec4& color)
{
sceneManager()->tree()->addActor( geom.
get(), effect.
get(),
NULL );
}
void keyPressEvent(
unsigned short ch,
vl::EKey key)
{
BaseDemo::keyPressEvent(ch,key);
{
mTest--;
mTest++;
if (mTest < 0) mTest = 3;
if (mTest > 3) mTest = 0;
sceneManager()->tree()->actors()->clear();
switch(mTest)
{
case 0: showSimplePipe(); break;
case 1: showFancyArch(); break;
case 2: showVortex(); break;
case 3: showNail(); break;
}
showText();
}
}
void showText()
{
text->
setText(
"Press the left/right arrow keys to change test.");
sceneManager()->tree()->addActor(text.
get(), effect.
get());
}
void initEvent()
{
showSimplePipe();
showText();
}
protected:
int mTest;
};