goat3dgfx
changeset 29:9d581abd0bfb
merged
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 02 Mar 2014 02:18:15 +0200 |
parents | dc5918c62a64 0b863938da04 |
children | 07c08d970cb4 |
files | |
diffstat | 7 files changed, 187 insertions(+), 100 deletions(-) [+] |
line diff
1.1 --- a/examples/viewscn/src/main.cc Sat Mar 01 22:04:29 2014 +0200 1.2 +++ b/examples/viewscn/src/main.cc Sun Mar 02 02:18:15 2014 +0200 1.3 @@ -87,9 +87,9 @@ 1.4 1.5 //setup_gl_matrices(); 1.6 1.7 - bind_shader(sdr); 1.8 + goatgfx::bind_shader(sdr); 1.9 scn->draw(); 1.10 - bind_shader(0); 1.11 + goatgfx::bind_shader(0); 1.12 1.13 /*glBegin(GL_QUADS); 1.14 glColor3f(1, 1, 1);
2.1 --- a/goat3dgfx.sln Sat Mar 01 22:04:29 2014 +0200 2.2 +++ b/goat3dgfx.sln Sun Mar 02 02:18:15 2014 +0200 2.3 @@ -9,6 +9,9 @@ 2.4 EndProjectSection 2.5 EndProject 2.6 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "viewscn", "examples\viewscn\viewscn.vcproj", "{7240C31B-8746-4816-AE13-BF0F75228411}" 2.7 + ProjectSection(ProjectDependencies) = postProject 2.8 + {251F8AFF-5A37-4F10-A519-C55C40E127AF} = {251F8AFF-5A37-4F10-A519-C55C40E127AF} 2.9 + EndProjectSection 2.10 EndProject 2.11 Global 2.12 GlobalSection(SolutionConfigurationPlatforms) = preSolution
3.1 --- a/goat3dgfx.vcproj Sat Mar 01 22:04:29 2014 +0200 3.2 +++ b/goat3dgfx.vcproj Sun Mar 02 02:18:15 2014 +0200 3.3 @@ -25,6 +25,7 @@ 3.4 > 3.5 <Tool 3.6 Name="VCPreBuildEventTool" 3.7 + CommandLine="echo #ifndef GOAT3DGFX_CONFIG_H_>$(ProjectDir)\src\config.h
echo #define GOAT3DGFX_CONFIG_H_>>$(ProjectDir)\src\config.h
echo #define USE_VR>>$(ProjectDir)\src\config.h
echo #define USE_LIBOVR>>$(ProjectDir)\src\config.h
echo #endif>>$(ProjectDir)\src\config.h
" 3.8 /> 3.9 <Tool 3.10 Name="VCCustomBuildTool" 3.11 @@ -41,6 +42,7 @@ 3.12 <Tool 3.13 Name="VCCLCompilerTool" 3.14 Optimization="0" 3.15 + AdditionalIncludeDirectories="$(SolutionDir)\src" 3.16 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GOAT3DGFX_EXPORTS" 3.17 MinimalRebuild="true" 3.18 BasicRuntimeChecks="3" 3.19 @@ -77,7 +79,7 @@ 3.20 /> 3.21 <Tool 3.22 Name="VCPostBuildEventTool" 3.23 - CommandLine="mkdir usr\include\goat3dgfx
mkdir usr\lib
copy /Y src\*.h usr\include\goat3dgfx\
copy /Y src\*.inl usr\include\goat3dgfx\
copy /Y $(TargetPath) usr\lib\" 3.24 + CommandLine="mkdir usr\include\goat3dgfx
mkdir usr\lib
copy /Y src\*.h usr\include\goat3dgfx\
copy /Y src\*.inl usr\include\goat3dgfx\
copy /Y $(TargetPath) usr\lib\
" 3.25 /> 3.26 </Configuration> 3.27 <Configuration 3.28 @@ -90,6 +92,7 @@ 3.29 > 3.30 <Tool 3.31 Name="VCPreBuildEventTool" 3.32 + CommandLine="echo #ifndef GOAT3DGFX_CONFIG_H_>$(ProjectDir)\src\config.h
echo #define GOAT3DGFX_CONFIG_H_>>$(ProjectDir)\src\config.h
echo #define USE_VR>>$(ProjectDir)\src\config.h
echo #define USE_LIBOVR>>$(ProjectDir)\src\config.h
echo #endif>>$(ProjectDir)\src\config.h
" 3.33 /> 3.34 <Tool 3.35 Name="VCCustomBuildTool" 3.36 @@ -107,6 +110,7 @@ 3.37 Name="VCCLCompilerTool" 3.38 Optimization="2" 3.39 EnableIntrinsicFunctions="true" 3.40 + AdditionalIncludeDirectories="$(SolutionDir)\src" 3.41 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GOAT3DGFX_EXPORTS" 3.42 RuntimeLibrary="2" 3.43 EnableFunctionLevelLinking="true" 3.44 @@ -141,6 +145,7 @@ 3.45 /> 3.46 <Tool 3.47 Name="VCPostBuildEventTool" 3.48 + CommandLine="mkdir usr\include\goat3dgfx
mkdir usr\lib
copy /Y src\*.h usr\include\goat3dgfx\
copy /Y src\*.inl usr\include\goat3dgfx\
copy /Y $(TargetPath) usr\lib\
" 3.49 /> 3.50 </Configuration> 3.51 </Configurations> 3.52 @@ -149,7 +154,7 @@ 3.53 <Files> 3.54 <Filter 3.55 Name="src" 3.56 - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" 3.57 + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;inl" 3.58 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" 3.59 > 3.60 <File 3.61 @@ -161,113 +166,35 @@ 3.62 > 3.63 </File> 3.64 <File 3.65 + RelativePath=".\src\assload.h" 3.66 + > 3.67 + </File> 3.68 + <File 3.69 + RelativePath=".\src\camera.cc" 3.70 + > 3.71 + </File> 3.72 + <File 3.73 + RelativePath=".\src\camera.h" 3.74 + > 3.75 + </File> 3.76 + <File 3.77 RelativePath=".\src\curve.cc" 3.78 > 3.79 </File> 3.80 <File 3.81 + RelativePath=".\src\curve.h" 3.82 + > 3.83 + </File> 3.84 + <File 3.85 RelativePath=".\src\curveload.cc" 3.86 > 3.87 </File> 3.88 <File 3.89 - RelativePath=".\src\datapath.cc" 3.90 + RelativePath=".\src\curveload.h" 3.91 > 3.92 </File> 3.93 <File 3.94 - RelativePath=".\src\geom.cc" 3.95 - > 3.96 - </File> 3.97 - <File 3.98 - RelativePath=".\src\gfxutil.cc" 3.99 - > 3.100 - </File> 3.101 - <File 3.102 - RelativePath=".\src\image.cc" 3.103 - > 3.104 - </File> 3.105 - <File 3.106 - RelativePath=".\src\logger.cc" 3.107 - > 3.108 - </File> 3.109 - <File 3.110 - RelativePath=".\src\material.cc" 3.111 - > 3.112 - </File> 3.113 - <File 3.114 - RelativePath=".\src\mesh.cc" 3.115 - > 3.116 - </File> 3.117 - <File 3.118 - RelativePath=".\src\meshgen.cc" 3.119 - > 3.120 - </File> 3.121 - <File 3.122 - RelativePath=".\src\object.cc" 3.123 - > 3.124 - </File> 3.125 - <File 3.126 - RelativePath=".\src\opengl.cc" 3.127 - > 3.128 - </File> 3.129 - <File 3.130 - RelativePath=".\src\psyspp.cc" 3.131 - > 3.132 - </File> 3.133 - <File 3.134 - RelativePath=".\src\rtarg.cc" 3.135 - > 3.136 - </File> 3.137 - <File 3.138 - RelativePath=".\src\scene.cc" 3.139 - > 3.140 - </File> 3.141 - <File 3.142 - RelativePath=".\src\sdrman.cc" 3.143 - > 3.144 - </File> 3.145 - <File 3.146 - RelativePath=".\src\shader.cc" 3.147 - > 3.148 - </File> 3.149 - <File 3.150 - RelativePath=".\src\texgen.cc" 3.151 - > 3.152 - </File> 3.153 - <File 3.154 - RelativePath=".\src\texman.cc" 3.155 - > 3.156 - </File> 3.157 - <File 3.158 - RelativePath=".\src\texture.cc" 3.159 - > 3.160 - </File> 3.161 - <File 3.162 - RelativePath=".\src\timer.cc" 3.163 - > 3.164 - </File> 3.165 - <File 3.166 - RelativePath=".\src\unistate.cc" 3.167 - > 3.168 - </File> 3.169 - <File 3.170 - RelativePath=".\src\xform_node.cc" 3.171 - > 3.172 - </File> 3.173 - </Filter> 3.174 - <Filter 3.175 - Name="include" 3.176 - Filter="h;hpp;hxx;hm;inl;inc;xsd" 3.177 - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" 3.178 - > 3.179 - <File 3.180 - RelativePath=".\src\assload.h" 3.181 - > 3.182 - </File> 3.183 - <File 3.184 - RelativePath=".\src\curve.h" 3.185 - > 3.186 - </File> 3.187 - <File 3.188 - RelativePath=".\src\curveload.h" 3.189 + RelativePath=".\src\datapath.cc" 3.190 > 3.191 </File> 3.192 <File 3.193 @@ -283,85 +210,193 @@ 3.194 > 3.195 </File> 3.196 <File 3.197 + RelativePath=".\src\geom.cc" 3.198 + > 3.199 + </File> 3.200 + <File 3.201 RelativePath=".\src\geom.h" 3.202 > 3.203 </File> 3.204 <File 3.205 + RelativePath=".\src\gfxutil.cc" 3.206 + > 3.207 + </File> 3.208 + <File 3.209 RelativePath=".\src\gfxutil.h" 3.210 > 3.211 </File> 3.212 <File 3.213 + RelativePath=".\src\goat3dgfx.cc" 3.214 + > 3.215 + </File> 3.216 + <File 3.217 + RelativePath=".\src\goat3dgfx.h" 3.218 + > 3.219 + </File> 3.220 + <File 3.221 + RelativePath=".\src\image.cc" 3.222 + > 3.223 + </File> 3.224 + <File 3.225 RelativePath=".\src\image.h" 3.226 > 3.227 </File> 3.228 <File 3.229 + RelativePath=".\src\logger.cc" 3.230 + > 3.231 + </File> 3.232 + <File 3.233 RelativePath=".\src\logger.h" 3.234 > 3.235 </File> 3.236 <File 3.237 + RelativePath=".\src\material.cc" 3.238 + > 3.239 + </File> 3.240 + <File 3.241 RelativePath=".\src\material.h" 3.242 > 3.243 </File> 3.244 <File 3.245 + RelativePath=".\src\mesh.cc" 3.246 + > 3.247 + </File> 3.248 + <File 3.249 RelativePath=".\src\mesh.h" 3.250 > 3.251 </File> 3.252 <File 3.253 + RelativePath=".\src\meshgen.cc" 3.254 + > 3.255 + </File> 3.256 + <File 3.257 RelativePath=".\src\meshgen.h" 3.258 > 3.259 </File> 3.260 <File 3.261 + RelativePath=".\src\object.cc" 3.262 + > 3.263 + </File> 3.264 + <File 3.265 RelativePath=".\src\object.h" 3.266 > 3.267 </File> 3.268 <File 3.269 + RelativePath=".\src\opengl.cc" 3.270 + > 3.271 + </File> 3.272 + <File 3.273 RelativePath=".\src\opengl.h" 3.274 > 3.275 </File> 3.276 <File 3.277 + RelativePath=".\src\psyspp.cc" 3.278 + > 3.279 + </File> 3.280 + <File 3.281 RelativePath=".\src\psyspp.h" 3.282 > 3.283 </File> 3.284 <File 3.285 + RelativePath=".\src\rtarg.cc" 3.286 + > 3.287 + </File> 3.288 + <File 3.289 RelativePath=".\src\rtarg.h" 3.290 > 3.291 </File> 3.292 <File 3.293 + RelativePath=".\src\scene.cc" 3.294 + > 3.295 + </File> 3.296 + <File 3.297 RelativePath=".\src\scene.h" 3.298 > 3.299 </File> 3.300 <File 3.301 + RelativePath=".\src\sdrman.cc" 3.302 + > 3.303 + </File> 3.304 + <File 3.305 RelativePath=".\src\sdrman.h" 3.306 > 3.307 </File> 3.308 <File 3.309 + RelativePath=".\src\shader.cc" 3.310 + > 3.311 + </File> 3.312 + <File 3.313 RelativePath=".\src\shader.h" 3.314 > 3.315 </File> 3.316 <File 3.317 + RelativePath=".\src\texgen.cc" 3.318 + > 3.319 + </File> 3.320 + <File 3.321 RelativePath=".\src\texgen.h" 3.322 > 3.323 </File> 3.324 <File 3.325 + RelativePath=".\src\texman.cc" 3.326 + > 3.327 + </File> 3.328 + <File 3.329 RelativePath=".\src\texman.h" 3.330 > 3.331 </File> 3.332 <File 3.333 + RelativePath=".\src\texture.cc" 3.334 + > 3.335 + </File> 3.336 + <File 3.337 RelativePath=".\src\texture.h" 3.338 > 3.339 </File> 3.340 <File 3.341 + RelativePath=".\src\timer.cc" 3.342 + > 3.343 + </File> 3.344 + <File 3.345 RelativePath=".\src\timer.h" 3.346 > 3.347 </File> 3.348 <File 3.349 + RelativePath=".\src\unistate.cc" 3.350 + > 3.351 + </File> 3.352 + <File 3.353 RelativePath=".\src\unistate.h" 3.354 > 3.355 </File> 3.356 <File 3.357 + RelativePath=".\src\vr.h" 3.358 + > 3.359 + </File> 3.360 + <File 3.361 + RelativePath=".\src\xform_node.cc" 3.362 + > 3.363 + </File> 3.364 + <File 3.365 RelativePath=".\src\xform_node.h" 3.366 > 3.367 </File> 3.368 + <Filter 3.369 + Name="vr" 3.370 + > 3.371 + <File 3.372 + RelativePath=".\src\vr\vr.cc" 3.373 + > 3.374 + </File> 3.375 + <File 3.376 + RelativePath=".\src\vr\vr_impl.h" 3.377 + > 3.378 + </File> 3.379 + <File 3.380 + RelativePath=".\src\vr\vr_sdr.h" 3.381 + > 3.382 + </File> 3.383 + </Filter> 3.384 </Filter> 3.385 </Files> 3.386 <Globals>
4.1 --- a/src/scene.cc Sat Mar 01 22:04:29 2014 +0200 4.2 +++ b/src/scene.cc Sun Mar 02 02:18:15 2014 +0200 4.3 @@ -40,6 +40,7 @@ 4.4 return false; 4.5 } 4.6 4.7 + // load all the meshes 4.8 int num_meshes = goat3d_get_mesh_count(goat); 4.9 for(int i=0; i<num_meshes; i++) { 4.10 goat3d_mesh *gmesh = goat3d_get_mesh(goat, i); 4.11 @@ -49,6 +50,12 @@ 4.12 } 4.13 } 4.14 4.15 + // load all the nodes recursively 4.16 + int num_nodes = goat3d_get_node_count(goat); 4.17 + for(int i=0; i<num_nodes; i++) { 4.18 + goat3d_node *gnode = goat3d_get_node(goat, i); 4.19 + } 4.20 + 4.21 goat3d_free(goat); 4.22 return true; 4.23 } 4.24 @@ -64,6 +71,7 @@ 4.25 objects[i]->draw(msec); 4.26 } 4.27 4.28 + // if there are no objects in the scene, just draw the meshes instead 4.29 if(objects.empty()) { 4.30 for(size_t i=0; i<meshes.size(); i++) { 4.31 meshes[i]->draw();
5.1 --- a/src/scene.h Sat Mar 01 22:04:29 2014 +0200 5.2 +++ b/src/scene.h Sun Mar 02 02:18:15 2014 +0200 5.3 @@ -12,6 +12,11 @@ 5.4 std::vector<Object*> objects; 5.5 std::vector<Mesh*> meshes; 5.6 std::vector<Curve*> curves; 5.7 + std::vector<Light*> lights; 5.8 + std::vector<Camera*> cameras; 5.9 + 5.10 + // nodes can be objects, lights, cameras, or just dummy nodes 5.11 + std::vector<XFormNode*> nodes; 5.12 5.13 ~Scene(); 5.14 void destroy();
6.1 --- a/src/vr/vr.cc Sat Mar 01 22:04:29 2014 +0200 6.2 +++ b/src/vr/vr.cc Sun Mar 02 02:18:15 2014 +0200 6.3 @@ -1,5 +1,11 @@ 6.4 +#include "config.h" 6.5 + 6.6 #include <stdio.h> 6.7 +#include <string.h> 6.8 +#define _USE_MATH_DEFINES 6.9 +#include <math.h> 6.10 #include <GL/glew.h> 6.11 +#include "vmath/vmath.h" 6.12 #include "vr.h" 6.13 #include "vr_impl.h" 6.14 #include "vr_sdr.h" 6.15 @@ -35,8 +41,10 @@ 6.16 extern "C" void vr_shutdown(void) 6.17 { 6.18 delete [] vr_ctx.info.display; 6.19 +#ifdef USE_LIBOVR 6.20 delete vr_ctx.ovr_sfusion; 6.21 //System::Destroy(); 6.22 +#endif 6.23 6.24 memset(&vr_ctx, 0, sizeof vr_ctx); 6.25 } 6.26 @@ -53,6 +61,7 @@ 6.27 6.28 static bool init_ovr() 6.29 { 6.30 +#ifdef USE_LIBOVR 6.31 LogMaskConstants log_level = LogMask_All; 6.32 // initialize Oculus SDK 6.33 const char *logenv = getenv("VR_LOGLEVEL"); 6.34 @@ -150,6 +159,7 @@ 6.35 vr_ctx.ovr_sfusion = new SensorFusion; 6.36 vr_ctx.ovr_sfusion->AttachToSensor(vr_ctx.ovr_sensor_dev); 6.37 } 6.38 +#endif // USE_LIBOVR 6.39 return true; 6.40 } 6.41 6.42 @@ -289,12 +299,16 @@ 6.43 6.44 extern "C" void vr_set_prediction_sec(float dt) 6.45 { 6.46 +#ifdef USE_LIBOVR 6.47 vr_ctx.ovr_sfusion->SetPrediction(dt); 6.48 +#endif 6.49 } 6.50 6.51 extern "C" float vr_get_prediction_sec(void) 6.52 { 6.53 +#ifdef USE_LIBOVR 6.54 return vr_ctx.ovr_sfusion->GetPredictionDelta(); 6.55 +#endif 6.56 } 6.57 6.58 extern "C" void vr_get_view_matrix(float *res, int eye) 6.59 @@ -304,12 +318,19 @@ 6.60 6.61 extern "C" void vr_get_proj_matrix(float *res, int eye) 6.62 { 6.63 +#ifdef USE_LIBOVR 6.64 static float eye_scale[] = {0.0, 1.0, -1.0}; 6.65 6.66 Matrix4f proj = Matrix4f::PerspectiveRH(vr_ctx.info.fov, vr_ctx.info.aspect / 2.0, 0.3, 1000.0); 6.67 proj = Matrix4f::Translation(vr_ctx.info.proj_center_offset * eye_scale[eye], 0, 0) * proj; 6.68 6.69 memcpy(res, proj.M[0], 16 * sizeof(float)); 6.70 +#else 6.71 + Matrix4x4 proj; 6.72 + proj.set_perspective(vr_ctx.info.fov, vr_ctx.info.aspect, 0.3, 1000.0); 6.73 + proj.transpose(); 6.74 + memcpy(res, proj[0], 16 * sizeof(float)); 6.75 +#endif 6.76 } 6.77 6.78 extern "C" void vr_get_translation(float *offs) 6.79 @@ -320,17 +341,26 @@ 6.80 6.81 extern "C" void vr_get_rotation(float *quat) 6.82 { 6.83 +#ifdef USE_LIBOVR 6.84 Quatf oq = vr_ctx.ovr_sfusion->GetPredictedOrientation(); 6.85 quat[0] = oq.x; 6.86 quat[1] = oq.y; 6.87 quat[2] = oq.z; 6.88 quat[3] = oq.w; 6.89 +#else 6.90 + quat[0] = quat[1] = quat[2] = 0.0; 6.91 + quat[3] = 1.0; 6.92 +#endif 6.93 } 6.94 6.95 extern "C" void vr_get_rotation_euler(float *euler) 6.96 { 6.97 +#ifdef USE_LIBOVR 6.98 Quatf oq = vr_ctx.ovr_sfusion->GetPredictedOrientation(); 6.99 oq.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(euler + 1, euler, euler + 2); 6.100 +#else 6.101 + euler[0] = euler[1] = euler[2] = 0.0; 6.102 +#endif 6.103 } 6.104 6.105 extern "C" void vr_draw_eye(int eye, unsigned int tex, float tex_scale_x, float tex_scale_y)
7.1 --- a/src/vr/vr_impl.h Sat Mar 01 22:04:29 2014 +0200 7.2 +++ b/src/vr/vr_impl.h Sun Mar 02 02:18:15 2014 +0200 7.3 @@ -1,15 +1,21 @@ 7.4 #ifndef VR_IMPL_H_ 7.5 #define VR_IMPL_H_ 7.6 7.7 +#include "config.h" 7.8 + 7.9 +#ifdef USE_LIBOVR 7.10 #include <OVR.h> 7.11 7.12 using namespace OVR; 7.13 +#endif 7.14 7.15 struct VRContext { 7.16 +#ifdef USE_LIBOVR 7.17 DeviceManager *ovr_devman; 7.18 HMDDevice *ovr_hmd_dev; 7.19 SensorDevice *ovr_sensor_dev; 7.20 SensorFusion *ovr_sfusion; 7.21 +#endif 7.22 7.23 struct { 7.24 char *display;