com.jogamp.opengl.math.Quaternion Java Examples

The following examples show how to use com.jogamp.opengl.math.Quaternion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClearVolumeRendererBase.java    From clearvolume with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setQuaternion(Quaternion pQuaternion)
{
  getDisplayLock().lock();
  try
  {
    if (mLastAppliedQuaternion == null
        || pQuaternion.getX() != mLastAppliedQuaternion.getX()
        || pQuaternion.getY() != mLastAppliedQuaternion.getY()
        || pQuaternion.getZ() != mLastAppliedQuaternion.getZ()
        || pQuaternion.getW() != mLastAppliedQuaternion.getW())
    {
      mRotationQuaternion.set(pQuaternion);
      notifyChangeOfVolumeRenderingParameters();
      mLastAppliedQuaternion = pQuaternion;
    }
  }
  finally
  {
    if (getDisplayLock().isHeldByCurrentThread())
      getDisplayLock().unlock();
  }
}
 
Example #2
Source File: ClearGLVolumeRenderer.java    From clearvolume with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void applyControllersTransform()
{
  if (getRotationControllers().size() > 0)
  {
    final Quaternion lQuaternion = new Quaternion();

    for (final RotationControllerInterface lRotationController : getRotationControllers())
      if (lRotationController.isActive())
      {
        if (lRotationController instanceof RotationControllerWithRenderNotification)
        {
          final RotationControllerWithRenderNotification lRenderNotification =
                                                                             (RotationControllerWithRenderNotification) lRotationController;
          lRenderNotification.notifyRender(this);
        }
        lQuaternion.mult(lRotationController.getQuaternion());

        notifyChangeOfVolumeRenderingParameters();
      }

    lQuaternion.mult(getQuaternion());
    setQuaternion(lQuaternion);
  }
}
 
Example #3
Source File: QuaternionRotationControllerBase.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Sets the quaternion.
 * 
 * @param pQuaternion
 *            quaternion
 */
@Override
public void setQuaternion(final Quaternion pQuaternion)
{
	synchronized (mQuaternionUpdateLock)
	{
		mQuaternion.setX(pQuaternion.getX());
		mQuaternion.setY(pQuaternion.getY());
		mQuaternion.setZ(pQuaternion.getZ());
		mQuaternion.setW(pQuaternion.getW());
	}
}
 
Example #4
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
private void transformShape(final PMVMatrix pmv, final UIShape uiShape) {
    final float[] uiTranslate = uiShape.getTranslate();
    pmv.glTranslatef(uiTranslate[0], uiTranslate[1], uiTranslate[2]);
    // final float dz = 100f;

    final Quaternion quat = uiShape.getRotation();
    final boolean rotate = !quat.isIdentity();
    final float[] uiScale = uiShape.getScale();
    final boolean scale = !VectorUtil.isVec3Equal(uiScale, 0, VectorUtil.VEC3_ONE, 0, FloatUtil.EPSILON);
    if( rotate || scale ) {
        final float[] rotOrigin = uiShape.getRotationOrigin();
        final boolean pivot = !VectorUtil.isVec3Zero(rotOrigin, 0, FloatUtil.EPSILON);
        // pmv.glTranslatef(0f, 0f, dz);
        if( pivot ) {
            pmv.glTranslatef(rotOrigin[0], rotOrigin[1], rotOrigin[2]);
        }
        if( scale ) {
            pmv.glScalef(uiScale[0], uiScale[1], uiScale[2]);
        }
        if( rotate ) {
            pmv.glRotate(quat);
        }
        if( pivot ) {
            pmv.glTranslatef(-rotOrigin[0], -rotOrigin[1], -rotOrigin[2]);
        }
        // pmv.glTranslatef(0f, 0f, -dz);
    }
}
 
Example #5
Source File: ClearVolumeRendererBase.java    From clearvolume with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Quaternion getQuaternion()
{
  return new Quaternion(mRotationQuaternion);
}
 
Example #6
Source File: QuaternionRotationControllerBase.java    From clearvolume with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Returns a copy of the currently used quaternion.
 * 
 * @return quaternion
 */
@Override
public Quaternion getQuaternion()
{
	return mQuaternion;
}
 
Example #7
Source File: AutoRotationController.java    From clearvolume with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Returns a copy of the currently used quaternion.
 * 
 * @return quaternion
 */
@Override
public Quaternion getQuaternion()
{
	return super.getQuaternion();
}
 
Example #8
Source File: ClearVolumeRendererInterface.java    From clearvolume with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Returns the Quaternion.
 *
 * @return Quaternion
 */
public Quaternion getQuaternion();
 
Example #9
Source File: ClearVolumeRendererInterface.java    From clearvolume with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Copies the given Quaternion to the current Quaternion values.
 * 
 * @param pQuaternion
 */
void setQuaternion(Quaternion pQuaternion);
 
Example #10
Source File: RotationControllerInterface.java    From clearvolume with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Sets the current Quaternion
 * 
 * @param pQuaternion
 */
void setQuaternion(final Quaternion pQuaternion);
 
Example #11
Source File: RotationControllerInterface.java    From clearvolume with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Returns the current Quaternion
 * 
 * @return current quaternion
 */
Quaternion getQuaternion();
 
Example #12
Source File: UIShape.java    From jogl-samples with MIT License votes vote down vote up
public final Quaternion getRotation() { return rotation; }