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


C# Random.NextVector3方法代码示例

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


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

示例1: TestMeasureOverride

        public void TestMeasureOverride()
        {
            var rand = new Random();
            var imageSize = new Vector3(100, 50, 0);
            var Sprite = new Sprite { Region = new Rectangle(0, 0, (int)imageSize.X, (int)imageSize.Y), Borders = new Vector4(1, 2, 3, 4) };
            var image = new ImageElement { Source = Sprite };

            // Fixed sized
            image.StretchType = StretchType.None;
            image.Measure(rand.NextVector3());
            Assert.AreEqual(imageSize, image.DesiredSizeWithMargins);

            // Uniform sized
            image.StretchType = StretchType.Uniform;
            image.Measure(new Vector3(50));
            Assert.AreEqual(new Vector3(50, 25, 0), image.DesiredSizeWithMargins);

            // Uniform to fill sized
            image.StretchType = StretchType.UniformToFill;
            image.Measure(new Vector3(50));
            Assert.AreEqual(new Vector3(100, 50, 0), image.DesiredSizeWithMargins);

            // Fill on stretch
            image.StretchType = StretchType.FillOnStretch;
            image.Measure(new Vector3(50));
            Assert.AreEqual(new Vector3(50, 25, 0), image.DesiredSizeWithMargins);

            // Fill
            image.StretchType = StretchType.Fill;
            image.Measure(new Vector3(50));
            Assert.AreEqual(new Vector3(50, 50, 0), image.DesiredSizeWithMargins);

            // Test minimal size due to borders
            image.StretchType = StretchType.Fill;
            image.Measure(new Vector3());
            Assert.AreEqual(new Vector3(4, 6, 0), image.DesiredSizeWithMargins);

            // Test with infinite value
            for (var type = 0; type < 5; ++type)
                TestMeasureOverrideInfiniteValues((StretchType)type);

            // Test stretch directions
            image.StretchType = StretchType.Fill;
            image.StretchDirection = StretchDirection.DownOnly;
            image.Measure(new Vector3(200, 300, 220));
            Assert.AreEqual(new Vector3(100, 50, 0), image.DesiredSizeWithMargins);
            image.Measure(new Vector3(20, 15, 30));
            Assert.AreEqual(new Vector3(20, 15, 0), image.DesiredSizeWithMargins);
            image.StretchDirection = StretchDirection.UpOnly;
            image.Measure(new Vector3(200, 300, 220));
            Assert.AreEqual(new Vector3(200, 300, 0), image.DesiredSizeWithMargins);
            image.Measure(new Vector3(20, 30, 22));
            Assert.AreEqual(new Vector3(100, 50, 0), image.DesiredSizeWithMargins);
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:54,代码来源:ImageElementTests.cs

示例2: MakeNebulaBackground

        public void MakeNebulaBackground(float absoluteSpread, int count, float size, float intensity)
        {
            var system = new ParticleSystem("InstancedBilboardingEffect", "Glow", intensity);
            var random = new Random();

            for (int i = 0; i < count; i++)
            {
                Vector3 position = random.NextVector3() * absoluteSpread;
                system.AddParticle(new Vector4(position, (float)random.NextDouble() * size));
            }

            _nebulas.Add(system);
        }
开发者ID:shadarath,项目名称:SpaceExplorer,代码行数:13,代码来源:EmptySolarSystem.cs

示例3: MakeNebula

        public static ParticleSystem MakeNebula(Vector3 postition, int count, float spread, float size, float intensity)
        {
            var system = new ParticleSystem("InstancedBilboardingEffect", "Glow", intensity);
            var random = new Random();

            for (int i = 0; i < count; i++)
            {
                float distanceRandom = (float)random.NextDouble() * spread;
                Vector3 position = postition + random.NextVector3(distanceRandom);
                system.AddParticle(new Vector4(position, (float)random.NextDouble() * size));
            }

            return system;
        }
开发者ID:shadarath,项目名称:SpaceExplorer,代码行数:14,代码来源:CelestialGenerator.cs

示例4: Initialize

		/// <summary>
		/// Initialize services :
		/// </summary>
		protected override void Initialize ()
		{
			base.Initialize();

			LoadContent();
			Reloading += (s,e) => LoadContent();

			CreateTargets();
			GraphicsDevice.DisplayBoundsChanged += (s,e) => CreateTargets();


			var lr = GetService<LightRenderer>();
			var rand = new Random(542);
			
			for (int i=0; i<1024; i++) {
				var light = new OmniLight();
				light.RadiusOuter	=	rand.NextFloat(3, 4);
				light.RadiusInner	=	light.RadiusOuter * 0.5f;
				light.Position		=	rand.NextVector3( new Vector3(-50,3,-50), new Vector3(50,6,50) );
				//light.Position		=	Vector3.Up * 3; //new Vector3(10,2,20);
				//light.Position		=	new Vector3( (i/32)*3-48, 2.5f, (i%32)*3-48 );
				light.Intensity		=	rand.NextColor4()*50;// new Color4(10,10,5,0);
				lr.OmniLights.Add( light );
			}

			var names = spotAtlas.SubImageNames;

			lr.MaskAtlas	=	spotAtlas;

			for (int i=0; i<16; i++) {
				var light = new SpotLight();

				var position		=	rand.NextVector3( new Vector3(-30,20,-30), new Vector3(30,20,30) );
				var target			=	position + rand.NextVector3( new Vector3(-10, -35,-10), new Vector3(10, -35,10) );

				//position			=	rand.NextVector3( new Vector3(-50,50,-50), new Vector3(50,50,50) );
				//target				=	Vector3.Down * 20;

				light.Intensity		=	rand.NextColor4()*100;// new Color4(10,10,5,0);
				light.SpotView		=	Matrix.LookAtRH( position, target, Vector3.Up );
				light.RadiusOuter	=	(target - position).Length() * 1.5f;
				light.RadiusInner	=	light.RadiusOuter * 0.5f;
				light.MaskName		=	names[ rand.Next(0, names.Length) ];
				light.Projection	=	Matrix.PerspectiveFovRH( MathUtil.DegreesToRadians(45), 1, 1f, light.RadiusOuter );

				lr.SpotLights.Add( light );
			}
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:51,代码来源:DeferredDemo.cs

示例5: TestViewport

        public void TestViewport(bool virtualizeChildren)
        {
            var random = new Random();
            var childSize1 = new Vector3(50, 150, 250);
            var childSize2 = new Vector3(150, 250, 350);
            var childSize3 = new Vector3(250, 250, 350);
            var childSize4 = new Vector3(350, 250, 350);

            var stackPanel = new StackPanel { DepthAlignment = DepthAlignment.Stretch, ItemVirtualizationEnabled = virtualizeChildren };

            Assert.AreEqual(Vector3.Zero, stackPanel.Viewport);

            var child1 = new StackPanel { Size = childSize1 };
            var child2 = new StackPanel { Size = childSize2 };
            var child3 = new StackPanel { Size = childSize3 };
            var child4 = new StackPanel { Size = childSize4 };

            stackPanel.Children.Add(child1);
            stackPanel.Children.Add(child2);
            stackPanel.Children.Add(child3);
            stackPanel.Children.Add(child4);

            var referencePosition = Vector3.Zero;
            stackPanel.Arrange(referencePosition, false);
            Assert.AreEqual(referencePosition, stackPanel.Viewport);

            referencePosition = random.NextVector3();
            stackPanel.Arrange(referencePosition, false);
            Assert.AreEqual(referencePosition, stackPanel.Viewport);

            referencePosition = random.NextVector3();
            stackPanel.ScrollToEnd(Orientation.Horizontal);
            stackPanel.ScrollToEnd(Orientation.Vertical);
            stackPanel.Children.Remove(child4);
            stackPanel.Arrange(referencePosition, false);
            Assert.AreEqual(referencePosition, stackPanel.Viewport);

            var stackSize = new Vector3(100, 200, 300);
            stackPanel.Size = stackSize;
            stackPanel.Arrange(Vector3.Zero, false);
            Assert.AreEqual(stackSize, stackPanel.Viewport);
        }
开发者ID:cg123,项目名称:xenko,代码行数:42,代码来源:StackPanelTests.cs

示例6: TestScrolling

        public void TestScrolling()
        {
            const float elementWidth = 100;
            const float elementHeight = 200;
            const float elementDepth = 300;

            var rand = new Random();
            var scrollViewer = new ScrollViewer { ScrollMode = ScrollingMode.HorizontalVertical, Width = elementWidth, Height = elementHeight, Depth = elementDepth };
            scrollViewer.Measure(Vector3.Zero);
            scrollViewer.Arrange(Vector3.Zero, false);

            // tests that no crashes happen with no content
            scrollViewer.ScrollTo(rand.NextVector3());
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollOf(rand.NextVector3());
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.Horizontal);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.InDepth);
            Assert.AreEqual(Vector3.Zero, ScrollPosition);

            // tests with an arranged element
            const float contentWidth = 1000;
            const float contentHeight = 2000;
            const float contentDepth = 3000;
            var content = new ContentDecorator { Width = contentWidth, Height = contentHeight, Depth = contentDepth };
            scrollViewer.Content = content;
            scrollViewer.Measure(Vector3.Zero);
            scrollViewer.Arrange(Vector3.Zero, false);

            var scrollValue = new Vector3(123, 456, 789);
            scrollViewer.ScrollTo(scrollValue);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);

            scrollViewer.ScrollToEnd(Orientation.Horizontal);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, scrollValue.Y, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.Vertical);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToEnd(Orientation.InDepth);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);

            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            Assert.AreEqual(new Vector3(0, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.Vertical);
            Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition);

            scrollViewer.ScrollOf(scrollValue);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);

            // tests with an not arranged element
            content.InvalidateArrange();
            scrollViewer.ScrollTo(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);
            content.InvalidateArrange();
            scrollViewer.ScrollOf(2*scrollValue);
            scrollViewer.ScrollTo(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);

            content.InvalidateArrange();
            scrollViewer.ScrollToEnd(Orientation.Horizontal);
            scrollViewer.ScrollToEnd(Orientation.Vertical);
            scrollViewer.ScrollToEnd(Orientation.InDepth);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition);

            content.InvalidateArrange();
            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            scrollViewer.ScrollToBeginning(Orientation.Vertical);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition);

            content.InvalidateArrange();
            scrollViewer.ScrollOf(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition);
            content.InvalidateArrange();
            scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            scrollViewer.ScrollToBeginning(Orientation.Vertical);
            scrollViewer.ScrollToBeginning(Orientation.InDepth);
            scrollViewer.ScrollOf(scrollValue);
            scrollViewer.ScrollOf(scrollValue);
            scrollViewer.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(2*scrollValue.X, 2*scrollValue.Y, 0), scrollViewer.ScrollPosition);
        }
