当前位置: 首页>>代码示例>>Java>>正文


Java Matrix4f.setScale方法代码示例

本文整理汇总了Java中com.jme3.math.Matrix4f.setScale方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix4f.setScale方法的具体用法?Java Matrix4f.setScale怎么用?Java Matrix4f.setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.math.Matrix4f的用法示例。


在下文中一共展示了Matrix4f.setScale方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: changeParent

import com.jme3.math.Matrix4f; //导入方法依赖的package包/类
/**
 * Changes the parent of a prefab while keeping the world transformation of
 * the prefab.
 * @param toChange the prefab to change.
 * @param newParent the new parent of the prefab.
 * @return the local transformation of the child, relative to the new parent.
 */
public static Matrix4f changeParent(Node toChange, Node newParent) {
    Matrix4f parentMatrix = new Matrix4f();
    parentMatrix.setTranslation(newParent.getWorldTranslation());
    parentMatrix.setRotationQuaternion(newParent.getWorldRotation());
    parentMatrix.setScale(newParent.getWorldScale());
    parentMatrix.invertLocal();

    Vector3f wtrans = toChange.getWorldTranslation().clone();
    Quaternion wrot = toChange.getWorldRotation().clone();
    Vector3f wscale = toChange.getWorldScale().clone();

    Matrix4f childMatrix = new Matrix4f();
    childMatrix.setTranslation(wtrans);
    childMatrix.setRotationQuaternion(wrot);
    childMatrix.setScale(wscale);

    Matrix4f local = parentMatrix.mult(childMatrix);
    return local;
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:27,代码来源:MathUtil.java

示例2: attachChild

import com.jme3.math.Matrix4f; //导入方法依赖的package包/类
@Override
public int attachChild(Spatial child) {
    if (getParent() instanceof CharacterPath && child instanceof Waypoint) {
        Waypoint w = (Waypoint) child;
        // local transform is relative to this transform.
        // needs to be relative to parent.
        Matrix4f parentMatrix = new Matrix4f();
        parentMatrix.setTranslation(getParent().getWorldTranslation());
        parentMatrix.setRotationQuaternion(getParent().getWorldRotation());
        parentMatrix.setScale(getParent().getWorldScale());
        parentMatrix.invertLocal();

        Matrix4f childMatrix = new Matrix4f();
        childMatrix.setTranslation(child.getWorldTranslation());
        childMatrix.setRotationQuaternion(child.getWorldRotation());
        childMatrix.setScale(child.getWorldScale());

        Matrix4f local = parentMatrix.mult(childMatrix);

        child.setLocalTranslation(local.toTranslationVector());
        child.setLocalRotation(local.toRotationQuat());
        child.setLocalScale(local.toScaleVector());

        ((CharacterPath) getParent()).insertWaypointAfter(this, w);

        // child is not attached to this node.
        return -1;
    } else {
        return super.attachChild(child);
    }
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:32,代码来源:Waypoint.java

示例3: toMatrix

import com.jme3.math.Matrix4f; //导入方法依赖的package包/类
/**
 * Converts given transformation parameters into the matrix.
 * 
 * @param transform
 *            the transform to be converted
 * @return 4x4 matrix that represents the given transformation parameters
 */
private Matrix4f toMatrix(Vector3f position, Quaternion rotation, Vector3f scale) {
    Matrix4f result = new Matrix4f();
    result.setTranslation(position);
    result.setRotationQuaternion(rotation);
    result.setScale(scale);
    return result;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:15,代码来源:ConstraintHelper.java

示例4: onMouseButtonPressed

import com.jme3.math.Matrix4f; //导入方法依赖的package包/类
/**
 * Called when the mouse button is pressed.
 *
 * @param viewport the viewport where the mouse button was released.
 */
@Override
public void onMouseButtonPressed(SandboxViewport viewport) {
    if (linkState == LinkState.LINK) {
        this.currentChildElement = viewport.pick();
        viewport.addToSelection(currentChildElement);
        viewport.getRootNode().attachChild(linkGeometry);
        linkState = LinkState.LINKPARENT;
    } else if (linkState == LinkState.LINKPARENT) {
        Prefab p = viewport.pick();
        if (p == currentChildElement || p == null) {
            return;
        }

        Vector3f wtrans = currentChildElement.getWorldTranslation().clone();
        Quaternion wrot = currentChildElement.getWorldRotation().clone();
        Vector3f wscale = currentChildElement.getWorldScale().clone();

        // child element is moved from one place to another.
        ProjectTreeNode previousParent = currentChildElement.getProjectParent();
        int previousIndex = previousParent.getIndexOfChild(currentChildElement);
        p.attachChild(currentChildElement);
        // it is possible that the attachment process attaches the child somewhere else.
        // express the world transformation of the child as a local transformation in the parent space.
        Node pn = currentChildElement.getParent();
        if (pn != null) {
            Matrix4f parentMatrix = new Matrix4f();
            parentMatrix.setTranslation(pn.getWorldTranslation());
            parentMatrix.setRotationQuaternion(pn.getWorldRotation());
            parentMatrix.setScale(pn.getWorldScale());
            parentMatrix.invertLocal();

            Matrix4f childMatrix = new Matrix4f();
            childMatrix.setTranslation(wtrans);
            childMatrix.setRotationQuaternion(wrot);
            childMatrix.setScale(wscale);

            Matrix4f local = parentMatrix.mult(childMatrix);

            TransformComponent tc = (TransformComponent) currentChildElement.getComponent("TransformComponent");
            if (tc != null) {
                tc.setTranslation(local.toTranslationVector());
                tc.setRotation(local.toRotationQuat());
                tc.setScale(local.toScaleVector());
            }
        }

        // remove child from its layer
        if (previousParent instanceof Layer) {
            Layer l = (Layer) previousParent;
            l.removeNode(currentChildElement);
        }

        Level level = viewport.getLevel();
        LevelEvent le = new LevelEvent(level, EventType.NODEMOVED, currentChildElement, previousParent, previousIndex, currentChildElement.getProjectParent());
        
        GlobalObjects.getInstance().postEvent(le);

        viewport.activateIdleState(this);
        linkText.setText("");
        textBackground.setDimension(0, 0);
        textBackgroundGeometry.updateModelBound();
        linkGeometry.removeFromParent();
        wireBoxGeometryLinkParent.removeFromParent();
        currentChildElement = null;

        linkText.removeFromParent();
        textBackgroundGeometry.removeFromParent();

        linkState = linkState.LINK;
    }
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:77,代码来源:LinkTool.java


注:本文中的com.jme3.math.Matrix4f.setScale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。