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, texture, FillMode.Solid, boxSphere); result.Add(outputInfo); if (item.Selected) { RenderInfo highlightInfo = new RenderInfo(mesh, 0, transform.Top, material, texture, FillMode.WireFrame, boxSphere); result.Add(highlightInfo); } transform.Pop(); return result; }
public override BoundingSphere GetBounds(SETItem item) { float scaleX = item.Scale.X; float scaleY = item.Scale.Y * 0.5f; float scaleZ = item.Scale.Z; if (scaleX >= 10.0f) { if (scaleX > 200.0f) { scaleX = 200f; } } else { scaleX = 10f; } if (scaleY >= 10.0f) { if (scaleY > 200.0f) { scaleY = 200f; } } else { scaleY = 10f; } if (scaleZ >= 10.0f) { if (scaleZ > 200.0f) { scaleZ = 200f; } } else { scaleZ = 10f; } float largestScale = scaleX; if (scaleY > largestScale) { largestScale = scaleY; } if (scaleZ > largestScale) { largestScale = scaleZ; } BoundingSphere boxSphere = new BoundingSphere() { Center = new Vertex(item.Position.X, item.Position.Y, item.Position.Z), Radius = largestScale }; return(boxSphere); }
public override BoundingSphere GetBounds(SETItem item) { BoundingSphere boxSphere = new BoundingSphere() { Center = new Vertex((item.Position.X), (item.Position.Y), item.Position.Z), Radius = 10f }; return(boxSphere); }
public override BoundingSphere GetBounds(SETItem item, NJS_OBJECT model) { float largestScale = (item.Scale.X + 10) / 5f; if (item.Scale.Y > largestScale) largestScale = (item.Scale.Y + 10) / 5f; if (item.Scale.Z > largestScale) largestScale = (item.Scale.Z + 10) / 5f; BoundingSphere boxSphere = new BoundingSphere() { Center = new Vertex(item.Position.X, item.Position.Y, item.Position.Z), Radius = largestScale }; return boxSphere; }
public BasicAttach() { Name = "attach_" + Extensions.GenerateIdentifier(); Bounds = new BoundingSphere(); Material = new List<NJS_MATERIAL>(); MaterialName = "matlist_" + Extensions.GenerateIdentifier(); Mesh = new List<NJS_MESHSET>(); MeshName = "meshlist_" + Extensions.GenerateIdentifier(); Vertex = new Vertex[0]; VertexName = "vertex_" + Extensions.GenerateIdentifier(); Normal = new Vertex[0]; NormalName = "normal_" + Extensions.GenerateIdentifier(); }
public override BoundingSphere GetBounds(SETItem item) { MatrixStack transform = new MatrixStack(); float middle = (item.Position.Y + (item.Scale.Y / 2)); float radius = (((Math.Abs(item.Scale.Y)) / 2) + 50.0f); BoundingSphere boxSphere = new BoundingSphere() { Center = new Vertex((item.Position.X), (middle), item.Position.Z), Radius = radius }; return(boxSphere); }
public override BoundingSphere GetBounds(SETItem item) { MatrixStack transform = new MatrixStack(); BoundingSphere result = new BoundingSphere(); for (int i = 0; i < Math.Min(item.Scale.X + 1, 8); i++) { transform.Push(); if (item.Scale.Z == 1) // circle { double v4 = i * 360.0; Vector3 v7 = new Vector3( ObjectHelper.NJSin((int)(v4 / item.Scale.X * 65536.0 * 0.002777777777777778)) * item.Scale.Y, 0, ObjectHelper.NJCos((int)(v4 / item.Scale.X * 65536.0 * 0.002777777777777778)) * item.Scale.Y); transform.Push(); transform.NJTranslate(item.Position); transform.NJRotateObject(item.Rotation); Vector3 pos = Vector3.TransformCoordinate(v7, transform.Top); transform.Pop(); transform.NJTranslate(pos); } else // line { transform.Push(); transform.NJTranslate(item.Position); transform.NJRotateObject(item.Rotation); double v5; if (i % 2 == 1) { v5 = i * item.Scale.Y * -0.5; } else { v5 = Math.Ceiling(i * 0.5) * item.Scale.Y; } Vector3 pos = Vector3.TransformCoordinate(new Vector3(0, 0, (float)v5), transform.Top); transform.Pop(); transform.NJTranslate(pos); } result = SonicRetro.SAModel.Direct3D.Extensions.Merge(result, ObjectHelper.GetModelBounds(model, transform)); transform.Pop(); } return(result); }
public override BoundingSphere GetBounds(SETItem item) { MatrixStack transform = new MatrixStack(); float middle = (item.Position.Y + (item.Scale.X / 2)); float radius = (((Math.Abs(item.Scale.X)) / 2) + 50.0f); BoundingSphere boxSphere = new BoundingSphere() { Center = new Vertex((item.Position.X), (middle), item.Position.Z), Radius = radius }; return(boxSphere); //transform.NJTranslate(item.Position); //transform.NJRotateY(item.Rotation.Y); //return ObjectHelper.GetModelBounds(Wele1, transform); }
public override List <RenderInfo> Render(SETItem item, Device dev, EditorCamera camera, MatrixStack transform) { if (texture == null) { texture = new Texture(dev, 2, 2, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); } 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, texture, FillMode.Solid, boxSphere); result.Add(outputInfo); if (item.Selected) { RenderInfo highlightInfo = new RenderInfo(mesh, 0, transform.Top, material, texture, FillMode.Wireframe, boxSphere); result.Add(highlightInfo); } transform.Pop(); return(result); }
public override BoundingSphere GetBounds(SETItem item) { 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) }; return(boxSphere); }
public COL(byte[] file, int address, uint imageBase, LandTableFormat format, Dictionary<int, string> labels, bool? forceBasic) { Bounds = new BoundingSphere(file, address); ModelFormat mfmt = 0; switch (format) { case LandTableFormat.SA1: mfmt = ModelFormat.Basic; break; case LandTableFormat.SADX: mfmt = ModelFormat.BasicDX; break; case LandTableFormat.SA2: if (forceBasic.HasValue && forceBasic.Value) mfmt = ModelFormat.Basic; else mfmt = ModelFormat.Chunk; break; } switch (format) { case LandTableFormat.SA1: case LandTableFormat.SADX: Unknown1 = ByteConverter.ToInt32(file, address + 0x10); Unknown2 = ByteConverter.ToInt32(file, address + 0x14); uint tmpaddr = ByteConverter.ToUInt32(file, address + 0x18) - imageBase; Model = new NJS_OBJECT(file, (int)tmpaddr, imageBase, mfmt, labels); Unknown3 = ByteConverter.ToInt32(file, address + 0x1C); Flags = ByteConverter.ToInt32(file, address + 0x20); break; case LandTableFormat.SA2: Flags = ByteConverter.ToInt32(file, address + 0x1C); if (!forceBasic.HasValue) mfmt = Flags < 0 ? ModelFormat.Chunk : ModelFormat.Basic; tmpaddr = ByteConverter.ToUInt32(file, address + 0x10) - imageBase; Model = new NJS_OBJECT(file, (int)tmpaddr, imageBase, mfmt, labels); Unknown2 = ByteConverter.ToInt32(file, address + 0x14); Unknown3 = ByteConverter.ToInt32(file, address + 0x18); break; } }
public override BoundingSphere GetBounds(SETItem item) { MatrixStack transform = new MatrixStack(); BoundingSphere result = new BoundingSphere(); int rows = (int)Math.Max(item.Scale.X, 1); int cols = (int)Math.Max(item.Scale.Z, 1); transform.NJTranslate(item.Position); transform.NJRotateObject(item.Rotation.X & 0xC000, item.Rotation.Y, 0); transform.NJTranslate((1 - rows) * 7.5f, 0, (1 - cols) * 7.5f); for (int i = 0; i < rows; ++i) { transform.Push(); for (int j = 0; j < cols; ++j) { result = SonicRetro.SAModel.Direct3D.Extensions.Merge(result, ObjectHelper.GetModelBounds(model, transform)); transform.NJTranslate(0, 0, 15); } transform.Pop(); transform.NJTranslate(15, 0, 0); } return(result); }
private void ActionInputCollector_OnActionRelease(ActionInputCollector sender, string actionName) { if (!loaded) { return; } bool draw = false; // should the scene redraw after this action switch (actionName) { case ("Camera Mode"): eventcamera = !eventcamera; draw = true; break; case ("Zoom to target"): if (selectedObject != null) { BoundingSphere bounds = (selectedObject.Model?.Attach != null) ? selectedObject.Model.Attach.Bounds : new BoundingSphere(selectedObject.Position.X, selectedObject.Position.Y, selectedObject.Position.Z, 10); bounds.Center += selectedObject.Position; cam.MoveToShowBounds(bounds); } draw = true; break; case ("Change Render Mode"): if (EditorOptions.RenderFillMode == FillMode.Solid) { EditorOptions.RenderFillMode = FillMode.Point; } else { EditorOptions.RenderFillMode += 1; } draw = true; break; case ("Increase camera move speed"): cam.MoveSpeed += 0.0625f; //UpdateTitlebar(); break; case ("Decrease camera move speed"): cam.MoveSpeed -= 0.0625f; //UpdateTitlebar(); break; case ("Reset camera move speed"): cam.MoveSpeed = EditorCamera.DefaultMoveSpeed; //UpdateTitlebar(); break; case ("Reset Camera Position"): if (!eventcamera) { cam.Position = new Vector3(); draw = true; } break; case ("Reset Camera Rotation"): if (!eventcamera) { cam.Pitch = 0; cam.Yaw = 0; draw = true; } break; case ("Camera Move"): cameraKeyDown = false; break; case ("Camera Zoom"): zoomKeyDown = false; break; case ("Camera Look"): lookKeyDown = false; break; case ("Next Scene"): scenenum++; animframe = (timer1.Enabled ? 0 : -1); decframe = animframe; if (scenenum == @event.Scenes.Count) { if (timer1.Enabled) { scenenum = 1; } else { scenenum = 0; } } draw = true; break; case ("Previous Scene"): scenenum--; animframe = (timer1.Enabled ? 0 : -1); decframe = animframe; if (scenenum == -1 || (timer1.Enabled && scenenum == 0)) { scenenum = @event.Scenes.Count - 1; } draw = true; break; case ("Previous Frame"): if (scenenum > 0 && !timer1.Enabled) { animframe--; if (animframe < -1) { scenenum--; if (scenenum == 0) { scenenum = @event.Scenes.Count - 1; } animframe = @event.Scenes[scenenum].FrameCount - 1; } decframe = animframe; draw = true; } break; case ("Next Frame"): if (scenenum > 0 && !timer1.Enabled) { animframe++; if (animframe == @event.Scenes[scenenum].FrameCount) { scenenum++; if (scenenum == @event.Scenes.Count) { scenenum = 1; } animframe = -1; } decframe = animframe; draw = true; } break; case ("Play/Pause Animation"): if (!timer1.Enabled) { if (scenenum == 0) { scenenum = 1; } if (animframe == -1) { decframe = animframe = 0; } } timer1.Enabled = !timer1.Enabled; draw = true; break; default: break; } if (draw) { UpdateWeightedModels(); DrawEntireModel(); } }
public COL() { Bounds = new BoundingSphere(); }
public override BoundingSphere GetBounds(SETItem item, NJS_OBJECT model) { BoundingSphere bounds = new BoundingSphere(item.Position, item.Scale.X); return bounds; }
public BasicAttach(byte[] file, int address, uint imageBase, bool DX, Dictionary<int, string> labels) : this() { if (labels.ContainsKey(address)) Name = labels[address]; else Name = "attach_" + address.ToString("X8"); Vertex = new Vertex[ByteConverter.ToInt32(file, address + 8)]; Normal = new Vertex[Vertex.Length]; int tmpaddr = (int)(ByteConverter.ToUInt32(file, address) - imageBase); if (labels.ContainsKey(tmpaddr)) VertexName = labels[tmpaddr]; else VertexName = "vertex_" + tmpaddr.ToString("X8"); for (int i = 0; i < Vertex.Length; i++) { Vertex[i] = new Vertex(file, tmpaddr); tmpaddr += SAModel.Vertex.Size; } tmpaddr = ByteConverter.ToInt32(file, address + 4); if (tmpaddr != 0) { tmpaddr = (int)((uint)tmpaddr - imageBase); if (labels.ContainsKey(tmpaddr)) NormalName = labels[tmpaddr]; else NormalName = "normal_" + tmpaddr.ToString("X8"); for (int i = 0; i < Vertex.Length; i++) { Normal[i] = new Vertex(file, tmpaddr); tmpaddr += SAModel.Vertex.Size; } } else { for (int i = 0; i < Vertex.Length; i++) Normal[i] = new Vertex(0, 1, 0); } int meshcnt = ByteConverter.ToInt16(file, address + 0x14); tmpaddr = ByteConverter.ToInt32(file, address + 0xC); if (tmpaddr != 0) { tmpaddr = (int)unchecked((uint)tmpaddr - imageBase); if (labels.ContainsKey(tmpaddr)) MeshName = labels[tmpaddr]; else MeshName = "meshlist_" + tmpaddr.ToString("X8"); for (int i = 0; i < meshcnt; i++) { Mesh.Add(new NJS_MESHSET(file, tmpaddr, imageBase, labels)); tmpaddr += NJS_MESHSET.Size(DX); } } int matcnt = ByteConverter.ToInt16(file, address + 0x16); tmpaddr = ByteConverter.ToInt32(file, address + 0x10); if (tmpaddr != 0) { tmpaddr = (int)unchecked((uint)tmpaddr - imageBase); if (labels.ContainsKey(tmpaddr)) MaterialName = labels[tmpaddr]; else MaterialName = "matlist_" + tmpaddr.ToString("X8"); for (int i = 0; i < matcnt; i++) { Material.Add(new NJS_MATERIAL(file, tmpaddr, labels)); tmpaddr += NJS_MATERIAL.Size; } } Bounds = new BoundingSphere(file, address + 0x18); }
public ChunkAttach(byte[] file, int address, uint imageBase, Dictionary<int, string> labels) : this() { if (labels.ContainsKey(address)) Name = labels[address]; else Name = "attach_" + address.ToString("X8"); ChunkType ctype; int tmpaddr = ByteConverter.ToInt32(file, address); if (tmpaddr != 0) { tmpaddr = (int)unchecked((uint)tmpaddr - imageBase); Vertex = new List<VertexChunk>(); if (labels.ContainsKey(tmpaddr)) VertexName = labels[tmpaddr]; else VertexName = "vertex_" + tmpaddr.ToString("X8"); ctype = (ChunkType)(ByteConverter.ToUInt32(file, tmpaddr) & 0xFF); while (ctype != ChunkType.End) { VertexChunk chunk = new VertexChunk(file, tmpaddr); Vertex.Add(chunk); tmpaddr += (chunk.Size * 4) + 4; ctype = (ChunkType)(ByteConverter.ToUInt32(file, tmpaddr) & 0xFF); } } tmpaddr = ByteConverter.ToInt32(file, address + 4); if (tmpaddr != 0) { tmpaddr = (int)unchecked((uint)tmpaddr - imageBase); Poly = new List<PolyChunk>(); if (labels.ContainsKey(tmpaddr)) PolyName = labels[tmpaddr]; else PolyName = "poly_" + tmpaddr.ToString("X8"); PolyChunk chunk = PolyChunk.Load(file, tmpaddr); while (chunk.Type != ChunkType.End) { if (chunk.Type != ChunkType.Null) Poly.Add(chunk); tmpaddr += chunk.ByteSize; chunk = PolyChunk.Load(file, tmpaddr); } } Bounds = new BoundingSphere(file, address + 8); }
public ChunkAttach(byte[] file, int address, uint imageBase, Dictionary <int, string> labels) : this() { if (labels.ContainsKey(address)) { Name = labels[address]; } else { Name = "attach_" + address.ToString("X8"); } ChunkType ctype; int tmpaddr = ByteConverter.ToInt32(file, address); if (tmpaddr != 0) { tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase); Vertex = new List <VertexChunk>(); if (labels.ContainsKey(tmpaddr)) { VertexName = labels[tmpaddr]; } else { VertexName = "vertex_" + tmpaddr.ToString("X8"); } ctype = (ChunkType)(ByteConverter.ToUInt32(file, tmpaddr) & 0xFF); while (ctype != ChunkType.End) { VertexChunk chunk = new VertexChunk(file, tmpaddr); Vertex.Add(chunk); tmpaddr += (chunk.Size * 4) + 4; ctype = (ChunkType)(ByteConverter.ToUInt32(file, tmpaddr) & 0xFF); } } tmpaddr = ByteConverter.ToInt32(file, address + 4); if (tmpaddr != 0) { tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase); Poly = new List <PolyChunk>(); if (labels.ContainsKey(tmpaddr)) { PolyName = labels[tmpaddr]; } else { PolyName = "poly_" + tmpaddr.ToString("X8"); } PolyChunk chunk = PolyChunk.Load(file, tmpaddr); while (chunk.Type != ChunkType.End) { if (chunk.Type != ChunkType.Null) { Poly.Add(chunk); } tmpaddr += chunk.ByteSize; chunk = PolyChunk.Load(file, tmpaddr); } } Bounds = new BoundingSphere(file, address + 8); }
public ChunkAttach() { Name = "attach_" + Extensions.GenerateIdentifier(); Bounds = new BoundingSphere(); }
public override List <RenderInfo> Render(SETItem item, Device dev, EditorCamera camera, MatrixStack transform) { List <RenderInfo> result = new List <RenderInfo>(); transform.Push(); float scaleX = item.Scale.X; float scaleY = item.Scale.Y * 0.5f; float scaleZ = item.Scale.Z; if (scaleX >= 10.0f) { if (scaleX > 200.0f) { scaleX = 200f; } } else { scaleX = 10f; } if (scaleY >= 10.0f) { if (scaleY > 200.0f) { scaleY = 200f; } } else { scaleY = 10f; } if (scaleZ >= 10.0f) { if (scaleZ > 200.0f) { scaleZ = 200f; } } else { scaleZ = 10f; } transform.NJTranslate(item.Position); transform.NJRotateY(item.Rotation.Y); transform.NJScale(scaleX, scaleY, scaleZ); float largestScale = item.Scale.X; 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 = largestScale }; RenderInfo outputInfo = new RenderInfo(mesh, 0, transform.Top, material, null, FillMode.Wireframe, 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 override BoundingSphere GetBounds(SETItem item) { BoundingSphere bounds = new BoundingSphere(item.Position, item.Scale.X); return(bounds); }