1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

OP-150 GCS/ModelView: Create a fallback default setting on the ModelView plugin

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1987 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
muralha 2010-10-18 00:08:31 +00:00 committed by muralha
parent 253d831fc9
commit 28c3dcf771
7 changed files with 21530 additions and 28 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,48 @@
# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
# File Created: 14.10.2010 00:38:26
newmtl red
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 1.0000 0.0000 0.0000
Kd 1.0000 0.0000 0.0000
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
newmtl white
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 1.0000 1.0000 1.0000
Kd 1.0000 1.0000 1.0000
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
newmtl black
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.0000 0.0000 0.0000
Kd 0.0000 0.0000 0.0000
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
newmtl wire_000000000
Ns 32
d 1
Tr 0
Tf 1 1 1
illum 2
Ka 0.0000 0.0000 0.0000
Kd 0.0000 0.0000 0.0000
Ks 0.3500 0.3500 0.3500

File diff suppressed because it is too large Load Diff

View File

@ -19,3 +19,6 @@ SOURCES += modelviewplugin.cpp \
modelviewgadgetoptionspage.cpp modelviewgadgetoptionspage.cpp
OTHER_FILES += ModelViewGadget.pluginspec OTHER_FILES += ModelViewGadget.pluginspec
FORMS += modelviewoptionspage.ui FORMS += modelviewoptionspage.ui
RESOURCES += \
modelview.qrc

View File

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/modelview">
<file>models/black.jpg</file>
<file>models/warning_sign.mtl</file>
<file>models/warning_sign.obj</file>
</qresource>
</RCC>

View File

@ -48,11 +48,12 @@ ModelViewGadgetWidget::ModelViewGadgetWidget(QWidget *parent)
CreateScene(); CreateScene();
m_Light.setPosition(4000.0, 40000.0, 80000.0); m_Light.setPosition(4000.0, -40000.0, 80000.0);
m_Light.setAmbientColor(Qt::lightGray); m_Light.setAmbientColor(Qt::lightGray);
m_GlView.cameraHandle()->setDefaultUpVector(glc::Z_AXIS); m_GlView.cameraHandle()->setDefaultUpVector(glc::Z_AXIS);
m_GlView.cameraHandle()->setFrontView(); m_GlView.cameraHandle()->setFrontView();
m_GlView.setToOrtho(true); // orthogonal view
QColor repColor; QColor repColor;
repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0); repColor.setRgbF(1.0, 0.11372, 0.11372, 0.0);
@ -141,13 +142,17 @@ void ModelViewGadgetWidget::resizeGL(int width, int height)
// Create GLC_Object to display // Create GLC_Object to display
void ModelViewGadgetWidget::CreateScene() void ModelViewGadgetWidget::CreateScene()
{ {
// put a black background if the 3D model is invalid or if the background image is also invalid
if (acFilename == ":/modelview/models/warning_sign.obj" or !QFile::exists(bgFilename))
bgFilename= ":/modelview/models/black.jpg";
try try
{ {
m_GlView.loadBackGroundImage(bgFilename); m_GlView.loadBackGroundImage(bgFilename);
} }
catch(GLC_Exception e) catch(GLC_Exception e)
{ {
qDebug("ModelView background image file loading failed."); qDebug("ModelView: background image file loading failed.");
} }
try try
@ -157,7 +162,7 @@ void ModelViewGadgetWidget::CreateScene()
QFile aircraft(acFilename); QFile aircraft(acFilename);
m_World= GLC_Factory::instance()->createWorldFromFile(aircraft); m_World= GLC_Factory::instance()->createWorldFromFile(aircraft);
m_ModelBoundingBox= m_World.boundingBox(); m_ModelBoundingBox= m_World.boundingBox();
m_GlView.reframe(m_ModelBoundingBox); // center 3d models in the scene m_GlView.reframe(m_ModelBoundingBox); // center 3D model in the scene
m_GlView.setDistMinAndMax(m_World.boundingBox()); m_GlView.setDistMinAndMax(m_World.boundingBox());
loadError = false; loadError = false;
if (!mvInitGLSuccess) if (!mvInitGLSuccess)
@ -168,7 +173,7 @@ void ModelViewGadgetWidget::CreateScene()
} }
catch(GLC_Exception e) catch(GLC_Exception e)
{ {
qDebug("ModelView aircraft texture file loading failed."); qDebug("ModelView: aircraft file loading failed.");
loadError = true; loadError = true;
} }
} }

View File

@ -50,8 +50,23 @@ class ModelViewGadgetWidget : public QGLWidget
public: public:
ModelViewGadgetWidget(QWidget *parent = 0); ModelViewGadgetWidget(QWidget *parent = 0);
~ModelViewGadgetWidget(); ~ModelViewGadgetWidget();
void setAcFilename(QString acf) { acFilename = acf; } void setAcFilename(QString acf)
void setBgFilename(QString bgf) { bgFilename = bgf; } {
if(QFile::exists(acf))
acFilename = acf;
else
{
acFilename= acf= ":/modelview/models/warning_sign.obj";
m_GlView.cameraHandle()->setFrontView(); // set to front camera to see/read the warning sign
}
}
void setBgFilename(QString bgf)
{
if (QFile::exists(bgFilename))
bgFilename = bgf;
else
bgFilename= ":/modelview/models/black.jpg"; // will put a black background if there's no background
}
void setVboEnable(bool eVbo) { vboEnable = eVbo; } void setVboEnable(bool eVbo) { vboEnable = eVbo; }
void reloadScene(); void reloadScene();
void updateAttitude(int value); void updateAttitude(int value);