goat3d
changeset 74:ab66cdabf6f2
loading scene files (no vis yet)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 06 May 2014 13:26:52 +0300 |
parents | 9862541fdcf5 |
children | 76dea247f75c |
files | exporters/maxgoat/resource.h goatview/goatview.vcxproj goatview/src/goatview.cc goatview/src/goatview.h src/goat3d.cc src/goat3d_impl.h src/goat3d_readxml.cc src/scene.cc |
diffstat | 8 files changed, 46 insertions(+), 10 deletions(-) [+] |
line diff
1.1 Binary file exporters/maxgoat/resource.h has changed
2.1 --- a/goatview/goatview.vcxproj Tue May 06 03:57:11 2014 +0300 2.2 +++ b/goatview/goatview.vcxproj Tue May 06 13:26:52 2014 +0300 2.3 @@ -102,7 +102,8 @@ 2.4 <Link> 2.5 <SubSystem>Console</SubSystem> 2.6 <GenerateDebugInformation>true</GenerateDebugInformation> 2.7 - <AdditionalDependencies>qtmaind.lib;Qt5Cored.lib;Qt5Widgetsd.lib;Qt5OpenGLd.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies> 2.8 + <AdditionalDependencies>goat3d-x64.lib;qtmaind.lib;Qt5Cored.lib;Qt5Widgetsd.lib;Qt5OpenGLd.lib;opengl32.lib;libvmath-x64-dbg.lib;libanim-x64-dbg.lib;pthreadVC2_x64.lib;%(AdditionalDependencies)</AdditionalDependencies> 2.9 + <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> 2.10 </Link> 2.11 <CustomBuildStep> 2.12 <Command> 2.13 @@ -153,7 +154,8 @@ 2.14 <GenerateDebugInformation>true</GenerateDebugInformation> 2.15 <EnableCOMDATFolding>true</EnableCOMDATFolding> 2.16 <OptimizeReferences>true</OptimizeReferences> 2.17 - <AdditionalDependencies>qtmain.lib;Qt5Widgets.lib;Qt5OpenGL.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies> 2.18 + <AdditionalDependencies>goat3d-x64.lib;qtmain.lib;Qt5Widgets.lib;Qt5OpenGL.lib;opengl32.lib;libvmath-x64.lib;libanim-x64.lib;pthreadVC2_x64.lib;%(AdditionalDependencies)</AdditionalDependencies> 2.19 + <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> 2.20 </Link> 2.21 </ItemDefinitionGroup> 2.22 <ItemGroup>
3.1 --- a/goatview/src/goatview.cc Tue May 06 03:57:11 2014 +0300 3.2 +++ b/goatview/src/goatview.cc Tue May 06 13:26:52 2014 +0300 3.3 @@ -1,4 +1,7 @@ 3.4 #include "goatview.h" 3.5 +#include "goat3d.h" 3.6 + 3.7 +goat3d *scene; 3.8 3.9 GoatView::GoatView() 3.10 { 3.11 @@ -77,7 +80,21 @@ 3.12 3.13 void GoatView::open_scene() 3.14 { 3.15 - statusBar()->showMessage("opening scene..."); 3.16 + std::string fname = QFileDialog::getOpenFileName(this, "Open scene file", "", 3.17 + "Goat3D Scene (*.goatsce);;All Files (*)").toStdString(); 3.18 + if(fname.empty()) { 3.19 + statusBar()->showMessage("Abort: No file selected!"); 3.20 + return; 3.21 + } 3.22 + 3.23 + if(scene) { 3.24 + goat3d_free(scene); 3.25 + } 3.26 + 3.27 + statusBar()->showMessage("opening scene file"); 3.28 + if(!(scene = goat3d_create()) || goat3d_load(scene, fname.c_str()) == -1) { 3.29 + statusBar()->showMessage("failed to load scene file"); 3.30 + } 3.31 } 3.32 3.33 void GoatView::open_anim()
4.1 --- a/goatview/src/goatview.h Tue May 06 03:57:11 2014 +0300 4.2 +++ b/goatview/src/goatview.h Tue May 06 13:26:52 2014 +0300 4.3 @@ -3,6 +3,9 @@ 4.4 4.5 #include <QtWidgets/QtWidgets> 4.6 #include <QtOpenGL/QGLWidget> 4.7 +#include "goat3d.h" 4.8 + 4.9 +extern goat3d *scene; 4.10 4.11 class GoatView : public QMainWindow { 4.12 Q_OBJECT
5.1 --- a/src/goat3d.cc Tue May 06 03:57:11 2014 +0300 5.2 +++ b/src/goat3d.cc Tue May 06 13:26:52 2014 +0300 5.3 @@ -31,12 +31,6 @@ 5.4 5.5 using namespace g3dimpl; 5.6 5.7 -struct goat3d { 5.8 - Scene *scn; 5.9 - unsigned int flags; 5.10 - char *search_path; 5.11 -}; 5.12 - 5.13 struct goat3d_material : public Material {}; 5.14 struct goat3d_mesh : public Mesh {}; 5.15 struct goat3d_light : public Light {}; 5.16 @@ -56,6 +50,7 @@ 5.17 goat->flags = 0; 5.18 goat->search_path = 0; 5.19 goat->scn = new Scene; 5.20 + goat->scn->goat = goat; 5.21 5.22 goat3d_setopt(goat, GOAT3D_OPT_SAVEXML, 1); 5.23 return goat;
6.1 --- a/src/goat3d_impl.h Tue May 06 03:57:11 2014 +0300 6.2 +++ b/src/goat3d_impl.h Tue May 06 13:26:52 2014 +0300 6.3 @@ -28,6 +28,17 @@ 6.4 #include "node.h" 6.5 6.6 namespace g3dimpl { 6.7 +class Scene; 6.8 +} 6.9 + 6.10 +struct goat3d { 6.11 + g3dimpl::Scene *scn; 6.12 + unsigned int flags; 6.13 + char *search_path; 6.14 +}; 6.15 + 6.16 + 6.17 +namespace g3dimpl { 6.18 6.19 extern int goat_log_level; 6.20 6.21 @@ -55,6 +66,8 @@ 6.22 std::vector<Node*> nodes; 6.23 6.24 public: 6.25 + goat3d *goat; 6.26 + 6.27 Scene(); 6.28 ~Scene(); 6.29
7.1 --- a/src/goat3d_readxml.cc Tue May 06 03:57:11 2014 +0300 7.2 +++ b/src/goat3d_readxml.cc Tue May 06 13:26:52 2014 +0300 7.3 @@ -211,7 +211,12 @@ 7.4 if((elem = xml_mesh->FirstChildElement("file"))) { 7.5 const char *fname = elem->Attribute("string"); 7.6 if(fname) { 7.7 - if(!mesh->load(fname)) { 7.8 + char *path = (char*)fname; 7.9 + if(scn->goat->search_path) { 7.10 + path = (char*)alloca(strlen(fname) + strlen(scn->goat->search_path) + 2); 7.11 + sprintf(path, "%s/%s", scn->goat->search_path, fname); 7.12 + } 7.13 + if(!mesh->load(path)) { 7.14 delete mesh; 7.15 return 0; 7.16 }