Add project files.
6
VoxelIsometricRenderer/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
22
VoxelIsometricRenderer/Program.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VoxelIsometricRenderer
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Terrain4());
|
||||
}
|
||||
}
|
||||
}
|
||||
33
VoxelIsometricRenderer/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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("VoxelIsometricRenderer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("VoxelIsometricRenderer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2026")]
|
||||
[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("bc07c626-47cc-41d7-bf64-e0842741c697")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
303
VoxelIsometricRenderer/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,303 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VoxelIsometricRenderer.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <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", "17.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 (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VoxelIsometricRenderer.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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap _16xDefaultTile {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("_16xDefaultTile", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap BlueSquare {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("BlueSquare", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ColourEdges {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ColourEdges", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap dirt {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("dirt", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap flower {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("flower", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap grasside {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("grasside", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap grassmed {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("grassmed", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap grasstall {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("grasstall", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap grasstop {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("grasstop", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap greenSquare {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("greenSquare", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap leaves {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("leaves", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap log {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("log", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap logtop {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("logtop", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap OrangeSquare {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("OrangeSquare", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ore1 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ore1", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap PinkSquare {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("PinkSquare", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap RedSquare {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("RedSquare", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap spruceleaves {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("spruceleaves", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap sprucelog {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("sprucelog", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap stone1 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("stone1", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap stone2 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("stone2", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap stone3 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("stone3", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap vine {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("vine", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap YellowSquare {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("YellowSquare", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
193
VoxelIsometricRenderer/Properties/Resources.resx
Normal file
@@ -0,0 +1,193 @@
|
||||
<?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>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="BlueSquare" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\BlueSquare.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ColourEdges" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ColourEdges.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="dirt" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\dirt.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="flower" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\flower.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="grasside" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\grasside.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="grassmed" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\grassmed.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="grasstall" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\grasstall.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="grasstop" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\grasstop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="greenSquare" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\greenSquare.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="leaves" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\leaves.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="log" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\log.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="logtop" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\logtop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="OrangeSquare" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\OrangeSquare.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ore1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ore1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="PinkSquare" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\PinkSquare.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="RedSquare" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\RedSquare.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="spruceleaves" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\spruceleaves.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="sprucelog" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\sprucelog.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="stone1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\stone1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="stone2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\stone2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="stone3" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\stone3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="vine" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\vine.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="YellowSquare" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\YellowSquare.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="_16xDefaultTile" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\16xDefaultTile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
30
VoxelIsometricRenderer/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VoxelIsometricRenderer.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
VoxelIsometricRenderer/Properties/Settings.settings
Normal file
@@ -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>
|
||||
BIN
VoxelIsometricRenderer/Resources/16xDefaultTile.png
Normal file
|
After Width: | Height: | Size: 117 B |
BIN
VoxelIsometricRenderer/Resources/BlueSquare.png
Normal file
|
After Width: | Height: | Size: 111 B |
BIN
VoxelIsometricRenderer/Resources/ColourEdges.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
VoxelIsometricRenderer/Resources/OrangeSquare.png
Normal file
|
After Width: | Height: | Size: 111 B |
BIN
VoxelIsometricRenderer/Resources/PinkSquare.png
Normal file
|
After Width: | Height: | Size: 111 B |
BIN
VoxelIsometricRenderer/Resources/RedSquare.png
Normal file
|
After Width: | Height: | Size: 111 B |
BIN
VoxelIsometricRenderer/Resources/YellowSquare.png
Normal file
|
After Width: | Height: | Size: 111 B |
BIN
VoxelIsometricRenderer/Resources/dirt.png
Normal file
|
After Width: | Height: | Size: 364 B |
BIN
VoxelIsometricRenderer/Resources/flower.png
Normal file
|
After Width: | Height: | Size: 603 B |
BIN
VoxelIsometricRenderer/Resources/grasside.png
Normal file
|
After Width: | Height: | Size: 598 B |
BIN
VoxelIsometricRenderer/Resources/grassmed.png
Normal file
|
After Width: | Height: | Size: 187 B |
BIN
VoxelIsometricRenderer/Resources/grasstall.png
Normal file
|
After Width: | Height: | Size: 248 B |
BIN
VoxelIsometricRenderer/Resources/grasstop.png
Normal file
|
After Width: | Height: | Size: 574 B |
BIN
VoxelIsometricRenderer/Resources/greenSquare.png
Normal file
|
After Width: | Height: | Size: 111 B |
BIN
VoxelIsometricRenderer/Resources/image (2).png
Normal file
|
After Width: | Height: | Size: 158 KiB |
BIN
VoxelIsometricRenderer/Resources/image (2).webp
Normal file
|
After Width: | Height: | Size: 114 KiB |
BIN
VoxelIsometricRenderer/Resources/image (3).png
Normal file
|
After Width: | Height: | Size: 122 KiB |
BIN
VoxelIsometricRenderer/Resources/leaves.png
Normal file
|
After Width: | Height: | Size: 459 B |
BIN
VoxelIsometricRenderer/Resources/log.png
Normal file
|
After Width: | Height: | Size: 433 B |
BIN
VoxelIsometricRenderer/Resources/logtop.png
Normal file
|
After Width: | Height: | Size: 506 B |
BIN
VoxelIsometricRenderer/Resources/ore1.png
Normal file
|
After Width: | Height: | Size: 652 B |
BIN
VoxelIsometricRenderer/Resources/spruceleaves.png
Normal file
|
After Width: | Height: | Size: 470 B |
BIN
VoxelIsometricRenderer/Resources/sprucelog.png
Normal file
|
After Width: | Height: | Size: 376 B |
BIN
VoxelIsometricRenderer/Resources/stone1.png
Normal file
|
After Width: | Height: | Size: 427 B |
BIN
VoxelIsometricRenderer/Resources/stone2.png
Normal file
|
After Width: | Height: | Size: 592 B |
BIN
VoxelIsometricRenderer/Resources/stone3.png
Normal file
|
After Width: | Height: | Size: 436 B |
BIN
VoxelIsometricRenderer/Resources/vine.png
Normal file
|
After Width: | Height: | Size: 417 B |
69
VoxelIsometricRenderer/Terrain4.Designer.cs
generated
Normal file
@@ -0,0 +1,69 @@
|
||||
namespace VoxelIsometricRenderer
|
||||
{
|
||||
partial class Terrain4
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.Display = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.Display)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Display
|
||||
//
|
||||
this.Display.BackColor = System.Drawing.Color.Aquamarine;
|
||||
this.Display.Location = new System.Drawing.Point(12, 12);
|
||||
this.Display.Name = "Display";
|
||||
this.Display.Size = new System.Drawing.Size(100, 50);
|
||||
this.Display.TabIndex = 0;
|
||||
this.Display.TabStop = false;
|
||||
this.Display.Paint += new System.Windows.Forms.PaintEventHandler(this.Draw);
|
||||
//
|
||||
// Terrain4
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.Display);
|
||||
this.DoubleBuffered = true;
|
||||
this.Name = "Terrain4";
|
||||
this.Text = "Form1";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.KillThreads);
|
||||
this.Load += new System.EventHandler(this.Terrain4_Load);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.KeyDownEvent);
|
||||
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.KeyUpEvent);
|
||||
this.Resize += new System.EventHandler(this.ResizeAspectRatio);
|
||||
((System.ComponentModel.ISupportInitialize)(this.Display)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox Display;
|
||||
}
|
||||
}
|
||||
|
||||
179
VoxelIsometricRenderer/Terrain4.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using VoxelIsometricRenderer.Properties;
|
||||
|
||||
namespace VoxelIsometricRenderer
|
||||
{
|
||||
public partial class Terrain4 : Form
|
||||
{
|
||||
public static bool running = true;
|
||||
public static List<Voxel> Voxels = new List<Voxel>();
|
||||
public static Thread MainThread;
|
||||
public static float scale = 2f;
|
||||
public static int FPS = 0;
|
||||
public static int Frames = 0;
|
||||
public Terrain4()
|
||||
{
|
||||
InitializeComponent();
|
||||
TextureManager.AddBitmap(Resources.grasside);
|
||||
TextureManager.AddBitmap(Resources.grasstop);
|
||||
TextureManager.AddBitmap(Resources.dirt);
|
||||
TextureManager.AddBitmap(Resources.log);
|
||||
TextureManager.AddBitmap(Resources.sprucelog);
|
||||
TextureManager.AddBitmap(Resources.logtop);
|
||||
TextureManager.AddBitmap(Resources.leaves);
|
||||
TextureManager.AddBitmap(Resources.spruceleaves);
|
||||
TextureManager.AddBitmap(Resources.stone1);
|
||||
TextureManager.AddBitmap(Resources.stone2);
|
||||
TextureManager.AddBitmap(Resources.stone3);
|
||||
TextureManager.AddBitmap(Resources.ore1);
|
||||
TextureManager.AddBitmap(Resources.flower);
|
||||
TextureManager.AddBitmap(Resources.vine);
|
||||
TextureManager.AddBitmap(Resources.grasstall);
|
||||
TextureManager.AddBitmap(Resources.grassmed);
|
||||
TextureManager.AddBitmap(Resources.BlueSquare);
|
||||
TextureManager.AddBitmap(Resources.greenSquare);
|
||||
TextureManager.AddBitmap(Resources.RedSquare);
|
||||
TextureManager.AddBitmap(Resources.YellowSquare);
|
||||
TextureManager.AddBitmap(Resources.PinkSquare);
|
||||
TextureManager.AddBitmap(Resources.OrangeSquare);
|
||||
TextureManager.AddBitmap(Resources.ColourEdges);
|
||||
Voxels.Add(new Voxel(0, 0, 0, 0, 0, 0));
|
||||
Voxels.Add(new Voxel(9, 9, 9, 9, 9, 9));
|
||||
Voxels.Add(new Voxel(10, 10, 10, 10, 10, 10));
|
||||
Voxels.Add(new Voxel(11, 11, 11, 11, 11, 11));
|
||||
Voxels.Add(new Voxel(12, 12, 12, 12, 12, 12));
|
||||
Voxels.Add(new Voxel(3, 3, 3, 3, 3, 3));
|
||||
Voxels.Add(new Voxel(1, 1, 1, 1, 2, 3));
|
||||
Voxels.Add(new Voxel(4, 4, 4, 4, 6, 6));
|
||||
Voxels.Add(new Voxel(5, 5, 5, 5, 6, 6));
|
||||
Voxels.Add(new Voxel(7, 7, 7, 7, 7, 7));
|
||||
Voxels.Add(new Voxel(17, 18, 19, 20, 21, 22));
|
||||
Voxels.Add(new Voxel(23, 23, 23, 23, 23, 23));
|
||||
Voxels.Add(new Voxel(17, 18, 19, 20, -1, -1));
|
||||
Voxels.Add(new Voxel(23, 23, 23, 23, -1, -1));
|
||||
Voxels.Add(new Voxel(-1, -1, -1, -1, 21, 22));
|
||||
Voxels.Add(new Voxel(-1, -1, -1, -1, 23, 23));
|
||||
Voxels.Add(new Voxel(1, 13, 13, 13, 13, -1, -1));
|
||||
Voxels.Add(new Voxel(1, 14, 14, 14,14, -1, -1));
|
||||
Voxels.Add(new Voxel(1, 15, 15, 15,15, -1, -1));
|
||||
Voxels.Add(new Voxel(1, 16, 16, 16,16, -1, -1));
|
||||
Random rnd = new Random();
|
||||
for(int i = 0; i < 25; i++)
|
||||
{
|
||||
Voxels.Add(new Voxel(rnd.Next(0,TextureManager.textures.Count - 1), rnd.Next(0, TextureManager.textures.Count - 1), rnd.Next(0, TextureManager.textures.Count - 1), rnd.Next(0, TextureManager.textures.Count - 1), rnd.Next(0, TextureManager.textures.Count - 1), rnd.Next(0, TextureManager.textures.Count - 1)));
|
||||
}
|
||||
TextureManager.GenerateVoxelFaces();
|
||||
for (int i = 0; i < Voxels.Count; i++)
|
||||
{
|
||||
//TextureManager.CreateModel(Voxels[i]);
|
||||
}
|
||||
MainThread = new Thread(Runtime);
|
||||
MainThread.SetApartmentState(ApartmentState.STA);
|
||||
MainThread.Start();
|
||||
ResizeDisplay();
|
||||
}
|
||||
|
||||
private void Runtime()
|
||||
{
|
||||
bool up = false;
|
||||
double LightingFrameTime = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds;
|
||||
double SecondFrameTime = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds;
|
||||
while (running)
|
||||
{
|
||||
Display.Refresh();
|
||||
if (Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds - LightingFrameTime > 16)
|
||||
{
|
||||
LightingFrameTime = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds;
|
||||
LightingManager.UpdateLighting();
|
||||
LightingManager.sunAngles[0] += 5f;
|
||||
LightingManager.sunAngles[1] += 1f;
|
||||
}
|
||||
if (Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds - SecondFrameTime > 1000) {
|
||||
SecondFrameTime = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds;
|
||||
FPS = Frames;
|
||||
Frames = 0;
|
||||
}
|
||||
if (up && LightingManager.AmbientColouring[0] < 1.5f)
|
||||
{
|
||||
//LightingManager.AmbientColouring[0] += 0.01f;
|
||||
//LightingManager.AmbientColouring[1] += 0.01f;
|
||||
//LightingManager.AmbientColouring[2] += 0.01f;
|
||||
}
|
||||
else if (up) up = false;
|
||||
else if (LightingManager.AmbientColouring[0] > 0.5f)
|
||||
{
|
||||
//LightingManager.AmbientColouring[0] -= 0.01f;
|
||||
//LightingManager.AmbientColouring[1] -= 0.01f;
|
||||
//LightingManager.AmbientColouring[2] -= 0.01f;
|
||||
}
|
||||
else up = true;
|
||||
}
|
||||
}
|
||||
private void Draw(object sender, PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
g.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
g.ScaleTransform(scale, scale);
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
foreach(Voxel voxel in Voxels)
|
||||
{
|
||||
voxel.Draw(g,2 + x,2 + y);
|
||||
x += 36;
|
||||
if ((x+32) * scale > Width)
|
||||
{
|
||||
y += 36;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
g.ResetTransform();
|
||||
g.DrawString(String.Format("FPS: {0}", FPS), SystemFonts.DefaultFont, Brushes.Red, new PointF(0, 0));
|
||||
Frames++;
|
||||
}
|
||||
public void ResizeDisplay()
|
||||
{
|
||||
Display.Left = 0;
|
||||
Display.Top = 0;
|
||||
Display.Width = Width;
|
||||
Display.Height = Height;
|
||||
}
|
||||
private void ResizeAspectRatio(object sender, EventArgs e)
|
||||
{
|
||||
ResizeDisplay();
|
||||
}
|
||||
|
||||
private void KillThreads(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
|
||||
private void KeyDownEvent(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Up) scale += 0.25f;
|
||||
if (e.KeyCode == Keys.Down) scale -= 0.25f;
|
||||
}
|
||||
|
||||
private void KeyUpEvent(object sender, KeyEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Terrain4_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
120
VoxelIsometricRenderer/Terrain4.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
||||
580
VoxelIsometricRenderer/Voxel.cs
Normal file
@@ -0,0 +1,580 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VoxelIsometricRenderer.Properties;
|
||||
|
||||
namespace VoxelIsometricRenderer
|
||||
{
|
||||
public enum LightDirection
|
||||
{
|
||||
North,
|
||||
NorthEast,
|
||||
NorthWest,
|
||||
East,
|
||||
West,
|
||||
SouthEast,
|
||||
SouthWest,
|
||||
South
|
||||
}
|
||||
public static class LightingManager
|
||||
{
|
||||
public static float[] AmbientColouring = new float[] { 1.0f, 1.0f, 1.0f };
|
||||
public static float[] AmbientMinimums = new float[] { 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f };
|
||||
public static float[] DefaultValues = new float[] { 0.6f, 0.6f, 0.6f, 0.6f, 1.0f, 0.4f };
|
||||
public static float[] SunModifiedValues = new float[] { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
public static float[] sunAngles = new float[] { 180, 0 };
|
||||
public static LightDirection SunAngle = LightDirection.North;
|
||||
|
||||
public static void UpdateLighting()
|
||||
{
|
||||
float[] AngleRanges = new float[] { 0,45, 90, 135, 180, 225, 270, 315 };
|
||||
float[] AngleOffsets = new float[] { 0,180, 90, 270, -1, -1};
|
||||
LightDirection[] directions = new LightDirection[] { LightDirection.North, LightDirection.NorthEast, LightDirection.East, LightDirection.SouthEast, LightDirection.South, LightDirection.SouthWest, LightDirection.West, LightDirection.NorthWest };
|
||||
if (sunAngles[0] > 360) sunAngles[0] -= 360;
|
||||
if (sunAngles[1] > 360) sunAngles[1] -= 360;
|
||||
if (sunAngles[0] <= -360) sunAngles[0] += 360;
|
||||
if (sunAngles[1] <= -360) sunAngles[1] += 360;
|
||||
float CurrentAngle = 0;
|
||||
int AngleIndex = 0;
|
||||
for (int i = 0; i < AngleRanges.Length; i++)
|
||||
{
|
||||
if (sunAngles[0] < AngleRanges[i])
|
||||
{
|
||||
CurrentAngle = AngleRanges[i];
|
||||
AngleIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Square(CurrentAngle - sunAngles[0]) > Square(sunAngles[0] - AngleRanges[AngleIndex - 1 >= 0 ? AngleIndex - 1 : AngleRanges.Length - 1]))
|
||||
{
|
||||
AngleIndex = AngleIndex - 1 >= 0 ? AngleIndex - 1 : AngleRanges.Length - 1;
|
||||
}
|
||||
SunAngle = directions[AngleIndex];
|
||||
for (int i = 0; i < SunModifiedValues.Length - 2; i++)
|
||||
{
|
||||
SunModifiedValues[i] = (float)((1 + Math.Cos(Math.PI * (sunAngles[0] + AngleOffsets[i]) / 180)/ 2.0) * (float)( 1 + Math.Sin(Math.PI * (sunAngles[1] + 45) / 180))/ 2.0);
|
||||
}
|
||||
for (int i = SunModifiedValues.Length - 2; i < SunModifiedValues.Length; i++)
|
||||
{
|
||||
SunModifiedValues[i] = (float)Math.Max((1 + Math.Cos(Math.PI * (sunAngles[1]) / 180)) / 2.0, 0.3f);
|
||||
}
|
||||
}
|
||||
private static float Square(float ValueIn)
|
||||
{
|
||||
return ValueIn * ValueIn;
|
||||
}
|
||||
}
|
||||
public static class TextureManager
|
||||
{
|
||||
public static List<Bitmap> textures = new List<Bitmap>() {Resources._16xDefaultTile};
|
||||
public static List<Bitmap> PreCompiledModels = new List<Bitmap>();
|
||||
public static Bitmap[,] GeneratedFaceTextures = new Bitmap[0,0];
|
||||
public static int VoxelCount = 0;
|
||||
public static Bitmap GetModel(int modelNum)
|
||||
{
|
||||
return PreCompiledModels[modelNum];
|
||||
}
|
||||
public static void CreateModel(Voxel voxel)
|
||||
{
|
||||
if (GeneratedFaceTextures.GetLength(1) < 6) GenerateVoxelFaces();
|
||||
int ImageWidth = 0;
|
||||
int ImageHeight = 0;
|
||||
int[] faces = voxel.getFaces();
|
||||
int[] DrawOrder = voxel.GetDrawOrder();
|
||||
for(int i = 0; i < faces.Length; i++)
|
||||
{
|
||||
if (faces[i] >= 0 && GeneratedFaceTextures[faces[i], i].Width > ImageWidth) ImageWidth = GeneratedFaceTextures[faces[i], i].Width;
|
||||
if (faces[i] >= 0 && GeneratedFaceTextures[faces[i], i].Height > ImageHeight) ImageHeight = GeneratedFaceTextures[faces[i], i].Height;
|
||||
}
|
||||
Bitmap GeneratedModel = new Bitmap(ImageWidth, ImageHeight);
|
||||
voxel.Draw(Graphics.FromImage(GeneratedModel),0,0);
|
||||
voxel.SetPreCompiledModel(PreCompiledModels.Count);
|
||||
PreCompiledModels.Add(GeneratedModel);
|
||||
GeneratedModel.Save("Model" + voxel.GetModelNum() + ".png");
|
||||
}
|
||||
public static float GetSunlightValue(int face)
|
||||
{
|
||||
return LightingManager.SunModifiedValues[face] * LightingManager.DefaultValues[face];
|
||||
}
|
||||
public static float GetShadingValue(float LightValue, int RGBIndex, int FaceIndex)
|
||||
{
|
||||
return (float)Math.Max(LightValue * LightingManager.AmbientColouring[RGBIndex], LightingManager.AmbientMinimums[FaceIndex]);
|
||||
}
|
||||
public static ImageAttributes GetShadow(int face)
|
||||
{
|
||||
ImageAttributes imageAttributes;
|
||||
float[][] colorMatrixElements;
|
||||
ColorMatrix colorMatrix;
|
||||
switch (face) {
|
||||
case 0:
|
||||
colorMatrixElements = new float[][]{
|
||||
new float[] { GetShadingValue(GetSunlightValue(face), 0,face), 0, 0, 0, 0}, // red
|
||||
new float[] {0, GetShadingValue(GetSunlightValue(face), 1, face), 0, 0, 0}, // green
|
||||
new float[] {0, 0, GetShadingValue(GetSunlightValue(face), 2, face), 0, 0}, // blue
|
||||
new float[] {0, 0, 0, 1, 0}, // alpha
|
||||
new float[] {0, 0, 0, 0, 1}}; // three translations of 0.2
|
||||
|
||||
colorMatrix = new ColorMatrix(colorMatrixElements);
|
||||
imageAttributes = new ImageAttributes();
|
||||
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
return imageAttributes;
|
||||
case 1:
|
||||
colorMatrixElements = new float[][]{
|
||||
new float[] { GetShadingValue(GetSunlightValue(face), 0,face), 0, 0, 0, 0}, // red
|
||||
new float[] {0, GetShadingValue(GetSunlightValue(face), 1, face), 0, 0, 0}, // green
|
||||
new float[] {0, 0, GetShadingValue(GetSunlightValue(face), 2, face), 0, 0}, // blue
|
||||
new float[] {0, 0, 0, 1, 0}, // alpha
|
||||
new float[] {0, 0, 0, 0, 1}}; // three translations of 0.2
|
||||
|
||||
colorMatrix = new ColorMatrix(colorMatrixElements);
|
||||
imageAttributes = new ImageAttributes();
|
||||
imageAttributes.SetColorMatrix( colorMatrix,ColorMatrixFlag.Default,ColorAdjustType.Bitmap);
|
||||
return imageAttributes;
|
||||
case 2:
|
||||
colorMatrixElements = new float[][]{
|
||||
new float[] { GetShadingValue(GetSunlightValue(face), 0,face), 0, 0, 0, 0}, // red
|
||||
new float[] {0, GetShadingValue(GetSunlightValue(face), 1, face), 0, 0, 0}, // green
|
||||
new float[] {0, 0, GetShadingValue(GetSunlightValue(face), 2, face), 0, 0}, // blue
|
||||
new float[] {0, 0, 0, 1, 0}, // alpha
|
||||
new float[] {0, 0, 0, 0, 1}}; // three translations of 0.2
|
||||
|
||||
colorMatrix = new ColorMatrix(colorMatrixElements);
|
||||
imageAttributes = new ImageAttributes();
|
||||
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
return imageAttributes;
|
||||
case 3:
|
||||
colorMatrixElements = new float[][]{
|
||||
new float[] { GetShadingValue(GetSunlightValue(face), 0,face), 0, 0, 0, 0}, // red
|
||||
new float[] {0, GetShadingValue(GetSunlightValue(face), 1, face), 0, 0, 0}, // green
|
||||
new float[] {0, 0, GetShadingValue(GetSunlightValue(face), 2, face), 0, 0}, // blue
|
||||
new float[] {0, 0, 0, 1, 0}, // alpha
|
||||
new float[] {0, 0, 0, 0, 1}}; // three translations of 0.2
|
||||
|
||||
colorMatrix = new ColorMatrix(colorMatrixElements);
|
||||
imageAttributes = new ImageAttributes();
|
||||
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
return imageAttributes;
|
||||
case 4:
|
||||
colorMatrixElements = new float[][]{
|
||||
new float[] { GetShadingValue(GetSunlightValue(face), 0,face), 0, 0, 0, 0}, // red
|
||||
new float[] {0, GetShadingValue(GetSunlightValue(face), 1, face), 0, 0, 0}, // green
|
||||
new float[] {0, 0, GetShadingValue(GetSunlightValue(face), 2, face), 0, 0}, // blue
|
||||
new float[] {0, 0, 0, 1, 0}, // alpha
|
||||
new float[] {0, 0, 0, 0, 1}}; // three translations of 0.2
|
||||
|
||||
colorMatrix = new ColorMatrix(colorMatrixElements);
|
||||
imageAttributes = new ImageAttributes();
|
||||
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
return imageAttributes;
|
||||
case 5:
|
||||
colorMatrixElements = new float[][]{
|
||||
new float[] { GetShadingValue(GetSunlightValue(face), 0,face), 0, 0, 0, 0}, // red
|
||||
new float[] {0, GetShadingValue(GetSunlightValue(face), 1, face), 0, 0, 0}, // green
|
||||
new float[] {0, 0, GetShadingValue(GetSunlightValue(face), 2, face), 0, 0}, // blue
|
||||
new float[] {0, 0, 0, 1, 0}, // alpha
|
||||
new float[] {0, 0, -0, 0, 1}}; // three translations of 0.2
|
||||
|
||||
colorMatrix = new ColorMatrix(colorMatrixElements);
|
||||
imageAttributes = new ImageAttributes();
|
||||
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
return imageAttributes;
|
||||
default:
|
||||
imageAttributes = new ImageAttributes();
|
||||
return imageAttributes;
|
||||
|
||||
}
|
||||
}
|
||||
public static Point IntegerCalculateIsometricProjection(int width, int height, int X, int Y, int Z, int Corner)
|
||||
{
|
||||
switch (Corner)
|
||||
{
|
||||
case 0:
|
||||
return new Point(width / 2 + (int)((X * 1) + (Z * -1)),
|
||||
height / 2 + (int)Math.Ceiling((X * 0.5f) + (Z * 0.5f) - (Y / 3) * 2));
|
||||
case 1:
|
||||
return new Point(width / 2 + (int)((X * 1) + (Z * -1)),
|
||||
height / 2 + (int)Math.Floor((X * 0.5f) + (Z * 0.5f) - (Y / 3) * 2));
|
||||
case 2:
|
||||
return new Point(-1 + width / 2 + (int)((X * 1) + (Z * -1)),
|
||||
height / 2 + (int)Math.Floor((X * 0.5f) + (Z * 0.5f) - (Y / 3) * 2));
|
||||
default:
|
||||
return new Point(-1 + width / 2 + (int)((X * 1) + (Z * -1)),
|
||||
height / 2 + (int)Math.Ceiling((X * 0.5f) + (Z * 0.5f) - (Y / 3) * 2));
|
||||
}
|
||||
}
|
||||
public static Point IntegerCalculateIsometricProjection(int width, int height, int X, int Y, int Z)
|
||||
{
|
||||
return new Point(width / 2 + (int)((X * 1) + (Z * -1)),
|
||||
height / 2 + (int)((X * 0.5f) + (Z * 0.5f) - (Y / 3) * 2));
|
||||
}
|
||||
public static PointF CalculateIsometricProjection(double[] Position, int width, int height, int X, int Y, int Z)
|
||||
{
|
||||
return new PointF(width / 2 + (float)(((/*Globals.CameraX*/ +X + Position[0]) * 0.5) + ((/*Globals.CameraZ +*/ Z + Position[1]) * -0.5)),
|
||||
height / 2 + (float)(((/*Globals.CameraX*/ +X + Position[0]) * 0.25f) + ((/*Globals.CameraZ*/ +Z + Position[1]) * 0.25f) - (((/*Globals.CameraY*/ +Position[2]) + (Y / 3) * 2))));
|
||||
}
|
||||
public static Bitmap GetVoxelFaceBitmap(int index, int face)
|
||||
{
|
||||
if (GeneratedFaceTextures.GetLength(1) < 6) GenerateVoxelFaces();
|
||||
return GeneratedFaceTextures[index,face];
|
||||
}
|
||||
public static Bitmap GetBitmap(int index)
|
||||
{
|
||||
return textures[index];
|
||||
}
|
||||
public static void AddBitmap(Bitmap texture)
|
||||
{
|
||||
textures.Add(texture);
|
||||
}
|
||||
public static void GenerateVoxelFaces()
|
||||
{
|
||||
GeneratedFaceTextures = new Bitmap[textures.Count, 6];
|
||||
for (int i = 0; i < textures.Count; i++)
|
||||
{
|
||||
for (int face = 0; face < 6; face++)
|
||||
{
|
||||
Bitmap SkewedTexture = new Bitmap(textures[i].Width * 2, textures[i].Height * 2);
|
||||
int y = 0;// textures[i].Height;
|
||||
switch (face)
|
||||
{
|
||||
case 0:
|
||||
y = 1;
|
||||
for(int x = 0; x < textures[i].Width; x++)
|
||||
{
|
||||
for(int ypx = 0; ypx < textures[i].Height; ypx++)
|
||||
{
|
||||
SkewedTexture.SetPixel(textures[i].Width+ x, y + ypx, textures[i].GetPixel(x, ypx));
|
||||
}
|
||||
if (x % 2 != 0) y++;
|
||||
}
|
||||
y = 0;
|
||||
break;
|
||||
case 1:
|
||||
for (int x = textures[i].Width - 1; x >= 0 ; x--)
|
||||
{
|
||||
for (int ypx = 0; ypx < textures[i].Height; ypx++)
|
||||
{
|
||||
SkewedTexture.SetPixel(x, SkewedTexture.Height - (y + ypx + 1), textures[i].GetPixel(x, textures[i].Height - 1 - ypx));
|
||||
}
|
||||
if (x % 2 == 0) y++;
|
||||
}
|
||||
y = 0;
|
||||
break;
|
||||
case 2:
|
||||
for (int x = 0; x < textures[i].Width; x++)
|
||||
{
|
||||
for (int ypx = 0; ypx < textures[i].Height; ypx++)
|
||||
{
|
||||
SkewedTexture.SetPixel(textures[i].Width + x, SkewedTexture.Height - (y + ypx + 1), textures[i].GetPixel(x, textures[i].Height - 1 - ypx));
|
||||
}
|
||||
if (x % 2 != 0) y++;
|
||||
}
|
||||
y = 0;
|
||||
break;
|
||||
case 3:
|
||||
y = 1;
|
||||
for (int x = textures[i].Width - 1; x >= 0; x--)
|
||||
{
|
||||
for (int ypx = 0; ypx < textures[i].Height; ypx++)
|
||||
{
|
||||
SkewedTexture.SetPixel(x, y + ypx, textures[i].GetPixel(x, ypx));
|
||||
}
|
||||
if (x % 2 == 0) y++;
|
||||
}
|
||||
y = 0;
|
||||
break;
|
||||
case 4:
|
||||
Bitmap[] Textures = new Bitmap[4];
|
||||
Bitmap MergedTextures = new Bitmap(SkewedTexture.Width, SkewedTexture.Height);
|
||||
for (int l = 0; l < 4; l++)
|
||||
{
|
||||
Textures[l] = new Bitmap(SkewedTexture.Width, SkewedTexture.Height);
|
||||
}
|
||||
for(int l = 0; l < 4; l++)
|
||||
{
|
||||
for (int x = 0; x < textures[i].Width; x++)
|
||||
{
|
||||
for (int ypx = 0; ypx < textures[i].Height; ypx++)
|
||||
{
|
||||
Point PixelLocation = IntegerCalculateIsometricProjection(textures[i].Width * 2, 0, x, 0, ypx,l);
|
||||
PixelLocation.X = Math.Max(Math.Min(PixelLocation.X, SkewedTexture.Width - 1), 0);
|
||||
PixelLocation.Y = Math.Max(Math.Min(PixelLocation.Y, SkewedTexture.Height - 1), 0);
|
||||
Textures[l].SetPixel(PixelLocation.X, PixelLocation.Y, textures[i].GetPixel(x, ypx));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int l = 0; l < 4; l++)
|
||||
{
|
||||
int Startx = 0;
|
||||
int Starty = 0;
|
||||
int endX = Textures[l].Width;
|
||||
int endY = Textures[l].Height;
|
||||
switch (l)
|
||||
{
|
||||
case 1:
|
||||
Startx = Textures[l].Width / 2;
|
||||
Starty = 0;
|
||||
endX = Textures[l].Width;
|
||||
endY = Textures[l].Height/4;
|
||||
break;
|
||||
case 0:
|
||||
Startx = Textures[l].Width / 2;
|
||||
Starty = Textures[l].Height / 4;
|
||||
endX = Textures[l].Width;
|
||||
endY = Textures[l].Height/2;
|
||||
break;
|
||||
case 2:
|
||||
Startx = 0;
|
||||
Starty = 0;
|
||||
endX = Textures[l].Width/2;
|
||||
endY = Textures[l].Height / 4 ;
|
||||
break;
|
||||
case 3:
|
||||
Startx = 0;
|
||||
Starty = Textures[l].Height / 4;
|
||||
endX = Textures[l].Width/2;
|
||||
endY = Textures[l].Height/2;
|
||||
break;
|
||||
}
|
||||
for(int x = Startx; x < endX; x++)
|
||||
{
|
||||
for (int ypx = Starty; ypx < endY;ypx++)
|
||||
{
|
||||
MergedTextures.SetPixel(x, ypx, Textures[l].GetPixel(x, ypx));
|
||||
}
|
||||
}
|
||||
}
|
||||
SkewedTexture = MergedTextures;
|
||||
y = 0;
|
||||
break;
|
||||
case 5:
|
||||
Textures = new Bitmap[4];
|
||||
MergedTextures = new Bitmap(SkewedTexture.Width, SkewedTexture.Height);
|
||||
for (int l = 0; l < 4; l++)
|
||||
{
|
||||
Textures[l] = new Bitmap(SkewedTexture.Width, SkewedTexture.Height);
|
||||
}
|
||||
for (int l = 0; l < 4; l++)
|
||||
{
|
||||
for (int x = 0; x < textures[i].Width; x++)
|
||||
{
|
||||
for (int ypx = 0; ypx < textures[i].Height; ypx++)
|
||||
{
|
||||
Point PixelLocation = IntegerCalculateIsometricProjection(textures[i].Width * 2, 0, x, 0, ypx, l);
|
||||
PixelLocation.X = Math.Max(Math.Min(PixelLocation.X, SkewedTexture.Width - 1), 0);
|
||||
PixelLocation.Y = Math.Max(Math.Min(textures[i].Height + PixelLocation.Y, SkewedTexture.Height - 1), 0);
|
||||
Textures[l].SetPixel(PixelLocation.X, PixelLocation.Y, textures[i].GetPixel(x, ypx));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int l = 0; l < 4; l++)
|
||||
{
|
||||
int Startx = 0;
|
||||
int Starty = 0;
|
||||
int endX = Textures[l].Width;
|
||||
int endY = Textures[l].Height;
|
||||
switch (l)
|
||||
{
|
||||
case 1:
|
||||
Startx = Textures[l].Width / 2;
|
||||
Starty = Textures[l].Height / 2;
|
||||
endX = Textures[l].Width;
|
||||
endY = (Textures[l].Height / 4) * 3;
|
||||
break;
|
||||
case 0:
|
||||
Startx = Textures[l].Width / 2;
|
||||
Starty = (Textures[l].Height / 4) * 3;
|
||||
endX = Textures[l].Width;
|
||||
endY = Textures[l].Height;
|
||||
break;
|
||||
case 2:
|
||||
Startx = 0;
|
||||
Starty = Textures[l].Height / 2;
|
||||
endX = Textures[l].Width / 2;
|
||||
endY = (Textures[l].Height / 4) * 3;
|
||||
break;
|
||||
case 3:
|
||||
Startx = 0;
|
||||
Starty = (Textures[l].Height / 4)*3;
|
||||
endX = Textures[l].Width / 2;
|
||||
endY = Textures[l].Height;
|
||||
break;
|
||||
}
|
||||
for (int x = Startx; x < endX; x++)
|
||||
{
|
||||
for (int ypx = Starty; ypx < endY; ypx++)
|
||||
{
|
||||
MergedTextures.SetPixel(x, ypx, Textures[l].GetPixel(x, ypx));
|
||||
}
|
||||
}
|
||||
}
|
||||
SkewedTexture = MergedTextures;
|
||||
y = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
GeneratedFaceTextures[i, face] = SkewedTexture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Voxel
|
||||
{
|
||||
int VoxelNum;
|
||||
int[] faces = new int[6];
|
||||
int[] DrawOrder = new int[] { 5, 0, 3, 1, 2, 4 };
|
||||
int ModelType = 0;
|
||||
int ModelNum = -1;
|
||||
public int[] getFaces()
|
||||
{
|
||||
return faces;
|
||||
}
|
||||
public int[] GetDrawOrder()
|
||||
{
|
||||
return DrawOrder;
|
||||
}
|
||||
public int GetModelNum()
|
||||
{
|
||||
return ModelNum;
|
||||
}
|
||||
public int GetModelType()
|
||||
{
|
||||
return ModelType;
|
||||
}
|
||||
public int GetVoxelNum()
|
||||
{
|
||||
return VoxelNum;
|
||||
}
|
||||
public Voxel(int ModelType,int NorthFace, int SouthFace, int EastFace, int WestFace, int UpFace, int DownFace)
|
||||
{
|
||||
this.ModelType = ModelType;
|
||||
faces = new int[] { NorthFace, SouthFace, EastFace, WestFace, UpFace, DownFace };
|
||||
VoxelNum = TextureManager.VoxelCount;
|
||||
TextureManager.VoxelCount++;
|
||||
}
|
||||
public void SetPreCompiledModel(int ModelNum)
|
||||
{
|
||||
this.ModelNum = ModelNum;
|
||||
}
|
||||
public Voxel(int NorthFace, int SouthFace, int EastFace, int WestFace, int UpFace, int DownFace)
|
||||
{
|
||||
faces = new int[] {NorthFace, SouthFace, EastFace, WestFace, UpFace, DownFace};
|
||||
VoxelNum = TextureManager.VoxelCount;
|
||||
TextureManager.VoxelCount++;
|
||||
}
|
||||
virtual public void Draw(Graphics g, int x, int y)
|
||||
{
|
||||
for (int i = 0; i < DrawOrder.Length; i++) {
|
||||
if (faces[DrawOrder[i]] >= 0)
|
||||
{
|
||||
if (ModelNum == -1)
|
||||
{
|
||||
Bitmap Side;
|
||||
switch (ModelType)
|
||||
{
|
||||
case 0:
|
||||
Side = GetRenderedSide(DrawOrder[i]);
|
||||
g.DrawImage(Side, new Rectangle(x, y, Side.Width, Side.Height), 0, 0, Side.Width, Side.Height, GraphicsUnit.Pixel, TextureManager.GetShadow(DrawOrder[i]));
|
||||
break;
|
||||
default:
|
||||
|
||||
switch (DrawOrder[i])
|
||||
{
|
||||
case 0:
|
||||
Side = GetRenderedSide(0);
|
||||
g.DrawImage(Side, new Rectangle(x - (Side.Width / 4), y, Side.Width, Side.Height),0,0,Side.Width,Side.Height, GraphicsUnit.Pixel, TextureManager.GetShadow(0));
|
||||
break;
|
||||
case 1:
|
||||
Side = GetRenderedSide(1);
|
||||
g.DrawImage(Side, new Rectangle(x + (Side.Width / 4), y - (Side.Height / 4), Side.Width, Side.Height),0,0,Side.Width,Side.Height, GraphicsUnit.Pixel, TextureManager.GetShadow(1));
|
||||
break;
|
||||
case 2:
|
||||
Side = GetRenderedSide(2);
|
||||
g.DrawImage(Side, new Rectangle(x - (Side.Width / 4), y - (Side.Height / 4), Side.Width, Side.Height),0,0,Side.Width,Side.Height, GraphicsUnit.Pixel, TextureManager.GetShadow(2));
|
||||
break;
|
||||
case 3:
|
||||
Side = GetRenderedSide(3);
|
||||
g.DrawImage(Side, new Rectangle( x + (Side.Width / 4),y,Side.Width,Side.Height),0,0,Side.Width,Side.Height, GraphicsUnit.Pixel, TextureManager.GetShadow(3));
|
||||
break;
|
||||
default:
|
||||
Side = GetRenderedSide(DrawOrder[i]);
|
||||
g.DrawImage(Side, new Rectangle(x, y, Side.Width, Side.Height), 0, 0, Side.Width, Side.Height, GraphicsUnit.Pixel, TextureManager.GetShadow(DrawOrder[i]));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawImage(TextureManager.GetModel(ModelNum), x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public Bitmap GetRenderedSide(int FaceIndex)
|
||||
{
|
||||
return TextureManager.GetVoxelFaceBitmap(faces[FaceIndex], FaceIndex);
|
||||
}
|
||||
public int GetFace(int index)
|
||||
{
|
||||
return faces[index];
|
||||
}
|
||||
public int GetNorthFace()
|
||||
{
|
||||
return faces[0];
|
||||
}
|
||||
public int GetSouthFace()
|
||||
{
|
||||
return faces[1];
|
||||
}
|
||||
public int GetEastFace()
|
||||
{
|
||||
return faces[2];
|
||||
}
|
||||
public int GetWestFace()
|
||||
{
|
||||
return faces[3];
|
||||
}
|
||||
public int GetUpFace()
|
||||
{
|
||||
return faces[4];
|
||||
}
|
||||
public int GetDownFace()
|
||||
{
|
||||
return faces[5];
|
||||
}
|
||||
public void SetFace(int face, int Texture)
|
||||
{
|
||||
faces[face] = Texture;
|
||||
}
|
||||
public void SetNorthFace(int Texture)
|
||||
{
|
||||
faces[0] = Texture;
|
||||
}
|
||||
public void SetSouthFace(int Texture)
|
||||
{
|
||||
faces[1] = Texture;
|
||||
}
|
||||
public void SetEastFace(int Texture)
|
||||
{
|
||||
faces[2] = Texture;
|
||||
}
|
||||
public void SetWestFace(int Texture)
|
||||
{
|
||||
faces[3] = Texture;
|
||||
}
|
||||
public void SetUpFace(int Texture)
|
||||
{
|
||||
faces[4] = Texture;
|
||||
}
|
||||
public void SetDownFace(int Texture)
|
||||
{
|
||||
faces[5] = Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
164
VoxelIsometricRenderer/VoxelIsometricRenderer.csproj
Normal file
@@ -0,0 +1,164 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" 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>{BC07C626-47CC-41D7-BF64-E0842741C697}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>VoxelIsometricRenderer</RootNamespace>
|
||||
<AssemblyName>VoxelIsometricRenderer</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</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.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Terrain4.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Terrain4.Designer.cs">
|
||||
<DependentUpon>Terrain4.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Voxel.cs" />
|
||||
<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>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Terrain4.resx">
|
||||
<DependentUpon>Terrain4.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<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>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\image %282%29.webp" />
|
||||
<None Include="Resources\stone3.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\16xDefaultTile.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\grasstop.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\leaves.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\log.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\logtop.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\ore1.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\spruceleaves.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\sprucelog.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\stone1.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\stone2.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\grasside.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\dirt.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\vine.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\flower.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\grasstall.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\grassmed.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\OrangeSquare.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\PinkSquare.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\RedSquare.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\YellowSquare.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\BlueSquare.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\greenSquare.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\ColourEdges.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\image %283%29.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\image %282%29.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||