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


C# Matrix4x4.ToString方法代码示例

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


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

示例1: OnRenderImage

		// Postprocess the image
		void OnRenderImage (RenderTexture source, RenderTexture destination)
		{
			stage += 0.02f;
			if (intensity == 0)
			{
				Graphics.Blit (source, destination);
				return;
			}
			float s1 =(Mathf.Sin(stage)+1.0f)/2.0f;
			float c1 = (Mathf.Cos (stage)+1.0f)/2.0f;
			float s2 =(Mathf.Sin(stage*1.3f+Mathf.PI)+1.0f)/2.0f;
			float c2 = (Mathf.Cos (stage*1.3f+Mathf.PI)+1.0f)/2.0f;
			material.SetFloat("_stage", intensity);
			Matrix4x4 colorMatrix= new Matrix4x4();
			colorMatrix.SetRow (0, new Vector4 (s1,c1,s2,0));
			colorMatrix.SetRow (1, new Vector4 (c2,c1,s1,0));
			colorMatrix.SetRow (2, new Vector4 (c2,s1,c1,0));
			colorMatrix.SetRow (3, new Vector4 (0,0,0,1));
			Debug.Log(colorMatrix.ToString ());
			material.SetMatrix ("_mymatrix", colorMatrix);
			Graphics.Blit (source, destination, material);
		}
开发者ID:VeryOriginalTeam,项目名称:OldGodsTheForest,代码行数:23,代码来源:trippyColorsEffect.cs

