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


C# Color.ToVector3方法代码示例

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


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

示例1: Draw

        public void Draw(GraphicsDevice device, BoundingBox boundingBox, Camera camera, Color color)
        {
            if (declaration == null)
            {
                declaration = VertexPositionColor.VertexDeclaration;
            }

            if (effect == null)
            {
                effect = new BasicEffect(device);
            }
            effect.DiffuseColor = color.ToVector3();

            effect.View = camera.EyeTransform;
            effect.Projection = camera.ProjectionTransform;
            Vector3 size = boundingBox.Max - boundingBox.Min;
            effect.World = Matrix.CreateScale(size)*Matrix.CreateTranslation(boundingBox.Max - size*0.5f);
            
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawUserIndexedPrimitives<VertexPositionColor>(
                                    PrimitiveType.LineList, points,
                                    0,
                                    8,
                                    index,
                                    0,
                                    12);
            }
        }
开发者ID:justshiv,项目名称:LightSavers,代码行数:30,代码来源:BoundingBoxRenderer.cs

示例2: Compress

        /// <summary>
        /// 指定された単色ビットマップ画像をDXT3テクスチャへ変換する
        /// </summary>
        /// <param name="source">変換元画像</param>
        /// <param name="color0">単色カラー</param>
        /// <returns>DXT3圧縮された画像</returns>
        public static Dxt3BitmapContent Compress(PixelBitmapContent<Color> source,
                                                    Color color0)
        {
            // DXT3ブロックデータを格納するためのバッファを確保
            byte[] outputData = new byte[source.Width * source.Height];

            // 単色カラーをBGR565に変換する
            ushort packedColor = new Bgr565(color0.ToVector3()).PackedValue;

            // 指定された画像を圧縮ブロック単位に処理をする
            int outputIndex = 0;
            for (int blockY = 0; blockY < source.Height; blockY += 4)
            {
                for (int blockX = 0; blockX < source.Width; blockX += 4)
                {
                    CompressDxt3Block(source, blockX, blockY, packedColor,
                                        outputData, outputIndex);
                    outputIndex += 16;
                }
            }

            // DXT3テクスチャの生成と圧縮したブロックデータの設定
            var result = new Dxt3BitmapContent(source.Width, source.Height);
            result.SetPixelData(outputData);

            return result;
        }
开发者ID:himapo,项目名称:ccm,代码行数:33,代码来源:SingleColorDxtCompressor.cs

示例3: Shift

        public static Color Shift(Color color, float hueShift)
        {
            Vector3 colorVector = color.ToVector3();
            Matrix hueShiftMatrix = HueShifter.CreateHueTransformationMatrix(hueShift);
            HueShifter.Shift(ref colorVector, ref hueShiftMatrix);

            return new Color(colorVector);
        }
开发者ID:JaakkoLipsanen,项目名称:Flai.XNA,代码行数:8,代码来源:HueShifter.cs

示例4: DrawRectangle

 public void DrawRectangle(Rectangle rectangle, Color color)
 {
     _effect.World = Matrix.CreateScale(rectangle.Width, rectangle.Height, 0f) * Matrix.CreateTranslation(rectangle.X, rectangle.Y, 0f);
     _effect.DiffuseColor = color.ToVector3();
     foreach (var pass in _effect.CurrentTechnique.Passes)
     {
         pass.Apply();
         _graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, _rectangleStart, _rectangleCount);
     }
 }
开发者ID:vkd,项目名称:Ctrl-Space,代码行数:10,代码来源:DebugGeometry.cs

示例5: DrawLine

 public void DrawLine(Vector2 start, float lenght, float direction, Color color)
 {
     _effect.World = Matrix.CreateScale(lenght) * Matrix.CreateRotationZ(direction) * Matrix.CreateTranslation(start.X, start.Y, 0f);
     _effect.DiffuseColor = color.ToVector3();
     foreach (var pass in _effect.CurrentTechnique.Passes)
     {
         pass.Apply();
         _graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, _lineStart, _lineCount);
     }
 }
开发者ID:vkd,项目名称:Ctrl-Space,代码行数:10,代码来源:DebugGeometry.cs

