本文整理汇总了Java中com.google.vr.sdk.base.HeadTransform.getForwardVector方法的典型用法代码示例。如果您正苦于以下问题:Java HeadTransform.getForwardVector方法的具体用法?Java HeadTransform.getForwardVector怎么用?Java HeadTransform.getForwardVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.vr.sdk.base.HeadTransform
的用法示例。
在下文中一共展示了HeadTransform.getForwardVector方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import com.google.vr.sdk.base.HeadTransform; //导入方法依赖的package包/类
@Override
public void update(HeadTransform headTransform) {
float[] forwardVec = new float[3];
float[] upVec = new float[3];
float[] rightVec = new float[3];
headTransform.getForwardVector(forwardVec, 0);
headTransform.getUpVector(upVec, 0);
headTransform.getRightVector(rightVec, 0);
// create m in column major order
// invert forward vec because in opengl -z is forward
float[] m = new float[] {
rightVec[0], upVec[0], -forwardVec[0], 0.0f,
rightVec[1], upVec[1], -forwardVec[1], 0.0f,
rightVec[2], upVec[2], -forwardVec[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
// a = M^T * b where b is vector representation in cardboard basis
float[] mt = new float[16];
Matrix.transposeM(mt, 0, m, 0);
mModelScreen = mt;
}
示例2: getCardboardToWorldTransform
import com.google.vr.sdk.base.HeadTransform; //导入方法依赖的package包/类
/**
* Calculates a column-major transformation matrix that will transform a vector in the basis
* formed by the Google cardboard (up, right, and forward vector from the HeadTransform)
* to the world system (right-handed for OpenGL). I.e., given the returned matrix M, and a vector b in cardboard coordinates,
* then a = M * b where a is in world coordinates.
* @param M The 4x4 matrix to place the transformation in.
* @param headTransform The head transform to form the transformation from
*/
public static void getCardboardToWorldTransform(float[] M, HeadTransform headTransform) {
if (M.length != 16) {
throw new IllegalArgumentException("Destination matrix array must be 4x4 (length 16)!");
}
float[] forwardVec = new float[3];
float[] upVec = new float[3];
float[] rightVec = new float[3];
headTransform.getForwardVector(forwardVec, 0);
headTransform.getUpVector(upVec, 0);
headTransform.getRightVector(rightVec, 0);
// transform to world coordinates from camera
// create m in column major order
// invert forward vec because in opengl -z is forward
float[] m = new float[] {
rightVec[0], upVec[0], -forwardVec[0], 0.0f,
rightVec[1], upVec[1], -forwardVec[1], 0.0f,
rightVec[2], upVec[2], -forwardVec[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
// a = m^T * b where b is vector representation in camera (cardboard) basis
Matrix.transposeM(M, 0, m, 0);
}
示例3: onNewFrame
import com.google.vr.sdk.base.HeadTransform; //导入方法依赖的package包/类
/**
* Prepares OpenGL ES before we draw a frame.
*
* @param headTransform The head transformation in the new frame.
*/
@Override
public void onNewFrame(HeadTransform headTransform) {
//rotate the cube, mangle is how fast, x,y,z which directions it rotates.
Matrix.rotateM(mRotationMatrix, 0, mAngle, 0.7f, 0.7f, 1.0f);
if (moving) {
//so figure out which direction we are facing, using the forward normalized vector.
headTransform.getForwardVector(forward, 0);
Log.v(TAG, "X =" + forward[0] + " Y=" + forward[1] + " Z=" + forward[2]);
MoveX = forward[0] * mSpeed;
MoveY = forward[1] * mSpeed;
MoveZ = -forward[2] * mSpeed; //-Z otherwise, going the wrong direction...
// X Y Z
//Matrix.translateM(camera, 0, 0, 0, 0.1f);
Matrix.translateM(camera, 0, MoveX, MoveY, MoveZ);
//moving = false;
}
//I don't think I need this at all.
headTransform.getHeadView(headView, 0);
}
示例4: onNewFrame
import com.google.vr.sdk.base.HeadTransform; //导入方法依赖的package包/类
@Override
public boolean onNewFrame(HeadTransform headTransform, boolean forceRedraw) {
scenes.get(sceneIndex).camera.updateViewMatrix();
headTransform.getForwardVector(forward, 0);
forwardVector.setAll(forward, 0);
// Check if we are looking to one of the two buttons
buttonLeft.checkIsLooking(scenes.get(sceneIndex).camera.getPosition(), forwardVector);
buttonRight.checkIsLooking(scenes.get(sceneIndex).camera.getPosition(), forwardVector);
// Animations
long currentTime = System.currentTimeMillis();
long timeElapsed = lastTimeStamp == -1 ? 0 : currentTime - lastTimeStamp;
lastTimeStamp = currentTime;
// First animate the buttons (it can also generate an scene change)
buttonLeft.animate(timeElapsed);
buttonRight.animate(timeElapsed);
// Now update the shown scene
if (scenes.get(sceneIndex) instanceof ObjLoaderScene) {
((ObjLoaderScene) scenes.get(sceneIndex)).update(timeElapsed);
}
return true;
}