public void Draw(Surface surface, int color, int step, Point location) { foreach (Letter letter in letters) { letter.Draw(surface, color, location); location.X += step; } }
/// <summary> /// Handle a request. /// </summary> /// <param name="pDisplay">The display which called this function.</param> /// <param name="pSurface">The surface which this display is hosted on.</param> /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param> /// <returns>True if the request was processed sucessfully. False if there was an error.</returns> public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments) { // Check we have a sound file. var sSound = dArguments.GetValueOrDefault("file", ""); if (sSound == null || sSound == "") { Log.Write("Cannot play sound. Are you missing a 'file' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning); return false; } // Attempt to play it. try { SoundPlayer pSound = new SoundPlayer(sSound); pSound.Play(); return true; } // Log warnings. catch (Exception e) { Log.Write("Cannot play sound. " + e.Message, pDisplay.ToString(), Log.Type.DisplayWarning); return false; } }
//begin functions public static void Main(string[] args) { //init the stringbuilder mID2 = new StringBuilder(); //args are the image(s) to load mBackgroundPath = args[0]; mForegroundPath = args[1]; if (args.Length > 2 && args[2] == "true") mStringReplace = true; //first, try to connect to arduino string arduino = GetArduinoSerial(); if (!ConnectToArduino(arduino)) { //Kill the program because we can't control the door like this System.Console.WriteLine("Could not connect to Arduino on port " + arduino); //Environment.Exit(1); } //select the font mFont = new SdlDotNet.Graphics.Font(@"font.ttf", 48); //set up the screen dimensions mVideoScreen = Video.SetVideoMode(1000/*width*/, 600/*height*/, false /*resize*/, false /*opengl*/, false /*fullscreen*/); //load the images or quit if they can't be loaded if (!LoadImages(mBackgroundPath, mForegroundPath)) Environment.Exit(1); //try to load the images, if cant, die Events.Fps = 30; //30 fps seems good for this application Events.Quit += new EventHandler<QuitEventArgs>(Events_Quit); //Events.Tick += new EventHandler<TickEventArgs>(Events_Tick); //Events.KeyboardDown += new EventHandler<KeyboardEventArgs>(Events_KeyboardDown); Events.KeyboardUp += new EventHandler<KeyboardEventArgs>(Events_KeyboardUp); PrintWelcomeMessage(); //Prints out the welcome message, should be able to grab updates from a file on disk Events.Run(); }
public override void DrawFast(Surface target,int x, int y,int width,int height) { if(!dying) images.DrawFast(target,x,y,width,height,(Direction)direction); else if(!moving) images.Death[dieFrame].DrawFast(target,x,y,width,height); }
public MinimapRender() { mRenderTarget = new Texture(Game.GameManager.GraphicsThread.GraphicsManager.Device, 2048, 2048, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); mRenderSurface = mRenderTarget.GetSurfaceLevel(0); }
public SurfaceSprite(Surface surface, Point2 location) { Contract.Requires(surface != null); _surface = surface; _location = location; }
public D3D9DepthBuffer( PoolId poolId, D3DRenderSystem renderSystem, Device creator, Surface depthBufferSurf, Format fmt, int width, int height, MultisampleType fsaa, int multiSampleQuality, bool isManual) : base(poolId, 0, width, height, (int)fsaa, "", isManual) { depthBuffer = depthBufferSurf; this.creator = creator; this.multiSampleQuality = multiSampleQuality; d3dFormat = fmt; this.renderSystem = renderSystem; switch (fmt) { case Format.D16Lockable: case Format.D15S1: case Format.D16: bitDepth = 16; break; case Format.D32: case Format.D24S8: case Format.D24X8: case Format.D24X4S4: case Format.D32Lockable: case Format.D24SingleS8: bitDepth = 32; break; } }
protected override Surface CreateSurface() { if (calc_width) { Surface textSurf = GuiUtil.ComposeText (Text, Font, Palette, -1, -1, Sensitive ? 4 : 24); Width = (ushort)textSurf.Width; Height = (ushort)textSurf.Height; return textSurf; } else { /* this is wrong */ Surface surf = new Surface (Width, Height); Surface textSurf = GuiUtil.ComposeText (Text, Font, Palette, Width, Height, Sensitive ? 4 : 24); int x = 0; if (Type == ElementType.LabelRightAlign) x += Width - textSurf.Width; else if (Type == ElementType.LabelCenterAlign) x += (Width - textSurf.Width) / 2; surf.Blit (textSurf, new Point (x, 0)); surf.TransparentColor = Color.Black /* XXX */; return surf; } }
public MafiaVideo(Form form, bool fullscreen) { this.form = form; this.fullscreen = fullscreen; if (fullscreen) { form.FormBorderStyle = FormBorderStyle.None; } else { form.FormBorderStyle = FormBorderStyle.Sizable; } try { device = new Device(0, DeviceType.Hardware, form, CreateFlags.HardwareVertexProcessing, GetDefaultPresentParameters(fullscreen)); } catch (InvalidCallException) { try { device = new Device(0, DeviceType.Hardware, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen)); } catch (InvalidCallException) { try { device = new Device(0, DeviceType.Software, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen)); } catch (InvalidCallException) { throw new Exception("Direct3Dデバイスの生成に失敗しました。"); } } } deviceLost = new EventHandler(OnDeviceLost); deviceReset = new EventHandler(OnDeviceReset); deviceResizing = new CancelEventHandler(OnDeviceResizing); device.DeviceLost += deviceLost; device.DeviceReset += deviceReset; device.DeviceResizing += deviceResizing; device.Clear(ClearFlags.Target, Color.FromArgb(212, 208, 200), 0.0f, 0); sprite = new Sprite(device); backBuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono); offScreenImage = new Texture(device, Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT, 1, Usage.RenderTarget, Manager.Adapters[0].CurrentDisplayMode.Format, Pool.Default); offScreenSurface = offScreenImage.GetSurfaceLevel(0); texture = MafiaLoader.DefaultLoader.GetTexture(device, "mafia.bmp"); if (fullscreen) { Cursor.Hide(); } // form.ClientSize = new Size(Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT); form.ClientSize = new Size(Mafia.SCREEN_WIDTH * 2, Mafia.SCREEN_HEIGHT * 2); }
/// <summary> /// Constructor /// </summary> /// <param name="positionsX">array of x positions of points</param> /// <param name="positionsY">array of y positions of points</param> /// <param name="surface">Textured surface</param> /// <param name="textureOffsetX">Texture is offset on the X axis</param> /// <param name="textureOffsetY">Texture is offset on the Y axis</param> public TexturedPolygon(Surface surface, short[] positionsX, short[] positionsY, int textureOffsetX, int textureOffsetY) { if (positionsX == null) { throw new ArgumentNullException("positionsX"); } if (positionsY == null) { throw new ArgumentNullException("positionsY"); } this.x = positionsX; this.y = positionsY; this.n = 0; this.list = new ArrayList(); this.xTotal = 0; this.yTotal = 0; this.texturedSurface = surface; this.textureOffsetX = textureOffsetX; this.textureOffsetY = textureOffsetY; if (x.Length != y.Length) { throw SdlException.Generate(); } else { this.n = x.Length; } }
/// <summary> /// Handle a request. /// </summary> /// <param name="pDisplay">The display which called this function.</param> /// <param name="pSurface">The surface which this display is hosted on.</param> /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param> /// <returns>True if the request was processed sucessfully. False if there was an error.</returns> public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments) { // Find the new surface. var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", "")); if (pTargetSurface == null) { Log.Write("Cannot swap display to target surface. Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning); return false; } // Check the surface this view is on is not our target. if (pTargetSurface == pDisplay.ActiveSurface) { Log.Write("Cannot swap display to target surface because it is already there.", pDisplay.ToString(), Log.Type.DisplayWarning); return false; } // If the target surface has a display, get a reference and remove it. Display pOtherView = pTargetSurface.ActiveDisplay; if (pOtherView != null) Authority.RemoveDisplay(pOtherView); // Remove this display from this surface and put it on the target surface. Authority.RemoveDisplay(pDisplay); Authority.ShowDisplay(pDisplay, pTargetSurface); // Now put the other display on the original surface. if (pOtherView != null) Authority.ShowDisplay(pOtherView, pSurface); // Boom. return true; }
public void DrawFast(Surface target,int x, int y,int width,int height,int frame) { north[frame].DrawFast(target,x,y-PckImage.Width/2,width,height); south[frame].DrawFast(target,x,y,width,height); east[frame].DrawFast(target,x+PckImage.Width/2,y-PckImage.Width/4,width,height); west[frame].DrawFast(target,x-PckImage.Width/2,y-PckImage.Width/4,width,height); }
public Direct2DRenderTarget(DeviceContext10_1 deviceContext10, Surface surface, Format format = Format.B8G8R8A8_UNorm) { m_deviceContext10 = deviceContext10; m_surface = surface; m_format = format; InitializeResources(surface); }
static unsafe void SaveSurface(Surface surface, string fileName) { if (surface.Width > 0 && surface.Height > 0) { var bitmap = new Bitmap(surface.Width, surface.Height, PixelFormat.Format24bppRgb); var bitmapData = bitmap.LockBits(new Rectangle(0, 0, surface.Width, surface.Height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb); for (int y = 0; y < surface.Height; y++) { var dest = (byte*)bitmapData.Scan0 + y * bitmapData.Stride; var src = (byte*)surface.Bits + y * surface.Pitch; for (int x = 0; x < surface.Width; x++) { var b = *src++; *dest++ = b; *dest++ = b; *dest++ = b; } } bitmap.UnlockBits(bitmapData); bitmap.Save(fileName); bitmap.Dispose(); Marshal.FreeHGlobal(surface.Bits); } }
private static unsafe bool RenderGlyph(FontFace typeface, char c, float pixelSize, out Surface surface) { bool result = false; Glyph glyph = typeface.GetGlyph(c, pixelSize); if (glyph != null && glyph.RenderWidth > 0 && glyph.RenderHeight > 0) { surface = new Surface { Bits = Marshal.AllocHGlobal(glyph.RenderWidth * glyph.RenderHeight), Width = glyph.RenderWidth, Height = glyph.RenderHeight, Pitch = glyph.RenderWidth }; var stuff = (byte*)surface.Bits; for (int i = 0; i < surface.Width * surface.Height; i++) *stuff++ = 0; glyph.RenderTo(surface); result = true; } else { surface = new Surface(); } return result; }
public PixelDataProvider(int width, int height, int numChannels, Device device, Usage usage) : base() { Format pf = Format.X8R8G8B8; switch (numChannels) { case 1: pf = Format.A8; break; case 3: pf = Format.R8G8B8; break; case 4: pf = Format.X8R8G8B8; break; case 8: pf = Format.A16B16G16R16; break; } //TODO: how to find out which Formats are supported?? //device.DeviceCaps.TextureCaps if (pf == Format.R8G8B8) pf = Format.X8R8G8B8; //RenderToSurface sf = new RenderToSurface(device, width, height, pf, false, null); //this._tx = new Texture(device, width, height, 1, Usage.RenderTarget, pf, Pool.Default); // Pool.Managed doesn't work with Usage.RenderTarget Pool pool = Pool.Managed; if (usage == Usage.RenderTarget) pool = Pool.Default; this._tx = new Texture(device, width, height, 1, usage, pf, pool); //this._sd = this._tx.GetLevelDescription(0); this._surf = this._tx.GetSurfaceLevel(0); //AOAO this._sd = this._surf.Description; }
public Doom3Map(Doom3MapData map) { Surfaces=new List<Surface>(); int verts = 0; int indices = 0; foreach(Doom3MapData.Model m in map.Models) { foreach(Doom3MapData.Surface s in m.Surfaces) { VertexBuffer vb = Root.Instance.UserInterface.Renderer.CreateStaticVertexBuffer( s.Vertices, s.Vertices.Length*4*(3+2+3) ); vb.Format = VertexFormat.VF_P3T2N3; IndexBuffer ib = new IndexBuffer(); ib.buffer = new int[s.Indices.Length]; for (int i = 0; i < ib.buffer.Length; ++i) ib.buffer[i] = s.Indices[i]; Surface s2 = new Surface(); s2.Ibuffer = ib; s2.Vbuffer = vb; verts += s.Vertices.Length; indices += s.Indices.Length; Texture t=null; try { t = Root.Instance.ResourceManager.LoadTexture(s.Name + ".tga"); } catch (Exception) { try { t = Root.Instance.ResourceManager.LoadTexture(s.Name + "_add.tga"); } catch (Exception) { try { t = Root.Instance.ResourceManager.LoadTexture(s.Name + "_d.tga"); } catch (Exception ) { System.Console.WriteLine("warning: cant load "+s.Name); } } } s2.Material=Material.CreateSimpleMaterial(t); //s2.Material.Additive = true; Surfaces.Add(s2); } } System.Console.WriteLine("surfaces: "+Surfaces.Count.ToString()); System.Console.WriteLine("verts: " + verts.ToString()); System.Console.WriteLine("indices: " + indices.ToString()); GC.Collect(); BBox = new BoundingBox(map.BBoxMin, map.BBoxMax); }
protected override Surface CreateSurface() { if (ParentScreen.Background == null && ParentScreen.UseTiles) { Surface surf = new Surface (Width, Height); surf.Fill (new Rectangle (new Point (0,0), new Size (Width, Height)), Color.FromArgb (0,0,0,0)); surf.TransparentColor = Color.Black; /* XXX */ Pcx pal = new Pcx (); pal.ReadFromStream ((Stream)Mpq.GetResource ("unit\\cmdbtns\\ticon.pcx"), -1, -1); /* tile the top border */ TileRow (surf, tileGrp, pal.Palette, TILE_TL, TILE_T, TILE_TR, 0); /* tile everything down to the bottom border */ for (int y = tileGrp.Height - 2; y < surf.Height - tileGrp.Height; y += tileGrp.Height - 2) TileRow (surf, tileGrp, pal.Palette, TILE_L, TILE_C, TILE_R, y); /* tile the bottom row */ TileRow (surf, tileGrp, pal.Palette, TILE_BL, TILE_B, TILE_BR, surf.Height - tileGrp.Height); return surf; } else return null; }
public BitmapHistoryMemento(string name, ImageResource image, IHistoryWorkspace historyWorkspace, int layerIndex, PdnRegion changedRegion, Surface copyFromThisSurface) : base(name, image) { this.historyWorkspace = historyWorkspace; this.layerIndex = layerIndex; PdnRegion region = changedRegion.Clone(); this.tempFileName = FileSystem.GetTempFileName(); FileStream outputStream = null; try { outputStream = FileSystem.OpenStreamingFile(this.tempFileName, FileAccess.Write); SaveSurfaceRegion(outputStream, copyFromThisSurface, region); } finally { if (outputStream != null) { outputStream.Dispose(); outputStream = null; } } this.tempFileHandle = new DeleteFileOnFree(this.tempFileName); BitmapHistoryMementoData data = new BitmapHistoryMementoData(null, region); this.Data = data; }
private void Setup() { try { EdgeMap = new Texture(SlimMMDXCore.Instance.Device, width, height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); } catch (Direct3D9Exception) { //あれ?ABGRで無いとダメなん? EdgeMap = new Texture(SlimMMDXCore.Instance.Device, width, height, 1, Usage.RenderTarget, Format.A8B8G8R8, Pool.Default); } renderSurface = EdgeMap.GetSurfaceLevel(0); depthBuffer = Surface.CreateDepthStencil(SlimMMDXCore.Instance.Device, width, height, Format.D16, MultisampleType.None, 0, true); //エッジ用エフェクト読み込み if (effect != null) { effect.OnResetDevice(); } else { effect = Effect.FromMemory(SlimMMDXCore.Instance.Device, MMDXResource.MMDEdgeEffect, #if DEBUG ShaderFlags.OptimizationLevel0 | ShaderFlags.Debug #else ShaderFlags.OptimizationLevel3 #endif ); } effect.SetValue("EdgeWidth", EdgeWidth); effect.Technique = "MMDEdgeEffect"; effect.SetValue("ScreenResolution", new Vector2(width, height)); CreateScreenVertex(); }
/// <summary> /// Handle a request. /// </summary> /// <param name="pDisplay">The display which called this function.</param> /// <param name="pSurface">The surface which this display is hosted on.</param> /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param> /// <returns>True if the request was processed sucessfully. False if there was an error.</returns> public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments) { // Check we have a function to return the results too. if (!dArguments.HasProperty("callback")) throw new Exception("Missing 'callback' argument."); // Return a list of surface names. JSValue[] lSurfaces = (from pSurf in Authority.Surfaces select new JSValue(pSurf.Identifier)).ToArray(); // If that function is a string. var jsValue = dArguments["callback"]; if (jsValue.IsString) { pDisplay.AsyncCallGlobalFunction(jsValue.ToString(), lSurfaces); return true; } /* // If it is a function. else if (jsValue.IsObject) { ((JSObject)jsValue).Invoke("call", lSurfaces); return true; } */ // Throw the error. throw new Exception("Unknown type specified in 'callback' argument. Expected string."); }
public static void AttemptRecovery() { try { Sprite.End(); } catch { } try { Device.EndScene(); } catch { } try { MainSurface = Device.GetBackBuffer(0, 0, BackBufferType.Mono); CurrentSurface = MainSurface; Device.SetRenderTarget(0, MainSurface); } catch { } }
public override void DrawToolOverlay(Surface s, Graphics g, Model m) { if (b != null) { var r = b.Bounds.SquaresToPixels(); g.DrawRectangle(brushPen, r); } }
public void Draw(Surface surface) { if (!visible) return; surface.DrawLine(end1.X + offset.X, end1.Y + offset.Y, end2.X + offset.X, end2.Y + offset.Y); }
public override bool OnMouseDown( Surface s, Model m, Point square, Point offset, MouseButtons mb ) { var a = Activator.CreateInstance(NewActorType, m) as Actor; a.Position = q.SquareToCenter(); m.AddActor(a); m.SyncActorList(); return true; }
public PixelDataProvider(Texture tx) : base() { this._tx = tx; //this._sd = this._tx.GetLevelDescription(0); this._surf = this._tx.GetSurfaceLevel(0); //AOAO this._sd = this._surf.Description; }
public D3dSurfaceBackground(Device i_dev,int i_width,int i_height) { this._height = i_height; this._width = i_width; this._surface = i_dev.CreateImageSurface(this._width, this._height, Format.R5G6B5); this._src_rect = new Rectangle(0, 0, this._width, this._height); return; }
public D3DTexture2D(Texture pTexture, ImageInformation pImageInfo, string szName) { m_pTexture = pTexture; m_pImageInfo = pImageInfo; m_szName = szName; m_pBaseSurface = pTexture.GetSurfaceLevel(0); m_nFrames = 1; }
private static bool IsSurfaceInPlane(Surface surface, Plane plane, double tolerance) { if (!surface.IsPlanar(tolerance)) return false; var bbox = surface.GetBoundingBox(true); return bbox.GetCorners().All(c => System.Math.Abs(plane.DistanceTo(c)) <= tolerance); }
public override bool OnMouseMove(Surface s, Model m, Point square, Point offset, MouseButtons mb) { if (mb == MouseButtons.Left) { end = square; return true; } return false; }
private async void Initialize() { // Create the scene with an imagery basemap. MySceneView.Scene = new Scene(Basemap.CreateImagery()); // Add the elevation surface. ArcGISTiledElevationSource tiledElevationSource = new ArcGISTiledElevationSource(_elevationUri); Surface baseSurface = new Surface { ElevationSources = { tiledElevationSource } }; MySceneView.Scene.BaseSurface = baseSurface; // Add buildings. ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_buildingsUri); MySceneView.Scene.OperationalLayers.Add(sceneLayer); await sceneLayer.LoadAsync(); // Configure the graphics overlay for the tank and add the overlay to the SceneView. _tankOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; MySceneView.GraphicsOverlays.Add(_tankOverlay); // Configure the heading expression for the tank; this will allow the // viewshed to update automatically based on the tank's position. SimpleRenderer renderer3D = new SimpleRenderer(); renderer3D.SceneProperties.HeadingExpression = "[HEADING]"; _tankOverlay.Renderer = renderer3D; // Create the tank graphic - get the model path. string modelPath = GetModelPath(); // - Create the symbol and make it 10x larger (to be the right size relative to the scene). ModelSceneSymbol tankSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 10); // - Adjust the position. tankSymbol.Heading = 90; // - The tank will be positioned relative to the scene surface by its bottom. // This ensures that the tank is on the ground rather than partially under it. tankSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // - Create the graphic. _tank = new Graphic(new MapPoint(4.847969, 45.746452, SpatialReferences.Wgs84), tankSymbol); // - Update the heading. _tank.Attributes["HEADING"] = 0.0; // - Add the graphic to the overlay. _tankOverlay.Graphics.Add(_tank); // Create a viewshed for the tank. GeoElementViewshed geoViewshed = new GeoElementViewshed( geoElement: _tank, horizontalAngle: 90.0, verticalAngle: 40.0, minDistance: 0.1, maxDistance: 250.0, headingOffset: 0.0, pitchOffset: 0.0) { // Offset viewshed observer location to top of tank. OffsetZ = 3.0 }; // Create the analysis overlay and add to the scene. AnalysisOverlay overlay = new AnalysisOverlay(); overlay.Analyses.Add(geoViewshed); MySceneView.AnalysisOverlays.Add(overlay); // Create a camera controller to orbit the tank. OrbitGeoElementCameraController cameraController = new OrbitGeoElementCameraController(_tank, 200.0) { CameraPitchOffset = 45.0 }; // - Apply the camera controller to the SceneView. MySceneView.CameraController = cameraController; // Create a timer; this will enable animating the tank. Timer animationTimer = new Timer(60) { Enabled = true, AutoReset = true }; // - Move the tank every time the timer expires. animationTimer.Elapsed += (o, e) => { AnimateTank(); }; // - Start the timer. animationTimer.Start(); // Allow the user to click to define a new destination. MySceneView.GeoViewTapped += (sender, args) => { _tankEndPoint = args.Location; }; }
public unsafe override void render(float elapsedTime) { Device device = GuiController.Instance.D3dDevice; Control panel3d = GuiController.Instance.Panel3d; time += elapsedTime; TgcD3dInput d3dInput = GuiController.Instance.D3dInput; //Obtener variacion XY del mouse if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { float mouseX = d3dInput.XposRelative; float mouseY = d3dInput.YposRelative; float an = mouseX * 0.1f; float x = (float)(LookFrom.X * Math.Cos(an) + LookFrom.Z * Math.Sin(an)); float z = (float)(LookFrom.Z * Math.Cos(an) - LookFrom.X * Math.Sin(an)); LookFrom.X = x; LookFrom.Z = z; LookFrom.Y += mouseY * 150f; } //Determinar distancia de la camara o zoom segun el Mouse Wheel if (d3dInput.WheelPos != 0) { Vector3 vdir = LookFrom - LookAt; vdir.Normalize(); LookFrom = LookFrom - vdir * (d3dInput.WheelPos * 500); } device.Transform.View = Matrix.LookAtLH(LookFrom, LookAt, new Vector3(0, 1, 0)); Matrix ant_Proj = device.Transform.Projection; Matrix ant_World = device.Transform.World; Matrix ant_View = device.Transform.View; device.Transform.Projection = Matrix.Identity; device.Transform.World = Matrix.Identity; device.Transform.View = Matrix.Identity; device.SetRenderState(RenderStates.AlphaBlendEnable, false); // rt1= velocidad Surface pOldRT = device.GetRenderTarget(0); Surface pSurf = g_pVelocidadOut.GetSurfaceLevel(0); device.SetRenderTarget(0, pSurf); Surface pOldDS = device.DepthStencilSurface; device.DepthStencilSurface = g_pDepthStencil; // rt2 = posicion Surface pSurf2 = g_pPosOut.GetSurfaceLevel(0); device.SetRenderTarget(1, pSurf2); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); effect.SetValue("elapsedTime", elapsedTime); effect.Technique = "ComputeVel"; effect.SetValue("g_pVelocidad", g_pVelocidad); effect.SetValue("g_pPos", g_pPos); device.VertexFormat = CustomVertex.PositionTextured.Format; device.SetStreamSource(0, g_pVBV3D, 0); effect.Begin(FX.None); effect.BeginPass(1); device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); effect.EndPass(); effect.End(); device.EndScene(); // leo los datos de la textura de velocidades // ---------------------------------------------------------------------- Surface pDestSurf = g_pTempVel.GetSurfaceLevel(0); device.GetRenderTargetData(pSurf, pDestSurf); Surface pDestSurf2 = g_pTempPos.GetSurfaceLevel(0); device.GetRenderTargetData(pSurf2, pDestSurf2); float *pDataVel = (float *)pDestSurf.LockRectangle(LockFlags.None).InternalData.ToPointer(); float *pDataPos = (float *)pDestSurf2.LockRectangle(LockFlags.None).InternalData.ToPointer(); for (int i = 0; i < MAX_DS; i++) { for (int j = 0; j < MAX_DS; j++) { vel_x[i, j] = *pDataVel++; vel_z[i, j] = *pDataVel++; pDataVel++; // no usado pDataVel++; // no usado pos_x[i, j] = *pDataPos++; pos_z[i, j] = *pDataPos++; pos_y[i, j] = *pDataPos++; pDataPos++; // no usado } } pDestSurf.UnlockRectangle(); pDestSurf2.UnlockRectangle(); pSurf.Dispose(); pSurf2.Dispose(); device.SetRenderTarget(0, pOldRT); device.SetRenderTarget(1, null); device.DepthStencilSurface = pOldDS; // swap de texturas Texture aux = g_pVelocidad; g_pVelocidad = g_pVelocidadOut; g_pVelocidadOut = aux; aux = g_pPos; g_pPos = g_pPosOut; g_pPosOut = aux; // dibujo pp dicho ---------------------------------------------- device.Transform.Projection = ant_Proj; device.Transform.World = ant_World; device.Transform.View = ant_View; device.BeginScene(); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); //Renderizar terreno if ((bool)GuiController.Instance.Modifiers["dibujar_terreno"]) { terrain.render(); } // dibujo las particulas como point sprites mesh.Effect = effect; mesh.Technique = "DefaultTechnique"; effect.SetValue("texDiffuseMap", g_pBaseTexture); CustomVertex.PositionColored[,] vertices = new CustomVertex.PositionColored[MAX_DS, MAX_DS]; for (int i = 0; i < MAX_DS; i++) { for (int j = 0; j < MAX_DS; j++) { float x0 = pos_x[i, j]; float z0 = pos_z[i, j]; float H = pos_y[i, j]; vertices[i, j] = new CustomVertex.PositionColored(x0, H + esfera_radio, z0, Color.Blue.ToArgb()); } } g_pVB.SetData(vertices, 0, LockFlags.None); device.VertexFormat = CustomVertex.PositionColored.Format; device.SetStreamSource(0, g_pVB, 0); device.SetTexture(0, null); device.SetRenderState(RenderStates.PointSize, 32); device.SetRenderState(RenderStates.PointScaleEnable, true); device.SetRenderState(RenderStates.PointSpriteEnable, true); device.DrawPrimitives(PrimitiveType.PointList, 0, MAX_DS * MAX_DS); device.EndScene(); }
/// <summary> /// Common function to send H264 data to the client /// </summary> /// <param name="h264DataFile">XML file of H264 data</param> /// <param name="isAVC444">Whether need RDP client support AVC444/AVC444v2</param> private void SendH264CodecStream(string h264DataFile, bool isAVC444) { //Load H264 data RdpegfxH264TestDatas h264TestData = GetH264TestData(h264DataFile); // Init for capability exchange this.TestSite.Log.Add(LogEntryKind.Comment, "Do capability exchange."); RDPEGFX_CapabilityExchange(); if (isAVC444) { this.TestSite.Assume.IsTrue(this.isH264AVC444Supported, "This test case requires RDP client to support AVC444/AVC444v2."); } else { this.TestSite.Assume.IsTrue(this.isH264AVC420Supported, "To test H264 codec, client must indicate support for H264 codec in RDPGFX_CAPS_ADVERTISE_PDU"); } this.TestSite.Log.Add(LogEntryKind.Comment, "Create a surface and fill it with green color."); // Create & output a surface RDPGFX_POINT16 surfPos = new RDPGFX_POINT16((ushort)h264TestData.SurfaceInfo.outputOriginX, (ushort)h264TestData.SurfaceInfo.outputOriginY); RDPGFX_RECT16 surfRect = RdpegfxTestUtility.ConvertToRect(surfPos, h264TestData.SurfaceInfo.width, h264TestData.SurfaceInfo.height); RDPGFX_RECT16 compareRect = RdpegfxTestUtility.ConvertToRect(surfPos, h264TestData.SurfaceInfo.width, h264TestData.SurfaceInfo.height); if (isWindowsImplementation && compareRect.top < 32 && compareRect.bottom > 32) { // Ignore the field of RDP client connection bar compareRect.top = 32; } Surface surf = this.rdpegfxAdapter.CreateAndOutputSurface(surfRect, (PixelFormat)h264TestData.SurfaceInfo.pixelFormat); this.TestSite.Assert.IsNotNull(surf, "Surface {0} is created", surf.Id); // Send solid fill request to client to fill surface with green color RDPGFX_RECT16[] fillRects = { new RDPGFX_RECT16(h264TestData.TestDataList[0].DestRect.left, h264TestData.TestDataList[0].DestRect.top, h264TestData.TestDataList[0].DestRect.right, h264TestData.TestDataList[0].DestRect.bottom) }; // Relative to surface uint fid = this.rdpegfxAdapter.SolidFillSurface(surf, RdpegfxTestUtility.fillColorGreen, fillRects); this.TestSite.Log.Add(LogEntryKind.Debug, "Surface is filled with solid color in frame: {0}", fid); this.rdpegfxAdapter.ExpectFrameAck(fid); // Send H264 codec data foreach (TestData data in h264TestData.TestDataList) { ushort codecId = data.codecId; PixelFormat pixFormat = (PixelFormat)data.pixelFormat; RDPGFX_RECT16 bmRect = new RDPGFX_RECT16(); bmRect.left = data.DestRect.left; bmRect.top = data.DestRect.top; bmRect.right = data.DestRect.right; bmRect.bottom = data.DestRect.bottom; if (codecId == (ushort)CodecType.RDPGFX_CODECID_AVC420 && data.AVC420BitmapStream != null) { this.TestSite.Log.Add(LogEntryKind.Comment, "Sending H264 AVC420 Encoded Bitmap Data Messages to client."); fid = this.rdpegfxAdapter.SendImageWithH264AVC420Codec(surf.Id, pixFormat, bmRect, data.AVC420BitmapStream.To_RFX_AVC420_BITMAP_STREAM(), data.GetBaseImage()); // Test case pass if frame acknowledge is received. this.rdpegfxAdapter.ExpectFrameAck(fid); } else if (codecId == (ushort)CodecType.RDPGFX_CODECID_AVC444 && data.AVC444BitmapStream != null) { this.TestSite.Log.Add(LogEntryKind.Comment, "Sending H264 AVC444 Encoded Bitmap Data Messages to client."); fid = this.rdpegfxAdapter.SendImageWithH264AVC444Codec(surf.Id, pixFormat, bmRect, CodecType.RDPGFX_CODECID_AVC444, data.AVC444BitmapStream.To_RFX_AVC444_BITMAP_STREAM(), data.GetBaseImage()); // Test case pass if frame acknowledge is received. this.rdpegfxAdapter.ExpectFrameAck(fid); } else if (codecId == (ushort)CodecType.RDPGFX_CODECID_AVC444v2 && data.AVC444v2BitmapStream != null) { this.TestSite.Log.Add(LogEntryKind.Comment, "Sending H264 AVC444v2 Encoded Bitmap Data Messages to client."); fid = this.rdpegfxAdapter.SendImageWithH264AVC444Codec(surf.Id, pixFormat, bmRect, CodecType.RDPGFX_CODECID_AVC444v2, data.AVC444v2BitmapStream.To_RFX_AVC444V2_BITMAP_STREAM(), data.GetBaseImage()); // Test case pass if frame acknowledge is received. this.rdpegfxAdapter.ExpectFrameAck(fid); } else { Site.Assert.Fail("Test data doesn't contain proper H264 encoded data corresponding to codec ID."); } this.TestSite.Log.Add(LogEntryKind.Comment, "Verify output on SUT Display if the verifySUTDisplay entry in PTF config is true."); this.VerifySUTDisplay(true, compareRect, 2); } // Delete the surface this.rdpegfxAdapter.DeleteSurface(surf.Id); this.TestSite.Log.Add(LogEntryKind.Debug, "Surface {0} is deleted", surf.Id); }
public SurfaceComponent(Entity id, Surface surfaceType) : base(id) { SurfaceType = surfaceType; }
public override void Init() { var d3dDevice = D3DDevice.Instance.Device; MyShaderDir = ShadersDir + "WorkshopShaders\\"; //Cargamos un escenario var loader = new TgcSceneLoader(); //TgcScene scene = loader.loadSceneFromFile(this.MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml"); var scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Selva\\Selva-TgcScene.xml"); meshes = scene.Meshes; var scene2 = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vegetacion\\Pasto\\Pasto-TgcScene.xml"); pasto = scene2.Meshes[0]; var scene3 = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vegetacion\\ArbolSelvatico\\ArbolSelvatico-TgcScene.xml"); arbol = scene3.Meshes[0]; var scene4 = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vegetacion\\Arbusto2\\Arbusto2-TgcScene.xml"); arbusto = scene4.Meshes[0]; //Cargar personaje con animaciones var skeletalLoader = new TgcSkeletalLoader(); var rnd = new Random(); for (var t = 0; t < 25; ++t) { enemigos.Add(skeletalLoader.loadMeshAndAnimationsFromFile( MediaDir + "SkeletalAnimations\\BasicHuman\\" + "CombineSoldier-TgcSkeletalMesh.xml", MediaDir + "SkeletalAnimations\\BasicHuman\\", new[] { MediaDir + "SkeletalAnimations\\BasicHuman\\Animations\\" + "StandBy-TgcSkeletalAnim.xml", MediaDir + "SkeletalAnimations\\BasicHuman\\Animations\\" + "Run-TgcSkeletalAnim.xml" })); //Configurar animacion inicial enemigos[t].playAnimation("StandBy", true); enemigos[t].Position = new Vector3(-rnd.Next(0, 1500) - 250, 0, -rnd.Next(0, 1500) - 250); enemigos[t].Scale = new Vector3(2f, 2f, 2f); bot_status[t] = 0; } //Cargar Shader personalizado string compilationErrors; effect = Effect.FromFile(D3DDevice.Instance.Device, MyShaderDir + "GaussianBlur.fx", null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors); if (effect == null) { throw new Exception("Error al cargar shader. Errores: " + compilationErrors); } //Configurar Technique dentro del shader effect.Technique = "DefaultTechnique"; //Camara en primera personas Camara = new TgcFpsCamera(new Vector3(-1000, 250, -1000), 1000f, 600f); g_pDepthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, DepthFormat.D24S8, MultiSampleType.None, 0, true); // inicializo el render target g_pRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth , d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); g_pGlowMap = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth , d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); g_pRenderTarget4 = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4 , d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); g_pRenderTarget4Aux = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4 , d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); effect.SetValue("g_RenderTarget", g_pRenderTarget); // Resolucion de pantalla effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth); effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight); CustomVertex.PositionTextured[] vertices = { new CustomVertex.PositionTextured(-1, 1, 1, 0, 0), new CustomVertex.PositionTextured(1, 1, 1, 1, 0), new CustomVertex.PositionTextured(-1, -1, 1, 0, 1), new CustomVertex.PositionTextured(1, -1, 1, 1, 1) }; //vertex buffer de los triangulos g_pVBV3D = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default); g_pVBV3D.SetData(vertices, 0, LockFlags.None); Modifiers.addBoolean("activar_efecto", "Activar efecto", true); timer_firing = new float[100]; pos_bala = new Vector3[100]; dir_bala = new Vector3[100]; for (var i = 0; i < cant_balas; ++i) { timer_firing[i] = i / (float)cant_balas * total_timer_firing; } }
private static NurbsCurve _ZigZagDeformations_TryRemove__by_removing_diapasons(NurbsCurve crv, Surface srf, int[] zigzagIndexes, List <ZigZagDiapason> diapasons) { // // Split curve on segments // Point3d[] allCrvPoints; //Try1 var divby = crv._GetDivBy(srf); var ts = crv._DivideByCount_ThreadSafe(divby, true, out allCrvPoints); if (allCrvPoints == null) { //Try2 ts = crv._DivideByCount_ThreadSafe(100, true, out allCrvPoints); if (allCrvPoints == null) { //Try3 var length = crv._Get3dLength(srf); if (length < 0.001) { allCrvPoints = new[] { crv.PointAtStart, crv.PointAtEnd }; ts = new[] { crv.Domain.T0, crv.Domain.T1 }; } else { return(null); } } } // // Fix curve by extending diapasons until we get fixed curve // NurbsCurve res = null; var diapasonExtensionMax = crv.Domain.Length * 0.05; // 5% double diapasonExtension = 0; while (diapasonExtension <= diapasonExtensionMax) { //Layers.Debug.AddPoint(crvNurb._PX3d(diapasons[0].StartIgnoreAtT - diapasonExtension, srf), Color.Red); //Layers.Debug.AddPoint(crvNurb._PX3d(diapasons[0].EndIgnoreAtT + diapasonExtension, srf), Color.Red); var crvFixed = _ZigZagDeformations_Remove(crv, srf, ts, diapasons, diapasonExtension); if (crvFixed == null) { break; //break tries - return what we found till now :( } // if no more zigzags - set result if (!crvFixed._ZigZagDeformationExists(srf)) { res = crvFixed; break; } // if we here - zigzags still exists after fix - so lets increaese cut length and lets try once again diapasonExtension += crv.Domain.Length * 0.01; // 1% } return(res); }
public void Main(string[] args) { using (AgateSetup setup = new AgateSetup(args)) { setup.AskUser = true; setup.Initialize(true, false, false); if (setup.WasCanceled) { return; } LightingTestForm frm = new LightingTestForm(); frm.Show(); DisplayWindow wnd = new DisplayWindow(CreateWindowParams.FromControl(frm.agateRenderTarget1)); Surface image = new Surface("jellybean.png"); Surface ball = new Surface("ball.png"); Point ballPt; double time = 0; image.SetScale(2.0, 2.0); ball.DisplayAlignment = OriginAlignment.Center; LightManager lights = new LightManager(); lights.Enabled = true; lights.AddPointLight(new Vector3(0, 0, -1), Color.White); lights.AddPointLight(new Vector3(0, 0, -1), Color.Yellow); Display.VSync = false; //lights[0].Ambient = Color.White; lights[1].AttenuationConstant = 0.01f; lights[1].AttenuationQuadratic = 5e-7f; Mouse.MouseMove += delegate(InputEventArgs e) { lights[1].Position = new Vector3(e.MousePosition.X, e.MousePosition.Y, -1); }; while (frm.Visible == true) { if (frm.chkMoveLight.Checked) { time += Display.DeltaTime / 1000.0; } ballPt = new Point((int)(120 + 110 * Math.Cos(time)), (int)(120 + 110 * Math.Sin(time))); lights[0].Position = new Vector3(ballPt.X, ballPt.Y, -1); lights[0].Ambient = Color.FromArgb(frm.btnAmbient.BackColor.ToArgb()); lights[0].Diffuse = Color.FromArgb(frm.btnDiffuse.BackColor.ToArgb()); image.RotationAngleDegrees = (double)frm.nudAngle.Value; Display.BeginFrame(); Display.Clear(Color.DarkRed); lights.Enabled = frm.enableLightingCheck.Checked; lights.DoLighting(); if (frm.chkSurfaceGradient.Checked) { Gradient g = new Gradient(Color.Red, Color.Blue, Color.Cyan, Color.Green); image.ColorGradient = g; } else { image.Color = Color.White; } image.TesselateFactor = (int)frm.nudTess.Value; image.Draw(50, 50); image.Draw(50 + image.DisplayWidth, 50); image.Draw(50, 50 + image.DisplayHeight); ball.Draw(ballPt); Display.EndFrame(); Core.KeepAlive(); frm.lblFPS.Text = "FPS: " + Display.FramesPerSecond.ToString("0.00"); } } }
public Level1(Surface video, Point positionUser) : base(video) { intTileArray = new int[80, 80] { { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }; CreateWorld(positionUser); }
private async void Initialize() { // Create a scene. Scene myScene = new Scene(Basemap.CreateImageryWithLabels()); // Create a surface for elevation data. Surface surface = new Surface(); surface.ElevationSources.Add(new ArcGISTiledElevationSource(_elevationUri)); // Add the surface to the scene. myScene.BaseSurface = surface; // Create a graphics overlay for the scene. GraphicsOverlay sceneGraphicsOverlay = new GraphicsOverlay() { SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute) }; MySceneView.GraphicsOverlays.Add(sceneGraphicsOverlay); // Location at the crater. MapPoint craterLocation = new MapPoint(-109.929589, 38.437304, 1700, SpatialReferences.Wgs84); // Create the plane symbol and make it 10x larger (to be the right size relative to the scene). ModelSceneSymbol planeSymbol; try { planeSymbol = await ModelSceneSymbol.CreateAsync(_modelUri, 10.0); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); await new MessageDialog("Loading plane model failed. Sample failed to initialize.", "Sample error").ShowAsync(); return; } // Create a graphic using the plane symbol. Graphic planeGraphic = new Graphic(new MapPoint(craterLocation.X, craterLocation.Y, 5000.0, SpatialReferences.Wgs84), planeSymbol); sceneGraphicsOverlay.Graphics.Add(planeGraphic); // Instantiate a new camera controller which orbits a geo element. _orbitPlaneCameraController = new OrbitGeoElementCameraController(planeGraphic, 300.0) { CameraPitchOffset = 30, CameraHeadingOffset = 150 }; // Instantiate a new camera controller which orbits a location. _orbitCraterCameraController = new OrbitLocationCameraController(craterLocation, 6000.0) { CameraPitchOffset = 3, CameraHeadingOffset = 150 }; // Set the starting camera controller. MySceneView.CameraController = _orbitPlaneCameraController; // Enable all of the radio buttons. OrbitPlaneButton.IsEnabled = true; OrbitCraterButton.IsEnabled = true; FreePanButton.IsEnabled = true; // Add the scene to the view. MySceneView.Scene = myScene; }
public static NurbsCurve _ZigZagDeformations_TryRemove(this Curve crv, Surface srf = null) { var DEBUG = false; var crvNurb = crv._ToNurbsCurve(); var zigzagIndexes = crvNurb._ZigZagDeformationsFind(srf); if (zigzagIndexes == null) { return(null); } var diapasons = _ZigZag_GetDiapasons(crvNurb, zigzagIndexes); // // Try to remove zigzag // var ress = new List <NurbsCurve>(); var ressMethod = new List <string>(); var res1 = _ZigZagDeformations_TryRemove__by_removing_diapasons(crvNurb, srf, zigzagIndexes, diapasons); if (res1 != null) { ress.Add(res1); ressMethod.Add("removing_diapasons"); } if (crv.Dimension == 3) { var res2 = _ZigZagDeformations_TryRemove__by_sorting_controlPoints(crvNurb, srf, zigzagIndexes, diapasons); if (res2 != null) { ress.Add(res2); ressMethod.Add("sorting_controlPoints"); } var res3 = _ZigZagDeformations_TryRemove__by_sorting_points3d(crvNurb, srf, zigzagIndexes, diapasons); if (res3 != null) { ress.Add(res3); ressMethod.Add("sorting_points3d"); } } // // Return best result // if (ress.Count == 0) { return(null); } if (ress.Count == 1) { return(ress[0]); } //DEBUG - log original curve //ress.Add(crvNurb); //ressMethod.Add("input_curve"); var smoothnests = new List <double>(); foreach (var fixedCrv in ress) { smoothnests.Add(_ZigZagDeformations_Get3dCurveSmoothnest(fixedCrv, srf)); } if (DEBUG) { log.temp("ZigZagDeformations poins {0}", crvNurb.Points.Count); } var bestIndex = 0; var bestSmoothnest = smoothnests[0]; var bestMethod = ressMethod[0]; for (int i = 0; i < smoothnests.Count; i++) { if (DEBUG) { log.temp(" Method {0} - smoothnests {1} ", ressMethod[i], smoothnests[i]); } if (smoothnests[i] < bestSmoothnest) { bestIndex = i; bestSmoothnest = smoothnests[i]; bestMethod = ressMethod[i]; } } return(ress[bestIndex]); }
public void setup(Surface surface) { this._surface = surface; this._compositorContext.onGrContextCreated(this._surface); }
public void teardown() { this._compositorContext.onGrContextDestroyed(); this._surface = null; this._lastLayerTree = null; }
// lower value - better smoothnes - for lines result will be 0 private static double _ZigZagDeformations_Get3dCurveSmoothnest(NurbsCurve crv, Surface srf) { // 2d curve must provide srf var crvDimension = crv.Dimension; if (crvDimension == 2) { return(0); } //get 100 points on curve Point3d[] points; crv._DivideByCount_ThreadSafe(50, true, out points); if (points == null) { return(0); } // convert point to 3d if curve is 2d if (crvDimension == 2 && srf != null) { for (int i = 0; i < points.Length; i++) { points[i] = srf.PointAt(points[i].X, points[i].Y); } } // get biggest angle between edges double biggestAngle = 0; for (int i2 = 1; i2 < points.Length - 1; i2++) // cycle from up-to-down and from down-to-up { var i1 = i2 - 1; var i3 = i2 + 1; var p1 = points[i1]; var p2 = points[i2]; var p3 = points[i3]; double angleInDegree; if (_Point3d._TryGetAngle(p1, p2, p2, p3, out angleInDegree)) { biggestAngle = Math.Max(biggestAngle, angleInDegree); } } return(biggestAngle); }
/// <summary> /// Compute the VolumeMassProperties for a single Surface. /// </summary> /// <param name="surface">Surface to measure.</param> /// <returns>The VolumeMassProperties for the given Surface or null on failure.</returns> /// <exception cref="System.ArgumentNullException">When surface is null.</exception> /// <since>5.0</since> public static VolumeMassProperties Compute(Surface surface) { return(Compute(surface, true, true, true, true)); }
public static bool _ZigZagDeformationExists(this Curve crv, Surface srf = null) { return(crv._ZigZagDeformationsFind(srf) != null); }
private static NurbsCurve _ZigZagDeformations_TryRemove__by_sorting_controlPoints(NurbsCurve crv, Surface srf, int[] zigzagIndexes, List <ZigZagDiapason> diapasons) { NurbsCurve res = null; var points3d = crv._Locations3d(); // set default all points are valid var indexes = new List <int>(); for (int i = 0; i < points3d.Length; i++) { indexes.Add(i); } // clear bad control points for (int di = 0; di < diapasons.Count; di++) { var d = diapasons[di]; for (int i = d.IndexStart + 1; i < d.IndexEnd; i++) { indexes[i] = -1; } } // // v1 - just remove - at least we will have some result if v2 fails // var res1 = _ZigZagDeformations_GetCurveFromPoints(crv, srf, points3d, false, indexes); if (res1 != null) { res = res1; } // // v2 - sort bad control points - try get better result // for (int di = 0; di < diapasons.Count; di++) { var d = diapasons[di]; var subPoints = new List <Point3d>(); for (int i = d.IndexStart; i <= d.IndexEnd; i++) { subPoints.Add(points3d[i]); } var subIndexesSorted = _Point3d._Sort(subPoints); for (int i = 0; i < d.IndexEnd - d.IndexStart + 1; i++) { var index = d.IndexStart + i; var indexSorted = d.IndexStart + subIndexesSorted[i]; indexes[index] = indexSorted; } } var res2 = _ZigZagDeformations_GetCurveFromPoints(crv, srf, points3d, false, indexes); if (res2 != null) { res = res2; } return(res); }
/// <summary> /// generate a tube with a cubic shape /// </summary> /// <param name="myWidth">width</param> /// <param name="myHeight">height</param> /// <param name="myThickness">thickness</param> /// <param name="myLength">length</param> public CubicTube(double myWidth, double myHeight, double myThickness, double myLength) {// note that u could have achieved the same by creating a wire, then make it slide on a spline to create a pipe, then cut external and internal shapes and finally triangulate it (example in the elbow file) // inferior part // base part ext gp_Pnt aPnt11 = new gp_Pnt(0, 0, 0); gp_Pnt aPnt12 = new gp_Pnt(myWidth, 0, 0); gp_Pnt aPnt13 = new gp_Pnt(myWidth, myHeight, 0); gp_Pnt aPnt14 = new gp_Pnt(0, myHeight, 0); // BASE PART INT gp_Pnt aPnt15 = new gp_Pnt( 0 + myThickness, 0 + myThickness, 0); gp_Pnt aPnt16 = new gp_Pnt(myWidth-myThickness, 0 + myThickness, 0); gp_Pnt aPnt17 = new gp_Pnt(myWidth-myThickness, myHeight - myThickness, 0); gp_Pnt aPnt18 = new gp_Pnt( 0 + myThickness, myHeight - myThickness, 0); // base part ext gp_Pnt aPnt21 = new gp_Pnt(0, 0, myLength); gp_Pnt aPnt22 = new gp_Pnt(myWidth, 0, myLength); gp_Pnt aPnt23 = new gp_Pnt(myWidth, myHeight, myLength); gp_Pnt aPnt24 = new gp_Pnt(0, myHeight, myLength); // BASE PART INT gp_Pnt aPnt25 = new gp_Pnt(0 + myThickness, 0 + myThickness, myLength); gp_Pnt aPnt26 = new gp_Pnt(myWidth - myThickness, 0 + myThickness, myLength); gp_Pnt aPnt27 = new gp_Pnt(myWidth - myThickness, myHeight - myThickness, myLength); gp_Pnt aPnt28 = new gp_Pnt(0 + myThickness, myHeight - myThickness, myLength); List<List<gp_Pnt>> faces = new List<List<gp_Pnt>> { new List<gp_Pnt> { aPnt11, aPnt12, aPnt13, aPnt14 }, new List<gp_Pnt> { aPnt15, aPnt16, aPnt17, aPnt18 }, new List<gp_Pnt> { aPnt21, aPnt22, aPnt23, aPnt24 }, new List<gp_Pnt> { aPnt25, aPnt26, aPnt27, aPnt28 } }; // sadly u must know how to orientate faces, the algorithm can't determine it by itself for now List<TopAbs_Orientation> orientations = new List<TopAbs_Orientation> { TopAbs_Orientation.TopAbs_REVERSED, TopAbs_Orientation.TopAbs_FORWARD }; List<Face> tempFaces = new List<Face>(); // top face List<gp_Pnt> allPoints = faces[0]; allPoints.AddRange(faces[1]); Surface surface = new Surface(allPoints, orientations[1]); tempFaces.AddRange(surface.ComputeFaces()); // bot face allPoints = faces[2]; allPoints.AddRange(faces[3]); surface = new Surface(allPoints, orientations[0]); tempFaces.AddRange(surface.ComputeFaces()); // lateral face exterior allPoints = faces[0]; allPoints.AddRange(faces[2]); surface = new Surface(allPoints, orientations[1]); tempFaces.AddRange(surface.ComputeFaces()); // lateral face interior allPoints = faces[1]; allPoints.AddRange(faces[3]); surface = new Surface(allPoints, orientations[0]); tempFaces.AddRange(surface.ComputeFaces()); // ordonned pts + triangles int count = 0; foreach (Face f in tempFaces) { myFaces.AddRange(f.ToTrianglesGraham(true).subFaces); count++; } }
private static NurbsCurve _ZigZagDeformations_TryRemove__by_sorting_points3d(NurbsCurve crv, Surface srf, int[] zigzagIndexes, List <ZigZagDiapason> diapasons) { // work only with 3d curves var crvDimension = crv.Dimension; if (crvDimension == 2) { return(null); } Point3d[] points; crv._DivideByCount_ThreadSafe(1000, true, out points); if (points == null) { return(null); } // convert point to 3d (if curve is 2d) if (crvDimension == 2 && srf != null) { for (int i = 0; i < points.Length; i++) { points[i] = srf.PointAt(points[i].X, points[i].Y); } } var indexes = _Point3d._Sort(points.ToList()); var res = _ZigZagDeformations_GetCurveFromPoints(crv, srf, points, true, indexes); return(res); }
private void ChartToCreate(String item) { List <String[]> originalData = ChartData(); String[] dataPicker = new String[originalData.Count]; for (int i = 0; i < originalData.Count; i++) { dataPicker[i] = originalData[i][1]; } _customChart.ChartView.Chart.Series.RemoveAllSeries(); var imageButton = ((((this.Children[0] as ContentPage).Content as ScrollView).Content as StackLayout).Children[1] as Grid).Children[2] as Button; switch (item) { case "AREA": Area area = new Area(); area.FillSampleValues(3); _customChart.ChartView.Chart.Series.Add(area); _customChart.ImageSource = dataPicker[0]; imageButton.Image = dataPicker[0]; break; #if !TEE_STD case "ARROW": Arrow arrow = new Arrow(); arrow.FillSampleValues(10); _customChart.ChartView.Chart.Series.Add(arrow); _customChart.ImageSource = dataPicker[1]; imageButton.Image = dataPicker[1]; break; #endif case "BAR": Bar bar = new Bar(); bar.FillSampleValues(4); _customChart.ChartView.Chart.Series.Add(bar); _customChart.ImageSource = dataPicker[2]; imageButton.Image = dataPicker[2]; break; #if !TEE_STD case "BARJOIN": BarJoin barjoin = new BarJoin(); barjoin.FillSampleValues(5); _customChart.ChartView.Chart.Series.Add(barjoin); _customChart.ImageSource = dataPicker[3]; imageButton.Image = dataPicker[3]; break; case "BEZIER": Bezier bezier = new Bezier(); bezier.FillSampleValues(5); _customChart.ChartView.Chart.Series.Add(bezier); _customChart.ImageSource = dataPicker[4]; imageButton.Image = dataPicker[4]; break; case "BOX": Box box = new Box(); box.FillSampleValues(3); _customChart.ChartView.Chart.Series.Add(box); _customChart.ImageSource = dataPicker[5]; imageButton.Image = dataPicker[5]; break; #endif case "BUBBLES": Bubble bubble = new Bubble(); bubble.FillSampleValues(7); _customChart.ChartView.Chart.Series.Add(bubble); _customChart.ImageSource = dataPicker[6]; imageButton.Image = dataPicker[6]; break; #if !TEE_STD case "CANDLE": Candle candle = new Candle(); candle.FillSampleValues(5); _customChart.ChartView.Chart.Series.Add(candle); _customChart.ImageSource = dataPicker[7]; imageButton.Image = dataPicker[7]; break; case "CONTOUR": Contour countour = new Contour(); countour.FillSampleValues(1); _customChart.ChartView.Chart.Series.Add(countour); _customChart.ImageSource = dataPicker[8]; imageButton.Image = dataPicker[8]; break; case "DARVAS": Darvas darvas = new Darvas(); darvas.FillSampleValues(3); _customChart.ChartView.Chart.Series.Add(darvas); _customChart.ImageSource = dataPicker[9]; imageButton.Image = dataPicker[9]; break; #endif case "DONUT": Donut donut = new Donut(); donut.FillSampleValues(1); _customChart.ChartView.Chart.Series.Add(donut); _customChart.ImageSource = dataPicker[10]; imageButton.Image = dataPicker[10]; break; #if !TEE_STD case "ERROR": Error error = new Error(); error.FillSampleValues(5); _customChart.ChartView.Chart.Series.Add(error); _customChart.ImageSource = dataPicker[11]; imageButton.Image = dataPicker[11]; break; case "ERRORBAR": ErrorBar errorbar = new ErrorBar(); errorbar.FillSampleValues(5); _customChart.ChartView.Chart.Series.Add(errorbar); _customChart.ImageSource = dataPicker[12]; imageButton.Image = dataPicker[12]; break; case "ERRORPOINT": ErrorPoint errorPoint = new ErrorPoint(); errorPoint.FillSampleValues(7); _customChart.ChartView.Chart.Series.Add(errorPoint); _customChart.ImageSource = dataPicker[13]; imageButton.Image = dataPicker[13]; break; #endif case "FASTLINE": FastLine fastLine = new FastLine(); fastLine.FillSampleValues(2); _customChart.ChartView.Chart.Series.Add(fastLine); _customChart.ImageSource = dataPicker[14]; imageButton.Image = dataPicker[14]; break; #if !TEE_STD case "HIGHLOW": HighLow highLow = new HighLow(); highLow.FillSampleValues(4); _customChart.ChartView.Chart.Series.Add(highLow); _customChart.ImageSource = dataPicker[15]; imageButton.Image = dataPicker[15]; break; case "HISTOGRAM": Histogram histogram = new Histogram(); histogram.FillSampleValues(6); _customChart.ChartView.Chart.Series.Add(histogram); _customChart.ImageSource = dataPicker[16]; imageButton.Image = dataPicker[16]; break; #endif case "HORIZAREA": HorizArea horizArea = new HorizArea(); horizArea.FillSampleValues(6); _customChart.ChartView.Chart.Series.Add(horizArea); _customChart.ImageSource = dataPicker[17]; imageButton.Image = dataPicker[17]; break; case "HORIZBAR": HorizBar horizBar = new HorizBar(); horizBar.FillSampleValues(6); _customChart.ChartView.Chart.Series.Add(horizBar); _customChart.ImageSource = dataPicker[18]; imageButton.Image = dataPicker[18]; break; case "HORIZLINE": HorizLine horizLine = new HorizLine(); horizLine.FillSampleValues(6); _customChart.ChartView.Chart.Series.Add(horizLine); _customChart.ImageSource = dataPicker[19]; imageButton.Image = dataPicker[19]; break; #if !TEE_STD case "ISOSURFACE": IsoSurface isoSurface = new IsoSurface(); isoSurface.FillSampleValues(10); _customChart.ChartView.Chart.Series.Add(isoSurface); _customChart.ImageSource = dataPicker[20]; imageButton.Image = dataPicker[20]; break; #endif case "LINE": Line line = new Line(); line.FillSampleValues(5); _customChart.ChartView.Chart.Series.Add(line); _customChart.ImageSource = dataPicker[21]; imageButton.Image = dataPicker[21]; break; #if !TEE_STD case "LINEPOINT": LinePoint linePoint = new LinePoint(); linePoint.FillSampleValues(6); _customChart.ChartView.Chart.Series.Add(linePoint); _customChart.ImageSource = dataPicker[22]; imageButton.Image = dataPicker[22]; break; #endif case "PIE": Pie pie = new Pie(); pie.FillSampleValues(4); _customChart.ChartView.Chart.Series.Add(pie); _customChart.ImageSource = dataPicker[23]; imageButton.Image = dataPicker[23]; break; #if !TEE_STD case "SURFACE": Surface surface = new Surface(); surface.FillSampleValues(10); //surface. _customChart.ChartView.Chart.Series.Add(surface); _customChart.ImageSource = dataPicker[24]; imageButton.Image = dataPicker[24]; break; case "TOWER": Tower tower = new Tower(); tower.FillSampleValues(8); _customChart.ChartView.Chart.Series.Add(tower); _customChart.ImageSource = dataPicker[25]; imageButton.Image = dataPicker[25]; break; case "VOLUME": Volume volume = new Volume(); volume.FillSampleValues(9); _customChart.ChartView.Chart.Series.Add(volume); _customChart.ImageSource = dataPicker[26]; imageButton.Image = dataPicker[26]; break; #endif } _customChart.ChartView.Chart.Axes.Left.Automatic = true; _customChart.ChartView.Chart.Axes.Bottom.Automatic = true; }
public SpherePacket256(VectorPacket256 centers, Vector256 <float> radiuses, Surface surface) : base(surface) { Centers = centers; Radiuses = radiuses; }
public unsafe override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; GuiController.Instance.CustomRenderEnabled = true; MyMediaDir = GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Media\\"; MyShaderDir = GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Shaders\\"; time = 0f; vel_x = new float[MAX_DS, MAX_DS]; vel_z = new float[MAX_DS, MAX_DS]; pos_x = new float[MAX_DS, MAX_DS]; pos_y = new float[MAX_DS, MAX_DS]; pos_z = new float[MAX_DS, MAX_DS]; //Crear loader TgcSceneLoader loader = new TgcSceneLoader(); // ------------------------------------------------------------ //Path de Heightmap default del terreno y Path de Textura default del terreno Vector3 PosTerrain = new Vector3(0, 0, 0); currentHeightmap = MyMediaDir + "Heighmaps\\" + "Heightmap2.jpg"; currentScaleXZ = 100f; currentScaleY = 6f; currentTexture = MyMediaDir + "Heighmaps\\" + "Heightmap2.JPG"; //+ "grid.JPG"; terrain = new TgcSimpleTerrain(); terrain.loadHeightmap(currentHeightmap, currentScaleXZ, currentScaleY, PosTerrain); terrain.loadTexture(currentTexture); // tomo el ancho de la textura, ojo tiene que ser cuadrada float terrain_width = (float)terrain.HeightmapData.GetLength(0); // mesh principal scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Sphere\\Sphere-TgcScene.xml"); Bitmap b = (Bitmap)Bitmap.FromFile(MyMediaDir + "Heighmaps\\grid.jpg"); g_pBaseTexture = Texture.FromBitmap(d3dDevice, b, Usage.None, Pool.Managed); b.Dispose(); mesh = scene.Meshes[0]; mesh.Scale = new Vector3(0.5f, 0.5f, 0.5f); mesh.Position = new Vector3(0f, 0f, 0f); mesh.AutoTransformEnable = false; Vector3 size = mesh.BoundingBox.calculateSize(); esfera_radio = Math.Abs(size.Y) / 2; //Cargar Shader string compilationErrors; effect = Effect.FromFile(d3dDevice, MyShaderDir + "GPUCompute.fx", null, null, ShaderFlags.None, null, out compilationErrors); if (effect == null) { throw new Exception("Error al cargar shader. Errores: " + compilationErrors); } //Configurar Technique effect.Technique = "DefaultTechnique"; effect.SetValue("map_size", terrain_width); effect.SetValue("map_desf", 0.5f / terrain_width); arrow = new TgcArrow(); arrow.Thickness = 1f; arrow.HeadSize = new Vector2(2f, 2f); arrow.BodyColor = Color.Blue; arrowN = new TgcArrow(); arrowN.Thickness = 1f; arrowN.HeadSize = new Vector2(2f, 2f); arrowN.BodyColor = Color.Red; arrowT = new TgcArrow(); arrowT.Thickness = 1f; arrowT.HeadSize = new Vector2(2f, 2f); arrowT.BodyColor = Color.Green; GuiController.Instance.RotCamera.CameraCenter = new Vector3(0, 0, 0); GuiController.Instance.RotCamera.CameraDistance = 3200; GuiController.Instance.RotCamera.RotationSpeed = 2f; LookAt = new Vector3(0, 0, 0); LookFrom = new Vector3(3200, 3000, 3200); float aspectRatio = (float)GuiController.Instance.Panel3d.Width / GuiController.Instance.Panel3d.Height; GuiController.Instance.CurrentCamera.updateCamera(); d3dDevice.Transform.Projection = Matrix.PerspectiveFovLH(Geometry.DegreeToRadian(45.0f), aspectRatio, 5f, 40000f); // Creo el mapa de velocidad g_pVelocidad = new Texture(d3dDevice, MAX_DS, MAX_DS, 1, Usage.RenderTarget, Format.A32B32G32R32F, Pool.Default); g_pVelocidadOut = new Texture(d3dDevice, MAX_DS, MAX_DS, 1, Usage.RenderTarget, Format.A32B32G32R32F, Pool.Default); // Mapa de Posicion g_pPos = new Texture(d3dDevice, MAX_DS, MAX_DS, 1, Usage.RenderTarget, Format.A32B32G32R32F, Pool.Default); g_pPosOut = new Texture(d3dDevice, MAX_DS, MAX_DS, 1, Usage.RenderTarget, Format.A32B32G32R32F, Pool.Default); // stencil compatible sin multisampling g_pDepthStencil = d3dDevice.CreateDepthStencilSurface(MAX_DS, MAX_DS, DepthFormat.D24S8, MultiSampleType.None, 0, true); // temporaria para recuperar los valores g_pTempVel = new Texture(d3dDevice, MAX_DS, MAX_DS, 1, 0, Format.A32B32G32R32F, Pool.SystemMemory); g_pTempPos = new Texture(d3dDevice, MAX_DS, MAX_DS, 1, 0, Format.A32B32G32R32F, Pool.SystemMemory); effect.SetValue("g_pVelocidad", g_pVelocidad); effect.SetValue("g_pPos", g_pPos); // Textura del heigmap g_pHeightmap = TextureLoader.FromFile(d3dDevice, currentHeightmap); effect.SetValue("height_map", g_pHeightmap); // Resolucion de pantalla effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth); effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight); effect.SetValue("currentScaleXZ", currentScaleXZ); effect.SetValue("currentScaleY", currentScaleY); //Se crean 2 triangulos con las dimensiones de la pantalla con sus posiciones ya transformadas // x = -1 es el extremo izquiedo de la pantalla, x=1 es el extremo derecho // Lo mismo para la Y con arriba y abajo // la Z en 1 simpre CustomVertex.PositionTextured[] vertices = new CustomVertex.PositionTextured[] { new CustomVertex.PositionTextured(-1, 1, 1, 0, 0), new CustomVertex.PositionTextured(1, 1, 1, 1, 0), new CustomVertex.PositionTextured(-1, -1, 1, 0, 1), new CustomVertex.PositionTextured(1, -1, 1, 1, 1) }; //vertex buffer de los triangulos g_pVBV3D = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default); g_pVBV3D.SetData(vertices, 0, LockFlags.None); g_pVB = new VertexBuffer(typeof(CustomVertex.PositionColored), MAX_DS * MAX_DS, d3dDevice, Usage.Dynamic | Usage.None, CustomVertex.PositionColored.Format, Pool.Default); // inicializo el mapa de velocidades Device device = GuiController.Instance.D3dDevice; Matrix ant_Proj = device.Transform.Projection; Matrix ant_World = device.Transform.World; Matrix ant_View = device.Transform.View; device.Transform.Projection = Matrix.Identity; device.Transform.World = Matrix.Identity; device.Transform.View = Matrix.Identity; // rt1 = velocidad Surface pOldRT = device.GetRenderTarget(0); Surface pSurf = g_pVelocidad.GetSurfaceLevel(0); device.SetRenderTarget(0, pSurf); Surface pOldDS = device.DepthStencilSurface; device.DepthStencilSurface = g_pDepthStencil; // rt2 = posicion Surface pSurf2 = g_pPos.GetSurfaceLevel(0); device.SetRenderTarget(1, pSurf2); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); effect.Technique = "ComputeVel"; device.VertexFormat = CustomVertex.PositionTextured.Format; device.SetStreamSource(0, g_pVBV3D, 0); effect.Begin(FX.None); effect.BeginPass(0); device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); effect.EndPass(); effect.End(); device.EndScene(); effect.SetValue("Kp", esfera_radio * (float)Math.PI / 2); // restauro los RT device.SetRenderTarget(0, pOldRT); device.SetRenderTarget(1, null); device.DepthStencilSurface = pOldDS; // restauro las Transf. device.Transform.Projection = ant_Proj; device.Transform.World = ant_World; device.Transform.View = ant_View; GuiController.Instance.Modifiers.addBoolean("dibujar_terreno", "Dibujar Terreno", true); }
private static NurbsCurve _ZigZagDeformations_GetCurveFromPoints(NurbsCurve crv, Surface srf, Point3d[] points3d, bool simplifyCurve, List <int> indexes = null) { var pps = new List <Point3d>(); if (indexes == null) { pps.AddRange(points3d); } else { for (int i = 0; i < indexes.Count; i++) { if (indexes[i] != -1) { pps.Add(points3d[indexes[i]]); } } } var c = Curve.CreateControlPointCurve(pps, 3); //var res1 = Curve.CreateInterpolatedCurve(pps, 3); - works bad - creates zigzags if (c != null) { if (crv.Dimension == 2) { c = c._SetDimension(2); } // it is incorrect to fix control point here! //////////if (crvNurb.Dimension == 2 && srf != null) //////////{ ////////// c = c._Fix2dContorlPoints(srf); // - shall we do fix 2d control points ??? - NO!!! //////////} if (simplifyCurve) { c = c._Simplify(srf, true); } if (!c._ZigZagDeformationExists(srf)) { return(c.ToNurbsCurve()); } } return(null); }
private static NurbsCurve _ZigZagDeformations_Remove(this NurbsCurve crvNurb, Surface srf, double[] ts, List <ZigZagDiapason> diapasons, double diapasonExtension) { // // Filter segmens - remove those segments what is close to zigzag control points // var filteredCrvPoints = new List <Point3d>(); filteredCrvPoints.Add(crvNurb.PointAt(ts[0])); // add 1-st point (PointAtStart) for (int i = 1; i < ts.Length - 1; i++) { var t = ts[i]; var isCloseToZigzag = false; foreach (var d in diapasons) { var minT = d.StartIgnoreAtT - diapasonExtension; var maxT = d.EndIgnoreAtT + diapasonExtension; if (minT <= t && t <= maxT) { isCloseToZigzag = true; break; } } if (!isCloseToZigzag) { filteredCrvPoints.Add(crvNurb.PointAt(t)); //Layers.Debug.AddPoint(crvNurb._PX3d(t, srf), Color.Green); } else { //Layers.Debug.AddPoint(crvNurb._PX3d(t, srf), Color.Red); } //DEBUG //var p3d = crvNurb.PointAt(t); //if (crvNurb.Dimension == 2) //{ // p3d = srf.PointAt(crvNurb.PointAt(t).X, crvNurb.PointAt(t).Y); //} //Layers.Debug.AddPoint(p3d, isCloseToZigzag ? Color.Red : Color.Blue); //ENDDEBUG } filteredCrvPoints.Add(crvNurb.PointAt(ts[ts.Length - 1]));// add last point (PointAtEnd) //DEBUG //log.temp("Adding debig point for ZigZag"); //Viewport.Redraw(RhinoDoc.ActiveDoc, "Layers.Debug.AddPoints(filteredCrvPoints)"); //foreach (var p in filteredCrvPoints) //{ // var p3d = p; // if (crvNurb.Dimension == 2) // { // p3d = srf.PointAt(p.X, p.Y); // } // Layers.Debug.AddPoint(p3d, Color.Blue); //} //ENDDEBUG // // Approximate and simplfy new crv // var res = Curve.CreateControlPointCurve(filteredCrvPoints, 3); //var res = Curve.CreateInterpolatedCurve(filteredCrvPoints, 3); - works bad - creates zigzags if (res != null) { if (crvNurb.Dimension == 2) { res = res._SetDimension(2); } // it is incorrect to fix control point here! //////////if (crvNurb.Dimension == 2 && srf != null) //////////{ ////////// res = res._Fix2dContorlPoints(srf); // - shall we do fix 2d control points ??? - NO!!! //////////} res = res._Simplify(srf, true); } return(res == null ? null : res._ToNurbsCurve()); }
private void Resize(object sender, VideoResizeEventArgs e) { screen = Video.SetVideoMode(e.Width, e.Height, true); this.width = e.Width; this.height = e.Height; }
public override bool IsSolid(Surface s) { return(false); // no solid surfaces }
public void Draw(Gdk.Rectangle cliprect) { if (surface == null) { return; } Surface sm = surface; Surface st = (surfaceTop != null)?(surfaceTop):(surface); Surface sb = (surfaceBottom != null)?(surfaceBottom):(surface); // TODO: // * Clip images that are partially outside the sector to make the edges // "neat"? How? // This is quite a hack, since we can't get our parent sector. // However we will only draw if we are the current sector, thus // we get the size from the Application. Gdk.Rectangle sectorbounds = new Gdk.Rectangle(0, 0, (int)Application.EditorApplication.CurrentSector.Width * 32, (int)Application.EditorApplication.CurrentSector.Height * 32); int minX; int maxX; if (Alignment == Alignments.none) { // Calc min and max *tiles*, including one *tile* overlap on both sides. minX = -((int)this.X / (int)st.Width) - 1; // Fix rounding with integer division... if (this.X > 0) { minX--; } maxX = Math.Abs(sectorbounds.Width - (int)this.X) / (int)st.Width; int minY = -((int)this.Y / (int)st.Height) - 1; // Fix rounding with integer division... if (this.Y > 0) { minY--; } int maxY = -1; //tile position 0 belongs to middle surface for (int tileX = minX; tileX <= maxX; tileX++) { for (int tileY = minY; tileY <= maxY; tileY++) { st.Draw(new Vector(X + st.Width * tileX, Y + st.Height * tileY)); } } } // Calc min and max *tiles*, including one *tile* overlap on both sides. minX = -((int)this.X / (int)sm.Width) - 1; // Fix rounding with integer division... if (this.X > 0) { minX--; } maxX = Math.Abs(sectorbounds.Width - (int)this.X) / (int)sm.Width; for (int tileX = minX; tileX <= maxX; tileX++) { sm.Draw(new Vector(X + sm.Width * tileX, Y)); } if (Alignment == Alignments.none) { // Calc min and max *tiles*, including one *tile* overlap on both sides. minX = -((int)this.X / (int)sb.Width) - 1; // Fix rounding with integer division... if (this.X > 0) { minX--; } maxX = Math.Abs(sectorbounds.Width - (int)this.X) / (int)sb.Width; int maxY = Math.Abs(sectorbounds.Height - (int)this.Y - (int)sm.Height) / (int)sb.Height; for (int tileX = minX; tileX <= maxX; tileX++) { for (int tileY = 0; tileY <= maxY; tileY++) { sb.Draw(new Vector(X + sb.Width * tileX, Y + sm.Height + sb.Height * tileY)); } } } }
public FilePlayer2(Surface surface) : base(surface) { }
public void CreateSurface(Surface p0) { CreateSurfaceInternal(p0); }
public override void Render(Surface src, Surface dst, Rectangle[] rois, int startIndex, int length) { ColorBgra colTransparent = ColorBgra.Transparent; unsafe { int aaSampleCount = quality * quality; PointF *aaPoints = stackalloc PointF[aaSampleCount]; PixelUtils.GetRgssOffsets(aaPoints, aaSampleCount, quality); ColorBgra *samples = stackalloc ColorBgra[aaSampleCount]; TransformData td; for (int n = startIndex; n < startIndex + length; ++n) { Rectangle rect = rois[n]; for (int y = rect.Top; y < rect.Bottom; y++) { ColorBgra *dstPtr = dst.GetPointAddressUnchecked(rect.Left, y); double relativeY = y - this.yCenterOffset; for (int x = rect.Left; x < rect.Right; x++) { double relativeX = x - this.xCenterOffset; int sampleCount = 0; for (int p = 0; p < aaSampleCount; ++p) { td.X = relativeX + aaPoints[p].X; td.Y = relativeY - aaPoints[p].Y; InverseTransform(ref td); float sampleX = (float)(td.X + this.xCenterOffset); float sampleY = (float)(td.Y + this.yCenterOffset); ColorBgra sample = colPrimary; if (IsOnSurface(src, sampleX, sampleY)) { sample = src.GetBilinearSample(sampleX, sampleY); } else { switch (this.edgeBehavior) { case WarpEdgeBehavior.Clamp: sample = src.GetBilinearSampleClamped(sampleX, sampleY); break; case WarpEdgeBehavior.Wrap: sample = src.GetBilinearSampleWrapped(sampleX, sampleY); break; case WarpEdgeBehavior.Reflect: sample = src.GetBilinearSampleClamped( ReflectCoord(sampleX, src.Width), ReflectCoord(sampleY, src.Height)); break; case WarpEdgeBehavior.Primary: sample = colPrimary; break; case WarpEdgeBehavior.Secondary: sample = colSecondary; break; case WarpEdgeBehavior.Transparent: sample = colTransparent; break; case WarpEdgeBehavior.Original: sample = src[x, y]; break; default: break; } } samples[sampleCount] = sample; ++sampleCount; } *dstPtr = ColorBgra.Blend(samples, sampleCount); ++dstPtr; } } } } }
static bool IsOnSurface(Surface src, float u, float v) { return(u >= 0 && u <= (src.Width - 1) && v >= 0 && v <= (src.Height - 1)); }