Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tinkering

  • Loading branch information...
commit 1411eed1a60dae8e69dd71e355b50903aa87d498 1 parent ef3003b
@53V3N1X authored
Showing with 1,534 additions and 456 deletions.
  1. +6 −0 Converter/App.config
  2. +88 −0 Converter/Converter.csproj
  3. +208 −0 Converter/ConverterGui.Designer.cs
  4. +20 −0 Converter/ConverterGui.cs
  5. +133 −0 Converter/ConverterGui.resx
  6. +22 −0 Converter/Program.cs
  7. +36 −0 Converter/Properties/AssemblyInfo.cs
  8. +71 −0 Converter/Properties/Resources.Designer.cs
  9. +117 −0 Converter/Properties/Resources.resx
  10. +30 −0 Converter/Properties/Settings.Designer.cs
  11. +7 −0 Converter/Properties/Settings.settings
  12. +20 −6 Game/Game.cs
  13. +4 −5 Game/Game.csproj
  14. +2 −2 Game/Units/Types/Melee.cs
  15. BIN  References/OpenTK.dll
  16. +20 −1 SevenEngine.sln
  17. +1 −0  SevenEngine/DataStructures/Array.cs
  18. +12 −6 SevenEngine/DataStructures/AvlTree.cs
  19. +1 −0  SevenEngine/DataStructures/HashTable.cs
  20. +2 −0  SevenEngine/DataStructures/Heap.cs
  21. +6 −0 SevenEngine/DataStructures/Link.cs
  22. +14 −8 SevenEngine/DataStructures/List.cs
  23. +202 −119 SevenEngine/DataStructures/Octree.cs
  24. +118 −12 SevenEngine/DataStructures/Quadtree.cs
  25. +2 −0  SevenEngine/DataStructures/Queue.cs
  26. +1 −0  SevenEngine/DataStructures/RedBlackTree.cs
  27. +3 −2 SevenEngine/DataStructures/Stack.cs
  28. +14 −0 SevenEngine/DynamicModels/Animation.cs
  29. +12 −4 SevenEngine/DynamicModels/DynamicModel.cs
  30. +16 −10 SevenEngine/{Physics/Substance.cs → DynamicModels/KeyFrame.cs}
  31. +1 −1  SevenEngine/MANAGERS/ShaderManager.cs
  32. +19 −28 SevenEngine/MANAGERS/StaticModelManager.cs
  33. +91 −102 SevenEngine/Mathematics/Matrix.cs
  34. +41 −14 SevenEngine/Mathematics/Quaternion.cs
  35. +15 −4 SevenEngine/Mathematics/Vector.cs
  36. +40 −0 SevenEngine/Physics/Material.cs
  37. +1 −1  SevenEngine/Physics/Matter.cs
  38. +22 −0 SevenEngine/Physics/Shapes/RectangularPrism.cs
  39. +3 −2 SevenEngine/SevenEngine.csproj
  40. +21 −2 SevenEngine/Shaders/VertexShader.cs
  41. +61 −12 SevenEngine/StaticModels/StaticMesh.cs
  42. +0 −89 SevenEngine/StaticModels/StaticMeshInstance.cs
  43. +6 −2 SevenEngine/StaticModels/StaticModel.cs
  44. +25 −24 SevenEngine/UTILITIES/Renderer.cs
