示例#1
0
 public static void MakeTransparent(TextureContent texture, Color color)
 {
     foreach (BitmapContent bitmap in texture.Faces.SelectMany(chain => chain))
     {
         if (bitmap is PixelBitmapContent<Vector4>)
             ((PixelBitmapContent<Vector4>)bitmap).ReplaceColor(color.ToVector4(), Vector4.Zero);
         else if (bitmap is PixelBitmapContent<Color>)
             ((PixelBitmapContent<Color>)bitmap).ReplaceColor(color, Color.Transparent);
     }
 }
 public void DrawLine(Vector3D v0, Vector3D v1, Color color)
 {
     if (numVertices + 2 < maxSize)
     {
         lineData[numVertices].Position = v0 - MyRenderCamera.Position;
         lineData[numVertices].Color = color.ToVector4();
         lineData[numVertices + 1].Position = v1 - MyRenderCamera.Position;
         lineData[numVertices + 1].Color = color.ToVector4();
         numVertices += 2;
     }
 }
        private void OnValueChange(MyGuiControlSlider sender)
        {
			var humanPlayer = MySession.LocalHumanPlayer;
			if (humanPlayer == null)
				return;

            UpdateLabels();
            Color c = new Color();
            c = (new Vector3(m_hueSlider.Value/360f, MathHelper.Clamp(m_saturationSlider.Value/100f + 0.8f,0f,1f), MathHelper.Clamp(m_valueSlider.Value/100f + 0.55f,0f,1f))).HSVtoColor();
			m_colorPaletteControlsList[humanPlayer.SelectedBuildColorSlot].ColorMask = c.ToVector4();
			humanPlayer.SelectedBuildColor = new Vector3((m_hueSlider.Value / 360f), (m_saturationSlider.Value / 100f), (m_valueSlider.Value / 100f));
        }
 private void OnValueChange(MyGuiControlSlider sender)
 {
     UpdateLabels();
     Color c = new Color();
     c = (new Vector3(m_hueSlider.Value/360f, MathHelper.Clamp(m_saturationSlider.Value/100f + 0.8f,0f,1f), MathHelper.Clamp(m_valueSlider.Value/100f + 0.55f,0f,1f))).HSVtoColor();
     m_colorPaletteControlsList[MyToolbar.m_currentColorMaskHSV].ColorMask = c.ToVector4();
     MyToolbar.ColorMaskHSV = new Vector3((m_hueSlider.Value / 360f), (m_saturationSlider.Value / 100f), (m_valueSlider.Value / 100f));
 }
 public void DrawOnScreenLine(Vector3 v0, Vector3 v1, Color color)
 {
     if (numOSVertices + 2 < maxSize)
     {
         onScreenLineData[numOSVertices].Position = v0;
         onScreenLineData[numOSVertices].Color = color.ToVector4();
         onScreenLineData[numOSVertices + 1].Position = v1;
         onScreenLineData[numOSVertices + 1].Color = color.ToVector4();
         numOSVertices += 2;
     }
 }
        /*
        public void OnMyShadowCheckEnable(MyGuiControlCheckbox sender)
        {
            foreach (MyPrefabLight prefabLight in m_prefabLights)
            {
                MyLight myLight = prefabLight.GetLight();

                if (sender == m_spotLightShadowCheckbox)
                {
                    myLight.ShadowsEnabled = sender.Checked;
                }

                prefabLight.OnWorldPositionChanged(this);
                prefabLight.UpdateEffect();
            }
            OnComponentChange(null);
        }
        */
        void OnComponentChange(MyGuiControlSlider sender)
        {
            foreach (MyPrefabLight prefabLight in m_prefabLights)
            {
                MyLight light = prefabLight.GetLight();
                Color tmpColor = new Color();
                tmpColor.R = (byte)m_pointNormalLightColorSlider[0].GetValue();
                tmpColor.G = (byte)m_pointNormalLightColorSlider[1].GetValue();
                tmpColor.B = (byte)m_pointNormalLightColorSlider[2].GetValue();
                light.Color = tmpColor.ToVector4();

                tmpColor.R = (byte)m_specularLightColorSlider[0].GetValue();
                tmpColor.G = (byte)m_specularLightColorSlider[1].GetValue();
                tmpColor.B = (byte)m_specularLightColorSlider[2].GetValue();
                light.SpecularColor = tmpColor.ToVector3();
                light.Falloff = m_pointFallOffSlider.GetValue(); // allowed values 0.1f-5.0f
                light.Range = m_pointRangeSlider.GetValue(); // allowed values 0.0f-MyLightsConstants.MAX_POINTLIGHT_RADIUS
                light.Intensity = prefabLight.m_IntensityMax = m_pointIntensitySlider.GetValue(); // allowed values 0.0f-10.0f
                light.PointLightOffset = m_pointOffsetSlider.GetValue();

                tmpColor.R = (byte)m_spotNormalLightColorSlider[0].GetValue();
                tmpColor.G = (byte)m_spotNormalLightColorSlider[1].GetValue();
                tmpColor.B = (byte)m_spotNormalLightColorSlider[2].GetValue();
                light.ReflectorColor = tmpColor.ToVector4();

                light.ReflectorFalloff = m_spotFallOffSlider.GetValue(); // allowed values 0.1f-5.0f
                light.ReflectorRange = m_spotRangeSlider.GetValue(); // allowed values 0.0f-MyLightsConstants.MAX_SPOTLIGHT_RANGE
                light.ReflectorIntensity = prefabLight.ReflectorIntensityMax = m_spotIntensitySlider.GetValue(); // allowed values 0.0f-10.0f

                light.ReflectorConeDegrees = m_spotAngleSlider.GetValue(); // allowed values 0.0f-MyLightsConstants.MAX_SPOTLIGHT_ANGLE
                light.ShadowDistance = m_spotLightShadowDistance.GetValue();
                prefabLight.FlashOffset = m_flashOffsetSlider.GetValue();
            }
        }
