} // end of UIGridModularMenu RefreshTexture() public void Render(Camera camera) { try { ShaderGlobals.SetValues(effect); ShaderGlobals.SetCamera(effect, camera); effect.CurrentTechnique = effect.Techniques["NormalMappedWithEnv"]; effect.Parameters["DiffuseTexture"].SetValue(diffuse); effect.Parameters["WorldMatrix"].SetValue(worldMatrix); effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix); effect.Parameters["Alpha"].SetValue(1.0f); effect.Parameters["DiffuseColor"].SetValue(new Vector4(1, 1, 1, 1)); effect.Parameters["SpecularColor"].SetValue(specularColor); effect.Parameters["SpecularPower"].SetValue(specularPower); effect.Parameters["NormalMap"].SetValue(normalMap); geometry.Render(effect); } catch { // This Try/Catch is here since the first frame back from a device reset // the call to diffuse fails saying that the rendertarget is // still set on the device. As far as I can tell it's not but I still // can't win the argument. } } // end of UIGridModularMenu Render()
} // end of c'tor public override void Render(Camera camera) { if (active || renderWhenInactive) { // Update the size if needed. float w = width; for (int i = 0; i < ActualDimensions.Y; i++) { UIGrid2DFloatingTextElement e = (UIGrid2DFloatingTextElement)grid[0, i]; w = Math.Max(w, e.WidthOfLabelInPixels); } w /= 96.0f; // pixels to inches. w += 2.0f * edgeSize; if (w > width) { width = w; BokuGame.Unload(geometry); geometry = new Base9Grid(width, height, edgeSize); BokuGame.Load(geometry); } UpdateSelectionFocus(); effect.CurrentTechnique = effect.Techniques["TexturedRegularAlpha"]; effect.Parameters["DiffuseTexture"].SetValue(backgroundTexture); // Calc position from lowerLeftCorner. Vector3 trans = new Vector3(lowerLeftCorner.X + (width - edgeSize) / 2.0f, lowerLeftCorner.Y + (height - edgeSize) / 2.0f, 0.0f); worldMatrix.Translation = trans; effect.Parameters["WorldMatrix"].SetValue(worldMatrix); effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix); effect.Parameters["Alpha"].SetValue(1.0f); effect.Parameters["DiffuseColor"].SetValue(Vector4.One); geometry.Render(effect); // // Render the menu elements. // Vector3 pos = worldMatrix.Translation + new Vector3(-(width / 2.0f - edgeSize), height / 2.0f - edgeSize, 0.0f); Point pixelCoord = camera.WorldToScreenCoords(pos); Vector2 position = new Vector2(pixelCoord.X, pixelCoord.Y); batch.Begin(); for (int i = 0; i < ActualDimensions.Y; i++) { UIGrid2DFloatingTextElement e = (UIGrid2DFloatingTextElement)grid[0, i]; e.RenderAt(batch, position); position.Y += lineHeight; } batch.End(); } //base.Render(camera); }
} // end of HandleTouchInput() public override void Render(Camera camera) { effect.CurrentTechnique = effect.Techniques["NormalMappedWithEnv"]; effect.Parameters["DiffuseTexture"].SetValue(diffuse); effect.Parameters["WorldMatrix"].SetValue(worldMatrix); effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix); effect.Parameters["Alpha"].SetValue(Alpha); effect.Parameters["DiffuseColor"].SetValue(new Vector4(1.0f, 1.0f, 1.0f, 1.0f)); effect.Parameters["SpecularColor"].SetValue(specularColor); effect.Parameters["SpecularPower"].SetValue(specularPower); effect.Parameters["NormalMap"].SetValue(normalMap); // Render the base tile. geometry.Render(effect); // Add the LEDs. CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance(); Vector2 size = new Vector2(0.2f, 0.2f); Vector2 innerFocusSize = new Vector2(0.24f, 0.24f); Vector2 outerFocusSize = new Vector2(0.28f, 0.28f); Vector2 margin = new Vector2(0.125f, 0.125f); // Postion of first LED. Vector2 basePosition = new Vector2(Position.X, Position.Y); basePosition.X = basePosition.X - 2.0f * size.X - 2.0f * margin.X; basePosition.Y = basePosition.Y + 2.0f * size.Y + 2.0f * margin.Y; for (int i = 0; i < 25; i++) { Vector2 pos = basePosition; pos.X += (i % 5) * (size.X + margin.X); pos.Y -= (int)(i / 5) * (size.Y + margin.Y); Vector4 color = leds[i] ? new Vector4(1, 0, 0, 1) : new Vector4(0, 0, 0, 1); if (i == focusIndex) { // Highlight around in-focus LED. csquad.Render(camera, white, new Vector4(1, 0, 0, 1), 1.0f, pos, outerFocusSize, "TexturedRegularAlpha"); csquad.Render(camera, white, new Vector4(1, 1, 1, 1), 1.0f, pos, innerFocusSize, "TexturedRegularAlpha"); } csquad.Render(camera, white, color, 1.0f, pos, size, "TexturedRegularAlpha"); // Also set hit box in camera space. ledHitBoxes[i].Set(pos - size, pos + size); } } // end of UIGrid2DLEDArray Render()
public override void Render(Camera camera) { effect.CurrentTechnique = effect.Techniques["NormalMappedWithEnv"]; effect.Parameters["DiffuseTexture"].SetValue(diffuse); effect.Parameters["WorldMatrix"].SetValue(worldMatrix); effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix); effect.Parameters["Alpha"].SetValue(Alpha); effect.Parameters["DiffuseColor"].SetValue(new Vector4(dim, dim, dim, 1.0f)); effect.Parameters["SpecularColor"].SetValue(specularColor); effect.Parameters["SpecularPower"].SetValue(specularPower); effect.Parameters["NormalMap"].SetValue(normalMap); geometry.Render(effect); } // end of UIGridModularRadioBoxElement Render()
} // end of HandleTouchInput() public override void Render(Camera camera) { if (diffuse == null) { effect.CurrentTechnique = effect.Techniques["NormalMappedNoTexture"]; } else { effect.CurrentTechnique = effect.Techniques["NormalMapped"]; effect.Parameters["DiffuseTexture"].SetValue(diffuse); } effect.Parameters["WorldMatrix"].SetValue(worldMatrix); effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix); effect.Parameters["Alpha"].SetValue(baseColor.W); effect.Parameters["DiffuseColor"].SetValue(baseColor); effect.Parameters["SpecularColor"].SetValue(specularColor); effect.Parameters["SpecularPower"].SetValue(specularPower); effect.Parameters["NormalMap"].SetValue(normalMap); geometry.Render(effect); } // end of UIGrid2DTextElement Render()
} // end of HandleTouchInput() public override void Render(Camera camera) { if (altShader) { effect.CurrentTechnique = effect.Techniques["AltNormalMapped"]; effect.Parameters["DiffuseTexture"].SetValue(diffuse); } else if (altPreMultAlphaShader) { effect.CurrentTechnique = effect.Techniques["AltNormalMappedPreMultAlpha"]; effect.Parameters["DiffuseTexture"].SetValue(diffuse); } else if (greyFlatShader) { effect.CurrentTechnique = effect.Techniques["GreyFlat"]; effect.Parameters["DiffuseTexture"].SetValue(diffuse); effect.Parameters["Grey"].SetValue(grey); } else { if (diffuse == null) { if (noZ) { effect.CurrentTechnique = effect.Techniques["NormalMappedNoTextureNoZ"]; } else { effect.CurrentTechnique = effect.Techniques["NormalMappedNoTexture"]; } } else { if (noZ) { if (overlayTexture == null) { effect.CurrentTechnique = effect.Techniques["NormalMappedNoZ"]; } else { effect.CurrentTechnique = effect.Techniques["NormalMappedNoZWithOverlay"]; effect.Parameters["OverlayTexture"].SetValue(overlayTexture); } } else { if (overlayTexture == null) { effect.CurrentTechnique = effect.Techniques["NormalMapped"]; } else { effect.CurrentTechnique = effect.Techniques["NormalMappedWithOverlay"]; effect.Parameters["OverlayTexture"].SetValue(overlayTexture); } } effect.Parameters["DiffuseTexture"].SetValue(diffuse); } } effect.Parameters["WorldMatrix"].SetValue(worldMatrix); effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix); effect.Parameters["Alpha"].SetValue(Alpha); effect.Parameters["DiffuseColor"].SetValue(baseColor); effect.Parameters["SpecularColor"].SetValue(specularColor); effect.Parameters["SpecularPower"].SetValue(specularPower); effect.Parameters["NormalMap"].SetValue(normalMap); geometry.Render(effect); } // end of UIGrid2DTextureElement Render()
} // end of ApplyExclusiveFiltering() public void Render(Camera camera) { if (Active && geometry != null) { // Black background. effect.CurrentTechnique = effect.Techniques["NormalMappedNoTexture"]; effect.Parameters["WorldMatrix"].SetValue(worldMatrix); effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix); effect.Parameters["Alpha"].SetValue(1.0f); effect.Parameters["DiffuseColor"].SetValue(new Vector4(0, 0, 0, 1)); effect.Parameters["SpecularColor"].SetValue(new Vector4(0.2f, 0.2f, 0.2f, 1.0f)); effect.Parameters["SpecularPower"].SetValue(32.0f); effect.Parameters["NormalMap"].SetValue(normalMap); geometry.Render(effect); ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector3 upperLeftCorner = worldMatrix.Translation; upperLeftCorner.X -= geometry.Width / 2.0f; upperLeftCorner.Y += geometry.Height / 2.0f; upperLeftCorner.X += tileBorder; upperLeftCorner.Y -= tileBorder / 2.0f; Point loc = camera.WorldToScreenCoords(upperLeftCorner); Vector2 pos = new Vector2(loc.X, loc.Y); loc = camera.WorldToScreenCoords(2.0f * worldMatrix.Translation - upperLeftCorner); Vector2 size = new Vector2(loc.X, loc.Y) - pos; int lineSpacing = Font().LineSpacing; // Render highlight. quad.Render(whiteHighlight, new Vector4(1.0f, 1.0f, 1.0f, 0.3f), pos + new Vector2(-4, 0), new Vector2(w + 6, w / 2.0f), "TexturedRegularAlpha"); // Render the green bar(). for (int i = 0; i < itemList.Count; i++) { if (itemList[i].BarAlpha > 0.0) { quad.Render(greenBar, new Vector4(1.0f, 1.0f, 1.0f, itemList[i].BarAlpha), pos + new Vector2(0, 2 + i * lineSpacing), new Vector2(w, lineSpacing), "TexturedRegularAlpha"); } } // Render the text. SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); for (int i = 0; i < itemList.Count; i++) { Vector2 position = pos + new Vector2(margin + checkboxSize + gap, i * lineSpacing); TextHelper.DrawString(Font, itemList[i].Text, position, itemList[i].TextColor); // Calc bounds in UV space. Vector2 min = new Vector2(0, i * lineSpacing); Vector2 max = min + new Vector2(w, lineSpacing); min /= size; max /= size; itemList[i].UVBoundingBox.Set(min, max); } batch.End(); // Render the checkboxes. for (int i = 0; i < itemList.Count; i++) { float a = itemList[i].LitValue; // If not fully lit. if (a < 1.0f) { quad.Render(AllExclusive ? radioButtonUnlit : checkboxUnlit, pos + new Vector2(margin, 6 + i * lineSpacing), new Vector2(checkboxSize), "TexturedRegularAlpha"); } // If lit at all. if (a > 0.0f) { quad.Render(AllExclusive ? radioButtonLit : checkboxLit, new Vector4(1, 1, 1, a), pos + new Vector2(margin, 6 + i * lineSpacing), new Vector2(checkboxSize), "TexturedRegularAlpha"); } } if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad) { // Render help. string str = "<a> " + Strings.Localize("saveLevelDialog.change") + "\n<b> " + Strings.Localize("saveLevelDialog.back"); TextBlob blob = new TextBlob(UI2D.Shared.GetGameFont24, str, 400); pos += size; pos.X += 16; pos.Y -= 2.0f * blob.TotalSpacing; blob.RenderWithButtons(pos, Color.White); // Mouse hit boxes for help. changeBox.Set(pos, pos + new Vector2(blob.GetLineWidth(0), blob.TotalSpacing)); backBox.Set(pos + new Vector2(0, blob.TotalSpacing), pos + new Vector2(0, blob.TotalSpacing) + new Vector2(blob.GetLineWidth(1), blob.TotalSpacing)); } } // end if active } // end of ModularCheckboxList Render()