Added Rasterizer and first OpenGL project

This commit is contained in:
2016-04-21 10:32:17 +02:00
parent 77199dc094
commit b98c9a979f
16 changed files with 1294 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGL1", "OpenGL1\OpenGL1.vcxproj", "{D5EB815D-142C-4A10-B69D-A4B326B079FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rasterizer", "Rasterizer\Rasterizer.csproj", "{ED0523E4-4D43-4F82-AA49-E878B53A0631}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Debug|Any CPU.ActiveCfg = Debug|Win32
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Debug|x64.ActiveCfg = Debug|x64
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Debug|x64.Build.0 = Debug|x64
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Debug|x86.ActiveCfg = Debug|Win32
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Debug|x86.Build.0 = Debug|Win32
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Release|Any CPU.ActiveCfg = Release|Win32
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Release|x64.ActiveCfg = Release|x64
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Release|x64.Build.0 = Release|x64
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Release|x86.ActiveCfg = Release|Win32
{D5EB815D-142C-4A10-B69D-A4B326B079FC}.Release|x86.Build.0 = Release|Win32
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Debug|x64.ActiveCfg = Debug|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Debug|x64.Build.0 = Debug|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Debug|x86.ActiveCfg = Debug|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Debug|x86.Build.0 = Debug|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Release|Any CPU.Build.0 = Release|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Release|x64.ActiveCfg = Release|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Release|x64.Build.0 = Release|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Release|x86.ActiveCfg = Release|Any CPU
{ED0523E4-4D43-4F82-AA49-E878B53A0631}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+149
View File
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D5EB815D-142C-4A10-B69D-A4B326B079FC}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>OpenGL1</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
</Project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
+147
View File
@@ -0,0 +1,147 @@
namespace Rasterizer
{
partial class Form1
{
/// <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.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout();
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 2;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button1.Location = new System.Drawing.Point(0, 484);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Kubus";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button2.Location = new System.Drawing.Point(81, 484);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 1;
this.button2.Text = "Kegel";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button3.Location = new System.Drawing.Point(243, 484);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 2;
this.button3.Text = "Bol";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button4.Location = new System.Drawing.Point(162, 484);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 3;
this.button4.Text = "Cilinder";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button5.Location = new System.Drawing.Point(660, 484);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 5;
this.button5.Text = "Toepassen";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// numericUpDown1
//
this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDown1.Location = new System.Drawing.Point(534, 484);
this.numericUpDown1.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.numericUpDown1.Size = new System.Drawing.Size(120, 20);
this.numericUpDown1.TabIndex = 6;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(747, 509);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.NumericUpDown numericUpDown1;
}
}
+245
View File
@@ -0,0 +1,245 @@
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 Rasterizer
{
public partial class Form1 : Form
{
TextureBrush myBrush;
int dots = 48;
int buttonPressed = 0;
public Form1()
{
InitializeComponent();
this.DoubleBuffered = true;
}
List<Vector3> vertices = new List<Vector3>();
List<Tuple<List<int>, Color>> polygons = new List<Tuple<List<int>, Color>>();
float rotation;
private void Form1_Load(object sender, EventArgs e)
{
//Create_Cube();
//myBrush = new TextureBrush(new Bitmap(@"C: \Users\kenny\Downloads\MTIwNjA4NjMzOTU5NTgxMTk2.bmp"), System.Drawing.Drawing2D.WrapMode.Tile);
}
private void Create_Cube()
{
vertices.Clear();
polygons.Clear();
vertices.Add(new Vector3(-1, -1, -1));
vertices.Add(new Vector3(1, -1, -1));
vertices.Add(new Vector3(1, 1, -1));
vertices.Add(new Vector3(-1, 1, -1));
vertices.Add(new Vector3(-1, -1, 1));
vertices.Add(new Vector3(1, -1, 1));
vertices.Add(new Vector3(1, 1, 1));
vertices.Add(new Vector3(-1, 1, 1));
polygons.Add(new Tuple<List<int>, Color>(new List<int>() { 0, 1, 2, 3 }, Color.Green));
polygons.Add(new Tuple<List<int>, Color>(new List<int>() { 4, 5, 6, 7 }, Color.Green));
polygons.Add(new Tuple<List<int>, Color>(new List<int>() { 0, 4, 5, 1 }, Color.Green));
polygons.Add(new Tuple<List<int>, Color>(new List<int>() { 2, 6, 7, 3 }, Color.Green));
}
//private void Create_Kegel()
//{
// //vertices.Clear();
// vertices.Add(new Vector3(-1, 0, -1));
// vertices.Add(new Vector3(0, 2, 0));
// vertices.Add(new Vector3(1, 0, -1));
// vertices.Add(new Vector3(-1, 0, 1));
// vertices.Add(new Vector3(0, 2, 0));
// vertices.Add(new Vector3(1, 0, 1));
// vertices.Add(new Vector3(-1, 0, 1));
// vertices.Add(new Vector3(0, 2, 0));
// vertices.Add(new Vector3(1, 0, 1));
// //vertices.Add(new Vector3(-1, 1, -1));
// //vertices.Add(new Vector3(-1, -1, 1));
// //vertices.Add(new Vector3(1, -1, 1));
// //vertices.Add(new Vector3(1, 1, 1));
// //vertices.Add(new Vector3(-1, 1, 1));
// polygons.Add(new List<int>() { 0, 1, 2 });
// polygons.Add(new List<int>() { 3, 4, 5 });
// polygons.Add(new List<int>() { 0, 3, 5, 2 });
// //polygons.Add(new List<int>() { 2, 6, 7, 3 });
//}
private void Create_Pin()
{
vertices.Clear();
polygons.Clear();
for (int i = 0; i < dots; i++)
{
vertices.Add(new Vector3((float)Math.Cos(i * ((360.0f / dots)/180 * Math.PI)), (float)Math.Sin(i * ((360.0f / dots)/180 * Math.PI)), (float)0));
polygons.Add(new Tuple<List<int>, Color>(new List<int>() { i,(i+1) % dots }, Color.Blue));
}
vertices.Add(new Vector3(0, 0, 2));
for(int t =0; t<dots;t++)
{
polygons.Add(new Tuple<List<int>, Color>(new List<int>() { t, dots}, Color.Blue));
}
}
private void Create_Buis()
{
vertices.Clear();
polygons.Clear();
for (int k = 0; k < 2; k++)
{
for (int i = 0; i < dots ; i++)
{
vertices.Add(new Vector3((float)Math.Cos(i * ((360.0f/ dots) / 180 * Math.PI)), (float)Math.Sin(i * ((360.0f/ dots) / 180 * Math.PI)), (float)k));
polygons.Add(new Tuple<List<int>, Color>(new List<int>() { i, (i + 1)% dots }, Color.Blue));
polygons.Add(new Tuple<List<int>, Color>(new List<int>() { i+dots, (i + 1) % dots +dots }, Color.Blue));
}
}
for (int t = 0; t < dots; t++)
{
polygons.Add(new Tuple<List<int>, Color>(new List<int>() { t, t+dots }, Color.Blue));
}
}
private void Create_Bol()
{
vertices.Clear();
polygons.Clear();
int slices = dots;
int stacks = dots;
for(int stack = 0; stack < stacks; ++stack)
{
for(int slice = 0; slice < slices; ++slice)
{
double y = 2.0 * stack / stacks - 1.0;
double r = Math.Sqrt(1 - Math.Pow(y, 2));
double x = r * Math.Sin(2.0 * Math.PI * slice / slices);
double z = r * Math.Cos(2.0 * Math.PI * slice / slices);
vertices.Add(new Vector3((float)x, (float)y, (float)z));
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
rotation += 0.01f;
Invalidate();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
var g = e.Graphics;
g.Clear(Color.Black);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Pen pen = new Pen(Color.PaleVioletRed, 1);
Matrix m = Matrix.identity();
m = m * Matrix.perspective((float)(Math.PI / 2), (float)Width/Height, 0.1f, 20f);
m = m * Matrix.translate(new Vector3(0, 0, -3 + (float)Math.Cos(rotation*8)));
m = m * Matrix.rotation(rotation, new Vector3(0, 1, 0));
m = m * Matrix.rotation((float)Math.Sin(rotation*4)*2, new Vector3(1, 0, 0));
foreach (Vector3 v in vertices)
{
Vector3 vect = new Vector3();
vect = m * v;
vect.x = Width / 2 + vect.x / vect.z * Width / 2;
vect.y = Height / 2 + vect.y / vect.z * Height / 2;
g.DrawRectangle(pen, vect.x - 5, vect.y - 5, 10, 10);
}
pen = new Pen(Color.Aquamarine, 5);
foreach (var _polygon in polygons)
{
var polygon = _polygon.Item1;
Point[] points = new Point[polygon.Count];
for (int p = 0; p < polygon.Count; p++)
{
int curr = polygon[p];
int next = polygon[(p + 1) % polygon.Count];
Vector3 vect1 = m * vertices[curr];
vect1.x = Width / 2 + vect1.x / vect1.z * Width / 2;
vect1.y = Height / 2 + vect1.y / vect1.z * Height / 2;
Vector3 vect2 = m * vertices[next];
vect2.x = Width / 2 + vect2.x / vect2.z * Width / 2;
vect2.y = Height / 2 + vect2.y / vect2.z * Height / 2;
points[p] = new Point((int)vect1.x, (int)vect1.y);
g.DrawLine(new Pen(_polygon.Item2,5), vect1.x, vect1.y, vect2.x, vect2.y);
}
// g.FillPolygon(myBrush, points);
}
}
private void button1_Click(object sender, EventArgs e)
{
Create_Cube();
buttonPressed = 0;
}
private void button2_Click(object sender, EventArgs e)
{
Create_Pin();
buttonPressed = 1;
}
private void button4_Click(object sender, EventArgs e)
{
Create_Buis();
buttonPressed = 2;
}
private void button3_Click(object sender, EventArgs e)
{
Create_Bol();
buttonPressed = 3;
}
private void button5_Click(object sender, EventArgs e)
{
dots = (int) numericUpDown1.Value;
if(buttonPressed==0)
{
Create_Cube();
}
else if (buttonPressed == 1)
{
Create_Pin();
}
else if (buttonPressed == 2)
{
Create_Buis();
}
else if (buttonPressed == 3)
{
Create_Bol();
}
}
}
}
+123
View File
@@ -0,0 +1,123 @@
<?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>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>10, 18</value>
</metadata>
</root>
+108
View File
@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rasterizer
{
struct Matrix
{
float[,] data;
private Matrix(int size = 4)
{
data = new float[size, size];
}
public static Matrix identity()
{
Matrix m = new Matrix(4);
m.data[0,0] = 1;
m.data[1,1] = 1;
m.data[2,2] = 1;
m.data[3,3] = 1;
return m;
}
public static Matrix perspective(float fovy, float aspect, float zNear, float zFar)
{
Matrix m = new Matrix(4);
m.data[0, 0] = (float)((1 / Math.Tan(fovy / 2)) / aspect);
m.data[1, 1] = (float)(1 / Math.Tan(fovy / 2));
m.data[2, 2] = (float)(zFar/(zFar - zNear));
m.data[2, 3] = -1;
m.data[3, 2] = (float)((zNear * zFar) / (zFar - zNear) );
return m;
}
public static Matrix rotation(float angle, Vector3 axis)
{
Matrix m = Matrix.identity();
float c = (float) Math.Cos((double) angle);
float s = (float) Math.Sin((double) angle);
m.data[0, 0] = (float) Math.Pow(axis.x, 2) * (1 - c) + c;
m.data[0, 1] = axis.x * axis.y * (1 - c) - axis.z * s;
m.data[0, 2] = axis.x * axis.z * (1 - c) - axis.y * s;
m.data[1, 0] = axis.x * axis.y * (1 - c) + axis.z * s;
m.data[1, 1] = (float)Math.Pow(axis.y, 2) * (1 - c) + c;
m.data[1, 2] = axis.y * axis.z * (1 - c) + axis.x * s;
m.data[2, 0] = axis.x * axis.z * (1 - c) + axis.y * s;
m.data[2, 1] = axis.y * axis.z * (1 - c) - axis.x * s;
m.data[2, 2] = (float)Math.Pow(axis.z, 2) * (1 - c) + c;
return m;
}
public static Matrix translate(Vector3 offset)
{
Matrix m = Matrix.identity();
for(int i = 0; i < 3; i++)
{
m.data[i, 3] = offset.data[i];
}
return m;
}
public static Vector3 operator * (Matrix mat, Vector3 vec)
{
Vector3 v = new Vector3(0,0,0);
for(int i = 0; i < 4; i++)
{
v.data[i] = 0;
for(int p = 0; p < 4; p++)
{
v.data[i] += mat.data[i, p] * vec.data[p];
}
}
return v;
}
public static Matrix operator * (Matrix mat1, Matrix mat2)
{
Matrix m = Matrix.identity();
for (int i = 0; i < 4; i++)
{
for (int p = 0; p < 4; p++)
{
m.data[i, p] = 0;
for (int q = 0; q < 4; q++)
{
m.data[i, p] += mat1.data[i, q] * mat2.data[q, p];
}
}
}
return m;
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Rasterizer
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
+36
View File
@@ -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("Rasterizer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rasterizer")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[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("ed0523e4-4d43-4f82-aa49-e878b53a0631")]
// 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")]
+71
View File
@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <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 Rasterizer.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("Rasterizer.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;
}
}
}
}
+117
View File
@@ -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>
+30
View 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 Rasterizer.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
View 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>
+92
View File
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{ED0523E4-4D43-4F82-AA49-E878B53A0631}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rasterizer</RootNamespace>
<AssemblyName>Rasterizer</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</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="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Matrix.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Vector3.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.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>
+78
View File
@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rasterizer
{
struct Vector3
{
public float[] data;
public float x { get { return data[0]; } set { data[0] = value; } }
public float y { get { return data[1]; } set { data[1] = value; } }
public float z { get { return data[2]; } set { data[2] = value; } }
public float length { get { return (float)Math.Sqrt(x * x + y * y + z * z); } }
public Vector3(float x, float y, float z)
{
data = new float[4];
this.x = x;
this.y = y;
this.z = z;
data[3] = 1;
}
public Vector3 normalize()
{
Vector3 v = new Vector3(0,0,0);
if (length != 0)
{
v.x = this.x / length;
v.y = this.y / length;
v.z = this.z / length;
}
return v;
}
public static Vector3 operator *(Vector3 vec, float f)
{
Vector3 v = new Vector3(0,0,0);
return v;
}
public static Vector3 operator *(float f, Vector3 vec)
{
Vector3 v = new Vector3(0,0,0);
return v;
}
public static Vector3 operator -(Vector3 a, Vector3 b)
{
Vector3 v = new Vector3(0,0,0);
return v;
}
public static Vector3 operator +(Vector3 a, Vector3 b)
{
Vector3 v = new Vector3(0,0,0);
return v;
}
public Vector3 cross(Vector3 other)
{
throw new NotImplementedException();
}
public float dot(Vector3 other)
{
throw new NotImplementedException();
}
}
}