コード例 #1
0
TEST(AnimationTranslationUtilTest, transformsWork)
{
    TransformOperations ops;
    WebTransformOperationsMock outOps;

    EXPECT_CALL(outOps, appendTranslate(2, 0, 0));
    EXPECT_CALL(outOps, appendRotate(0.1, 0.2, 0.3, 200000.4));
    EXPECT_CALL(outOps, appendScale(50.2, 100, -4));

    ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TranslateX));
    ops.operations().append(RotateTransformOperation::create(0.1, 0.2, 0.3, 200000.4, TransformOperation::Rotate3D));
    ops.operations().append(ScaleTransformOperation::create(50.2, 100, -4, TransformOperation::Scale3D));
    toWebTransformOperations(ops, &outOps);
}
コード例 #2
0
ファイル: cell.cpp プロジェクト: cdenix/ps3-mame-0125
void setSizeV(float direction) {
	float size = scaler.getY();
	float value = size;
	size += direction * 0.01f;
	if (size < 0.6f) {
		size = 0.6f;
	} else
	if (size > 1.5f) {
		size = 1.5f;
	}
	if (value != size) {
		scaler.setY(size);
		modelMatrix = appendScale(modelMatrixBase, scaler);
	}
}
コード例 #3
0
ファイル: object.cpp プロジェクト: whztt07/Magic3D-2
void Magic3D::Object::updateMatrix()
{
    if (getRigidBody())
    {
        btTransform transform;
        getRigidBody()->getMotionState()->getWorldTransform(transform);
        btQuaternion q = transform.getRotation();
        btVector3    v = transform.getOrigin();

        if (getShapeRotation().getX() != 0.0f || getShapeRotation().getY() != 0.0f || getShapeRotation().getZ() != 0.0f)
        {
            rotation = Quaternion(q.getX(), q.getY(), getRender() == eRENDER_2D ? -q.getZ() : q.getZ(), q.getW());
        }
        if (getRender() == eRENDER_2D)
        {
            position = Vector3((v.getX() + 1.0f - 1.0f), -(v.getY() + 1.0f - 1.0f), 0.0f);
        }
        else
        {
            position = Vector3(v.getX(), v.getY(), v.getZ());
        }

        matrix = Matrix4(rotation, position) * Matrix4(Matrix3::identity(), -getShapePosition());
    }
    else
    {
        matrix = Matrix4(rotation, position);
    }

    matrix = appendScale(matrix, scale);

    upward    = matrix.getCol1().getXYZ();
    forward   = matrix.getCol2().getXYZ();
    rightward = cross(forward, upward);

    std::vector<Object*>::const_iterator it_o = children.begin();
    while (it_o != children.end())
    {
        (*it_o++)->needTransform = true;
    }

    if (isNetworkSpawn())
    {
        Network::getInstance()->sendObject(this, false);
    }
    needUpdateOctree = true;
}
コード例 #4
0
ファイル: Matrix3D.cpp プロジェクト: BobLChen/opengl-es-2d-3d
void Matrix3D::recompose(const Vector3D *components) {
    identity();
    appendScale(components[2].x, components[2].y, components[2].z);
    
    float angle = -components[1].x;
    float v[] = {1, 0, 0, 0, 0, cosf(angle), -sinf(angle), 0, 0, sinf(angle), cosf(angle), 0, 0, 0, 0 , 0};
    _mt.copyRawDataFrom(v);
    append(_mt);
    
    angle = -components[1].y;
    float v0[] = {cosf(angle), 0, sinf(angle), 0, 0, 1, 0, 0, -sinf(angle), 0, cosf(angle), 0, 0, 0, 0, 0};
    _mt.copyRawDataFrom(v0);
    append(_mt);
    
    angle = -components[1].z;
    float v1[] = {cosf(angle), -sinf(angle), 0, 0, sinf(angle), cosf(angle), 0, 0, 0, 0, 1, 0, 0, 0, 0, 0};
    _mt.copyRawDataFrom(v1);
    append(_mt);
    
    setPosition(components[0]);
    rawData[15] = 1.0f;
}
コード例 #5
0
ファイル: object.cpp プロジェクト: whztt07/Magic3D-2
Magic3D::Matrix4 Magic3D::Object::getMatrixFromParent()
{
    Matrix4 m = getMatrix();

    if (getParent())
    {
        m = getParent()->getMatrixFromParent();

        if (getParentBone())
        {
            m = m * getParentBone()->getMatrixFromParent();
        }

        if (isParentPosition() && isParentRotation() && isParentScale())
        {
            m = m * getMatrix();
        }
        else
        {
            Vector3 tmpPos = m.getTranslation();
            Matrix3 mRot = m.getUpper3x3();
            Vector3 tmpScale  = Vector3(length(mRot.getCol0()), length(mRot.getCol1()), length(mRot.getCol2()));

            mRot.setCol0(normalize(mRot.getCol0()));
            mRot.setCol1(normalize(mRot.getCol1()));
            mRot.setCol2(normalize(mRot.getCol2()));

            m = Matrix4::identity();

            if (isParentRotation())
            {
                m = m * Matrix4(mRot, Vector3(0.0f, 0.0f, 0.0f));
            }

            if (isParentPosition())
            {
                m.setTranslation(tmpPos);
            }

            if (isParentScale())
            {
                m = appendScale(m, tmpScale); // Faster than creating and multiplying a scale transformation matrix.
            }

            m = m * getMatrix();
        }
    }

    if (billboard != eBILLBOARD_NONE)
    {
        Camera* camera = Renderer::getInstance()->getCurrentViewPort()->getPerspective();
        Matrix3 view = camera->getView().getUpper3x3();
        Matrix3 bb = Matrix3::identity();

        switch (billboard)
        {
            case eBILLBOARD_HORIZONTAL:
            {
                Vector3 v1 = Vector3(1.0f, 0.0f, 0.0f);
                Vector3 v2 = view.getCol0();

                float angle = Math::angle(v1, v2, Vector3(0.0f, 1.0f, 0.0f));

                bb = Matrix3::rotationY(angle);
                break;
            }
            case eBILLBOARD_VERTICAL:
            {
                Vector3 v1 = Vector3(0.0f, 1.0f, 0.0f);
                Vector3 v2 = view.getCol1();

                float angle = Math::angle(v1, v2, Vector3(1.0f, 0.0f, 0.0f));

                bb = Matrix3::rotationX(angle);
                break;
            }
            default:
            {
                bb = view;
                break;
            }            
        }

        bb = inverse(m.getUpper3x3()) * inverse(bb);

        m = m * Matrix4(bb, Vector3(0.0f, 0.0f, 0.0f));
    }

    return m;
}
コード例 #6
0
ファイル: cell.cpp プロジェクト: cdenix/ps3-mame-0125
void updateModelMatrix() {
	modelMatrix = appendScale(modelMatrixBase, scaler);
	modelMatrix.setTranslation(translator);
}
コード例 #7
0
ファイル: Matrix4x4.hpp プロジェクト: Vintage12/minko
			inline
			Ptr
			appendScale(float scale)
			{
				return appendScale(scale, scale, scale);
			}