示例#7
0
 /// <summary>
 /// Data to transport for HUD Text Display
 /// </summary>
 /// <param name="messageid">Message id is automatically generated if set to 0. Resend a message with the same ID to overwrite previously sent messages</param>
 /// <param name="timetolive">How many frames a message will live</param>
 /// <param name="Origin">Vector 2D, middle of screen is (0,0) up is positive, down is negative, right is positive, left is negative. up to +1 and -1</param>
 /// <param name="Scale">Scale multiplier for text, 0.5 is half as big. 2.0 twice as big.</param>
 /// <param name="HideHud">Automatically hide this HUD element when player hides their HUD</param>
 /// <param name="Shadowing">Enables text shadowing</param>
 /// <param name="Shadowcolor">Specifies Text Shadow Color</param>
 /// <param name="message">Message string that you want to send. &lt;color=colorname&gt; to change the color of the text. </param>
 public HUDMessage(long messageid, int timetolive, Vector2D Origin, double Scale, bool HideHud, bool Shadowing, Color Shadowcolor, string message)
 {
     options = Options.None;
     if (HideHud)
         options |= Options.HideHud;
     if (Shadowing)
         options |= Options.Shadowing;
     scale = Scale;
     id = messageid;
     ttl = timetolive;
     shadowcolor = Shadowcolor.ToVector4();
     origin = Origin;
     this.message = message;
 }
示例#8
0
		//Draw texture section
		internal void Draw(Texture2D texture2D, Vector2 position, Nullable<Rectangle> source, Color color)
        {
			graphicsDevice.DrawQueue.EnqueueSprite(new DrawSpriteCall(texture2D, position, source, color.ToVector4(), Vector2.Zero, SpriteEffects.None));
        }
示例#9
0
 public static void AddDrawTriangle(Vector3 vertex1, Vector3 vertex2, Vector3 vertex3, Color color)
 {       
     m_moints.Add(new MyVertexFormatPositionColor(vertex1, color.ToVector4()));
     m_moints.Add(new MyVertexFormatPositionColor(vertex2, color.ToVector4()));
     m_moints.Add(new MyVertexFormatPositionColor(vertex3, color.ToVector4())); 
 }
