goat3d

changeset 72:36e39632db75

- fixed exporter animation bounds calculation - fixed missing scene name in exported meshes - rewritting goatview as a full GUI app with Qt
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 May 2014 03:31:35 +0300
parents 39d8457e43df
children 9862541fdcf5
files exporters/maxgoat/src/maxgoat.cc goat3d-vs2012.sln goatview/goatview.vcxproj goatview/goatview.vcxproj.filters goatview/src/goatview.cc goatview/src/goatview.h goatview/src/main.c goatview/src/main.cc src/goat3d.cc
diffstat 9 files changed, 485 insertions(+), 244 deletions(-) [+]
line diff
     1.1 --- a/exporters/maxgoat/src/maxgoat.cc	Mon Apr 21 03:44:42 2014 +0300
     1.2 +++ b/exporters/maxgoat/src/maxgoat.cc	Tue May 06 03:31:35 2014 +0300
     1.3 @@ -107,6 +107,10 @@
     1.4  	for(int i=0; fname[i]; i++) {
     1.5  		fname[i] = tolower(fname[i]);
     1.6  	}
     1.7 +	char *basename = (char*)alloca(strlen(fname) + 1);
     1.8 +	strcpy(basename, fname);
     1.9 +	char *suffix = strrchr(basename, '.');
    1.10 +	if(suffix) *suffix = 0;
    1.11  
    1.12  	maxlog("Exporting Goat3D Scene (text) file: %s\n", fname);
    1.13  	if(!(igame = GetIGameInterface())) {
    1.14 @@ -118,6 +122,7 @@
    1.15  	igame->InitialiseIGame();
    1.16  
    1.17  	goat3d *goat = goat3d_create();
    1.18 +	goat3d_set_name(goat, basename);
    1.19  
    1.20  	process_materials(goat);
    1.21  
    1.22 @@ -288,8 +293,6 @@
    1.23  	}
    1.24  
    1.25  	// grab the animation data
    1.26 -	IGameControl *ctrl = maxnode->GetIGameControl();
    1.27 -
    1.28  	if(!dynamic_cast<GoatAnimExporter*>(this)) {
    1.29  		// no animation, just get the static PRS
    1.30  		GMatrix maxmatrix = maxnode->GetObjectTM();
    1.31 @@ -304,16 +307,21 @@
    1.32  	} else {
    1.33  		// exporting animations (if available)
    1.34  		// TODO sample keys if requested
    1.35 -		if(ctrl->IsAnimated(IGAME_POS) || ctrl->IsAnimated(IGAME_POS_X) ||
    1.36 -				ctrl->IsAnimated(IGAME_POS_Y) || ctrl->IsAnimated(IGAME_POS_Z)) {
    1.37 -			get_position_keys(ctrl, node);
    1.38 -		}
    1.39 -		if(ctrl->IsAnimated(IGAME_ROT) || ctrl->IsAnimated(IGAME_EULER_X) ||
    1.40 -				ctrl->IsAnimated(IGAME_EULER_Y) || ctrl->IsAnimated(IGAME_EULER_Z)) {
    1.41 -			get_rotation_keys(ctrl, node);
    1.42 -		}
    1.43 -		if(ctrl->IsAnimated(IGAME_SCALE)) {
    1.44 -			get_scaling_keys(ctrl, node);
    1.45 +		IGameControl *ctrl = maxnode->GetIGameControl();
    1.46 +		if(ctrl) {
    1.47 +			if(ctrl->IsAnimated(IGAME_POS) || ctrl->IsAnimated(IGAME_POS_X) ||
    1.48 +					ctrl->IsAnimated(IGAME_POS_Y) || ctrl->IsAnimated(IGAME_POS_Z)) {
    1.49 +				get_position_keys(ctrl, node);
    1.50 +			}
    1.51 +			if(ctrl->IsAnimated(IGAME_ROT) || ctrl->IsAnimated(IGAME_EULER_X) ||
    1.52 +					ctrl->IsAnimated(IGAME_EULER_Y) || ctrl->IsAnimated(IGAME_EULER_Z)) {
    1.53 +				get_rotation_keys(ctrl, node);
    1.54 +			}
    1.55 +			if(ctrl->IsAnimated(IGAME_SCALE)) {
    1.56 +				get_scaling_keys(ctrl, node);
    1.57 +			}
    1.58 +		} else {
    1.59 +			maxlog("%s: failed to get IGameControl for node: %s\n", __FUNCTION__, name);
    1.60  		}
    1.61  	}
    1.62  
    1.63 @@ -496,13 +504,13 @@
    1.64  	}
    1.65  }
    1.66  
    1.67 -#if 0
    1.68  static bool get_anim_bounds(IGameNode *node, long *tstart, long *tend);
    1.69 +static bool get_node_anim_bounds(IGameNode *node, long *tstart, long *tend);
    1.70  
    1.71  static bool get_anim_bounds(IGameScene *igame, long *tstart, long *tend)
    1.72  {
    1.73 -	int tmin = LONG_MAX;
    1.74 -	int tmax = LONG_MIN;
    1.75 +	long tmin = LONG_MAX;
    1.76 +	long tmax = LONG_MIN;
    1.77  
    1.78  	int num_nodes = igame->GetTopLevelNodeCount();
    1.79  	for(int i=0; i<num_nodes; i++) {
    1.80 @@ -523,8 +531,10 @@
    1.81  
    1.82  static bool get_anim_bounds(IGameNode *node, long *tstart, long *tend)
    1.83  {
    1.84 -	int tmin = LONG_MAX;
    1.85 -	int tmax = LONG_MIN;
    1.86 +	long tmin = LONG_MAX;
    1.87 +	long tmax = LONG_MIN;
    1.88 +
    1.89 +	get_node_anim_bounds(node, &tmin, &tmax);
    1.90  
    1.91  	int num_children = node->GetChildCount();
    1.92  	for(int i=0; i<num_children; i++) {
    1.93 @@ -542,7 +552,56 @@
    1.94  	}
    1.95  	return false;
    1.96  }
    1.97 -#endif
    1.98 +
    1.99 +static bool get_node_anim_bounds(IGameNode *node, long *tstart, long *tend)
   1.100 +{
   1.101 +	static const IGameControlType ctypes[] = {
   1.102 +		IGAME_POS, IGAME_POS_X, IGAME_POS_Y, IGAME_POS_Z,
   1.103 +		IGAME_ROT, IGAME_EULER_X, IGAME_EULER_Y, IGAME_EULER_Z,
   1.104 +		IGAME_SCALE
   1.105 +	};
   1.106 +
   1.107 +	// NOTE: apparently if I don't call GetIGameObject, then GetIGameControl always returns null...
   1.108 +	node->GetIGameObject();
   1.109 +	IGameControl *ctrl = node->GetIGameControl();
   1.110 +	if(!ctrl) {
   1.111 +		maxlog("%s: failed to get IGameControl for node: %s\n", __FUNCTION__, max_string(node->GetName()));
   1.112 +		return false;
   1.113 +	}
   1.114 +
   1.115 +	IGameKeyTab keys;
   1.116 +	long t0, t1;
   1.117 +	long tmin = LONG_MAX;
   1.118 +	long tmax = LONG_MIN;
   1.119 +
   1.120 +	for(int i=0; i<sizeof ctypes / sizeof *ctypes; i++) {
   1.121 +		if(ctrl->GetBezierKeys(keys, ctypes[i]) && keys.Count()) {
   1.122 +			t0 = KEY_TIME(keys[0]);
   1.123 +			t1 = KEY_TIME(keys[keys.Count() - 1]);
   1.124 +			if(t0 < tmin) tmin = t0;
   1.125 +			if(t1 > tmax) tmax = t1;
   1.126 +		}
   1.127 +		if(ctrl->GetLinearKeys(keys, ctypes[i]) && keys.Count()) {
   1.128 +			t0 = KEY_TIME(keys[0]);
   1.129 +			t1 = KEY_TIME(keys[keys.Count() - 1]);
   1.130 +			if(t0 < tmin) tmin = t0;
   1.131 +			if(t1 > tmax) tmax = t1;
   1.132 +		}
   1.133 +		if(ctrl->GetTCBKeys(keys, ctypes[i]) && keys.Count()) {
   1.134 +			t0 = KEY_TIME(keys[0]);
   1.135 +			t1 = KEY_TIME(keys[keys.Count() - 1]);
   1.136 +			if(t0 < tmin) tmin = t0;
   1.137 +			if(t1 > tmax) tmax = t1;
   1.138 +		}
   1.139 +	}
   1.140 +
   1.141 +	if(tmin != LONG_MAX) {
   1.142 +		*tstart = tmin;
   1.143 +		*tend = tmax;
   1.144 +		return true;
   1.145 +	}
   1.146 +	return false;
   1.147 +}
   1.148  
   1.149  void GoatExporter::process_mesh(goat3d *goat, goat3d_mesh *mesh, IGameObject *maxobj)
   1.150  {
   1.151 @@ -648,6 +707,7 @@
   1.152  
   1.153  
   1.154  // ---- GoatAnimExporter implementation ----
   1.155 +static long tstart, tend;
   1.156  
   1.157  int GoatAnimExporter::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent, DWORD opt)
   1.158  {
   1.159 @@ -658,9 +718,10 @@
   1.160  	IGameConversionManager *cm = GetConversionManager();
   1.161  	cm->SetCoordSystem(IGameConversionManager::IGAME_OGL);
   1.162  	igame->InitialiseIGame();
   1.163 +	igame->SetStaticFrame(0);
   1.164  
   1.165 -	//long tstart = 0, tend = 0;
   1.166 -	//get_anim_bounds(igame, &tstart, &tend);
   1.167 +	tstart = tend = 0;
   1.168 +	get_anim_bounds(igame, &tstart, &tend);
   1.169  
   1.170  	if(!DialogBox(hinst, MAKEINTRESOURCE(IDD_GOAT_ANM), 0, anim_gui_handler)) {
   1.171  		igame->ReleaseIGame();
   1.172 @@ -674,7 +735,6 @@
   1.173  	}
   1.174  
   1.175  	maxlog("Exporting Goat3D Animation (text) file: %s\n", fname);
   1.176 -	igame->SetStaticFrame(0);
   1.177  
   1.178  	goat3d *goat = goat3d_create();
   1.179  
   1.180 @@ -699,8 +759,15 @@
   1.181  {
   1.182  	switch(msg) {
   1.183  	case WM_INITDIALOG:
   1.184 -		CheckDlgButton(win, IDC_GOAT_ANM_FULL, 1);
   1.185 -		CheckDlgButton(win, IDC_RAD_KEYS_ORIG, 1);
   1.186 +		{
   1.187 +			wchar_t buf[128];
   1.188 +			CheckDlgButton(win, IDC_GOAT_ANM_FULL, BST_CHECKED);
   1.189 +			CheckDlgButton(win, IDC_RAD_KEYS_ORIG, BST_CHECKED);
   1.190 +			wsprintf(buf, L"%ld", tstart);
   1.191 +			SetDlgItemText(win, IDC_EDIT_TSTART, buf);
   1.192 +			wsprintf(buf, L"%ld", tend);
   1.193 +			SetDlgItemText(win, IDC_EDIT_TEND, buf);
   1.194 +		}
   1.195  		break;
   1.196  
   1.197  	case WM_COMMAND:
     2.1 --- a/goat3d-vs2012.sln	Mon Apr 21 03:44:42 2014 +0300
     2.2 +++ b/goat3d-vs2012.sln	Tue May 06 03:31:35 2014 +0300
     2.3 @@ -10,6 +10,8 @@
     2.4  EndProject
     2.5  Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "maxgoat_stub", "exporters\maxgoat_stub\maxgoat_stub.vcxproj", "{941007A1-6375-4507-8745-FC3EA9DF010B}"
     2.6  EndProject
     2.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "goatview", "goatview\goatview.vcxproj", "{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}"
     2.8 +EndProject
     2.9  Global
    2.10  	GlobalSection(SolutionConfigurationPlatforms) = preSolution
    2.11  		Debug|Mixed Platforms = Debug|Mixed Platforms
    2.12 @@ -55,6 +57,17 @@
    2.13  		{941007A1-6375-4507-8745-FC3EA9DF010B}.Release|Win32.ActiveCfg = Release|Win32
    2.14  		{941007A1-6375-4507-8745-FC3EA9DF010B}.Release|Win32.Build.0 = Release|Win32
    2.15  		{941007A1-6375-4507-8745-FC3EA9DF010B}.Release|x64.ActiveCfg = Release|Win32
    2.16 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
    2.17 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Debug|Mixed Platforms.Build.0 = Debug|Win32
    2.18 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Debug|Win32.ActiveCfg = Debug|Win32
    2.19 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Debug|Win32.Build.0 = Debug|Win32
    2.20 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Debug|x64.ActiveCfg = Debug|x64
    2.21 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Debug|x64.Build.0 = Debug|x64
    2.22 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Release|Mixed Platforms.ActiveCfg = Release|Win32
    2.23 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Release|Mixed Platforms.Build.0 = Release|Win32
    2.24 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Release|Win32.ActiveCfg = Release|Win32
    2.25 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Release|Win32.Build.0 = Release|Win32
    2.26 +		{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}.Release|x64.ActiveCfg = Release|Win32
    2.27  	EndGlobalSection
    2.28  	GlobalSection(SolutionProperties) = preSolution
    2.29  		HideSolutionNode = FALSE
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/goatview/goatview.vcxproj	Tue May 06 03:31:35 2014 +0300
     3.3 @@ -0,0 +1,181 @@
     3.4 +<?xml version="1.0" encoding="utf-8"?>
     3.5 +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     3.6 +  <ItemGroup Label="ProjectConfigurations">
     3.7 +    <ProjectConfiguration Include="Debug|Win32">
     3.8 +      <Configuration>Debug</Configuration>
     3.9 +      <Platform>Win32</Platform>
    3.10 +    </ProjectConfiguration>
    3.11 +    <ProjectConfiguration Include="Debug|x64">
    3.12 +      <Configuration>Debug</Configuration>
    3.13 +      <Platform>x64</Platform>
    3.14 +    </ProjectConfiguration>
    3.15 +    <ProjectConfiguration Include="Release|Win32">
    3.16 +      <Configuration>Release</Configuration>
    3.17 +      <Platform>Win32</Platform>
    3.18 +    </ProjectConfiguration>
    3.19 +    <ProjectConfiguration Include="Release|x64">
    3.20 +      <Configuration>Release</Configuration>
    3.21 +      <Platform>x64</Platform>
    3.22 +    </ProjectConfiguration>
    3.23 +  </ItemGroup>
    3.24 +  <PropertyGroup Label="Globals">
    3.25 +    <ProjectGuid>{26EB2DC7-B2FF-4587-95CD-5DF70287FA0A}</ProjectGuid>
    3.26 +    <Keyword>Win32Proj</Keyword>
    3.27 +    <RootNamespace>goatview</RootNamespace>
    3.28 +  </PropertyGroup>
    3.29 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
    3.30 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    3.31 +    <ConfigurationType>Application</ConfigurationType>
    3.32 +    <UseDebugLibraries>true</UseDebugLibraries>
    3.33 +    <PlatformToolset>v110</PlatformToolset>
    3.34 +    <CharacterSet>Unicode</CharacterSet>
    3.35 +  </PropertyGroup>
    3.36 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    3.37 +    <ConfigurationType>Application</ConfigurationType>
    3.38 +    <UseDebugLibraries>true</UseDebugLibraries>
    3.39 +    <PlatformToolset>v110</PlatformToolset>
    3.40 +    <CharacterSet>Unicode</CharacterSet>
    3.41 +  </PropertyGroup>
    3.42 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    3.43 +    <ConfigurationType>Application</ConfigurationType>
    3.44 +    <UseDebugLibraries>false</UseDebugLibraries>
    3.45 +    <PlatformToolset>v110</PlatformToolset>
    3.46 +    <WholeProgramOptimization>true</WholeProgramOptimization>
    3.47 +    <CharacterSet>Unicode</CharacterSet>
    3.48 +  </PropertyGroup>
    3.49 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    3.50 +    <ConfigurationType>Application</ConfigurationType>
    3.51 +    <UseDebugLibraries>false</UseDebugLibraries>
    3.52 +    <PlatformToolset>v110</PlatformToolset>
    3.53 +    <WholeProgramOptimization>true</WholeProgramOptimization>
    3.54 +    <CharacterSet>Unicode</CharacterSet>
    3.55 +  </PropertyGroup>
    3.56 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
    3.57 +  <ImportGroup Label="ExtensionSettings">
    3.58 +  </ImportGroup>
    3.59 +  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    3.60 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    3.61 +  </ImportGroup>
    3.62 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
    3.63 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    3.64 +  </ImportGroup>
    3.65 +  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    3.66 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    3.67 +  </ImportGroup>
    3.68 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
    3.69 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    3.70 +  </ImportGroup>
    3.71 +  <PropertyGroup Label="UserMacros" />
    3.72 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    3.73 +    <LinkIncremental>true</LinkIncremental>
    3.74 +  </PropertyGroup>
    3.75 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    3.76 +    <LinkIncremental>true</LinkIncremental>
    3.77 +  </PropertyGroup>
    3.78 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    3.79 +    <LinkIncremental>false</LinkIncremental>
    3.80 +  </PropertyGroup>
    3.81 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    3.82 +    <LinkIncremental>false</LinkIncremental>
    3.83 +  </PropertyGroup>
    3.84 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    3.85 +    <ClCompile>
    3.86 +      <PrecompiledHeader>
    3.87 +      </PrecompiledHeader>
    3.88 +      <WarningLevel>Level3</WarningLevel>
    3.89 +      <Optimization>Disabled</Optimization>
    3.90 +      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    3.91 +    </ClCompile>
    3.92 +    <Link>
    3.93 +      <SubSystem>Console</SubSystem>
    3.94 +      <GenerateDebugInformation>true</GenerateDebugInformation>
    3.95 +    </Link>
    3.96 +  </ItemDefinitionGroup>
    3.97 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    3.98 +    <ClCompile>
    3.99 +      <PrecompiledHeader>
   3.100 +      </PrecompiledHeader>
   3.101 +      <WarningLevel>Level3</WarningLevel>
   3.102 +      <Optimization>Disabled</Optimization>
   3.103 +      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
   3.104 +    </ClCompile>
   3.105 +    <Link>
   3.106 +      <SubSystem>Console</SubSystem>
   3.107 +      <GenerateDebugInformation>true</GenerateDebugInformation>
   3.108 +      <AdditionalDependencies>qtmaind.lib;Qt5Cored.lib;Qt5Widgetsd.lib;Qt5OpenGLd.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
   3.109 +    </Link>
   3.110 +    <CustomBuildStep>
   3.111 +      <Command>
   3.112 +      </Command>
   3.113 +    </CustomBuildStep>
   3.114 +    <CustomBuildStep>
   3.115 +      <Message>
   3.116 +      </Message>
   3.117 +    </CustomBuildStep>
   3.118 +    <CustomBuildStep>
   3.119 +      <Outputs>
   3.120 +      </Outputs>
   3.121 +    </CustomBuildStep>
   3.122 +    <CustomBuildStep>
   3.123 +      <Inputs>
   3.124 +      </Inputs>
   3.125 +    </CustomBuildStep>
   3.126 +  </ItemDefinitionGroup>
   3.127 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
   3.128 +    <ClCompile>
   3.129 +      <WarningLevel>Level3</WarningLevel>
   3.130 +      <PrecompiledHeader>
   3.131 +      </PrecompiledHeader>
   3.132 +      <Optimization>MaxSpeed</Optimization>
   3.133 +      <FunctionLevelLinking>true</FunctionLevelLinking>
   3.134 +      <IntrinsicFunctions>true</IntrinsicFunctions>
   3.135 +      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
   3.136 +    </ClCompile>
   3.137 +    <Link>
   3.138 +      <SubSystem>Console</SubSystem>
   3.139 +      <GenerateDebugInformation>true</GenerateDebugInformation>
   3.140 +      <EnableCOMDATFolding>true</EnableCOMDATFolding>
   3.141 +      <OptimizeReferences>true</OptimizeReferences>
   3.142 +    </Link>
   3.143 +  </ItemDefinitionGroup>
   3.144 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
   3.145 +    <ClCompile>
   3.146 +      <WarningLevel>Level3</WarningLevel>
   3.147 +      <PrecompiledHeader>
   3.148 +      </PrecompiledHeader>
   3.149 +      <Optimization>MaxSpeed</Optimization>
   3.150 +      <FunctionLevelLinking>true</FunctionLevelLinking>
   3.151 +      <IntrinsicFunctions>true</IntrinsicFunctions>
   3.152 +      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
   3.153 +    </ClCompile>
   3.154 +    <Link>
   3.155 +      <SubSystem>Console</SubSystem>
   3.156 +      <GenerateDebugInformation>true</GenerateDebugInformation>
   3.157 +      <EnableCOMDATFolding>true</EnableCOMDATFolding>
   3.158 +      <OptimizeReferences>true</OptimizeReferences>
   3.159 +      <AdditionalDependencies>qtmain.lib;Qt5Widgets.lib;Qt5OpenGL.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
   3.160 +    </Link>
   3.161 +  </ItemDefinitionGroup>
   3.162 +  <ItemGroup>
   3.163 +    <ClCompile Include="src\goatview.cc" />
   3.164 +    <ClCompile Include="src\main.cc" />
   3.165 +    <ClCompile Include="src\moc_goatview.cc" />
   3.166 +  </ItemGroup>
   3.167 +  <!--ItemGroup>
   3.168 +    <ClInclude Include="src\goatview.h" />
   3.169 +  </ItemGroup-->
   3.170 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   3.171 +  <ImportGroup Label="ExtensionTargets">
   3.172 +  </ImportGroup>
   3.173 +  <ItemGroup>
   3.174 +    <CustomBuild Include="src\goatview.h">
   3.175 +      <Message>Running MOC on src\goatview.h ...</Message>
   3.176 +      <Command>moc.exe src\goatview.h -o src\moc_goatview.cc</Command>
   3.177 +      <Outputs>src\moc_goatview.cc</Outputs>
   3.178 +    </CustomBuild>
   3.179 +  </ItemGroup>
   3.180 +  <PropertyGroup>
   3.181 +    <CustomBuildAfterTargets>ClCompile</CustomBuildAfterTargets>
   3.182 +    <CustomBuildBeforeTargets>Link</CustomBuildBeforeTargets>
   3.183 +  </PropertyGroup>
   3.184 +</Project>
   3.185 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/goatview/goatview.vcxproj.filters	Tue May 06 03:31:35 2014 +0300
     4.3 @@ -0,0 +1,36 @@
     4.4 +<?xml version="1.0" encoding="utf-8"?>
     4.5 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     4.6 +  <ItemGroup>
     4.7 +    <Filter Include="Source Files">
     4.8 +      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
     4.9 +      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
    4.10 +    </Filter>
    4.11 +    <Filter Include="Header Files">
    4.12 +      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
    4.13 +      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
    4.14 +    </Filter>
    4.15 +    <Filter Include="Resource Files">
    4.16 +      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
    4.17 +      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
    4.18 +    </Filter>
    4.19 +    <Filter Include="moc">
    4.20 +      <UniqueIdentifier>{a278f8f5-22fd-495a-a96f-0b1a9964828b}</UniqueIdentifier>
    4.21 +    </Filter>
    4.22 +  </ItemGroup>
    4.23 +  <ItemGroup>
    4.24 +    <ClCompile Include="src\main.cc">
    4.25 +      <Filter>Source Files</Filter>
    4.26 +    </ClCompile>
    4.27 +    <ClCompile Include="src\goatview.cc">
    4.28 +      <Filter>Source Files</Filter>
    4.29 +    </ClCompile>
    4.30 +    <ClCompile Include="src\moc_goatview.cc">
    4.31 +      <Filter>moc</Filter>
    4.32 +    </ClCompile>
    4.33 +  </ItemGroup>
    4.34 +  <ItemGroup>
    4.35 +    <CustomBuild Include="src\goatview.h">
    4.36 +      <Filter>Header Files</Filter>
    4.37 +    </CustomBuild>
    4.38 +  </ItemGroup>
    4.39 +</Project>
    4.40 \ No newline at end of file
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/goatview/src/goatview.cc	Tue May 06 03:31:35 2014 +0300
     5.3 @@ -0,0 +1,117 @@
     5.4 +#include "goatview.h"
     5.5 +
     5.6 +GoatView::GoatView()
     5.7 +{
     5.8 +	make_menu();
     5.9 +	make_dock();
    5.10 +	make_center();
    5.11 +
    5.12 +	statusBar();
    5.13 +
    5.14 +	setWindowTitle("GoatView");
    5.15 +}
    5.16 +
    5.17 +GoatView::~GoatView()
    5.18 +{
    5.19 +}
    5.20 +
    5.21 +bool GoatView::make_menu()
    5.22 +{
    5.23 +	QMenu *menu_file = menuBar()->addMenu("&File");
    5.24 +
    5.25 +	QAction *act_open_sce = new QAction("&Open Scene", this);
    5.26 +	act_open_sce->setShortcuts(QKeySequence::Open);
    5.27 +	connect(act_open_sce, &QAction::triggered, this, &GoatView::open_scene);
    5.28 +	menu_file->addAction(act_open_sce);
    5.29 +
    5.30 +	QAction *act_open_anm = new QAction("Open &Animation", this);
    5.31 +	connect(act_open_anm, &QAction::triggered, this, &GoatView::open_anim);
    5.32 +	menu_file->addAction(act_open_anm);
    5.33 +
    5.34 +	QAction *act_quit = new QAction("&Quit", this);
    5.35 +	act_quit->setShortcuts(QKeySequence::Quit);
    5.36 +	connect(act_quit, &QAction::triggered, [&](){qApp->quit();});
    5.37 +	menu_file->addAction(act_quit);
    5.38 +	return true;
    5.39 +}
    5.40 +
    5.41 +bool GoatView::make_dock()
    5.42 +{
    5.43 +	// ---- side-dock ----
    5.44 +	QWidget *dock_cont = new QWidget;
    5.45 +	QVBoxLayout *dock_vbox = new QVBoxLayout;
    5.46 +	dock_cont->setLayout(dock_vbox);
    5.47 +
    5.48 +	QPushButton *bn_quit = new QPushButton("quit");
    5.49 +	dock_vbox->addWidget(bn_quit);
    5.50 +	connect(bn_quit, &QPushButton::clicked, [&](){qApp->quit();});
    5.51 +
    5.52 +	QDockWidget *dock = new QDockWidget("Scene graph", this);
    5.53 +	dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    5.54 +	dock->setWidget(dock_cont);
    5.55 +	addDockWidget(Qt::LeftDockWidgetArea, dock);
    5.56 +
    5.57 +	// ---- bottom dock ----
    5.58 +	dock_cont = new QWidget;
    5.59 +	QHBoxLayout *dock_hbox = new QHBoxLayout;
    5.60 +	dock_cont->setLayout(dock_hbox);
    5.61 +
    5.62 +	QSlider *slider_time = new QSlider(Qt::Orientation::Horizontal);
    5.63 +	slider_time->setDisabled(true);
    5.64 +	dock_hbox->addWidget(slider_time);
    5.65 +
    5.66 +	dock = new QDockWidget("Animation", this);
    5.67 +	dock->setAllowedAreas(Qt::BottomDockWidgetArea);
    5.68 +	dock->setWidget(dock_cont);
    5.69 +	addDockWidget(Qt::BottomDockWidgetArea, dock);
    5.70 +
    5.71 +	return true;
    5.72 +}
    5.73 +
    5.74 +bool GoatView::make_center()
    5.75 +{
    5.76 +	GoatViewport *vport = new GoatViewport;
    5.77 +	setCentralWidget(vport);
    5.78 +	return true;
    5.79 +}
    5.80 +
    5.81 +void GoatView::open_scene()
    5.82 +{
    5.83 +	statusBar()->showMessage("opening scene...");
    5.84 +}
    5.85 +
    5.86 +void GoatView::open_anim()
    5.87 +{
    5.88 +	statusBar()->showMessage("opening animation...");
    5.89 +}
    5.90 +
    5.91 +
    5.92 +// ---- OpenGL viewport ----
    5.93 +GoatViewport::GoatViewport()
    5.94 +	: QGLWidget(QGLFormat(QGL::DepthBuffer))
    5.95 +{
    5.96 +}
    5.97 +
    5.98 +GoatViewport::~GoatViewport()
    5.99 +{
   5.100 +}
   5.101 +
   5.102 +QSize GoatViewport::sizeHint() const
   5.103 +{
   5.104 +	return QSize(800, 600);
   5.105 +}
   5.106 +
   5.107 +void GoatViewport::initializeGL()
   5.108 +{
   5.109 +}
   5.110 +
   5.111 +void GoatViewport::resizeGL(int xsz, int ysz)
   5.112 +{
   5.113 +	glViewport(0, 0, xsz, ysz);
   5.114 +}
   5.115 +
   5.116 +void GoatViewport::paintGL()
   5.117 +{
   5.118 +	glClearColor(1, 0, 0, 1);
   5.119 +	glClear(GL_COLOR_BUFFER_BIT);
   5.120 +}
   5.121 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/goatview/src/goatview.h	Tue May 06 03:31:35 2014 +0300
     6.3 @@ -0,0 +1,36 @@
     6.4 +#ifndef GOATVIEW_H_
     6.5 +#define GOATVIEW_H_
     6.6 +
     6.7 +#include <QtWidgets/QtWidgets>
     6.8 +#include <QtOpenGL/QGLWidget>
     6.9 +
    6.10 +class GoatView : public QMainWindow {
    6.11 +	Q_OBJECT
    6.12 +private:
    6.13 +	bool make_menu();
    6.14 +	bool make_dock();
    6.15 +	bool make_center();
    6.16 +
    6.17 +private slots:
    6.18 +	void open_scene();
    6.19 +	void open_anim();
    6.20 +
    6.21 +public:
    6.22 +	GoatView();
    6.23 +	~GoatView();
    6.24 +};
    6.25 +
    6.26 +class GoatViewport : public QGLWidget {
    6.27 +	Q_OBJECT
    6.28 +public:
    6.29 +	GoatViewport();
    6.30 +	~GoatViewport();
    6.31 +
    6.32 +	QSize sizeHint() const;
    6.33 +
    6.34 +	void initializeGL();
    6.35 +	void resizeGL(int xsz, int ysz);
    6.36 +	void paintGL();
    6.37 +};
    6.38 +
    6.39 +#endif	// GOATVIEW_H_
    6.40 \ No newline at end of file
     7.1 --- a/goatview/src/main.c	Mon Apr 21 03:44:42 2014 +0300
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,220 +0,0 @@
     7.4 -#include <stdio.h>
     7.5 -#include <stdlib.h>
     7.6 -#include <assert.h>
     7.7 -#ifndef __APPLE__
     7.8 -#include <GL/glut.h>
     7.9 -#else
    7.10 -#include <GLUT/glut.h>
    7.11 -#endif
    7.12 -#include "goat3d.h"
    7.13 -
    7.14 -static void cleanup(void);
    7.15 -static void disp(void);
    7.16 -static void draw_scene(struct goat3d *g);
    7.17 -static void draw_mesh(struct goat3d_mesh *mesh);
    7.18 -static void reshape(int x, int y);
    7.19 -static void keyb(unsigned char key, int x, int y);
    7.20 -static void mouse(int bn, int st, int x, int y);
    7.21 -static void motion(int x, int y);
    7.22 -
    7.23 -static struct goat3d *goat;
    7.24 -static float cam_theta, cam_phi, cam_dist = 10;
    7.25 -
    7.26 -int main(int argc, char **argv)
    7.27 -{
    7.28 -	int i, nmeshes;
    7.29 -
    7.30 -	glutInitWindowSize(800, 600);
    7.31 -	glutInit(&argc, argv);
    7.32 -
    7.33 -	if(!argv[1]) {
    7.34 -		fprintf(stderr, "you must specify a goat3d scene file to open\n");
    7.35 -		return 1;
    7.36 -	}
    7.37 -
    7.38 -	if(!(goat = goat3d_create())) {
    7.39 -		fprintf(stderr, "failed to create goat3d\n");
    7.40 -		return 1;
    7.41 -	}
    7.42 -	if(goat3d_load(goat, argv[1]) == -1) {
    7.43 -		fprintf(stderr, "failed to load goat3d scene: %s\n", argv[1]);
    7.44 -		goat3d_free(goat);
    7.45 -		return 1;
    7.46 -	}
    7.47 -
    7.48 -	nmeshes = goat3d_get_mesh_count(goat);
    7.49 -	printf("loaded %d meshes\n", nmeshes);
    7.50 -	for(i=0; i<nmeshes; i++) {
    7.51 -		struct goat3d_mesh *m = goat3d_get_mesh(goat, i);
    7.52 -
    7.53 -		printf("- mesh[%d]: %s (%d verts, %d faces)\n", i, goat3d_get_mesh_name(m),
    7.54 -				goat3d_get_mesh_attrib_count(m, GOAT3D_MESH_ATTR_VERTEX),
    7.55 -				goat3d_get_mesh_face_count(m));
    7.56 -	}
    7.57 -
    7.58 -	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    7.59 -	glutCreateWindow(argv[1]);
    7.60 -
    7.61 -	glutDisplayFunc(disp);
    7.62 -	glutReshapeFunc(reshape);
    7.63 -	glutKeyboardFunc(keyb);
    7.64 -	glutMouseFunc(mouse);
    7.65 -	glutMotionFunc(motion);
    7.66 -
    7.67 -	glEnable(GL_DEPTH_TEST);
    7.68 -	glEnable(GL_CULL_FACE);
    7.69 -	glEnable(GL_LIGHTING);
    7.70 -	glEnable(GL_LIGHT0);
    7.71 -
    7.72 -	glClearColor(0.1, 0.1, 0.1, 1.0);
    7.73 -
    7.74 -	atexit(cleanup);
    7.75 -
    7.76 -	glutMainLoop();
    7.77 -	return 0;
    7.78 -}
    7.79 -
    7.80 -static void cleanup(void)
    7.81 -{
    7.82 -	goat3d_free(goat);
    7.83 -}
    7.84 -
    7.85 -static void disp(void)
    7.86 -{
    7.87 -	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    7.88 -
    7.89 -	glMatrixMode(GL_MODELVIEW);
    7.90 -	glLoadIdentity();
    7.91 -	glTranslatef(0, 0, -cam_dist);
    7.92 -	glRotatef(cam_phi, 1, 0, 0);
    7.93 -	glRotatef(cam_theta, 0, 1, 0);
    7.94 -
    7.95 -	draw_scene(goat);
    7.96 -
    7.97 -	glutSwapBuffers();
    7.98 -	assert(glGetError() == GL_NO_ERROR);
    7.99 -}
   7.100 -
   7.101 -static void draw_scene(struct goat3d *g)
   7.102 -{
   7.103 -	int i, num_meshes;
   7.104 -
   7.105 -	num_meshes = goat3d_get_mesh_count(g);
   7.106 -	for(i=0; i<num_meshes; i++) {
   7.107 -		struct goat3d_mesh *mesh = goat3d_get_mesh(g, i);
   7.108 -		draw_mesh(mesh);
   7.109 -	}
   7.110 -}
   7.111 -
   7.112 -static void draw_mesh(struct goat3d_mesh *mesh)
   7.113 -{
   7.114 -	int vnum, fnum;
   7.115 -	struct goat3d_material *mtl;
   7.116 -	float *verts, *normals, *texcoords;
   7.117 -	int *vidx;
   7.118 -
   7.119 -	if((mtl = goat3d_get_mesh_mtl(mesh))) {
   7.120 -		float white[] = {1, 1, 1, 1};
   7.121 -		float black[] = {0, 0, 0, 0};
   7.122 -		float zero = 0.0;
   7.123 -		const float *diffuse, *specular, *shininess;
   7.124 -
   7.125 -		if(!(diffuse = goat3d_get_mtl_attrib(mtl, GOAT3D_MAT_ATTR_DIFFUSE))) {
   7.126 -			diffuse = white;
   7.127 -		}
   7.128 -		if(!(specular = goat3d_get_mtl_attrib(mtl, GOAT3D_MAT_ATTR_SPECULAR))) {
   7.129 -			specular = black;
   7.130 -		}
   7.131 -		if(!(shininess = goat3d_get_mtl_attrib(mtl, GOAT3D_MAT_ATTR_SHININESS))) {
   7.132 -			shininess = &zero;
   7.133 -		}
   7.134 -
   7.135 -		glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, diffuse);
   7.136 -		glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
   7.137 -		glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, *shininess);
   7.138 -	}
   7.139 -
   7.140 -	vnum = goat3d_get_mesh_attrib_count(mesh, GOAT3D_MESH_ATTR_VERTEX);
   7.141 -	fnum = goat3d_get_mesh_face_count(mesh);
   7.142 -
   7.143 -	if(!vnum || !fnum) {
   7.144 -		return;
   7.145 -	}
   7.146 -
   7.147 -	verts = goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_VERTEX);
   7.148 -	normals = goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_NORMAL);
   7.149 -	texcoords = goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_TEXCOORD);
   7.150 -	vidx = goat3d_get_mesh_faces(mesh);
   7.151 -
   7.152 -	glEnableClientState(GL_VERTEX_ARRAY);
   7.153 -	glVertexPointer(3, GL_FLOAT, 0, verts);
   7.154 -
   7.155 -	if(normals) {
   7.156 -		glEnableClientState(GL_NORMAL_ARRAY);
   7.157 -		glNormalPointer(GL_FLOAT, 0, normals);
   7.158 -	}
   7.159 -	if(texcoords) {
   7.160 -		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
   7.161 -		glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
   7.162 -	}
   7.163 -
   7.164 -	glDrawElements(GL_TRIANGLES, fnum * 3, GL_UNSIGNED_INT, vidx);
   7.165 -
   7.166 -	glDisableClientState(GL_VERTEX_ARRAY);
   7.167 -	if(normals) {
   7.168 -		glDisableClientState(GL_NORMAL_ARRAY);
   7.169 -	}
   7.170 -	if(texcoords) {
   7.171 -		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
   7.172 -	}
   7.173 -}
   7.174 -
   7.175 -static void reshape(int x, int y)
   7.176 -{
   7.177 -	glViewport(0, 0, x, y);
   7.178 -
   7.179 -	glMatrixMode(GL_PROJECTION);
   7.180 -	glLoadIdentity();
   7.181 -	gluPerspective(50.0, (float)x / (float)y, 0.5, 1000.0);
   7.182 -}
   7.183 -
   7.184 -static void keyb(unsigned char key, int x, int y)
   7.185 -{
   7.186 -	switch(key) {
   7.187 -	case 27:
   7.188 -		exit(0);
   7.189 -	}
   7.190 -}
   7.191 -
   7.192 -static int bnstate[32];
   7.193 -static int prev_x, prev_y;
   7.194 -
   7.195 -static void mouse(int bn, int st, int x, int y)
   7.196 -{
   7.197 -	bnstate[bn - GLUT_LEFT_BUTTON] = (st == GLUT_DOWN);
   7.198 -	prev_x = x;
   7.199 -	prev_y = y;
   7.200 -}
   7.201 -
   7.202 -static void motion(int x, int y)
   7.203 -{
   7.204 -	int dx = x - prev_x;
   7.205 -	int dy = y - prev_y;
   7.206 -	prev_x = x;
   7.207 -	prev_y = y;
   7.208 -
   7.209 -	if(bnstate[0]) {
   7.210 -		cam_theta += dx * 0.5;
   7.211 -		cam_phi += dy * 0.5;
   7.212 -
   7.213 -		if(cam_phi < -90) cam_phi = -90;
   7.214 -		if(cam_phi > 90) cam_phi = 90;
   7.215 -		glutPostRedisplay();
   7.216 -	}
   7.217 -	if(bnstate[2]) {
   7.218 -		cam_dist += dy * 0.1;
   7.219 -
   7.220 -		if(cam_dist < 0) cam_dist = 0;
   7.221 -		glutPostRedisplay();
   7.222 -	}
   7.223 -}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/goatview/src/main.cc	Tue May 06 03:31:35 2014 +0300
     8.3 @@ -0,0 +1,12 @@
     8.4 +#include <QtWidgets/QtWidgets>
     8.5 +#include "goatview.h"
     8.6 +
     8.7 +int main(int argc, char **argv)
     8.8 +{
     8.9 +	QApplication app(argc, argv);
    8.10 +
    8.11 +	GoatView gview;
    8.12 +	gview.show();
    8.13 +
    8.14 +	return app.exec();
    8.15 +}
    8.16 \ No newline at end of file
     9.1 --- a/src/goat3d.cc	Mon Apr 21 03:44:42 2014 +0300
     9.2 +++ b/src/goat3d.cc	Tue May 06 03:31:35 2014 +0300
     9.3 @@ -56,7 +56,6 @@
     9.4  	goat->flags = 0;
     9.5  	goat->search_path = 0;
     9.6  	goat->scn = new Scene;
     9.7 -	goat->scn->goat = goat;
     9.8  
     9.9  	goat3d_setopt(goat, GOAT3D_OPT_SAVEXML, 1);
    9.10  	return goat;