1
From ed9ca2736bf3d18a709a7ab2a477d098b13174b2 Mon Sep 17 00:00:00 2001
2
From: Sven Eckelmann <sven.eckelmann@gmx.de>
3
Date: Sun, 15 Feb 2009 11:08:16 +0000
4
Subject: [PATCH] Transform g3d model orientation to s3d orientation
6
libg3d changed the model orientation in rev378 (precedes libg3d 0.0.7).
7
All s3d programs expect a different rotation around the x axis and we
8
should give them their data as before.
9
g3d_model_transform is a new function in libg3d 0.0.7 so we need to
10
depend at least on that version.
12
cmake/modules/FindG3D.cmake | 2 +-
13
libs3d/modelread.c | 5 +++++
14
2 files changed, 6 insertions(+), 1 deletions(-)
16
diff --git a/cmake/modules/FindG3D.cmake b/cmake/modules/FindG3D.cmake
17
index 2242c1f..4e9356f 100644
18
--- a/cmake/modules/FindG3D.cmake
19
+++ b/cmake/modules/FindG3D.cmake
20
@@ -11,5 +11,5 @@ if (G3D_LIBRARIES AND G3D_INCLUDE_DIRS)
21
else (G3D_LIBRARIES AND G3D_INCLUDE_DIRS)
22
find_package(PkgConfig)
24
- pkg_search_module(G3D libg3d>=0.0.6)
25
+ pkg_search_module(G3D libg3d>=0.0.7)
26
endif (G3D_LIBRARIES AND G3D_INCLUDE_DIRS)
27
diff --git a/libs3d/modelread.c b/libs3d/modelread.c
28
index 8d03198..2f82253 100644
29
--- a/libs3d/modelread.c
30
+++ b/libs3d/modelread.c
35
+#include <g3d/matrix.h>
36
#include <stdlib.h> /* exit(), malloc() */
37
#include <math.h> /* sqrt() */
38
#include <string.h> /* strncpy() */
39
@@ -122,6 +123,7 @@ static int model_load(char *file)
42
GSList *oitem, *oface;
43
+ G3DMatrix rmatrix[16];
44
struct material2texture *mat2tex;
46
int j, material_count, texture_count, voff, obj_id;
47
@@ -136,6 +138,9 @@ static int model_load(char *file)
48
model = g3d_model_load_full(context, file, 0);
51
+ g3d_matrix_identity(rmatrix);
52
+ g3d_matrix_rotate_xyz(G_PI * 90.0 / 180, 0.0, 0.0, rmatrix);
53
+ g3d_model_transform(model, rmatrix);
55
oitem = model->objects;
56
obj_id = s3d_new_object();