示例#10
0
        public static void DrawLine2D(Vector2 pointFrom, Vector2 pointTo, Color colorFrom, Color colorTo)
        {   
            Device graphicsDevice = MyMinerGame.Static.GraphicsDevice;

            //  Create the line vertices
            m_verticesLine[0].Position = new Vector3(pointFrom, 0);
            m_verticesLine[0].Color = colorFrom.ToVector4();
            m_verticesLine[1].Position = new Vector3(pointTo, 0);
            m_verticesLine[1].Color = colorTo.ToVector4();

            var effect = (MyEffectModelsDiffuse)MyRender.GetEffect(MyEffects.ModelDiffuse);

            effect.SetProjectionMatrix(Matrix.CreateOrthographicOffCenter(0.0F, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0.0F, 0.0F, -1.0F));
            effect.SetViewMatrix(Matrix.Identity);
            effect.SetWorldMatrix(Matrix.Identity);
            effect.SetTechnique(MyEffectModelsDiffuse.Technique.PositionColor);

            graphicsDevice.VertexDeclaration = MyVertexFormatPositionColor.VertexDeclaration;

            //  Draw the line
            effect.Begin();
            graphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, 0, 1, m_verticesLine);
            effect.End();
        }
示例#11
0
        public static void DrawLine3D(ref Vector3 pointFrom, ref Vector3 pointTo, ref Color colorFrom, ref Color colorTo)
        {                 
            Device graphicsDevice = MyMinerGame.Static.GraphicsDevice;
            
            //  Create the line vertices
            m_verticesLine[0].Position = pointFrom;
            m_verticesLine[0].Color = colorFrom.ToVector4();
            m_verticesLine[1].Position = pointTo;
            m_verticesLine[1].Color = colorTo.ToVector4();

            var effect = (MyEffectModelsDiffuse)MyRender.GetEffect(MyEffects.ModelDiffuse);

            effect.SetProjectionMatrix(Matrix.CreatePerspectiveFieldOfView(MyCamera.FovWithZoom, MyCamera.AspectRatio, 0.01f, 1000000));
            effect.SetViewMatrix(MyCamera.ViewMatrix);
            effect.SetWorldMatrix(Matrix.Identity);
            effect.SetTechnique(MyEffectModelsDiffuse.Technique.PositionColor);

            graphicsDevice.VertexDeclaration = MyVertexFormatPositionColor.VertexDeclaration;
            //  Draw the line
            effect.Begin();
            graphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, 0, 1, m_verticesLine);
            effect.End();                
        }
示例#12
0
 public void SetAllColors(Color newColor)
 {
     m_light.Color = newColor.ToVector4();
     m_light.ReflectorColor = newColor.ToVector4();
     m_light.SpecularColor = newColor.ToVector3();
 }
示例#13
0
 public void DrawLine(Vector3 v0, Vector3 v1, Color color)
 {
     if (numVertices + 2 < maxSize)
     {
         lineData[numVertices].Position = v0;
         lineData[numVertices].Color = color.ToVector4();
         lineData[numVertices + 1].Position = v1;
         lineData[numVertices + 1].Color = color.ToVector4();
         numVertices += 2;
     }
 }
示例#14
0
        public void DrawLines(Vector3[] lineData, Color color)
        {
            // drawing in 3D requires you to define vertices of a certain type
            // VertexPositionColor simply means a vertex with a position and color
            MyVertexFormatPositionColor[] line = new MyVertexFormatPositionColor[lineData.Length];

            for (int i = 0; i < lineData.Length; i++)
            {
                line[i] = new MyVertexFormatPositionColor(lineData[i], color.ToVector4());
            }

            var effect = (MyEffectModelsDiffuse)MyRender.GetEffect(MyEffects.ModelDiffuse);

            // you have to set these parameters for the basic effect to be able to draw
            // on the screen
            effect.SetProjectionMatrix(MyCamera.ProjectionMatrix);
            effect.SetViewMatrix(MyCamera.ViewMatrix);

            // graphics card should use basic effect shader
            effect.Begin();

            // you have to tell the graphics card what kind of vertices it will be receiving
            MinerWars.AppCode.App.MyMinerGame.Static.GraphicsDevice.VertexDeclaration = MyVertexFormatPositionColor.VertexDeclaration;
            MinerWars.AppCode.App.MyMinerGame.Static.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, 0, lineData.Length, line);

            effect.End();
        }
