28 |
|
|
29 |
#include "org_nongnu_libvob_gl_GL.h" |
#include "org_nongnu_libvob_gl_GL.h" |
30 |
#include "vobjnidef.hxx" |
#include "vobjnidef.hxx" |
31 |
|
#include "vob/Debug.hxx" |
32 |
|
|
33 |
namespace Vob { |
namespace Vob { |
34 |
|
|
35 |
|
DBGVAR(dbg_trans, "JNI.transform"); |
36 |
|
|
37 |
extern Primitives::HierarchicalTransform *defaultTransformFactory(int id) ; |
extern Primitives::HierarchicalTransform *defaultTransformFactory(int id) ; |
38 |
|
|
39 |
extern "C" { |
extern "C" { |
51 |
(int*)0, (float*)0, |
(int*)0, (float*)0, |
52 |
(float)0, (bool)true); |
(float)0, (bool)true); |
53 |
|
|
54 |
|
DBG(dbg_trans) << "SetPoints -- now: "<<coordsys<<"\n"; |
55 |
|
|
56 |
int arrayLength = env->GetArrayLength(j_points); |
int arrayLength = env->GetArrayLength(j_points); |
57 |
jfloat *points = env->GetFloatArrayElements(j_points, 0); |
jfloat *points = env->GetFloatArrayElements(j_points, 0); |
58 |
|
int nInto = env->GetArrayLength(j_into); |
59 |
|
if(arrayLength != nInto) { |
60 |
|
jclass Exception = env->FindClass("java/lang/Exception"); |
61 |
|
env->ThrowNew(Exception,"Invalid into array length"); |
62 |
|
} |
63 |
jfloat *into = env->GetFloatArrayElements(j_into, 0); |
jfloat *into = env->GetFloatArrayElements(j_into, 0); |
64 |
|
|
65 |
const Transform *cs = coordset.get(coordsys); |
const Transform *cs = coordset.get(coordsys); |
66 |
if(cs != 0) { |
if(cs != 0) { |
67 |
if(inverse) cs = &cs->getInverse(); |
if(inverse) { |
68 |
|
DBG(dbg_trans) << "Inverting...\n"; |
69 |
|
cs = &cs->getInverse(); |
70 |
|
} |
71 |
if(cs != 0) |
if(cs != 0) |
72 |
for(int i=0; i<arrayLength; i+=3) { |
for(int i=0; i<arrayLength; i+=3) { |
73 |
ZPt pt(points[i], points[i+1], points[i+2]); |
ZPt pt(points[i], points[i+1], points[i+2]); |
74 |
|
DBG(dbg_trans) << "Transform "<<pt<<"...\n"; |
75 |
ZPt pt2 = cs->transform(pt); |
ZPt pt2 = cs->transform(pt); |
76 |
into[i] = pt2.x; |
into[i] = pt2.x; |
77 |
into[i+1] = pt2.y; |
into[i+1] = pt2.y; |