コード例 #1
0
ファイル: Imath.py プロジェクト: yjcnbnbnb200/cortex
    def testSlerpStability(self):

        q1 = imath.Quatd(
            0.60477471085951961527,
            0.19082800913200048676,
            -0.73048263950686898038,
            0.25343112163777203882,
        )
        q2 = imath.Quatd(
            0.6047747108595192822,
            0.190828009132000459,
            -0.73048263950686909141,
            0.25343112163777264945,
        )

        q3 = q1.slerp(q2, 0.5)

        self.assert_(q1.v().equalWithAbsError(q3.v(), 0.000000000000001))
        self.assertAlmostEqual(q1.r(), q3.r(), 14)
コード例 #2
0
    def test(self):

        tm = IECore.TransformationMatrixfData()
        p = IECore.TransformationMatrixfParameter(
            name="f",
            description="d",
            defaultValue=tm,
        )
        p.validate()

        self.assertEqual(p.name, "f")
        self.assertEqual(p.description, "d")
        self.assertEqual(p.valueValid()[0], True)

        self.assertTrue(isinstance(p.getTypedValue().translate, imath.V3f))
        self.assertEqual(p.getTypedValue().translate, imath.V3f(0, 0, 0))
        self.assertEqual(p.getTypedValue().rotate, imath.Eulerf(0, 0, 0))
        self.assertEqual(p.getTypedValue().rotationOrientation,
                         imath.Quatf(1, 0, 0, 0))
        self.assertEqual(p.getTypedValue().scale, imath.V3f(1, 1, 1))
        self.assertEqual(p.getTypedValue().shear, imath.V3f(0, 0, 0))
        self.assertEqual(p.getTypedValue().rotatePivot, imath.V3f(0, 0, 0))
        self.assertEqual(p.getTypedValue().rotatePivotTranslation,
                         imath.V3f(0, 0, 0))
        self.assertEqual(p.getTypedValue().scalePivot, imath.V3f(0, 0, 0))
        self.assertEqual(p.getTypedValue().scalePivotTranslation,
                         imath.V3f(0, 0, 0))

        tm = IECore.TransformationMatrixdData()
        p = IECore.TransformationMatrixdParameter(
            name="f",
            description="d",
            defaultValue=tm,
        )
        p.validate()

        self.assertEqual(p.name, "f")
        self.assertEqual(p.description, "d")
        self.assertEqual(p.valueValid()[0], True)

        self.assertTrue(isinstance(p.getTypedValue().translate, imath.V3d))
        self.assertEqual(p.getTypedValue().translate, imath.V3d(0, 0, 0))
        self.assertEqual(p.getTypedValue().rotate, imath.Eulerd(0, 0, 0))
        self.assertEqual(p.getTypedValue().rotationOrientation,
                         imath.Quatd(1, 0, 0, 0))
        self.assertEqual(p.getTypedValue().scale, imath.V3d(1, 1, 1))
        self.assertEqual(p.getTypedValue().shear, imath.V3d(0, 0, 0))
        self.assertEqual(p.getTypedValue().rotatePivot, imath.V3d(0, 0, 0))
        self.assertEqual(p.getTypedValue().rotatePivotTranslation,
                         imath.V3d(0, 0, 0))
        self.assertEqual(p.getTypedValue().scalePivot, imath.V3d(0, 0, 0))
        self.assertEqual(p.getTypedValue().scalePivotTranslation,
                         imath.V3d(0, 0, 0))
コード例 #3
0
 def testAttributes(self):
     """Test TransformationMatrixd attributes"""
     a = IECore.TransformationMatrixd()
     self.assertEqual(a.scalePivot, imath.V3d(0, 0, 0))
     self.assertEqual(a.scale, imath.V3d(1, 1, 1))
     self.assertEqual(a.shear, imath.V3d(0, 0, 0))
     self.assertEqual(a.scalePivotTranslation, imath.V3d(0, 0, 0))
     self.assertEqual(a.rotatePivot, imath.V3d(0, 0, 0))
     self.assertEqual(a.rotationOrientation, imath.Quatd())
     self.assertEqual(a.rotate, imath.Eulerd())
     self.assertEqual(a.rotatePivotTranslation, imath.V3d(0, 0, 0))
     self.assertEqual(a.translate, imath.V3d(0, 0, 0))
     try:
         a.transform = 1
     except:
         pass
     else:
         raise Exception("Should not be able to set transform.")
