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

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

Introduction

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

Prototype

public float getRoll() 

Source Link

Document

Get the roll euler angle in degrees, which is the rotation around the z axis.

Usage

From source file:com.mbrlabs.mundus.ui.modules.inspector.TransformWidget.java

License:Apache License

private void setupListeners() {
    final ProjectContext projectContext = projectManager.current();

    // position// w  ww.j a  va 2s . c  o m
    posX.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            GameObject go = projectContext.currScene.currentSelection;
            if (go == null)
                return;
            TranslateCommand command = new TranslateCommand(go);
            Vector3 pos = go.getLocalPosition(tempV3);
            command.setBefore(pos);
            go.setLocalPosition(posX.getFloat(), pos.y, pos.z);
            command.setAfter(go.getLocalPosition(tempV3));
            history.add(command);
        }
    });
    posY.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            GameObject go = projectContext.currScene.currentSelection;
            if (go == null)
                return;
            TranslateCommand command = new TranslateCommand(go);
            Vector3 pos = go.getLocalPosition(tempV3);
            command.setBefore(pos);
            go.setLocalPosition(pos.x, posY.getFloat(), pos.z);
            command.setAfter(go.getLocalPosition(tempV3));
            history.add(command);
        }
    });
    posZ.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            GameObject go = projectContext.currScene.currentSelection;
            if (go == null)
                return;
            TranslateCommand command = new TranslateCommand(go);
            Vector3 pos = go.getLocalPosition(tempV3);
            command.setBefore(pos);
            go.setLocalPosition(pos.x, pos.y, posZ.getFloat());
            command.setAfter(go.getLocalPosition(tempV3));
            history.add(command);
        }
    });

    // rotation
    rotX.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            GameObject go = projectContext.currScene.currentSelection;
            if (go == null)
                return;
            Quaternion rot = go.getLocalRotation(tempQuat);
            RotateCommand rotateCommand = new RotateCommand(go);
            rotateCommand.setBefore(rot);
            rot.setEulerAngles(rot.getYaw(), rotX.getFloat(), rot.getRoll());
            go.setLocalRotation(rot.x, rot.y, rot.z, rot.w);
            rotateCommand.setAfter(go.getLocalRotation(tempQuat));
            history.add(rotateCommand);
        }
    });
    rotY.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            GameObject go = projectContext.currScene.currentSelection;
            if (go == null)
                return;
            Quaternion rot = go.getLocalRotation(tempQuat);
            RotateCommand rotateCommand = new RotateCommand(go);
            rotateCommand.setBefore(rot);
            rot.setEulerAngles(rotY.getFloat(), rot.getPitch(), rot.getRoll());
            go.setLocalRotation(rot.x, rot.y, rot.z, rot.w);
            rotateCommand.setAfter(go.getLocalRotation(tempQuat));
            history.add(rotateCommand);
        }
    });
    rotZ.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            GameObject go = projectContext.currScene.currentSelection;
            if (go == null)
                return;
            Quaternion rot = go.getLocalRotation(tempQuat);
            RotateCommand rotateCommand = new RotateCommand(go);
            rotateCommand.setBefore(rot);
            rot.setEulerAngles(rot.getYaw(), rot.getPitch(), rotZ.getFloat());
            go.setLocalRotation(rot.x, rot.y, rot.z, rot.w);
            rotateCommand.setAfter(go.getLocalRotation(tempQuat));
            history.add(rotateCommand);
        }
    });

    // scale
    scaleX.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            GameObject go = projectContext.currScene.currentSelection;
            if (go != null && scaleX.getFloat() > 0f) {
                ScaleCommand command = new ScaleCommand(go);
                Vector3 scl = go.getLocalScale(tempV3);
                command.setBefore(scl);
                go.setLocalScale(scaleX.getFloat(), scl.y, scl.z);
                command.setAfter(go.getLocalScale(tempV3));
                history.add(command);
            }
        }
    });
    scaleY.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            GameObject go = projectContext.currScene.currentSelection;
            if (go != null && scaleY.getFloat() > 0f) {
                ScaleCommand command = new ScaleCommand(go);
                Vector3 scl = go.getLocalScale(tempV3);
                command.setBefore(scl);
                go.setLocalScale(scl.x, scaleY.getFloat(), scl.z);
                command.setAfter(go.getLocalScale(tempV3));
                history.add(command);
            }
        }
    });
    scaleZ.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            GameObject go = projectContext.currScene.currentSelection;
            if (go != null && scaleZ.getFloat() > 0f) {
                ScaleCommand command = new ScaleCommand(go);
                Vector3 scl = go.getLocalScale(tempV3);
                command.setBefore(scl);
                go.setLocalScale(scl.x, scl.y, scaleZ.getFloat());
                command.setAfter(go.getLocalScale(tempV3));
                history.add(command);
            }
        }
    });

}

From source file:com.mbrlabs.mundus.ui.modules.inspector.TransformWidget.java

License:Apache License

@Override
public void setValues(GameObject go) {
    Vector3 pos = go.getLocalPosition(tempV3);
    posX.setText(StringUtils.formatFloat(pos.x, 2));
    posY.setText(StringUtils.formatFloat(pos.y, 2));
    posZ.setText(StringUtils.formatFloat(pos.z, 2));

    Quaternion rot = go.getLocalRotation(tempQuat);
    rotX.setText(StringUtils.formatFloat(rot.getPitch(), 2));
    rotY.setText(StringUtils.formatFloat(rot.getYaw(), 2));
    rotZ.setText(StringUtils.formatFloat(rot.getRoll(), 2));

    Vector3 scl = go.getLocalScale(tempV3);
    scaleX.setText(StringUtils.formatFloat(scl.x, 2));
    scaleY.setText(StringUtils.formatFloat(scl.y, 2));
    scaleZ.setText(StringUtils.formatFloat(scl.z, 2));
}