HI,
also ich habs jetz mal so versucht, jedoch verändert sich, wenn ich die Maus bewege nichts.
was könnte der Grund dafür sein?
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
public class CamFP {
final float pi = 3.141592f;
Vektor eyeOrigin = new Vektor();
Vektor eye = new Vektor();
Vektor centerOrigin = new Vektor();
Vektor center = new Vektor();
Vektor upOrigin = new Vektor();
Vektor upVector = new Vektor();
float phi;
float theta;
float radius;
public CamFP(float eyeX, float eyeY, float eyeZ)
{
centerOrigin.x = 0.0f;
centerOrigin.y = 0.0f;
centerOrigin.z = 0.0f;
center = centerOrigin;
eyeOrigin.x = eyeX;
eyeOrigin.y = eyeY;
eyeOrigin.z = eyeZ;
eye = eyeOrigin;
upOrigin.x = 0.0f;
upOrigin.y = 1.0f;
upOrigin.z = 0.0f;
upVector = upOrigin;
cartesianToSpherical();
}
void calcRadius(){
radius = (float)Math.sqrt((Math.pow(eye.x,2) + Math.pow(eye.y,2) + Math.pow(eye.z,2)));
}
void calcTheta(){
theta = (float)Math.acos(eye.x / radius);
}
void calcPhi(){
phi = (float)Math.acos( eye.x /(radius * Math.sin(theta) ) );
}
public float radToDeg(float x) {
return x * 180.0f / pi;
}
public float degToRad(float x) {
return x * pi / 180.0f;
}
public void rotateY(float degrees) {
theta += degrees;
}
public void rotateZ(float degrees) {
phi += degrees;
}
public void cartesianToSpherical(/*float pEyeX, float pEyeY, float pEyeZ*/){
calcRadius();
calcTheta();
calcPhi();
eye.x = radius;
eye.y = theta;
eye.z = phi;
eye.y = radToDeg(eye.y);
eye.z = radToDeg(eye.z);
}
private void sphericalToCartesian(){
center.x = radius * (float)Math.cos(phi) * (float)Math.cos(theta);
center.y = radius * (float)Math.cos(phi) * (float)Math.sin(theta);
center.z = radius * (float)Math.sin(phi); //should be identical to starting cZ value
}
public void updateView(){
sphericalToCartesian();
center.x = centerOrigin.x - eye.x;
center.y = centerOrigin.y - eye.y;
center.z = centerOrigin.z - eye.z;
float length;
length = (float)Math.sqrt(Math.pow(center.x, 2) + Math.pow(center.y, 2) + Math.pow(center.z, 2));
center.x /= length;
center.y /= length;
center.z /= length;
GLU.gluLookAt(eye.x, eye.y, eye.z, center.x, center.y, center.z, upVector.x, upVector.y, upVector.z);
}
}
class Vektor{
float x=0;
float y=0;
float z=0;
}
|
Ich glaube, dass es an dem LookAt liegt, muss ich dafür noch etwas Besonderes aktivieren, dass es funktioniert?
Danke schonmal.
Mfg,
Mick