コード例 #4
0
    def testTypeConvertion(self):

        self.assertEqual(
            IECore.DataCastOp()(object=IECore.FloatData(2),
                                targetType=int(IECore.TypeId.DoubleData)),
            IECore.DoubleData(2))
        self.assertEqual(
            IECore.DataCastOp()(object=IECore.DoubleData(2),
                                targetType=int(IECore.TypeId.FloatData)),
            IECore.FloatData(2))
        self.assertEqual(
            IECore.DataCastOp()(object=IECore.IntData(2),
                                targetType=int(IECore.TypeId.UIntData)),
            IECore.UIntData(2))
        self.assertEqual(
            IECore.DataCastOp()(object=IECore.V3fData(imath.V3f(2)),
                                targetType=int(IECore.TypeId.V3dData)),
            IECore.V3dData(imath.V3d(2)))
        self.assertEqual(
            IECore.DataCastOp()(object=IECore.QuatfData(imath.Quatf(
                1, 2, 3, 4)),
                                targetType=int(IECore.TypeId.QuatdData)),
            IECore.QuatdData(imath.Quatd(1, 2, 3, 4)))
コード例 #5
0
ファイル: USDSceneTest.py プロジェクト: SimonForgot/cortex
    def testPrimVarTypes(self):

        root = IECoreScene.SceneInterface.create(
            os.path.dirname(__file__) + "/data/primVars.usda",
            IECore.IndexedIO.OpenMode.Read)

        object = root.child("root").child("sphere").readObject(0.0)

        expected = {
            'test_Bool_Scalar_constant':
            IECore.BoolData(0),
            'test_Double2_Array_constant':
            IECore.V2dVectorData([
                imath.V2d(1.1, 1.2),
                imath.V2d(2.1, 2.2),
                imath.V2d(3.1, 3.2)
            ]),
            'test_Double2_Scalar_constant':
            IECore.V2dData(imath.V2d(0.1, 0.2)),
            'test_Double3_Array_constant':
            IECore.V3dVectorData([
                imath.V3d(1.1, 1.2, 1.3),
                imath.V3d(2.1, 2.2, 2.3),
                imath.V3d(3.1, 3.2, 3.3)
            ]),
            'test_Double3_Scalar_constant':
            IECore.V3dData(imath.V3d(0.1, 0.2, 0.3)),
            'test_Double_Array_constant':
            IECore.DoubleVectorData([1.2, 1.3, 1.4]),
            'test_Double_Scalar_constant':
            IECore.DoubleData(1.1),
            'test_Float2_Array_constant':
            IECore.V2fVectorData([
                imath.V2f(1.1, 1.2),
                imath.V2f(2.1, 2.2),
                imath.V2f(3.1, 3.2)
            ]),
            'test_Float2_Scalar_constant':
            IECore.V2fData(imath.V2f(0.1, 0.2)),
            'test_Float3_Array_constant':
            IECore.V3fVectorData([
                imath.V3f(1.1, 1.2, 1.3),
                imath.V3f(2.1, 2.2, 2.3),
                imath.V3f(3.1, 3.2, 3.3)
            ]),
            'test_Float3_Scalar_constant':
            IECore.V3fData(imath.V3f(0.1, 0.2, 0.3)),
            'test_Float_Array_constant':
            IECore.FloatVectorData([0.7, 0.8, 0.9]),
            'test_Float_Scalar_constant':
            IECore.FloatData(0.6),
            'test_Half_Array_constant':
            IECore.HalfVectorData([0.0999756, 0.199951, 0.300049]),
            'test_Half_Scalar_constant':
            IECore.HalfData(0.5),
            'test_Int2_Array_constant':
            IECore.V2iVectorData(
                [imath.V2i(3, 4),
                 imath.V2i(5, 6),
                 imath.V2i(7, 8)]),
            'test_Int2_Scalar_constant':
            IECore.V2iData(imath.V2i(1, 2)),
            'test_Int3_Array_constant':
            IECore.V3iVectorData(
                [imath.V3i(3, 4, 5),
                 imath.V3i(5, 6, 7),
                 imath.V3i(7, 8, 9)]),
            'test_Int3_Scalar_constant':
            IECore.V3iData(imath.V3i(1, 2, 3)),
            'test_Int64_Array_constant':
            IECore.Int64VectorData([
                9223372036854775805, 9223372036854775806, 9223372036854775807
            ]),
            'test_Int64_Scalar_constant':
            IECore.Int64Data(-9223372036854775808),
            'test_Int_Array_constant':
            IECore.IntVectorData([0, -1, -2]),
            'test_Int_Scalar_constant':
            IECore.IntData(-1),
            'test_String_Array_constant':
            IECore.StringVectorData(["is", "a", "test"]),
            'test_String_Scalar_constant':
            IECore.StringData('this'),
            'test_Token_Array_constant':
            IECore.InternedStringVectorData([
                IECore.InternedString("t-is"),
                IECore.InternedString("t-a"),
                IECore.InternedString("t-test")
            ]),
            'test_Token_Scalar_constant':
            IECore.InternedStringData(IECore.InternedString("t-this")),
            'test_UChar_Array_constant':
            IECore.UCharVectorData([0, 1, 2]),
            'test_UChar_Scalar_constant':
            IECore.UCharData(0),
            'test_UInt64_Array_constant':
            IECore.UInt64VectorData([
                18446744073709551613, 18446744073709551614,
                18446744073709551615
            ]),
            'test_UInt64_Scalar_constant':
            IECore.UInt64Data(18446744073709551615),
            'test_UInt_Array_constant':
            IECore.UIntVectorData([4294967293, 4294967294, 4294967295]),
            'test_UInt_Scalar_constant':
            IECore.UIntData(4294967295),
            #'test_color3d_Array_constant' : IECore.Color3dVectorData([IECore.Color3d(1.1, 1.2, 1.3), IECore.Color3d(2.1, 2.2, 2.3), IECore.Color3d(3.1, 3.2, 3.3)]),
            #'test_color3d_Scalar_constant' : IECore.Color3dData(IECore.Color3d(0.1, 0.2, 0.3)),
            'test_color3f_Array_constant':
            IECore.Color3fVectorData([
                imath.Color3f(1.1, 1.2, 1.3),
                imath.Color3f(2.1, 2.2, 2.3),
                imath.Color3f(3.1, 3.2, 3.3)
            ]),
            'test_color3f_Scalar_constant':
            IECore.Color3fData(imath.Color3f(0.1, 0.2, 0.3)),
            #'test_color4d_Array_constant' : IECore.Color4dVectorData([IECore.Color4d(1.1, 1.2, 1.3, 1.4), IECore.Color4d(2.1, 2.2, 2.3, 2.4), IECore.Color4d(3.1, 3.2, 3.3, 3.4)]),
            #'test_color4d_Scalar_constant' : IECore.Color4dData(IECore.Color4d(0.1, 0.2, 0.3, 0.4)),
            'test_color4f_Array_constant':
            IECore.Color4fVectorData([
                imath.Color4f(1.1, 1.2, 1.3, 1.4),
                imath.Color4f(2.1, 2.2, 2.3, 2.4),
                imath.Color4f(3.1, 3.2, 3.3, 3.4)
            ]),
            'test_color4f_Scalar_constant':
            IECore.Color4fData(imath.Color4f(0.1, 0.2, 0.3, 0.4)),
            'test_matrix3d_Array_constant':
            IECore.M33dVectorData([
                imath.M33d(0, 0, 0, 0, 1, 0, 0, 0, 0),
                imath.M33d(0, 0, 0, 0, 0, 0, 0, 0, 2),
                imath.M33d(0, 0, 4, 0, 0, 0, 0, 0, 0)
            ]),
            'test_matrix3d_Scalar_constant':
            IECore.M33dData(imath.M33d(0, 0, 0, 0, 0, 0, 0, 0, 0)),
            'test_matrix4d_Array_constant':
            IECore.M44dVectorData([
                imath.M44d(1, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0),
                imath.M44d(1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                imath.M44d(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0)
            ]),
            'test_matrix4d_Scalar_constant':
            IECore.M44dData(
                imath.M44d(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)),
            'test_normal3d_Array_constant':
            IECore.V3dVectorData([
                imath.V3d(1.1, 1.2, 1.3),
                imath.V3d(2.1, 2.2, 2.3),
                imath.V3d(3.1, 3.2, 3.3)
            ]),
            'test_normal3d_Scalar_constant':
            IECore.V3dData(imath.V3d(0.1, 0.2, 0.3)),
            'test_normal3f_Array_constant':
            IECore.V3fVectorData([
                imath.V3f(1.1, 1.2, 1.3),
                imath.V3f(2.1, 2.2, 2.3),
                imath.V3f(3.1, 3.2, 3.3)
            ]),
            'test_normal3f_Scalar_constant':
            IECore.V3fData(imath.V3f(0.1, 0.2, 0.3)),
            'test_point3d_Array_constant':
            IECore.V3dVectorData([
                imath.V3d(1.1, 1.2, 1.3),
                imath.V3d(2.1, 2.2, 2.3),
                imath.V3d(3.1, 3.2, 3.3)
            ]),
            'test_point3d_Scalar_constant':
            IECore.V3dData(imath.V3d(0.1, 0.2, 0.3)),
            'test_point3f_Array_constant':
            IECore.V3fVectorData([
                imath.V3f(1.1, 1.2, 1.3),
                imath.V3f(2.1, 2.2, 2.3),
                imath.V3f(3.1, 3.2, 3.3)
            ]),
            'test_point3f_Scalar_constant':
            IECore.V3fData(imath.V3f(0.1, 0.2, 0.3)),
            'test_quatd_Array_constant':
            IECore.QuatdVectorData([
                imath.Quatd(1, 0, 0, 0),
                imath.Quatd(0, 1, 0, 0),
                imath.Quatd(0, 0, 1, 0)
            ]),
            'test_quatd_Scalar_constant':
            IECore.QuatdData(imath.Quatd(0, 0, 0, 1)),
            'test_quatf_Array_constant':
            IECore.QuatfVectorData([
                imath.Quatf(1, 0, 0, 0),
                imath.Quatf(0, 1, 0, 0),
                imath.Quatf(0, 0, 1, 0)
            ]),
            'test_quatf_Scalar_constant':
            IECore.QuatfData(imath.Quatf(0, 0, 0, 1)),
            'test_vector3d_Array_constant':
            IECore.V3dVectorData([
                imath.V3d(1.1, 1.2, 1.3),
                imath.V3d(2.1, 2.2, 2.3),
                imath.V3d(3.1, 3.2, 3.3)
            ]),
            'test_vector3d_Scalar_constant':
            IECore.V3dData(imath.V3d(0.1, 0.2, 0.3)),
            'test_vector3f_Array_constant':
            IECore.V3fVectorData([
                imath.V3f(1.1, 1.2, 1.3),
                imath.V3f(2.1, 2.2, 2.3),
                imath.V3f(3.1, 3.2, 3.3)
            ]),
            'test_vector3f_Scalar_constant':
            IECore.V3fData(imath.V3f(0.1, 0.2, 0.3)),
        }

        for primVarName, primVarExpectedValue in expected.items():
            self.assertTrue(primVarName in object.keys())
            p = object[primVarName]
            self.assertEqual(p.data, primVarExpectedValue)
コード例 #6
0
def createQuatd(value):
    return imath.Quatd(value, 0, 0, 0)