// c'tor public TextLineEditor(AABB2D location, string original, string iconName = null) { TextLineEditor.Instance = this; shared = new Shared(this); shared.location = location; // Set the hit box for the text area. shared.textAreaHitBox.Set(shared.location); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(shared); shared.blob = new TextBlob(renderObj.Font, (null != original) ? original : "", shared.textWidth); shared.blob.Justification = UIGridElement.Justification.Left; shared.blob.End(); shared.topLine = 0; shared.textOffset = 0; shared.iconName = iconName; // We use the updateObj for this deserialization since the text callbacks // belong to it. Otherwise nothing will ever hook up right. //commandMap = CommandMap.Deserialize(updateObj, @"TextEditor.Xml"); } // end of TextEditor c'tor
/// <summary> /// Render this distortion pulse to the current offscreen /// Assumes the proper InGame.inGame.renderEffects is setup /// </summary> /// <param name="camera"></param> /// <param name="effectsImage"></param> public void RenderSM3(Camera camera, Texture2D effectsImage) { if (effect != null) { Matrix preWorld = Matrix.CreateScale(scale); Parameter(EffectParams.DepthTexture).SetValue(effectsImage); Parameter(EffectParams.PreWorld).SetValue(preWorld); Parameter(EffectParams.Opacity).SetValue(scales * opacity); if (bump != null) { SetupBump(camera); } if (Bloom) { Parameter(EffectParams.BloomColor).SetValue(bumpTint); } RenderObj.Render(camera); Parameter(EffectParams.PreWorld).SetValue(Matrix.Identity); } }
public GateBot() : base() { this.classification = new Classification("gatebot", Classification.Colors.White, Classification.Shapes.Ball, Classification.Tastes.None, Classification.Smells.None, Classification.Physicalities.Collectable); this.classification.audioImpression = Classification.AudioImpression.Noisy; this.classification.audioVolume = Classification.AudioVolume.Soft; this.classification.emitter = ExpressModifier.Emitters.None; this.classification.expression = Face.FaceState.None; StaticPropChassis staticChassis = new StaticPropChassis(); Chassis = staticChassis; staticChassis.Mass = 500.0f; staticChassis.DefaultEditHeight = 0.0f; renderObj = new RenderObj(this, GateBotSRO.GetInstance); InitGameActorParams(); BokuGame.Load(this); // Set holding position after loading model so that BoundingSphere is initialized. this.holdingPosition = new Vector3(0.6f, 0.0f, 0.6f); } // end of GateBot c'tor
// c'tor public TitleScreen() { shared = new Shared(); renderObj = new RenderObj(ref shared); updateObj = new UpdateObj(ref shared); } // end of TitleScreen c'tor
public Cursor3D(Vector2 position, Vector4 color) : base("cursor", new CursorChassis()) { Position = new Vector3(position.X, position.Y, 0.0f); renderObj = new RenderObj(this, color); } // end of Cursor3D c'tor
/// <summary> /// Generate a filler arc of a circle fan, with center at pC, /// and the arc going from p0 to p1, counterclockwise. /// </summary> /// <param name="p0"></param> /// <param name="p1"></param> /// <param name="pC"></param> protected void MakeFan(WayPoint.Node node, Section first, Section second) { RenderObj ro = Road.Generator.NewFan(node, first, second); if (ro != null) { fans.Add(ro); } }
// c'tor public AddItemHelpCard() { AddItemHelpCard.Instance = this; shared = new Shared(this); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(shared); } // end of AddItemHelpCard c'tor
// c'tor public VideoOutput() { VideoOutput.Instance = this; shared = new Shared(this); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(this, shared); } // end of VideoOutput c'tor
// c'tor public HelpScreens() { HelpScreens.Instance = this; shared = new Shared(this); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(shared); } // end of HelpScreens c'tor
private void RasterizeByY(RenderObj obj, List <PixelInfo> sidePoints) { var yList = sidePoints.OrderBy(x => x.Y).ToList(); foreach (var pixel in yList) { int y = pixel.Y; var coordinates = sidePoints .Where(coord => coord.Y == y) .OrderBy(coord => coord.X) .DistinctBy(coord => coord.X) .ToList(); var startPoint = coordinates.First(); var endPoint = coordinates.Last(); int signZ = startPoint.Z < endPoint.Z ? 1 : -1; var delta = endPoint.X - startPoint.X; float z = startPoint.Z; float w = startPoint.W; Vector3 vn = startPoint.Vn; Vector3 vt = startPoint.Vt; if (delta == 0) { continue; } float deltaZ = Math.Abs((endPoint.Z - startPoint.Z) / delta); float deltaW = (endPoint.W - startPoint.W) / delta; Vector3 deltaVn = (endPoint.Vn - startPoint.Vn) / delta; Vector3 deltaVt = (endPoint.Vt - startPoint.Vt) / delta; for (int x = startPoint.X; x < endPoint.X; x++) { z += signZ * deltaZ; vn += deltaVn; vt += deltaVt; w += deltaW; if (UpdateZBuffer(x, y, z)) { if (lighting is PhongTexturizingLighting) { bmp[x, y] = lighting.GetTexturizedColorForPoint(obj, vn / w, vt / w); } else { bmp[x, y] = lighting.GetColorForPoint(vn / w); } } } } }
/// <summary> /// Render this section of road/wall /// </summary> /// <param name="camera"></param> public void Render(Camera camera) { if (RenderObj != null) { Frustum.CullResult cull = camera.Frustum.CullTest(Sphere); if (cull != Frustum.CullResult.TotallyOutside) { RenderObj.Render(camera, Road); } } }
// c'tor public OldLoadLevelMenu() { OldLoadLevelMenu.Instance = this; shared = new Shared(this); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(shared); Init(); } // end of LoadLevelMenu c'tor
public LightColumn(GraphicsDevice device, Vector2 position, Vector4 color) { shared = new Shared(); shared.Position = new Vector3(position.X, position.Y, 0.0f); // Z is set during update to match terrain. renderObj = new RenderObj(device, ref shared, color); updateObj = new UpdateObj(ref shared); } // end of LightColumn c'tor
public NotPieSelector(Object parent, string uiMode) : base() { this.parentSelector = parent as UiSelector; this.parent = parent; SelectWater = uiMode.Contains("waters"); SetWater = uiMode.Contains("setwater"); this.updateObj = new UpdateObj(this); this.renderObj = new RenderObj(this); }
// c'tor public MessageBox(String message, Color color) { MessageBox.Instance = this; shared = new Shared(this, message, color); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(shared); Init(); } // end of MessageBox c'tor
List <GameObject> childList = null; // List of children, must be of type GameObject // c'tor public UIShim(AddChildren addChildren, out UiSelector uiSelector, bool ignorePaths) { shared = new Shared(); renderObj = new RenderObj(ref shared); InGame.inGame.SetUIShim(renderObj); updateObj = new UpdateObj(ref shared); childList = new List <GameObject>(); this.ignorePaths = ignorePaths; addChildren(childList, out uiSelector, ignorePaths); } // end of UIShim c'tor
// c'tor public TitleScreenMode() { // Create the RenderObject and UpdateObject parts of this mode. shared = new Shared(); updateObj = new UpdateObj(this, ref shared); renderObj = new RenderObj(this, ref shared); logonDialog.OnButtonPressed += OnTextDialogButton; logonDialog.UserText = Auth.CreatorName; logonDialog.Prompt = Strings.Localize("textDialog.logonPrompt"); logonDialog.SetButtonText(TextDialog.TextDialogButtons.Accept, Strings.Localize("textDialog.continue")); Init(); } // end of TitleScreenMode c'tor
public void Execute(int i) { RenderObj obj = allObjects[i]; Vector3 position; //计算距离,进行分层 if (PlaneTest(ref obj.localToWorldMatrices, ref obj.extent, out position)) { float distance = Vector3.Distance(position, cameraPos); float layer = distance / cameraFarClipDistance; int layerValue = (int)Mathf.Clamp(Mathf.Lerp(0, SortMesh.LayerCount, layer), 0, SortMesh.LayerCount - 1); SortMesh.sortObj[layerValue].Add(distance, obj); } }
// c'tor public TextDialog(Color color, TextDialogButtons buttons) { this.buttons = buttons; // Create sub objects shared = new Shared(this); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(shared); // Set default button labels SetButtonText(TextDialogButtons.Accept, Strings.Localize("textDialog.accept")); SetButtonText(TextDialogButtons.Cancel, Strings.Localize("textDialog.cancel")); SetButtonText(TextDialogButtons.Discard, Strings.Localize("textDialog.discard")); } // end of TextDialog c'tor
/// <summary> /// Render this object's SM2 glow to the screen. /// </summary> /// <param name="camera"></param> public void RenderBloomSM2(Camera camera) { if (effect != null) { Matrix preWorld = Matrix.CreateScale(scale); Parameter(EffectParams.PreWorld).SetValue(preWorld); Parameter(EffectParams.Opacity).SetValue(scales * opacity); Parameter(EffectParams.BloomColor).SetValue(bumpTint); Debug.Assert(Bloom, "No other reason for rendering in SM2"); RenderObj.Render(camera); Parameter(EffectParams.PreWorld).SetValue(Matrix.Identity); } }
private Vector3 GetPhongTexturizedLightVector(RenderObj obj, Vector3 pointNormal, Vector3 texel) { var x = texel.X * obj.DiffuseTexture.PixelWidth; var y = (1 - texel.Y) * obj.DiffuseTexture.PixelHeight; if (x < 0 || y < 0 || x >= obj.DiffuseTexture.PixelWidth || y >= obj.DiffuseTexture.PixelHeight) { return(new Vector3(0)); } var normal = GetNormalTextureVector(obj.NormalTexture, x, y, obj.ModelMatrix) ?? pointNormal; var resultVector = GetAmbientTextureVector(obj.DiffuseTexture, x, y) + GetDiffusedTextureVector(obj.DiffuseTexture, x, y, normal) + GetSpecularTextureVector(obj.SpecularTexture, x, y, normal); return(resultVector.ToByteVector3()); }
private void Rasterize(RenderObj obj, List <PixelInfo> sidePoints) { var yCoordsCount = sidePoints.Select(x => x.Y).Distinct().Count(); if (yCoordsCount < 2) { // Swap x and y for the case when all pixels have the same Y // in order for interpolation to work foreach (var pixel in sidePoints) { var temp = pixel.X; pixel.X = pixel.Y; pixel.Y = temp; } } RasterizeByY(obj, sidePoints); }
private void LoadFile(string fileName) { var objPath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\", "examples", $"{fileName}.{FileExtensions.Object}")); var normalsPath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\", "examples", $"{fileName}_{FileExtensions.Normal}.{FileExtensions.ImgType}")); var diffuseTexturePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\", "examples", $"{fileName}_{FileExtensions.Diffuse}.{FileExtensions.ImgType}")); var specularTexturePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\", "examples", $"{fileName}_{FileExtensions.Specular}.{FileExtensions.ImgType}")); var parser = new ObjParser(); parser.LoadObj(objPath); camera.Position = new Vector3(vm.XCameraPos, vm.YCameraPos, vm.ZCameraPos); camera.Target = Vector3.Zero; mesh = new RenderObj(parser.VertexList.Count, parser.FaceList.Count, parser.NormalList.Count, parser.TextureList.Count); mesh.NormalTexture = parser.LoadTexture(normalsPath); mesh.DiffuseTexture = parser.LoadTexture(diffuseTexturePath); mesh.SpecularTexture = parser.LoadTexture(specularTexturePath); mesh.Position = new Vector3(vm.XObjectPos, vm.YObjectPos, vm.ZObjectPos); for (var i = 0; i < parser.VertexList.Count; i++) { mesh.Vertices[i] = parser.VertexList[i].ToVector4(); } mesh.Faces = parser.FaceList.ToArray(); for (var i = 0; i < parser.NormalList.Count; i++) { mesh.Normals[i] = parser.NormalList[i].ToVector(); } for (var i = 0; i < parser.TextureList.Count; i++) { mesh.TextureCoordinates[i] = parser.TextureList[i].ToVector(); } UpdateAnimation(); }
// // HoverCar // public HoverCar() : base() { this.classification = new Classification("fish", Classification.Colors.White, Classification.Shapes.Tube, Classification.Tastes.Salty, Classification.Smells.Pleasant, Classification.Physicalities.Collectable); this.classification.audioImpression = Classification.AudioImpression.Noisy; this.classification.audioVolume = Classification.AudioVolume.Loud; this.classification.emitter = ExpressModifier.Emitters.None; this.classification.expression = Face.FaceState.None; InitGameActorParams(); renderObj = new RenderObj(this, HoverCarSRO.GetInstance); BokuGame.Load(this); // Set holding position after loading model so that BoundingSphere is initialized. this.holdingPosition = new Vector3(1.5f, 0.0f, -0.1f); }
public ShareHub() { ShareHub.Instance = this; shared = new Shared(this); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(this, shared); openingSharingRoomMessage = new ModularMessageDialog( Strings.Localize("shareHub.messageOpeningSharingRoom"), null, null, null, null, null, null, null, null); openingInviteGuideMessage = new ModularMessageDialog( Strings.Localize("shareHub.messageOpeningInviteGuide"), null, null, null, null, null, null, null, null); } // end of MainMenu c'tor
// c'tor public MiniHub() { MiniHub.Instance = this; shared = new Shared(this); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(this, shared); saveLevelDialog.OnButtonPressed += OnSaveLevelDialogButton; // // Set up SaveChangesDialogs // { ModularMessageDialog.ButtonHandler handlerA = delegate(ModularMessageDialog dialog) { // User chose "save" // Deactivate dialog. dialog.Deactivate(); // Activate saveLevelDialog. saveLevelDialog.Activate(); }; ModularMessageDialog.ButtonHandler handlerB = delegate(ModularMessageDialog dialog) { // User chose "back" // Deactivate dialog. dialog.Deactivate(); // Clear the flag since the user backed out. This way if they // try again the save changes message will be displayed again. saveChangesActivated = false; // Reactivate the mini-hub grid. shared.menu.Active = true; }; ModularMessageDialog.ButtonHandler handlerX = delegate(ModularMessageDialog dialog) { // User chose "discard" // Deactivate self and go wherever we were going... dialog.Deactivate(); // Deactivate mini-hub. //Deactivate(); // We gave the user the opportunity to save changes and he chose // not to so call OnSelect() once more to get them on their way. if (saveChangesActivated) { OnSelect(shared.menu); saveChangesActivated = false; } }; saveChangesMessage = new ModularMessageDialog( Strings.Localize("textDialog.saveChangesPrompt"), handlerA, Strings.Localize("textDialog.save"), handlerB, Strings.Localize("textDialog.back"), null, null, null, null ); saveChangesWithDiscardMessage = new ModularMessageDialog( Strings.Localize("textDialog.saveChangesPrompt"), handlerA, Strings.Localize("textDialog.save"), handlerB, Strings.Localize("textDialog.back"), handlerX, Strings.Localize("textDialog.discard"), null, null ); } // // Set up ShareSuccessDialog // { ModularMessageDialog.ButtonHandler handlerB = delegate(ModularMessageDialog dialog) { // User chose "back" // Deactivate dialog. dialog.Deactivate(); // Make sure grid is still active. shared.menu.Active = true; }; shareSuccessMessage = new ModularMessageDialog( Strings.Localize("miniHub.shareSuccessMessage"), null, null, handlerB, Strings.Localize("textDialog.back"), null, null, null, null ); } // // Set up NoCommunityDialog // { ModularMessageDialog.ButtonHandler handlerB = delegate(ModularMessageDialog dialog) { // User chose "back" // Deactivate dialog. dialog.Deactivate(); // Make sure grid is still active. shared.menu.Active = true; }; noCommunityMessage = new ModularMessageDialog( Strings.Localize("miniHub.noCommunityMessage"), null, null, handlerB, Strings.Localize("textDialog.back"), null, null, null, null ); } // // Set up NewWorld dialog. // NewWorldDialog.OnAction OnSelectWorld = delegate(string level) { // Deactivate main menu and go into editor with empty level. string levelFilename = Path.Combine(BokuGame.Settings.MediaPath, BokuGame.BuiltInWorldsPath, level + ".Xml"); if (BokuGame.bokuGame.inGame.LoadLevelAndRun(levelFilename, keepPersistentScores: false, newWorld: true, andRun: false)) { Deactivate(); InGame.inGame.Activate(); InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.ToolMenu; } else { shared.menu.Active = true; } }; NewWorldDialog.OnAction OnCancel = delegate(string level) { shared.menu.Active = true; }; newWorldDialog = new NewWorldDialog(OnSelectWorld, OnCancel); } // end of MiniHub c'tor
// c'tor public MainMenu() { MainMenu.Instance = this; shared = new Shared(this); // Create the RenderObject and UpdateObject parts of this mode. updateObj = new UpdateObj(this, shared); renderObj = new RenderObj(this, shared); NewWorldDialog.OnAction OnSelectWorld = delegate(string level) { // Deactivate main menu and go into editor with empty level. string levelFilename = Path.Combine(BokuGame.Settings.MediaPath, BokuGame.BuiltInWorldsPath, level + ".Xml"); if (BokuGame.bokuGame.inGame.LoadLevelAndRun(levelFilename, keepPersistentScores: false, newWorld: true, andRun: false)) { Deactivate(); InGame.inGame.Activate(); InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.ToolMenu; } else { shared.menu.Active = true; } }; NewWorldDialog.OnAction OnCancel = delegate(string level) { shared.menu.Active = true; }; newWorldDialog = new NewWorldDialog(OnSelectWorld, OnCancel); // Set up the NoCommunity, NoSharing and PrevCrash dialogs. ModularMessageDialog.ButtonHandler handlerA = delegate(ModularMessageDialog dialog) { // User chose "resume" // Deactivate dialog. dialog.Deactivate(); if (InGame.CurrentWorldId == Guid.Empty) { if (InGame.UnDoStack.Resume()) { // Deactivate MainMenu. Deactivate(); } else { //Debug.Assert(false, "Resume should not be enabled unless there is something to resume from"); // We had some error in trying to resume. So, remove the resume // option from the menu and soldier on. shared.menu.DeleteText(Strings.Localize("mainMenu.resume")); shared.menu.Active = true; XmlOptionsData.LastAutoSave = -1; } } else { // Deactivate MainMenu. Deactivate(); // Just reactivate the existing game. BokuGame.bokuGame.inGame.Activate(); } }; ModularMessageDialog.ButtonHandler handlerB = delegate(ModularMessageDialog dialog) { // User chose "back" // Deactivate dialog. dialog.Deactivate(); // Only needed for corruptStorageMessage but shouldn't hurt for all. }; ModularMessageDialog.ButtonHandler handlerX = delegate(ModularMessageDialog dialog) { // User chose to quit Kodu // Deactivate dialog. dialog.Deactivate(); // Wave bye, bye. #if NETFX_CORE Windows.UI.Xaml.Application.Current.Exit(); #else BokuGame.bokuGame.Exit(); #endif exitingKodu = true; }; noCommunityMessage = new ModularMessageDialog(Strings.Localize("miniHub.noCommunityMessage"), null, null, handlerB, Strings.Localize("textDialog.back"), null, null, null, null ); noSharingMessage = new ModularMessageDialog(Strings.Localize("miniHub.noSharingMessage"), null, null, handlerB, Strings.Localize("textDialog.back"), null, null, null, null ); prevSessionCrashedMessage = new ModularMessageDialog(Strings.Localize("mainMenu.prevSessionCrashedMessage"), handlerA, Strings.Localize("textDialog.resume"), handlerB, Strings.Localize("textDialog.back"), null, null, null, null ); } // end of MainMenu c'tor
public override BmpColor GetTexturizedColorForPoint(RenderObj obj, Vector3 normal, Vector3 texel) { return(GetPhongTexturizedLightVector(obj, normal, texel).ToColor()); }
// Bresenham's algorithm public List <PixelInfo> GetSides(RenderObj obj, PixelInfo point0, PixelInfo point1) { int x0 = point0.X; int y0 = point0.Y; float z0 = point0.Z; int x1 = point1.X; int y1 = point1.Y; float z1 = point1.Z; float w0 = 1 / point0.W; float w1 = 1 / point1.W; Vector3 vn0 = point0.Vn * w0; Vector3 vn1 = point1.Vn * w1; Vector3 vt0 = point0.Vt * w0; Vector3 vt1 = point1.Vt * w1; int deltaX = Math.Abs(x1 - x0); int deltaY = Math.Abs(y1 - y0); int error = deltaX - deltaY; var sidePoints = new List <PixelInfo>(); sidePoints.Add(new PixelInfo(x1, y1, z1, w1, vn1, vt1)); if (UpdateZBuffer(x1, y1, z1)) { if (lighting is PhongTexturizingLighting) { bmp[x1, y1] = lighting.GetTexturizedColorForPoint(obj, vn1 / w1, vt1 / w1); } else { bmp[x1, y1] = lighting.GetColorForPoint(vn1 / w1); } } // In this case there is no point in further actions if (deltaX == 0 && deltaY == 0) { return(sidePoints); } int delta = (deltaY == 0) ? deltaX : deltaY; float deltaZ = Math.Abs(z1 - z0) / delta; float deltaW = (w1 - w0) / delta; Vector3 deltaVn = (vn1 - vn0) / delta; Vector3 deltaVt = (vt1 - vt0) / delta; int signX = x0 < x1 ? 1 : -1; int signY = y0 < y1 ? 1 : -1; float signZ = z0 < z1 ? 1 : -1; while (x0 != x1 || y0 != y1) { sidePoints.Add(new PixelInfo(x0, y0, z0, w0, vn0, vt0)); int error2 = error * 2; if (error2 > -deltaY) { error -= deltaY; x0 += signX; } if (error2 < deltaX) { if (UpdateZBuffer(x0, y0, z0)) { if (lighting is PhongTexturizingLighting) { bmp[x0, y0] = lighting.GetTexturizedColorForPoint(obj, vn0 / w0, vt0 / w0); } else { bmp[x0, y0] = lighting.GetColorForPoint(vn0 / w0); } } error += deltaX; y0 += signY; z0 += signZ * deltaZ; w0 += deltaW; vn0 += deltaVn; vt0 += deltaVt; } } return(sidePoints); }
public virtual BmpColor GetTexturizedColorForPoint(RenderObj obj, Vector3 normal, Vector3 texel) { throw new NotImplementedException(); }