View
6 Converter/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+ </startup>
+</configuration>
View
88 Converter/Converter.csproj
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Converter</RootNamespace>
+ <AssemblyName>Converter</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ConverterGui.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="ConverterGui.Designer.cs">
+ <DependentUpon>ConverterGui.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="ConverterGui.resx">
+ <DependentUpon>ConverterGui.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
208 Converter/ConverterGui.Designer.cs
@@ -0,0 +1,208 @@
+namespace Converter
+{
+ partial class guiConverterForm
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(guiConverterForm));
+ this.tabControl1 = new System.Windows.Forms.TabControl();
+ this.tabPage2 = new System.Windows.Forms.TabPage();
+ this.tabPage1 = new System.Windows.Forms.TabPage();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.pictureBox1 = new System.Windows.Forms.PictureBox();
+ this.button1 = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.tabPage3 = new System.Windows.Forms.TabPage();
+ this.tabPage4 = new System.Windows.Forms.TabPage();
+ this.textBox2 = new System.Windows.Forms.TextBox();
+ this.tabControl1.SuspendLayout();
+ this.tabPage2.SuspendLayout();
+ this.tabPage1.SuspendLayout();
+ this.panel1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
+ this.SuspendLayout();
+ //
+ // tabControl1
+ //
+ this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tabControl1.Controls.Add(this.tabPage2);
+ this.tabControl1.Controls.Add(this.tabPage1);
+ this.tabControl1.Controls.Add(this.tabPage3);
+ this.tabControl1.Controls.Add(this.tabPage4);
+ this.tabControl1.Location = new System.Drawing.Point(0, 0);
+ this.tabControl1.Name = "tabControl1";
+ this.tabControl1.SelectedIndex = 0;
+ this.tabControl1.Size = new System.Drawing.Size(541, 336);
+ this.tabControl1.TabIndex = 0;
+ //
+ // tabPage2
+ //
+ this.tabPage2.Controls.Add(this.textBox2);
+ this.tabPage2.Location = new System.Drawing.Point(4, 22);
+ this.tabPage2.Name = "tabPage2";
+ this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage2.Size = new System.Drawing.Size(533, 310);
+ this.tabPage2.TabIndex = 1;
+ this.tabPage2.Text = "Info";
+ this.tabPage2.UseVisualStyleBackColor = true;
+ //
+ // tabPage1
+ //
+ this.tabPage1.Controls.Add(this.panel1);
+ this.tabPage1.Controls.Add(this.button1);
+ this.tabPage1.Controls.Add(this.label1);
+ this.tabPage1.Controls.Add(this.textBox1);
+ this.tabPage1.Location = new System.Drawing.Point(4, 22);
+ this.tabPage1.Name = "tabPage1";
+ this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage1.Size = new System.Drawing.Size(533, 310);
+ this.tabPage1.TabIndex = 0;
+ this.tabPage1.Text = "Image";
+ this.tabPage1.UseVisualStyleBackColor = true;
+ //
+ // panel1
+ //
+ this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.panel1.BackColor = System.Drawing.Color.Gray;
+ this.panel1.Controls.Add(this.pictureBox1);
+ this.panel1.Location = new System.Drawing.Point(0, 0);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(256, 310);
+ this.panel1.TabIndex = 4;
+ //
+ // pictureBox1
+ //
+ this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.pictureBox1.BackColor = System.Drawing.Color.White;
+ this.pictureBox1.Location = new System.Drawing.Point(19, 19);
+ this.pictureBox1.Name = "pictureBox1";
+ this.pictureBox1.Size = new System.Drawing.Size(213, 273);
+ this.pictureBox1.TabIndex = 0;
+ this.pictureBox1.TabStop = false;
+ //
+ // button1
+ //
+ this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.button1.Location = new System.Drawing.Point(471, 4);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(59, 23);
+ this.button1.TabIndex = 3;
+ this.button1.Text = "Browse";
+ this.button1.UseVisualStyleBackColor = true;
+ //
+ // label1
+ //
+ this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(262, 9);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(26, 13);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "File:";
+ //
+ // textBox1
+ //
+ this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBox1.Location = new System.Drawing.Point(294, 6);
+ this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(171, 20);
+ this.textBox1.TabIndex = 1;
+ //
+ // tabPage3
+ //
+ this.tabPage3.Location = new System.Drawing.Point(4, 22);
+ this.tabPage3.Name = "tabPage3";
+ this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage3.Size = new System.Drawing.Size(550, 292);
+ this.tabPage3.TabIndex = 2;
+ this.tabPage3.Text = "Static Model";
+ this.tabPage3.UseVisualStyleBackColor = true;
+ //
+ // tabPage4
+ //
+ this.tabPage4.Location = new System.Drawing.Point(4, 22);
+ this.tabPage4.Name = "tabPage4";
+ this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage4.Size = new System.Drawing.Size(550, 292);
+ this.tabPage4.TabIndex = 3;
+ this.tabPage4.Text = "Dynamic Model";
+ this.tabPage4.UseVisualStyleBackColor = true;
+ //
+ // textBox2
+ //
+ this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBox2.Location = new System.Drawing.Point(6, 6);
+ this.textBox2.Multiline = true;
+ this.textBox2.Name = "textBox2";
+ this.textBox2.Size = new System.Drawing.Size(523, 298);
+ this.textBox2.TabIndex = 0;
+ this.textBox2.Text = resources.GetString("textBox2.Text");
+ //
+ // guiConverterForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(540, 335);
+ this.Controls.Add(this.tabControl1);
+ this.Name = "guiConverterForm";
+ this.Text = "SevenEngine";
+ this.tabControl1.ResumeLayout(false);
+ this.tabPage2.ResumeLayout(false);
+ this.tabPage2.PerformLayout();
+ this.tabPage1.ResumeLayout(false);
+ this.tabPage1.PerformLayout();
+ this.panel1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TabControl tabControl1;
+ private System.Windows.Forms.TabPage tabPage1;
+ private System.Windows.Forms.TabPage tabPage2;
+ private System.Windows.Forms.TabPage tabPage3;
+ private System.Windows.Forms.TabPage tabPage4;
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.PictureBox pictureBox1;
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.TextBox textBox2;
+ }
+}
+
View
20 Converter/ConverterGui.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Converter
+{
+ public partial class guiConverterForm : Form
+ {
+ public guiConverterForm()
+ {
+ InitializeComponent();
+ }
+ }
+}
View
133 Converter/ConverterGui.resx
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="textBox2.Text" xml:space="preserve">
+ <value>This is the file converter for SevenEngine.
+
+You can you this program to convert files into formats accepted by SevenEngine.
+
+The reason for this converter is to ensure fast load times, make it easier on the SevenEngine software developers, and to standardize the graphics filetypes.
+
+Click on the appropriate tab to begin file conversions:
+- Image (for image files)
+- Static Model (for non-animated models)
+- Dynamic Model (for animated models)
+- Advanced (for mass file conversions)</value>
+ </data>
+</root>
View
22 Converter/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Converter
+{
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new guiConverterForm());
+ }
+ }
+}
View
36 Converter/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Converter")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Converter")]
+[assembly: AssemblyCopyright("Copyright © 2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1227432c-449d-4866-a24d-06e36ed063ce")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
71 Converter/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.34003
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Converter.Properties
+{
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Converter.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
View
117 Converter/Properties/Resources.resx
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
View
30 Converter/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.34003
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Converter.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
View
7 Converter/Properties/Settings.settings
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
View
26 Game/Game.cs
@@ -111,7 +111,13 @@ public override void InitializeModels()
// meshes because they do not have transformations. Put them in a static model to render them.
StaticModelManager.LoadMesh("terrain", FilePath.FromRelative(@"\..\..\Assets\Models\Terrain.obj"));
StaticModelManager.LoadMesh("RedRanger", FilePath.FromRelative(@"\..\..\Assets\Models\RedRanger.obj"));
+ StaticModelManager.LoadMesh("BlackRanger", FilePath.FromRelative(@"\..\..\Assets\Models\RedRanger.obj"));
+ StaticModelManager.LoadMesh("BlueRanger", FilePath.FromRelative(@"\..\..\Assets\Models\RedRanger.obj"));
+ StaticModelManager.LoadMesh("YellowRanger", FilePath.FromRelative(@"\..\..\Assets\Models\RedRanger.obj"));
+ StaticModelManager.LoadMesh("PinkRanger", FilePath.FromRelative(@"\..\..\Assets\Models\RedRanger.obj"));
StaticModelManager.LoadMesh("Tux", FilePath.FromRelative(@"\..\..\Assets\Models\tux.obj"));
+ StaticModelManager.LoadMesh("TuxRed", FilePath.FromRelative(@"\..\..\Assets\Models\tux.obj"));
+ StaticModelManager.LoadMesh("TuxGreen", FilePath.FromRelative(@"\..\..\Assets\Models\tux.obj"));
StaticModelManager.LoadMesh("mountain", FilePath.FromRelative(@"\..\..\Assets\Models\mountain.obj"));
StaticModelManager.LoadMesh("MushroomCloud", FilePath.FromRelative(@"\..\..\Assets\Models\MushCloud.obj"));
@@ -121,14 +127,16 @@ public override void InitializeModels()
StaticModelManager.LoadModel("Terrain", new string[] { "Terrain" }, new string[] { "terrain" }, new string[] { "grass" });
StaticModelManager.LoadModel("Mountain", new string[] { "mountain" }, new string[] { "mountain" }, new string[] { "rock" });
StaticModelManager.LoadModel("Mountain2", new string[] { "mountain" }, new string[] { "mountain" }, new string[] { "rock2" });
+
StaticModelManager.LoadModel("Tux", new string[] { "Body" }, new string[] { "Tux" }, new string[] { "Tux" });
- StaticModelManager.LoadModel("TuxRed", new string[] { "Body" }, new string[] { "Tux" }, new string[] { "TuxRed" });
- StaticModelManager.LoadModel("TuxGreen", new string[] { "Body" }, new string[] { "Tux" }, new string[] { "TuxGreen" });
+ StaticModelManager.LoadModel("TuxRed", new string[] { "Body" }, new string[] { "TuxRed" }, new string[] { "TuxRed" });
+ StaticModelManager.LoadModel("TuxGreen", new string[] { "Body" }, new string[] { "TuxGreen" }, new string[] { "TuxGreen" });
+
StaticModelManager.LoadModel("RedRanger", new string[] { "Body" }, new string[] { "RedRanger" }, new string[] { "RedRanger" });
- StaticModelManager.LoadModel("BlueRanger", new string[] { "Body" }, new string[] { "RedRanger" }, new string[] { "BlueRanger" });
- StaticModelManager.LoadModel("BlackRanger", new string[] { "Body" }, new string[] { "RedRanger" }, new string[] { "BlackRanger" });
- StaticModelManager.LoadModel("PinkRanger", new string[] { "Body" }, new string[] { "RedRanger" }, new string[] { "PinkRanger" });
- StaticModelManager.LoadModel("YellowRanger", new string[] { "Body" }, new string[] { "RedRanger" }, new string[] { "YellowRanger" });
+ StaticModelManager.LoadModel("BlueRanger", new string[] { "Body" }, new string[] { "BlueRanger" }, new string[] { "BlueRanger" });
+ StaticModelManager.LoadModel("BlackRanger", new string[] { "Body" }, new string[] { "BlackRanger" }, new string[] { "BlackRanger" });
+ StaticModelManager.LoadModel("PinkRanger", new string[] { "Body" }, new string[] { "PinkRanger" }, new string[] { "PinkRanger" });
+ StaticModelManager.LoadModel("YellowRanger", new string[] { "Body" }, new string[] { "YellowRanger" }, new string[] { "YellowRanger" });
}
public override void InitializeShaders()
@@ -183,6 +191,12 @@ public override void InitializeStates()
// The state must be loaded before you make it the current state.
StateManager.TriggerStateLoad("AiBattle");
StateManager.ChangeState("AiBattle");
+
+
+
+ /*StateManager.AddState(new SpriteState("SpriteState"));
+ StateManager.TriggerStateLoad("SpriteState");
+ StateManager.ChangeState("SpriteState");*/
}
public override void Update(double elapsedTime)
View
9 Game/Game.csproj
@@ -30,9 +30,11 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
+ <DefineConstants>
+ </DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -79,8 +81,5 @@
<Target Name="AfterBuild">
</Target>
-->
- <ItemGroup>
- <Folder Include="Units\Types\Ai\Killem\" />
- <Folder Include="Units\Types\Ai\Seven\" />
- </ItemGroup>
+ <ItemGroup />
</Project>
View
4 Game/Units/Types/Melee.cs
@@ -16,8 +16,8 @@ public abstract class Melee : Unit
private const int _damageMax = 20;
private const int _viewDistanceMin = 1;
private const int _viewDistanceMax = 10000;
- private const int _moveSpeedMin = 60;
- private const int _moveSpeedMax = 70;
+ private const int _moveSpeedMin = 70;
+ private const int _moveSpeedMax = 110;
public Melee(string id, StaticModel staticModel) : base(id, staticModel)
{
View
BIN  References/OpenTK.dll
Binary file not shown
View
21 SevenEngine.sln
@@ -1,10 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
+# Visual Studio 2013
+VisualStudioVersion = 12.0.21005.1
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SevenEngine", "SevenEngine\SevenEngine.csproj", "{78E91C0F-F05D-4BBA-92B3-E5A84705F63D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Game", "Game\Game.csproj", "{7FEC005B-B67A-4543-8D29-E85C782B70C3}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Converter", "Converter\Converter.csproj", "{F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C4930C7E-077A-4990-99ED-8B92CF533129}"
+ ProjectSection(SolutionItems) = preProject
+ Performance1.psess = Performance1.psess
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +48,16 @@ Global
{7FEC005B-B67A-4543-8D29-E85C782B70C3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7FEC005B-B67A-4543-8D29-E85C782B70C3}.Release|x86.ActiveCfg = Release|Any CPU
{7FEC005B-B67A-4543-8D29-E85C782B70C3}.Release|x86.Build.0 = Release|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {F3DC16FC-D842-4DFF-91BD-4D6BB8C033D9}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
1  SevenEngine/DataStructures/Array.cs
@@ -27,6 +27,7 @@ public interface Array<Type> : DataStructure<Type>
/// <summary>Implements a standard array that inherits InterfaceTraversable.</summary>
/// <typeparam name="Type">The generic type within the structure.</typeparam>
+ [Serializable]
public class ArrayBase<Type> : Array<Type>
{
private Type[] _array;
View
18 SevenEngine/DataStructures/AvlTree.cs
@@ -57,24 +57,25 @@ public interface AvlTree<ValueType, FirstKeyType, SecondKeyType> : AvlTree<Value
/// <summary>Implements an AVL Tree where the items are sorted by string id values.</summary>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class AvlTreeLinked<ValueType> : AvlTree<ValueType>
{
#region AvlTreeNodeLinked
/// <summary>This class just holds the data for each individual node of the tree.</summary>
- protected class AvlTreeLinkedNode
+ public class AvlTreeLinkedNode
{
private ValueType _value;
private AvlTreeLinkedNode _leftChild;
private AvlTreeLinkedNode _rightChild;
private int _height;
- internal ValueType Value { get { return _value; } set { _value = value; } }
- internal AvlTreeLinkedNode LeftChild { get { return _leftChild; } set { _leftChild = value; } }
- internal AvlTreeLinkedNode RightChild { get { return _rightChild; } set { _rightChild = value; } }
- internal int Height { get { return _height; } set { _height = value; } }
+ public ValueType Value { get { return _value; } set { _value = value; } }
+ public AvlTreeLinkedNode LeftChild { get { return _leftChild; } set { _leftChild = value; } }
+ public AvlTreeLinkedNode RightChild { get { return _rightChild; } set { _rightChild = value; } }
+ public int Height { get { return _height; } set { _height = value; } }
- internal AvlTreeLinkedNode(ValueType value)
+ public AvlTreeLinkedNode(ValueType value)
{
_value = value;
_leftChild = null;
@@ -94,6 +95,9 @@ internal AvlTreeLinkedNode(ValueType value)
protected int _readers;
protected int _writers;
+ /// <summary>WARNING! Allows direct access to the tree structure. Can corrupt tree if miss-used</summary>
+ public AvlTreeLinkedNode UnsafeTop { get { return _avlTree; } set { _avlTree = value; } }
+
/// <summary>Gets the number of elements in the collection.</summary>
/// <remarks>Runtime: O(1).</remarks>
public int Count { get { ReaderLock(); int count = _count; ReaderUnlock(); return _count; } }
@@ -571,6 +575,7 @@ protected class AvlTreeLinkedException : Exception { public AvlTreeLinkedExcepti
/// <summary>Implements an AVL Tree where the items are sorted by string id values.</summary>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class AvlTreeLinked<ValueType, KeyType> : AvlTreeLinked<ValueType>, AvlTree<ValueType, KeyType>
{
protected Func<ValueType, KeyType, int> _keyComparisonFunction;
@@ -795,6 +800,7 @@ protected void TraversalInOrder(Action<ValueType> traversalFunction, AvlTreeLink
/// <summary>Implements an AVL Tree where the items are sorted by string id values.</summary>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class AvlTreeLinked<ValueType, FirstKeyType, SecondKeyType> : AvlTreeLinked<ValueType, FirstKeyType>, AvlTree<ValueType, FirstKeyType, SecondKeyType>
{
Func<ValueType, SecondKeyType, int> _secondkeyComparisonFunction;
View
1  SevenEngine/DataStructures/HashTable.cs
@@ -31,6 +31,7 @@ public interface HashTable<ValueType, KeyType> : DataStructure<ValueType>
#region HashTableLinked
+ [Serializable]
public class HashTableLinked<ValueType, KeyType> : HashTable<ValueType, KeyType>
{
/// <summary>A set of allowable table sizes, all of which are prime.</summary>
View
2  SevenEngine/DataStructures/Heap.cs
@@ -264,6 +264,7 @@ private class HeapArrayStaticException : Exception { public HeapArrayStaticExcep
/// <summary>Implements a mutable priority heap with static priorities using an array.</summary>
/// <typeparam name="Type">The type of item to be stored in this priority heap.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class HeapArrayStatic<Type> : Heap<Type>
{
#region HeapArrayLink
@@ -489,6 +490,7 @@ private class HeapArrayStaticException : Exception { public HeapArrayStaticExcep
/// <summary>Implements a mutable priority heap with dynamic priorities using an array and a hash table.</summary>
/// <typeparam name="Type">The type of item to be stored in this priority heap.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class HeapArrayDynamic<Type> : Heap<Type>
{
#region HeapArrayDynamicLink
View
6 SevenEngine/DataStructures/Link.cs
@@ -10,6 +10,8 @@
// - Zachary Aaron Patten (aka Seven) seven@sevenengine.com
// Last Edited: 11-16-13
+using System;
+
namespace SevenEngine.DataStructures
{
#region Link2
@@ -17,6 +19,7 @@ namespace SevenEngine.DataStructures
/// <summary>Represents a link between two objects.</summary>
/// <typeparam name="FirstItem">The type of the left item to be linked.</typeparam>
/// <typeparam name="SecondItem">The type of the right item to be linked.</typeparam>
+ [Serializable]
public class Link2<FirstItem, SecondItem>
{
private FirstItem _first;
@@ -48,6 +51,7 @@ public Link2(FirstItem first, SecondItem second)
/// <typeparam name="FirstType">The type of the first item to be linked.</typeparam>
/// <typeparam name="SecondType">The type of the second item to be linked.</typeparam>
/// <typeparam name="ThirdType">The type of the third item to be linked.</typeparam>
+ [Serializable]
public class Link3<FirstType, SecondType, ThirdType>
{
private FirstType _first;
@@ -86,6 +90,7 @@ public Link3(FirstType first, SecondType second, ThirdType third)
/// <typeparam name="SecondType">The type of the second item to be linked.</typeparam>
/// <typeparam name="ThirdType">The type of the third item to be linked.</typeparam>
/// <typeparam name="FourthType">The type of the fourth item to be linked.</typeparam>
+ [Serializable]
public class Link4<FirstType, SecondType, ThirdType, FourthType>
{
private FirstType _first;
@@ -131,6 +136,7 @@ public Link4(FirstType first, SecondType second, ThirdType third, FourthType fou
/// <typeparam name="ThirdType">The type of the third item to be linked.</typeparam>
/// <typeparam name="FourthType">The type of the fourth item to be linked.</typeparam>
/// <typeparam name="FifthType">The type of the fifth item to be linked.</typeparam>
+ [Serializable]
public class Link5<FirstType, SecondType, ThirdType, FourthType, FifthType>
{
private FirstType _first;
View
22 SevenEngine/DataStructures/List.cs
@@ -48,6 +48,7 @@ public interface List<ValueType, FirstKeyType, SecondKeyType> : List<ValueType,
/// <summary>Implements a growing, singularly-linked list data structure that inherits InterfaceTraversable.</summary>
/// <typeparam name="InterfaceStringId">The type of objects to be placed in the list.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class ListLinked<Type> : List<Type>
{
#region ListLinkedNode
@@ -223,13 +224,13 @@ public Type[] ToArray()
}
/// <summary>Thread safe enterance for readers.</summary>
- protected void ReaderLock() { lock (_lock) { while (!(_writers == 0)) Monitor.Wait(_lock); _readers++; } }
+ protected void ReaderLock() { }// lock (_lock) { while (!(_writers == 0)) Monitor.Wait(_lock); _readers++; } }
/// <summary>Thread safe exit for readers.</summary>
- protected void ReaderUnlock() { lock (_lock) { _readers--; Monitor.Pulse(_lock); } }
+ protected void ReaderUnlock() { }// lock (_lock) { _readers--; Monitor.Pulse(_lock); } }
/// <summary>Thread safe enterance for writers.</summary>
- protected void WriterLock() { lock (_lock) { while (!(_writers == 0) && !(_readers == 0)) Monitor.Wait(_lock); _writers++; } }
+ protected void WriterLock() { } //lock (_lock) { while (!(_writers == 0) && !(_readers == 0)) Monitor.Wait(_lock); _writers++; } }
/// <summary>Thread safe exit for readers.</summary>
- protected void WriterUnlock() { lock (_lock) { _writers--; Monitor.PulseAll(_lock); } }
+ protected void WriterUnlock() { } //lock (_lock) { _writers--; Monitor.PulseAll(_lock); } }
/// <summary>This is used for throwing AVL Tree exceptions only to make debugging faster.</summary>
protected class ListLinkedException : Exception { public ListLinkedException(string message) : base(message) { } }
@@ -242,6 +243,7 @@ protected class ListLinkedException : Exception { public ListLinkedException(str
/// <summary>Implements a growing, singularly-linked list data structure that inherits InterfaceTraversable.</summary>
/// <typeparam name="InterfaceStringId">The type of objects to be placed in the list.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class ListLinked<ValueType, KeyType> : ListLinked<ValueType>, List<ValueType, KeyType>
{
protected Func<ValueType, KeyType, bool> _equalityFunction;
@@ -339,6 +341,7 @@ public void RemoveFirst(KeyType removalKey)
/// <summary>Implements a growing, singularly-linked list data structure that inherits InterfaceTraversable.</summary>
/// <typeparam name="InterfaceStringId">The type of objects to be placed in the list.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class ListLinked<ValueType, FirstKeyType, SecondKeyType> : ListLinked<ValueType, FirstKeyType>, List<ValueType, FirstKeyType, SecondKeyType>
{
protected Func<ValueType, SecondKeyType, bool> _secondequalityFunction;
@@ -445,6 +448,7 @@ public void RemoveFirstSecondGeneric(SecondKeyType removalKey)
/// data structure that inherits InterfaceTraversable.</summary>
/// <typeparam name="Type">The type of objects to be placed in the list.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class ListArray<Type> : List<Type>
{
protected Type[] _list;
@@ -715,13 +719,13 @@ public Type[] ToArray()
}
/// <summary>Thread safe enterance for readers.</summary>
- protected void ReaderLock() { lock (_lock) { while (!(_writers == 0)) Monitor.Wait(_lock); _readers++; } }
+ protected void ReaderLock() { } //lock (_lock) { while (!(_writers == 0)) Monitor.Wait(_lock); _readers++; } }
/// <summary>Thread safe exit for readers.</summary>
- protected void ReaderUnlock() { lock (_lock) { _readers--; Monitor.Pulse(_lock); } }
+ protected void ReaderUnlock() { } //lock (_lock) { _readers--; Monitor.Pulse(_lock); } }
/// <summary>Thread safe enterance for writers.</summary>
- protected void WriterLock() { lock (_lock) { while (!(_writers == 0) && !(_readers == 0)) Monitor.Wait(_lock); _writers++; } }
+ protected void WriterLock() { } //lock (_lock) { while (!(_writers == 0) && !(_readers == 0)) Monitor.Wait(_lock); _writers++; } }
/// <summary>Thread safe exit for readers.</summary>
- protected void WriterUnlock() { lock (_lock) { _writers--; Monitor.PulseAll(_lock); } }
+ protected void WriterUnlock() { } //lock (_lock) { _writers--; Monitor.PulseAll(_lock); } }
/// <summary>This is used for throwing AVL Tree exceptions only to make debugging faster.</summary>
protected class ListArrayException : Exception { public ListArrayException(string message) : base(message) { } }
@@ -735,6 +739,7 @@ protected class ListArrayException : Exception { public ListArrayException(strin
/// data structure that inherits InterfaceTraversable.</summary>
/// <typeparam name="Type">The type of objects to be placed in the list.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class ListArray<ValueType, KeyType> : ListArray<ValueType>, List<ValueType, KeyType>
{
protected Func<ValueType, KeyType, int> _keyComparisonFunction;
@@ -823,6 +828,7 @@ public void RemoveFirst(KeyType removal)
/// data structure that inherits InterfaceTraversable.</summary>
/// <typeparam name="Type">The type of objects to be placed in the list.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class ListArray<ValueType, FirstKeyType, SecondKeyType> : ListArray<ValueType, FirstKeyType>, List<ValueType, FirstKeyType>
{
protected Func<ValueType, SecondKeyType, int> _secondkeyComparisonFunction;
View
321 SevenEngine/DataStructures/Octree.cs
@@ -60,31 +60,13 @@ public interface Octree<ValueType, KeyType> : Octree<ValueType>
#region OctreeLinked
+ [Serializable]
public class OctreeLinked<ValueType, KeyType> : Octree<ValueType, KeyType>
where ValueType : IOctreeEntry
{
private Func<ValueType, ValueType, int> _valueComparisonFunction;
private Func<ValueType, KeyType, int> _keyComparisonFunction;
- #region OctreeLinkedBound
-
- /// <summary>Represents a bounding cube. Includes coordinates of the center
- /// and a scale of expansion along each axis.</summary>
- private class OctreeLinkedBound
- {
- private float _x, _y, _z, _scale;
-
- internal float X { get { return _x; } }
- internal float Y { get { return _y; } }
- internal float Z { get { return _z; } }
- internal float Scale { get { return _scale; } }
-
- internal OctreeLinkedBound(float x, float y, float z, float scale)
- { _x = x; _y = y; _z = z; _scale = scale; }
- }
-
- #endregion
-
#region OctreeLinkedNode
/// <summary>Represents a single node of the octree. Includes references both upwards and
@@ -110,60 +92,68 @@ internal OctreeLinkedNode(float x, float y, float z, float scale, OctreeLinkedBr
}
/// <summary>Finds the child index relative to "this" node given x, y, and z coordinates.</summary>
- internal int DetermineChild(float x, float y, float z)
+ static internal int DetermineChild(OctreeLinkedNode node, float x, float y, float z)
{
// Finds the child given an x, y, and z
// Possible child (all): 0, 1, 2, 3, 4, 5, 6, 7
- if (z < _z)
+ if (z < node.Z)
{
// Possible child: 0, 2, 4, 6
- if (y < _y)
+ if (y < node.Y)
// Possible child: 0, 4
- if (x < _x) return 0;
+ if (x < node.X) return 0;
else return 4;
else
// Possible child: 2, 6,
- if (x < _x) return 2;
+ if (x < node.X) return 2;
else return 6;
}
else
{
// Possible child: 1, 3, 5, 7
- if (y < _y)
+ if (y < node.Y)
// Possible child: 1, 5
- if (x < _x) return 1;
+ if (x < node.X) return 1;
else return 5;
else
// Possible child: 3, 7
- if (x < _x) return 3;
+ if (x < node.X) return 3;
else return 7;
}
}
/// <summary>Determins the bounds of a child node.</summary>
- internal OctreeLinkedBound DetermineChildBounds(int child)
+ static internal void DetermineChildBounds(OctreeLinkedNode node, int child, out float x, out float y, out float z, out float scale)
{
- float halfScale = _scale / 2;
+ float halfScale = node.Scale * .5f;
switch (child)
{
- case 0:
- return new OctreeLinkedBound(_x - halfScale, _y - halfScale, _z - halfScale, halfScale);
- case 1:
- return new OctreeLinkedBound(_x - halfScale, _y - halfScale, _z + halfScale, halfScale);
- case 2:
- return new OctreeLinkedBound(_x - halfScale, _y + halfScale, _z - halfScale, halfScale);
- case 3:
- return new OctreeLinkedBound(_x - halfScale, _y + halfScale, _z + halfScale, halfScale);
- case 4:
- return new OctreeLinkedBound(_x + halfScale, _y - halfScale, _z - halfScale, halfScale);
- case 5:
- return new OctreeLinkedBound(_x + halfScale, _y - halfScale, _z + halfScale, halfScale);
- case 6:
- return new OctreeLinkedBound(_x + halfScale, _y + halfScale, _z - halfScale, halfScale);
- case 7:
- return new OctreeLinkedBound(_x + halfScale, _y + halfScale, _z + halfScale, halfScale);
+ case 0: x = node.X - halfScale; y = node.Y - halfScale; z = node.Z - halfScale; scale = halfScale; return;
+ case 1: x = node.X - halfScale; y = node.Y - halfScale; z = node.Z + halfScale; scale = halfScale; return;
+ case 2: x = node.X - halfScale; y = node.Y + halfScale; z = node.Z - halfScale; scale = halfScale; return;
+ case 3: x = node.X - halfScale; y = node.Y + halfScale; z = node.Z + halfScale; scale = halfScale; return;
+ case 4: x = node.X + halfScale; y = node.Y - halfScale; z = node.Z - halfScale; scale = halfScale; return;
+ case 5: x = node.X + halfScale; y = node.Y - halfScale; z = node.Z + halfScale; scale = halfScale; return;
+ case 6: x = node.X + halfScale; y = node.Y + halfScale; z = node.Z - halfScale; scale = halfScale; return;
+ case 7: x = node.X + halfScale; y = node.Y + halfScale; z = node.Z + halfScale; scale = halfScale; return;
+ default: throw new OctreeLinkedException("There is a glitch in my octree, sorry...");
}
- throw new OctreeLinkedException("There is a glitch in my octree, sorry...");
+ }
+
+ static internal bool ContainsBounds(OctreeLinkedNode node, float xMin, float yMin, float zMin, float xMax, float yMax, float zMax)
+ {
+ return !(node == null ||
+ xMax < node.X - node.Scale || xMin > node.X + node.Scale ||
+ yMax < node.Y - node.Scale || yMin > node.Y + node.Scale ||
+ zMax < node.Z - node.Scale || zMin > node.Z + node.Scale);
+ }
+
+ static internal bool ContainsCoordinate(OctreeLinkedNode node, float x, float y, float z)
+ {
+ return !(node == null ||
+ x < node.X - node.Scale || x > node.X + node.Scale ||
+ y < node.Y - node.Scale || y > node.Y + node.Scale ||
+ z < node.Z - node.Scale || z > node.Z + node.Scale);
}
}
@@ -208,22 +198,80 @@ private class OctreeLinkedBranch : OctreeLinkedNode
// The children are indexed as follows (relative to this node's center):
// 0: (-x, -y, -z) 1: (-x, -y, z) 2: (-x, y, -z) 3: (-x, y, z)
// 4: (x, -y, -z) 5: (x, -y, z) 6: (x, y, -z) 7: (x, y, z)
- private OctreeLinkedNode[] _children;
+ //private OctreeLinkedNode[] _children;
+
+ private OctreeLinkedNode _child0;
+ private OctreeLinkedNode _child1;
+ private OctreeLinkedNode _child2;
+ private OctreeLinkedNode _child3;
+ private OctreeLinkedNode _child4;
+ private OctreeLinkedNode _child5;
+ private OctreeLinkedNode _child6;
+ private OctreeLinkedNode _child7;
+
+ public OctreeLinkedNode Child0 { get { return _child0; } }
+ public OctreeLinkedNode Child1 { get { return _child1; } }
+ public OctreeLinkedNode Child2 { get { return _child2; } }
+ public OctreeLinkedNode Child3 { get { return _child3; } }
+ public OctreeLinkedNode Child4 { get { return _child4; } }
+ public OctreeLinkedNode Child5 { get { return _child5; } }
+ public OctreeLinkedNode Child6 { get { return _child6; } }
+ public OctreeLinkedNode Child7 { get { return _child7; } }
+
+ public OctreeLinkedNode this[int index]
+ {
+ get
+ {
+ switch (index)
+ {
+ case 0: return _child0;
+ case 1: return _child1;
+ case 2: return _child2;
+ case 3: return _child3;
+ case 4: return _child4;
+ case 5: return _child5;
+ case 6: return _child6;
+ case 7: return _child7;
+ default: throw new OctreeLinkedException("index out of bounds.");
+ }
+ }
+ set
+ {
+ switch (index)
+ {
+ case 0: _child0 = value; break;
+ case 1: _child1 = value; break;
+ case 2: _child2 = value; break;
+ case 3: _child3 = value; break;
+ case 4: _child4 = value; break;
+ case 5: _child5 = value; break;
+ case 6: _child6 = value; break;
+ case 7: _child7 = value; break;
+ default: throw new OctreeLinkedException("index out of bounds.");
+ }
+ }
+ }
+
+ //internal OctreeLinkedNode[] Children { get { return _children; } }
- internal OctreeLinkedNode[] Children { get { return _children; } }
internal bool IsEmpty
{
get
{
- return _children[0] == null && _children[1] == null && _children[2] == null
- && _children[3] == null && _children[4] == null && _children[5] == null
- && _children[6] == null && _children[7] == null;
+ //return _children[0] == null && _children[1] == null && _children[2] == null
+ // && _children[3] == null && _children[4] == null && _children[5] == null
+ // && _children[6] == null && _children[7] == null;
+ return _child0 == null && _child1 == null && _child2 == null
+ && _child3 == null && _child4 == null && _child5== null
+ && _child6 == null && _child7 == null;
}
}
internal OctreeLinkedBranch(float x, float y, float z, float scale, OctreeLinkedBranch parent)
: base(x, y, z, scale, parent)
- { _children = new OctreeLinkedNode[8]; }
+ {
+ //_children = new OctreeLinkedNode[8];
+ }
}
#endregion
@@ -319,7 +367,7 @@ private OctreeLinkedLeaf Add(ValueType addition, OctreeLinkedNode octreeNode)
if (parent == null)
growth = (OctreeLinkedBranch)(_top = new OctreeLinkedBranch(_top.X, _top.Y, _top.Z, _top.Scale, null));
else
- growth = GrowBranch(parent, parent.DetermineChild(addition.Position.X, addition.Position.Y, addition.Position.Z));
+ growth = GrowBranch(parent, OctreeLinkedNode.DetermineChild(parent, addition.Position.X, addition.Position.Y, addition.Position.Z));
foreach (ValueType entry in leaf.Contents)
_referenceDatabase.GetSecondGeneric(entry).Leaf = Add(entry, growth);
return Add(addition, growth);
@@ -329,32 +377,34 @@ private OctreeLinkedLeaf Add(ValueType addition, OctreeLinkedNode octreeNode)
else
{
OctreeLinkedBranch branch = (OctreeLinkedBranch)octreeNode;
- int child = branch.DetermineChild(addition.Position.X, addition.Position.Y, addition.Position.Z);
+ int child = OctreeLinkedNode.DetermineChild(branch, addition.Position.X, addition.Position.Y, addition.Position.Z);
// If the leaf is null, we must grow one before attempting to add to it
- if (branch.Children[child] == null)
+ if (branch[child] == null)
return GrowLeaf(branch, child).Add(addition);
- return Add(addition, branch.Children[child]);
+ return Add(addition, branch[child]);
}
}
// Grows a branch on the tree at the desired location
private OctreeLinkedBranch GrowBranch(OctreeLinkedBranch branch, int child)
{
- OctreeLinkedBound childBounds = branch.DetermineChildBounds(child);
- branch.Children[child] =
- new OctreeLinkedBranch(childBounds.X, childBounds.Y, childBounds.Z, childBounds.Scale, branch);
- return (OctreeLinkedBranch)branch.Children[child];
+ // values for the new node
+ float x, y, z, scale;
+ OctreeLinkedNode.DetermineChildBounds(branch, child, out x, out y, out z, out scale);
+ branch[child] = new OctreeLinkedBranch(x, y, z, scale, branch);
+ return (OctreeLinkedBranch)branch[child];
}
// Grows a leaf on the tree at the desired location
private OctreeLinkedLeaf GrowLeaf(OctreeLinkedBranch branch, int child)
{
- if (branch.Children[child] != null)
+ if (branch[child] != null)
throw new OctreeLinkedException("My octree has a glitched, sorry.");
- OctreeLinkedBound childBounds = branch.DetermineChildBounds(child);
- branch.Children[child] =
- new OctreeLinkedLeaf(childBounds.X, childBounds.Y, childBounds.Z, childBounds.Scale, branch, _branchFactor);
- return (OctreeLinkedLeaf)branch.Children[child];
+ // values for new node
+ float x, y, z, scale;
+ OctreeLinkedNode.DetermineChildBounds(branch, child, out x, out y, out z, out scale);
+ branch[child] = new OctreeLinkedLeaf(x, y, z, scale, branch, _branchFactor);
+ return (OctreeLinkedLeaf)branch[child];
}
/// <summary>Removes an item from the octree by the id that was assigned to it.</summary>
@@ -382,26 +432,26 @@ private void Remove(KeyType key, OctreeLinkedLeaf leaf)
break;
}
}
- else PluckLeaf(leaf.Parent, leaf.Parent.DetermineChild(leaf.X, leaf.Y, leaf.Z));
+ else PluckLeaf(leaf.Parent, OctreeLinkedNode.DetermineChild(leaf.Parent, leaf.X, leaf.Y, leaf.Z));
}
private void PluckLeaf(OctreeLinkedBranch branch, int child)
{
- if (!(branch.Children[child] is OctreeLinkedLeaf) || ((OctreeLinkedLeaf)branch.Children[child]).Count > 1)
+ if (!(branch[child] is OctreeLinkedLeaf) || ((OctreeLinkedLeaf)branch[child]).Count > 1)
throw new OctreeLinkedException("There is a glitch in my octree, sorry.");
- branch.Children[child] = null;
+ branch[child] = null;
while (branch.IsEmpty)
{
- ChopBranch(branch.Parent, branch.Parent.DetermineChild(branch.X, branch.Y, branch.Z));
+ ChopBranch(branch.Parent, OctreeLinkedNode.DetermineChild(branch.Parent, branch.X, branch.Y, branch.Z));
branch = branch.Parent;
}
}
private void ChopBranch(OctreeLinkedBranch branch, int child)
{
- if (branch.Children[child] == null)
+ if (branch[child] == null)
throw new OctreeLinkedException("There is a glitch in my octree, sorry...");
- branch.Children[child] = null;
+ branch[child] = null;
}
/// <summary>Moves an existing item from one position to another.</summary>
@@ -474,14 +524,14 @@ private bool TraverseBreakable(Func<ValueType, bool> traversalFunctionBreakable,
{
// The current node is a branch
OctreeLinkedBranch branch = (OctreeLinkedBranch)octreeNode;
- if (!TraverseBreakable(traversalFunctionBreakable, branch.Children[0])) return false;
- if (!TraverseBreakable(traversalFunctionBreakable, branch.Children[1])) return false;
- if (!TraverseBreakable(traversalFunctionBreakable, branch.Children[2])) return false;
- if (!TraverseBreakable(traversalFunctionBreakable, branch.Children[3])) return false;
- if (!TraverseBreakable(traversalFunctionBreakable, branch.Children[4])) return false;
- if (!TraverseBreakable(traversalFunctionBreakable, branch.Children[5])) return false;
- if (!TraverseBreakable(traversalFunctionBreakable, branch.Children[6])) return false;
- if (!TraverseBreakable(traversalFunctionBreakable, branch.Children[7])) return false;
+ if (!TraverseBreakable(traversalFunctionBreakable, branch.Child0)) return false;
+ if (!TraverseBreakable(traversalFunctionBreakable, branch.Child1)) return false;
+ if (!TraverseBreakable(traversalFunctionBreakable, branch.Child2)) return false;
+ if (!TraverseBreakable(traversalFunctionBreakable, branch.Child3)) return false;
+ if (!TraverseBreakable(traversalFunctionBreakable, branch.Child4)) return false;
+ if (!TraverseBreakable(traversalFunctionBreakable, branch.Child5)) return false;
+ if (!TraverseBreakable(traversalFunctionBreakable, branch.Child6)) return false;
+ if (!TraverseBreakable(traversalFunctionBreakable, branch.Child7)) return false;
}
}
return true;
@@ -506,14 +556,14 @@ private void Traverse(Action<ValueType> traversalFunction, OctreeLinkedNode octr
{
// The current node is a branch
OctreeLinkedBranch branch = (OctreeLinkedBranch)octreeNode;
- Traverse(traversalFunction, branch.Children[0]);
- Traverse(traversalFunction, branch.Children[1]);
- Traverse(traversalFunction, branch.Children[2]);
- Traverse(traversalFunction, branch.Children[3]);
- Traverse(traversalFunction, branch.Children[4]);
- Traverse(traversalFunction, branch.Children[5]);
- Traverse(traversalFunction, branch.Children[6]);
- Traverse(traversalFunction, branch.Children[7]);
+ Traverse(traversalFunction, branch.Child0);
+ Traverse(traversalFunction, branch.Child1);
+ Traverse(traversalFunction, branch.Child2);
+ Traverse(traversalFunction, branch.Child3);
+ Traverse(traversalFunction, branch.Child4);
+ Traverse(traversalFunction, branch.Child5);
+ Traverse(traversalFunction, branch.Child6);
+ Traverse(traversalFunction, branch.Child7);
}
}
}
@@ -549,18 +599,39 @@ private bool TraverseBreakable(Func<ValueType, bool> traversalFunction, OctreeLi
}
else
{
- // The current node is a branch
- foreach (OctreeLinkedNode node in ((OctreeLinkedBranch)octreeNode).Children)
- {
- if (node == null) continue;
- else if (xMax < node.X - node.Scale) continue;
- else if (yMax < node.Y - node.Scale) continue;
- else if (zMax < node.Z - node.Scale) continue;
- else if (xMin > node.X + node.Scale) continue;
- else if (yMin > node.Y + node.Scale) continue;
- else if (zMin > node.Z + node.Scale) continue;
- if (!TraverseBreakable(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax)) return false;
- }
+ OctreeLinkedBranch branch = (OctreeLinkedBranch)octreeNode;
+ OctreeLinkedNode node = branch.Child0;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ if (!TraverseBreakable(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax))
+ return false;
+ node = branch.Child1;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ if (!TraverseBreakable(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax))
+ return false;
+ node = branch.Child2;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ if (!TraverseBreakable(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax))
+ return false;
+ node = branch.Child3;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ if (!TraverseBreakable(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax))
+ return false;
+ node = branch.Child4;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ if (!TraverseBreakable(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax))
+ return false;
+ node = branch.Child5;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ if (!TraverseBreakable(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax))
+ return false;
+ node = branch.Child6;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ if (!TraverseBreakable(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax))
+ return false;
+ node = branch.Child7;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ if (!TraverseBreakable(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax))
+ return false;
}
}
return true;
@@ -579,7 +650,6 @@ private void Traverse(Action<ValueType> traversalFunction, OctreeLinkedNode octr
if (octreeNode is OctreeLinkedLeaf)
{
foreach (ValueType entry in ((OctreeLinkedLeaf)octreeNode).Contents)
- //if (!traversalFunction(item)) return false;
if (entry != null &&
entry.Position.X > xMin && entry.Position.X < xMax
&& entry.Position.Y > yMin && entry.Position.Y < yMax
@@ -588,18 +658,31 @@ private void Traverse(Action<ValueType> traversalFunction, OctreeLinkedNode octr
}
else
{
- // The current node is a branch
- foreach (OctreeLinkedNode node in ((OctreeLinkedBranch)octreeNode).Children)
- {
- if (node == null) continue;
- else if (xMax < node.X - node.Scale) continue;
- else if (yMax < node.Y - node.Scale) continue;
- else if (zMax < node.Z - node.Scale) continue;
- else if (xMin > node.X + node.Scale) continue;
- else if (yMin > node.Y + node.Scale) continue;
- else if (zMin > node.Z + node.Scale) continue;
+ OctreeLinkedBranch branch = (OctreeLinkedBranch)octreeNode;
+ OctreeLinkedNode node = branch.Child0;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ Traverse(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax);
+ node = branch.Child1;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ Traverse(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax);
+ node = branch.Child2;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ Traverse(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax);
+ node = branch.Child3;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ Traverse(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax);
+ node = branch.Child4;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ Traverse(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax);
+ node = branch.Child5;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ Traverse(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax);
+ node = branch.Child6;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
+ Traverse(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax);
+ node = branch.Child7;
+ if (OctreeLinkedNode.ContainsBounds(node, xMin, yMin, zMin, xMax, yMax, zMax))
Traverse(traversalFunction, node, xMin, yMin, zMin, xMax, yMax, zMax);
- }
}
}
}
@@ -629,14 +712,14 @@ private void ToArray(OctreeLinkedNode octreeNode, ValueType[] array, int entryIn
{
// The current node is a branch
OctreeLinkedBranch branch = (OctreeLinkedBranch)octreeNode;
- ToArray(branch.Children[0], array, entryIndex, out entryIndex);
- ToArray(branch.Children[1], array, entryIndex, out entryIndex);
- ToArray(branch.Children[2], array, entryIndex, out entryIndex);
- ToArray(branch.Children[3], array, entryIndex, out entryIndex);
- ToArray(branch.Children[4], array, entryIndex, out entryIndex);
- ToArray(branch.Children[5], array, entryIndex, out entryIndex);
- ToArray(branch.Children[6], array, entryIndex, out entryIndex);
- ToArray(branch.Children[7], array, entryIndex, out entryIndex);
+ ToArray(branch.Child0, array, entryIndex, out entryIndex);
+ ToArray(branch.Child1, array, entryIndex, out entryIndex);
+ ToArray(branch.Child2, array, entryIndex, out entryIndex);
+ ToArray(branch.Child3, array, entryIndex, out entryIndex);
+ ToArray(branch.Child4, array, entryIndex, out entryIndex);
+ ToArray(branch.Child5, array, entryIndex, out entryIndex);
+ ToArray(branch.Child6, array, entryIndex, out entryIndex);
+ ToArray(branch.Child7, array, entryIndex, out entryIndex);
returnIndex = entryIndex;
}
}
View
130 SevenEngine/DataStructures/Quadtree.cs
@@ -1,12 +1,118 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace SevenEngine.DataStructures
-{
- //public class Quadtree
- //{
- // Still in progress
- //}
-}
+//// SEVENENGINE LISCENSE:
+//// You are free to use, modify, and distribute any or all code segments/files for any purpose
+//// including commercial use under the following condition: any code using or originally taken
+//// from the SevenEngine project must include citation to its original author(s) located at the
+//// top of each source code file, or you may include a reference to the SevenEngine project as
+//// a whole but you must include the current SevenEngine official website URL and logo.
+//// - Thanks. :) (support: seven@sevenengine.com)
+
+//// Author(s):
+//// - Zachary Aaron Patten (aka Seven) seven@sevenengine.com
+//// Last Edited: 11-16-13
+
+//using System;
+//using SevenEngine.Mathematics;
+
+//namespace SevenEngine.DataStructures
+//{
+// /// <summary>Implementing classes contain a vector indicating X and Y position coordinates.</summary>
+// public interface IQuadTreeEntry
+// {
+// /// <summary>Indicates an object's X and Y position coordinates.</summary>
+// Vector Position { get; set; }
+// }
+
+// [Serializable]
+// public class QuadtreeLinked<ValueType, KeyType>
+// {
+// #region QuadtreeLinkedNode
+
+// public class QuadtreeLinkedNode<Type>
+// where Type : IQuadTreeEntry
+// {
+// private float _minX, _minY, _maxX, _maxY;
+// private QuadtreeLinkedNode<Type> _child0, _child1, _child2, _child3;
+
+// public float MinX { get { return _minX; } set { _minX = value; } }
+// public float MinY { get { return _minY; } set { _minY = value; } }
+// public float MaxX { get { return _maxX; } set { _maxX = value; } }
+// public float MaxY { get { return _maxY; } set { _maxY = value; } }
+
+// public QuadtreeLinkedNode<Type> Child0 { get { return _child0; } set { _child0 = value; } }
+// public QuadtreeLinkedNode<Type> Child1 { get { return _child1; } set { _child1 = value; } }
+// public QuadtreeLinkedNode<Type> Child2 { get { return _child2; } set { _child2 = value; } }
+// public QuadtreeLinkedNode<Type> Child3 { get { return _child3; } set { _child3 = value; } }
+
+// public QuadtreeLinkedNode(float minX, float minY, float maxX, float maxY)
+// {
+// _minX = minX;
+// _minY = minY;
+// _maxX = maxX;
+// _maxY = maxY;
+// }
+// }
+
+// #endregion
+
+// #region QuadtreeLinkedBranch
+
+// public class QuadtreeLinkedBranch<Type> : QuadtreeLinkedNode<Type>
+// where Type : IQuadTreeEntry
+// {
+// private float _minX, _minY, _maxX, _maxY;
+// private QuadtreeLinkedNode<Type> _child0, _child1, _child2, _child3;
+
+// public QuadtreeLinkedNode<Type> Child0 { get { return _child0; } set { _child0 = value; } }
+// public QuadtreeLinkedNode<Type> Child1 { get { return _child1; } set { _child1 = value; } }
+// public QuadtreeLinkedNode<Type> Child2 { get { return _child2; } set { _child2 = value; } }
+// public QuadtreeLinkedNode<Type> Child3 { get { return _child3; } set { _child3 = value; } }
+
+// public QuadtreeLinkedBranch(float minX, float minY, float maxX, float maxY)
+// : base(minX, minY, maxX, maxY) { }
+// }
+
+// #endregion
+
+// #region QuadtreeLinkedLeaf
+
+// public class QuadtreeLinkedLeaf<Type> : QuadtreeLinkedNode<Type>
+// where Type : IQuadTreeEntry
+// {
+// private Type[] _contents;
+
+// public Type[] Contents { get { return _contents; } }
+
+// public QuadtreeLinkedLeaf(float minX, float minY, float maxX, float maxY, int branchFactor)
+// : base(minX, minY, maxX, maxY) { _contents = new Type[branchFactor]; }
+// }
+
+// #endregion
+
+// #region OctreeLinkedReference
+
+// private class QuadtreeLinkedReference<Type>
+// {
+// private ValueType _value;
+// private QuadtreeLinkedLeaf<ValueType> _leaf;
+
+// internal ValueType Value { get { return _value; } set { _value = value; } }
+// internal QuadtreeLinkedLeaf<ValueType> Leaf { get { return _leaf; } set { _leaf = value; } }
+
+// internal QuadtreeLinkedReference<>(ValueType value, QuadtreeLinkedLeaf<ValueType> leaf) { _value = value; _leaf = leaf; }
+// }
+
+// #endregion
+
+// private int _branchFactor;
+// private int _count;
+// private AvlTree<QuadtreeLinkedReference, KeyType, ValueType> _referenceDatabase;
+// private QuadtreeLinkedNode<ValueType> _top;
+
+// private object _lock;
+// private int _readers;
+// private int _writers;
+
+// public int Count { get { return _count; } }
+// public bool IsEmpty { get { return _count == 0; } }
+// }
+//}
View
2  SevenEngine/DataStructures/Queue.cs
@@ -30,6 +30,7 @@ public interface Queue<Type> : DataStructure<Type>
/// <summary>Implements First-In-First-Out queue data structure that inherits InterfaceTraversable.</summary>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class QueueLinked<Type> : Queue<Type>
{
#region QueueNode
@@ -199,6 +200,7 @@ private class QueueException : Exception { public QueueException(string message)
/// data structure that inherits InterfaceTraversable.</summary>
/// <typeparam name="Type">The type of objects to be placed in the list.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class QueueArray<Type> : Queue<Type>
{
private Type[] _queue;
View
1  SevenEngine/DataStructures/RedBlackTree.cs
@@ -50,6 +50,7 @@ public interface RedBlackTree<ValueType, FirstKeyType, SecondKeyType> : RedBlack
#region RedBlackTreeLinked
+ [Serializable]
public class RedBlackTreeLinked<ValueType> : RedBlackTree<ValueType>
{
protected const bool Red = true;
View
5 SevenEngine/DataStructures/Stack.cs
@@ -29,6 +29,7 @@ public interface Stack<Type> : DataStructure<Type>
/// <typeparam name="Type">The generic type within the structure.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.
/// Seven (Zachary Patten) 10-12-13.</remarks>
+ [Serializable]
public class StackLinked<Type> : Stack<Type>
{
#region StackLinkedNode
@@ -187,10 +188,10 @@ private class StackLinkedException : Exception { public StackLinkedException(str
#region StackArray
- /// <summary>Implements a growing list as an array (with expansions/contractions)
- /// data structure that inherits InterfaceTraversable.</summary>
+ /// <summary>Implements a growing stack as an array (with expansions/contractions) data structure.</summary>
/// <typeparam name="Type">The type of objects to be placed in the list.</typeparam>
/// <remarks>The runtimes of each public member are included in the "remarks" xml tags.</remarks>
+ [Serializable]
public class StackArray<Type> : Stack<Type>
{
private Type[] _stack;
View
14 SevenEngine/DynamicModels/Animation.cs
@@ -0,0 +1,14 @@
+using System;
+using SevenEngine.DataStructures;
+
+namespace SevenEngine.DynamicModels
+{
+ public class Animation
+ {
+ private string _id;
+ private float length; // length in seconds
+ private ListArray<KeyFrame> _frames;
+
+
+ }
+}
View
16 SevenEngine/DynamicModels/DynamicModel.cs
@@ -1,7 +1,15 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+// SEVENENGINE LISCENSE:
+// You are free to use, modify, and distribute any or all code segments/files for any purpose
+// including commercial use under the following condition: any code using or originally taken
+// from the SevenEngine project must include citation to its original author(s) located at the
+// top of each source code file, or you may include a reference to the SevenEngine project as
+// a whole but you must include the current SevenEngine official website URL and logo.
+// - Thanks. :) (support: seven@sevenengine.com)
+
+// Author(s):
+// - Zachary Aaron Patten (aka Seven) seven@sevenengine.com
+
+using SevenEngine.DataStructures;
namespace SevenEngine.DynamicModels
{
View
26 SevenEngine/Physics/Substance.cs → SevenEngine/DynamicModels/KeyFrame.cs
@@ -8,19 +8,25 @@
// Author(s):
// - Zachary Aaron Patten (aka Seven) seven@sevenengine.com
-// Last Edited: 11-28-13
+// Last Edited: 11-16-13
using System;
+using SevenEngine.Mathematics;
+using SevenEngine.DataStructures;
-namespace SevenEngine.Physics
+namespace SevenEngine.DynamicModels
{
- public class Substance
+ public class KeyFrame
{
- protected float _density;
- protected float _magnetism;
- protected float _radioactivity;
- protected float _conductivity;
- protected float _integrity;
- protected float _elasticity;
+ private float _start, _end; // seconds
+ private ListArray<Matrix> _tranformations;
+
+ public float Start { get { return _start; } }
+ public float End { get { return _end; } }
+
+ public KeyFrame(ListArray<Matrix> transformations)
+ {
+
+ }
}
-}
+}
View
2  SevenEngine/MANAGERS/ShaderManager.cs
@@ -301,7 +301,7 @@ internal static void SetUpBuiltInShaders()
// Transform Vertex Shader
int transformVertexShaderHandle = GL.CreateShader(ShaderType.VertexShader);
- GL.ShaderSource(transformVertexShaderHandle, VertexShader.Transform);
+ GL.ShaderSource(transformVertexShaderHandle, VertexShader.FTransform);
GL.CompileShader(transformVertexShaderHandle);
VertexShader transformVertexShader =
new VertexShader("VertexShaderTransform", "Built-In", transformVertexShaderHandle);
View
47 SevenEngine/MANAGERS/StaticModelManager.cs
@@ -24,8 +24,8 @@ namespace SevenEngine
/// <summary>StaticModelManager is used for rigid-body model management (loading, storing, hardware instance controling, and disposing).</summary>
public static class StaticModelManager
{
- private static AvlTree<StaticMeshInstance, string> _staticMeshDatabase =
- new AvlTreeLinked<StaticMeshInstance, string>(StaticMeshInstance.CompareTo, StaticMeshInstance.CompareTo);
+ private static AvlTree<StaticMesh, string> _staticMeshDatabase =
+ new AvlTreeLinked<StaticMesh, string>(StaticMesh.CompareTo, StaticMesh.CompareTo);
private static AvlTree<StaticModel, string> _staticModelDatabase =
new AvlTreeLinked<StaticModel, string>(StaticModel.CompareTo, StaticModel.CompareTo);
@@ -39,9 +39,9 @@ public static class StaticModelManager
/// <returns>The desired static mesh if it exists.</returns>
public static StaticMesh GetMesh(string staticMeshId)
{
- StaticMeshInstance mesh = _staticMeshDatabase.Get(staticMeshId);
+ StaticMesh mesh = _staticMeshDatabase.Get(staticMeshId);
mesh.ExistingReferences++;
- return new StaticMesh(mesh.Id, null, mesh);
+ return mesh;
}
/// <summary>Gets a static model you loaded that you have loaded.</summary>
@@ -56,20 +56,13 @@ public static StaticModel GetModel(string staticModelId)
(StaticMesh mesh) =>
{
mesh.Texture.ExistingReferences++;
- mesh.StaticMeshInstance.ExistingReferences++;
- meshes.Add(new StaticMesh(mesh.Id, mesh.Texture, mesh.StaticMeshInstance));
+ mesh.ExistingReferences++;
+ meshes.Add(mesh);
}
);
return new StaticModel(modelToGet.Id, meshes);
}
- private static void CopyMeshes(StaticMesh mesh, ListLinked<StaticMesh, string> meshes)
- {
- mesh.Texture.ExistingReferences++;
- mesh.StaticMeshInstance.ExistingReferences++;
- meshes.Add(new StaticMesh(mesh.Id, mesh.Texture, mesh.StaticMeshInstance));
- }
-
#region Parsers
/// <summary>Loads an 3d model file. NOTE that only obj files are currently supported.</summary>
@@ -104,38 +97,37 @@ public static void RemoveModel(string staticMeshId)
{
// Get the struct with the GPU mappings.
StaticMesh mesh = GetMesh(staticMeshId);
- StaticMeshInstance meshInstance = mesh.StaticMeshInstance;
// If the game tries to remove a texture that still has active references then
// lets warn them.
- if (meshInstance.ExistingReferences > 1)
+ if (mesh.ExistingReferences > 1)
Output.WriteLine("WARNING: texture removal \"" + staticMeshId + "\" still has active references.");
// Delete the vertex buffer if it exists.
- int vertexBufferId = meshInstance.VertexBufferHandle;
+ int vertexBufferId = mesh.VertexBufferHandle;
if (vertexBufferId != 0)
GL.DeleteBuffers(1, ref vertexBufferId);
// Delete the normal buffer if it exists.
- int normalbufferId = meshInstance.NormalBufferHandle;
+ int normalbufferId = mesh.NormalBufferHandle;
if (normalbufferId != 0)
GL.DeleteBuffers(1, ref normalbufferId);
// Delete the color buffer if it exists.
- int colorBufferId = meshInstance.ColorBufferHandle;
+ int colorBufferId = mesh.ColorBufferHandle;
if (colorBufferId != 0)
GL.DeleteBuffers(1, ref colorBufferId);
// Delete the texture coordinate buffer if it exists.
- int textureCoordinateBufferId = meshInstance.TextureCoordinateBufferHandle;
+ int textureCoordinateBufferId = mesh.TextureCoordinateBufferHandle;
if (textureCoordinateBufferId != 0)
GL.DeleteBuffers(1, ref textureCoordinateBufferId);
// Delete the element buffer if it exists.
- int elementBufferId = meshInstance.ElementBufferHandle;
+ int elementBufferId = mesh.ElementBufferHandle;
if (elementBufferId != 0)
GL.DeleteBuffers(1, ref elementBufferId);
// Now we can remove it from the dictionary.
_staticMeshDatabase.Remove(staticMeshId);
}
- private static StaticMeshInstance LoadObj(string staticMeshId, string filePath)
+ private static StaticMesh LoadObj(string staticMeshId, string filePath)
{
// These are temporarily needed lists for storing the parsed data as you read it.
// Its better to use "ListArrays" vs "Lists" because they will be accessed by indeces
@@ -334,7 +326,7 @@ private static StaticMeshInstance LoadObj(string staticMeshId, string filePath)
}
else { normalBufferId = 0; }
- return new StaticMeshInstance(
+ return new StaticMesh(
filePath,
staticMeshId,
vertexBufferId,
@@ -342,7 +334,8 @@ private static StaticMeshInstance LoadObj(string staticMeshId, string filePath)
textureCoordinateBufferId,
normalBufferId,
0, // I don't support an index buffer at this time
- verteces.Length);
+ verteces.Length,
+ null);
}
/// <summary>DONT USE THIS FUNCTION!!! This is an experimental file type I may use in the future.</summary>
@@ -582,18 +575,16 @@ public static StaticModel LoadSevenModelFromDisk(string staticModelId, string fi
else { normalBufferId = 0; }
meshes.Add(
- new StaticMesh(
+ new StaticMesh(
meshName,
- texture,
- new StaticMeshInstance(
- filePath,
staticModelId + "sub" + meshes.Count,
vertexBufferId,
0, // Obj files don't support vertex colors
textureCoordinateBufferId,
normalBufferId,
0, // I don't support an index buffer at this time
- verteces.Length)));
+ verteces.Length,
+ texture));
fileVerteces.Clear();
fileNormals.Clear();
fileTextureCoordinates.Clear();
View
193 SevenEngine/Mathematics/Matrix.cs
@@ -310,7 +310,7 @@ public static Matrix Factory3x3RotationZthenYthenX(float angleX, float angleY, f
/// <summary>Automatically converts a matrix into a float[,] if necessary.</summary>
/// <param name="matrix">The matrix to convert to a float[,].</param>
/// <returns>The reference to the float[,] representing the matrix.</returns>
- public static implicit operator float[](Matrix matrix) { return matrix.Floats; }
+ //public static implicit operator float[](Matrix matrix) { return matrix.Floats; }
/// <summary>Negates all the values in this matrix.</summary>
/// <returns>The resulting matrix after the negations.</returns>
@@ -367,12 +367,13 @@ public static Matrix Factory3x3RotationZthenYthenX(float angleX, float angleY, f
/// <returns>The resulting matrix after the negations.</returns>
public static Matrix Negate(Matrix matrix)
{
- float[] result = new float[matrix.Floats.Length];
- Buffer.BlockCopy(matrix.Floats, 0, result, 0, matrix.Floats.Length * sizeof(float));
- int length = result.Length;
+ Matrix result = new Matrix(matrix.Rows, matrix.Columns, matrix.Floats);
+ float[] resultFloats = result.Floats;
+ float[] matrixFloats = matrix.Floats;
+ int length = resultFloats.Length;
for (int i = 0; i < length; i++)
- result[i] = -result[i];
- return new Matrix(matrix.Rows, matrix.Columns, result);
+ resultFloats[i] = -matrixFloats[i];
+ return result;
}
/// <summary>Does standard addition of two matrices.</summary>
@@ -383,15 +384,15 @@ public static Matrix Add(Matrix left, Matrix right)
{
if (left.Rows != right.Rows || left.Columns != right.Columns)
throw new MatrixException("invalid addition (size miss-match).");
-
- //float[] result = (float[])left.Floats.Clone();
- float[] result = new float[left.Floats.Length];
- Buffer.BlockCopy(left.Floats, 0, result, 0, left.Floats.Length * sizeof(float));
- float[] rightFloats = right.Floats;
- int length = result.Length;
+ Matrix result = new Matrix(left.Rows, left.Columns);
+ float[]
+ resultFloats = result.Floats,
+ leftFloats = left.Floats,
+ rightFloats = right.Floats;
+ int length = resultFloats.Length;
for (int i = 0; i < length; i++)
- result[i] += rightFloats[i];
- return new Matrix(left.Rows, left.Columns, result);
+ resultFloats[i] = leftFloats[i] + rightFloats[i];
+ return result;
}
/// <summary>Subtracts a scalar from all the values in a matrix.</summary>
@@ -402,14 +403,14 @@ public static Matrix Subtract(Matrix left, Matrix right)
{
if (left.Rows != right.Rows || left.Columns != right.Columns)
throw new MatrixException("invalid subtraction (size miss-match).");
- //float[] result = (float[])left.Floats.Clone();
- float[] result = new float[left.Floats.Length];
- Buffer.BlockCopy(left.Floats, 0, result, 0, left.Floats.Length * sizeof(float));
- float[] rightFloats = right.Floats;
- int length = result.Length;
+ Matrix result = new Matrix(left.Rows, left.Columns);
+ float[] resultFloats = result.Floats,
+ leftFloats = left.Floats,
+ rightFloats = right.Floats;
+ int length = resultFloats.Length;
for (int i = 0; i < length; i++)
- result[i] -= rightFloats[i];
- return new Matrix(left.Rows, left.Columns, result);
+ resultFloats[i] = leftFloats[i] - rightFloats[i];
+ return result;
}
/// <summary>Does a standard (triple for looped) multiplication between matrices.</summary>
@@ -418,16 +419,16 @@ public static Matrix Subtract(Matrix left, Matrix right)
/// <returns>The resulting matrix of the multiplication.</returns>
public static Matrix Multiply(Matrix left, Matrix right)
{
- float[] leftFloats = left.Floats, rightFloats = right.Floats, result;
+ float[] leftFloats = left.Floats, rightFloats = right.Floats, resultFloats;
int leftRows = left.Rows, leftCols = left.Columns, rightRows = right.Rows, rightCols = right.Columns;
-
+ Matrix result = new Matrix(leftRows, rightCols);
+ resultFloats = result.Floats;
#region Optimizations
-
if (leftRows < 5)
{
if (leftRows == 4 && leftCols == 4 && rightRows == 4 && rightCols == 4)
{
- result = new float[16];
+ resultFloats = new