Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
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 |
public class Camera { private float[] matrixX=new float[16]; private float[] matrixY=new float[16]; private float[] matrixZ=new float[16]; private float[] result=new float[16]; public float rot(int pIndex){ float rot = 0; if(pIndex==0) rot=result[0]; if(pIndex==1) rot=result[5]; if(pIndex==2) rot=result[10]; return rot; } public float degreesToRadians(float pDegrees){ return pDegrees * 3.14159265f / 180 ; } public void matrixIdentity(float[] matrix) { matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.0f; matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0.0f; matrix[6] = matrix[7] = matrix[8] = matrix[9] = 0.0f; matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0.0f; } public void matrixRotateX(float degrees) { float radians = degreesToRadians(degrees); matrixIdentity(matrixX); matrixX[5] = (float)Math.cos(radians); matrixX[6] = (float)-Math.sin(radians); matrixX[9] = -matrixX[6]; matrixX[10] = matrixX[5]; } public void matrixRotateY(float degrees) { float radians = degreesToRadians(degrees); matrixIdentity(matrixY); matrixY[0] = (float)Math.cos(radians); matrixY[2] = (float)Math.sin(radians); matrixY[8] = -matrixY[2]; matrixY[10] = matrixY[0]; } public void matrixRotateZ(float degrees) { float radians = degreesToRadians(degrees); matrixIdentity(matrixZ); matrixZ[0] = (float)Math.cos(radians); matrixZ[1] = (float)Math.sin(radians); matrixZ[4] = -matrixZ[1]; matrixZ[5] = matrixZ[0]; } public void cam(){ matrixMultiply(matrixX, matrixY); matrixMultiply(result, matrixZ); } public void matrixMultiply(float[] m1, float[] m2) { result[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3]; result[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3]; result[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3]; result[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3]; result[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7]; result[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7]; result[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7]; result[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7]; result[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11]; result[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11]; result[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11]; result[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11]; result[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15]; result[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15]; result[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15]; result[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15]; } } |
Quellcode |
|
1 2 3 |
GL11.glRotatef(rot(0)*360, 1, 0, 0); GL11.glRotatef(rot(1)*360, 0, 1, 0); GL11.glRotatef(rot(2)*360, 0, 0, 1); |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »mick1114« (11.11.2011, 13:06)
Werbeanzeige