Added support for adding basic primitives cube, sphere, cylinder, teapot.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent a2ccb7e796
commit 04dcad32e7

@ -177,6 +177,62 @@ namespace MaterialEditor
viewPort->init();
}
void MaterialEditorWindow::onAddCubeClicked()
{
if( !nl3dIface->addCube() )
{
QMessageBox::critical(
this,
tr( "Error adding primitive" ),
tr( "There was an error while adding this primitive" )
);
return;
}
viewPort->startTimedUpdates( 20 );
}
void MaterialEditorWindow::onAddSphereClicked()
{
if( !nl3dIface->addSphere() )
{
QMessageBox::critical(
this,
tr( "Error adding primitive" ),
tr( "There was an error while adding this primitive" )
);
return;
}
viewPort->startTimedUpdates( 20 );
}
void MaterialEditorWindow::onAddCylinderClicked()
{
if( !nl3dIface->addCylinder() )
{
QMessageBox::critical(
this,
tr( "Error adding primitive" ),
tr( "There was an error while adding this primitive" )
);
return;
}
viewPort->startTimedUpdates( 20 );
}
void MaterialEditorWindow::onAddTeaPotClicked()
{
if( !nl3dIface->addTeaPot() )
{
QMessageBox::critical(
this,
tr( "Error adding primitive" ),
tr( "There was an error while adding this primitive" )
);
return;
}
viewPort->startTimedUpdates( 20 );
}
void MaterialEditorWindow::onClearSceneClicked()
{
nl3dIface->clearScene();
@ -210,6 +266,21 @@ namespace MaterialEditor
mm = m->addMenu( tr( "Scene" ) );
{
QMenu *mmm = mm->addMenu( tr( "Add primitive" ) );
a = new QAction( tr( "Cube" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddCubeClicked() ) );
mmm->addAction( a );
a = new QAction( tr( "Sphere" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddSphereClicked() ) );
mmm->addAction( a );
a = new QAction( tr( "Cylinder" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddCylinderClicked() ) );
mmm->addAction( a );
a = new QAction( tr( "Tea pot" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddTeaPotClicked() ) );
mmm->addAction( a );
a = new QAction( tr( "Clear scene" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onClearSceneClicked() ) );
mm->addAction( a );

@ -44,6 +44,12 @@ private Q_SLOTS:
void onShadersClicked();
void onPassesClicked();
void onStartup();
void onAddCubeClicked();
void onAddSphereClicked();
void onAddCylinderClicked();
void onAddTeaPotClicked();
void onClearSceneClicked();
private:

@ -372,6 +372,26 @@ namespace MaterialEditor
}
}
bool CNel3DInterface::addCube()
{
return loadShape( "primitives/cube.shape" );
}
bool CNel3DInterface::addSphere()
{
return loadShape( "primitives/sphere.shape" );
}
bool CNel3DInterface::addCylinder()
{
return loadShape( "primitives/cylinder.shape" );
}
bool CNel3DInterface::addTeaPot()
{
return loadShape( "primitives/teapot.shape" );
}
bool CNel3DInterface::loadShape( const std::string &fileName )
{
NLMISC::CPath::addSearchPath( NLMISC::CFile::getPath( fileName ), false, false );

@ -149,6 +149,11 @@ namespace MaterialEditor
void resizeViewPort( unsigned long w, unsigned long h );
NL3D::UDriver* getDriver(){ return driver; }
bool addCube();
bool addSphere();
bool addCylinder();
bool addTeaPot();
bool loadShape( const std::string &fileName );
void clearScene();
void updateInput();

Loading…
Cancel
Save