示例#15
0
 internal void DrawString(SpriteFont font, string value, Vector2 position, Color color)
 {
     graphicsDevice.DrawQueue.EnqueueString(new DrawStringCall(font, value, position, color.ToVector4()));
 }
示例#16
0
        internal void Draw(Texture2D texture2D, Vector2 position, Nullable<Rectangle> source, Color color, float p, Vector2 Origin, float p_2, SpriteEffects spriteEffects, float p_3)
        {
			graphicsDevice.DrawQueue.EnqueueSprite(new DrawSpriteCall(texture2D, position, source, color.ToVector4(), Origin, spriteEffects));
        }
示例#17
0
 public static void DrawTriangle(Vector3 vertex1, Vector3 vertex2, Vector3 vertex3, Color color1, Color color2, Color color3)
 {
     DrawTriangle(vertex1, vertex2, vertex3, color1.ToVector4(), color2.ToVector4(), color3.ToVector4());
 }
示例#18
0
		//TODO:
		internal void Draw (Texture2D texture, Nullable<Rectangle> source, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effect, float depth)
		{
/*
			if (sourceRectangle.HasValue) {
				tempRect = sourceRectangle.Value;
			} else {
				tempRect.X = 0;
				tempRect.Y = 0;
				tempRect.Width = texture.Width;
				tempRect.Height = texture.Height;				
			}
			
			texCoordTL.X = tempRect.X / (float)texture.Width;
			texCoordTL.Y = tempRect.Y / (float)texture.Height;
			texCoordBR.X = (tempRect.X + tempRect.Width) / (float)texture.Width;
			texCoordBR.Y = (tempRect.Y + tempRect.Height) / (float)texture.Height;

			if ((effect & SpriteEffects.FlipVertically) != 0) {
				float temp = texCoordBR.Y;
				texCoordBR.Y = texCoordTL.Y;
				texCoordTL.Y = temp;
			}
			if ((effect & SpriteEffects.FlipHorizontally) != 0) {
				float temp = texCoordBR.X;
				texCoordBR.X = texCoordTL.X;
				texCoordTL.X = temp;
			}
*/
			graphicsDevice.DrawQueue.EnqueueSprite(new DrawSpriteCall(texture, Vector2.Zero, source, color.ToVector4(), Vector2.Zero, SpriteEffects.None));
		}
示例#19
0
 public void Clear(Color color)
 {
     Vector4 vector = color.ToVector4();
     GL.ClearColor(vector.X, vector.Y, vector.Z, vector.W);
     GL.Clear((uint)All.ColorBufferBit);
 }
示例#20
0
 /// <summary>
 /// Creates a BillBoardHUDMessage
 /// </summary>
 /// <param name="messageid">ID of message, resend a message with the same ID to overwrite</param>
 /// <param name="timetolive">How many frames the message will live.</param>
 /// <param name="Origin">Screen origin of the billboard, from -1 to 1. </param>
 /// <param name="BillBoardColor">Color of the billboard</param>
 /// <param name="Material">Material of the billboard</param>
 /// <param name="scale">Scale in size, defaults to 1</param>
 /// <param name="rotation">Rotation in radians</param>
 /// <param name="HideHud">Hide the billboard if the user hides his/her HUD, defaults to true</param>
 public BillBoardHUDMessage(long messageid, int timetolive, Vector2D Origin, Color BillBoardColor, string Material, double scale = 1, float rotation = 0, bool HideHud = true)
 {
     id = messageid;
     ttl = timetolive;
     origin = Origin;
     options = Options.None;
     if (HideHud)
         options |= Options.HideHud;
     bbcolor = BillBoardColor.ToVector4();
     this.scale = scale;
     this.material = Material;
     this.rotation = rotation;
 }
 public void SetColorizeColor(Color color)
 {
     m_D3DEffect.SetValue(m_colorizeColor, color.ToVector4());
 }