protected override void OnUpdateControl(GameTime gameTime) { if (!ShouldUpdate()) { return; } var actualDrawPosition = new Vector2(DrawPositionWithParentOffset.X + 34, DrawPositionWithParentOffset.Y + 25); if (_lastPosition != actualDrawPosition) { _characterRenderer.SetAbsoluteScreenPosition((int)actualDrawPosition.X, (int)actualDrawPosition.Y); } if (((CurrentMouseState.LeftButton == ButtonState.Released && PreviousMouseState.LeftButton == ButtonState.Pressed) || (CurrentMouseState.RightButton == ButtonState.Released && PreviousMouseState.RightButton == ButtonState.Pressed)) && DrawAreaWithParentOffset.ContainsPoint(CurrentMouseState.X, CurrentMouseState.Y)) { var nextDirectionInt = (int)RenderProperties.Direction + 1; var nextDirection = (EODirection)(nextDirectionInt % 4); RenderProperties = RenderProperties.WithDirection(nextDirection); } base.OnUpdateControl(gameTime); _lastPosition = actualDrawPosition; }
public MaterialInfo(string name, Bitmap texture, RenderProperties renderProperties, MaterialBehavior materialBehavior) { Name = name; Texture = texture; RenderProperties = renderProperties; MaterialBehavior = materialBehavior; }
public override bool Render(RenderProperties rp) { List <ShapeBBInformation> transportRectangleList = new List <ShapeBBInformation>(); StringBuilder dispString = new StringBuilder(); SolidBrush brush = new SolidBrush(config.ExPntLayerPointColor); SolidBrush highlightBrush = new SolidBrush(Color.Red); layerManager.generatePointList(ref transportRectangleList); int displayCharacterCount = config.ExPntLayerDisplayCommentMaxLength; if (transportRectangleList.Count != 0) { IShape shape; for (int i = 0; i < transportRectangleList.Count; i++) { shape = transportRectangleList[i].Shape; if (shape.Visible) { // draw the outline if (shape.IsHighlighted) { rp.G.FillEllipse(highlightBrush, transportRectangleList[i].BoundingBox); } else { rp.G.FillEllipse(brush, transportRectangleList[i].BoundingBox); } if (config.ExPntLayerDisplayComments) { dispString.Remove(0, dispString.Length); dispString.Append(shape.Commment); if (dispString.Length > 0) { if (dispString.Length > displayCharacterCount) { dispString.Remove(displayCharacterCount, dispString.Length - displayCharacterCount); dispString.Append("..."); } SizeF stringSize = rp.G.MeasureString(dispString.ToString(), CommentFont); shape.StringSize = stringSize; rp.G.DrawString(dispString.ToString(), CommentFont, brush, new Rectangle( transportRectangleList[i].BoundingBox.Right + 2, transportRectangleList[i].BoundingBox.Bottom + 2, (int)stringSize.Width, (int)stringSize.Height)); } } } } } return(true); }
public RenderProperties GetRenderProperties() { var renderProperties = new RenderProperties(); object r = renderProperties; ReadNode(_treeView.Nodes, ref r); return(renderProperties); }
public override bool Render(RenderProperties rp) { //if (this.Visible && Style.Enabled && this.Style.MaxVisible >= absoluteZoom && this.Style.MinVisible <= absoluteZoom) //{ // if (this.DataSource == null) // throw (new ApplicationException("DataSource property not set on layer '" + this.LayerName + "'")); //} return(true); }
public override bool Render(RenderProperties rp) { double xOff = rp.DX / rp.Scale; double yOff = rp.DY / rp.Scale; if (Changed) { recalculateData(rp.AbsoluteZoom, rp.Scale, xOff, yOff); } IntPtr hDC = rp.G.GetHdc(); MapPanelBindings.GDALDrawImage(layermanager.CGDALContainer, hDC, xOff, yOff, this.layerID); rp.G.ReleaseHdc(hDC); return(true); }
public override bool Render(RenderProperties rp) { // clip everything outside drawingArea // in this case this means, draw nothing if (isInDrawingArea(p, rp.DrawingArea)) { SolidBrush brush = new SolidBrush(config.GpsLayerPointColor); p = CoordCalculator.calculateDisplayCoords( gkToRender, rp.DX, rp.DY, this.mainControler.LayerManager.Scale); rp.G.FillEllipse(brush, new Rectangle( Convert.ToInt32(p.x), Convert.ToInt32(p.y), config.GpsLayerPointWidth, config.GpsLayerPointWidth)); } return(true); }
void Awake() { fogEffect = FindObjectOfType<FogEffect>(); renderProperties = FindObjectOfType<RenderProperties>(); var tmp = new Texture2D(4096, 4096); tmp.LoadImage(File.ReadAllBytes("C:\\Users\\nlight\\Desktop\\sky.png")); var pixels = tmp.GetPixels(); cubemap = new Cubemap(4096, TextureFormat.RGBA32, false); cubemap.SetPixels(pixels, CubemapFace.NegativeX); cubemap.SetPixels(pixels, CubemapFace.NegativeY); cubemap.SetPixels(pixels, CubemapFace.NegativeZ); cubemap.SetPixels(pixels, CubemapFace.PositiveX); cubemap.SetPixels(pixels, CubemapFace.PositiveY); cubemap.SetPixels(pixels, CubemapFace.PositiveZ); cubemap.Apply(); }
private void OnResolutionChanged(int width, int height) { if (screen.Width == width && screen.Height == height) { return; } playerTex?.Release(); cellsTexture?.Release(); playerTex = new RenderTexture(width, height, 32); playerTex.name = "Player Render"; PlayerCamera.targetTexture = playerTex; cellsTexture = new RenderTexture(width, height, 0, GraphicsFormat.R8_UNorm); cellsTexture.name = "Cells Visualization Texture"; SplitLineMaterial.SetTexture(SHADER_CELLS_STENCIL_TEX, cellsTexture); SplitLineMaterial.SetFloat(SHADER_LINE_THICKNESS, (float)height / 200); screen = new RenderProperties(width, height); }
private string RenderTableHeaderRow(int tabPos, RenderProperties renderProperties) { var txt = string.Empty; RenderLine(ref txt, ++tabPos, "<tr style=\"background-color:black;color:white;font-size:1em;text-align:left;\">"); tabPos++; if (renderProperties.Count) { RenderColumnHeaderTag(ref txt, tabPos, "#"); } var nugetProperties = renderProperties.NugetProperties; var packageProperties = renderProperties.PackageProperties; var projectReferenceProperties = renderProperties.ProjectReferenceProperties; if (nugetProperties != null) { if (nugetProperties.Id) { RenderColumnHeaderTag(ref txt, tabPos, "Library"); } if (nugetProperties.Version) { RenderColumnHeaderTag(ref txt, tabPos, "Version"); } if (nugetProperties.Description) { RenderColumnHeaderTag(ref txt, tabPos, "Description"); } if (nugetProperties.LicenseUrl) { RenderColumnHeaderTag(ref txt, tabPos, nugetProperties.LicenseType ? "License url" : "License"); } if (nugetProperties.LicenseType) { RenderColumnHeaderTag(ref txt, tabPos, nugetProperties.LicenseUrl ? "License type" : "License"); } if (nugetProperties.Authors) { RenderColumnHeaderTag(ref txt, tabPos, "Authors"); } if (nugetProperties.Owners) { RenderColumnHeaderTag(ref txt, tabPos, "Owners"); } if (nugetProperties.ProjectUrl) { RenderColumnHeaderTag(ref txt, tabPos, "Project Url"); } } if (packageProperties != null) { if (packageProperties.Id) { RenderColumnHeaderTag(ref txt, tabPos, "Package name"); } if (packageProperties.Version) { RenderColumnHeaderTag(ref txt, tabPos, "Package version"); } if (packageProperties.TargetFramework) { RenderColumnHeaderTag(ref txt, tabPos, "Package target framework"); } } if (projectReferenceProperties != null) { if (projectReferenceProperties.Name) { RenderColumnHeaderTag(ref txt, tabPos, "Reference name"); } if (projectReferenceProperties.Version) { RenderColumnHeaderTag(ref txt, tabPos, "Reference version"); } if (projectReferenceProperties.Culture) { RenderColumnHeaderTag(ref txt, tabPos, "Reference culture"); } if (projectReferenceProperties.PublicKeyToken) { RenderColumnHeaderTag(ref txt, tabPos, "Reference public key token"); } if (projectReferenceProperties.ProcessorArchitecture) { RenderColumnHeaderTag(ref txt, tabPos, "Reference processor architecture"); } if (projectReferenceProperties.Location) { RenderColumnHeaderTag(ref txt, tabPos, "Reference location"); } if (projectReferenceProperties.Private) { RenderColumnHeaderTag(ref txt, tabPos, "Reference is private"); } if (projectReferenceProperties.ProjectGuid) { RenderColumnHeaderTag(ref txt, tabPos, "Reference project guid"); } if (projectReferenceProperties.LicenseFiles) { RenderColumnHeaderTag(ref txt, tabPos, "Reference license files"); } if (projectReferenceProperties.ParentProjectName) { RenderColumnHeaderTag(ref txt, tabPos, "Reference parent project name"); } if (projectReferenceProperties.ParentProjectPath) { RenderColumnHeaderTag(ref txt, tabPos, "Reference parent project path"); } } tabPos--; RenderLine(ref txt, tabPos--, "</tr>"); return(txt); }
void Update() { if (timer == null) { timer = GetComponent<Timer>(); } if (light == null) { var lights = FindObjectsOfType<Light>(); foreach (var _light in lights) { if (_light.type == LightType.Directional) { light = _light; break; } } } if (renderProperties == null) { renderProperties = FindObjectOfType<RenderProperties>(); } RenderSettings.ambientMode = AmbientMode.Flat; RenderSettings.ambientIntensity = GlobalAmbientIntensity; RenderSettings.ambientGroundColor = GetAmbientColorByTimeOfDay(timer.TimeOfDay, timer.T); RenderSettings.ambientLight = Color.black; RenderSettings.ambientSkyColor = GetAmbientColorByTimeOfDay(timer.TimeOfDay, timer.T); RenderSettings.customReflection = null; renderProperties.m_ambientLight = RenderSettings.ambientSkyColor; renderProperties.m_fogColor = GetFogColorByTimeOfDay(timer.TimeOfDay, timer.T); renderProperties.m_volumeFogColor = GetFogColorByTimeOfDay(timer.TimeOfDay, timer.T); // renderProperties.m_pollutionFogColor = GetFogColorByTimeOfDay(timer.TimeOfDay, timer.T); light.color = GetSunColorByTimeOfDay(timer.TimeOfDay, timer.T); renderProperties.m_inscatteringColor = light.color; light.intensity = GlobalSunIntensity; var sunDirection = GetSunDirectionByTimeOfDay(timer.TimeOfDay, timer.T); light.transform.rotation = Quaternion.LookRotation(sunDirection, Vector3.up); }
/* * private ScreenSpaceAmbientOcclusion sSAOC; * private ScreenSpaceAmbientObscurance sSAOB; * private EdgeDetection edgeDetection; * private CreaseShading creaseShading; */ /* Fog */ /* * private float m_3DFogAmount = 0f; * private float m_3DFogAmountMax = 1f; * * private float m_3DFogStart = 0f; * private float m_3DFogStartMax = 1f; * * private float m_3DFogDistance = 0; * private float m_3DFogDistanceMax = 100000f; * * private float m_3DNoiseStepSize = 0f; * private float m_3DNoiseStepSizeMax = 120f; * * private float m_3DNoiseScale = 0; * private float m_3DNoiseScaleMax = 1f; */ //Game //private bool useButtons; //private bool useCollision; // Use this for initialization void Start() { //Resolution fullScreen = Screen.fullScreen; /* * //Rendering * antiAliasing = QualitySettings.antiAliasing; * anisotropicFilt = QualitySettings.anisotropicFiltering; * textureQuality = QualitySettings.masterTextureLimit; * pixelLightCount = QualitySettings.pixelLightCount; * //Shadow * shadowProjection = QualitySettings.shadowProjection; * shadowDistance = QualitySettings.shadowDistance; * shadowCascade = QualitySettings.shadowCascades; * //Other * vSync = QualitySettings.vSyncCount; * particleRaycastBudget = QualitySettings.particleRaycastBudget; * frameRate = Application.targetFrameRate; * * LoDLevel = QualitySettings.maximumLODLevel; * LoDBias = QualitySettings.lodBias;*/ //FPS frameUpdateTimer = new Timer(refreshRateMS); frameUpdateTimer.Elapsed += new ElapsedEventHandler(frameUpdateTimer_Elapsed); frameUpdateTimer.AutoReset = true; frameUpdateTimer.Start(); optionWindowRect = new Rect((Screen.width / 2) - (optionWindowRect.width / 2), (Screen.height / 2) - (optionWindowRect.height / 2), optionWindowRect.width, optionWindowRect.height); cameraBehaviours = Camera.main.GetComponents <MonoBehaviour>() as MonoBehaviour[]; //Get MonoBehaviours here. foreach (var t in FindObjectsOfType <MonoBehaviour>()) { var properties = t as RenderProperties; if (properties != null) { this.renderProperties = properties; } var properties1 = t as DayNightProperties; if (properties1 != null) { this.dayNightProperties = properties1; } var properties2 = t as DayNightCloudsProperties; if (properties2 != null) { this.dayNightCloudsProperties = properties2; } var properties3 = t as FogProperties; if (properties3 != null) { this.fogProperties = properties3; } } //m_fogHeight = (float)EUtils.GetFieldValue(renderProperties,"m_fogHeight"); /* * m_fogHeight = (float)EUtils.GetFieldValue(renderProperties,"m_fogHeight"); * EUtils.SetFieldValue(renderProperties,"m_fogHeight",m_fogHeight); * * m_edgeFogDistance = (float)EUtils.GetFieldValue(renderProperties,"m_edgeFogDistance"); * EUtils.SetFieldValue(renderProperties,"m_edgeFogDistance",m_edgeFogDistance); * * m_useVolumeFog = (bool)EUtils.GetFieldValue(renderProperties,"m_useVolumeFog"); * EUtils.SetFieldValue(renderProperties,"m_useVolumeFog",m_useVolumeFog); * * m_volumeFogDensity = (float)EUtils.GetFieldValue(renderProperties,"m_volumeFogDensity"); * EUtils.SetFieldValue(renderProperties,"m_volumeFogDensity",m_volumeFogDensity); * * m_volumeFogStart = (float)EUtils.GetFieldValue(renderProperties,"m_volumeFogStart"); * EUtils.SetFieldValue(renderProperties,"m_volumeFogStart",m_volumeFogStart); * * m_volumeFogDistance = (float)EUtils.GetFieldValue(renderProperties,"m_volumeFogDistance"); * EUtils.SetFieldValue(renderProperties,"m_volumeFogDistance",m_volumeFogDistance); * * m_pollutionFogIntensity = (float)EUtils.GetFieldValue(renderProperties,"m_pollutionFogIntensity"); * EUtils.SetFieldValue(renderProperties,"m_pollutionFogIntensity",m_pollutionFogIntensity); */ /* Fog */ /* * m_3DFogAmount = (float)EUtils.GetFieldValue(GetCameraBehaviour("FogEffect"),"m_3DFogAmount"); * m_3DFogStart = (float)EUtils.GetFieldValue(GetCameraBehaviour("FogEffect"),"m_3DFogStart"); * m_3DFogDistance = (float)EUtils.GetFieldValue(GetCameraBehaviour("FogEffect"),"m_3DFogDistance"); * m_3DNoiseStepSize = (float)EUtils.GetFieldValue(GetCameraBehaviour("FogEffect"),"m_3DNoiseStepSize"); * m_3DNoiseScale = (float)EUtils.GetFieldValue(GetCameraBehaviour("FogEffect"),"m_3DNoiseScale"); */ //Added Effects /* * sSAOC = Camera.main.gameObject.AddComponent<ScreenSpaceAmbientOcclusion>(); * sSAOB = Camera.main.gameObject.AddComponent<ScreenSpaceAmbientObscurance>(); * edgeDetection = Camera.main.gameObject.AddComponent<EdgeDetection>(); * creaseShading = Camera.main.gameObject.AddComponent<CreaseShading>(); * * sSAOC.enabled = false; * sSAOB.enabled = false; * edgeDetection.enabled = false; * creaseShading.enabled = false;*/ //QugetFileLoader Alpha. filePath = Application.persistentDataPath + "\\qMoreOptionsConfig.qgt"; QLoader qLoader = new QLoader(filePath); qData = qLoader.qData; if (qData == null) { qData = new QData(); } if (qData.GetValueByKey("DONT_REMOVE_THIS") == null) { //OVERRIDE qData.AddToValues("DONT_REMOVE_THIS", "ELSE_IT_RESETS!"); ResetToDefault(); } else { //Default antiAliasing = Load(saveTag + GetName(new { antiAliasing })); //anisotropicFilt = Load(saveTag + GetName (new { anisotropicFilt })); float anisoFloat = Load(saveTag + GetName(new { anisotropicFilt })); if (anisoFloat == 0) { anisotropicFilt = AnisotropicFiltering.Disable; } if (anisoFloat == 1) { anisotropicFilt = AnisotropicFiltering.Enable; } if (anisoFloat == 2) { anisotropicFilt = AnisotropicFiltering.ForceEnable; } textureQuality = Load(saveTag + GetName(new { textureQuality })); pixelLightCount = Load(saveTag + GetName(new { pixelLightCount })); //Shadow float shadowProjFloat = Load(saveTag + GetName(new { shadowProjection })); if (shadowProjFloat == 0) { shadowProjection = ShadowProjection.CloseFit; } if (shadowProjFloat == 1) { shadowProjection = ShadowProjection.StableFit; } maxShadowDistance = Load(saveTag + GetName(new { shadowDistance = maxShadowDistance })); shadowCascade = Load(saveTag + GetName(new { shadowCascade })); //Other vSync = Load(saveTag + GetName(new { vSync })); particleRaycastBudget = Load(saveTag + GetName(new { particleRaycastBudget })); frameRate = Load(saveTag + GetName(new { frameRate })); LoDLevel = Load(saveTag + GetName(new { LoDLevel })); LoDBias = Load(saveTag + GetName(new { LoDBias })); //Update QualitySettings.antiAliasing = (int)antiAliasing; QualitySettings.anisotropicFiltering = anisotropicFilt; QualitySettings.masterTextureLimit = (int)textureQuality; QualitySettings.pixelLightCount = (int)pixelLightCount; //Shadow QualitySettings.shadowProjection = shadowProjection; QualitySettings.shadowDistance = maxShadowDistance; QualitySettings.shadowCascades = (int)shadowCascade; //Other QualitySettings.vSyncCount = (int)vSync; QualitySettings.particleRaycastBudget = (int)particleRaycastBudget; Application.targetFrameRate = (int)frameRate; QualitySettings.maximumLODLevel = (int)LoDLevel; QualitySettings.lodBias = LoDBias; //Fog BackupFogClassicOptions(); Configuration.instance.fogClassic = Configuration.defaults.fogClassic; SetFogClassicOptions(); } }
public override bool Render(RenderProperties rp) { if (this.shapeType != ShapeLib.ShapeType.NullShape && NumberOfShapes > 0) { if (Changed || rp.ScreenChanged) { int tempPointSize = layerManager.PointSize; Pen layerPen = this.vectorInfo.LayerPen; if (rp.AbsoluteZoom > constZoomLevelLimit || bOutOfMemory) { // if we are switching to this "mode" (e.g. calculating all the points // again on every change) we must initialize the bitmapList with drawingArea // sized bitmaps since we do not want to create them all the time from scratch if (prepareBitmap) { bitmap.Dispose(); bitmap = new Bitmap(rp.DrawingArea.Width, rp.DrawingArea.Height, System.Drawing.Imaging.PixelFormat.Format16bppRgb555); prepareBitmap = false; } // this is done because multiplication is faster than division double invAbsZoom = 1.0 / rp.AbsoluteZoom; Rectangle collideRec = new Rectangle(1, 1, (int)(Math.Ceiling(rp.DrawingArea.Width * invAbsZoom)), (int)(Math.Ceiling(rp.DrawingArea.Height * invAbsZoom))); //Rectangle collideRec = new Rectangle(1, 1, // (int)(Math.Ceiling(rp.ClipRectangle.Width * invAbsZoom)), // (int)(Math.Ceiling(rp.ClipRectangle.Height * invAbsZoom))); Graphics gx = Graphics.FromImage(bitmap); gx.Clear(Color.NavajoWhite); // clip the collide rectanlge //clipRectagle // TODO: kann man das nicht irgendwie zusammenfassen / beschleunigen? collideRec.X = (int)(rp.DX * invAbsZoom - BoundingBox.Left * rp.Scale * invAbsZoom); collideRec.Y = (int)(-(rp.DY * invAbsZoom - BoundingBox.Top * rp.Scale * invAbsZoom)); //collideRec.X = (int)( (rp.DX + rp.ClipRectangle.X) * invAbsZoom - BoundingBox.Left * rp.Scale * invAbsZoom); //collideRec.Y = (int)(-((rp.DY + rp.ClipRectangle.Y) * invAbsZoom - BoundingBox.Top * rp.Scale * invAbsZoom)); long relativeDiffX = Convert.ToInt64(rp.DX - BoundingBox.Left * rp.Scale); //int relativeDiffX = Convert.ToInt32(rp.DX); long relativeDiffY = Convert.ToInt64(BoundingBox.Top * rp.Scale - rp.DY); //int relativeDiffY = Convert.ToInt32(-rp.DY); List <PointList> pl = new List <PointList>(); partGrid.CollidingPoints(collideRec, ref pl); if (!isPoint) { Point[] temp; // treat polygons special since they can be filled if (this.shapeType == MapTools.ShapeLib.ShapeType.Polygon && vectorInfo.Fill) { Brush layerBrush = new SolidBrush(this.vectorInfo.FillColor); for (int pointList = 0; pointList < pl.Count; pointList++) { temp = new Point[pl[pointList].Length]; for (int p = 0; p < temp.Length; p++) { temp[p].X = (int)(pl[pointList].getDispPoint(p).X - relativeDiffX); temp[p].Y = (int)(pl[pointList].getDispPoint(p).Y - relativeDiffY); } gx.FillPolygon(layerBrush, temp); gx.DrawLines(layerPen, temp); } } else if (this.shapeType != MapTools.ShapeLib.ShapeType.MultiPoint) { for (int pointList = 0; pointList < pl.Count; pointList++) { temp = new Point[pl[pointList].Length]; for (int p = 0; p < temp.Length; p++) { temp[p].X = (int)(pl[pointList].getDispPoint(p).X - relativeDiffX); temp[p].Y = (int)(pl[pointList].getDispPoint(p).Y - relativeDiffY); } gx.DrawLines(layerPen, temp); } } else { Rectangle drawRect = new Rectangle(); Brush tempPointBrush = new SolidBrush(this.VectorInfo.LayerPen.Color); for (int pointList = 0; pointList < pl.Count; pointList++) { temp = new Point[pl[pointList].Length]; for (int p = 0; p < temp.Length; p++) { temp[p].X = (int)(pl[pointList].getDispPoint(p).X - relativeDiffX); temp[p].Y = (int)(pl[pointList].getDispPoint(p).Y - relativeDiffY); } drawRect = new Rectangle(); for (int p = 0; p < temp.Length; p++) { drawRect.X = (int)(temp[p].X - (tempPointSize >> 1)); // >>1 is faster thatn *2 drawRect.Y = (int)(temp[p].Y - (tempPointSize >> 1)); drawRect.Width = tempPointSize; drawRect.Height = tempPointSize; gx.FillEllipse(tempPointBrush, drawRect); } } } } else // only one point in shape { gx.DrawEllipse(VectorInfo.LayerPen, new Rectangle((int)(_boundingBox.Left - relativeDiffX), (int)(_boundingBox.Bottom - relativeDiffY), tempPointSize, tempPointSize)); } gx.Dispose(); } else { // we rendered the image if (Changed) { bitmap.Dispose(); try { //try: drawing Points bitmap = new Bitmap( Convert.ToInt32(Width * rp.Scale + tempPointSize * 0.5 + 1), Convert.ToInt32(Height * rp.Scale + tempPointSize * 0.5 + 1), System.Drawing.Imaging.PixelFormat.Format16bppRgb555); } catch (OutOfMemoryException) { // jump over to resuce plan B :P bOutOfMemory = true; prepareBitmap = true; return(false); } Graphics gx = Graphics.FromImage(bitmap); gx.Clear(Color.NavajoWhite); if (shapeType == MapTools.ShapeLib.ShapeType.MultiPoint) { Rectangle drawRect = new Rectangle(); Brush tempPointBrush = new SolidBrush(VectorInfo.LayerPen.Color); Point[] intPL; for (int pointList = 0; pointList < polyLinePointList.Length; pointList++) { intPL = polyLinePointList[pointList].displayPointList; drawRect.X = (int)(intPL[0].X - (tempPointSize >> 1)); // >>1 is faster than *2 drawRect.Y = (int)(intPL[0].Y - (tempPointSize >> 1)); if (drawRect.X < 0) { drawRect.X = 0; } if (drawRect.Y < 0) { drawRect.Y = 0; } drawRect.Width = tempPointSize; drawRect.Height = tempPointSize; gx.FillEllipse(tempPointBrush, drawRect); } } else { if (vectorInfo.Fill) { Brush layerBrush = new SolidBrush(vectorInfo.FillColor); for (int pointList = 0; pointList < polyLinePointList.Length; pointList++) { gx.FillPolygon(layerBrush, polyLinePointList[pointList].displayPointList); gx.DrawLines(VectorInfo.LayerPen, polyLinePointList[pointList].displayPointList); } } else { for (int pointList = 0; pointList < polyLinePointList.Length; pointList++) { gx.DrawLines(VectorInfo.LayerPen, polyLinePointList[pointList].displayPointList); } } } if (isPoint) { double tempScale = layerManager.Scale; Brush tempBrush = new SolidBrush(VectorInfo.LayerPen.Color); gx.FillEllipse(tempBrush, new Rectangle( (int)((_boundingBox.Left) * tempScale), (int)((_boundingBox.Bottom) * tempScale), tempPointSize, tempPointSize)); } gx.Dispose(); Changed = false; } } } Rectangle destRect = new Rectangle(rp.DrawingArea.X, rp.DrawingArea.Y, bitmap.Width, bitmap.Height); if (rp.AbsoluteZoom <= constZoomLevelLimit && !bOutOfMemory) { destRect.X += Convert.ToInt32(BoundingBox.Left * rp.Scale - rp.DX); destRect.Y += Convert.ToInt32(rp.DY - BoundingBox.Top * rp.Scale); } rp.G.DrawImage(bitmap, destRect, 0, 0, destRect.Width, destRect.Height, GraphicsUnit.Pixel, imageAttributes); #region Feature highlighting // this has to be drawn directly to screen since we do not // want to change the stored image if (rp.Highlight && selectedItems != null) { int tempPointSize = layerManager.PointSize; Point[] intPL; Graphics g = rp.G; int drawingAreaX = rp.DrawingArea.X; int drawingAreaY = rp.DrawingArea.Y; Pen highlightPen = new Pen(Color.Red, this.vectorInfo.LayerPen.Width + 2); if (rp.AbsoluteZoom > constZoomLevelLimit || bOutOfMemory) { #region "direct draw" case //long relativeDiffX = Convert.ToInt64(dX - relativeLeft * absoluteZoom); //long relativeDiffY = Convert.ToInt64(-(dY + relativeTop * absoluteZoom)); long relativeDiffX = Convert.ToInt64(rp.DX - BoundingBox.Left * rp.Scale); long relativeDiffY = Convert.ToInt64(BoundingBox.Top * rp.Scale - rp.DY); PointList myPl; if (IsWellDefined) { for (int i = selectedItems.Length - 1; i >= 0; i--) { myPl = polyLinePointList[selectedItems[i]]; intPL = new Point[myPl.Length]; for (int p = 0; p < intPL.Length; p++) { intPL[p].X = (int)(myPl.getDispPoint(p).X - relativeDiffX); intPL[p].Y = (int)(myPl.getDispPoint(p).Y - relativeDiffY); } if (this.shapeType != ShapeLib.ShapeType.MultiPoint) { g.DrawLines(highlightPen, intPL); } else { Rectangle drawRect = new Rectangle(); Brush tempPointBrush = new SolidBrush(Color.Red); for (int p = 0; p < intPL.Length; p++) { drawRect.X = (int)(intPL[p].X - tempPointSize / 2); drawRect.Y = (int)(intPL[p].Y - tempPointSize / 2); drawRect.Width = tempPointSize; drawRect.Height = tempPointSize; g.FillEllipse(tempPointBrush, drawRect); } } } } #endregion } else { # region Bitmap drawing case if (IsWellDefined) { if (this.shapeType != ShapeLib.ShapeType.MultiPoint) { for (int i = selectedItems.Length - 1; i >= 0; i--) { intPL = (Point[])(polyLinePointList[selectedItems[i]].displayPointList.Clone()); for (int j = intPL.Length - 1; j >= 0; j--) { intPL[j].X += destRect.X; intPL[j].Y += destRect.Y; } g.DrawLines(highlightPen, intPL); } } else { Rectangle drawRect = new Rectangle(); Brush tempPointBrush = new SolidBrush(Color.Red); for (int i = selectedItems.Length - 1; i >= 0; i--) { intPL = (Point[])(polyLinePointList[selectedItems[i]].displayPointList.Clone()); drawRect.X = (int)(intPL[0].X - tempPointSize * 0.5 + destRect.X); drawRect.Y = (int)(intPL[0].Y - tempPointSize * 0.5 + destRect.Y); drawRect.Width = drawRect.Height = tempPointSize; g.FillEllipse(tempPointBrush, drawRect); } } } #endregion } } #endregion }
public abstract bool Render(RenderProperties rp);
public override bool Render(RenderProperties rp) { double newsize = size / rp.AbsoluteZoom; double CurrentxPos = (xPos + rp.DX / rp.AbsoluteZoom) * (newsize / Height); double CurrentyPos = (rp.DY / rp.AbsoluteZoom - yPos) * (newsize / Height); IntPtr hDC = rp.G.GetHdc(); MapPanelBindings.DrawMandelbrot( cMandelbrot, hDC, rp.DX, rp.DY, maxIterations, CurrentxPos, CurrentyPos, newsize); rp.G.ReleaseHdc(hDC); return(true); //Color[] cs = new Color[256]; //// Fills cs with the colors from the current ColorMap file //cs = GetColors(ColMaps[CurColMap]); //// Creates the Bitmap we draw to //Bitmap b = new Bitmap(this.Width, this.Height); //// From here on out is just converted from the c++ version. //double x, y, x1, y1, xx, xmin, xmax, ymin, ymax = 0.0; //int looper, s, z = 0; //double intigralX, intigralY = 0.0; //xmin = Sx; // Start x value, normally -2.1 //ymin = Sy; // Start y value, normally -1.3 //xmax = Fx; // Finish x value, normally 1 //ymax = Fy; // Finish y value, normally 1.3 //intigralX = (xmax - xmin) / this.Width; // Make it fill the whole window //intigralY = (ymax - ymin) / this.Height; //x = xmin; //for (s = 1; s < this.Width; s++) //{ // y = ymin; // for (z = 1; z < this.Height; z++) // { // x1 = 0; // y1 = 0; // looper = 0; // while (looper < 100 && Math.Sqrt((x1 * x1) + (y1 * y1)) < 2) // { // looper++; // xx = (x1 * x1) - (y1 * y1) + x; // y1 = 2 * x1 * y1 + y; // x1 = xx; // } // // Get the percent of where the looper stopped // double perc = looper / (100.0); // // Get that part of a 255 scale // int val = ((int)(perc * 255)); // // Use that number to set the color // b.SetPixel(s, z, cs[val]); // y += intigralY; // } // x += intigralX; //} //bq = b; // bq is a globally defined bitmap //this.BackgroundImage = (Image)bq; // Draw it to the form }
public void NextHairColor() { RenderProperties = RenderProperties.WithHairColor((byte)((RenderProperties.HairColor + 1) % 10)); }
public void NextHairStyle() { RenderProperties = RenderProperties.WithHairStyle((byte)((RenderProperties.HairStyle + 1) % 21)); }
public async Task <string> RenderToString(RenderProperties renderProperties, SolutionList solutionList, string titleText, string headerText) { return(await Render(renderProperties, solutionList, titleText, headerText)); }
private async Task <string> Render(RenderProperties renderProperties, SolutionList solutionList, string titleText, string headerText, string outputPath = null, string indexFileName = null) { var createFile = !string.IsNullOrWhiteSpace(outputPath) && !string.IsNullOrWhiteSpace(indexFileName); var packageReferences = solutionList.GetPackageReferences(!renderProperties.IncludeDuplicates, !renderProperties.IncludePackageDependencies, "<br>"); if (packageReferences.Any()) { if (createFile && !Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } var tabPos = 0; string txt = string.Empty; RenderLine(ref txt, tabPos, "<html>"); RenderLine(ref txt, ++tabPos, "<head>"); RenderLine(ref txt, ++tabPos, $"<title>{titleText}</title>"); if (renderProperties.PageAutomaticRefresh) { RenderLine(ref txt, tabPos, "<meta http-equiv=\"refresh\" content=\"5\">"); } RenderLine(ref txt, --tabPos, "</head>"); RenderLine(ref txt, tabPos, "<body style=\"font-family: Verdana, Helvetica, sans-serif;font-size:8pt;\">"); RenderLine(ref txt, ++tabPos, $"<h1>{headerText}</h1>"); if (renderProperties.IncludeSolutionInformation) { solutionList.ForEach(s => { RenderLine(ref txt, tabPos, $"<b>{s.Name}</b><br>"); RenderLine(ref txt, tabPos, $"<ul>"); s.Projects.ForEach(p => { RenderLine(ref txt, ++tabPos, $"<li>{p.Name}<br></li>"); }); RenderLine(ref txt, --tabPos, $"</ul>"); RenderLine(ref txt, tabPos, $"<br>"); }); RenderLine(ref txt, tabPos, $"<br>"); } if (createFile) { RenderLine(ref txt, tabPos, "<button onclick=\"createMarkdown();\">Markdown to clipboard</button>"); } RenderLine(ref txt, tabPos, $"<table id=\"mainTable\" cellspacing=\"1\" cellpadding=\"3\" style=\"font-size:8pt;\">"); txt += RenderTableHeaderRow(tabPos, renderProperties); txt += await RenderTableRows(tabPos, renderProperties, packageReferences, outputPath, createFile); RenderLine(ref txt, tabPos--, "</table>"); if (createFile) { txt += AddMarkdownScript(tabPos); txt += "<textarea type=\"text\" id=\"hiddenInput\" style=\"position:absolute;left:-100px;top:-100px;width:10px;height:10px;\"></textarea>"; } RenderLine(ref txt, tabPos--, "</body>"); RenderLine(ref txt, tabPos, "</html>"); if (createFile) { var file = Path.Combine(outputPath, indexFileName); await _fileUtilities.CreateFile(file, txt); } return(txt); } return(null); }
/// <summary> /// Renders the view of a given Renderer as if it were through another renderer /// </summary> /// <param name="camera">The origin camera</param> /// <param name="material">The Material to modify</param> /// <param name="sourceRenderer">The Source renderer</param> /// <param name="targetRenderer">The Target renderer</param> /// <param name="mesh">The Mesh of the source Renderer</param> /// <param name="obliquePlane">Will the projection matrix be clipped at the near plane?</param> /// <param name="is3d">Is the renderer not being treated as two-dimenstional?</param> /// <param name="isMirror">Is the renderer rendering through itself?</param> public void RenderIntoMaterial(Camera camera, Material material, MeshRenderer sourceRenderer, MeshRenderer targetRenderer, Mesh mesh, bool obliquePlane = true, bool is3d = false, bool isMirror = false, bool isSSR = false) { _renderData = RenderData; if (!Initialized) { return; } #if !SKS_Portals //if (camera.transform.parent == transform.parent) // return; #endif bool firstRender = false; Camera renderingCamera = RecursionCams[CurrentDepth]; Camera currentCamera = camera; //Render Placeholder if max depth hit if (CurrentDepth > SKSGlobalRenderSettings.RecursionNumber) { return; } RenderTexture renderTarget = camera.targetTexture; CameraMarker marker = CameraMarker.GetMarker(camera); if (marker) { // marker.CurrentRenderer = sourceRenderer; if (marker.Owner == OtherCamera) { return; } } Graphics.SetRenderTarget(renderTarget); //Sets up the Render Properties for this render RenderProperties renderProps = new RenderProperties(); //Is this the first time that the IsMirror is being rendered this frame? if (camera == Camera.main) { firstRender = true; } GUIStyle style = new GUIStyle(); style.normal.textColor = Color.red; renderProps |= firstRender ? RenderProperties.FirstRender : 0; renderProps |= RenderProperties.Optimize; renderProps |= (CurrentDepth < 1) ? (obliquePlane ? RenderProperties.ObliquePlane : 0) : RenderProperties.ObliquePlane; renderProps |= isMirror ? RenderProperties.Mirror : 0; renderProps |= isSSR ? RenderProperties.IsSSR : 0; renderProps |= SKSGlobalRenderSettings.CustomSkybox ? RenderProperties.RipCustomSkybox : 0; renderProps |= SKSGlobalRenderSettings.AggressiveRecursionOptimization ? RenderProperties.AggressiveOptimization : 0; if (firstRender) { renderProps |= SKSGlobalRenderSettings.Inverted ? RenderProperties.InvertedCached : 0; renderProps |= SKSGlobalRenderSettings.UvFlip ? RenderProperties.UvFlipCached : 0; } #if SKS_VR renderProps |= RenderProperties.VR; renderProps |= SKSGlobalRenderSettings.SinglePassStereo ? RenderProperties.SinglePass : 0; #endif _recursionNumber++; //Renders the IsMirror itself to the rendertexture transform.SetParent(RenderingCameraParent); CurrentDepth++; renderingCamera.renderingPath = camera.renderingPath; renderingCamera.cullingMask = camera.cullingMask; renderingCamera.stereoTargetEye = StereoTargetEyeMask.None; renderingCamera.enabled = false; RenderingCameras.Add(camera); //Set up the RenderData for the current frame RenderData.Camera = camera; RenderData.RenderingCamera = renderingCamera; RenderData.CurrentDepth = CurrentDepth; #if SKS_VR //Stereo Rendering if (camera.stereoTargetEye == StereoTargetEyeMask.Both) { RenderingCameraParent.rotation = DestinationTransform.rotation * (Quaternion.Inverse(OriginTransform.rotation) * (camera.transform.rotation)); RenderData tempDataLeft = RenderData.Clone(); RenderData tempDataRight = RenderData.Clone(); //Left eye tempDataLeft.Position = -SKVREyeTracking.EyeOffset(camera); tempDataLeft.ProjectionMatrix = camera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left); tempDataLeft.TextureName = "_LeftEyeTexture"; tempDataLeft.RenderProperties = renderProps; tempDataLeft.Eye = false; _cameraLib.RenderCamera(tempDataLeft); //Right eye tempDataRight.Position = SKVREyeTracking.EyeOffset(camera); tempDataRight.ProjectionMatrix = camera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right); tempDataRight.TextureName = "_RightEyeTexture"; tempDataRight.RenderProperties = renderProps; tempDataRight.Eye = true; if (!SKSGlobalRenderSettings.SinglePassStereo) { _cameraLib.RenderCamera(tempDataRight); } else { renderingCamera.stereoTargetEye = StereoTargetEyeMask.Right; _cameraLib.RenderCamera(tempDataRight); } } else { //Non-VR rendering with VR enabled RenderData tempData = RenderData.Clone(); renderProps &= ~RenderProperties.SinglePass; renderProps &= ~RenderProperties.VR; tempData.RenderProperties = renderProps; renderingCamera.transform.rotation = DestinationTransform.rotation * (Quaternion.Inverse(OriginTransform.rotation) * (camera.transform.rotation)); tempData.ProjectionMatrix = camera.projectionMatrix; tempData.Position = renderingCamera.transform.position; if (renderingCamera.stereoTargetEye == StereoTargetEyeMask.Left) { tempData.TextureName = "_LeftEyeTexture"; tempData.Eye = false; _cameraLib.RenderCamera(tempData); } else { tempData.TextureName = "_RightEyeTexture"; tempData.Eye = true; _cameraLib.RenderCamera(tempData); } } #else //Non-stereo rendering //RenderData.Position = camera.transform.position; RenderData tempData = RenderData.Clone(); tempData.ProjectionMatrix = camera.projectionMatrix; tempData.TextureName = "_RightEyeTexture"; tempData.RenderProperties = renderProps; tempData.Eye = true; renderingCamera.transform.rotation = DestinationTransform.rotation * (Quaternion.Inverse(OriginTransform.rotation) * (camera.transform.rotation)); CameraLib.RenderCamera(tempData); #endif SKEffectCamera.CurrentDepth--; RenderingCameras.Remove(camera); if (RenderingCameras.Count == 0) { try { _cameraLib.TerminateRender(); //SKSRenderLib.ClearUnwinder(); } catch (NullReferenceException e) { Debug.LogWarning("Attempted to render without proper setup"); } } }
private void OnWillRenderObject() { #if UNITY_EDITOR if (!(Selection.activeGameObject == gameObject)) { return; } if (!TargetController || !PortalMaterial || !Mask || !SKSGlobalRenderSettings.Preview || !this || Application.isPlaying) { //CleanupTemp(); return; } MeshRenderer previewRenderer = PreviewRoot.GetComponent <MeshRenderer>(); previewRenderer.sharedMaterial = PortalMaterial; //previewRenderer.enabled = true; SKSRenderLib lib = PreviewCamera.GetComponent <SKSRenderLib>(); PreviewCamera.transform.localPosition = Vector3.zero; Camera sceneCam = SceneView.GetAllSceneCameras()[0]; Camera cam = PreviewCamera; GL.Clear(true, true, Color.black); Graphics.SetRenderTarget(null); RenderProperties renderProps = new RenderProperties(); //renderState |= RenderState.FirstRender; renderProps |= RenderProperties.Optimize; renderProps |= SKSGlobalRenderSettings.Inverted ? RenderProperties.InvertedCached : 0; renderProps |= !SKSGlobalRenderSettings.UvFlip ? RenderProperties.UvFlipCached : 0; renderProps |= RenderProperties.ObliquePlane; renderProps |= RenderProperties.FirstRender; renderProps |= RenderProperties.RipCustomSkybox; MeshRenderer rend = GetComponent <MeshRenderer>(); MeshRenderer rend2 = TargetController.GetComponent <MeshRenderer>(); Mesh mesh = PreviewRoot.GetComponent <MeshFilter>().sharedMesh; //TargetController.PreviewRoot.GetComponent<MeshRenderer>().enabled = false; //TargetController.GetComponent<MeshRenderer>().enabled = false; cam.transform.localPosition = Vector3.zero; TargetController.PreviewRoot.transform.localPosition = Vector3.zero; cam.transform.rotation = TargetController.PreviewRoot.transform.rotation * (Quaternion.Inverse(transform.rotation) * (sceneCam.transform.rotation)); TargetController.PreviewRoot.transform.localScale = Vector3.one; if (renderData == null) { renderData = new RenderData(renderProps, cam, sceneCam, sceneCam.transform.position, sceneCam.projectionMatrix, "_RightEyeTexture", PortalMaterial, new Vector2(Screen.currentResolution.width, Screen.currentResolution.height), previewRenderer, rend2, mesh, 1, 0, false, false); } else { renderData.Position = sceneCam.transform.position; renderData.ProjectionMatrix = sceneCam.projectionMatrix; renderData.ScreenSize = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height); renderData.RenderingCamera = PreviewCamera; renderData.SourceRenderer = previewRenderer; } lib.RenderCamera(renderData); MaterialPropertyBlock block = new MaterialPropertyBlock(); previewRenderer.GetPropertyBlock(block); RenderTexture output = (RenderTexture)block.GetTexture("_RightEyeTexture"); //RenderTexture cachedOutput = RenderTexture.GetTemporary(output.width, output.height, output.depth, output.format); //cachedOutput.Create(); //texturesToDispose.Add(cachedOutput); //Graphics.CopyTexture(output, cachedOutput); if (output) { previewRenderer.sharedMaterial.SetTexture("_RightEyeTexture", output); } if (output) { previewRenderer.sharedMaterial.SetTexture("_LeftEyeTexture", output); } if (output) { block.SetTexture("_LeftEyeTexture", output); } //PortalController.PortalMaterial.SetVector("_LeftDrawPos", PortalController.PortalMaterial.GetVector("_RightDrawPos")); Graphics.SetRenderTarget(null); lib.TerminateRender(); #endif }
public override bool Render(RenderProperties rp) { List <PolyShapeBBInformation> transportPointList = new List <PolyShapeBBInformation>(); StringBuilder dispString = new StringBuilder(); Pen pen = new Pen(config.ExPLineLayerLineColor, config.exPLineLayerLineWidth); Pen hihglightPen = new Pen(Color.Red, config.exPLineLayerLineWidth); hihglightPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; SolidBrush brush = new SolidBrush(config.ExPLineLayerLineColor); SolidBrush brushPoint = new SolidBrush(config.ExPLineLayerPointColor); SolidBrush hlBrush = new SolidBrush(Color.Red); Graphics g = rp.G; double scale = rp.Scale; double dX = rp.DX; double dY = rp.DY; int pntWidth = config.ExPLineLayerPointWidth; IShape vertex = null; layermanager.generatePolylineList(ref transportPointList); if (transportPointList.Count != 0) { IShape shape; for (int i = transportPointList.Count - 1; i >= 0; i--) { shape = transportPointList[i].Shape; if (shape.Visible) { // draw the outline if (shape.IsHighlighted) { rp.G.DrawLines(hihglightPen, transportPointList[i].Pointlist); } else { rp.G.DrawLines(pen, transportPointList[i].Pointlist); } for (int j = shape.PointCount - 1; j >= 0; j--) { vertex = shape.getElement(j); // draw highlighted vertices if (vertex.IsHighlighted) { g.FillEllipse(hlBrush, vertex.getDisplayBoundingBox(dX, dY, pntWidth, scale, 1)); } else { // draw the vertices if (pntWidth > 0) { g.FillEllipse(brushPoint, vertex.getDisplayBoundingBox(dX, dY, pntWidth, scale, 0)); } } } if (config.ExPLineLayerDisplayComments) { dispString.Remove(0, dispString.Length); dispString.Append(shape.Commment); if (dispString.Length > 0) { if (dispString.Length > displayCharacterCount) { dispString.Remove(displayCharacterCount, dispString.Length - this.displayCharacterCount); dispString.Append("..."); } SizeF stringSize = rp.G.MeasureString(dispString.ToString(), commentFont); shape.StringSize = stringSize; g.DrawString(dispString.ToString(), this.commentFont, brush, new Rectangle( transportPointList[i].BoundingBox.Right + 2, transportPointList[i].BoundingBox.Bottom + 2, (int)stringSize.Width, (int)stringSize.Height)); } } } } } return(true); }
/// <summary> /// Handles scenveview rendering of portal previews and related editor utilities /// </summary> private void OnWillRenderObject() { #if UNITY_EDITOR if (!(Selection.activeGameObject == gameObject)) return; if (!TargetController || !PortalMaterial || !Mask || !SKSGlobalRenderSettings.Preview || !this || Application.isPlaying) return; var previewRenderer = PreviewRoot.GetComponent<MeshRenderer>(); previewRenderer.sharedMaterial = PortalMaterial; //previewRenderer.enabled = true; var lib = PreviewCamera.GetComponent<SKSRenderLib>(); PreviewCamera.transform.localPosition = Vector3.zero; var sceneCam = SceneView.GetAllSceneCameras()[0]; var cam = PreviewCamera; GL.Clear(true, true, Color.black); Graphics.SetRenderTarget(null); var renderProps = new RenderProperties(); //renderState |= RenderState.FirstRender; renderProps |= RenderProperties.Optimize; renderProps |= SKSGlobalRenderSettings.Inverted ? RenderProperties.InvertedCached : 0; renderProps |= !SKSGlobalRenderSettings.UvFlip ? RenderProperties.UvFlipCached : 0; renderProps |= RenderProperties.ObliquePlane; renderProps |= RenderProperties.FirstRender; renderProps |= RenderProperties.RipCustomSkybox; var rend = GetComponent<MeshRenderer>(); var rend2 = TargetController.GetComponent<MeshRenderer>(); var mesh = PreviewRoot.GetComponent<MeshFilter>().sharedMesh; //TargetController.PreviewRoot.GetComponent<MeshRenderer>().enabled = false; //TargetController.GetComponent<MeshRenderer>().enabled = false; cam.transform.localPosition = Vector3.zero; TargetController.PreviewRoot.transform.localPosition = Vector3.zero; cam.transform.rotation = TargetController.PreviewRoot.transform.rotation * (Quaternion.Inverse(transform.rotation) * sceneCam.transform.rotation); TargetController.PreviewRoot.transform.localScale = Vector3.one; if (renderData == null) { renderData = new RenderData(renderProps, cam, sceneCam, sceneCam.projectionMatrix, TextureTargetEye.Right, PortalMaterial, new Vector2(Screen.currentResolution.width, Screen.currentResolution.height), previewRenderer, rend2, null, null, mesh, 1, 0, false, 0); } else { renderData.Position = sceneCam.transform.position; renderData.ProjectionMatrix = sceneCam.projectionMatrix; renderData.ScreenSize = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height); renderData.RenderingCamera = PreviewCamera; renderData.SourceRenderer = previewRenderer; } try { lib.RenderCamera(renderData); } catch { //Doesn't really matter what happened here, unity editor strangeness sometimes hucks issues Graphics.SetRenderTarget(null); lib.TerminateRender(); return; } var block = new MaterialPropertyBlock(); previewRenderer.GetPropertyBlock(block); var output = (RenderTexture) block.GetTexture(TextureTargetEye.Right.Name()); if (output) previewRenderer.sharedMaterial.SetTexture(TextureTargetEye.Right.Name(), output); if (output) previewRenderer.sharedMaterial.SetTexture(TextureTargetEye.Left.Name(), output); if (output) block.SetTexture(TextureTargetEye.Left.Name(), output); Graphics.SetRenderTarget(null); lib.TerminateRender(); #endif }
public void NextGender() { RenderProperties = RenderProperties.WithGender((byte)((RenderProperties.Gender + 1) % 2)); }
public void NextRace() { RenderProperties = RenderProperties.WithRace((byte)((RenderProperties.Race + 1) % 6)); }
/// <summary> /// Renders the view of a given Renderer as if it were through another renderer. Returns true if successful. /// </summary> /// <param name="headCam">The origin camera</param> /// <param name="material">The Material to modify</param> /// <param name="sourceRenderer">The Source renderer</param> /// <param name="targetRenderer">The Target renderer</param> /// <param name="mesh">The Mesh of the source Renderer</param> /// <param name="obliquePlane">Will the projection matrix be clipped at the near plane?</param> /// <param name="is3d">Is the renderer not being treated as two-dimenstional?</param> /// <param name="isMirror">Is the renderer rendering through itself?</param> /// <param name="isSSR">Is the renderer a low quality effect renderer, similar to ssr?</param> public bool RenderIntoMaterial(Camera headCam, Material material, MeshRenderer sourceRenderer, MeshRenderer targetRenderer, Mesh mesh, bool obliquePlane = true, bool is3d = false, bool isMirror = false, bool isSSR = false) { if (!Initialized) { return(false); } #if !SKS_VR headCam.stereoTargetEye = StereoTargetEyeMask.None; #endif _renderDataTemplate = RenderDataTemplate; RenderDataTemplate.ScreenSize = new Vector2(MainCamera.pixelWidth, MainCamera.pixelHeight); #if !SKS_PORTALS //if (camera.transform.parent == transform.parent) // return; #endif var firstRender = false; var renderingCamera = RecursionCams[CurrentDepth]; //Render Placeholder if max depth hit if (CurrentDepth > SKSGlobalRenderSettings.RecursionNumber) { return(false); } var renderTarget = headCam.targetTexture; var marker = CameraMarker.GetMarker(headCam); if (marker) { if (marker.Owner == OtherCamera) { return(false); } } Graphics.SetRenderTarget(renderTarget); //Sets up the Render Properties for this render var renderProps = new RenderProperties(); //Is this the first time that the IsMirror is being rendered this frame? if (headCam == MainCamera) { firstRender = true; } renderProps |= firstRender ? RenderProperties.FirstRender : 0; //todo: reenable renderProps |= RenderProperties.Optimize; renderProps |= CurrentDepth < 1 ? (obliquePlane ? RenderProperties.ObliquePlane : 0) : RenderProperties.ObliquePlane; renderProps |= isMirror ? RenderProperties.Mirror : 0; renderProps |= isSSR ? RenderProperties.IsSSR : 0; renderProps |= SKSGlobalRenderSettings.CustomSkybox ? RenderProperties.RipCustomSkybox : 0; renderProps |= SKSGlobalRenderSettings.AggressiveRecursionOptimization ? RenderProperties.AggressiveOptimization : 0; if (firstRender) { renderProps |= SKSGlobalRenderSettings.Inverted ? RenderProperties.InvertedCached : 0; renderProps |= SKSGlobalRenderSettings.UvFlip ? RenderProperties.UvFlipCached : 0; } #if SKS_VR renderProps |= RenderProperties.VR; renderProps |= SKSGlobalRenderSettings.SinglePassStereo ? RenderProperties.SinglePass : 0; #endif //renderProps &= ~RenderProperties.Optimize; _recursionNumber++; //Renders the IsMirror itself to the rendertexture transform.SetParent(RenderingCameraParent); CurrentDepth++; renderingCamera.renderingPath = headCam.renderingPath; renderingCamera.cullingMask = headCam.cullingMask; renderingCamera.cullingMask |= 1 << Keywords.Layers.CustomRendererOnly; renderingCamera.stereoTargetEye = StereoTargetEyeMask.None; renderingCamera.enabled = false; RenderingCameras.Add(headCam); //Set up the RenderData for the current frame RenderDataTemplate.OriginCamera = headCam; RenderDataTemplate.RenderingCamera = renderingCamera; RenderDataTemplate.CurrentDepth = CurrentDepth; //Copy per-frame values for (var i = 0; i < (int)TextureTargetEye.Count; i++) { RenderDataTemplate.RenderDataCache[i].CopyFrameData(RenderDataTemplate); } #if SKS_VR //Stereo Rendering if (headCam.stereoTargetEye == StereoTargetEyeMask.Both) { RenderingCameraParent.rotation = DestinationTransform.rotation * (Quaternion.Inverse(OriginTransform.rotation) * (headCam.transform.rotation)); //Todo: Figure out why this optimization doesn't work in VR mode //var tempDataLeft = RenderDataTemplate.RenderDataCache[(int)TextureTargetEye.Left]; //var tempDataRight = RenderDataTemplate.RenderDataCache[(int)TextureTargetEye.Right]; var tempDataLeft = RenderDataTemplate.Clone(); var tempDataRight = RenderDataTemplate.Clone(); //Left eye tempDataLeft.Position = -SkvrEyeTracking.EyeOffset(headCam); tempDataLeft.ProjectionMatrix = headCam.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left); tempDataLeft.TargetEye = TextureTargetEye.Left; tempDataLeft.RenderProperties = renderProps; _cameraLib.RenderCamera(tempDataLeft); Debug.DrawRay(tempDataLeft.Position, headCam.transform.forward, Color.magenta, 1); //Right eye tempDataRight.Position = SkvrEyeTracking.EyeOffset(headCam); tempDataRight.ProjectionMatrix = headCam.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right); tempDataRight.TargetEye = TextureTargetEye.Right; tempDataRight.RenderProperties = renderProps; //Debug.DrawRay(tempDataRight.Position, headCam.transform.forward, Color.cyan, 1); if (!SKSGlobalRenderSettings.SinglePassStereo) { _cameraLib.RenderCamera(tempDataRight); } else { renderingCamera.stereoTargetEye = StereoTargetEyeMask.Right; _cameraLib.RenderCamera(tempDataRight); } } else { //Non-VR rendering with VR enabled //Todo: Figure out why this optimization doesn't work in VR mode /* * var tempData = * RenderDataTemplate.RenderDataCache[ * (int)TextureTargetEyeMethods.StereoTargetToTextureTarget( * renderingCamera.stereoTargetEye * ) * ];*/ var tempData = RenderDataTemplate.Clone(); renderProps &= ~RenderProperties.SinglePass; renderProps &= ~RenderProperties.VR; tempData.RenderProperties = renderProps; renderingCamera.transform.rotation = DestinationTransform.rotation * (Quaternion.Inverse(OriginTransform.rotation) * (headCam.transform.rotation)); tempData.ProjectionMatrix = headCam.projectionMatrix; tempData.Position = renderingCamera.transform.position; if (renderingCamera.stereoTargetEye == StereoTargetEyeMask.Left) { tempData.TargetEye = TextureTargetEye.Left; _cameraLib.RenderCamera(tempData); } else { tempData.TargetEye = TextureTargetEye.Right; _cameraLib.RenderCamera(tempData); } } #else //Non-stereo rendering //RenderData.Position = camera.transform.position; var tempData = RenderDataTemplate.RenderDataCache[(int)TextureTargetEye.Right]; tempData.ProjectionMatrix = headCam.projectionMatrix; tempData.RenderProperties = renderProps; renderingCamera.transform.rotation = DestinationTransform.rotation * (Quaternion.Inverse(OriginTransform.rotation) * headCam.transform.rotation); CameraLib.RenderCamera(tempData); #endif CurrentDepth--; RenderingCameras.Remove(headCam); if (RenderingCameras.Count == 0) { try { //_cameraLib.TerminateRender(); //SKSRenderLib.ClearUnwinder(); } catch (NullReferenceException e) { Debug.LogWarning("Attempted to render without proper setup"); } } return(true); }
private async Task <string> RenderTableRows(int tabPos, RenderProperties renderProperties, ProjectReferenceList packageReferences, string outputPath, bool createFile) { var txt = string.Empty; var i = 1; var renderCount = renderProperties.Count; var nugetProperties = renderProperties.NugetProperties; var packageProperties = renderProperties.PackageProperties; var projectReferenceProperties = renderProperties.ProjectReferenceProperties; foreach (var packageReference in packageReferences) { RenderLine(ref txt, ++tabPos, i % 2 == 0 ? "<tr style=\"background-color:#e9e9e9\">" : "<tr>"); tabPos++; if (renderCount) { RenderColumnTag(ref txt, tabPos, i.ToString()); } var nugetValues = packageReference.NugetPackage; if (nugetProperties != null && nugetValues != null) { if (nugetProperties.Id) { RenderColumnTag(ref txt, tabPos, nugetValues.Id); } if (nugetProperties.Version) { RenderColumnTag(ref txt, tabPos, nugetValues.Version); } if (nugetProperties.Description) { RenderColumnTag(ref txt, tabPos, nugetValues.Description); } if (nugetProperties.LicenseUrl) { RenderColumnTag(ref txt, tabPos, $"<a href=\"{nugetValues.LicenseUrl}\" target=\"blank\">{nugetValues.LicenseUrl}</a>"); } if (nugetProperties.LicenseType) { var fallbackText = nugetProperties.LicenseUrl ? string.Empty : nugetValues.LicenseUrl; var licenseType = await _licenseMapper.GetLicenseType(nugetValues.LicenseUrl, fallbackText); RenderColumnTag(ref txt, tabPos, $"<a href=\"{nugetValues.LicenseUrl}\" target=\"blank\">{licenseType}</a>"); } if (nugetProperties.Authors) { RenderColumnTag(ref txt, tabPos, nugetValues.Authors); } if (nugetProperties.Owners) { RenderColumnTag(ref txt, tabPos, nugetValues.Owners); } if (nugetProperties.ProjectUrl) { RenderColumnTag(ref txt, tabPos, $"<a href=\"{nugetValues.ProjectUrl}\" target=\"blank\">{nugetValues.ProjectUrl}</a>"); } } var packageValues = packageReference.Package; if (packageProperties != null && packageValues != null) { if (packageProperties.Id) { RenderColumnTag(ref txt, tabPos, packageValues.Id); } if (packageProperties.Version) { RenderColumnTag(ref txt, tabPos, packageValues.Version); } if (packageProperties.TargetFramework) { RenderColumnTag(ref txt, tabPos, packageValues.TargetFramework); } } if (projectReferenceProperties != null) { if (projectReferenceProperties.Name) { RenderColumnTag(ref txt, tabPos, packageReference.Name); } if (projectReferenceProperties.Version) { RenderColumnTag(ref txt, tabPos, packageReference.Version); } if (projectReferenceProperties.Culture) { RenderColumnTag(ref txt, tabPos, packageReference.Culture); } if (projectReferenceProperties.PublicKeyToken) { RenderColumnTag(ref txt, tabPos, packageReference.PublicKeyToken); } if (projectReferenceProperties.ProcessorArchitecture) { RenderColumnTag(ref txt, tabPos, packageReference.ProcessorArchitecture); } if (projectReferenceProperties.Location) { RenderColumnTag(ref txt, tabPos, packageReference.Location); } if (projectReferenceProperties.Private) { RenderColumnTag(ref txt, tabPos, packageReference.Private.ToString()); } if (projectReferenceProperties.ProjectGuid) { RenderColumnTag(ref txt, tabPos, packageReference.ProjectGuid); } if (projectReferenceProperties.LicenseFiles) { RenderColumnTag(ref txt, tabPos, await RenderLicenseLinks(packageReference, outputPath, createFile)); } if (projectReferenceProperties.ParentProjectName) { RenderColumnTag(ref txt, tabPos, packageReference.ParentProjectName); } if (projectReferenceProperties.ParentProjectPath) { RenderColumnTag(ref txt, tabPos, packageReference.ParentProjectPath); } } tabPos--; RenderLine(ref txt, tabPos--, "</tr>"); i++; } return(txt); }