/** * Rotates this object (optionally from its initial orientation) around the provided axis by the * specified angle. * * @param axis {@link Vector3} The axis or rotation. * @param angle {@code double} The angle of rotation. * @param append {@code boolean} If true, the rotation is applied to the current orientation. */ public void rotateAround(Vector3 axis, double angle, boolean append) { if (append) { mTmpOrientation.fromAngleAxis(axis, angle); mOrientation.multiply(mTmpOrientation); } else { mOrientation.fromAngleAxis(axis, angle); } markModelMatrixDirty(); }
public void setSensorOrientation(float[] quaternion) { synchronized (mCameraOrientationLock) { mCameraOrientation.x = quaternion[1]; mCameraOrientation.y = quaternion[2]; mCameraOrientation.z = quaternion[3]; mCameraOrientation.w = quaternion[0]; mScratchQuaternion1.fromAngleAxis(Axis.X, -90); mScratchQuaternion1.multiply(mCameraOrientation); mScratchQuaternion2.fromAngleAxis(Axis.Z, -90); mScratchQuaternion1.multiply(mScratchQuaternion2); mCameraOrientation.setAll(mScratchQuaternion1); } }
private void createFloor() { // // -- Load a bitmap that represents the terrain. Its color values will // be used to generate heights. // Plane mPlane = new Plane(500, 500, 100, 100); mPlane.setPosition(0, 0, 0); mPlane.setDoubleSided(true); Material material1 = new Material(); material1.setColorInfluence(0); Bitmap picTexture = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.squares_big); try { material1.addTexture(new Texture("squares", picTexture)); } catch (TextureException e) { e.printStackTrace(); } mPlane.setMaterial(material1); // Set orientation of the plane. Quaternion q = new Quaternion(); q.fromAngleAxis(Vector3.Axis.X, 90); mPlane.setOrientation(q); getCurrentScene().addChild(mPlane); try { getCurrentScene() .setSkybox( R.drawable.right, R.drawable.left, R.drawable.top, R.drawable.bottom, R.drawable.front, R.drawable.back); } catch (TextureException e) { e.printStackTrace(); } }
/** * Sets the rotation of this {@link ATransformable3D} by the rotation described by the provided * axis and angle of rotation. If this is part of a scene graph, the graph will be notified of the * change. * * @param x double The x component of the axis of rotation. * @param y double The y component of the axis of rotation. * @param z double The z component of the axis of rotation. * @param angle double The angle of rotation in degrees. * @return A reference to this {@link ATransformable3D} to facilitate chaining. */ public ATransformable3D setRotation(double x, double y, double z, double angle) { mOrientation.multiply(mTmpOrientation.fromAngleAxis(x, y, z, angle)); mLookAtValid = false; markModelMatrixDirty(); return this; }
/** * Sets the rotation of this {@link ATransformable3D} by the rotation described by the provided * {@link Vector3.Axis} cardinal axis and angle of rotation. If this is part of a scene graph, the * graph will be notified of the change. * * @param axis {@link Vector3.Axis} The axis of rotation. * @param angle double The angle of rotation in degrees. * @return A reference to this {@link ATransformable3D} to facilitate chaining. */ public ATransformable3D setRotation(final Vector3.Axis axis, double angle) { mOrientation.multiply(mTmpOrientation.fromAngleAxis(axis, angle)); mLookAtValid = false; markModelMatrixDirty(); return this; }