Clean up code

Adjust UI
Fixed some bugs
This commit is contained in:
Perfare 2017-02-27 23:56:24 +08:00
parent 29068481f5
commit 45b9b781b1
3 changed files with 104 additions and 113 deletions

View File

@ -380,6 +380,7 @@ namespace Unity_Studio
fileNodes = new List<GameObject>();
if (buildHierarchyMenuItem)
{
SetProgressBarMaximum(1);
SetProgressBarValue(1);
SetProgressBarMaximum(assetsfileList.Sum(x => x.GameObjectList.Values.Count) + 1);
foreach (var assetsFile in assetsfileList)

View File

@ -575,9 +575,9 @@
this.FMODpanel.Controls.Add(this.FMODstopButton);
this.FMODpanel.Controls.Add(this.FMODpauseButton);
this.FMODpanel.Controls.Add(this.FMODplayButton);
this.FMODpanel.Location = new System.Drawing.Point(223, 217);
this.FMODpanel.Location = new System.Drawing.Point(0, 0);
this.FMODpanel.Name = "FMODpanel";
this.FMODpanel.Size = new System.Drawing.Size(400, 200);
this.FMODpanel.Size = new System.Drawing.Size(838, 635);
this.FMODpanel.TabIndex = 2;
this.FMODpanel.Visible = false;
//
@ -585,7 +585,7 @@
//
this.FMODcopyright.AutoSize = true;
this.FMODcopyright.ForeColor = System.Drawing.SystemColors.ControlLight;
this.FMODcopyright.Location = new System.Drawing.Point(117, 187);
this.FMODcopyright.Location = new System.Drawing.Point(249, 380);
this.FMODcopyright.Name = "FMODcopyright";
this.FMODcopyright.Size = new System.Drawing.Size(283, 13);
this.FMODcopyright.TabIndex = 9;
@ -594,7 +594,7 @@
// FMODinfoLabel
//
this.FMODinfoLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.FMODinfoLabel.Location = new System.Drawing.Point(82, 54);
this.FMODinfoLabel.Location = new System.Drawing.Point(305, 271);
this.FMODinfoLabel.Name = "FMODinfoLabel";
this.FMODinfoLabel.Size = new System.Drawing.Size(176, 13);
this.FMODinfoLabel.TabIndex = 8;
@ -602,7 +602,7 @@
// FMODtimerLabel
//
this.FMODtimerLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.FMODtimerLabel.Location = new System.Drawing.Point(212, 54);
this.FMODtimerLabel.Location = new System.Drawing.Point(435, 271);
this.FMODtimerLabel.Name = "FMODtimerLabel";
this.FMODtimerLabel.Size = new System.Drawing.Size(158, 13);
this.FMODtimerLabel.TabIndex = 7;
@ -612,7 +612,7 @@
// FMODstatusLabel
//
this.FMODstatusLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.FMODstatusLabel.Location = new System.Drawing.Point(26, 54);
this.FMODstatusLabel.Location = new System.Drawing.Point(249, 271);
this.FMODstatusLabel.Name = "FMODstatusLabel";
this.FMODstatusLabel.Size = new System.Drawing.Size(50, 13);
this.FMODstatusLabel.TabIndex = 6;
@ -621,7 +621,7 @@
// FMODprogressBar
//
this.FMODprogressBar.AutoSize = false;
this.FMODprogressBar.Location = new System.Drawing.Point(29, 73);
this.FMODprogressBar.Location = new System.Drawing.Point(252, 290);
this.FMODprogressBar.Maximum = 1000;
this.FMODprogressBar.Name = "FMODprogressBar";
this.FMODprogressBar.Size = new System.Drawing.Size(348, 24);
@ -634,7 +634,7 @@
// FMODvolumeBar
//
this.FMODvolumeBar.LargeChange = 2;
this.FMODvolumeBar.Location = new System.Drawing.Point(273, 103);
this.FMODvolumeBar.Location = new System.Drawing.Point(496, 320);
this.FMODvolumeBar.Name = "FMODvolumeBar";
this.FMODvolumeBar.Size = new System.Drawing.Size(104, 45);
this.FMODvolumeBar.TabIndex = 4;
@ -645,7 +645,7 @@
// FMODloopButton
//
this.FMODloopButton.Appearance = System.Windows.Forms.Appearance.Button;
this.FMODloopButton.Location = new System.Drawing.Point(212, 103);
this.FMODloopButton.Location = new System.Drawing.Point(435, 320);
this.FMODloopButton.Name = "FMODloopButton";
this.FMODloopButton.Size = new System.Drawing.Size(55, 46);
this.FMODloopButton.TabIndex = 3;
@ -656,7 +656,7 @@
//
// FMODstopButton
//
this.FMODstopButton.Location = new System.Drawing.Point(151, 103);
this.FMODstopButton.Location = new System.Drawing.Point(374, 320);
this.FMODstopButton.Name = "FMODstopButton";
this.FMODstopButton.Size = new System.Drawing.Size(55, 46);
this.FMODstopButton.TabIndex = 2;
@ -666,7 +666,7 @@
//
// FMODpauseButton
//
this.FMODpauseButton.Location = new System.Drawing.Point(90, 103);
this.FMODpauseButton.Location = new System.Drawing.Point(313, 320);
this.FMODpauseButton.Name = "FMODpauseButton";
this.FMODpauseButton.Size = new System.Drawing.Size(55, 46);
this.FMODpauseButton.TabIndex = 1;
@ -676,7 +676,7 @@
//
// FMODplayButton
//
this.FMODplayButton.Location = new System.Drawing.Point(29, 103);
this.FMODplayButton.Location = new System.Drawing.Point(252, 320);
this.FMODplayButton.Name = "FMODplayButton";
this.FMODplayButton.Size = new System.Drawing.Size(55, 46);
this.FMODplayButton.TabIndex = 0;
@ -717,7 +717,6 @@
this.glControl1.BackColor = System.Drawing.SystemColors.ControlDarkDark;
this.glControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.glControl1.Location = new System.Drawing.Point(0, 0);
this.glControl1.Margin = new System.Windows.Forms.Padding(6);
this.glControl1.Name = "glControl1";
this.glControl1.Size = new System.Drawing.Size(838, 635);
this.glControl1.TabIndex = 4;

View File

@ -36,7 +36,7 @@ namespace Unity_Studio
private Bitmap imageTexture;
// OpenTK variables
#region OpenTK variables
int pgmID;
int vsID;
int fsID;
@ -50,12 +50,67 @@ namespace Unity_Studio
int vboColors;
int vboViewMatrix;
int eboElements;
Vector3[] vertexData;
Vector3[] normalData;
Vector4[] colorData;
Matrix4[] viewMatrixData;
int[] indiceData;
Vector3[] vertexData =
{
new Vector3(-0.5f, -0.5f, -0.5f),
new Vector3(0.5f, -0.5f, -0.5f),
new Vector3(0.5f, 0.5f, -0.5f),
new Vector3(-0.5f, 0.5f, -0.5f),
new Vector3(-0.5f, -0.5f, 0.5f),
new Vector3(0.5f, -0.5f, 0.5f),
new Vector3(0.5f, 0.5f, 0.5f),
new Vector3(-0.5f, 0.5f, 0.5f)
};
Vector3[] normalData =
{
//left
new Vector3(-1.0f, 0.0f, 0.0f)
//back
//new Vector3(0.0f, 0.0f, -1.0f),
//right
//new Vector3(1.0f, 0.0f, 0.0f),
//top
//new Vector3(0.0f, 1.0f, 0.0f),
//front
//new Vector3(0.0f, 0.0f, 1.0f),
//bottom
//new Vector3(0.0f, -1.0f, 0.0f)
};
Vector4[] colorData =
{
new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
new Vector4(0.5f, 0.5f, 0.5f, 1.0f)
};
Matrix4[] viewMatrixData = { Matrix4.Identity };
int[] indiceData =
{
//left
0,2,1,
0,3,2,
//back
1,2,6,
6,5,1,
//right
4,5,6,
6,7,4,
//top
2,3,6,
6,3,7,
//front
0,7,3,
0,4,7,
//bottom
0,1,5,
0,5,4
};
bool wireFrameView;
#endregion
//asset list sorting helpers
private int firstSortColumn = -1;
@ -342,7 +397,7 @@ namespace Unity_Studio
GL.UniformMatrix4(uniformViewMatrix, false, ref viewMatrixData[0]);
glControl1.Invalidate();
}
// <-- Left
if (e.KeyCode == Keys.A)
{
@ -360,7 +415,7 @@ namespace Unity_Studio
// Up
if (e.KeyCode == Keys.W)
{
{
if (e.Control && e.KeyCode == Keys.W) //Toggle WireFrame
{
wireFrameView = !wireFrameView;
@ -963,7 +1018,7 @@ namespace Unity_Studio
{
glControl1.Visible = true;
viewMatrixData = new Matrix4[] {
Matrix4.Identity
Matrix4.Identity
* Matrix4.CreateTranslation( 0.0f, -1.0f, 0.0f )
* Matrix4.CreateRotationY(-90.0f)};
@ -991,19 +1046,26 @@ namespace Unity_Studio
indiceData[i + 1] = (int)m_Mesh.m_Indices[i + 1];
indiceData[i + 2] = (int)m_Mesh.m_Indices[i + 2];
}
if (m_Mesh.m_Normals.Length == m_Mesh.m_VertexCount * 3) { count = 3; }
else if (m_Mesh.m_Normals.Length == m_Mesh.m_VertexCount * 4) { count = 4; }
normalData = new Vector3[m_Mesh.m_VertexCount];
for (int n = 0; n < m_Mesh.m_VertexCount; n++)
if (m_Mesh.m_Normals != null && m_Mesh.m_Normals.Length > 0)
{
normalData[n] = new Vector3(
m_Mesh.m_Normals[n * count],
m_Mesh.m_Normals[n * count + 1],
m_Mesh.m_Normals[n * count + 2]);
}
if (m_Mesh.m_Normals.Length == m_Mesh.m_VertexCount * 3)
{
count = 3;
}
else if (m_Mesh.m_Normals.Length == m_Mesh.m_VertexCount * 4)
{
count = 4;
}
normalData = new Vector3[m_Mesh.m_VertexCount];
for (int n = 0; n < m_Mesh.m_VertexCount; n++)
{
normalData[n] = new Vector3(
m_Mesh.m_Normals[n * count],
m_Mesh.m_Normals[n * count + 1],
m_Mesh.m_Normals[n * count + 2]);
}
}
if (m_Mesh.m_Colors == null || m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3)
{
colorData = new Vector4[m_Mesh.m_VertexCount];
@ -1028,9 +1090,9 @@ namespace Unity_Studio
}
createVAO();
StatusStripUpdate("Using OpenGL Version: " + GL.GetString(StringName.Version)
+ " | 'T'=Start/Stop Rotation | 'WASD'=Manual Rotate | "
StatusStripUpdate("Using OpenGL Version: " + GL.GetString(StringName.Version)
+ " | 'T'=Start/Stop Rotation | 'WASD'=Manual Rotate | "
+ "'Shift WASD'=Move | 'Q/E'=Zoom | 'Ctl W' =Wireframe");
}
break;
@ -1667,6 +1729,8 @@ namespace Unity_Studio
private void initOpenTK()
{
GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height);
GL.ClearColor(Color.CadetBlue);
pgmID = GL.CreateProgram();
loadShader("vs.glsl", ShaderType.VertexShader, pgmID, out vsID);
loadShader("fs.glsl", ShaderType.FragmentShader, pgmID, out fsID);
@ -1676,6 +1740,7 @@ namespace Unity_Studio
attributeNormalDirection = GL.GetAttribLocation(pgmID, "normalDirection");
attributeVertexColor = GL.GetAttribLocation(pgmID, "vertexColor");
uniformViewMatrix = GL.GetUniformLocation(pgmID, "viewMatrix");
glControl1.Visible = false;
}
private void loadShader(string filename, ShaderType type, int program, out int address)
@ -1729,7 +1794,7 @@ namespace Unity_Studio
data,
BufferUsageHint.StaticDraw);
}
private void createVAO()
{
timerOpenTK.Stop();
@ -1748,71 +1813,7 @@ namespace Unity_Studio
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
glControl1_Resize(this, EventArgs.Empty);
GL.ClearColor(Color.CadetBlue);
initOpenTK();
vertexData = new Vector3[]
{
new Vector3(-0.5f, -0.5f, -0.5f),
new Vector3(0.5f, -0.5f, -0.5f),
new Vector3(0.5f, 0.5f, -0.5f),
new Vector3(-0.5f, 0.5f, -0.5f),
new Vector3(-0.5f, -0.5f, 0.5f),
new Vector3(0.5f, -0.5f, 0.5f),
new Vector3(0.5f, 0.5f, 0.5f),
new Vector3(-0.5f, 0.5f, 0.5f)
};
indiceData = new int[]
{
//left
0,2,1,
0,3,2,
//back
1,2,6,
6,5,1,
//right
4,5,6,
6,7,4,
//top
2,3,6,
6,3,7,
//front
0,7,3,
0,4,7,
//bottom
0,1,5,
0,5,4
};
normalData = new Vector3[]
{
//left
new Vector3(-1.0f, 0.0f, 0.0f)
//back
//new Vector3(0.0f, 0.0f, -1.0f),
//right
//new Vector3(1.0f, 0.0f, 0.0f),
//top
//new Vector3(0.0f, 1.0f, 0.0f),
//front
//new Vector3(0.0f, 0.0f, 1.0f),
//bottom
//new Vector3(0.0f, -1.0f, 0.0f)
};
colorData = new Vector4[vertexData.Length];
for (int c = 0; c < vertexData.Length; c++)
{
colorData[c] = new Vector4(
0.5f, 0.5f, 0.5f, 1.0f);
};
viewMatrixData = new Matrix4[]
{
Matrix4.Identity
};
createVAO();
glControl1.Visible = false;
}
private void glControl1_Paint(object sender, PaintEventArgs e)
@ -1821,7 +1822,7 @@ namespace Unity_Studio
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Enable(EnableCap.DepthTest);
GL.DepthFunc(DepthFunction.Less);
GL.BindVertexArray(vao);
GL.BindVertexArray(vao);
if (wireFrameView == true)
{
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); //Wireframe
@ -1836,16 +1837,6 @@ namespace Unity_Studio
glControl1.SwapBuffers();
}
private void glControl1_Resize(object sender, EventArgs e)
{
if (glControl1.ClientSize.Height == 0)
{
glControl1.ClientSize = new System.Drawing.Size(glControl1.ClientSize.Width, 1);
}
GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height);
}
private void resetForm()
{
/*Properties.Settings.Default["uniqueNames"] = uniqueNamesMenuItem.Checked;
@ -1859,7 +1850,7 @@ namespace Unity_Studio
assetsfileList.Clear();
exportableAssets.Clear();
visibleAssets.Clear();
UnityStudio.assetsfileandstream.Clear();
assetsfileandstream.Clear();
sceneTreeView.Nodes.Clear();