开发者ID:cg123,项目名称:xenko,代码行数:93,代码来源:ScrollViewerTests.cs

示例7: TransformHierarchyInitialized

		[Test] public void TransformHierarchyInitialized()
		{
			Random rnd = new Random();

			// Create a simple parent-child relation
			GameObject sourceParentObj = new GameObject("Parent");
			GameObject sourceChildObj = new GameObject("Child", sourceParentObj);
			Transform sourceParentTransform = sourceParentObj.AddComponent<Transform>();
			Transform sourceChildTransform = sourceChildObj.AddComponent<Transform>();

			// Test whether transform values work relative as expected
			{
				Transform parent = sourceParentTransform;
				Transform child = sourceChildTransform;
				Vector3 parentPosAbs = rnd.NextVector3();
				Vector3 childPosRel = rnd.NextVector3();
				parent.Pos = parentPosAbs;
				child.RelativePos = childPosRel;

				Assert.AreEqual(parentPosAbs.X + childPosRel.X, child.Pos.X, 0.000001f);
				Assert.AreEqual(parentPosAbs.Y + childPosRel.Y, child.Pos.Y, 0.000001f);
				Assert.AreEqual(parentPosAbs.Z + childPosRel.Z, child.Pos.Z, 0.000001f);

				childPosRel = rnd.NextVector3();
				child.RelativePos = childPosRel;
			
				Assert.AreEqual(parentPosAbs.X + childPosRel.X, child.Pos.X, 0.000001f);
				Assert.AreEqual(parentPosAbs.Y + childPosRel.Y, child.Pos.Y, 0.000001f);
				Assert.AreEqual(parentPosAbs.Z + childPosRel.Z, child.Pos.Z, 0.000001f);
			}

			// Clone the object hierarchy
			GameObject targetParentObj = sourceParentObj.DeepClone();
			GameObject targetChildObj = targetParentObj.ChildByName("Child");
			Transform targetParentTransform = targetParentObj.Transform;
			Transform targetChildTransform = targetChildObj.Transform;

			// Test whether transform values also work for the cloned hierarchy
			{
				Transform parent = targetParentTransform;
				Transform child = targetChildTransform;
				Vector3 parentPosAbs = rnd.NextVector3();
				Vector3 childPosRel = rnd.NextVector3();
				parent.Pos = parentPosAbs;
				child.RelativePos = childPosRel;

				Assert.AreEqual(parentPosAbs.X + childPosRel.X, child.Pos.X, 0.000001f);
				Assert.AreEqual(parentPosAbs.Y + childPosRel.Y, child.Pos.Y, 0.000001f);
				Assert.AreEqual(parentPosAbs.Z + childPosRel.Z, child.Pos.Z, 0.000001f);

				childPosRel = rnd.NextVector3();
				child.RelativePos = childPosRel;
			
				Assert.AreEqual(parentPosAbs.X + childPosRel.X, child.Pos.X, 0.000001f);
				Assert.AreEqual(parentPosAbs.Y + childPosRel.Y, child.Pos.Y, 0.000001f);
				Assert.AreEqual(parentPosAbs.Z + childPosRel.Z, child.Pos.Z, 0.000001f);
			}
		}
