public MainForm() { InitializeComponent(); // Load global settings this.mGlobalSettings = new GlobalSettings(); this.mLocalSettings = LocalSettings.GetInstance(); // Restore the size Size = mLocalSettings.m_size; if ((Size.Height < 100) || (Size.Width < 200)) { Size lsize = new Size(); lsize.Height = 500; lsize.Width = 800; this.Size = lsize; } //register the viewer manager classes //qq there must be a better way of doing this, it seems a bit // odd. Could use reflection. Might be a little slow or have // unexpected side-effects. It's nice to be able to control // the order the tabs appear in, too. ViewTabActions.Tag = ActionsViewer.InitialiseViewer(this); ViewTabXML.Tag = XMLViewer.InitialiseViewer(this); ViewTabFlat.Tag = FlatViewer.InitialiseViewer(this); ViewTabImg.Tag = ImageViewer.InitialiseViewer(this); ViewTabBump.Tag = BumpViewer.InitialiseViewer(this); ViewTabSteering.Tag = SteeringViewer.InitialiseViewer(this); ViewTabCamera.Tag = CameraViewer.InitialiseViewer(this); ViewTabGrid.Tag = GridViewer.InitialiseViewer(this); ViewTab3D.Tag = ThreeDeeViewer.InitialiseViewer(this); ViewTabVRAM.Tag = VRAMViewer.InitialiseViewer(this); ViewTab3dEditor.Tag = ThreeDeeEditor.InitialiseViewer(this); ViewTabHistory.Tag = HistoryViewer.InitialiseViewer(this); //auto-load last level if (mLocalSettings.LastOpenedFile != null) { LoadInternal(mLocalSettings.LastOpenedType, mLocalSettings.LastOpenedFile); } }
public Entity GetEntity(Chunk xiRootChunk, eTextureMode xiTextureMode, eTexMetaDataEntries xiSelectedMetadata, object xiMeshOwner) { MMEdEntity lAcc = new MMEdEntity(xiMeshOwner); Mesh lColouredMesh = null; Dictionary <int, Mesh> lPageIdToTexturedMeshMap = new Dictionary <int, Mesh>(); List <Mesh> lTranslucentMeshes = new List <Mesh>(); //qq move all this into Face class? //qq add quad mode meshes (needs separate meshes currently...) Vertex[] lVBuff = new Vertex[4]; foreach (Face f in Faces) { if (!f.IsUnknownType()) { for (int v = 0; v < f.mVertexIds.Length; v++) { lVBuff[v] = new Vertex(ThreeDeeViewer.Short3CoordToPoint(Vertices[f.mVertexIds[v]])); //normal if (v < f.mNormalIds.Length) { lVBuff[v].Normal = ThreeDeeViewer.Short3CoordToPoint(Normals[f.mNormalIds[v]]).GetPositionVector().Normalise(); } else { lVBuff[v].Normal = ThreeDeeViewer.Short3CoordToPoint(Normals[f.mNormalIds[0]]).GetPositionVector().Normalise(); } //color: if (f.mColors != null && v < f.mColors.Length) { lVBuff[v].Color = Utils.PSRGBColorToColor(f.mColors[v]); } else if (f.mColors != null) { lVBuff[v].Color = Utils.PSRGBColorToColor(f.mColors[0]); } //tex coords if (f.mTexCoords != null && v < f.mTexCoords.Length) { lVBuff[v].TexCoordX = f.mTexCoords[v].X / (double)VRAMViewer.TEX_PAGE_WIDTH; lVBuff[v].TexCoordY = f.mTexCoords[v].Y / (double)VRAMViewer.TEX_PAGE_HEIGHT; } } // Create a new mesh if appropriate, or add this face to an existing mesh // First check if it's tex or solid? Mesh lMesh; if (f.mTexCoords != null) { if (!lPageIdToTexturedMeshMap.ContainsKey(f.mTexPage)) { lMesh = new OwnedMesh(xiMeshOwner); lPageIdToTexturedMeshMap[f.mTexPage] = lMesh; if (xiTextureMode == eTextureMode.NormalTextures || xiTextureMode == eTextureMode.NormalTexturesWithMetadata) { lMesh.RenderMode = RenderMode.Textured; lMesh.Texture = AbstractRenderer.ImageToTextureId( VRAMViewer.GetInstance().GetTexturePage(xiRootChunk, f.mTexPage)); } else { lMesh.RenderMode = RenderMode.Wireframe; } } else { lMesh = lPageIdToTexturedMeshMap[f.mTexPage]; } } else { if (f.IsTranslucent()) { lMesh = new OwnedMesh(xiMeshOwner); if (xiTextureMode == eTextureMode.NormalTextures || xiTextureMode == eTextureMode.NormalTexturesWithMetadata) { lMesh.RenderMode = RenderMode.TranslucentFilled; } else { lMesh.RenderMode = RenderMode.Wireframe; } lTranslucentMeshes.Add(lMesh); } else { if (lColouredMesh == null) { lColouredMesh = new OwnedMesh(xiMeshOwner); if (xiTextureMode == eTextureMode.NormalTextures || xiTextureMode == eTextureMode.NormalTexturesWithMetadata) { lColouredMesh.RenderMode = RenderMode.Filled; } else { lColouredMesh.RenderMode = RenderMode.Wireframe; } } lMesh = lColouredMesh; } } if (f.mVertexIds.Length == 3) { lMesh.AddFace(lVBuff[0], lVBuff[1], lVBuff[2]); } else //4 { lMesh.AddFace(lVBuff[0], lVBuff[1], lVBuff[2]); lMesh.AddFace(lVBuff[0], lVBuff[2], lVBuff[3]); } } } foreach (Mesh lTexturedMesh in lPageIdToTexturedMeshMap.Values) { lAcc.Meshes.Add(lTexturedMesh); } if (lColouredMesh != null) { lAcc.Meshes.Add(lColouredMesh); } lAcc.Meshes.AddRange(lTranslucentMeshes); lAcc.Scale(1, 1, -1); return(lAcc); }
public Bitmap GetTexturePageById(int xiId) { return(VRAMViewer.GetInstance().GetTexturePage(this, xiId)); }