Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - miron123

Pages: 1 [2]
16
Support / Rounded Cube
« on: September 17, 2012, 10:38:32 am »
Hello.
I have a small problem. In the last 4 month i tried to create a cube with rounded edges. First I tried OpenGl ES and finally I found my way to jpct-ae. Now its a imported obj file.
Problem: I try to start new Activities based on the cube side the user is looking at, but I don t want to check for all 4 rotation matrices of each cube side. So I wanted to ask if someone knows a better solution. I heard Quaternion are a good way to go, but I don t realy have a clue how they work.
Code: [Select]
public class MyMath {

public static int getVisibleCubeSide(SimpleVector vector){
int vectorX = (int) Math.round(vector.x);
int vectorY = (int) Math.round(vector.y);
int vectorZ = (int) Math.round(vector.z);
    int[][] posibilities = new int[6][4];

//klassenbuch
posibilities[0][0] = 0;
posibilities[0][1] = 0;
posibilities[0][2] = 1;
posibilities[0][3] = 2;

//studenplan
posibilities[1][0] = 0;
posibilities[1][1] = 1;
posibilities[1][2] = 0;
posibilities[1][3] = 1;

//countdown
posibilities[2][0] = 0;
posibilities[2][1] = 0;
posibilities[2][2] = -1;
posibilities[2][3] = 0;

//Lehrer
posibilities[3][0] = 0;
posibilities[3][1] = -1;
posibilities[3][2] = 0;
posibilities[3][3] = 5;

//Trainer
posibilities[4][0] = 1;
posibilities[4][1] = 0;
posibilities[4][2] = 0;
posibilities[4][3] = 4;

//new termine
posibilities[5][0] = -1;
posibilities[5][1] = 0;
posibilities[5][2] = 0;
posibilities[5][3] = 3;

//checks if the parameter vector equals one of the vectors above
for(int i = 0; i < 6; i++){
if(vectorX == posibilities[i][0] && vectorY == posibilities[i][1] && vectorZ == posibilities[i][2]){
Log.i("side", "v" + vector.toString());
Log.i("side", "s: " + posibilities[i][3]);
return posibilities[i][3];
}
}

Log.i("side", "" + -1);
return -1;
}
Thats how i calculate my cube side atm. but it s not always correct cause i only check for one rotation matrix for each side but each side has 4 rotation matrices.
So I hope somebody has a good idea how to calculate the cube side based on matrices.

Pages: 1 [2]