protected override void OnLostFocus(EventArgs e) { // Set state to Normal base.OnLostFocus(e); drawState = DrawState.Normal; Invalidate(); }
protected void DrawBackground( Graphics g, DrawState state ) { Rectangle rc = ClientRectangle; // Draw background if( state == DrawState.Normal || state == DrawState.Disable ) { g.FillRectangle( SystemBrushes.Control, rc ); Pen p = ( state == DrawState.Disable ) ? SystemPens.ControlDark : SystemPens.ControlDarkDark; // Draw border rectangle g.DrawRectangle( p, rc.Left, rc.Top, rc.Width-1, rc.Height-1); } else if( state == DrawState.Hot || state == DrawState.Pressed ) { // Erase whaterver that was there before if ( state == DrawState.Hot ) g.FillRectangle( ColorUtil.VSNetSelectionBrush, rc ); else g.FillRectangle( ColorUtil.VSNetPressedBrush, rc ); // Draw border rectangle g.DrawRectangle( SystemPens.Highlight, rc.Left, rc.Top, rc.Width-1, rc.Height-1 ); } }
void Start() { _drawStates = new DrawState[_pinchDetectors.Length]; for (int i = 0; i < _pinchDetectors.Length; i++) { _drawStates[i] = new DrawState(this); } }
protected override void OnGotFocus(EventArgs e) { // Set state to Hot base.OnGotFocus(e); drawState = DrawState.Hot; Invalidate(); }
//===================================================================== /// <summary>Constructor</summary> /// <param name="graphics">The graphics context</param> /// <param name="state">The drawing state of the item</param> /// <param name="offset">The image offset if scrolled</param> /// <param name="drawFocus">A flag indicating whether or not to draw the focus rectangle on return</param> public DrawImageEventArgs(Graphics graphics, DrawState state, Point offset, bool drawFocus) { this.Graphics = graphics; this.DrawState = state; this.ImageOffset = offset; this.DrawFocus = drawFocus; }
public void ChangeDrawState(DrawState drawState, int id) { //選択できる範囲外だったら何もせずに終了 if (!CanChangeDrawState(drawState, id)) return; switch (drawState) { case DrawState.MapChip: MapChipPalletViewModel.DrawMapState.Set(id); ObjectChipPalletViewModel.SelectCancel(); _current = MapChipPalletViewModel; break; case DrawState.ObjChip: ObjectChipPalletViewModel.DrawObjectState.Set(id); MapChipPalletViewModel.SelectCancel(); _current = ObjectChipPalletViewModel; break; case DrawState.Empty: //何もしない break; default: throw new ArgumentOutOfRangeException("drawState"); } }
protected override void OnMouseEnter(EventArgs e) { // Set state to hot base.OnMouseEnter(e); drawState = DrawState.Hot; Invalidate(); }
protected void DrawBackground(Graphics g, DrawState state) { Rectangle rc = ClientRectangle; // Draw background if (state == DrawState.Normal || state == DrawState.Disable) { g.FillRectangle(new SolidBrush(SystemColors.Control), rc); using (SolidBrush rcBrush = state == DrawState.Disable ? new SolidBrush(SystemColors.ControlDark) : new SolidBrush(SystemColors.ControlDarkDark)) { // Draw border rectangle g.DrawRectangle(new Pen(rcBrush), rc.Left, rc.Top, rc.Width - 1, rc.Height - 1); } } else if ( state == DrawState.Hot || state == DrawState.Pressed ) { // Erase whaterver that was there before if ( state == DrawState.Hot ) g.FillRectangle(new SolidBrush(ColorUtil.VSNetSelectionColor), rc); else g.FillRectangle(new SolidBrush(ColorUtil.VSNetPressedColor), rc); // Draw border rectangle g.DrawRectangle(SystemPens.Highlight, rc.Left, rc.Top, rc.Width-1, rc.Height-1); } }
protected override IShader BindShader(DrawState state, bool maskOnly) { Xen.Ex.Graphics2D.Statistics.DrawGraphLine shader = state.GetShader<Xen.Ex.Graphics2D.Statistics.DrawGraphLine>(); if (dirty) { float x = widthScale; for (int i = 0; i < graphData.Length; i++) { int index = (i + this.index) % graphData.Length; float good = 0; if (goodValue != 0) { good = values[index]; good = (good - Math.Abs(goodValue)) / goodValue; } graphData[i] = new Vector4(x, values[index] * maxValueInv, 0, good); x += widthScale; } dirty = false; } shader.GraphLine = this.graphData; return shader; }
/// <summary> /// Begin the modifier (This method is called by the DrawTarget) /// </summary> /// <param name="state"></param> public void Begin(DrawState state) { enabledBuffer = enabled; this.cameras = state.Camera; if (enabledBuffer) state.Cullers.PushPostCuller(this); }
public MatrixCalc(MatrixOp op, MatrixSource provider, MatrixSource source, DrawState state) { #if DEBUG this.state = state; #endif this.op = op; this.provider = provider; this.source = source; }
protected void DrawButtonState(Graphics g, DrawState state) { DrawBackground(g, state); Rectangle rc = ClientRectangle; bool hasText = false; bool hasImage = Image != null; Size textSize = new Size(0,0); if ( Text != string.Empty && Text != "" ) { hasText = true; textSize = TextUtil.GetTextSize(g, Text, Font); } int imageWidth = 0; int imageHeight = 0; if ( hasImage ) { SizeF sizeF = Image.PhysicalDimension; imageWidth = (int)sizeF.Width; imageHeight = (int)sizeF.Height; // We are assuming that the button image is smaller than // the button itself if ( imageWidth > rc.Width || imageHeight > rc.Height) { Debug.WriteLine("Image dimensions need to be smaller that button's dimension..."); return; } } int x, y; if ( hasText && !hasImage ) { // Text only drawing x = (Width - textSize.Width)/2; y = (Height - textSize.Height)/2; DrawText(g, Text, state, x, y); } else if ( hasImage && !hasText ) { // Image only drawing x = (Width - imageWidth)/2; y = (Height - imageHeight)/2; DrawImage(g, state, Image, x, y); } else { // Text and Image drawing x = (Width - textSize.Width - imageWidth -2)/2; y = (Height - imageHeight)/2; DrawImage(g, state, Image, x, y); x += imageWidth + 2; y = (Height - textSize.Height)/2; DrawText(g, Text, state, x, y); } }
protected override void OnMouseLeave(EventArgs e) { // Set state to Normal base.OnMouseLeave(e); if ( !ContainsFocus ) { drawState = DrawState.Normal; Invalidate(); } }
protected void DrawButtonState( Graphics g, DrawState state ) { DrawBackground( g, state ); Rectangle rc = ClientRectangle; Rectangle rcText = Rectangle.Inflate( ClientRectangle, -1, -1 ); // draw Image if( Image != null ) { SizeF sizeF = Image.PhysicalDimension; int imgWidth = (int)sizeF.Width; int imgHeight = (int)sizeF.Height; StringAlignment imgVAlign = GetVerticalAlign( ImageAlign ); StringAlignment imgHAlign = GetHorizontalAlign( ImageAlign ); int minWid = Width - 2, minHg = Height - 2; minWid = Math.Min( minWid, imgWidth ); minHg = Math.Min( minHg, imgHeight ); int xPos = Math.Min( minHg, minWid ) + 2; Bitmap bmp = new Bitmap( Image, new Size( minWid, minHg ) ); int y = 1; if( imgVAlign == StringAlignment.Center ) { y = ( Height - bmp.Height ) / 2; } else if( imgVAlign == StringAlignment.Far ) { y = ( Height - bmp.Height - 1 ); } switch( imgHAlign ) { case StringAlignment.Near: rcText.X = xPos; rcText.Width -= xPos; DrawImage( g, state, bmp, 2+(xPos-minWid)/2, y ); break; case StringAlignment.Far: rcText.Width = rcText.Right - xPos; DrawImage( g, state, bmp, rcText.Right + (xPos-minWid)/2 - 2, y ); break; } bmp.Dispose(); } // draw Text DrawText( g, Text, state, rcText ); }
public override void Draw(IOutputCommand output, DrawState state, object param) { double I, J; if (!TryGetVariable('I', out I)) { I = 0; } if (!TryGetVariable('J', out J)) { J = 0; } output.DrawArc(this,param, Convert(Movetype, state), CalculatedStartPosition, CalculatedEndPosition,new Framework.Tools.Drawing.Point3D() { X=I, Y=J},true); }
protected void DrawBackground(Graphics g, DrawState state) { Rectangle rc = this.ClientRectangle; if (_focusedBackgroundBrush == null) { CreateBrushes(); } if (state == DrawState.Normal || state == DrawState.Disabled) { g.FillRectangle(_checked ? SystemBrushes.ControlLight : SystemBrushes.Control, rc); if (_checked) { ControlPaint.DrawBorder3D(g, rc, Border3DStyle.Sunken); } else if (_borderstyle != BorderStyle.None) { //!!g.FillRectangle(new SolidBrush(this.BackColor), rc); g.DrawRectangle(state == DrawState.Disabled ? SystemPens.ControlDark : SystemPens.ControlDarkDark, rc.Left, rc.Top, rc.Width - 1, rc.Height - 1); } } else if (state == DrawState.Hover || state == DrawState.Focused) { if (state == DrawState.Hover) { g.FillRectangle(_hoverBackgroundBrush, rc); } else { g.FillRectangle(_focusedBackgroundBrush, rc); } g.DrawRectangle(SystemPens.Highlight, rc.Left, rc.Top, rc.Width - 1, rc.Height - 1); } }
protected void DrawBackground(Graphics g, DrawState state) { Rectangle rc = ClientRectangle; // Draw background if (state == DrawState.Normal || state == DrawState.Disable) { g.FillRectangle(new SolidBrush(SystemColors.Control), rc); SolidBrush rcBrush; if (state == DrawState.Disable) { rcBrush = new SolidBrush(SystemColors.ControlDark); } else { rcBrush = new SolidBrush(SystemColors.ControlDarkDark); } // Draw border rectangle g.DrawRectangle(new Pen(rcBrush), rc.Left, rc.Top, rc.Width - 1, rc.Height - 1); } else if (state == DrawState.Hot || state == DrawState.Pressed) { // Erase whaterver that was there before if (state == DrawState.Hot) { g.FillRectangle(new SolidBrush(ColorUtil.VSNetSelectionColor), rc); } else { g.FillRectangle(new SolidBrush(ColorUtil.VSNetPressedColor), rc); } // Draw border rectangle g.DrawRectangle(SystemPens.Highlight, rc.Left, rc.Top, rc.Width - 1, rc.Height - 1); } }
public static void OnBegin(XSpriteBatch __instance, ref SpriteSortMode sortMode, BlendState?blendState, SamplerState?samplerState, DepthStencilState?depthStencilState, RasterizerState?rasterizerState, Effect?effect, Matrix?transformMatrix) { if (!Config.IsEnabled) { return; } /* * if (sortMode is (SpriteSortMode.Deferred or SpriteSortMode.Immediate)) { * sortMode = SpriteSortMode.Texture; * } */ DrawState.OnBegin( __instance, sortMode, blendState ?? BlendState.AlphaBlend, samplerState ?? SamplerState.PointClamp, depthStencilState ?? DepthStencilState.None, rasterizerState ?? RasterizerState.CullCounterClockwise, effect, transformMatrix ?? Matrix.Identity ); }
/// <summary></summary> /// <param name="state"></param> protected override void DrawItems(DrawState state) { //draw all items in the tree minBuffer[0] = boundsMin.X; minBuffer[1] = boundsMin.Y; minBuffer[2] = boundsMin.Z; maxBuffer[0] = boundsMax.X; maxBuffer[1] = boundsMax.Y; maxBuffer[2] = boundsMax.Z; if (this.count > 64 && state.Application.ThreadPool.ThreadCount > 0) { //if there are lots of items and free threads, then traverse the tree on multiple threads DrawItemsThread(state); return; } Matrix world; state.GetWorldMatrix(out world); allNodes[0].Draw(state, minBuffer, maxBuffer, 0, allChildren, allNodes, world == Matrix.Identity, this.IsOptimizedState); }
void IBeginEndDraw.Begin(DrawState state) { if (currentlyActive) { throw new InvalidOperationException("This viewport modified is already in use"); } currentlyActive = true; if (enabled) { GraphicsDevice device = state.graphics; previous = device.Viewport; Viewport vp = new Viewport(); int x = state.DrawTarget.Width, y = state.DrawTarget.Height; vp.MaxDepth = maxDepth; vp.MinDepth = minDepth; vp.X = (int)(left * x + 0.5f); vp.Y = (int)(top * y + 0.5f); vp.Width = (int)(Width * x + 0.5f); vp.Height = (int)(Height * y + 0.5f); device.Viewport = vp; currentlyEnabled = true; } }
private void ApplyShaderProgram(DrawState drawState, SceneState sceneState) { ShaderProgramGL3x shaderProgramGL3x = (ShaderProgramGL3x)drawState.ShaderProgram; if (_boundShaderProgram != shaderProgramGL3x) { shaderProgramGL3x.Bind(); _boundShaderProgram = shaderProgramGL3x; } _boundShaderProgram.Clean(this, drawState, sceneState); #if DEBUG GL.ValidateProgram(_boundShaderProgram.Handle.Value); int validateStatus; GL.GetProgram(_boundShaderProgram.Handle.Value, ProgramParameter.ValidateStatus, out validateStatus); if (validateStatus == 0) { throw new ArgumentException( "Shader program validation failed: " + _boundShaderProgram.Log, "drawState.ShaderProgram"); } #endif }
public void UpdateDirtyRegions(DrawState state, object target, object parent) { int writeRange = -1; foreach (DirtyRange range in dirtyRanges) { if ((range.start == 0 && range.length == Count) || !isList) { //write buffer from the start writeRange = Math.Max(writeRange, (range.length + range.start) * Stride); } else { WriteBuffer(state, range.start, range.length * Stride, target, parent); } } if (writeRange != -1) { WriteBuffer(state, 0, writeRange, target, parent); } dirtyRanges.Clear(); }
/// <summary></summary> /// <param name="state"></param> /// <param name="repeat"></param> /// <param name="camera"></param> /// <returns></returns> internal override bool BeginRepeat(DrawState state, int repeat, ref ICamera camera) { if (isDisposed) throw new ObjectDisposedException("this"); GraphicsDevice device = state.graphics; if (!facesEnabled[repeat]) return false; #if XBOX360 state.nonScreenRenderComplete = true; #endif if (repeat == minFaceEnabled) { if (texture == null) { Warm(state); } if (texture.IsDisposed) throw new ObjectDisposedException("RenderTexture"); state.shaderSystem.ResetTextures(); } device.SetRenderTarget(texture, (CubeMapFace)repeat); if (cubeCamera == null) cubeCamera = new Camera3D(new Projection(MathHelper.PiOver2,1,100,1)); if (repeat == minFaceEnabled) { camera.GetCameraMatrix(out cubeCameraMatrix); if (camera is Camera3D) { this.cubeCamera.Projection.NearClip = ((Camera3D)camera).Projection.NearClip; this.cubeCamera.Projection.FarClip = ((Camera3D)camera).Projection.FarClip; this.cubeCamera.Projection.UseLeftHandedProjection = true;// ((Camera3D)camera).Projection.UseLeftHandedProjection; this.cubeCamera.ReverseBackfaceCulling = true; } else { this.cubeCamera.Projection.NearClip = 1; this.cubeCamera.Projection.FarClip = 100; this.cubeCamera.Projection.UseLeftHandedProjection = false; } } Matrix view; Matrix.Multiply(ref CubeMapFaceMatrices[repeat], ref cubeCameraMatrix, out view); this.cubeCamera.SetCameraMatrix(ref view); camera = this.cubeCamera; return true; }
//NEW CODE private void DrawBoundingBoxes(DrawState state) { //First, get the animated bone transforms of the model. //These transforms are in 'bone-space', not in world space. ReadOnlyArrayCollection <Transform> boneAnimationTransforms = model.GetAnimationController().GetTransformedBones(state); //Get a simple shader from Xen.Ex that fills a solid colour Xen.Ex.Shaders.FillSolidColour shader = state.GetShader <Xen.Ex.Shaders.FillSolidColour>(); shader.FillColour = Color.White.ToVector4(); shader.Bind(state); //push the render state... state.PushRenderState(); //disable back face culling state.RenderState.DepthColourCull.CullMode = CullMode.None; //set to wireframe state.RenderState.DepthColourCull.FillMode = FillMode.WireFrame; //loop through all the geometry data in the model.. //(note, the sample model has only 1 geometry instance) Xen.Ex.Graphics.Content.SkeletonData modelSkeleton = model.ModelData.Skeleton; Matrix matrix; int boxIndex = 0; foreach (Xen.Ex.Graphics.Content.MeshData meshData in model.ModelData.Meshes) { foreach (Xen.Ex.Graphics.Content.GeometryData geometry in meshData.Geometry) { //now loop through all bones used by this geometry for (int geometryBone = 0; geometryBone < geometry.BoneIndices.Length; geometryBone++) { //index of the bone (a piece of geometry may not use all the bones in the model) int boneIndex = geometry.BoneIndices[geometryBone]; //get the base transform of the bone (the transform when not animated) Transform boneTransform = modelSkeleton.BoneWorldTransforms[boneIndex]; //multiply the transform with the animation bone-local transform //it would be better to use Transform.Multiply() here to save data copying on the xbox boneTransform *= boneAnimationTransforms[boneIndex]; //Get the transform as a matrix boneTransform.GetMatrix(out matrix); //push the matrix state.PushWorldMatrix(ref matrix); //draw the box if (boundingBoxes[boxIndex].CullTest(state)) { boundingBoxes[boxIndex].Draw(state); } boxIndex++; //pop the world matrix state.PopWorldMatrix(); } } } //pop the render state state.PopRenderState(); }
protected override void Draw(DrawState state) { drawToScreen.Draw(state); }
public void UnloadContent(ContentRegister content, DrawState state) { }
public void LoadContent(ContentRegister content, DrawState state, ContentManager manager) { //load the model data into the model instance model.ModelData = manager.Load <Xen.Ex.Graphics.Content.ModelData>(@"tiny_4anim"); }
/// <summary></summary> /// <param name="state"></param> protected internal override void End(DrawState state) { }
/// <summary></summary> /// <param name="state"></param> protected internal abstract void End(DrawState state);
public override void Draw(IOutputCommand output, DrawState state, object param) { //base.Draw(output, state, param); state.LaserOn = false; state.UseLaser = true; }
/// <summary>Begin drawing this cube as a batch operation</summary> public StreamFrequency.InstanceBuffer BeginDrawBatch(DrawState state, int maxInstances) { return(state.BeginDrawBatch(maxInstances)); }
/// <summary> /// Draw the cube geometry /// </summary> /// <param name="state"></param> public void Draw(DrawState state) { verts.Draw(state, inds, PrimitiveType.TriangleList); }
protected override void BindOverride(DrawState state) { HalfVector = state.Camera.HalfVector; WorldViewProjection = state.WorldViewProjection; }
//call made by a particle drawer internal void DrawCallback(DrawState state, IParticleSystemDrawer particleDrawer) { if (systemLogic == null) throw new InvalidOperationException("Attempting to draw a ParticleSystem with unassigned ParticleSystemData Content"); if (disposed) return; this.drawProc.MarkAsDrawn(); //loop all the particle stores, and draw them all foreach (ParticleStore store in this.particleStore) store.ParticleProcessor.DrawCallback(state, particleDrawer, store.Count); }
/// <summary></summary> /// <param name="state"></param> /// <param name="repeat"></param> internal override void EndRepeat(DrawState state, int repeat) { if (texture.IsDisposed) throw new ObjectDisposedException("RenderTexture"); }
/// <summary> /// Draws the specified texture using specified draw-state , with a tint color. /// </summary> /// <param name="name">The name of the item to draw.</param> /// <param name="drawState">The state that contains all the info to draw the item.</param> /// <param name="tintColor">The color to use to tint the shown item.</param> public abstract void Draw(string name, DrawState drawState, GUIColor tintColor);
/// <summary></summary> /// <param name="state"></param> protected internal abstract void Begin(DrawState state);
public abstract void Set(Context context, DrawState drawState, SceneState sceneState);
internal virtual bool BeginRepeat(DrawState state, int repeat, ref ICamera camera) { return true; }
internal virtual void EndRepeat(DrawState state, int repeat) { }
/// <summary></summary> /// <param name="state"></param> protected internal override void Begin(DrawState state) { #if DEBUG if (this.application != Application.GetApplicationInstance()) throw new InvalidOperationException("DrawTargetScreen is being used with an application it wasn't created with"); #endif GraphicsDevice device = state.graphics; state.shaderSystem.ResetTextures(); device.SetRenderTarget(null); Vector2 ws = new Vector2((float)Width, (float)Height); if (ws.X != windowSize.X || ws.Y != windowSize.Y) { windowSize = ws; windowSizeChangeIndex = System.Threading.Interlocked.Increment(ref DrawTarget.baseSizeIndex); } }
/// <summary></summary> /// <param name="state"></param> protected internal override void End(DrawState state) { if (targets == null) throw new ObjectDisposedException("this"); }
/// <summary></summary> /// <param name="state"></param> protected internal override void Begin(DrawState state) { if (targets == null) throw new ObjectDisposedException("this"); for (int i = 0; i < targets.Length; i++) { targets[i].Warm(state); if (targets[i].IsDisposed) throw new ObjectDisposedException("RenderTexture"); } #if XBOX360 state.nonScreenRenderComplete = true; #endif GraphicsDevice device = state.graphics; state.shaderSystem.ResetTextures(); if (binding == null) { this.binding = new RenderTargetBinding[targets.Length]; for (int i = 0; i < targets.Length; i++) binding[i] = new RenderTargetBinding(targets[i].GetRenderTarget2D()); } device.SetRenderTargets(binding); }
protected TextureSurface(DrawState defaultDrawState) : base(defaultDrawState) { }
public void Draw(DrawContext drawContext, Camera camera, Box2 bounds, float opacity) { if (Texture == null) { return; } var renderer = DrawState.Prepare(drawContext.Get <SpriteRenderer>(), camera, RenderStates); var color = Color.WithOpacity(opacity); float textureX0 = 0; float textureY0 = 0; float textureX1 = Texture.Width; float textureY1 = Texture.Height; var scaleH = bounds.Width / Texture.Width; var scaleV = bounds.Height / Texture.Height; float scale; switch (ScaleMode) { case ScaleMode.Fill: if (scaleH > scaleV) { scale = scaleH; textureY0 = (Texture.Height - bounds.Height / scale) * 0.5f; textureY1 = Texture.Height - textureY0; } else { scale = scaleV; textureX0 = (Texture.Width - bounds.Width / scale) * 0.5f; textureX1 = Texture.Width - textureX0; } break; case ScaleMode.Fit: case ScaleMode.RepeatFit: scale = Math.Min(scaleH, scaleV); break; default: scale = 1f; break; } switch (ScaleMode) { case ScaleMode.Repeat: case ScaleMode.RepeatFit: for (var y = bounds.Top; y < bounds.Bottom; y += Texture.Height * scale) { for (var x = bounds.Left; x < bounds.Right; x += Texture.Width * scale) { var textureX = Math.Min((bounds.Right - x) / scale, Texture.Width); var textureY = Math.Min((bounds.Bottom - y) / scale, Texture.Height); renderer.Draw(Texture, x, y, 0, 0, scale, scale, 0, color, 0, 0, textureX, textureY); } } break; default: renderer.Draw(Texture, (bounds.Left + bounds.Right) * 0.5f, (bounds.Top + bounds.Bottom) * 0.5f, (textureX1 - textureX0) * 0.5f, (textureY1 - textureY0) * 0.5f, scale, scale, Rotation, color, textureX0, textureY0, textureX1, textureY1); break; } }
// Start is called before the first frame update void Start() { inkLeft = inkCapacity; gameState = DrawState.Pending; }
/// <summary> /// Warms the particle system (preloads any resources used) /// </summary> /// <param name="state"></param> public void Warm(DrawState state) { if (this.systemData == null) throw new InvalidOperationException("ParticleSystemData == null"); foreach (ParticleStore store in this.particleStore) store.ParticleProcessor.Warm(state.Application); }
//draws on CPU particle systems /// <summary> /// draws the particles from a CPU system /// </summary> protected override void DrawCpuParticles(DrawState state, Content.ParticleSystemTypeData particleType, uint particleCount, AlphaBlendState blendMode, Vector4[] positionSize, Vector4[] velocityRotation, Vector4[] colourData, Vector4[] userValues) { //this is very similar to the billboard drawer (see it for reference) Vector2 targetSize = state.DrawTarget.Size; state.PushRenderState(); state.RenderState.AlphaBlend = blendMode; state.RenderState.DepthColourCull.DepthWriteEnabled = false; Texture2D displayTexture = particleType.Texture ?? Xen.Ex.Material.WhiteTexture.GetTexture(state); BillboardParticles2DElement.GenerateBillboardVertices(state, ref this.vertices, ref this.indices); int count = (int)particleCount; DrawVelocityParticles_BillboardCpu shaderNoColour = null; DrawVelocityParticlesColour_BillboardCpu shaderColour = null; if (colourData != null) { shaderColour = state.GetShader <DrawVelocityParticlesColour_BillboardCpu>(); } else { shaderNoColour = state.GetShader <DrawVelocityParticles_BillboardCpu>(); } Vector2 velScale = new Vector2(velocityScale, 0); if (this.useRotationToScaleVelocityEffect) { velScale = new Vector2(0, velocityScale); } int drawn = 0; while (count > 0) { int drawCount; drawCount = Math.Min(count, 80); if (colourData != null) { shaderColour.PositionData.SetArray(positionSize, drawn); shaderColour.VelocityData.SetArray(velocityRotation, drawn); shaderColour.ColourData.SetArray(colourData, drawn); shaderColour.DisplayTexture = displayTexture; shaderColour.SetVelocityScale(ref velScale); shaderColour.Bind(state); } else { shaderNoColour.PositionData.SetArray(positionSize, drawn); shaderNoColour.VelocityData.SetArray(velocityRotation, drawn); shaderNoColour.DisplayTexture = displayTexture; shaderNoColour.SetVelocityScale(ref velScale); shaderNoColour.Bind(state); } vertices.Draw(state, indices, PrimitiveType.TriangleList, drawCount * 2, 0, 0); count -= drawCount; drawn += drawCount; } state.PopRenderState(); }
public override void BeginDraw(DrawState state) { this.state.BeginDraw(this.Camera, state); this.Clear(); }
/// <summary> /// draws the particles on a GPU system /// </summary> protected override void DrawGpuParticles(DrawState state, Content.ParticleSystemTypeData particleType, uint particleCount, AlphaBlendState blendMode, Texture2D positionTex, Texture2D velocityRotation, Texture2D colourTex, Texture2D userValues, bool usesUserValuesPositionBuffer) { //this is very similar to the billboard drawer (see it for reference) Vector2 targetSize = state.DrawTarget.Size; state.PushRenderState(); state.RenderState.AlphaBlend = blendMode; state.RenderState.DepthColourCull.DepthWriteEnabled = false; Texture2D displayTexture = particleType.Texture ?? Xen.Ex.Material.WhiteTexture.GetTexture(state); //get the shared vertice BillboardParticles2DElement.GenerateBillboardVertices(state, ref vertices, ref indices); int count = (int)particleCount; DrawVelocityParticles_GpuTex shaderNoColour = null; DrawVelocityParticlesColour_GpuTex shaderColour = null; //user variants DrawVelocityParticles_GpuTex_UserOffset shaderNoColour_UO = null; DrawVelocityParticlesColour_GpuTex_UserOffset shaderColour_UO = null; float resolutionXF = (float)positionTex.Width; float resolutionYF = (float)positionTex.Height; Vector2 invTextureSize; Vector2 velScale = new Vector2(velocityScale, 0); if (this.useRotationToScaleVelocityEffect) { velScale = new Vector2(0, velocityScale); } invTextureSize = new Vector2(1.0f / resolutionXF, 1.0f / resolutionYF); IShader shader; if (!usesUserValuesPositionBuffer) { if (colourTex != null) { shader = shaderColour = state.GetShader <DrawVelocityParticlesColour_GpuTex>(); shaderColour.PositionTexture = positionTex; shaderColour.ColourTexture = colourTex; shaderColour.VelocityTexture = velocityRotation; shaderColour.DisplayTexture = displayTexture; shaderColour.SetVelocityScale(ref velScale); } else { shader = shaderNoColour = state.GetShader <DrawVelocityParticles_GpuTex>(); shaderNoColour.PositionTexture = positionTex; shaderNoColour.VelocityTexture = velocityRotation; shaderNoColour.DisplayTexture = displayTexture; shaderNoColour.SetVelocityScale(ref velScale); } } else { if (colourTex != null) { shader = shaderColour_UO = state.GetShader <DrawVelocityParticlesColour_GpuTex_UserOffset>(); shaderColour_UO.PositionTexture = positionTex; shaderColour_UO.ColourTexture = colourTex; shaderColour_UO.VelocityTexture = velocityRotation; shaderColour_UO.UserTexture = userValues; shaderColour_UO.DisplayTexture = displayTexture; shaderColour_UO.SetVelocityScale(ref velScale); } else { shader = shaderNoColour_UO = state.GetShader <DrawVelocityParticles_GpuTex_UserOffset>(); shaderNoColour_UO.PositionTexture = positionTex; shaderNoColour_UO.VelocityTexture = velocityRotation; shaderNoColour_UO.UserTexture = userValues; shaderNoColour_UO.DisplayTexture = displayTexture; shaderNoColour_UO.SetVelocityScale(ref velScale); } } int drawn = 0; while (count > 0) { int drawCount = Math.Min(count, vertices.Count / 4); if (!usesUserValuesPositionBuffer) { if (colourTex != null) { shaderColour.TextureSizeOffset = new Vector3(invTextureSize, (float)drawn); } else { shaderNoColour.TextureSizeOffset = new Vector3(invTextureSize, (float)drawn); } } else { if (colourTex != null) { shaderColour_UO.TextureSizeOffset = new Vector3(invTextureSize, (float)drawn); } else { shaderNoColour_UO.TextureSizeOffset = new Vector3(invTextureSize, (float)drawn); } } //bind shader.Bind(state); vertices.Draw(state, indices, PrimitiveType.TriangleList, drawCount * 2, 0, 0); count -= drawCount; drawn += drawCount; } state.PopRenderState(); }
internal DrawStateProperties(DrawState state) { this.state = state; state.Application.Content.Add(this); }
protected abstract void BindOverride(DrawState state);
/// <summary> /// Draw multiple instances of this cube geometry /// </summary> /// <param name="state"></param> /// <param name="CanDrawItem"></param> /// <param name="instances"></param> /// <param name="instanceCount"></param> public void DrawBatch(DrawState state, Callback <bool, int, ICuller> CanDrawItem, Matrix[] instances, int instanceCount) { state.DrawBatch(verts, inds, PrimitiveType.TriangleList, CanDrawItem, instances, instanceCount); }
public virtual void Bind(DrawState state) { BindOverride(state); _effect.CurrentTechnique.Passes[0].Apply(); }
/// <summary>End drawing this cube as a batch operation</summary> public void EndDrawBatch(DrawState state, StreamFrequency.InstanceBuffer buffer) { state.EndDrawBatch(verts, inds, PrimitiveType.TriangleList, buffer); }
public void Warm(DrawState state) { lock (this) WarmOverride(state); }
// Update is called once per frame void Update() { //ProcessInputs(); // calculate raycasted position RaycastHit hit; if (Physics.Raycast(transform.position, Vector3.down, out hit, Mathf.Infinity, drawableLayers)) { m_raycastedPosition = hit.point; } else { m_raycastedPosition = new Vector3(transform.position.x, m_raycastedPosition.y, transform.position.z); } m_particleEmitter.transform.position = new Vector3(m_raycastedPosition.x, m_raycastedPosition.y + 0.1f, m_raycastedPosition.z); switch (m_currentState) { case (DrawState.Uncreated): { m_bezierSpline.SetControlPoint(m_splinePointCount, m_raycastedPosition); break; } case (DrawState.Adding): { if (m_particles) { m_particles.Play(); } m_bezierSpline.AddCurve(); m_splinePointCount += m_bezierSpline.getDimension(); // Start control point. if (m_splinePointCount - m_bezierSpline.getDimension() > 0) { m_bezierSpline.SetControlPointMode(m_splinePointCount - m_bezierSpline.getDimension(), m_curveMode); } else { m_bezierSpline.SetControlPointMode(m_splinePointCount - m_bezierSpline.getDimension(), BezierSpline.BezierControlPointMode.Free); } m_bezierSpline.SetControlPoint(m_splinePointCount - m_bezierSpline.getDimension(), m_raycastedPosition); // End control point. m_bezierSpline.SetControlPoint(m_splinePointCount, m_raycastedPosition); m_bezierSpline.SetControlPointMode(m_splinePointCount, BezierSpline.BezierControlPointMode.Free); // Tween control points. for (int i = 1; i < m_bezierSpline.getDimension(); ++i) { //m_bezierSpline.SetControlPointMode(m_splinePointCount - i, BezierSpline.BezierControlPointMode.Free); m_bezierSpline.SetControlPoint(m_splinePointCount - i, m_raycastedPosition); } m_currentState = DrawState.Following; break; } case (DrawState.Following): { int segmentStartPointIndex = m_splinePointCount - m_bezierSpline.getDimension(); if (segmentStartPointIndex >= 0) { Vector3 segmentStartPointPosition = m_bezierSpline.GetControlPoint(segmentStartPointIndex); if (Vector3.Distance(m_raycastedPosition, segmentStartPointPosition) > m_newPointDistance) { m_currentState = DrawState.Adding; } else { for (int i = m_bezierSpline.getDimension(); i >= 1; --i) { //m_bezierSpline.SetControlPointMode(m_splinePointCount - i + 1, m_curveMode); Vector3 controlPointPosition = Vector3.Lerp(segmentStartPointPosition, m_raycastedPosition, (float)i / (float)m_bezierSpline.getDimension()); m_bezierSpline.SetControlPoint(m_splinePointCount - m_bezierSpline.getDimension() + i, controlPointPosition); } } } // drawing is completed if (checkIsComplete()) { // TODO: Remove this once we have a cleaner way to reset this. if (m_timeAngle) { m_timeAngle.reset(); } // get encompassed objects GameObject[] controllables = GameObject.FindGameObjectsWithTag("TimeControllable"); for (int i = 0; i < controllables.Length; i++) { if (GeometryHelper.PolyContainsPoint(m_bezierSpline.GetPoints(), controllables[i].transform.position)) { m_encompassed.Add(controllables[i]); controllables[i].gameObject.GetComponent <TimeControllable>().Circle(); } } // activate global time controller m_globalTime.GetComponent <AnimParameterController>().setAnimators(m_encompassed); m_globalTime.GetComponent <AnimParameterController>().setActive(true); m_currentState = DrawState.Complete; } break; } case (DrawState.Complete): { m_particles.Stop(); if (m_lineWalker && !m_lineWalker.getIsActive()) { m_lineWalker.setSpline(m_bezierSplineComponent); m_lineWalker.setStartPoint(m_closedLoopStartPoint); m_lineWalker.reset(); m_lineWalker.play(); } break; } } }
internal abstract void WarmOverride(DrawState state);
/// <summary> /// Draw the sprite and its current frame to the screen. /// </summary> /// <param name="spriteBatch">The sprite batch to use.</param> /// <param name="state">The type of drawing to perform.</param> /// <param name="effect">The shader effect to use. NOTE: Currently assumes it is a depth buffer.</param> public void Draw(SpriteBatch spriteBatch, DrawState state, Effect effect) { //If the sprite is invisible, stop here. if (_Visibility == Visibility.Invisible) { return; } //The texture to render. Texture2D texture = null; //Decide which type of texture map to use. switch (state) { case DrawState.Color: { texture = _ColorTexture; break; } case DrawState.Normal: { texture = _NormalTexture; break; } case DrawState.Depth: { texture = _DepthTexture; break; } } //If there is no texture loaded, stop here. if (texture == null) { return; } //Whether to mirror the sprite. SpriteEffects mirror = (_Orientation == Orientation.Right) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; //Prepare the depth-buffer. if (effect != null) { effect.Parameters["DepthMap"].SetValue(_DepthTexture); } //Draw the sprite. spriteBatch.Draw(texture, _Position + _PositionOffset, null, Color.White * _Transparence, Calculator.AddAngles(_Rotation, _RotationOffset), _Frames[_FrameIndex].Origin, _Scale, mirror, 0); }
//load the font used by the status text protected override void LoadContent(DrawState state, ContentManager manager) { statusText.Font = manager.Load <SpriteFont>("Arial"); }