开发者ID:undue,项目名称:duality,代码行数:58,代码来源:SpecificCloningTest.cs

示例8: OrtagonalFromRandom

 private static Vector3 OrtagonalFromRandom(Vector3 localPostion)
 {
     var rand = new Random();
     var vec = rand.NextVector3();
     return Vector3.Cross(vec, localPostion);
 }
开发者ID:shadarath,项目名称:SpaceExplorer,代码行数:6,代码来源:Orbit.cs

示例9: TestArrangeOverride

        public void TestArrangeOverride()
        {
            var rand = new Random();
            var imageSize = new Vector3(100, 50, 0);
            var sprite = new Sprite { Region = new Rectangle(0, 0, (int)imageSize.X, (int)imageSize.Y), Borders = new Vector4(1, 2, 3, 4) };
            var image = new ImageElement { Source = (SpriteFromTexture)sprite };

            // Fixed sized
            image.StretchType = StretchType.None;
            image.Arrange(rand.NextVector3(), false);
            Assert.AreEqual(imageSize, image.RenderSize);

            // Uniform sized
            image.StretchType = StretchType.Uniform;
            image.Arrange(new Vector3(50), false);
            Assert.AreEqual(new Vector3(50, 25, 0), image.RenderSize);

            // Uniform to fill sized
            image.StretchType = StretchType.UniformToFill;
            image.Arrange(new Vector3(50), false);
            Assert.AreEqual(new Vector3(100, 50, 0), image.RenderSize);

            // Fill on stretch
            image.StretchType = StretchType.FillOnStretch;
            image.Arrange(new Vector3(50), false);
            Assert.AreEqual(new Vector3(50, 50, 0), image.RenderSize);

            // Fill
            image.StretchType = StretchType.Fill;
            image.Arrange(new Vector3(50), false);
            Assert.AreEqual(new Vector3(50, 50, 0), image.RenderSize);

            // Test there is no minimal size due to borders in arrange
            image.StretchType = StretchType.Fill;
            image.Arrange(new Vector3(), false);
            Assert.AreEqual(new Vector3(), image.RenderSize);

            // Test with infinite value
            for (var type = 0; type < 5; ++type)
                TestArrangeOverrideInfiniteValues((StretchType)type);

            // Test stretch directions
            image.StretchType = StretchType.Fill;
            image.StretchDirection = StretchDirection.DownOnly;
            image.Arrange(new Vector3(200, 300, 220), false);
            Assert.AreEqual(new Vector3(100, 50, 0), image.RenderSize);
            image.Arrange(new Vector3(20, 15, 30), false);
            Assert.AreEqual(new Vector3(20, 15, 0), image.RenderSize);
            image.StretchDirection = StretchDirection.UpOnly;
            image.Arrange(new Vector3(200, 300, 220), false);
            Assert.AreEqual(new Vector3(200, 300, 0), image.RenderSize);
            image.Arrange(new Vector3(20, 30, 22), false);
            Assert.AreEqual(new Vector3(100, 50, 0), image.RenderSize);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:54,代码来源:ImageElementTests.cs

示例10: SkySettings

		public SkySettings()
		{
			RgbSpace			= RgbSpace.sRGB;
			AerialFogDensity	= 0.001f;
			SkySphereSize		= 1000.0f;
			SkyTurbidity		= 4.0f;
			SunPosition		= new Vector3( 1.0f, 0.1f, 1.0f );
			SunGlowIntensity	= Half.MaxValue/2;
			SunLightIntensity	= 300.0f;
			SunTemperature		= 5500;
			SkyIntensity		= 1.0f;


			randVectors	=	new Vector3[64];
			var rand	=	new Random(465464);

			for (int i=0; i<randVectors.Length; i++) {
				Vector3 randV;
				do {
					randV = rand.NextVector3( -Vector3.One, Vector3.One );
				} while ( randV.Length()>1 && randV.Y < 0 );

				randVectors[i] = randV.Normalized();
			}
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:25,代码来源:SkySettings.cs

示例11: CreateRandomPoints

        /*     public void Insert(Vector3 position, bool doNotUpdate = false)
        {
            Vector3[] newArray = new Vector3[spherePositionArray.Length+1];
            for(int i=0; i<spherePositionArray.Length; ++i)
                newArray
        }*/
        public void CreateRandomPoints(int randomSeed, uint numPoints, float worldWidth, float worldHeight)
        {
            selectedSphere = -1;
            Seed = randomSeed;

            Random random = new Random(randomSeed);
            spherePositionArray = new Vector3[numPoints];
            for (int i = 0; i < numPoints; ++i)
                spherePositionArray[i] = random.NextVector3(Vector3.Zero, new Vector3(worldWidth, 1.0f, worldHeight));

            UpdateSpherePositionsBuffer();
        }
开发者ID:Wumpf,项目名称:mstbasedheightmapgen,代码行数:18,代码来源:PointSet.cs


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