Example usage for com.badlogic.gdx.math Quaternion Quaternion

List of usage examples for com.badlogic.gdx.math Quaternion Quaternion

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Quaternion Quaternion.

Prototype

public Quaternion(Quaternion quaternion) 

Source Link

Document

Constructor, sets the quaternion components from the given quaternion.

Usage

From source file:com.mbrlabs.mundus.commons.scene3d.SimpleNode.java

License:Apache License

/**
 * Copy construction//from   ww  w .jav a2  s. c om
 * 
 * @param simpleNode
 * @param id
 */
public SimpleNode(SimpleNode simpleNode, int id) {
    super(id);
    this.localPosition = new Vector3(simpleNode.localPosition);
    this.localRotation = new Quaternion(simpleNode.localRotation);
    this.localScale = new Vector3(simpleNode.localScale);
    this.combined = new Matrix4(simpleNode.combined);
}

From source file:de.longri.cachebox3.gui.map.layer.SharedModel.java

License:Open Source License

private void copyAnimations(final Iterable<Animation> source) {
    for (final Animation anim : source) {
        Animation animation = new Animation();
        animation.id = anim.id;/*from  w ww.  java 2  s.  c o  m*/
        for (final NodeAnimation nanim : anim.nodeAnimations) {
            final Node node = getNode(nanim.node.id);
            if (node == null)
                continue;
            NodeAnimation nodeAnim = new NodeAnimation();
            nodeAnim.node = node;
            if (nanim.rotation != null) {
                nodeAnim.rotation = new Array<NodeKeyframe<Quaternion>>();
                nodeAnim.rotation.ensureCapacity(nanim.rotation.size);
                for (final NodeKeyframe<Quaternion> kf : nanim.rotation) {
                    if (kf.keytime > animation.duration)
                        animation.duration = kf.keytime;
                    nodeAnim.rotation.add(new NodeKeyframe<Quaternion>(kf.keytime,
                            new Quaternion(kf.value == null ? node.rotation : kf.value)));
                }
            }
            if (nanim.scaling != null) {
                nodeAnim.scaling = new Array<NodeKeyframe<Vector3>>();
                nodeAnim.scaling.ensureCapacity(nanim.scaling.size);
                for (final NodeKeyframe<Vector3> kf : nanim.scaling) {
                    if (kf.keytime > animation.duration)
                        animation.duration = kf.keytime;
                    nodeAnim.scaling.add(new NodeKeyframe<Vector3>(kf.keytime,
                            new Vector3(kf.value == null ? node.scale : kf.value)));
                }
            }
            if (nanim.translation != null) {
                nodeAnim.translation = new Array<NodeKeyframe<Vector3>>();
                nodeAnim.translation.ensureCapacity(nanim.translation.size);
                for (final NodeKeyframe<Vector3> kf : nanim.translation) {
                    if (kf.keytime > animation.duration)
                        animation.duration = kf.keytime;
                    nodeAnim.translation.add(new NodeKeyframe<Vector3>(kf.keytime,
                            new Vector3(kf.value == null ? node.translation : kf.value)));
                }
            }
            if ((nodeAnim.rotation != null && nodeAnim.rotation.size > 0)
                    || (nodeAnim.scaling != null && nodeAnim.scaling.size > 0)
                    || (nodeAnim.translation != null && nodeAnim.translation.size > 0))
                animation.nodeAnimations.add(nodeAnim);
        }
        if (animation.nodeAnimations.size > 0)
            animations.add(animation);
    }
}