public MochaVec4(Microsoft.Xna.Framework.Vector4 vec) { x = vec.X; y = vec.Y; z = vec.Z; w = vec.W; }
public override void Construct() { var font = Root.GetTileSheet("font10"); var size = font.MeasureString(Text); // TODO (mklingensmith) why do I need this padding? size.X = (int)(size.X * 1.25f); size.Y = (int)(size.Y * 1.75f); Font = "font10"; TextColor = new Microsoft.Xna.Framework.Vector4(1, 1, 1, 1); Border = "border-dark"; Rect = new Microsoft.Xna.Framework.Rectangle(0, 0, size.X, size.Y); TextVerticalAlign = Gui.VerticalAlign.Center; TextHorizontalAlign = Gui.HorizontalAlign.Center; OnUpdate = (sender, time) => { Update(DwarfTime.LastTime); }; if (OnClick == null) { OnClick = (sender, args) => { Root.DestroyWidget(this); }; } HoverTextColor = Microsoft.Xna.Framework.Color.LightGoldenrodYellow.ToVector4(); ChangeColorOnHover = true; Root.RegisterForUpdate(this); base.Construct(); }
public void CopyToEffect(EffectTexture2D.Scalar4 dst, string name, XNAV4 defval) { dst.Texture = UseChannelTexture(name); dst.Sampler = UseChannelSampler(name); dst.Scale = GetScaler(name, defval); dst.SetIndex = GetTextureSet(name); dst.Transform = GetTransform(name); }
public static Vector4 ConvertFrom(Microsoft.Xna.Framework.Vector4 value) { return(new Vector4() { X = value.X, Y = value.Y, Z = value.Z, W = value.W }); }
public static Matrix <float> CreateTranslation(Vector4 value) { var m = CreateIdentity(); m[4, 0] = value.X; m[4, 1] = value.Y; m[4, 2] = value.Z; m[4, 3] = value.W; return(m); }
public static Matrix <float> CreateScale(Vector4 value) { var m = new Matrix <float>(5); m[0, 0] = value.X; m[1, 1] = value.Y; m[2, 2] = value.Z; m[3, 3] = value.W; m[4, 4] = 1f; return(m); }
/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/> protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext) { // if the device changed, call Warm() if ((state.DeviceUniqueIndex != DepthOutRg.gd)) { this.WarmShader(state); ic = true; } // Force updating if the instance has changed this.vreg_change = (this.vreg_change | ic); this.vbreg_change = (this.vbreg_change | ic); this.vireg_change = (this.vireg_change | ic); // Set the value for attribute 'cameraNearFar' this.vreg_change = (this.vreg_change | state.SetCameraNearFarVector2(ref this.vreg[9], ref this.sc0)); // Set the value for attribute 'viewDirection' this.vreg_change = (this.vreg_change | state.SetViewDirectionVector3(ref this.vreg[7], ref this.sc1)); // Set the value for attribute 'viewPoint' this.vreg_change = (this.vreg_change | state.SetViewPointVector3(ref this.vreg[8], ref this.sc2)); Microsoft.Xna.Framework.Vector4 unused = new Microsoft.Xna.Framework.Vector4(); // Set the value for attribute 'worldMatrix' this.vreg_change = (this.vreg_change | state.SetWorldMatrix(ref this.vreg[4], ref this.vreg[5], ref this.vreg[6], ref unused, ref this.sc3)); // Set the value for attribute 'worldViewProj' this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.sc4)); if ((this.vreg_change == true)) { DepthOutRg.fx.vs_c.SetValue(this.vreg); this.vreg_change = false; ic = true; } if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Blending)) { ic = (ic | state.SetBlendMatricesDirect(DepthOutRg.fx.vsb_c, ref this.sc5)); } if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Instancing)) { this.vireg_change = (this.vireg_change | state.SetViewProjectionMatrix(ref this.vireg[0], ref this.vireg[1], ref this.vireg[2], ref this.vireg[3], ref this.sc6)); if ((this.vireg_change == true)) { DepthOutRg.fx.vsi_c.SetValue(this.vireg); this.vireg_change = false; ic = true; } } // Finally, bind the effect if ((ic | ec)) { state.SetEffect(this, ref DepthOutRg.fx, ext); } }
private void ReactToChangedAnimationFrame(string spriteName, AnimationChainContainer animationChainContainer, LayeredTileMap layeredTileMap) { AnimationFrame animationFrame = animationChainContainer.CurrentFrame; Microsoft.Xna.Framework.Vector4 textureValues = new Microsoft.Xna.Framework.Vector4(); foreach (var mapLayer in layeredTileMap.MapLayers) { var nameDictionary = mapLayer.NamedTileOrderedIndexes; if (nameDictionary.ContainsKey(spriteName)) { var indexes = nameDictionary[spriteName]; foreach (int value in indexes) { textureValues.X = animationFrame.LeftCoordinate; textureValues.Y = animationFrame.RightCoordinate; textureValues.Z = animationFrame.TopCoordinate; textureValues.W = animationFrame.BottomCoordinate; var flipFlags = mapLayer.FlipFlagArray[value]; if ((flipFlags & TMXGlueLib.DataTypes.ReducedQuadInfo.FlippedHorizontallyFlag) == TMXGlueLib.DataTypes.ReducedQuadInfo.FlippedHorizontallyFlag) { var temp = textureValues.Y; textureValues.Y = textureValues.X; textureValues.X = temp; } if ((flipFlags & TMXGlueLib.DataTypes.ReducedQuadInfo.FlippedVerticallyFlag) == TMXGlueLib.DataTypes.ReducedQuadInfo.FlippedVerticallyFlag) { var temp = textureValues.Z; textureValues.Z = textureValues.W; textureValues.W = temp; } mapLayer.PaintTileTextureCoordinates(value, textureValues.X, textureValues.Z, textureValues.Y, textureValues.W); // not sure why it's done this way, copied from MapDrawableBatch... if ((flipFlags & TMXGlueLib.DataTypes.ReducedQuadInfo.FlippedDiagonallyFlag) == TMXGlueLib.DataTypes.ReducedQuadInfo.FlippedDiagonallyFlag) { mapLayer.ApplyDiagonalFlip(value); } } } } }
private bool TryProjectPrimitive(ref HyperLine hyperLine, Matrix <float> worldViewProjection) { Vector4 u = new Vector4(); var pStart = ProjectVector(hyperLine.Start, worldViewProjection, out u.X); var pEnd = ProjectVector(hyperLine.End, worldViewProjection, out u.Y); const float epsilon = float.Epsilon; if (u.X < epsilon || u.Y < epsilon) { return(false); } pStart /= u.X; pEnd /= u.Y; hyperLine = new HyperLine(pStart, pEnd, hyperLine.Color); return(true); }
/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/> protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext) { // if the device changed, call Warm() if ((state.DeviceUniqueIndex != DrawVelocityBillboardParticles_GpuTex3D.gd)) { this.WarmShader(state); ic = true; } // Force updating if the instance has changed this.vreg_change = (this.vreg_change | ic); // Set the value for attribute 'viewPoint' this.vreg_change = (this.vreg_change | state.SetViewPointVector3(ref this.vreg[7], ref this.sc0)); Microsoft.Xna.Framework.Vector4 unused = new Microsoft.Xna.Framework.Vector4(); // Set the value for attribute 'worldMatrix' this.vreg_change = (this.vreg_change | state.SetWorldMatrix(ref this.vreg[4], ref this.vreg[5], ref this.vreg[6], ref unused, ref this.sc1)); // Set the value for attribute 'worldViewProj' this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.sc2)); // Assign pixel shader textures and samplers if ((ic | this.ptc)) { state.SetPixelShaderSamplers(this.ptx, this.pts); this.ptc = false; } // Assign pixel shader textures and samplers if ((ic | this.vtc)) { state.SetVertexShaderSamplers(this.vtx, this.vts); this.vtc = false; } if ((this.vreg_change == true)) { DrawVelocityBillboardParticles_GpuTex3D.fx.vs_c.SetValue(this.vreg); this.vreg_change = false; ic = true; } // Finally, bind the effect if ((ic | ec)) { state.SetEffect(this, ref DrawVelocityBillboardParticles_GpuTex3D.fx, ext); } }
public static Vector4 Multiply(this Matrix matrix, Vector4 vector) { if (matrix == null) { throw new ArgumentNullException("matrix"); } if (vector == null) { throw new ArgumentNullException("vector"); } var product = new Vector4(); for (var i = 0; i < 4; i++) { for (var k = 0; k < 4; k++) { product.SetIndex(i, product.Index(i) + matrix[i, k] * vector.Index(k)); } } return(product); }
private Vector4 ProjectVector(Vector4 v, Matrix <float> transform, out float uComponent) { // matrix applied to right side (row-vector) float x = v.X * transform.Elements[0] + v.Y * transform.Elements[5] + v.Z * transform.Elements[10] + v.W * transform.Elements[15] + transform.Elements[20]; float y = v.X * transform.Elements[1] + v.Y * transform.Elements[6] + v.Z * transform.Elements[11] + v.W * transform.Elements[16] + transform.Elements[21]; float z = v.X * transform.Elements[2] + v.Y * transform.Elements[7] + v.Z * transform.Elements[12] + v.W * transform.Elements[17] + transform.Elements[22]; float w = v.X * transform.Elements[3] + v.Y * transform.Elements[8] + v.Z * transform.Elements[13] + v.W * transform.Elements[18] + transform.Elements[23]; uComponent = v.X * transform.Elements[4] + v.Y * transform.Elements[9] + v.Z * transform.Elements[14] + v.W * transform.Elements[19] + transform.Elements[24]; return(new Vector4(x, y, z, w)); }
private XNAV4 GetScaler(string name, XNAV4 defval) { var channel = _MaterialSource.FindChannel(name); return(channel == null ? defval : new XNAV4(channel.Value[0], channel.Value[1], channel.Value[2], channel.Value[3])); }
public TestbedGameplay() { m_Selected = new List <Tantric.Logic.Unit>(); m_SelectionBox = new Microsoft.Xna.Framework.Vector4(0, 0, 1, 1); }
public static float GetW(Microsoft.Xna.Framework.Vector4 v) { return(v.W); }
public HyperLine(Vector4 start, Vector4 end, Color color) { Start = start; End = end; Color = color; }
public Color(Microsoft.Xna.Framework.Vector4 v) { _color = (Color) new Microsoft.Xna.Framework.Color(v); }
public static Color FromNonPremultiplied(Microsoft.Xna.Framework.Vector4 vector) { return(Microsoft.Xna.Framework.Color.FromNonPremultiplied(vector)); }
public Vector4(float x, float y, float z, float w) { _vector = new Vector(x, y, z, w); }
public static Vector4 Normalize(Vector4 v) { return(new Vector4(Vector.Normalize(v))); }
private Vector4(Vector v) { _vector = v; }
private Vector4(Vector v) { _vector = v; }
public static Vector4 Slerp(Vector4 v1, Vector4 v2, float amount) { return(new Vector4(Vector.SmoothStep(v1, v2, amount))); }
public static Vector4 Lerp(Vector4 v1, Vector4 v2, float amount) { return(new Vector4(Vector.Lerp(v1, v2, amount))); }
public static Vector4 Transform(Vector4 val, Matrix transform) { return(new Vector4(Vector.Transform(val, transform))); }
public static Vector4 Hermite(Vector4 v1, Vector4 t1, Vector4 v2, Vector4 t2, float amount) { return(new Vector4(Vector.Hermite(v1, t1, v2, t2, amount))); }
public static System.Numerics.Vector4 ToCS(this Microsoft.Xna.Framework.Vector4 vector) { return(new System.Numerics.Vector4(vector.X, vector.Y, vector.Z, vector.W)); }
public static SlimDX.Vector4 dx(this Microsoft.Xna.Framework.Vector4 v) { return(new SlimDX.Vector4(v.X, v.Y, v.Z, v.W)); }
public static Vector4 CatmullRom(Vector4 v1, Vector4 v2, Vector4 v3, Vector4 v4, float amount) { return(new Vector4(Vector.CatmullRom(v1, v2, v3, v4, amount))); }
public static Vector4 ToSlimDX(this Microsoft.Xna.Framework.Vector4 v) { return(new Vector4(v.X, v.Y, v.Z, v.W)); }
public static Vector4 Barycentric(Vector4 v1, Vector4 v2, Vector4 v3, float a1, float a2) { return(new Vector4(Vector.Barycentric(v1, v2, v3, a1, a2))); }
public static Vector4 Clamp(Vector4 val, Vector4 min, Vector4 max) { return(new Vector4(Vector.Clamp(val, min, max))); }
public Vector4(float x, float y, float z,float w) { _vector = new Vector(x, y, z, w); }