public void Render(GameClient gameClient, RenderInfo renderInfo) { _currentFrameTime = GameTime.Now(); GL.ClearColor(0.5f, 0.6f, 0.9f, 1f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); var offset = gameClient.PositionData.Placement.Pos - EntityPos.Origin; SetProjectionMatrix(renderInfo); _modelViewMatrix = Matrix4.Identity * Matrix4.CreateTranslation((float)-offset.X, (float)-offset.Y - gameClient.PhysicsValues.PlayerEyeHeight, (float)-offset.Z) * Matrix4.CreateRotationY((float)-gameClient.PositionData.Placement.Orientation.Horizontal) * Matrix4.CreateRotationX((float)gameClient.PositionData.Placement.Orientation.Vertical); _textureAtlas.Bind(); RenderHighlightedFace(gameClient); RenderBlocks(gameClient); RenderEntities(gameClient); _outlineRenderer.RenderOutlines(renderInfo); }
public virtual void Render(RenderInfo info, Sprite sprite) { //this.Scale = .1f * Math.Min(1, this.Life * 5); //this.Alpha = 1.0f * Math.Min(1, this.Life * 5); this.PreRender(); sprite.RenderFrame(info, this.Frame, this.Position, 0, this.Scale / sprite.Width, this.Color, this.Alpha); }
public override void Render(RenderInfo info) { this.effect.Projection = Matrix.CreateOrthographicOffCenter( -1, 1, 1, -1, 0, 1); PhantomGame.Game.GraphicsDevice.BlendState = BlendState.NonPremultiplied; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); PhantomGame.Game.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, this.vertices, 0, this.vertices.Length, this.indices, 0, 4); } base.Render(info); }
public override void Render(Device dev, EditorCamera cam) { if (texs_main == null) { texs_main = ObjectHelper.GetTextures("WINDY_BACK2", texlist_main, dev); } if (texs_floating == null) { texs_floating = ObjectHelper.GetTextures("WINDY_BACK2", texlist_floating, dev); } dev.SetRenderState(RenderState.ZWriteEnable, true); List <RenderInfo> result = new List <RenderInfo>(); MatrixStack transform = new MatrixStack(); transform.Push(); transform.NJTranslate(650, -360, -200); result.AddRange(models[0].DrawModelTree(dev.GetRenderState <FillMode>(RenderState.FillMode), transform, texs_main, meshes[0], EditorOptions.IgnoreMaterialColors, EditorOptions.OverrideLighting)); result.AddRange(models[1].DrawModelTree(dev.GetRenderState <FillMode>(RenderState.FillMode), transform, texs_floating, meshes[1], EditorOptions.IgnoreMaterialColors, EditorOptions.OverrideLighting)); result.AddRange(models[2].DrawModelTree(dev.GetRenderState <FillMode>(RenderState.FillMode), transform, texs_floating, meshes[1], EditorOptions.IgnoreMaterialColors, EditorOptions.OverrideLighting)); RenderInfo.Draw(result, dev, cam); }
private void DrawStraightLineSelector(RenderInfo info, float x1, float y1, float x2, float y2) { #region Add BBox var bbox = new BoundingBox(); bbox.Target = this; bbox.Data = this; var tmp = new Rectangle((int)Math.Min(x1, x2), (int)Math.Min(y1, y2), (int)Math.Abs(x2 - x1), (int)Math.Abs(y2 - y1)); tmp.Inflate(6, 6); bbox.Bounds = tmp; info.BoundingBoxes.Add(bbox); #endregion if (Selected) { tmp.Inflate(-2, -2); info.Graphics.FillRectangle(Brushes.Selection, tmp); } }
public override void Render(Device dev, EditorCamera cam) { if (Act == 1 && cam.Position.Y <= -10400.0f) { return; } List <RenderInfo> result = new List <RenderInfo>(); MatrixStack transform = new MatrixStack(); transform.Push(); transform.NJTranslate(cam.Position.X, cam.Position.Y, cam.Position.Z); transform.NJScale(Skybox_Scale); switch (Act) { case 0: default: textures[0] = ObjectHelper.GetTextures("BG_HIGHWAY"); textures[1] = ObjectHelper.GetTextures("BG_HIGHWAY01"); break; case 1: textures[0] = ObjectHelper.GetTextures("BG_HIGHWAY"); textures[1] = ObjectHelper.GetTextures("BG_HIGHWAY02"); break; case 2: textures[0] = ObjectHelper.GetTextures("BG_HIGHWAY03"); textures[1] = null; break; } for (int i = 0; i < 2; i++) { if (models[i] != null) { result.AddRange(models[i].DrawModelTree(dev.GetRenderState <FillMode>(RenderState.FillMode), transform, textures[i], meshes[i], EditorOptions.IgnoreMaterialColors, EditorOptions.OverrideLighting)); } } transform.Pop(); RenderInfo.Draw(result, dev, cam); }
protected override void OnInit(EventArgs e) { base.OnInit(e); ModuleInfo module = ModuleContext.Configuration; // auto attach a ContentLocalized OpenContent module to the reference module of the default language string openContentAutoAttach = PortalController.GetPortalSetting("OpenContent_AutoAttach", ModuleContext.PortalId, "False"); bool autoAttach = bool.Parse(openContentAutoAttach); if (autoAttach) { //var module = (new ModuleController()).GetModule(ModuleContext.moduleId, ModuleContext.tabId, false); var defaultModule = module.DefaultLanguageModule; if (defaultModule != null) { if (ModuleContext.ModuleId != defaultModule.ModuleID) { var mc = (new ModuleController()); mc.DeLocalizeModule(module); mc.ClearCache(defaultModule.TabID); mc.ClearCache(module.TabID); const string MODULE_SETTINGS_CACHE_KEY = "ModuleSettings{0}"; // to be compatible with dnn 7.2 DataCache.RemoveCache(string.Format(MODULE_SETTINGS_CACHE_KEY, defaultModule.TabID)); DataCache.RemoveCache(string.Format(MODULE_SETTINGS_CACHE_KEY, module.TabID)); //DataCache.ClearCache(); module = mc.GetModule(defaultModule.ModuleID, ModuleContext.TabId, true); _settings = module.OpenContentSettings(); } } } engine = new RenderEngine(module); _renderinfo = engine.Info; _settings = engine.Settings; OpenContent.TemplateInit ti = (TemplateInit)TemplateInitControl; ti.ModuleContext = ModuleContext; ti.Settings = _settings; ti.Renderinfo = _renderinfo; }
public void RenderOutlines(RenderInfo renderInfo) { GL.Flush(); GL.UseProgram(_postProcessShader.Value.Id); GL.BindTexture(TextureTarget.Texture2D, _depthBufferTexture.Value); if (renderInfo.Width != _depthBufferWidth || renderInfo.Height != _depthBufferHeight) { _depthBufferWidth = renderInfo.Width; _depthBufferHeight = renderInfo.Height; GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.DepthComponent, _depthBufferWidth, _depthBufferHeight, 0, PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero); } GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, _depthBufferWidth, _depthBufferHeight); GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.MirroredRepeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.MirroredRepeat); GL.Disable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Begin(PrimitiveType.Quads); GL.TexCoord2(0, 0); GL.Vertex3(-1, -1, 0); GL.TexCoord2(1, 0); GL.Vertex3(1, -1, 0); GL.TexCoord2(1, 1); GL.Vertex3(1, 1, 0); GL.TexCoord2(0, 1); GL.Vertex3(-1, 1, 0); GL.End(); GL.UseProgram(0); }
public override void RenderLate(Device dev, EditorCamera cam) { dev.SetRenderState(RenderState.ZWriteEnable, true); texs_ocean = ObjectHelper.GetTextures("E101R_TIKEI"); List <RenderInfo> result3 = new List <RenderInfo>(); MatrixStack transform = new MatrixStack(); dev.SetRenderState(RenderState.ZWriteEnable, true); for (int o = 0; o < SADXOceanData.WaterSurfaces.Count; o++) { SADXOceanData.WaterSurfaceData water = SADXOceanData.WaterSurfaces[o]; transform.Push(); transform.NJTranslate(cam.Position.X, 0, cam.Position.Z); transform.NJScale(2.0f, 1.0f, 2.0f); transform.NJTranslate(water.Center); transform.NJTranslate(0, -40, 0); transform.Push(); for (int i = 0; i < water.WrapX; i++) { for (int z = 0; z < water.WrapZ; z++) { result3.Add(new RenderInfo(water.Meshes[z], 0, transform.Top, SADXOceanData.Material, texs_ocean?[water.TextureWaves], dev.GetRenderState <FillMode>(RenderState.FillMode), water.Bounds)); } transform.NJTranslate(water.WrapXZ, 0, 0); } transform.Pop(); transform.Push(); for (int i = 0; i < water.WrapX; i++) { for (int z = 0; z < water.WrapZ; z++) { result3.Add(new RenderInfo(water.Meshes[z], 0, transform.Top, SADXOceanData.Material, texs_ocean?[water.TextureSea], dev.GetRenderState <FillMode>(RenderState.FillMode), water.Bounds)); } transform.NJTranslate(water.WrapXZ, 0, 0); } transform.Pop(); transform.Pop(); } RenderInfo.Draw(result3, dev, cam); }
override public bool GetGlyphSize(char ch, out float width, out float height) { if (_font.GetCharacterInfo(ch, out sTempChar, _size, _style)) { RenderInfo ri; if (_lastFontSize == _size) { ri = _lastRenderInfo; } else { _lastFontSize = _size; ri = _lastRenderInfo = GetRenderInfo(_size); } #if (UNITY_5 || UNITY_5_3_OR_NEWER) width = sTempChar.advance; #else width = Mathf.CeilToInt(sTempChar.width); #endif height = ri.height; if (customBold) { width++; } if (keepCrisp) { width /= UIContentScaler.scaleFactor; height /= UIContentScaler.scaleFactor; } return(true); } else { width = 0; height = 0; return(false); } }
public override void PreviewDrawBackground(RenderInfo info) { Shape start = Start; Shape end = End; if (start == null || end == null) { return; } Rectangle startBounds = start.Bounds; Rectangle endBounds = end.Bounds; float x1 = startBounds.X + startBounds.Width / 2; float y1 = startBounds.Y + startBounds.Height / 2; float x2 = endBounds.X + endBounds.Width / 2; float y2 = endBounds.Y + endBounds.Height / 2; info.Graphics.DrawLine(System.Drawing.Pens.DarkGray, x1, y1, x2, y2); }
private void SetUpScreen(RenderInfo renderInfo) { float diagonalFactor = (float)(_uiDiagonal / Math.Sqrt(ExtraMath.Square(renderInfo.Width) + ExtraMath.Square(renderInfo.Height))); Width = renderInfo.Width * diagonalFactor; Height = renderInfo.Height * diagonalFactor; GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); var modelViewMatrix = Matrix4.Zero; modelViewMatrix.M11 = 2.0f / Width; modelViewMatrix.M41 = -1.0f; modelViewMatrix.M22 = -2.0f / Height; modelViewMatrix.M42 = 1.0f; modelViewMatrix.M33 = 1; modelViewMatrix.M44 = 1; GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelViewMatrix); }
public static MvcHtmlString SortableListAddButtonFor <VM, TItem>( this HtmlHelper <VM> htmlHelper, RenderInfo <IEnumerable <TItem> > renderInfo, string textOrUrl, ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button, IDictionary <string, object> htmlAttributes = null, string name = null, int templateIndex = 0) { if (renderInfo == null) { throw (new ArgumentNullException("renderInfo")); } if (MvcEnvironment.Validation(htmlHelper) == ValidationType.StandardClient) { return(MvcHtmlString.Create(string.Empty)); } string id = BasicHtmlHelper.IdFromName(renderInfo.Prefix); return(htmlHelper.ManipulationButton(ManipulationButtonType.Custom, textOrUrl, string.Format(addButtonScript, id, templateIndex), name == null ? id + "_AddButton" + templateIndex.ToString(CultureInfo.InvariantCulture) : name, manipulationButtonStyle, htmlAttributes)); }
internal void DrawLevel() { if (!loaded) { return; } d3ddevice.SetTransform(TransformType.Projection, Matrix.PerspectiveFovRH((float)(Math.PI / 4), panel1.Width / (float)panel1.Height, 1, cam.DrawDistance)); d3ddevice.SetTransform(TransformType.View, cam.ToMatrix()); Text = "X=" + cam.Position.X + " Y=" + cam.Position.Y + " Z=" + cam.Position.Z + " Pitch=" + cam.Pitch.ToString("X") + " Yaw=" + cam.Yaw.ToString("X") + " Interval=" + interval + (cam.mode == 1 ? " Distance=" + cam.Distance : "") + (animation != null ? " Animation=" + animation.Name + " Frame=" + animframe : ""); d3ddevice.RenderState.FillMode = EditorOptions.RenderFillMode; d3ddevice.RenderState.CullMode = EditorOptions.RenderCullMode; d3ddevice.Material = new Material { Ambient = Color.White }; d3ddevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToArgb(), 1, 0); d3ddevice.RenderState.ZBufferEnable = true; d3ddevice.BeginScene(); //all drawings after this line EditorOptions.RenderStateCommonSetup(d3ddevice); MatrixStack transform = new MatrixStack(); if (animation != null) { RenderInfo.Draw(model.DrawModelTreeAnimated(d3ddevice, transform, Textures, meshes, animation, animframe), d3ddevice, cam); } else { RenderInfo.Draw(model.DrawModelTree(d3ddevice, transform, Textures, meshes), d3ddevice, cam); } if (selectedObject != null) { DrawSelectedObject(model, transform); } d3ddevice.EndScene(); //all drawings before this line d3ddevice.Present(); }
public override void Draw(RenderInfo info) { int grid = info.GridSize; Rectangle renderBounds = Bounds; var bboxThis = new BoundingBox(); bboxThis.Bounds = renderBounds; bboxThis.Target = this; bboxThis.Data = BodyIdentifier; info.BoundingBoxes.Add(bboxThis); int x = renderBounds.X; int y = renderBounds.Y; int width = renderBounds.Width; int height = renderBounds.Height; GraphicsPath path = GetOutlinePath(x, y, width, height); Pen borderPen = GetBorderPen(); using (Brush captionBrush = GetCaptionBrush(renderBounds)) { if (Expanded) { DrawExpanded(info, path, x, y, width, height, captionBrush, borderPen); } else { DrawCollapsed(info, path, x, y, width, height, captionBrush, borderPen); } } DrawTypeExpander(info, x, y, width); DrawSelection(info); DrawTypeName(info, x, y, width); DrawTypeKind(info, x, y, width); DrawCustomCaptionInfo(info, x, y, width); }
public override List <RenderInfo> Render(SETItem item, Device dev, EditorCamera camera, MatrixStack transform) { List <RenderInfo> result = new List <RenderInfo>(); transform.Push(); transform.NJTranslate(item.Position); transform.NJRotateY(item.Rotation.Y - 0x5772); transform.NJScale(item.Scale.X, item.Scale.Y, item.Scale.Z); float largestScale = item.Scale.X; if (item.Scale.Y > largestScale) { largestScale = item.Scale.Y; } if (item.Scale.Z > largestScale) { largestScale = item.Scale.Z; } BoundingSphere boxSphere = new BoundingSphere() { Center = new Vertex(item.Position.X, item.Position.Y, item.Position.Z), Radius = (1.5f * largestScale) }; RenderInfo outputInfo = new RenderInfo(mesh, 0, transform.Top, material, null, FillMode.Solid, boxSphere); result.Add(outputInfo); if (item.Selected) { RenderInfo highlightInfo = new RenderInfo(mesh, 0, transform.Top, material, null, FillMode.Wireframe, boxSphere); result.Add(highlightInfo); } transform.Pop(); return(result); }
public void GetDetailData(RenderInfo info, OpenContentModuleInfo module) { info.ResetData(); var ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module); var dsItem = ds.Get(dsContext, info.DetailItemId); //if (LogContext.IsLogActive) //{ // var logKey = "Get detail data"; // LogContext.Log(_module.ModuleID, logKey, "debuginfo", dsItems.DebugInfo); //} if (dsItem != null) { //check permissions var portalSettings = PortalSettings.Current; bool isEditable = _module.ViewModule.CheckIfEditable(portalSettings); if (!isEditable) { var indexConfig = OpenContentUtils.GetIndexConfig(info.Template); string raison; if (!OpenContentUtils.HaveViewPermissions(dsItem, portalSettings.UserInfo, indexConfig, out raison)) { if (module.ViewModule.HasEditRightsOnModule()) { Exceptions.ProcessHttpException(new NotAuthorizedException(404, $"No detail view permissions for id={info.DetailItemId} (due to {raison}) \nGo into Edit Mode to view/change the item")); } else { Exceptions.ProcessHttpException(new NotAuthorizedException(404, "Access denied. You might want to contact your administrator for more information.")); } } } info.SetData(dsItem, dsItem.Data, module.Settings.Data); } }
private void GetDetailData(RenderInfo info, OpenContentModuleConfig module) { info.ResetData(); var ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module); var dsItem = ds.Get(dsContext, info.DetailItemId); //if (LogContext.IsLogActive) //{ // var logKey = "Get detail data"; // LogContext.Log(_module.ModuleID, logKey, "debuginfo", dsItems.DebugInfo); //} if (dsItem != null) { //check permissions bool isEditable = _module.ViewModule.CheckIfEditable(module); if (!isEditable) { var indexConfig = OpenContentUtils.GetIndexConfig(info.Template); string raison; if (!OpenContentUtils.HaveViewPermissions(dsItem, module.UserRoles.FromDnnRoles(), indexConfig, out raison)) { App.Services.Logger.Error($"Error accessing {HttpContext.Current?.Request?.Url?.AbsoluteUri}. Referrer {HttpContext.Current?.Request?.UrlReferrer?.AbsoluteUri}"); if (module.ViewModule.HasEditRightsOnModule()) { throw new NotAuthorizedException(404, $"No detail view permissions for id={info.DetailItemId} (due to {raison}) \nGo into Edit Mode to view/change the item."); } else { throw new NotAuthorizedException(404, $"Access denied. You might want to contact your administrator for more information. (due to {raison})"); } } } info.SetData(dsItem, dsItem.Data, module.Settings.Data); } }
/// <summary> /// Begin the Player's turn, asking for input to select a Ghost. /// </summary> public void DoTurn() { RenderInfo.UpdateGhostListing(myGhosts); // Ask for Input // Receive the Input as a Vector with x:[0,2] and y:[0,18] input = InputReceiver.AskGhostSelect(); // Select a Ghost int nonNullGhosts = GetGhostNumbers(input.X); if (input.Y > nonNullGhosts) { SelectedGhost = myGhosts[input.X][nonNullGhosts]; } else { SelectedGhost = myGhosts[input.X][input.Y]; } UseGhost(); }
protected void DrawTypeExpander(RenderInfo info, int x, int y, int width) { var typeExpanderBounds = new Rectangle(x + width - 20, y + 6, 13, 13); #region add type expander bbox var bboxTypeExpander = new BoundingBox(); bboxTypeExpander.Target = this; bboxTypeExpander.Bounds = typeExpanderBounds; bboxTypeExpander.Data = TypeExpanderIdentifier; info.BoundingItems.Add(bboxTypeExpander); #endregion if (Expanded) { info.Graphics.DrawImage(Resources.CollapseType, typeExpanderBounds); } else { info.Graphics.DrawImage(Resources.ExpandType, typeExpanderBounds); } }
private void DrawPortSelector(RenderInfo info, float x1, float y1, float x2, float y2, object portIdentifier) { #region Add BBox var bbox = new BoundingBox { Target = this, Data = portIdentifier }; var tmp = new Rectangle((int)Math.Min(x1, x2), (int)Math.Min(y1, y2), (int)Math.Abs(x2 - x1), (int)Math.Abs(y2 - y1)); tmp.Inflate(6, 6); bbox.Bounds = tmp; info.BoundingItems.Add(bbox); #endregion if (Selected) { tmp.Inflate(-2, -2); info.Graphics.FillRectangle(Brushes.Selection, tmp); } }
protected int DrawExpandedCaption(RenderInfo info, GraphicsPath path, int x, int y, int width, int height, Brush captionBrush) { int captionHeight = 48; var captionBounds = new Rectangle(x, y, width, captionHeight); #region add caption bbox var bboxCaption = new BoundingBox(); bboxCaption.Bounds = captionBounds; bboxCaption.Target = this; bboxCaption.Data = CaptionIdentifier; info.BoundingItems.Add(bboxCaption); #endregion info.Graphics.SetClip(path); info.Graphics.FillRectangle(captionBrush, captionBounds); info.Graphics.FillRectangle(Brushes.White, x, y + captionHeight, width, height - captionHeight); info.Graphics.DrawLine(Pens.LightGray, x, y + captionHeight, x + width, y + captionHeight); info.Graphics.ResetClip(); return(captionHeight); }
public static void WriteRenderInfo(this FMAT m, Material mat) { if (mat.RenderInfos == null) { mat.RenderInfos = new List <RenderInfo>(); } mat.RenderInfos.Clear(); foreach (BfresRenderInfo rnd in m.renderinfo) { RenderInfo r = new RenderInfo(); r.Name = rnd.Name; switch (rnd.Type) { case RenderInfoType.Int32: r.SetValue(rnd.ValueInt); break; case RenderInfoType.Single: r.SetValue(rnd.ValueFloat); break; case RenderInfoType.String: r.SetValue(rnd.ValueString); break; } mat.RenderInfos.Add(r); } }
public void Render(RenderInfo info) { _shaderProgram.UseProgram(); // Set camera location and projection _shaderProgram.SetUniform("viewMatrix", info.CurrentViewMatrix); _shaderProgram.SetUniform("projectionMatrix", info.CurrentProjectionMatrix); _shaderProgram.SetUniform("inverseProjectViewMatrix", Matrix4.Invert(info.CurrentViewMatrix * info.CurrentProjectionMatrix)); _shaderProgram.SetUniform("windowWidth", info.Width); _shaderProgram.SetUniform("windowHeight", info.Height); // TODO: Remove ToArray() GL.BindTextures(0, _renderTextures.Count, _renderTextures.Select(tex => tex.OpenGLTextureId).ToArray()); // This is must be here, otherwise the first bound image from BindTextureUnit will display instead of the one that is actually bound var samplerArray = Enumerable.Range(0, _renderTextures.Count).ToArray(); _shaderProgram.SetUniform("samplers", samplerArray); GL.BindVertexArray(_vertexArrayObject); GL.BindBuffer(BufferTarget.ElementArrayBuffer, _vertexIndexBufferId); GL.DrawElements(PrimitiveType.Triangles, _triangleAssertionsToRender.Length * VerticesPerTriangle, DrawElementsType.UnsignedInt, 0); }
public override void RenderLate(Device dev, EditorCamera cam) { List <RenderInfo> result3 = new List <RenderInfo>(); MatrixStack transform = new MatrixStack(); dev.SetRenderState(RenderState.ZWriteEnable, false); Texture[] watertex = Act == 3 ? texs_advss03 : texs_advss04; for (int o = 0; o < SADXOceanData.WaterSurfaces.Count; o++) { SADXOceanData.WaterSurfaceData water = SADXOceanData.WaterSurfaces[o]; transform.Push(); transform.NJTranslate(water.Center); transform.Push(); transform.NJTranslate(0, -1, 0); for (int i = 0; i < water.WrapX; i++) { for (int z = 0; z < water.WrapZ; z++) { result3.Add(new RenderInfo(water.Meshes[z], 0, transform.Top, SADXOceanData.Material, watertex?[water.TextureWaves], dev.GetRenderState <FillMode>(RenderState.FillMode), water.Bounds)); } transform.NJTranslate(water.WrapXZ, 0, 0); } transform.Pop(); transform.Push(); for (int i = 0; i < water.WrapX; i++) { for (int z = 0; z < water.WrapZ; z++) { result3.Add(new RenderInfo(water.Meshes[z], 0, transform.Top, SADXOceanData.Material, watertex?[water.TextureSea], dev.GetRenderState <FillMode>(RenderState.FillMode), water.Bounds)); } transform.NJTranslate(water.WrapXZ, 0, 0); } transform.Pop(); transform.Pop(); } RenderInfo.Draw(result3, dev, cam); }
private static void DrawPort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) { const int marginSize = Margins.RelationPortMargin; if (portSide == UmlPortSide.Left) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); } if (portSide == UmlPortSide.Right) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); } if (portSide == UmlPortSide.Top) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); } if (portSide == UmlPortSide.Bottom) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); } }
private void SetProjectionMatrix(RenderInfo renderInfo) { float dw = renderInfo.Width; float dh = renderInfo.Height; float dd = (float)Math.Sqrt(dw * dw + dh * dh); float df = 1.0f / (float)Math.Tan(_viewingAngle / 180.0 * Math.PI * 0.5); float yScale = df * dd / dh; float xScale = df * dd / dw; float near = 0.05f; float far = 1000.0f; float length = far - near; Matrix4 projectionMatrix = Matrix4.Zero; projectionMatrix.M11 = xScale; projectionMatrix.M22 = yScale; projectionMatrix.M33 = (-far - near) / length; projectionMatrix.M34 = -1; projectionMatrix.M43 = -2 * near * far / length; projectionMatrix.M44 = 0; _projectionMatrix = projectionMatrix; }
/// <summary> /// Must be called in render loop. /// </summary> private PickingInfo GetPickingInfo(RenderInfo info, int pickLocationX, int pickLocationY) { // Get surface ID float[] colourAttachment1Dump = new float[4]; int screenYInverted = info.Height - pickLocationY - 1; GL.ReadBuffer(ReadBufferMode.ColorAttachment1); GL.ReadPixels(pickLocationX, screenYInverted, 1, 1, PixelFormat.Rgba, PixelType.Float, colourAttachment1Dump); GL.ReadBuffer(ReadBufferMode.ColorAttachment0); // In this case nothing has been hit and we are looking at the clear colour if (colourAttachment1Dump[0] == 0.0) { return(new PickingInfo(null, info.TotalRenderTime, pickLocationX, pickLocationY, default)); } float[] zValue = new float[1]; GL.ReadPixels(pickLocationX, screenYInverted, 1, 1, PixelFormat.DepthComponent, PixelType.Float, zValue); ulong surfaceIdOut = (ulong)colourAttachment1Dump[0]; return(new PickingInfo(surfaceIdOut, info.TotalRenderTime, pickLocationX, pickLocationY, new Vector3(colourAttachment1Dump[1], colourAttachment1Dump[2], colourAttachment1Dump[3]))); }
public void GetDetailData(RenderInfo info, OpenContentSettings settings) { info.ResetData(); var ds = DataSourceManager.GetDataSource(settings.Manifest.DataSource); var dsContext = new DataSourceContext() { ModuleId = info.ModuleId, ActiveModuleId = _module.ModuleID, TemplateFolder = settings.TemplateDir.FolderPath, Config = settings.Manifest.DataSourceConfig }; var dsItem = ds.Get(dsContext, info.DetailItemId); if (LogContext.IsLogActive) { var logKey = "Get detail data"; LogContext.Log(_module.ModuleID, logKey, "result", dsItem); } if (dsItem != null) { info.SetData(dsItem, dsItem.Data, settings.Data); } }
public override void AddLines(RenderInfo info, ArrayList <VertexNormalColor> opaqueVertexData, ArrayList <VertexNormalColor> transparentVertexData) { ArrayList <VertexNormalColor> vertexData = (PrimitiveColor.A < 255 ? transparentVertexData : opaqueVertexData); Matrix4x4 rotation = new Matrix4x4(new Quaternion(up, Math.PI * 2.0 / segments)); Vector3 currentDir = handDir; Vector3 oldDir = currentDir; for (int i = 1; i <= segments; i++) { currentDir = rotation * currentDir; vertexData.Add(new VertexNormalColor() { Position = oldDir * radius + center, Color = PrimitiveColor }); vertexData.Add(new VertexNormalColor() { Position = currentDir * radius + center, Color = PrimitiveColor }); oldDir = currentDir; } }
public static MvcHtmlString JsonModel <M, T>(this HtmlHelper <M> htmlHelper, string name, T value, IDictionary <string, object> htmlAttributes = null, bool translateBack = false) { if (string.IsNullOrWhiteSpace(name)) { throw(new ArgumentNullException("name")); } if (translateBack) { RenderInfo <T> renderInfo = new RenderInfo <T>( htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(name), name, string.Empty, value); var h = htmlHelper.RenderWith( htmlHelper.InvokeTransform( renderInfo, new SipleModelTranslator <T>())); return(h.HiddenFor(m => m.JSonModel, htmlAttributes)); } else { return(htmlHelper.Hidden(name, value == null ? null : BasicHtmlHelper.ClientEncode(value), htmlAttributes)); } }
private void DrawPortBackground(RenderInfo info, UmlPortSide portSide, PointF point, object portIdentifier) { const int marginSize = Margins.RelationPortMargin; if (portSide == UmlPortSide.Left) { DrawPortSelector(info, point.X, point.Y, point.X + marginSize, point.Y, portIdentifier); } if (portSide == UmlPortSide.Right) { DrawPortSelector(info, point.X, point.Y, point.X - marginSize, point.Y, portIdentifier); } if (portSide == UmlPortSide.Top) { DrawPortSelector(info, point.X, point.Y, point.X, point.Y + marginSize, portIdentifier); } if (portSide == UmlPortSide.Bottom) { DrawPortSelector(info, point.X, point.Y, point.X, point.Y - marginSize, portIdentifier); } }
public override void Render(Device dev, EditorCamera cam) { List <RenderInfo> result = new List <RenderInfo>(); MatrixStack transform = new MatrixStack(); // Sky transform.Push(); transform.NJTranslate(cam.Position.X, 0, cam.Position.Z); transform.NJRotateY(0xE000); result.AddRange(model1.DrawModelTree(dev.GetRenderState <FillMode>(RenderState.FillMode), transform, ObjectHelper.GetTextures("CHAOS6_BG"), mesh1, EditorOptions.IgnoreMaterialColors, EditorOptions.OverrideLighting)); transform.Pop(); // Moving cloud transform.Push(); dev.SetRenderState(RenderState.ZWriteEnable, true); dev.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha); dev.SetRenderState(RenderState.DestinationBlend, Blend.One); transform.NJTranslate(cam.Position.X, 2300.0f, cam.Position.Z); // Absolutely wrong but accurate to SADX! transform.NJScale(3.0f, 1.0f, 3.0f); result.AddRange(model2.DrawModelTree(dev.GetRenderState <FillMode>(RenderState.FillMode), transform, ObjectHelper.GetTextures("CHAOS6_BG"), mesh2, EditorOptions.IgnoreMaterialColors, EditorOptions.OverrideLighting)); dev.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha); dev.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha); transform.Pop(); RenderInfo.Draw(result, dev, cam); }
/// <summary> /// Renders a single line of the mandelbrot image. /// </summary> /// <param name="renderInfo">The image information.</param> /// <param name="maxIterations">The maximum iterations.</param> private static unsafe void RenderSingleLine(ref RenderInfo renderInfo, int maxIterations) { var colorScale = 255D / maxIterations; var width = renderInfo.Width; var pixel = renderInfo.LinePointer; var pixelPosition = renderInfo.PixelPosition; var pixelIncrease = renderInfo.PixelIncrease; for (var x = 0; x < width; ++x) { SetColorAtLocation(pixel, ref pixelPosition, colorScale, maxIterations); // advance the pixel pointer pixelPosition += pixelIncrease; pixel += BytesPerPixel; } }
/// <summary> /// Renders the mandelbrot set onto the <paramref name="buffer" />. /// </summary> /// <param name="buffer">The buffer.</param> /// <param name="height">The height.</param> /// <param name="width">The width.</param> /// <param name="stride">The stride.</param> private unsafe void RenderMandelbrotSet([NotNull] byte[] buffer, int height, int width, int stride) { // Lock the bitmap for rendering fixed (byte* scan0 = buffer) { // fetch some base pointers var basePointer = scan0; // determine the running variables in the complex plane var linePosition = _topLeft + _translate; var lineIncrease = _deltaImaginary; var pixelIncrease = _deltaReal; // iterate over all lines and columns var options = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }; const int maxIterations = 100; Parallel.For(0, height, options, y => { var linePointer = basePointer + y * stride; var pixelPosition = linePosition + y * lineIncrease; var ii = new RenderInfo(linePointer, pixelPosition, pixelIncrease, width); RenderSingleLine(ref ii, maxIterations); }); } // Release the Kraken }
public ItemList(Catalog catalog, ListDictionary columnNames, Hashtable columnsToShow, Presentation presentation) { this.presentation = presentation; this.catalog = catalog; catalog.OnItemCollectionChanged += Refresh; this.columnNames = columnNames; this.items = new Hashtable (); order = new ArrayList (); if (this.columnNames != null) { int columnIndex = 0; this.columnsToShow = columnsToShow; // create the types array for the treeview types = new Hashtable (); foreach (string columnName in this.columnNames.Keys) { TreeViewColumn column = new TreeViewColumn(); if (columnName.Equals ("id")) { // Let's fill the Type array for the Model and create the columns. // Id Column types.Add (columnName, typeof (string)); order.Add (columnName); column.Title = "Id"; CellRendererText idCellRenderer = new CellRendererText (); column.PackStart (idCellRenderer, false); RenderInfo idRenderInfo = new RenderInfo (this, columnIndex); column.SetCellDataFunc (idCellRenderer, new TreeCellDataFunc (idRenderInfo.GenericCellDataFunc)); column.SortColumnId = columnIndex; this.InsertColumn (column, columnIndex); idColumnPosition = columnIndex; column.Visible = false; } else if (columnName.Equals ("image")) { types.Add (columnName, typeof (Gdk.Pixbuf)); order.Add (columnName); column.Title = Mono.Posix.Catalog.GetString ("Cover"); CellRendererPixbuf imageCellRenderer = new CellRendererPixbuf (); column.PackStart (imageCellRenderer, false); column.SetCellDataFunc (imageCellRenderer, new TreeCellDataFunc (ImageCellDataFunc)); this.InsertColumn (column, columnIndex); imageColumnPosition = columnIndex; column.Visible = (bool)this.columnsToShow["image"]; } else { types.Add (columnName, typeof(string)); order.Add (columnName); column.Resizable = true; column.Title = columnName; RenderInfo renderInfo = new RenderInfo (this, columnIndex); CellRendererText genericCellRenderer = new CellRendererText(); column.PackStart (genericCellRenderer, false); column.SetCellDataFunc (genericCellRenderer, new TreeCellDataFunc (renderInfo.GenericCellDataFunc)); column.SortColumnId = columnIndex; this.InsertColumn (column, columnIndex); column.Visible = (bool)this.columnsToShow[columnName]; } columnIndex++; } Type[] typeArray = new Type[types.Count]; for (int i=0; i<order.Count; i++) { typeArray[i] = (Type)types[order[i]]; } this.Model = new ListStore (typeArray); this.Selection.Mode = SelectionMode.Multiple; this.Selection.Changed += OnSelectionChanged; this.ButtonReleaseEvent += OnButtonReleased; this.RowActivated += OnRowActivated; this.EnableSearch = true; this.HeadersVisible = true; this.RulesHint = true; this.Visible = true; LoadAll(); } }