示例6: DrawCircle

 public void DrawCircle(Vector2 center, float radius, Color color)
 {
     _effect.World = Matrix.CreateScale(radius) * Matrix.CreateTranslation(center.X, center.Y, 0f);
     _effect.DiffuseColor = color.ToVector3();
     foreach (var pass in _effect.CurrentTechnique.Passes)
     {
         pass.Apply();
         _graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, _circleStart, _circleCount);
     }
 }
开发者ID:vkd,项目名称:Ctrl-Space,代码行数:10,代码来源:DebugGeometry.cs

示例7: Create

        public static Texture2D Create(GraphicsDevice graphicsDevice, int width, int height, Color color)
        {
            Texture2D texture = new Texture2D(graphicsDevice, width, height, false, SurfaceFormat.Color);

            Color[] colors = new Color[width * height];
            for (int i = 0; i < colors.Length; i++)
            {
                colors[i] = new Color(color.ToVector3());
            }

            texture.SetData(colors);

            return texture;
        }
开发者ID:vkrajacic89,项目名称:MagiciansEscape-TVZ,代码行数:14,代码来源:ColorTexture.cs

示例8: CreateSinglePixel

        private static Texture2D CreateSinglePixel(GraphicsDevice graphicsDevice, int width, int height, Color color)
        {
            // create the rectangle texture without colors
            var texture = new Texture2D(graphicsDevice, width, height, false, SurfaceFormat.Color);

            // Create a color array for the pixels
            var colors = new Color[width * height];
            for (int i = 0; i < colors.Length; i++)
            {
                colors[i] = new Color(color.ToVector3());
            }

            // Set the color data for the texture
            texture.SetData(colors);

            return texture;
        }
开发者ID:redbadger,项目名称:XPF,代码行数:17,代码来源:PrimitivesService.cs

示例9: Update

		// per frame simulation update
		public void Update(float currentTime, float elapsedTime)
		{
			// determine upper bound for pursuit prediction time
			float seekerToGoalDist = Vector3.Distance(Globals.HomeBaseCenter, Globals.Seeker.Position);
			float adjustedDistance = seekerToGoalDist - Radius - Plugin.BaseRadius;
			float seekerToGoalTime = ((adjustedDistance < 0) ? 0 : (adjustedDistance / Globals.Seeker.Speed));
			float maxPredictionTime = seekerToGoalTime * 0.9f;

			// determine steering (pursuit, obstacle avoidance, or braking)
			Vector3 steer = Vector3.Zero;
			if (Globals.Seeker.State == SeekerState.Running)
			{
				Vector3 avoidance = SteerToAvoidObstacles(Globals.AVOIDANCE_PREDICT_TIME_MIN, AllObstacles);

				// saved for annotation
				Avoiding = (avoidance == Vector3.Zero);

				steer = Avoiding ? SteerForPursuit(Globals.Seeker, maxPredictionTime) : avoidance;
			}
			else
			{
				ApplyBrakingForce(Globals.BRAKING_RATE, elapsedTime);
			}
			ApplySteeringForce(steer, elapsedTime);

			// annotation
			annotation.VelocityAcceleration(this);
			Trail.Record(currentTime, Position);

			// detect and record interceptions ("tags") of seeker
			float seekerToMeDist = Vector3.Distance(Position, Globals.Seeker.Position);
			float sumOfRadii = Radius + Globals.Seeker.Radius;
			if (seekerToMeDist < sumOfRadii)
			{
				if (Globals.Seeker.State == SeekerState.Running) Globals.Seeker.State = SeekerState.Tagged;

				// annotation:
				if (Globals.Seeker.State == SeekerState.Tagged)
				{
					Color color = new Color((byte)(255.0f * 0.8f), (byte)(255.0f * 0.5f), (byte)(255.0f * 0.5f));
					annotation.DiskXZ(sumOfRadii, (Position + Globals.Seeker.Position) / 2, color.ToVector3().FromXna(), 20);
				}
			}
		}
开发者ID:cupsster,项目名称:SharpSteer2,代码行数:45,代码来源:CtfEnemy.cs