示例2: UpdateAR

	bool UpdateAR()
	{
        if (!_running) {
            return false;
        }
        
        if (!_sceneConfiguredForVideo) {
            
            // Wait for the wrapper to confirm video frames have arrived before configuring our video-dependent stuff.
            if (!PluginFunctions.arwIsRunning()) {
				if (!_sceneConfiguredForVideoWaitingMessageLogged) {
					Log(LogTag + "UpdateAR: Waiting for ARToolKit video.");
					_sceneConfiguredForVideoWaitingMessageLogged = true;
				}
            } else {
				Log(LogTag + "UpdateAR: ARToolKit video is running. Configuring Unity scene for video.");
		
				// Retrieve ARToolKit video source(s) frame size and format, and projection matrix, and store globally.
				// Then create the required object(s) to instantiate a mesh/meshes with the frame texture(s).
				// Each mesh lives in a separate "video background" layer.
				if (!VideoIsStereo) {

					// ARToolKit video size and format.
				 
					bool ok1 = PluginFunctions.arwGetVideoParams(out _videoWidth0, out _videoHeight0, out _videoPixelSize0, out _videoPixelFormatString0);
					if (!ok1) return false;
					Log(LogTag + "Video " + _videoWidth0 + "x" + _videoHeight0 + "@" + _videoPixelSize0 + "Bpp (" + _videoPixelFormatString0 + ")");
					
					// ARToolKit projection matrix adjusted for Unity
					float[] projRaw = new float[16];
					PluginFunctions.arwGetProjectionMatrix(projRaw);
					_videoProjectionMatrix0 = ARUtilityFunctions.MatrixFromFloatArray(projRaw);
					Log(LogTag + "Projection matrix: [" + Environment.NewLine + _videoProjectionMatrix0.ToString().Trim() + "]");
					if (ContentRotate90) _videoProjectionMatrix0 = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(90.0f, Vector3.back), Vector3.one) * _videoProjectionMatrix0;
					if (ContentFlipV) _videoProjectionMatrix0 = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1.0f, -1.0f, 1.0f)) * _videoProjectionMatrix0;
					if (ContentFlipH) _videoProjectionMatrix0 = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(-1.0f, 1.0f, 1.0f)) * _videoProjectionMatrix0;

					_videoBackgroundMeshGO0 = CreateVideoBackgroundMesh(0, _videoWidth0, _videoHeight0, BackgroundLayer0, out _videoColorArray0, out _videoColor32Array0, out _videoTexture0, out _videoMaterial0);
					if (_videoBackgroundMeshGO0 == null || _videoTexture0 == null || _videoMaterial0 == null) {
						Log (LogTag + "Error: unable to create video mesh.");
					}

				} else {

					// ARToolKit stereo video size and format.
					bool ok1 = PluginFunctions.arwGetVideoParamsStereo(out _videoWidth0, out _videoHeight0, out _videoPixelSize0, out _videoPixelFormatString0, out _videoWidth1, out _videoHeight1, out _videoPixelSize1, out _videoPixelFormatString1);
					if (!ok1) return false;
					Log(LogTag + "Video left " + _videoWidth0 + "x" + _videoHeight0 + "@" + _videoPixelSize0 + "Bpp (" + _videoPixelFormatString0 + "), right " + _videoWidth1 + "x" + _videoHeight1 + "@" + _videoPixelSize1 + "Bpp (" + _videoPixelFormatString1 + ")");
					
					// ARToolKit projection matrices, adjusted for Unity
					float[] projRaw0 = new float[16];
					float[] projRaw1 = new float[16];
					PluginFunctions.arwGetProjectionMatrixStereo(projRaw0, projRaw1);
					_videoProjectionMatrix0 = ARUtilityFunctions.MatrixFromFloatArray(projRaw0);
					_videoProjectionMatrix1 = ARUtilityFunctions.MatrixFromFloatArray(projRaw1);
					Log(LogTag + "Projection matrix left: [" + Environment.NewLine + _videoProjectionMatrix0.ToString().Trim() + "], right: [" + Environment.NewLine + _videoProjectionMatrix1.ToString().Trim() + "]");
					if (ContentRotate90) _videoProjectionMatrix0 = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(90.0f, Vector3.back), Vector3.one) * _videoProjectionMatrix0;
					if (ContentRotate90) _videoProjectionMatrix1 = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(90.0f, Vector3.back), Vector3.one) * _videoProjectionMatrix1;
					if (ContentFlipV) _videoProjectionMatrix0 = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1.0f, -1.0f, 1.0f)) * _videoProjectionMatrix0;
					if (ContentFlipV) _videoProjectionMatrix1 = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1.0f, -1.0f, 1.0f)) * _videoProjectionMatrix1;
					if (ContentFlipH) _videoProjectionMatrix0 = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(-1.0f, 1.0f, 1.0f)) * _videoProjectionMatrix0;
					if (ContentFlipH) _videoProjectionMatrix1 = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(-1.0f, 1.0f, 1.0f)) * _videoProjectionMatrix1;

					_videoBackgroundMeshGO0 = CreateVideoBackgroundMesh(0, _videoWidth0, _videoHeight0, BackgroundLayer0, out _videoColorArray0, out _videoColor32Array0, out _videoTexture0, out _videoMaterial0);
					_videoBackgroundMeshGO1 = CreateVideoBackgroundMesh(1, _videoWidth1, _videoHeight1, BackgroundLayer1, out _videoColorArray1, out _videoColor32Array1, out _videoTexture1, out _videoMaterial1);
					if (_videoBackgroundMeshGO0 == null || _videoTexture0 == null || _videoMaterial0 == null || _videoBackgroundMeshGO1 == null || _videoTexture1 == null || _videoMaterial1 == null) {
						Log (LogTag + "Error: unable to create video background mesh.");
					}
				}
	            
				// Create background camera(s) to actually view the "video background" layer(s).
				bool haveStereoARCameras = false;
				ARCamera[] arCameras = FindObjectsOfType(typeof(ARCamera)) as ARCamera[];
				foreach (ARCamera arc in arCameras) {
					if (arc.Stereo) haveStereoARCameras = true;
				}
				if (!haveStereoARCameras) {
					// Mono display.
					// Use only first video source, regardless of whether VideoIsStereo.
					// (The case where stereo video source is used with a mono display is not likely to be common.)
					_videoBackgroundCameraGO0 = CreateVideoBackgroundCamera("Video background", BackgroundLayer0, out _videoBackgroundCamera0);
					if (_videoBackgroundCameraGO0 == null || _videoBackgroundCamera0 == null) {
						Log (LogTag + "Error: unable to create video background camera.");
					}
				} else {
					// Stereo display.
					// If not VideoIsStereo, right eye will display copy of video frame.
					_videoBackgroundCameraGO0 = CreateVideoBackgroundCamera("Video background (L)", BackgroundLayer0, out _videoBackgroundCamera0);
					_videoBackgroundCameraGO1 = CreateVideoBackgroundCamera("Video background (R)", (VideoIsStereo ? BackgroundLayer1 : BackgroundLayer0), out _videoBackgroundCamera1);
					if (_videoBackgroundCameraGO0 == null || _videoBackgroundCamera0 == null || _videoBackgroundCameraGO1 == null || _videoBackgroundCamera1 == null) {
						Log (LogTag + "Error: unable to create video background camera.");
					}
				}

				// Setup foreground cameras for the video configuration.
				ConfigureForegroundCameras();

				// Adjust viewports of both background and foreground cameras.
				ConfigureViewports();

//.........这里部分代码省略.........
开发者ID:RealityDaemon,项目名称:DocAR,代码行数:101,代码来源:ARController.cs

示例3: Matrix4x4ToStringTest

        public void Matrix4x4ToStringTest()
        {
            Matrix4x4 a = new Matrix4x4();
            a.M11 = 11.0f;
            a.M12 = -12.0f;
            a.M13 = -13.3f;
            a.M14 = 14.4f;
            a.M21 = 21.0f;
            a.M22 = 22.0f;
            a.M23 = 23.0f;
            a.M24 = 24.0f;
            a.M31 = 31.0f;
            a.M32 = 32.0f;
            a.M33 = 33.0f;
            a.M34 = 34.0f;
            a.M41 = 41.0f;
            a.M42 = 42.0f;
            a.M43 = 43.0f;
            a.M44 = 44.0f;

            string expected = String.Format(CultureInfo.CurrentCulture,
                "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} }}",
                    11.0f, -12.0f, -13.3f, 14.4f,
                    21.0f, 22.0f, 23.0f, 24.0f,
                    31.0f, 32.0f, 33.0f, 34.0f,
                    41.0f, 42.0f, 43.0f, 44.0f);

            string actual = a.ToString();
            Assert.Equal(expected, actual);
        }
开发者ID:rajeevkb,项目名称:corefx,代码行数:30,代码来源:Matrix4x4Tests.cs

示例4: Start

    // Use this for initialization
    void Start()
    {
        knotPositions = new Vector3[pointsNumber];
        shapes = new List<ShapeClass>();
        for (int i = 0; i < pointsNumber; i++ )
        {
            knotPositions[i] = GetPointPositionInSpline(new Vector3(), new Vector3(0, 1, 0), new Vector3(2, 3, 0), new Vector3(3, 3, 0), (float)i / (float)(pointsNumber - 1));
        }
        originalShape = new ShapeClass(new Vector3[]{new Vector3(-1, 0, -1), new Vector3(-1, 0, 1), new Vector3(1, 0, 1), new Vector3(1, 0, -1)});

        shapes.Add(originalShape);

        //startQ = new Quaternion(0, 0, 1, 0);
        startQ = Quaternion.Euler(0, 0, 0);
        startMatrix = Matrix4x4.TRS(new Vector3(), startQ, new Vector3(1, 1, 1));
        endQ = Quaternion.Euler(0, 0, -90);
        //endQ = new Quaternion(0, 1, 0, 0);
        endMatrix = Matrix4x4.TRS(new Vector3(3, 3, 0), endQ, new Vector3(1, 1, 1));
        //endQ = QuaternionFromMatrix(endMatrix);

        print("end Quaternion=" + endQ.ToString() + " start Quaternion=" + startQ.ToString());
        print("startMatrix=" + startMatrix.ToString());

        //calculate angle between quaternions
           // float angle = (180 * Mathf.Acos(Quaternion.Dot(startQ, endQ))) / Mathf.PI;
        float angle = Mathf.Acos(Quaternion.Dot(startQ, endQ) / (GetQuaternionLength(startQ) * GetQuaternionLength(endQ)));
        //print("Angle=" + angle.ToString());

        endShape = new ShapeClass();
        endShape.CopyFrom(originalShape);
        endShape.MapsTo(endMatrix);

        //calculate other shapes
        for (int i = 1; i < pointsNumber-1; i++ )
        {
            //Quaternion middleQ = Quaternion.Lerp(startQ, endQ, (float)i * 100 / (float)(pointsNumber - 1));
            Quaternion middleQ = GetInterpolatedQuaternion(startQ, endQ, angle, (float)i / (float)(pointsNumber - 1));
            print(middleQ.ToString() + " " + ((float)i / (float)(pointsNumber - 1)).ToString());
            Matrix4x4 middleMatrix = Matrix4x4.TRS(knotPositions[i], middleQ, new Vector3(1, 1, 1));

            ShapeClass middleShape = new ShapeClass();
            middleShape.CopyFrom(originalShape);
            middleShape.MapsTo(middleMatrix);

            shapes.Add(middleShape);

        }

        shapes.Add(endShape);
    }