示例10: Draw

        public void Draw(Matrix world, Matrix view, Matrix projection, Color color)
        {
            basicEffect.World = world;
            basicEffect.View = view;
            basicEffect.Projection = projection;
            basicEffect.DiffuseColor = color.ToVector3();

            GraphicsDevice graphicsDevice = basicEffect.GraphicsDevice;
            graphicsDevice.SetVertexBuffer(vertexBuffer);
            graphicsDevice.Indices = indexBuffer;

            foreach (EffectPass effectPass in basicEffect.CurrentTechnique.Passes)
            {
                effectPass.Apply();

                int triangles = indexBuffer.IndexCount / 3;
                graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0,
                                                     vertexBuffer.VertexCount, 0, triangles);
            }
        }
开发者ID:JackieWang,项目名称:Exercise.WP7,代码行数:20,代码来源:ColorCube.cs

示例11: Draw

        // Draws the triangle mesh.
        public void Draw(GraphicsDevice graphicsDevice, BasicEffect effect, Pose pose, Color color)
        {
            if (_vertexBuffer == null)
            return;

              // Select the vertex buffer.
              graphicsDevice.SetVertexBuffer(_vertexBuffer);

              // The parameter 'pose' defines the world matrix and can be implicitly converted to
              // a XNA Matrix.
              effect.World = pose;
              effect.DiffuseColor = color.ToVector3();

              // Draw the vertex buffer.
              foreach (EffectPass pass in effect.CurrentTechnique.Passes)
              {
            pass.Apply();
            graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, _numberOfTriangles);
              }
        }
开发者ID:HATtrick-games,项目名称:ICT309,代码行数:21,代码来源:DrawableShape.cs

示例12: ToVector3Tests

        public void ToVector3Tests()
        {
            Color c = new Color(0xFF, 0xBF, 0x7F, 0x00);
            Vector3 v = c.ToVector3();

            Assert.IsTrue(TestHelper.ApproximatelyEquals(1.0f, v.X), "Unexpected value for X");
            Assert.IsTrue(TestHelper.ApproximatelyEquals(0.75f, v.Y), "Unexpected value for Y");
            Assert.IsTrue(TestHelper.ApproximatelyEquals(0.5f, v.Z), "Unexpected value for Z");
        }
开发者ID:kiichi7,项目名称:monoxna,代码行数:9,代码来源:ColorTests.cs

示例13: Mix

 public static Color Mix(this Color a, Color b, float percent = 0.5f)
 {
     percent = MathHelper.Clamp (percent, 0f, 1f);
     return new Color (a.ToVector3 () * (1f - percent) + b.ToVector3 () * percent);
 }
开发者ID:knot3,项目名称:knot3-code,代码行数:5,代码来源:ColorHelper.cs

示例14: Draw

        public void Draw(Matrix world, Matrix view, Matrix projection, Color color, Texture2D texture)
        {
            basicEffect.World = world;
            basicEffect.View = view;
            basicEffect.Projection = projection;
            basicEffect.DiffuseColor = color.ToVector3();
            basicEffect.Texture = texture;
            basicEffect.TextureEnabled = true;

            GraphicsDevice graphicsDevice = basicEffect.GraphicsDevice;
            graphicsDevice.SetVertexBuffer(vertexBuffer);
            graphicsDevice.Indices = indexBuffer;

            // BugFix::
            // Windows Phone 7 的XNA中默认的纹理寻址模式使用了Wrap,造成了与GPU的不兼容,
            // 如果改成Clamp就好了。
            graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;

            foreach (EffectPass effectPass in basicEffect.CurrentTechnique.Passes)
            {
                effectPass.Apply();

                int triangles = indexBuffer.IndexCount / 3;
                graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0,
                                                     vertexBuffer.VertexCount, 0, triangles);
            }
        }
开发者ID:JackieWang,项目名称:Exercise.WP7,代码行数:27,代码来源:Cube.cs

示例15: ToVector3

 public static void ToVector3(this DrawingColor color, out Vector3 result)
 {
     var xnaColor = new XnaColor(color.R, color.G, color.B);
     result = xnaColor.ToVector3();
 }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:5,代码来源:DrawingColorExtension.cs


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