开发者ID:Angel07,项目名称:SpineConstructor,代码行数:51,代码来源:GenExtrude.cs

示例5: Matrix4x4ToStringTest

        public void Matrix4x4ToStringTest()
        {
            Matrix4x4 a = new Matrix4x4();
            a.M11 = 11.0f; a.M12 = -12.0f; a.M13 = -13.3f; a.M14 = 14.4f;
            a.M21 = 21.0f; a.M22 = 22.0f; a.M23 = 23.0f; a.M24 = 24.0f;
            a.M31 = 31.0f; a.M32 = 32.0f; a.M33 = 33.0f; a.M34 = 34.0f;
            a.M41 = 41.0f; a.M42 = 42.0f; a.M43 = 43.0f; a.M44 = 44.0f;

            string expected = "{ {M11:11 M12:-12 M13:-13.3 M14:14.4} " +
                                "{M21:21 M22:22 M23:23 M24:24} " +
                                "{M31:31 M32:32 M33:33 M34:34} " +
                                "{M41:41 M42:42 M43:43 M44:44} }";
            string actual;

            actual = a.ToString();
            Assert.AreEqual(expected, actual, "Matrix4x4.ToString did not return the expected value.");
        }
开发者ID:gfcprogramer,项目名称:Win2D,代码行数:17,代码来源:Matrix4x4Test.cs

示例6: ReadCalibration

 internal Matrix4x4 ReadCalibration(string fileName)
 {
     Matrix4x4 matrixCalibration = new Matrix4x4();
     try
     {
         using (StreamReader sr = new StreamReader(Application.dataPath + @"/../transform_matrix.txt"))
         {
             for (int i = 0; i < 4; i++)
             {
                 Vector4 row = new Vector4();
                 String line = sr.ReadLine();
                 String[] tokens = line.Split();
                 int j = 0;
                 foreach (string token in tokens)
                 {
                     float matrixCoord = Single.Parse(token);
                     row[j++] = matrixCoord;
                 }
                 matrixCalibration.SetRow(i, row);
             }
         }
         if (!CalibrationValidity.Instance.CheckValidity(matrixCalibration))
         {
             UnityEngine.Debug.Log("Calibration Error: " + CalibrationValidity.Instance.GetError());
             EventLogger.Instance.LogData("Calibration Error: " + CalibrationValidity.Instance.GetError());
             isCalibrated = false;
             matrixCalibration = Matrix4x4.zero;
         }
     }
     catch (Exception e)
     {
         UnityEngine.Debug.Log("Error getting transform: " + e.Message);
         EventLogger.Instance.LogData("Error reading calibration matrix: " + e.Message);
         matrixCalibration = Matrix4x4.zero;
     }
     transformMatrix = matrixCalibration;
     EventLogger.Instance.LogData("Calibration Matrix: " + transformMatrix.ToString());
     return matrixCalibration;
 }
开发者ID:hazlett,项目名称:ChildrensHospital,代码行数:39,代码来源:GameControl.cs


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