mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 12:33:12 +00:00
Remove framework files and use a .dll for now. Will add submodule later
This commit is contained in:
parent
7848428ad5
commit
c879a1299c
51 changed files with 14 additions and 5424 deletions
Binary file not shown.
63
GL_EditorFramework-master/.gitattributes
vendored
63
GL_EditorFramework-master/.gitattributes
vendored
|
@ -1,63 +0,0 @@
|
|||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
261
GL_EditorFramework-master/.gitignore
vendored
261
GL_EditorFramework-master/.gitignore
vendored
|
@ -1,261 +0,0 @@
|
|||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
#*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
|
@ -1,31 +0,0 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.136
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gl_EditorFramework", "Gl_EditorFramework\Gl_EditorFramework.csproj", "{D593A72D-554D-40FB-9967-503CB15A744F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testing", "Testing\Testing.csproj", "{860B49C9-54E3-4E10-830D-6497B845ED11}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{860B49C9-54E3-4E10-830D-6497B845ED11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{860B49C9-54E3-4E10-830D-6497B845ED11}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{860B49C9-54E3-4E10-830D-6497B845ED11}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{860B49C9-54E3-4E10-830D-6497B845ED11}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {DF396B96-389A-48D7-8A82-0D3C500F744D}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,71 +0,0 @@
|
|||
using GL_EditorFramework.GL_Core;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework.EditorDrawables
|
||||
{
|
||||
public abstract class EditableObject : AbstractGlDrawable
|
||||
{
|
||||
public static Vector4 hoverColor = new Vector4(1, 1, 0.925f,1);
|
||||
public static Vector4 selectColor = new Vector4(1, 1, 0.675f, 1);
|
||||
|
||||
[Browsable(false)]
|
||||
public bool Visible = true;
|
||||
|
||||
public EditableObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//only gets called when the object is selected
|
||||
public abstract bool CanStartDragging();
|
||||
|
||||
public abstract bool IsSelected();
|
||||
|
||||
public abstract Vector3 GetSelectionCenter();
|
||||
|
||||
public abstract uint SelectAll(I3DControl control);
|
||||
|
||||
public abstract uint SelectDefault(I3DControl control);
|
||||
|
||||
public virtual void Draw(GL_ControlModern control, Pass pass, EditorScene editorScene)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Draw(GL_ControlLegacy control, Pass pass, EditorScene editorScene)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract uint Select(int partIndex, I3DControl control);
|
||||
|
||||
public abstract uint Deselect(int partIndex, I3DControl control);
|
||||
public abstract uint DeselectAll(I3DControl control);
|
||||
|
||||
public abstract void ApplyTransformationToSelection(DeltaTransform deltaTransform);
|
||||
|
||||
public struct DeltaTransform
|
||||
{
|
||||
public Vector3 Translation;
|
||||
public Quaternion Rotation;
|
||||
public Vector3 Scaling;
|
||||
|
||||
public DeltaTransform(Vector3 Translation, Quaternion Rotation, Vector3 Scaling)
|
||||
{
|
||||
this.Translation = Translation;
|
||||
this.Rotation = Rotation;
|
||||
this.Scaling = Scaling;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,604 +0,0 @@
|
|||
using GL_EditorFramework.GL_Core;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using OpenTK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework.EditorDrawables
|
||||
{
|
||||
public class EditorScene : AbstractGlDrawable
|
||||
{
|
||||
protected bool multiSelect;
|
||||
|
||||
public EditableObject hovered = null;
|
||||
|
||||
public int hoveredPart = 0;
|
||||
|
||||
public List<EditableObject> objects = new List<EditableObject>();
|
||||
|
||||
protected List<EditableObject> selectedObjects = new List<EditableObject>();
|
||||
|
||||
public List<AbstractGlDrawable> staticObjects = new List<AbstractGlDrawable>();
|
||||
|
||||
public event EventHandler SelectionChanged;
|
||||
|
||||
private float draggingDepth;
|
||||
|
||||
private GL_ControlBase control;
|
||||
|
||||
public EditableObject.DeltaTransform deltaTransform = new EditableObject.DeltaTransform(new Vector3(), new Quaternion(), new Vector3(1,1,1));
|
||||
|
||||
public EditorScene(bool multiSelect = true)
|
||||
{
|
||||
this.multiSelect = multiSelect;
|
||||
}
|
||||
|
||||
public List<EditableObject> SelectedObjects
|
||||
{
|
||||
get => selectedObjects;
|
||||
set
|
||||
{
|
||||
uint var = 0;
|
||||
foreach (EditableObject obj in value)
|
||||
{
|
||||
if (!selectedObjects.Contains(obj)) //object wasn't selected before
|
||||
var |= obj.SelectDefault(control); //select it
|
||||
|
||||
else //object stays selected
|
||||
selectedObjects.Remove(obj); //filter out these to find all objects which are not selected anymore
|
||||
|
||||
Console.WriteLine(obj);
|
||||
}
|
||||
|
||||
foreach (EditableObject obj in selectedObjects) //now the selected objects are a list of objects to deselect
|
||||
//which is fine because in the end they get overwriten anyway
|
||||
{
|
||||
var |= obj.DeselectAll(control); //Deselect them all
|
||||
}
|
||||
selectedObjects = value;
|
||||
|
||||
if ((var & AbstractGlDrawable.REDRAW)>0)
|
||||
control.Refresh();
|
||||
if ((var & AbstractGlDrawable.REDRAW_PICKING) > 0)
|
||||
control.DrawPicking();
|
||||
}
|
||||
}
|
||||
|
||||
public void ToogleSelected(EditableObject obj, bool isSelected)
|
||||
{
|
||||
uint var = 0;
|
||||
|
||||
bool alreadySelected = selectedObjects.Contains(obj);
|
||||
if(alreadySelected && !isSelected)
|
||||
{
|
||||
var |= obj.DeselectAll(control);
|
||||
selectedObjects.Remove(obj);
|
||||
}
|
||||
else if(!alreadySelected && isSelected)
|
||||
{
|
||||
var |= obj.SelectDefault(control);
|
||||
selectedObjects.Add(obj);
|
||||
}
|
||||
|
||||
if ((var & AbstractGlDrawable.REDRAW)>0)
|
||||
control.Refresh();
|
||||
if ((var & AbstractGlDrawable.REDRAW_PICKING) > 0)
|
||||
control.DrawPicking();
|
||||
}
|
||||
|
||||
public void Add(params EditableObject[] objs)
|
||||
{
|
||||
uint var = 0;
|
||||
|
||||
foreach (EditableObject selected in selectedObjects)
|
||||
{
|
||||
var |= selected.DeselectAll(control);
|
||||
}
|
||||
selectedObjects.Clear();
|
||||
|
||||
foreach (EditableObject obj in objs)
|
||||
{
|
||||
objects.Add(obj);
|
||||
|
||||
selectedObjects.Add(obj);
|
||||
var |= obj.SelectDefault(control);
|
||||
}
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
|
||||
if ((var & AbstractGlDrawable.REDRAW) > 0)
|
||||
control.Refresh();
|
||||
if ((var & AbstractGlDrawable.REDRAW_PICKING) > 0)
|
||||
control.DrawPicking();
|
||||
}
|
||||
|
||||
public void Delete(params EditableObject[] objs)
|
||||
{
|
||||
uint var = 0;
|
||||
|
||||
bool selectionHasChanged = false;
|
||||
|
||||
foreach (EditableObject obj in objs)
|
||||
{
|
||||
objects.Remove(obj);
|
||||
if (selectedObjects.Contains(obj))
|
||||
{
|
||||
var |= obj.DeselectAll(control);
|
||||
selectedObjects.Remove(obj);
|
||||
}
|
||||
}
|
||||
if(selectionHasChanged)
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
|
||||
if ((var & AbstractGlDrawable.REDRAW) > 0)
|
||||
control.Refresh();
|
||||
if ((var & AbstractGlDrawable.REDRAW_PICKING) > 0)
|
||||
control.DrawPicking();
|
||||
}
|
||||
|
||||
public void InsertAfter(int index, params EditableObject[] objs)
|
||||
{
|
||||
uint var = 0;
|
||||
|
||||
foreach (EditableObject selected in selectedObjects)
|
||||
{
|
||||
var |= selected.DeselectAll(control);
|
||||
}
|
||||
selectedObjects.Clear();
|
||||
|
||||
foreach (EditableObject obj in objs)
|
||||
{
|
||||
objects.Insert(index, obj);
|
||||
|
||||
selectedObjects.Add(obj);
|
||||
var |= obj.SelectDefault(control);
|
||||
index++;
|
||||
}
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
|
||||
if ((var & AbstractGlDrawable.REDRAW) > 0)
|
||||
control.Refresh();
|
||||
if ((var & AbstractGlDrawable.REDRAW_PICKING) > 0)
|
||||
control.DrawPicking();
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlModern control, Pass pass)
|
||||
{
|
||||
foreach (EditableObject obj in objects)
|
||||
{
|
||||
if(obj.Visible)
|
||||
obj.Draw(control, pass, this);
|
||||
}
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
obj.Draw(control, pass);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass)
|
||||
{
|
||||
foreach (EditableObject obj in objects)
|
||||
{
|
||||
if (obj.Visible)
|
||||
obj.Draw(control, pass, this);
|
||||
}
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
obj.Draw(control, pass);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
this.control = control;
|
||||
foreach (EditableObject obj in objects)
|
||||
obj.Prepare(control);
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
obj.Prepare(control);
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlLegacy control)
|
||||
{
|
||||
this.control = control;
|
||||
foreach (EditableObject obj in objects)
|
||||
obj.Prepare(control);
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
obj.Prepare(control);
|
||||
}
|
||||
|
||||
public override uint MouseDown(MouseEventArgs e, I3DControl control)
|
||||
{
|
||||
uint var = 0;
|
||||
if (draggingDepth == -1 && e.Button == MouseButtons.Left && selectedObjects.Contains(hovered))
|
||||
{
|
||||
if(hovered.CanStartDragging())
|
||||
draggingDepth = control.PickingDepth;
|
||||
}
|
||||
foreach (EditableObject obj in objects)
|
||||
{
|
||||
var |= obj.MouseDown(e, control);
|
||||
}
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
var |= obj.MouseDown(e, control);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
public override uint MouseMove(MouseEventArgs e, Point lastMousePos, I3DControl control)
|
||||
{
|
||||
uint var = 0;
|
||||
|
||||
foreach (EditableObject obj in objects)
|
||||
{
|
||||
var |= obj.MouseMove(e, lastMousePos, control);
|
||||
}
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
var |= obj.MouseMove(e, lastMousePos, control);
|
||||
}
|
||||
|
||||
if (draggingDepth != -1)
|
||||
{
|
||||
Vector3 translation = new Vector3();
|
||||
|
||||
//code from Whitehole
|
||||
|
||||
float deltaX = e.X - control.DragStartPos.X;
|
||||
float deltaY = e.Y - control.DragStartPos.Y;
|
||||
|
||||
deltaX *= draggingDepth * control.FactorX;
|
||||
deltaY *= draggingDepth * control.FactorY;
|
||||
|
||||
translation += Vector3.UnitX * deltaX * (float)Math.Cos(control.CamRotX);
|
||||
translation -= Vector3.UnitX * deltaY * (float)Math.Sin(control.CamRotX) * (float)Math.Sin(control.CamRotY);
|
||||
translation -= Vector3.UnitY * deltaY * (float)Math.Cos(control.CamRotY);
|
||||
translation += Vector3.UnitZ * deltaX * (float)Math.Sin(control.CamRotX);
|
||||
translation += Vector3.UnitZ * deltaY * (float)Math.Cos(control.CamRotX) * (float)Math.Sin(control.CamRotY);
|
||||
|
||||
deltaTransform.Translation = translation;
|
||||
|
||||
var |= REDRAW | NO_CAMERA_ACTION;
|
||||
|
||||
var &= ~REPICK;
|
||||
}
|
||||
else
|
||||
{
|
||||
var |= REPICK;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
public override uint MouseUp(MouseEventArgs e, I3DControl control)
|
||||
{
|
||||
uint var = 0;
|
||||
|
||||
if (!(draggingDepth == -1)&&e.Button == MouseButtons.Left)
|
||||
{
|
||||
foreach (EditableObject obj in selectedObjects)
|
||||
{
|
||||
obj.ApplyTransformationToSelection(deltaTransform);
|
||||
}
|
||||
|
||||
deltaTransform = new EditableObject.DeltaTransform(new Vector3(), new Quaternion(), new Vector3(1, 1, 1));
|
||||
}
|
||||
|
||||
foreach (EditableObject obj in objects)
|
||||
{
|
||||
var |= obj.MouseUp(e, control);
|
||||
}
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
var |= obj.MouseUp(e, control);
|
||||
}
|
||||
|
||||
draggingDepth = -1;
|
||||
return var;
|
||||
}
|
||||
|
||||
public override uint MouseClick(MouseEventArgs e, I3DControl control)
|
||||
{
|
||||
uint var = 0;
|
||||
foreach (EditableObject obj in objects)
|
||||
{
|
||||
var |= obj.MouseClick(e, control);
|
||||
}
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
var |= obj.MouseClick(e, control);
|
||||
}
|
||||
|
||||
if (!(e.Button == MouseButtons.Left))
|
||||
return var;
|
||||
|
||||
if (!(multiSelect && OpenTK.Input.Keyboard.GetState().IsKeyDown(OpenTK.Input.Key.ShiftLeft)))
|
||||
{
|
||||
if (multiSelect)
|
||||
{
|
||||
if (!selectedObjects.Contains(hovered))
|
||||
{
|
||||
foreach (EditableObject selected in selectedObjects)
|
||||
{
|
||||
selected.DeselectAll(control);
|
||||
}
|
||||
}
|
||||
|
||||
if (hovered != null && !selectedObjects.Contains(hovered))
|
||||
{
|
||||
selectedObjects.Clear();
|
||||
selectedObjects.Add(hovered);
|
||||
hovered.Select(hoveredPart,control);
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
else if(hovered == null)
|
||||
{
|
||||
selectedObjects.Clear();
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (EditableObject selected in selectedObjects)
|
||||
{
|
||||
selected.DeselectAll(control);
|
||||
}
|
||||
|
||||
if (hovered != null && !selectedObjects.Contains(hovered))
|
||||
{
|
||||
selectedObjects.Clear();
|
||||
selectedObjects.Add(hovered);
|
||||
hovered.Select(hoveredPart, control);
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedObjects.Clear();
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedObjects.Contains(hovered))
|
||||
{
|
||||
selectedObjects.Remove(hovered);
|
||||
hovered.Deselect(hoveredPart, control);
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
else if(hovered != null)
|
||||
{
|
||||
selectedObjects.Add(hovered);
|
||||
hovered.Select(hoveredPart, control);
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
draggingDepth = -1; //because MouseClick implies that the Mouse Button is not pressed anymore
|
||||
|
||||
var |= REDRAW;
|
||||
|
||||
return var;
|
||||
}
|
||||
|
||||
public override uint MouseWheel(MouseEventArgs e, I3DControl control)
|
||||
{
|
||||
uint var = 0;
|
||||
foreach (EditableObject obj in objects) {
|
||||
var |= obj.MouseWheel(e, control);
|
||||
}
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
var |= obj.MouseWheel(e, control);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
public override int GetPickableSpan()
|
||||
{
|
||||
int var = 0;
|
||||
foreach (EditableObject obj in objects)
|
||||
var += obj.GetPickableSpan();
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
var += obj.GetPickableSpan();
|
||||
return var;
|
||||
}
|
||||
|
||||
public override uint MouseEnter(int index, I3DControl control)
|
||||
{
|
||||
int inObjectIndex = index;
|
||||
if(!(draggingDepth == -1))
|
||||
return 0;
|
||||
|
||||
foreach (EditableObject obj in objects)
|
||||
{
|
||||
int span = obj.GetPickableSpan();
|
||||
Console.WriteLine(obj.ToString() + " span " + span.ToString());
|
||||
Console.WriteLine(obj.ToString() + " inObjectIndex " + inObjectIndex.ToString());
|
||||
|
||||
if (inObjectIndex >= 0 && inObjectIndex < span)
|
||||
{
|
||||
hovered = obj;
|
||||
return obj.MouseEnter(inObjectIndex, control) | REDRAW;
|
||||
}
|
||||
inObjectIndex -= span;
|
||||
}
|
||||
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
int span = obj.GetPickableSpan();
|
||||
if (inObjectIndex >= 0 && inObjectIndex < span)
|
||||
{
|
||||
return obj.MouseEnter(inObjectIndex, control);
|
||||
}
|
||||
inObjectIndex -= span;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override uint MouseLeave(int index, I3DControl control)
|
||||
{
|
||||
int inObjectIndex = index;
|
||||
foreach (EditableObject obj in objects)
|
||||
{
|
||||
int span = obj.GetPickableSpan();
|
||||
if (inObjectIndex >= 0 && inObjectIndex < span)
|
||||
{
|
||||
return obj.MouseLeave(inObjectIndex, control);
|
||||
}
|
||||
inObjectIndex -= span;
|
||||
}
|
||||
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
int span = obj.GetPickableSpan();
|
||||
if (inObjectIndex >= 0 && inObjectIndex < span)
|
||||
{
|
||||
return obj.MouseLeave(inObjectIndex, control);
|
||||
}
|
||||
inObjectIndex -= span;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override uint MouseLeaveEntirely(I3DControl control)
|
||||
{
|
||||
hovered = null;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint KeyDown(KeyEventArgs e, I3DControl control)
|
||||
{
|
||||
uint var = 0;
|
||||
if(e.KeyCode == Keys.Z && selectedObjects.Count>0)
|
||||
{
|
||||
Vector3 sum = new Vector3();
|
||||
int index = 0;
|
||||
foreach (EditableObject selected in selectedObjects)
|
||||
{
|
||||
sum -= selected.GetSelectionCenter();
|
||||
index++;
|
||||
}
|
||||
sum /= index;
|
||||
control.CameraTarget = sum;
|
||||
|
||||
var = REDRAW_PICKING;
|
||||
}else if (e.KeyCode == Keys.H && selectedObjects.Count > 0)
|
||||
{
|
||||
foreach (EditableObject selected in selectedObjects)
|
||||
{
|
||||
selected.Visible = e.Shift;
|
||||
}
|
||||
var = REDRAW_PICKING;
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.A)
|
||||
{
|
||||
if (e.Shift)
|
||||
{
|
||||
foreach (EditableObject selected in selectedObjects)
|
||||
{
|
||||
selected.DeselectAll(control);
|
||||
}
|
||||
selectedObjects.Clear();
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
|
||||
if (!e.Shift && multiSelect)
|
||||
{
|
||||
foreach (EditableObject obj in objects)
|
||||
{
|
||||
obj.SelectAll(control);
|
||||
selectedObjects.Add(obj);
|
||||
}
|
||||
SelectionChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
var = REDRAW;
|
||||
}
|
||||
|
||||
foreach (EditableObject obj in objects) {
|
||||
var |= obj.KeyDown(e, control);
|
||||
}
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
var |= obj.KeyDown(e, control);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
public override uint KeyUp(KeyEventArgs e, I3DControl control)
|
||||
{
|
||||
uint var = 0;
|
||||
foreach (EditableObject obj in objects) {
|
||||
var |= obj.KeyUp(e, control);
|
||||
}
|
||||
foreach (AbstractGlDrawable obj in staticObjects)
|
||||
{
|
||||
var |= obj.KeyUp(e, control);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
public struct SelectInfo
|
||||
{
|
||||
public Vector3 LastPos;
|
||||
|
||||
public SelectInfo(Vector3 LastPos)
|
||||
{
|
||||
this.LastPos = LastPos;
|
||||
}
|
||||
}
|
||||
|
||||
public struct ObjID : IEquatable<ObjID>
|
||||
{
|
||||
public int ObjectIndex;
|
||||
public int SubObjectIndex;
|
||||
|
||||
public static readonly ObjID None = new ObjID(-1, -1);
|
||||
|
||||
public bool IsNone()
|
||||
{
|
||||
return (ObjectIndex == -1) || (SubObjectIndex == -1);
|
||||
}
|
||||
|
||||
public ObjID(int ObjectIndex, int SubObjectIndex)
|
||||
{
|
||||
this.ObjectIndex = ObjectIndex;
|
||||
this.SubObjectIndex = SubObjectIndex;
|
||||
}
|
||||
|
||||
public bool Equals(ObjID other)
|
||||
{
|
||||
return (ObjectIndex == other.ObjectIndex)&&(SubObjectIndex==other.SubObjectIndex);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (ObjectIndex << 32) + SubObjectIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class AbstractTransformAction
|
||||
{
|
||||
public abstract Vector3 newPos(Vector3 pos);
|
||||
|
||||
public Quaternion deltaRotation;
|
||||
|
||||
public Vector3 scale;
|
||||
|
||||
public void SetDragDist(Point point) { }
|
||||
public void SetScrollDragDist(Point point, Point projX, Point projY, Point projZ) { }
|
||||
}
|
||||
|
||||
public class TranslateAction : AbstractTransformAction
|
||||
{
|
||||
Vector3 translation = new Vector3();
|
||||
public override Vector3 newPos(Vector3 pos)
|
||||
{
|
||||
return pos + translation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,452 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using GL_EditorFramework.GL_Core;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace GL_EditorFramework.EditorDrawables
|
||||
{
|
||||
//this class is under developemnt and won't work right now
|
||||
|
||||
/*
|
||||
public class Path : EditableObject
|
||||
{
|
||||
private static bool Initialized = false;
|
||||
private static ShaderProgram defaultShaderProgram;
|
||||
private static ShaderProgram defaultLinesShaderProgram;
|
||||
private static ShaderProgram connectLinesShaderProgram;
|
||||
|
||||
private List<PathPoint> pathPoints;
|
||||
|
||||
protected Vector4 lineColor = new Vector4(0.75f, 1f, 1f, 1f);
|
||||
|
||||
public Path()
|
||||
{
|
||||
pathPoints = new List<PathPoint>();
|
||||
pathPoints.Add(new PathPoint(
|
||||
new Vector3d(0, 0, 0),
|
||||
new Vector3d(0, 0, 0),
|
||||
new Vector3d(3, 0, 0)
|
||||
));
|
||||
pathPoints.Add(new PathPoint(
|
||||
new Vector3d(8, 4, 2),
|
||||
new Vector3d(-4, 0, 4),
|
||||
new Vector3d(4, 0, -4)
|
||||
));
|
||||
pathPoints.Add(new PathPoint(
|
||||
new Vector3d(4, 2, -6),
|
||||
new Vector3d(0, 0, 0),
|
||||
new Vector3d(0, 0, 0)
|
||||
));
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlModern control)
|
||||
{
|
||||
GL.LineWidth(2f);
|
||||
control.CurrentShader = defaultShaderProgram;
|
||||
|
||||
Matrix4 mtx = Matrix4.CreateTranslation(Position);
|
||||
control.UpdateModelMatrix(mtx);
|
||||
|
||||
GL.Uniform1(defaultShaderProgram["scale"], 0.5f);
|
||||
|
||||
bool picked = EditorScene.IsHovered();
|
||||
|
||||
GL.Begin(PrimitiveType.Points);
|
||||
{
|
||||
int i = 1;
|
||||
foreach (PathPoint point in pathPoints)
|
||||
{
|
||||
GL.VertexAttrib4(1, (picked || EditorScene.IsHovered(i)) ? CubeColor * 0.5f + hoverColor * 0.5f : CubeColor);
|
||||
GL.VertexAttrib3(2, point.controlPoint1);
|
||||
GL.VertexAttrib3(3, point.controlPoint2);
|
||||
GL.Vertex3(point.position);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
GL.End();
|
||||
|
||||
control.CurrentShader = defaultLinesShaderProgram;
|
||||
GL.Uniform1(defaultLinesShaderProgram["scale"], 0.5f);
|
||||
|
||||
GL.Begin(PrimitiveType.Points);
|
||||
{
|
||||
int i = 1;
|
||||
foreach (PathPoint point in pathPoints)
|
||||
{
|
||||
GL.VertexAttrib4(1, (picked || EditorScene.IsHovered(i)) ? hoverColor : lineColor);
|
||||
GL.VertexAttrib3(2, point.controlPoint1);
|
||||
GL.VertexAttrib3(3, point.controlPoint2);
|
||||
GL.Vertex3(point.position);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
GL.End();
|
||||
|
||||
control.CurrentShader = connectLinesShaderProgram;
|
||||
|
||||
GL.Uniform4(connectLinesShaderProgram["color"], picked ? hoverColor : CubeColor);
|
||||
|
||||
GL.Begin(PrimitiveType.Lines);
|
||||
for(int i = 1; i<pathPoints.Count; i++)
|
||||
{
|
||||
PathPoint p1 = pathPoints[i - 1];
|
||||
PathPoint p2 = pathPoints[i];
|
||||
|
||||
GL.VertexAttrib3(1, p1.controlPoint2);
|
||||
GL.Vertex3(p1.position);
|
||||
|
||||
GL.VertexAttrib3(1, p2.controlPoint1);
|
||||
GL.Vertex3(p2.position);
|
||||
}
|
||||
GL.End();
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlLegacy control)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void DrawPicking(GL_ControlModern control)
|
||||
{
|
||||
control.CurrentShader = connectLinesShaderProgram;
|
||||
|
||||
Matrix4 mtx = Matrix4.CreateTranslation(Position);
|
||||
control.UpdateModelMatrix(mtx);
|
||||
|
||||
GL.Uniform4(connectLinesShaderProgram["color"], control.nextPickingColor());
|
||||
|
||||
GL.Begin(PrimitiveType.Lines);
|
||||
for (int i = 1; i < pathPoints.Count; i++)
|
||||
{
|
||||
PathPoint p1 = pathPoints[i - 1];
|
||||
PathPoint p2 = pathPoints[i];
|
||||
|
||||
GL.VertexAttrib3(1, p1.controlPoint2);
|
||||
GL.Vertex3(p1.position);
|
||||
|
||||
GL.VertexAttrib3(1, p2.controlPoint1);
|
||||
GL.Vertex3(p2.position);
|
||||
}
|
||||
GL.End();
|
||||
|
||||
control.CurrentShader = defaultShaderProgram;
|
||||
GL.Uniform1(defaultShaderProgram["scale"], 0.5f);
|
||||
GL.Begin(PrimitiveType.Points);
|
||||
foreach (PathPoint point in pathPoints)
|
||||
{
|
||||
System.Drawing.Color c = control.nextPickingColor();
|
||||
GL.VertexAttrib4(1, c.R/256f, c.G / 256f, c.B / 256f, c.A / 256f);
|
||||
GL.VertexAttrib3(2, point.controlPoint1);
|
||||
GL.VertexAttrib3(3, point.controlPoint2);
|
||||
GL.Vertex3(point.position);
|
||||
}
|
||||
GL.End();
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
if (!Initialized)
|
||||
{
|
||||
var defaultFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
in vec4 fragColor;
|
||||
void main(){
|
||||
gl_FragColor = fragColor;
|
||||
}");
|
||||
|
||||
var defaultVert = new VertexShader(
|
||||
@"#version 330
|
||||
in vec4 position;
|
||||
|
||||
layout(location = 1) in vec4 color;
|
||||
layout(location = 2) in vec3 _cp1;
|
||||
layout(location = 3) in vec3 _cp2;
|
||||
|
||||
out vec4 vertColor;
|
||||
out vec4 cp1;
|
||||
out vec4 cp2;
|
||||
|
||||
void main(){
|
||||
cp1 = vec4(_cp1,0);
|
||||
cp2 = vec4(_cp2,0);
|
||||
vertColor = color;
|
||||
gl_Position = position;
|
||||
}");
|
||||
|
||||
#region block shader
|
||||
defaultShaderProgram = new ShaderProgram(defaultFrag, defaultVert);
|
||||
|
||||
defaultShaderProgram.AttachShader(new Shader(
|
||||
@"#version 330
|
||||
layout(points) in;
|
||||
layout(triangle_strip, max_vertices = 72) out;
|
||||
|
||||
in vec4 vertColor[];
|
||||
in vec4 cp1[];
|
||||
in vec4 cp2[];
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform mat4 mtxMdl;
|
||||
uniform mat4 mtxCam;
|
||||
uniform float scale;
|
||||
|
||||
float cubeScale;
|
||||
vec4 pos;
|
||||
|
||||
mat4 mtx = mtxCam*mtxMdl;
|
||||
|
||||
vec4 points[8] = vec4[](
|
||||
vec4(-1.0,-1.0,-1.0, 0.0),
|
||||
vec4( 1.0,-1.0,-1.0, 0.0),
|
||||
vec4(-1.0, 1.0,-1.0, 0.0),
|
||||
vec4( 1.0, 1.0,-1.0, 0.0),
|
||||
vec4(-1.0,-1.0, 1.0, 0.0),
|
||||
vec4( 1.0,-1.0, 1.0, 0.0),
|
||||
vec4(-1.0, 1.0, 1.0, 0.0),
|
||||
vec4( 1.0, 1.0, 1.0, 0.0)
|
||||
);
|
||||
|
||||
void face(int p1, int p2, int p3, int p4){
|
||||
gl_Position = mtx * (pos + points[p1]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p2]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p3]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p4]*cubeScale); EmitVertex();
|
||||
EndPrimitive();
|
||||
}
|
||||
|
||||
void faceInv(int p3, int p4, int p1, int p2){
|
||||
gl_Position = mtx * (pos + points[p1]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p2]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p3]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p4]*cubeScale); EmitVertex();
|
||||
EndPrimitive();
|
||||
}
|
||||
|
||||
void main(){
|
||||
cubeScale = scale;
|
||||
pos = gl_in[0].gl_Position;
|
||||
fragColor = vertColor[0];
|
||||
face(0,1,2,3);
|
||||
faceInv(4,5,6,7);
|
||||
faceInv(0,1,4,5);
|
||||
face(2,3,6,7);
|
||||
face(0,2,4,6);
|
||||
faceInv(1,3,5,7);
|
||||
|
||||
cubeScale = scale*0.5;
|
||||
|
||||
if(cp1[0]!=vec4(0,0,0,0)){
|
||||
pos = gl_in[0].gl_Position+cp1[0];
|
||||
face(0,1,2,3);
|
||||
faceInv(4,5,6,7);
|
||||
faceInv(0,1,4,5);
|
||||
face(2,3,6,7);
|
||||
face(0,2,4,6);
|
||||
faceInv(1,3,5,7);
|
||||
}
|
||||
|
||||
if(cp2[0]!=vec4(0,0,0,0)){
|
||||
pos = gl_in[0].gl_Position+cp2[0];
|
||||
face(0,1,2,3);
|
||||
faceInv(4,5,6,7);
|
||||
faceInv(0,1,4,5);
|
||||
face(2,3,6,7);
|
||||
face(0,2,4,6);
|
||||
faceInv(1,3,5,7);
|
||||
}
|
||||
}
|
||||
", ShaderType.GeometryShader));
|
||||
|
||||
defaultShaderProgram.LinkShaders();
|
||||
#endregion
|
||||
|
||||
#region lines shader
|
||||
defaultLinesShaderProgram = new ShaderProgram(defaultFrag, defaultVert);
|
||||
|
||||
defaultLinesShaderProgram.AttachShader(new Shader(
|
||||
@"#version 330
|
||||
layout(points) in;
|
||||
layout(line_strip, max_vertices = 72) out;
|
||||
|
||||
in vec4 vertColor[];
|
||||
in vec4 cp1[];
|
||||
in vec4 cp2[];
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform mat4 mtxMdl;
|
||||
uniform mat4 mtxCam;
|
||||
uniform float scale;
|
||||
|
||||
float cubeScale;
|
||||
vec4 pos;
|
||||
|
||||
mat4 mtx = mtxCam*mtxMdl;
|
||||
|
||||
vec4 points[8] = vec4[](
|
||||
vec4(-1.0,-1.0,-1.0, 0.0),
|
||||
vec4( 1.0,-1.0,-1.0, 0.0),
|
||||
vec4(-1.0, 1.0,-1.0, 0.0),
|
||||
vec4( 1.0, 1.0,-1.0, 0.0),
|
||||
vec4(-1.0,-1.0, 1.0, 0.0),
|
||||
vec4( 1.0,-1.0, 1.0, 0.0),
|
||||
vec4(-1.0, 1.0, 1.0, 0.0),
|
||||
vec4( 1.0, 1.0, 1.0, 0.0)
|
||||
);
|
||||
|
||||
void face(int p1, int p2, int p4, int p3){
|
||||
gl_Position = mtx * (pos + points[p1]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p2]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p3]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p4]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p1]*cubeScale); EmitVertex();
|
||||
EndPrimitive();
|
||||
}
|
||||
|
||||
void line(int p1, int p2){
|
||||
gl_Position = mtx * (pos + points[p1]*cubeScale); EmitVertex();
|
||||
gl_Position = mtx * (pos + points[p2]*cubeScale); EmitVertex();
|
||||
EndPrimitive();
|
||||
}
|
||||
|
||||
void main(){
|
||||
cubeScale = scale;
|
||||
pos = gl_in[0].gl_Position;
|
||||
fragColor = vertColor[0];
|
||||
face(0,1,2,3);
|
||||
face(4,5,6,7);
|
||||
line(0,4);
|
||||
line(1,5);
|
||||
line(2,6);
|
||||
line(3,7);
|
||||
|
||||
cubeScale = scale*0.5;
|
||||
|
||||
if(cp1[0]!=vec4(0,0,0,0)){
|
||||
pos = gl_in[0].gl_Position+cp1[0];
|
||||
face(0,1,2,3);
|
||||
face(4,5,6,7);
|
||||
line(0,4);
|
||||
line(1,5);
|
||||
line(2,6);
|
||||
line(3,7);
|
||||
}
|
||||
|
||||
if(cp2[0]!=vec4(0,0,0,0)){
|
||||
pos = gl_in[0].gl_Position+cp2[0];
|
||||
face(0,1,2,3);
|
||||
face(4,5,6,7);
|
||||
line(0,4);
|
||||
line(1,5);
|
||||
line(2,6);
|
||||
line(3,7);
|
||||
}
|
||||
}
|
||||
", ShaderType.GeometryShader));
|
||||
|
||||
defaultLinesShaderProgram.LinkShaders();
|
||||
#endregion
|
||||
|
||||
var connectLinesFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
uniform vec4 color;
|
||||
void main(){
|
||||
gl_FragColor = color;
|
||||
}");
|
||||
var connectLinesVert = new VertexShader(
|
||||
@"#version 330
|
||||
in vec4 position;
|
||||
|
||||
layout(location = 1) in vec3 _controlPoint;
|
||||
|
||||
out vec4 controlPoint;
|
||||
|
||||
void main(){
|
||||
controlPoint = vec4(_controlPoint,0.0);
|
||||
gl_Position = position;
|
||||
}");
|
||||
|
||||
#region connections shader
|
||||
connectLinesShaderProgram = new ShaderProgram(connectLinesFrag, connectLinesVert);
|
||||
|
||||
connectLinesShaderProgram.AttachShader(new Shader(
|
||||
@"#version 330
|
||||
layout(lines) in;
|
||||
layout(line_strip, max_vertices = 19) out;
|
||||
|
||||
in vec4 controlPoint[];
|
||||
|
||||
uniform mat4 mtxMdl;
|
||||
uniform mat4 mtxCam;
|
||||
|
||||
mat4 mtx = mtxCam*mtxMdl;
|
||||
|
||||
vec4 p0 = gl_in[0].gl_Position;
|
||||
vec4 p1 = gl_in[0].gl_Position + controlPoint[0];
|
||||
vec4 p2 = gl_in[1].gl_Position + controlPoint[1];
|
||||
vec4 p3 = gl_in[1].gl_Position;
|
||||
|
||||
void getPointAtTime(float t){
|
||||
float u = 1f - t;
|
||||
float tt = t * t;
|
||||
float uu = u * u;
|
||||
float uuu = uu * u;
|
||||
float ttt = tt * t;
|
||||
|
||||
gl_Position = mtx * (uuu * p0 +
|
||||
3 * uu * t * p1 +
|
||||
3 * u *tt * p2 +
|
||||
ttt * p3);
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
|
||||
void main(){
|
||||
gl_Position = mtx * p1;
|
||||
EmitVertex();
|
||||
for(float t = 0; t<=1.0; t+=0.0625){
|
||||
getPointAtTime(t);
|
||||
}
|
||||
gl_Position = mtx * p2;
|
||||
EmitVertex();
|
||||
EndPrimitive();
|
||||
}
|
||||
", ShaderType.GeometryShader));
|
||||
#endregion
|
||||
|
||||
connectLinesShaderProgram.LinkShaders();
|
||||
|
||||
Initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlLegacy control)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override int GetPickableSpan() => pathPoints.Count + 1;
|
||||
|
||||
|
||||
|
||||
struct PathPoint
|
||||
{
|
||||
public PathPoint(Vector3d position, Vector3d controlPoint1, Vector3d controlPoint2)
|
||||
{
|
||||
this.position = position;
|
||||
this.controlPoint1 = controlPoint1;
|
||||
this.controlPoint2 = controlPoint2;
|
||||
}
|
||||
public Vector3d position;
|
||||
public Vector3d controlPoint1;
|
||||
public Vector3d controlPoint2;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
using GL_EditorFramework.GL_Core;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using OpenGl_EditorFramework;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework.EditorDrawables
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// An EditableObject that has only one selectable Part. It's represented by a blue block
|
||||
public class SingleObject : EditableObject
|
||||
{
|
||||
public Vector3 Position = new Vector3(0, 0, 0);
|
||||
|
||||
protected bool Selected = false;
|
||||
|
||||
public override bool IsSelected() => Selected;
|
||||
|
||||
protected static Vector4 Color = new Vector4(0f, 0.25f, 1f, 1f);
|
||||
|
||||
|
||||
|
||||
public SingleObject(Vector3 pos)
|
||||
{
|
||||
Position = pos;
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlModern control, Pass pass, EditorScene editorScene)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
bool hovered = editorScene.hovered == this;
|
||||
|
||||
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
||||
Matrix4.CreateTranslation(Position + (Selected ? editorScene.deltaTransform.Translation : new Vector3())));
|
||||
|
||||
Vector4 blockColor;
|
||||
Vector4 lineColor;
|
||||
|
||||
if (hovered && Selected)
|
||||
lineColor = hoverColor;
|
||||
else if (hovered || Selected)
|
||||
lineColor = selectColor;
|
||||
else
|
||||
lineColor = Color;
|
||||
|
||||
if (hovered && Selected)
|
||||
blockColor = Color * 0.5f + hoverColor * 0.5f;
|
||||
else if (hovered || Selected)
|
||||
blockColor = Color * 0.5f + selectColor * 0.5f;
|
||||
else
|
||||
blockColor = Color;
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, blockColor, lineColor, control.nextPickingColor());
|
||||
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlModern control, Pass pass)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
||||
Matrix4.CreateTranslation(Position));
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, control.nextPickingColor());
|
||||
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass, EditorScene editorScene)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
bool hovered = editorScene.hovered == this;
|
||||
|
||||
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
||||
Matrix4.CreateTranslation(Position + (Selected ? editorScene.deltaTransform.Translation : new Vector3())));
|
||||
|
||||
Vector4 blockColor;
|
||||
Vector4 lineColor;
|
||||
|
||||
if (hovered && Selected)
|
||||
lineColor = hoverColor;
|
||||
else if (hovered || Selected)
|
||||
lineColor = selectColor;
|
||||
else
|
||||
lineColor = Color;
|
||||
|
||||
if (hovered && Selected)
|
||||
blockColor = Color * 0.5f + hoverColor * 0.5f;
|
||||
else if (hovered || Selected)
|
||||
blockColor = Color * 0.5f + selectColor * 0.5f;
|
||||
else
|
||||
blockColor = Color;
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, blockColor, lineColor, control.nextPickingColor());
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
control.UpdateModelMatrix(Matrix4.CreateScale(0.5f) *
|
||||
Matrix4.CreateTranslation(Position));
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, control.nextPickingColor());
|
||||
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
Renderers.ColorBlockRenderer.Initialize();
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlLegacy control)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Translate(Vector3 lastPos, Vector3 translate, int subObj)
|
||||
{
|
||||
Position = lastPos + translate;
|
||||
}
|
||||
|
||||
public virtual void UpdatePosition(int subObj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool CanStartDragging() => true;
|
||||
|
||||
public override Vector3 GetSelectionCenter()
|
||||
{
|
||||
return Position;
|
||||
}
|
||||
|
||||
public override uint SelectAll(I3DControl control)
|
||||
{
|
||||
Selected = true;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint SelectDefault(I3DControl control)
|
||||
{
|
||||
Selected = true;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint Select(int partIndex, I3DControl control)
|
||||
{
|
||||
Selected = true;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint Deselect(int partIndex, I3DControl control)
|
||||
{
|
||||
Selected = false;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override uint DeselectAll(I3DControl control)
|
||||
{
|
||||
Selected = false;
|
||||
return REDRAW;
|
||||
}
|
||||
|
||||
public override void ApplyTransformationToSelection(DeltaTransform deltaTransform)
|
||||
{
|
||||
Position += deltaTransform.Translation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GL_EditorFramework.GL_Core;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace GL_EditorFramework
|
||||
{
|
||||
public sealed class Framework {
|
||||
public static void Initialize()
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
|
||||
//texture sheet
|
||||
TextureSheet = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, TextureSheet);
|
||||
|
||||
var bmp = OpenGl_EditorFramework.Properties.Resources.TextureSheet;
|
||||
var bmpData = bmp.LockBits(
|
||||
new System.Drawing.Rectangle(0, 0, 128*4, 128*2),
|
||||
System.Drawing.Imaging.ImageLockMode.ReadOnly,
|
||||
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, 128*4, 128*2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
|
||||
GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
bmp.UnlockBits(bmpData);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
private static bool initialized = false;
|
||||
public static int TextureSheet;
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
using GL_EditorFramework.Interfaces;
|
||||
using OpenTK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework.StandardCameras
|
||||
{
|
||||
public class InspectCamera : AbstractCamera
|
||||
{
|
||||
private float maxCamMoveSpeed;
|
||||
|
||||
public InspectCamera(float maxCamMoveSpeed = 0.1f)
|
||||
{
|
||||
this.maxCamMoveSpeed = maxCamMoveSpeed;
|
||||
}
|
||||
|
||||
public override uint MouseDown(MouseEventArgs e, I3DControl control)
|
||||
{
|
||||
if (OpenTK.Input.Keyboard.GetState().IsKeyDown(OpenTK.Input.Key.ControlLeft) &&
|
||||
e.Button == MouseButtons.Right &&
|
||||
control.PickingDepth != control.ZFar)
|
||||
{
|
||||
control.CameraTarget = control.coordFor(e.X, e.Y, control.PickingDepth);
|
||||
|
||||
return UPDATE_CAMERA;
|
||||
}
|
||||
return base.MouseDown(e, control);
|
||||
}
|
||||
|
||||
public override uint MouseMove(MouseEventArgs e, Point lastMouseLoc, I3DControl control)
|
||||
{
|
||||
float deltaX = e.Location.X - lastMouseLoc.X;
|
||||
float deltaY = e.Location.Y - lastMouseLoc.Y;
|
||||
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
control.CamRotX += deltaX * 0.002f;
|
||||
control.CamRotY += deltaY * 0.002f;
|
||||
return UPDATE_CAMERA;
|
||||
}
|
||||
else if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
base.MouseMove(e, lastMouseLoc, control);
|
||||
|
||||
if (OpenTK.Input.Keyboard.GetState().IsKeyDown(OpenTK.Input.Key.ControlLeft))
|
||||
control.CameraDistance *= 1f - deltaY*-5 * 0.001f;
|
||||
else
|
||||
{
|
||||
//code from Whitehole
|
||||
|
||||
deltaX *= Math.Min(maxCamMoveSpeed, depth * control.FactorX);
|
||||
deltaY *= Math.Min(maxCamMoveSpeed, depth * control.FactorY);
|
||||
|
||||
control.CameraTarget += Vector3.UnitX * deltaX * (float)Math.Cos(control.CamRotX);
|
||||
control.CameraTarget -= Vector3.UnitX * deltaY * (float)Math.Sin(control.CamRotX) * (float)Math.Sin(control.CamRotY);
|
||||
control.CameraTarget -= Vector3.UnitY * deltaY * (float)Math.Cos(control.CamRotY);
|
||||
control.CameraTarget += Vector3.UnitZ * deltaX * (float)Math.Sin(control.CamRotX);
|
||||
control.CameraTarget += Vector3.UnitZ * deltaY * (float)Math.Cos(control.CamRotX) * (float)Math.Sin(control.CamRotY);
|
||||
}
|
||||
|
||||
return UPDATE_CAMERA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override uint MouseWheel(MouseEventArgs e, I3DControl control)
|
||||
{
|
||||
control.CameraDistance *= 1f - e.Delta * 0.001f;
|
||||
return UPDATE_CAMERA;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
using GL_EditorFramework.Interfaces;
|
||||
using OpenTK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework.StandardCameras
|
||||
{
|
||||
public class WalkaroundCamera : AbstractCamera
|
||||
{
|
||||
private float maxCamMoveSpeed;
|
||||
|
||||
public WalkaroundCamera(float maxCamMoveSpeed = 0.1f)
|
||||
{
|
||||
this.maxCamMoveSpeed = maxCamMoveSpeed;
|
||||
}
|
||||
|
||||
public override uint MouseDown(MouseEventArgs e, I3DControl control)
|
||||
{
|
||||
if (OpenTK.Input.Keyboard.GetState().IsKeyDown(OpenTK.Input.Key.ControlLeft) &&
|
||||
e.Button == MouseButtons.Right &&
|
||||
control.PickingDepth != control.ZFar)
|
||||
{
|
||||
float delta = control.PickingDepth + control.CameraDistance;
|
||||
control.CameraTarget -= Vector3.UnitX * (float)Math.Sin(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;
|
||||
control.CameraTarget += Vector3.UnitY * (float)Math.Sin(control.CamRotY) * delta;
|
||||
control.CameraTarget += Vector3.UnitZ * (float)Math.Cos(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;
|
||||
|
||||
Vector2 normCoords = control.NormMouseCoords(e.Location.X, e.Location.Y);
|
||||
|
||||
float factoffX = (float)(-normCoords.X * control.PickingDepth) * control.FactorX;
|
||||
float factoffY = (float)(-normCoords.Y * control.PickingDepth) * control.FactorY;
|
||||
|
||||
control.CameraTarget += Vector3.UnitX * (float)Math.Cos(control.CamRotX) * factoffX;
|
||||
control.CameraTarget -= Vector3.UnitX * (float)Math.Sin(control.CamRotX) * (float)Math.Sin(control.CamRotY) * factoffY;
|
||||
control.CameraTarget -= Vector3.UnitY * (float)Math.Cos(control.CamRotY) * factoffY;
|
||||
control.CameraTarget += Vector3.UnitZ * (float)Math.Sin(control.CamRotX) * factoffX;
|
||||
control.CameraTarget += Vector3.UnitZ * (float)Math.Cos(control.CamRotX) * (float)Math.Sin(control.CamRotY) * factoffY;
|
||||
}
|
||||
base.MouseDown(e, control);
|
||||
return UPDATE_CAMERA;
|
||||
}
|
||||
|
||||
public override uint MouseMove(MouseEventArgs e, Point lastMouseLoc, I3DControl control)
|
||||
{
|
||||
float deltaX = e.Location.X - lastMouseLoc.X;
|
||||
float deltaY = e.Location.Y - lastMouseLoc.Y;
|
||||
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
control.CamRotX += deltaX * 0.00390625f;
|
||||
control.CamRotY += deltaY * 0.00390625f;
|
||||
return UPDATE_CAMERA;
|
||||
}
|
||||
else if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
base.MouseMove(e, lastMouseLoc, control);
|
||||
|
||||
if (OpenTK.Input.Keyboard.GetState().IsKeyDown(OpenTK.Input.Key.ControlLeft))
|
||||
{
|
||||
float delta = ((float)deltaY*-5 * Math.Min(0.01f, depth / 500f));
|
||||
control.CameraTarget -= Vector3.UnitX * (float)Math.Sin(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;
|
||||
control.CameraTarget += Vector3.UnitY * (float)Math.Sin(control.CamRotY) * delta;
|
||||
control.CameraTarget += Vector3.UnitZ * (float)Math.Cos(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//code from Whitehole
|
||||
|
||||
deltaX *= Math.Min(maxCamMoveSpeed, depth * control.FactorX);
|
||||
deltaY *= Math.Min(maxCamMoveSpeed, depth * control.FactorY);
|
||||
|
||||
control.CameraTarget += Vector3.UnitX * deltaX * (float)Math.Cos(control.CamRotX);
|
||||
control.CameraTarget -= Vector3.UnitX * deltaY * (float)Math.Sin(control.CamRotX) * (float)Math.Sin(control.CamRotY);
|
||||
control.CameraTarget -= Vector3.UnitY * deltaY * (float)Math.Cos(control.CamRotY);
|
||||
control.CameraTarget += Vector3.UnitZ * deltaX * (float)Math.Sin(control.CamRotX);
|
||||
control.CameraTarget += Vector3.UnitZ * deltaY * (float)Math.Cos(control.CamRotX) * (float)Math.Sin(control.CamRotY);
|
||||
|
||||
}
|
||||
|
||||
return UPDATE_CAMERA;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override uint MouseWheel(MouseEventArgs e, I3DControl control)
|
||||
{
|
||||
depth = control.PickingDepth;
|
||||
float delta = ((float)e.Delta * Math.Min(0.01f, depth / 500f));
|
||||
control.CameraTarget -= Vector3.UnitX * (float)Math.Sin(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;
|
||||
control.CameraTarget += Vector3.UnitY * (float)Math.Sin(control.CamRotY) * delta;
|
||||
control.CameraTarget += Vector3.UnitZ * (float)Math.Cos(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;
|
||||
|
||||
Vector2 normCoords = control.NormMouseCoords(e.Location.X, e.Location.Y);
|
||||
|
||||
float factoffX = (float)(-normCoords.X * delta) * control.FactorX;
|
||||
float factoffY = (float)(-normCoords.Y * delta) * control.FactorY;
|
||||
|
||||
control.CameraTarget += Vector3.UnitX * (float)Math.Cos(control.CamRotX) * factoffX;
|
||||
control.CameraTarget -= Vector3.UnitX * (float)Math.Sin(control.CamRotX) * (float)Math.Sin(control.CamRotY) * factoffY;
|
||||
control.CameraTarget -= Vector3.UnitY * (float)Math.Cos(control.CamRotY) * factoffY;
|
||||
control.CameraTarget += Vector3.UnitZ * (float)Math.Sin(control.CamRotX) * factoffX;
|
||||
control.CameraTarget += Vector3.UnitZ * (float)Math.Cos(control.CamRotX) * (float)Math.Sin(control.CamRotY) * factoffY;
|
||||
return UPDATE_CAMERA;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,673 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using GL_EditorFramework.StandardCameras;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework.GL_Core
|
||||
{
|
||||
public class GL_ControlBase : GLControl, I3DControl
|
||||
{
|
||||
public GL_ControlBase(int maxGL_Version, int redrawerInterval) : base(OpenTK.Graphics.GraphicsMode.Default, maxGL_Version, 1, OpenTK.Graphics.GraphicsContextFlags.Default)
|
||||
{
|
||||
redrawer.Interval = redrawerInterval;
|
||||
redrawer.Tick += Redrawer_Tick;
|
||||
}
|
||||
|
||||
private void Redrawer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
base.Refresh();
|
||||
if (repickerOwners > 0)
|
||||
Repick();
|
||||
RedrawerFrame++;
|
||||
}
|
||||
|
||||
public GL_ControlBase() : base(OpenTK.Graphics.GraphicsMode.Default, 1, 1, OpenTK.Graphics.GraphicsContextFlags.Default)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected Matrix4 orientationCubeMtx;
|
||||
|
||||
protected bool showFakeCursor;
|
||||
|
||||
private Timer redrawer = new Timer();
|
||||
|
||||
private uint redrawerOwners = 0;
|
||||
|
||||
private uint repickerOwners = 0;
|
||||
|
||||
protected Point lastMouseLoc;
|
||||
protected Point dragStartPos = new Point(-1, -1);
|
||||
protected float camRotX = 0;
|
||||
protected float camRotY = 0;
|
||||
|
||||
protected float camDistance = -10f;
|
||||
protected Vector3 camTarget;
|
||||
|
||||
|
||||
protected float zfar = 1000f;
|
||||
protected float znear = 0.01f;
|
||||
protected float fov = MathHelper.PiOver4;
|
||||
|
||||
public float PickedObjectPart => pickingFrameBuffer;
|
||||
|
||||
protected uint pickingFrameBuffer;
|
||||
protected int pickingIndex;
|
||||
private int lastPicked = -1;
|
||||
protected float normPickingDepth = 0f;
|
||||
protected float pickingDepth = 0f;
|
||||
|
||||
public Matrix4 mtxMdl, mtxCam, mtxProj;
|
||||
protected float factorX, factorY;
|
||||
|
||||
protected bool stereoscopy;
|
||||
protected bool showOrientationCube = true;
|
||||
|
||||
protected int viewPortX(int x) => stereoscopy ? x % (Width / 2) : x;
|
||||
protected int viewPortDX(int dx) => stereoscopy ? dx * 2 : dx;
|
||||
protected int viewPortXOff(int x) => stereoscopy ? (x - Width / 4) * 2 : x - Width / 2;
|
||||
|
||||
public Color BackgroundColor1 = Color.FromArgb(20, 20, 20);
|
||||
|
||||
public Color BackgroundColor2 = Color.FromArgb(70, 70, 70);
|
||||
|
||||
public bool GradientBackground;
|
||||
|
||||
public Point DragStartPos
|
||||
{
|
||||
get => dragStartPos;
|
||||
set
|
||||
{
|
||||
dragStartPos = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Stereoscopy
|
||||
{
|
||||
get => stereoscopy;
|
||||
set
|
||||
{
|
||||
stereoscopy = value;
|
||||
OnResize(null);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowOrientationCube
|
||||
{
|
||||
get => showOrientationCube;
|
||||
set
|
||||
{
|
||||
showOrientationCube = value;
|
||||
pickingIndexOffset = value?7:1;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 coordFor(int x, int y, float depth)
|
||||
{
|
||||
Vector3 vec = camTarget;
|
||||
float delta = depth + camDistance;
|
||||
vec -= Vector3.UnitX * (float)Math.Sin(camRotX) * (float)Math.Cos(camRotY) * delta;
|
||||
vec += Vector3.UnitY * (float)Math.Sin(camRotY) * delta;
|
||||
vec += Vector3.UnitZ * (float)Math.Cos(camRotX) * (float)Math.Cos(camRotY) * delta;
|
||||
|
||||
Vector2 normCoords = NormMouseCoords(x, y);
|
||||
|
||||
float factoffX = (float)(-normCoords.X * depth) * factorX;
|
||||
float factoffY = (float)(-normCoords.Y * depth) * factorY;
|
||||
|
||||
vec += Vector3.UnitX * (float)Math.Cos(camRotX) * factoffX;
|
||||
vec -= Vector3.UnitX * (float)Math.Sin(camRotX) * (float)Math.Sin(camRotY) * factoffY;
|
||||
vec -= Vector3.UnitY * (float)Math.Cos(camRotY) * factoffY;
|
||||
vec += Vector3.UnitZ * (float)Math.Sin(camRotX) * factoffX;
|
||||
vec += Vector3.UnitZ * (float)Math.Cos(camRotX) * (float)Math.Sin(camRotY) * factoffY;
|
||||
|
||||
return vec;
|
||||
|
||||
//TODO: Get this working, to get rid of sin and cos functions
|
||||
/*
|
||||
Vector4 vec;
|
||||
|
||||
vec.X = 2.0f * x / (float)Width - 1;
|
||||
vec.Y = -(2.0f * y / (float)Height) + 1;
|
||||
vec.Z = normDepth;
|
||||
vec.W = 1.0f;
|
||||
|
||||
Matrix4 viewInv = Matrix4.Invert(mtxCam);
|
||||
Matrix4 projInv = Matrix4.Invert(mtxProj);
|
||||
|
||||
Vector4.Transform(ref vec, ref projInv, out vec);
|
||||
Vector4.Transform(ref vec, ref viewInv, out vec);
|
||||
|
||||
if (vec.W > 0.000001f || vec.W < -0.000001f)
|
||||
{
|
||||
vec.X /= vec.W;
|
||||
vec.Y /= vec.W;
|
||||
vec.Z /= vec.W;
|
||||
}
|
||||
|
||||
vec.X *= -1;
|
||||
vec.Y *= -1;
|
||||
vec.Z *= -1;
|
||||
|
||||
return vec.Xyz;
|
||||
*/
|
||||
}
|
||||
|
||||
public Vector3 screenCoordFor(Vector3 coord)
|
||||
{
|
||||
return new Vector3();
|
||||
}
|
||||
|
||||
protected AbstractGlDrawable mainDrawable;
|
||||
public virtual AbstractGlDrawable MainDrawable { get; set; }
|
||||
|
||||
protected AbstractCamera activeCamera;
|
||||
private bool shouldRedraw;
|
||||
private bool shouldRepick;
|
||||
private bool skipCameraAction;
|
||||
private int pickingIndexOffset = 7;
|
||||
|
||||
public AbstractCamera ActiveCamera
|
||||
{
|
||||
get => activeCamera;
|
||||
set
|
||||
{
|
||||
if (value == null) return;
|
||||
activeCamera = value;
|
||||
MakeCurrent();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public int ViewWidth => stereoscopy ? Width / 2 : Width;
|
||||
|
||||
public int ViewHeighth => Height;
|
||||
|
||||
public Vector2 NormMouseCoords(int x, int y) {
|
||||
return new Vector2(x - Width / 2, y - Height / 2);
|
||||
}
|
||||
|
||||
public float ZFar { get => zfar; set { zfar = value; } }
|
||||
public float ZNear { get => znear; set { znear = value; } }
|
||||
public float Fov { get => fov; set { fov = value; } }
|
||||
|
||||
public float FactorX => factorX;
|
||||
|
||||
public float FactorY => factorY;
|
||||
|
||||
public Vector3 CameraTarget { get => camTarget; set { camTarget = value; } }
|
||||
public float CameraDistance { get => camDistance; set { camDistance = value; } }
|
||||
public float CamRotX { get => camRotX; set { camRotX = value; } }
|
||||
public float CamRotY { get => camRotY; set { camRotY = value; } }
|
||||
|
||||
public float PickingDepth => pickingDepth;
|
||||
|
||||
public float NormPickingDepth => normPickingDepth;
|
||||
|
||||
public ulong RedrawerFrame { get; private set; } = 0;
|
||||
|
||||
void handleDrawableEvtResult(uint result)
|
||||
{
|
||||
shouldRedraw |= (result&AbstractGlDrawable.REDRAW)> 0;
|
||||
shouldRepick |= (result & AbstractGlDrawable.REPICK) > 0;
|
||||
skipCameraAction |= (result & AbstractGlDrawable.NO_CAMERA_ACTION) > 0;
|
||||
}
|
||||
|
||||
void handleCameraEvtResult(uint result)
|
||||
{
|
||||
shouldRedraw |= result > 0;
|
||||
shouldRepick |= result > 0;
|
||||
}
|
||||
|
||||
public Color nextPickingColor()
|
||||
{
|
||||
return Color.FromArgb(pickingIndex++);
|
||||
}
|
||||
|
||||
public void skipPickingColors(uint count)
|
||||
{
|
||||
pickingIndex += (int)count;
|
||||
}
|
||||
|
||||
public virtual void UpdateModelMatrix(Matrix4 matrix) { }
|
||||
public virtual void ApplyModelTransform(Matrix4 matrix) { }
|
||||
|
||||
public virtual void ResetModelMatrix() { }
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
|
||||
if (DesignMode) return;
|
||||
|
||||
activeCamera = new WalkaroundCamera();
|
||||
|
||||
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
GL.CullFace(CullFaceMode.Back);
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
|
||||
GL.Enable(EnableCap.AlphaTest);
|
||||
|
||||
GL.Enable(EnableCap.LineSmooth);
|
||||
GL.Enable(EnableCap.PolygonSmooth);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
if (DesignMode) return;
|
||||
|
||||
float aspect_ratio;
|
||||
if (stereoscopy)
|
||||
aspect_ratio = Width / 2 / (float)Height;
|
||||
else
|
||||
aspect_ratio = Width / (float)Height;
|
||||
|
||||
mtxProj = Matrix4.CreatePerspectiveFieldOfView(fov, aspect_ratio, znear, zfar);
|
||||
|
||||
//using the calculation from whitehole
|
||||
factorX = (2f * (float)Math.Tan(fov * 0.5f) * aspect_ratio) / Width;
|
||||
|
||||
factorY = (2f * (float)Math.Tan(fov * 0.5f)) / Height;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
if (DesignMode || mainDrawable == null) return;
|
||||
|
||||
Focus();
|
||||
|
||||
lastMouseLoc = e.Location;
|
||||
if(dragStartPos == new Point(-1,-1))
|
||||
dragStartPos = e.Location;
|
||||
|
||||
shouldRedraw = false;
|
||||
shouldRepick = false;
|
||||
skipCameraAction = false;
|
||||
handleDrawableEvtResult(mainDrawable.MouseDown(e, this));
|
||||
|
||||
if (!skipCameraAction)
|
||||
handleCameraEvtResult(activeCamera.MouseDown(e, this));
|
||||
|
||||
if (shouldRepick)
|
||||
Repick();
|
||||
|
||||
if (shouldRedraw)
|
||||
Refresh();
|
||||
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
if (DesignMode || mainDrawable == null) return;
|
||||
|
||||
shouldRedraw = false;
|
||||
shouldRepick = false;
|
||||
skipCameraAction = false;
|
||||
|
||||
handleDrawableEvtResult(mainDrawable.MouseMove(e, lastMouseLoc, this));
|
||||
|
||||
if (!skipCameraAction)
|
||||
{
|
||||
handleCameraEvtResult(activeCamera.MouseMove(e, lastMouseLoc, this));
|
||||
}
|
||||
|
||||
if (shouldRepick)
|
||||
Repick();
|
||||
|
||||
if (shouldRedraw||showFakeCursor)
|
||||
Refresh();
|
||||
|
||||
lastMouseLoc = e.Location;
|
||||
}
|
||||
|
||||
protected override void OnMouseWheel(MouseEventArgs e)
|
||||
{
|
||||
if (DesignMode || mainDrawable == null) return;
|
||||
|
||||
shouldRedraw = false;
|
||||
shouldRepick = false;
|
||||
skipCameraAction = false;
|
||||
|
||||
handleDrawableEvtResult(mainDrawable.MouseWheel(e, this));
|
||||
|
||||
if (!skipCameraAction)
|
||||
handleCameraEvtResult(activeCamera.MouseWheel(e, this));
|
||||
|
||||
if (shouldRepick)
|
||||
Repick();
|
||||
|
||||
if (shouldRedraw)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
if (DesignMode || mainDrawable == null) return;
|
||||
|
||||
shouldRedraw = false;
|
||||
shouldRepick = false;
|
||||
skipCameraAction = false;
|
||||
|
||||
if((e.Location.X == dragStartPos.X) && (e.Location.Y == dragStartPos.Y))
|
||||
{
|
||||
shouldRedraw = true;
|
||||
switch (showOrientationCube ? pickingFrameBuffer : 0)
|
||||
{
|
||||
case 1:
|
||||
camRotX = 0;
|
||||
camRotY = (float)Math.PI * 0.5f;
|
||||
break;
|
||||
case 2:
|
||||
camRotX = 0;
|
||||
camRotY = -(float)Math.PI * 0.5f;
|
||||
break;
|
||||
case 3:
|
||||
camRotX = 0;
|
||||
camRotY = 0;
|
||||
break;
|
||||
case 4:
|
||||
camRotX = (float)Math.PI;
|
||||
camRotY = 0;
|
||||
break;
|
||||
case 5:
|
||||
camRotX = -(float)Math.PI * 0.5f;
|
||||
camRotY = 0;
|
||||
break;
|
||||
case 6:
|
||||
camRotX = (float)Math.PI * 0.5f;
|
||||
camRotY = 0;
|
||||
break;
|
||||
default:
|
||||
shouldRedraw = false;
|
||||
handleDrawableEvtResult(mainDrawable.MouseClick(e, this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handleDrawableEvtResult(mainDrawable.MouseUp(e, this));
|
||||
}
|
||||
|
||||
dragStartPos = new Point(-1, -1);
|
||||
|
||||
if (!skipCameraAction)
|
||||
handleCameraEvtResult(activeCamera.MouseUp(e, this));
|
||||
|
||||
if (shouldRepick)
|
||||
Repick();
|
||||
|
||||
if (shouldRedraw)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
protected void Repick()
|
||||
{
|
||||
int pickingMouseX = stereoscopy ? lastMouseLoc.X / 2 : lastMouseLoc.X;
|
||||
|
||||
pickingIndex = 1;
|
||||
|
||||
DrawPicking();
|
||||
|
||||
GL.Flush();
|
||||
|
||||
GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.Bgra, PixelType.UnsignedByte, ref pickingFrameBuffer);
|
||||
|
||||
// depth math from http://www.opengl.org/resources/faq/technical/depthbuffer.htm
|
||||
|
||||
GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref normPickingDepth);
|
||||
|
||||
pickingDepth = -(zfar * znear / (normPickingDepth * (zfar - znear) - zfar));
|
||||
|
||||
Console.WriteLine(normPickingDepth);
|
||||
|
||||
int picked = (int)pickingFrameBuffer - pickingIndexOffset;
|
||||
if (lastPicked != picked)
|
||||
{
|
||||
if (picked >= 0)
|
||||
{
|
||||
handleDrawableEvtResult(mainDrawable.MouseEnter(picked, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
handleDrawableEvtResult(mainDrawable.MouseLeaveEntirely(this));
|
||||
}
|
||||
if (lastPicked >= 0)
|
||||
{
|
||||
handleDrawableEvtResult(mainDrawable.MouseLeave(lastPicked, this));
|
||||
}
|
||||
lastPicked = picked;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(EventArgs e)
|
||||
{
|
||||
if (DesignMode)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
return;
|
||||
}
|
||||
if (stereoscopy)
|
||||
{
|
||||
showFakeCursor = true;
|
||||
Cursor.Hide();
|
||||
}
|
||||
base.OnMouseEnter(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
if (DesignMode)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
return;
|
||||
}
|
||||
if (stereoscopy)
|
||||
{
|
||||
showFakeCursor = false;
|
||||
Cursor.Show();
|
||||
}
|
||||
base.OnMouseLeave(e);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if (DesignMode || mainDrawable == null) return;
|
||||
|
||||
shouldRedraw = false;
|
||||
shouldRepick = false;
|
||||
skipCameraAction = false;
|
||||
|
||||
handleDrawableEvtResult(mainDrawable.KeyDown(e, this));
|
||||
|
||||
if (!skipCameraAction)
|
||||
handleCameraEvtResult(activeCamera.KeyDown(e, this));
|
||||
|
||||
if (shouldRepick)
|
||||
Repick();
|
||||
|
||||
if (shouldRedraw)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
protected override void OnKeyUp(KeyEventArgs e)
|
||||
{
|
||||
if (DesignMode || mainDrawable == null) return;
|
||||
|
||||
shouldRedraw = false;
|
||||
shouldRepick = false;
|
||||
skipCameraAction = false;
|
||||
|
||||
handleDrawableEvtResult(mainDrawable.KeyUp(e, this));
|
||||
|
||||
if (skipCameraAction)
|
||||
handleCameraEvtResult(activeCamera.KeyUp(e, this));
|
||||
|
||||
if (shouldRepick)
|
||||
Repick();
|
||||
|
||||
if (shouldRedraw)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public virtual void DrawPicking() { }
|
||||
|
||||
protected void DrawFakeCursor()
|
||||
{
|
||||
GL.Color3(1f, 1f, 1f);
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
GL.LoadIdentity();
|
||||
GL.Translate(lastMouseLoc.X * 2 / (float)Width - 1, -(lastMouseLoc.Y * 2 / (float)Height - 1), 0);
|
||||
GL.Scale(80f / Width, 40f / Height, 1);
|
||||
GL.Begin(PrimitiveType.Polygon);
|
||||
GL.Vertex2(0, 0);
|
||||
GL.Vertex2(0, -1);
|
||||
GL.Vertex2(0.25, -0.75);
|
||||
GL.Vertex2(0.625, -0.75);
|
||||
GL.End();
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
}
|
||||
|
||||
protected void DrawOrientationCube()
|
||||
{
|
||||
GL.ActiveTexture(TextureUnit.Texture0);
|
||||
GL.BindTexture(TextureTarget.Texture2D, Framework.TextureSheet);
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color3(new Vector3(pickingFrameBuffer == 1 ? 1f : 0.75f)); //UP
|
||||
GL.TexCoord2(0f, 1f);
|
||||
GL.Vertex3(-1f, 1f, 1f);
|
||||
GL.TexCoord2(0.25f, 1f);
|
||||
GL.Vertex3(1f, 1f, 1f);
|
||||
GL.TexCoord2(0.25f, 0.5f);
|
||||
GL.Vertex3(1f, 1f, -1f);
|
||||
GL.TexCoord2(0f, 0.5f);
|
||||
GL.Vertex3(-1f, 1f, -1f);
|
||||
GL.Color3(new Vector3(pickingFrameBuffer == 2 ? 1f : 0.75f)); //DOWN
|
||||
GL.TexCoord2(0.25f, 1f);
|
||||
GL.Vertex3(-1f, -1f, -1f);
|
||||
GL.TexCoord2(0.5f, 1f);
|
||||
GL.Vertex3(1f, -1f, -1f);
|
||||
GL.TexCoord2(0.5f, 0.5f);
|
||||
GL.Vertex3(1f, -1f, 1f);
|
||||
GL.TexCoord2(0.25f, 0.5f);
|
||||
GL.Vertex3(-1f, -1f, 1f);
|
||||
GL.Color3(new Vector3(pickingFrameBuffer == 3 ? 1f : 0.75f)); //FRONT
|
||||
GL.TexCoord2(0.25f, 0f);
|
||||
GL.Vertex3(1f, 1f, 1f);
|
||||
GL.TexCoord2(0f, 0f);
|
||||
GL.Vertex3(-1f, 1f, 1f);
|
||||
GL.TexCoord2(0f, 0.5f);
|
||||
GL.Vertex3(-1f, -1f, 1f);
|
||||
GL.TexCoord2(0.25f, 0.5f);
|
||||
GL.Vertex3(1f, -1f, 1f);
|
||||
GL.Color3(new Vector3(pickingFrameBuffer == 4 ? 1f : 0.75f)); //BACK
|
||||
GL.TexCoord2(0.75f, 0.0f);
|
||||
GL.Vertex3(-1f, 1f, -1f);
|
||||
GL.TexCoord2(0.5f, 0.0f);
|
||||
GL.Vertex3(1f, 1f, -1f);
|
||||
GL.TexCoord2(0.5f, 0.5f);
|
||||
GL.Vertex3(1f, -1f, -1f);
|
||||
GL.TexCoord2(0.75f, 0.5f);
|
||||
GL.Vertex3(-1f, -1f, -1f);
|
||||
GL.Color3(new Vector3(pickingFrameBuffer == 5 ? 1f : 0.75f)); //LEFT
|
||||
GL.TexCoord2(0.5f, 0f);
|
||||
GL.Vertex3(1f, 1f, -1f);
|
||||
GL.TexCoord2(0.25f, 0f);
|
||||
GL.Vertex3(1f, 1f, 1f);
|
||||
GL.TexCoord2(0.25f, 0.5f);
|
||||
GL.Vertex3(1f, -1f, 1f);
|
||||
GL.TexCoord2(0.5f, 0.5f);
|
||||
GL.Vertex3(1f, -1f, -1f);
|
||||
GL.Color3(new Vector3(pickingFrameBuffer == 6 ? 1f : 0.75f)); //RIGHT
|
||||
GL.TexCoord2(1f, 0f);
|
||||
GL.Vertex3(-1f, 1f, 1f);
|
||||
GL.TexCoord2(0.75f, 0f);
|
||||
GL.Vertex3(-1f, 1f, -1f);
|
||||
GL.TexCoord2(0.75f, 0.5f);
|
||||
GL.Vertex3(-1f, -1f, -1f);
|
||||
GL.TexCoord2(1f, 0.5f);
|
||||
GL.Vertex3(-1f, -1f, 1f);
|
||||
GL.End();
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
}
|
||||
|
||||
protected void DrawGradientBG()
|
||||
{
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.DepthFunc(DepthFunction.Lequal);
|
||||
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
GL.LoadIdentity();
|
||||
GL.Begin(PrimitiveType.TriangleStrip);
|
||||
GL.Color3(BackgroundColor2);
|
||||
GL.Vertex3(1, 1, 0.99998);
|
||||
GL.Vertex3(-1, 1, 0.99998);
|
||||
GL.Color3(BackgroundColor1);
|
||||
GL.Vertex3(1, -1, 0.99998);
|
||||
GL.Vertex3(-1, -1, 0.99998);
|
||||
GL.End();
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
if(redrawerOwners==0) //Redrawer is deactivated?
|
||||
base.Refresh(); //event can force a redraw
|
||||
}
|
||||
|
||||
public void AttachRedrawer()
|
||||
{
|
||||
if (redrawerOwners == 0)
|
||||
redrawer.Start();
|
||||
redrawerOwners++;
|
||||
}
|
||||
|
||||
public void AttachPickingRedrawer()
|
||||
{
|
||||
if (redrawerOwners == 0)
|
||||
redrawer.Start();
|
||||
repickerOwners++;
|
||||
redrawerOwners++;
|
||||
}
|
||||
|
||||
public void DetachRedrawer()
|
||||
{
|
||||
redrawerOwners--;
|
||||
if (redrawerOwners == 0)
|
||||
{
|
||||
RedrawerFrame = 0;
|
||||
redrawer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void DetachPickingRedrawer()
|
||||
{
|
||||
redrawerOwners--;
|
||||
repickerOwners--;
|
||||
if (redrawerOwners == 0)
|
||||
{
|
||||
RedrawerFrame = 0;
|
||||
redrawer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,302 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using GL_EditorFramework.StandardCameras;
|
||||
|
||||
namespace GL_EditorFramework.GL_Core
|
||||
{
|
||||
public class GL_ControlLegacy : GL_ControlBase
|
||||
{
|
||||
public GL_ControlLegacy(int redrawerInterval) : base(1, redrawerInterval)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public GL_ControlLegacy() : base(1, 16)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
if (DesignMode) return;
|
||||
MakeCurrent();
|
||||
Framework.Initialize();
|
||||
}
|
||||
|
||||
public override AbstractGlDrawable MainDrawable
|
||||
{
|
||||
get => mainDrawable;
|
||||
set
|
||||
{
|
||||
if (value == null || DesignMode) return;
|
||||
mainDrawable = value;
|
||||
MakeCurrent();
|
||||
mainDrawable.Prepare(this);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateModelMatrix(Matrix4 matrix)
|
||||
{
|
||||
if (DesignMode) return;
|
||||
mtxMdl = matrix;
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
GL.LoadMatrix(ref mtxMdl);
|
||||
}
|
||||
|
||||
public override void ApplyModelTransform(Matrix4 matrix)
|
||||
{
|
||||
if (DesignMode) return;
|
||||
mtxMdl *= matrix;
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
GL.LoadMatrix(ref mtxMdl);
|
||||
}
|
||||
|
||||
public override void ResetModelMatrix()
|
||||
{
|
||||
if (DesignMode) return;
|
||||
mtxMdl = Matrix4.Identity;
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
GL.LoadMatrix(ref mtxMdl);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
|
||||
if (mainDrawable == null || DesignMode)
|
||||
{
|
||||
e.Graphics.Clear(this.BackColor);
|
||||
e.Graphics.DrawString("Legacy Gl" + (stereoscopy ? " stereoscopy" : ""), SystemFonts.DefaultFont, SystemBrushes.ControlLight, 10f, 10f);
|
||||
return;
|
||||
}
|
||||
|
||||
MakeCurrent();
|
||||
|
||||
GL.ClearColor(BackgroundColor1);
|
||||
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
if (stereoscopy)
|
||||
{
|
||||
#region left eye
|
||||
GL.Viewport(0, 0, Width / 2, Height);
|
||||
|
||||
ResetModelMatrix();
|
||||
mtxCam =
|
||||
Matrix4.CreateTranslation(camTarget) *
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateTranslation(0.25f, 0, camDistance) *
|
||||
Matrix4.CreateRotationY(0.02f);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
Matrix4 computedMatrix = mtxCam * mtxProj;
|
||||
GL.LoadMatrix(ref computedMatrix);
|
||||
|
||||
mainDrawable.Draw(this, Pass.OPAQUE);
|
||||
|
||||
mainDrawable.Draw(this, Pass.TRANSPARENT);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
|
||||
if (GradientBackground)
|
||||
DrawGradientBG();
|
||||
|
||||
if (showOrientationCube)
|
||||
{
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
orientationCubeMtx =
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateScale(80f / Width, 40f / Height, 0.25f) *
|
||||
Matrix4.CreateTranslation(1 - 160f / Width, 1 - 80f / Height, 0) *
|
||||
Matrix4.CreateRotationY(0.03125f);
|
||||
GL.LoadMatrix(ref orientationCubeMtx);
|
||||
|
||||
DrawOrientationCube();
|
||||
}
|
||||
|
||||
if (showFakeCursor)
|
||||
DrawFakeCursor();
|
||||
|
||||
#endregion
|
||||
|
||||
#region right eye
|
||||
GL.Viewport(Width / 2, 0, Width / 2, Height);
|
||||
|
||||
ResetModelMatrix();
|
||||
mtxCam =
|
||||
Matrix4.CreateTranslation(camTarget) *
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateTranslation(-0.25f, 0, camDistance) *
|
||||
Matrix4.CreateRotationY(-0.02f);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
computedMatrix = mtxCam * mtxProj;
|
||||
GL.LoadMatrix(ref computedMatrix);
|
||||
|
||||
mainDrawable.Draw(this, Pass.OPAQUE);
|
||||
|
||||
mainDrawable.Draw(this, Pass.TRANSPARENT);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
|
||||
if (GradientBackground)
|
||||
DrawGradientBG();
|
||||
|
||||
if (showOrientationCube)
|
||||
{
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
orientationCubeMtx =
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateScale(80f / Width, 40f / Height, 0.25f) *
|
||||
Matrix4.CreateTranslation(1 - 160f / Width, 1 - 80f / Height, 0) *
|
||||
Matrix4.CreateRotationY(-0.03125f);
|
||||
GL.LoadMatrix(ref orientationCubeMtx);
|
||||
|
||||
DrawOrientationCube();
|
||||
}
|
||||
|
||||
if (showFakeCursor)
|
||||
DrawFakeCursor();
|
||||
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
ResetModelMatrix();
|
||||
mtxCam =
|
||||
Matrix4.CreateTranslation(camTarget) *
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateTranslation(0, 0, camDistance);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
Matrix4 computedMatrix = mtxCam * mtxProj;
|
||||
GL.LoadMatrix(ref computedMatrix);
|
||||
|
||||
mainDrawable.Draw(this, Pass.OPAQUE);
|
||||
|
||||
mainDrawable.Draw(this, Pass.TRANSPARENT);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
|
||||
if (GradientBackground)
|
||||
DrawGradientBG();
|
||||
|
||||
if (showOrientationCube)
|
||||
{
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
orientationCubeMtx =
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateScale(40f / Width, 40f / Height, 0.25f) *
|
||||
Matrix4.CreateTranslation(1 - 80f / Width, 1 - 80f / Height, 0);
|
||||
GL.LoadMatrix(ref orientationCubeMtx);
|
||||
|
||||
DrawOrientationCube();
|
||||
}
|
||||
}
|
||||
|
||||
SwapBuffers();
|
||||
|
||||
}
|
||||
|
||||
public override void DrawPicking()
|
||||
{
|
||||
if (DesignMode) return;
|
||||
MakeCurrent();
|
||||
GL.ClearColor(0f, 0f, 0f, 0f);
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
if (stereoscopy)
|
||||
GL.Viewport(0, 0, Width / 2, Height);
|
||||
else
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
ResetModelMatrix();
|
||||
mtxCam =
|
||||
Matrix4.CreateTranslation(camTarget) *
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateTranslation(0, 0, camDistance);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
Matrix4 computedMatrix = mtxCam * mtxProj;
|
||||
GL.LoadMatrix(ref computedMatrix);
|
||||
|
||||
if (showOrientationCube)
|
||||
skipPickingColors(6); //the orientation cube faces
|
||||
|
||||
mainDrawable.Draw(this, Pass.PICKING);
|
||||
|
||||
if (showOrientationCube)
|
||||
{
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
orientationCubeMtx =
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateScale((stereoscopy ? 80f : 40f) / Width, 40f / Height, 0.25f) *
|
||||
Matrix4.CreateTranslation(1 - (stereoscopy ? 160f : 80f) / Width, 1 - 80f / Height, 0);
|
||||
GL.LoadMatrix(ref orientationCubeMtx);
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color4(Color.FromArgb(1)); //UP
|
||||
GL.Vertex3(-1f, 1f, 1f);
|
||||
GL.Vertex3(1f, 1f, 1f);
|
||||
GL.Vertex3(1f, 1f, -1f);
|
||||
GL.Vertex3(-1f, 1f, -1f);
|
||||
GL.Color4(Color.FromArgb(2)); //DOWN
|
||||
GL.Vertex3(-1f, -1f, -1f);
|
||||
GL.Vertex3(1f, -1f, -1f);
|
||||
GL.Vertex3(1f, -1f, 1f);
|
||||
GL.Vertex3(-1f, -1f, 1f);
|
||||
GL.Color4(Color.FromArgb(3)); //FRONT
|
||||
GL.Vertex3(1f, 1f, 1f);
|
||||
GL.Vertex3(-1f, 1f, 1f);
|
||||
GL.Vertex3(-1f, -1f, 1f);
|
||||
GL.Vertex3(1f, -1f, 1f);
|
||||
GL.Color4(Color.FromArgb(4)); //BACK
|
||||
GL.Vertex3(-1f, 1f, -1f);
|
||||
GL.Vertex3(1f, 1f, -1f);
|
||||
GL.Vertex3(1f, -1f, -1f);
|
||||
GL.Vertex3(-1f, -1f, -1f);
|
||||
GL.Color4(Color.FromArgb(5)); //LEFT
|
||||
GL.Vertex3(1f, 1f, -1f);
|
||||
GL.Vertex3(1f, 1f, 1f);
|
||||
GL.Vertex3(1f, -1f, 1f);
|
||||
GL.Vertex3(1f, -1f, -1f);
|
||||
GL.Color4(Color.FromArgb(6)); //RIGHT
|
||||
GL.Vertex3(-1f, 1f, 1f);
|
||||
GL.Vertex3(-1f, 1f, -1f);
|
||||
GL.Vertex3(-1f, -1f, -1f);
|
||||
GL.Vertex3(-1f, -1f, 1f);
|
||||
GL.End();
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,327 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using GL_EditorFramework.StandardCameras;
|
||||
|
||||
namespace GL_EditorFramework.GL_Core
|
||||
{
|
||||
public class GL_ControlModern : GL_ControlBase
|
||||
{
|
||||
public GL_ControlModern(int redrawerInterval) : base(3, redrawerInterval)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public GL_ControlModern() : base(3, 16)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
if (DesignMode) return;
|
||||
MakeCurrent();
|
||||
Framework.Initialize();
|
||||
}
|
||||
|
||||
private ShaderProgram shader;
|
||||
public ShaderProgram CurrentShader
|
||||
{
|
||||
get => shader;
|
||||
set
|
||||
{
|
||||
if (value == null || value == shader || DesignMode) return;
|
||||
shader = value;
|
||||
|
||||
shader.Setup(mtxMdl, mtxCam, mtxProj);
|
||||
}
|
||||
}
|
||||
|
||||
public override AbstractGlDrawable MainDrawable
|
||||
{
|
||||
get => mainDrawable;
|
||||
set
|
||||
{
|
||||
if (value == null || DesignMode) return;
|
||||
mainDrawable = value;
|
||||
MakeCurrent();
|
||||
mainDrawable.Prepare(this);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadShaders()
|
||||
{
|
||||
if (mainDrawable != null)
|
||||
{
|
||||
mainDrawable.Prepare(this);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateModelMatrix(Matrix4 matrix)
|
||||
{
|
||||
if (DesignMode) return;
|
||||
mtxMdl = matrix;
|
||||
if (shader!=null)
|
||||
shader.UpdateModelMatrix(matrix);
|
||||
}
|
||||
|
||||
public override void ApplyModelTransform(Matrix4 matrix)
|
||||
{
|
||||
if (DesignMode) return;
|
||||
shader.UpdateModelMatrix(mtxMdl *= matrix);
|
||||
}
|
||||
|
||||
public override void ResetModelMatrix()
|
||||
{
|
||||
if (DesignMode) return;
|
||||
shader.UpdateModelMatrix(mtxMdl = Matrix4.Identity);
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
if (DesignMode)
|
||||
{
|
||||
base.OnResize(e);
|
||||
return;
|
||||
}
|
||||
MakeCurrent();
|
||||
|
||||
float aspect_ratio;
|
||||
if (stereoscopy)
|
||||
aspect_ratio = Width / 2 / (float)Height;
|
||||
else
|
||||
aspect_ratio = Width / (float)Height;
|
||||
|
||||
mtxProj = Matrix4.CreatePerspectiveFieldOfView(fov, aspect_ratio, znear, zfar);
|
||||
|
||||
orientationCubeMtx = Matrix4.CreateOrthographic(Width, Height, 0.125f, 2f) * Matrix4.CreateTranslation(0, 0, 1);
|
||||
|
||||
//using the calculation from whitehole
|
||||
factorX = (2f * (float)Math.Tan(fov * 0.5f) * aspect_ratio) / Width;
|
||||
|
||||
factorY = (2f * (float)Math.Tan(fov * 0.5f)) / Height;
|
||||
|
||||
base.OnResize(e);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
|
||||
if (mainDrawable == null || DesignMode)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
e.Graphics.Clear(Color.Black);
|
||||
e.Graphics.DrawString("Modern Gl" + (stereoscopy ? " stereoscopy" : ""), SystemFonts.DefaultFont, SystemBrushes.ControlLight, 10f, 10f);
|
||||
return;
|
||||
}
|
||||
MakeCurrent();
|
||||
|
||||
base.OnPaint(e);
|
||||
|
||||
GL.ClearColor(BackgroundColor1);
|
||||
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
|
||||
if (stereoscopy)
|
||||
{
|
||||
#region left eye
|
||||
GL.Viewport(0, 0, Width / 2, Height);
|
||||
|
||||
mtxMdl = Matrix4.Identity;
|
||||
mtxCam =
|
||||
Matrix4.CreateTranslation(camTarget) *
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateTranslation(0.25f, 0, camDistance) *
|
||||
Matrix4.CreateRotationY(0.02f);
|
||||
|
||||
mainDrawable.Draw(this, Pass.OPAQUE);
|
||||
|
||||
mainDrawable.Draw(this, Pass.TRANSPARENT);
|
||||
|
||||
shader = null;
|
||||
GL.UseProgram(0);
|
||||
|
||||
if (GradientBackground)
|
||||
DrawGradientBG();
|
||||
|
||||
if (showOrientationCube)
|
||||
{
|
||||
orientationCubeMtx =
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateScale(80f / Width, 40f / Height, 0.25f) *
|
||||
Matrix4.CreateTranslation(1 - 160f / Width, 1 - 80f / Height, 0) *
|
||||
Matrix4.CreateRotationY(0.03125f);
|
||||
GL.LoadMatrix(ref orientationCubeMtx);
|
||||
|
||||
DrawOrientationCube();
|
||||
}
|
||||
|
||||
if (showFakeCursor)
|
||||
DrawFakeCursor();
|
||||
#endregion
|
||||
|
||||
#region right eye
|
||||
GL.Viewport(Width / 2, 0, Width / 2, Height);
|
||||
|
||||
mtxMdl = Matrix4.Identity;
|
||||
mtxCam =
|
||||
Matrix4.CreateTranslation(camTarget) *
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateTranslation(-0.25f, 0, camDistance) *
|
||||
Matrix4.CreateRotationY(-0.02f);
|
||||
|
||||
mainDrawable.Draw(this, Pass.OPAQUE);
|
||||
|
||||
mainDrawable.Draw(this, Pass.TRANSPARENT);
|
||||
|
||||
shader = null;
|
||||
GL.UseProgram(0);
|
||||
|
||||
if (GradientBackground)
|
||||
DrawGradientBG();
|
||||
|
||||
if (showOrientationCube)
|
||||
{
|
||||
orientationCubeMtx =
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateScale(80f / Width, 40f / Height, 0.25f) *
|
||||
Matrix4.CreateTranslation(1 - 160f / Width, 1 - 80f / Height, 0) *
|
||||
Matrix4.CreateRotationY(-0.03125f);
|
||||
GL.LoadMatrix(ref orientationCubeMtx);
|
||||
|
||||
DrawOrientationCube();
|
||||
}
|
||||
|
||||
if (showFakeCursor)
|
||||
DrawFakeCursor();
|
||||
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
mtxMdl = Matrix4.Identity;
|
||||
mtxCam =
|
||||
Matrix4.CreateTranslation(camTarget) *
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateTranslation(0, 0, camDistance);
|
||||
|
||||
mainDrawable.Draw(this, Pass.OPAQUE);
|
||||
|
||||
mainDrawable.Draw(this, Pass.TRANSPARENT);
|
||||
|
||||
shader = null;
|
||||
GL.UseProgram(0);
|
||||
|
||||
if (GradientBackground)
|
||||
DrawGradientBG();
|
||||
|
||||
if (showOrientationCube)
|
||||
{
|
||||
orientationCubeMtx =
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateScale(40f / Width, 40f / Height, 0.25f) *
|
||||
Matrix4.CreateTranslation(1 - 80f / Width, 1 - 80f / Height, 0);
|
||||
GL.LoadMatrix(ref orientationCubeMtx);
|
||||
|
||||
DrawOrientationCube();
|
||||
}
|
||||
}
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
public override void DrawPicking()
|
||||
{
|
||||
if (DesignMode) return;
|
||||
MakeCurrent();
|
||||
GL.ClearColor(0f, 0f, 0f, 0f);
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
if (stereoscopy)
|
||||
GL.Viewport(0, 0, Width / 2, Height);
|
||||
else
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
if (showOrientationCube)
|
||||
skipPickingColors(6); //the orientation cube faces
|
||||
|
||||
mainDrawable.Draw(this, Pass.PICKING);
|
||||
|
||||
if (showOrientationCube)
|
||||
{
|
||||
GL.UseProgram(0);
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
orientationCubeMtx =
|
||||
Matrix4.CreateRotationY(camRotX) *
|
||||
Matrix4.CreateRotationX(camRotY) *
|
||||
Matrix4.CreateScale((stereoscopy ? 80f : 40f) / Width, 40f / Height, 0.25f) *
|
||||
Matrix4.CreateTranslation(1 - (stereoscopy ? 160f : 80f) / Width, 1 - 80f / Height, 0);
|
||||
GL.LoadMatrix(ref orientationCubeMtx);
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color4(Color.FromArgb(1)); //UP
|
||||
GL.Vertex3(-1f, 1f, 1f);
|
||||
GL.Vertex3(1f, 1f, 1f);
|
||||
GL.Vertex3(1f, 1f, -1f);
|
||||
GL.Vertex3(-1f, 1f, -1f);
|
||||
GL.Color4(Color.FromArgb(2)); //DOWN
|
||||
GL.Vertex3(-1f, -1f, -1f);
|
||||
GL.Vertex3(1f, -1f, -1f);
|
||||
GL.Vertex3(1f, -1f, 1f);
|
||||
GL.Vertex3(-1f, -1f, 1f);
|
||||
GL.Color4(Color.FromArgb(3)); //FRONT
|
||||
GL.Vertex3(1f, 1f, 1f);
|
||||
GL.Vertex3(-1f, 1f, 1f);
|
||||
GL.Vertex3(-1f, -1f, 1f);
|
||||
GL.Vertex3(1f, -1f, 1f);
|
||||
GL.Color4(Color.FromArgb(4)); //BACK
|
||||
GL.Vertex3(-1f, 1f, -1f);
|
||||
GL.Vertex3(1f, 1f, -1f);
|
||||
GL.Vertex3(1f, -1f, -1f);
|
||||
GL.Vertex3(-1f, -1f, -1f);
|
||||
GL.Color4(Color.FromArgb(5)); //LEFT
|
||||
GL.Vertex3(1f, 1f, -1f);
|
||||
GL.Vertex3(1f, 1f, 1f);
|
||||
GL.Vertex3(1f, -1f, 1f);
|
||||
GL.Vertex3(1f, -1f, -1f);
|
||||
GL.Color4(Color.FromArgb(6)); //RIGHT
|
||||
GL.Vertex3(-1f, 1f, 1f);
|
||||
GL.Vertex3(-1f, 1f, -1f);
|
||||
GL.Vertex3(-1f, -1f, -1f);
|
||||
GL.Vertex3(-1f, -1f, 1f);
|
||||
GL.End();
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace GL_EditorFramework.GL_Core
|
||||
{
|
||||
public class OldGlEmulator : IDisposable
|
||||
{
|
||||
List<float> dataList = new List<float>();
|
||||
|
||||
float current_r = 255f;
|
||||
float current_g = 255f;
|
||||
float current_b = 255f;
|
||||
float current_a = 255f;
|
||||
public OldGlEmulator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Vertex3(float x, float y, float z)
|
||||
{
|
||||
dataList.Add(x); dataList.Add(y); dataList.Add(z);
|
||||
dataList.Add(current_r); dataList.Add(current_g); dataList.Add(current_b); dataList.Add(current_a);
|
||||
}
|
||||
|
||||
public void Color3(float r, float g, float b)
|
||||
{
|
||||
current_r = r;
|
||||
current_g = g;
|
||||
current_b = b;
|
||||
}
|
||||
|
||||
public void WriteToBuffer(int buffer) {
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);
|
||||
float[] arrayData = dataList.ToArray();
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * arrayData.Length, arrayData, BufferUsageHint.StaticDraw);
|
||||
|
||||
GL.EnableVertexAttribArray(0);
|
||||
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 7, 0);
|
||||
GL.EnableVertexAttribArray(1);
|
||||
GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, sizeof(float) * 7, sizeof(float) * 3);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 8.5 KiB |
|
@ -1,262 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace GL_EditorFramework.GL_Core
|
||||
{
|
||||
public class ShaderProgram
|
||||
{
|
||||
private int fragSh, vertSh, geomSh;
|
||||
private Matrix4 modelMatrix;
|
||||
private Matrix4 computedCamMtx;
|
||||
private Matrix4 projectionMatrix;
|
||||
|
||||
private Dictionary<string, int> attributes = new Dictionary<string, int>();
|
||||
private int activeAttributeCount;
|
||||
public int program;
|
||||
|
||||
public ShaderProgram(FragmentShader frag, VertexShader vert)
|
||||
{
|
||||
LoadShaders(new Shader[] { vert, frag });
|
||||
}
|
||||
|
||||
public ShaderProgram(FragmentShader frag, VertexShader vert, GeomertyShader geom)
|
||||
{
|
||||
LoadShaders(new Shader[] { vert, frag, geom });
|
||||
}
|
||||
|
||||
public ShaderProgram(Shader[] shaders)
|
||||
{
|
||||
LoadShaders(shaders);
|
||||
}
|
||||
|
||||
private void LoadShaders(Shader[] shaders)
|
||||
{
|
||||
program = GL.CreateProgram();
|
||||
|
||||
foreach (Shader shader in shaders)
|
||||
{
|
||||
AttachShader(shader);
|
||||
}
|
||||
|
||||
GL.LinkProgram(program);
|
||||
foreach (Shader shader in shaders)
|
||||
{
|
||||
if (shader.type == ShaderType.VertexShader)
|
||||
Console.WriteLine("vertex:");
|
||||
if (shader.type == ShaderType.FragmentShader)
|
||||
Console.WriteLine("fragment:");
|
||||
if (shader.type == ShaderType.GeometryShader)
|
||||
Console.WriteLine("geometry:");
|
||||
|
||||
Console.WriteLine(GL.GetShaderInfoLog(shader.id));
|
||||
}
|
||||
LoadAttributes();
|
||||
}
|
||||
|
||||
public void AttachShader(Shader shader)
|
||||
{
|
||||
Console.WriteLine("shader:");
|
||||
Console.WriteLine(GL.GetShaderInfoLog(shader.id));
|
||||
GL.AttachShader(program, shader.id);
|
||||
}
|
||||
|
||||
public void DetachShader(Shader shader)
|
||||
{
|
||||
GL.DetachShader(program, shader.id);
|
||||
}
|
||||
|
||||
public void LinkShaders()
|
||||
{
|
||||
GL.LinkProgram(program);
|
||||
}
|
||||
|
||||
public void SetFragmentShader(FragmentShader shader)
|
||||
{
|
||||
GL.DetachShader(program, fragSh);
|
||||
GL.AttachShader(program, shader.id);
|
||||
fragSh = shader.id;
|
||||
GL.LinkProgram(program);
|
||||
}
|
||||
|
||||
public void SetVertexShader(VertexShader shader)
|
||||
{
|
||||
GL.DetachShader(program, vertSh);
|
||||
GL.AttachShader(program, shader.id);
|
||||
vertSh = shader.id;
|
||||
GL.LinkProgram(program);
|
||||
|
||||
GL.UniformMatrix4(GL.GetUniformLocation(program, "mtxMdl"), false, ref modelMatrix);
|
||||
GL.UniformMatrix4(GL.GetUniformLocation(program, "mtxCam"), false, ref computedCamMtx);
|
||||
}
|
||||
|
||||
public void Setup(Matrix4 mtxMdl, Matrix4 mtxCam, Matrix4 mtxProj)
|
||||
{
|
||||
GL.UseProgram(program);
|
||||
modelMatrix = mtxMdl;
|
||||
int mtxMdl_loc = GL.GetUniformLocation(program, "mtxMdl");
|
||||
if (mtxMdl_loc != -1)
|
||||
GL.UniformMatrix4(mtxMdl_loc, false, ref modelMatrix);
|
||||
|
||||
computedCamMtx = mtxCam * mtxProj;
|
||||
|
||||
int mtxCam_loc = GL.GetUniformLocation(program, "mtxCam");
|
||||
if (mtxCam_loc != -1)
|
||||
GL.UniformMatrix4(mtxCam_loc, false, ref computedCamMtx);
|
||||
|
||||
int mtxCamTest_loc = GL.GetUniformLocation(program, "mtxCamTest");
|
||||
if (mtxCamTest_loc != -1)
|
||||
GL.UniformMatrix4(mtxCamTest_loc, false, ref mtxCam);
|
||||
|
||||
projectionMatrix = mtxProj;
|
||||
|
||||
int projCam_loc = GL.GetUniformLocation(program, "mtxProj");
|
||||
if (projCam_loc != -1)
|
||||
GL.UniformMatrix4(projCam_loc, false, ref projectionMatrix);
|
||||
}
|
||||
|
||||
public void UpdateModelMatrix(Matrix4 matrix)
|
||||
{
|
||||
modelMatrix = matrix;
|
||||
int mtxMdl_loc = GL.GetUniformLocation(program, "mtxMdl");
|
||||
if (mtxMdl_loc != -1)
|
||||
GL.UniformMatrix4(mtxMdl_loc, false, ref modelMatrix);
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
GL.UseProgram(program);
|
||||
}
|
||||
|
||||
public int this[string name]
|
||||
{
|
||||
get => GL.GetUniformLocation(program, name);
|
||||
}
|
||||
|
||||
private void LoadAttributes()
|
||||
{
|
||||
attributes.Clear();
|
||||
|
||||
GL.GetProgram(program, GetProgramParameterName.ActiveAttributes, out activeAttributeCount);
|
||||
for (int i = 0; i < activeAttributeCount; i++)
|
||||
AddAttribute(i);
|
||||
}
|
||||
|
||||
private void AddAttribute(int index)
|
||||
{
|
||||
string name = GL.GetActiveAttrib(program, index, out int size, out ActiveAttribType type);
|
||||
int location = GL.GetAttribLocation(program, name);
|
||||
|
||||
// Overwrite existing vertex attributes.
|
||||
attributes[name] = location;
|
||||
}
|
||||
|
||||
public int GetAttribute(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name) || !attributes.ContainsKey(name))
|
||||
return -1;
|
||||
else
|
||||
return attributes[name];
|
||||
}
|
||||
|
||||
public void EnableVertexAttributes()
|
||||
{
|
||||
foreach (KeyValuePair<string, int> attrib in attributes)
|
||||
{
|
||||
GL.EnableVertexAttribArray(attrib.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public void DisableVertexAttributes()
|
||||
{
|
||||
foreach (KeyValuePair<string, int> attrib in attributes)
|
||||
{
|
||||
GL.DisableVertexAttribArray(attrib.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBoolToInt(string name, bool value)
|
||||
{
|
||||
if (value)
|
||||
GL.Uniform1(this[name], 1);
|
||||
else
|
||||
GL.Uniform1(this[name], 0);
|
||||
}
|
||||
|
||||
public void SetMatrix4x4(string name, ref Matrix4 value, bool Transpose = false)
|
||||
{
|
||||
GL.UniformMatrix4(this[name], false, ref value);
|
||||
}
|
||||
|
||||
public void SetVector4(string name, Vector4 value)
|
||||
{
|
||||
GL.Uniform4(this[name], value);
|
||||
}
|
||||
|
||||
public void SetVector3(string name, Vector3 value)
|
||||
{
|
||||
GL.Uniform3(this[name], value);
|
||||
}
|
||||
|
||||
public void SetVector2(string name, Vector2 value)
|
||||
{
|
||||
GL.Uniform2(this[name], value);
|
||||
}
|
||||
|
||||
public void SetFloat(string name, float value)
|
||||
{
|
||||
GL.Uniform1(this[name], value);
|
||||
}
|
||||
|
||||
public void SetInt(string name, int value)
|
||||
{
|
||||
GL.Uniform1(this[name], value);
|
||||
}
|
||||
}
|
||||
|
||||
public class Shader
|
||||
{
|
||||
public Shader(string src, ShaderType type)
|
||||
{
|
||||
id = GL.CreateShader(type);
|
||||
GL.ShaderSource(id, src);
|
||||
GL.CompileShader(id);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ShaderType type;
|
||||
|
||||
public int id;
|
||||
}
|
||||
|
||||
public class FragmentShader : Shader
|
||||
{
|
||||
public FragmentShader(string src)
|
||||
: base(src, ShaderType.FragmentShader)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class VertexShader : Shader
|
||||
{
|
||||
public VertexShader(string src)
|
||||
: base(src, ShaderType.VertexShader)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class GeomertyShader : Shader
|
||||
{
|
||||
public GeomertyShader(string src)
|
||||
: base(src, ShaderType.GeometryShader)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
<?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>{D593A72D-554D-40FB-9967-503CB15A744F}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenGl_EditorFramework</RootNamespace>
|
||||
<AssemblyName>OpenGl_EditorFramework</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK">
|
||||
<HintPath>..\..\Toolbox\Lib\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK.GLControl">
|
||||
<HintPath>..\..\Toolbox\Lib\OpenTK.GLControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EditorDrawables\SingleObject.cs" />
|
||||
<Compile Include="GL_Core\Cameras\Inspect.cs" />
|
||||
<Compile Include="GL_Core\Cameras\Walkaround.cs" />
|
||||
<Compile Include="EditorDrawables\EditableObject.cs" />
|
||||
<Compile Include="EditorDrawables\EditorScene.cs" />
|
||||
<Compile Include="EditorDrawables\Path.cs" />
|
||||
<Compile Include="Framework.cs" />
|
||||
<Compile Include="GL_Core\GL_ControlBase.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GL_Core\GL_ControlLegacy.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GL_Core\GL_ControlModern.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GL_Core\OldGlEmulator.cs" />
|
||||
<Compile Include="Interfaces\AbstractCamera.cs" />
|
||||
<Compile Include="Interfaces\AbstractEventHandlingObj.cs" />
|
||||
<Compile Include="Interfaces\AbstractGlDrawable.cs" />
|
||||
<Compile Include="Interfaces\I3DControl.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Renderers.cs" />
|
||||
<Compile Include="SceneListView.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GL_Core\ShaderClass.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="GL_Core\Resources\TextureSheet.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,40 +0,0 @@
|
|||
using OpenTK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework.Interfaces
|
||||
{
|
||||
public abstract class AbstractCamera : AbstractEventHandling3DObj
|
||||
{
|
||||
public const uint UPDATE_CAMERA = 0x80000000;
|
||||
private const float depthAdjust = 1;
|
||||
|
||||
protected float depth, desiredDepth;
|
||||
|
||||
public override uint MouseDown(MouseEventArgs e, I3DControl control)
|
||||
{
|
||||
desiredDepth = control.PickingDepth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override uint MouseMove(MouseEventArgs e, Point lastMouseLoc, I3DControl control)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (depth < desiredDepth - depthAdjust)
|
||||
depth += depthAdjust;
|
||||
else if (depth != desiredDepth)
|
||||
depth = desiredDepth;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public virtual void Update() { }
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
using GL_EditorFramework.GL_Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework.Interfaces
|
||||
{
|
||||
public class AbstractEventHandling3DObj
|
||||
{
|
||||
public virtual uint MouseDown(MouseEventArgs e, I3DControl control) { return 0; }
|
||||
public virtual uint MouseMove(MouseEventArgs e, Point lastMousePos, I3DControl control) {return 0; }
|
||||
public virtual uint MouseUp(MouseEventArgs e, I3DControl control) { return 0; }
|
||||
public virtual uint MouseWheel(MouseEventArgs e, I3DControl control) { return 0; }
|
||||
public virtual uint MouseClick(MouseEventArgs e, I3DControl control) { return 0; }
|
||||
|
||||
public virtual uint KeyDown(KeyEventArgs e, I3DControl control) { return 0; }
|
||||
public virtual uint KeyUp(KeyEventArgs e, I3DControl control) { return 0; }
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
using GL_EditorFramework.GL_Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework.Interfaces
|
||||
{
|
||||
public enum Pass
|
||||
{
|
||||
OPAQUE,
|
||||
TRANSPARENT,
|
||||
PICKING
|
||||
}
|
||||
|
||||
public abstract class AbstractGlDrawable : AbstractEventHandling3DObj
|
||||
{
|
||||
public const uint REDRAW = 0x80000000;
|
||||
public const uint REDRAW_PICKING = 0xC0000000;
|
||||
public const uint NO_CAMERA_ACTION = 0x20000000;
|
||||
public const uint REPICK = 0x40000000;
|
||||
|
||||
public abstract void Prepare(GL_ControlModern control);
|
||||
public abstract void Prepare(GL_ControlLegacy control);
|
||||
public abstract void Draw(GL_ControlModern control, Pass pass);
|
||||
public abstract void Draw(GL_ControlLegacy control, Pass pass);
|
||||
public virtual int GetPickableSpan() => 1;
|
||||
public virtual uint MouseEnter(int index, I3DControl control) { return 0; }
|
||||
public virtual uint MouseLeave(int index, I3DControl control) { return 0; }
|
||||
public virtual uint MouseLeaveEntirely(I3DControl control) { return 0; }
|
||||
public override uint MouseMove(MouseEventArgs e, Point lastMousePos, I3DControl control) { return REPICK; }
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
using OpenTK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GL_EditorFramework.Interfaces
|
||||
{
|
||||
public interface I3DControl
|
||||
{
|
||||
void AttachRedrawer();
|
||||
void AttachPickingRedrawer();
|
||||
void DetachRedrawer();
|
||||
void DetachPickingRedrawer();
|
||||
|
||||
ulong RedrawerFrame { get; }
|
||||
|
||||
int ViewWidth { get; }
|
||||
int ViewHeighth { get; }
|
||||
Vector2 NormMouseCoords(int x, int y);
|
||||
|
||||
Point DragStartPos { get; set; }
|
||||
|
||||
float ZFar { get; set; }
|
||||
float ZNear { get; set; }
|
||||
float Fov { get; set; }
|
||||
float FactorX { get; }
|
||||
float FactorY { get; }
|
||||
|
||||
Vector3 CameraTarget { get; set; }
|
||||
float CameraDistance { get; set; }
|
||||
float CamRotX { get; set; }
|
||||
float CamRotY { get; set; }
|
||||
|
||||
Vector3 coordFor(int x, int y, float depth);
|
||||
|
||||
Vector3 screenCoordFor(Vector3 coord);
|
||||
|
||||
float PickingDepth { get; }
|
||||
|
||||
float NormPickingDepth { get; }
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
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("OpenGl_EditorFramework")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("OpenGl_EditorFramework")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[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("d593a72d-554d-40fb-9967-503cb15a744f")]
|
||||
|
||||
// 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")]
|
|
@ -1,73 +0,0 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <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 OpenGl_EditorFramework.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", "15.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("OpenGl_EditorFramework.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 TextureSheet {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("TextureSheet", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
<?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="TextureSheet" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\GL_Core\Resources\TextureSheet.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1,464 +0,0 @@
|
|||
using GL_EditorFramework;
|
||||
using GL_EditorFramework.GL_Core;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenGl_EditorFramework
|
||||
{
|
||||
public static class Renderers
|
||||
{
|
||||
private static void face(ref float[][] points, ref List<float> data, int p1, int p2, int p4, int p3)
|
||||
{
|
||||
data.AddRange(new float[] {
|
||||
points[p1][0], points[p1][1], points[p1][2],
|
||||
points[p2][0], points[p2][1], points[p2][2],
|
||||
points[p3][0], points[p3][1], points[p3][2],
|
||||
points[p4][0], points[p4][1], points[p4][2]
|
||||
});
|
||||
}
|
||||
|
||||
private static void lineFace(ref float[][] points, ref List<float> data, int p1, int p2, int p4, int p3)
|
||||
{
|
||||
data.AddRange(new float[] {
|
||||
points[p1][0], points[p1][1], points[p1][2],
|
||||
points[p2][0], points[p2][1], points[p2][2],
|
||||
points[p2][0], points[p2][1], points[p2][2],
|
||||
points[p3][0], points[p3][1], points[p3][2],
|
||||
points[p3][0], points[p3][1], points[p3][2],
|
||||
points[p4][0], points[p4][1], points[p4][2],
|
||||
points[p4][0], points[p4][1], points[p4][2],
|
||||
points[p1][0], points[p1][1], points[p1][2]
|
||||
});
|
||||
}
|
||||
|
||||
private static void line(ref float[][] points, ref List<float> data, int p1, int p2)
|
||||
{
|
||||
data.AddRange(new float[] {
|
||||
points[p1][0], points[p1][1], points[p1][2],
|
||||
points[p2][0], points[p2][1], points[p2][2]
|
||||
});
|
||||
}
|
||||
|
||||
private static void faceInv(ref float[][] points, ref List<float> data, int p2, int p1, int p3, int p4)
|
||||
{
|
||||
data.AddRange(new float[] {
|
||||
points[p1][0], points[p1][1], points[p1][2],
|
||||
points[p2][0], points[p2][1], points[p2][2],
|
||||
points[p3][0], points[p3][1], points[p3][2],
|
||||
points[p4][0], points[p4][1], points[p4][2]
|
||||
});
|
||||
}
|
||||
|
||||
public static class ColorBlockRenderer {
|
||||
private static bool Initialized = false;
|
||||
|
||||
private static ShaderProgram defaultShaderProgram;
|
||||
private static ShaderProgram solidColorShaderProgram;
|
||||
|
||||
private static int linesVao;
|
||||
private static int blockVao;
|
||||
|
||||
private static float[][] points = new float[][]
|
||||
{
|
||||
new float[]{-1,-1, 1},
|
||||
new float[]{ 1,-1, 1},
|
||||
new float[]{-1, 1, 1},
|
||||
new float[]{ 1, 1, 1},
|
||||
new float[]{-1,-1,-1},
|
||||
new float[]{ 1,-1,-1},
|
||||
new float[]{-1, 1,-1},
|
||||
new float[]{ 1, 1,-1}
|
||||
};
|
||||
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (!Initialized)
|
||||
{
|
||||
var defaultFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
uniform sampler2D tex;
|
||||
in vec4 fragColor;
|
||||
in vec3 fragPosition;
|
||||
in vec2 uv;
|
||||
|
||||
void main(){
|
||||
gl_FragColor = fragColor*((fragPosition.y+2)/3)*texture(tex, uv);
|
||||
}");
|
||||
var solidColorFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
uniform vec4 color;
|
||||
void main(){
|
||||
gl_FragColor = color;
|
||||
}");
|
||||
var defaultVert = new VertexShader(
|
||||
@"#version 330
|
||||
layout(location = 0) in vec4 position;
|
||||
uniform vec4 color;
|
||||
uniform mat4 mtxMdl;
|
||||
uniform mat4 mtxCam;
|
||||
out vec4 fragColor;
|
||||
out vec3 fragPosition;
|
||||
out vec2 uv;
|
||||
|
||||
vec2 map(vec2 value, vec2 min1, vec2 max1, vec2 min2, vec2 max2) {
|
||||
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
|
||||
}
|
||||
|
||||
void main(){
|
||||
fragPosition = position.xyz;
|
||||
uv = map(fragPosition.xz,vec2(-1.0625,-1.0625),vec2(1.0625,1.0625), vec2(0.5,0.5), vec2(0.75,1.0));
|
||||
gl_Position = mtxCam*mtxMdl*position;
|
||||
fragColor = color;
|
||||
}");
|
||||
var solidColorVert = new VertexShader(
|
||||
@"#version 330
|
||||
layout(location = 0) in vec4 position;
|
||||
uniform mat4 mtxMdl;
|
||||
uniform mat4 mtxCam;
|
||||
void main(){
|
||||
gl_Position = mtxCam*mtxMdl*position;
|
||||
}");
|
||||
defaultShaderProgram = new ShaderProgram(defaultFrag, defaultVert);
|
||||
solidColorShaderProgram = new ShaderProgram(solidColorFrag, solidColorVert);
|
||||
|
||||
int buffer;
|
||||
|
||||
#region block
|
||||
GL.BindVertexArray(blockVao = GL.GenVertexArray());
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, buffer = GL.GenBuffer());
|
||||
List<float> list = new List<float>();
|
||||
|
||||
face(ref points, ref list, 0, 1, 2, 3);
|
||||
faceInv(ref points, ref list, 4, 5, 6, 7);
|
||||
faceInv(ref points, ref list, 0, 1, 4, 5);
|
||||
face(ref points, ref list, 2, 3, 6, 7);
|
||||
face(ref points, ref list, 0, 2, 4, 6);
|
||||
faceInv(ref points, ref list, 1, 3, 5, 7);
|
||||
|
||||
float[] data = list.ToArray();
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * data.Length, data, BufferUsageHint.StaticDraw);
|
||||
|
||||
GL.EnableVertexAttribArray(0);
|
||||
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 3, 0);
|
||||
#endregion
|
||||
|
||||
#region lines
|
||||
GL.BindVertexArray(linesVao = GL.GenVertexArray());
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, buffer = GL.GenBuffer());
|
||||
list = new List<float>();
|
||||
|
||||
lineFace(ref points, ref list, 0, 1, 2, 3);
|
||||
lineFace(ref points, ref list, 4, 5, 6, 7);
|
||||
line(ref points, ref list, 0, 4);
|
||||
line(ref points, ref list, 1, 5);
|
||||
line(ref points, ref list, 2, 6);
|
||||
line(ref points,
|
||||
ref list, 3, 7);
|
||||
|
||||
data = list.ToArray();
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * data.Length, data, BufferUsageHint.StaticDraw);
|
||||
|
||||
GL.EnableVertexAttribArray(0);
|
||||
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 3, 0);
|
||||
#endregion
|
||||
|
||||
|
||||
Initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Draw(GL_ControlModern control, Pass pass, Vector4 blockColor, Vector4 lineColor, Color pickingColor)
|
||||
{
|
||||
control.CurrentShader = solidColorShaderProgram;
|
||||
|
||||
if (pass == Pass.OPAQUE)
|
||||
{
|
||||
|
||||
#region outlines
|
||||
GL.LineWidth(2.0f);
|
||||
|
||||
GL.Uniform4(solidColorShaderProgram["color"], lineColor);
|
||||
GL.BindVertexArray(linesVao);
|
||||
GL.DrawArrays(PrimitiveType.Lines, 0, 24);
|
||||
#endregion
|
||||
control.CurrentShader = defaultShaderProgram;
|
||||
|
||||
GL.Uniform1(defaultShaderProgram["tex"], Framework.TextureSheet - 1);
|
||||
|
||||
GL.Uniform4(defaultShaderProgram["color"], blockColor);
|
||||
}
|
||||
else
|
||||
GL.Uniform4(solidColorShaderProgram["color"], pickingColor);
|
||||
|
||||
GL.BindVertexArray(blockVao);
|
||||
GL.DrawArrays(PrimitiveType.Quads, 0, 24);
|
||||
}
|
||||
|
||||
public static void Draw(GL_ControlLegacy control, Pass pass, Vector4 blockColor, Vector4 lineColor, Color pickingColor)
|
||||
{
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
|
||||
if (pass == Pass.OPAQUE)
|
||||
{
|
||||
#region draw lines
|
||||
GL.Color4(lineColor);
|
||||
|
||||
GL.LineWidth(2.0f);
|
||||
|
||||
GL.Begin(PrimitiveType.LineStrip);
|
||||
GL.Vertex3(points[6]);
|
||||
GL.Vertex3(points[2]);
|
||||
GL.Vertex3(points[3]);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.Vertex3(points[6]);
|
||||
|
||||
GL.Vertex3(points[4]);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.Vertex3(points[1]);
|
||||
GL.Vertex3(points[0]);
|
||||
GL.Vertex3(points[4]);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(PrimitiveType.Lines);
|
||||
GL.Vertex3(points[2]);
|
||||
GL.Vertex3(points[0]);
|
||||
GL.Vertex3(points[3]);
|
||||
GL.Vertex3(points[1]);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.End();
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.Color4(pickingColor);
|
||||
|
||||
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.Vertex3(points[6]);
|
||||
GL.Vertex3(points[2]);
|
||||
GL.Vertex3(points[3]);
|
||||
|
||||
GL.Vertex3(points[4]);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.Vertex3(points[1]);
|
||||
GL.Vertex3(points[0]);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(PrimitiveType.QuadStrip);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.Vertex3(points[6]);
|
||||
GL.Vertex3(points[4]);
|
||||
GL.Vertex3(points[2]);
|
||||
GL.Vertex3(points[0]);
|
||||
GL.Vertex3(points[3]);
|
||||
GL.Vertex3(points[1]);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.End();
|
||||
}
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
|
||||
if (pass == Pass.OPAQUE)
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, Framework.TextureSheet);
|
||||
|
||||
#region draw faces
|
||||
Vector4 darkerColor = blockColor * 0.71875f;
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color4(blockColor);
|
||||
GL.TexCoord2(0.71875f, 0.515625f);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.TexCoord2(0.53125f, 0.515625f);
|
||||
GL.Vertex3(points[6]);
|
||||
GL.TexCoord2(0.53125f, 0.984375f);
|
||||
GL.Vertex3(points[2]);
|
||||
GL.TexCoord2(0.71875f, 0.984375f);
|
||||
GL.Vertex3(points[3]);
|
||||
|
||||
GL.Color4(darkerColor);
|
||||
GL.TexCoord2(0.53125f, 0.515625f);
|
||||
GL.Vertex3(points[4]);
|
||||
GL.TexCoord2(0.71875f, 0.515625f);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.TexCoord2(0.71875f, 0.984375f);
|
||||
GL.Vertex3(points[1]);
|
||||
GL.TexCoord2(0.53125f, 0.984375f);
|
||||
GL.Vertex3(points[0]);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(PrimitiveType.QuadStrip);
|
||||
GL.TexCoord2(0.71875f, 0.515625f);
|
||||
GL.Color4(blockColor);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.Color4(darkerColor);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.Color4(blockColor);
|
||||
GL.Vertex3(points[6]);
|
||||
GL.Color4(darkerColor);
|
||||
GL.Vertex3(points[4]);
|
||||
GL.Color4(blockColor);
|
||||
GL.Vertex3(points[2]);
|
||||
GL.Color4(darkerColor);
|
||||
GL.Vertex3(points[0]);
|
||||
GL.Color4(blockColor);
|
||||
GL.Vertex3(points[3]);
|
||||
GL.Color4(darkerColor);
|
||||
GL.Vertex3(points[1]);
|
||||
GL.Color4(blockColor);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.Color4(darkerColor);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.End();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LineBoxRenderer
|
||||
{
|
||||
|
||||
private static bool Initialized = false;
|
||||
|
||||
private static ShaderProgram defaultShaderProgram;
|
||||
|
||||
private static int linesVao;
|
||||
|
||||
private static float[][] points = new float[][]
|
||||
{
|
||||
new float[]{-1,-1, 1},
|
||||
new float[]{ 1,-1, 1},
|
||||
new float[]{-1, 1, 1},
|
||||
new float[]{ 1, 1, 1},
|
||||
new float[]{-1,-1,-1},
|
||||
new float[]{ 1,-1,-1},
|
||||
new float[]{-1, 1,-1},
|
||||
new float[]{ 1, 1,-1}
|
||||
};
|
||||
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (!Initialized)
|
||||
{
|
||||
var defaultFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
uniform vec4 color;
|
||||
void main(){
|
||||
gl_FragColor = color;
|
||||
}");
|
||||
var defaultVert = new VertexShader(
|
||||
@"#version 330
|
||||
layout(location = 0) in vec4 position;
|
||||
uniform mat4 mtxMdl;
|
||||
uniform mat4 mtxCam;
|
||||
void main(){
|
||||
gl_Position = mtxCam*mtxMdl*position;
|
||||
}");
|
||||
defaultShaderProgram = new ShaderProgram(defaultFrag, defaultVert);
|
||||
|
||||
int buffer;
|
||||
|
||||
#region lines
|
||||
GL.BindVertexArray(linesVao = GL.GenVertexArray());
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, buffer = GL.GenBuffer());
|
||||
List<float> list = new List<float>();
|
||||
|
||||
lineFace(ref points, ref list, 0, 1, 2, 3);
|
||||
lineFace(ref points, ref list, 4, 5, 6, 7);
|
||||
line(ref points, ref list, 0, 4);
|
||||
line(ref points, ref list, 1, 5);
|
||||
line(ref points, ref list, 2, 6);
|
||||
line(ref points, ref list, 3, 7);
|
||||
|
||||
float[] data = list.ToArray();
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * data.Length, data, BufferUsageHint.StaticDraw);
|
||||
|
||||
GL.EnableVertexAttribArray(0);
|
||||
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 3, 0);
|
||||
#endregion
|
||||
|
||||
|
||||
Initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Draw(GL_ControlModern control, Pass pass, Vector4 color, Color pickingColor)
|
||||
{
|
||||
control.CurrentShader = defaultShaderProgram;
|
||||
|
||||
if (pass == Pass.OPAQUE)
|
||||
{
|
||||
GL.LineWidth(4.0f);
|
||||
GL.Uniform4(defaultShaderProgram["color"], color);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.LineWidth(6.0f);
|
||||
GL.Uniform4(defaultShaderProgram["color"], pickingColor);
|
||||
}
|
||||
|
||||
GL.BindVertexArray(linesVao);
|
||||
GL.DrawArrays(PrimitiveType.Lines, 0, 24);
|
||||
}
|
||||
|
||||
public static void Draw(GL_ControlLegacy control, Pass pass, Vector4 color, Color pickingColor)
|
||||
{
|
||||
GL.Disable(EnableCap.Texture2D);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
|
||||
if (pass == Pass.OPAQUE)
|
||||
{
|
||||
GL.LineWidth(4.0f);
|
||||
GL.Color4(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.LineWidth(6.0f);
|
||||
GL.Color4(pickingColor);
|
||||
}
|
||||
|
||||
GL.Begin(PrimitiveType.LineStrip);
|
||||
GL.Vertex3(points[6]);
|
||||
GL.Vertex3(points[2]);
|
||||
GL.Vertex3(points[3]);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.Vertex3(points[6]);
|
||||
|
||||
GL.Vertex3(points[4]);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.Vertex3(points[1]);
|
||||
GL.Vertex3(points[0]);
|
||||
GL.Vertex3(points[4]);
|
||||
GL.End();
|
||||
|
||||
GL.Begin(PrimitiveType.Lines);
|
||||
GL.Vertex3(points[2]);
|
||||
GL.Vertex3(points[0]);
|
||||
GL.Vertex3(points[3]);
|
||||
GL.Vertex3(points[1]);
|
||||
GL.Vertex3(points[7]);
|
||||
GL.Vertex3(points[5]);
|
||||
GL.End();
|
||||
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GL_EditorFramework
|
||||
{
|
||||
public partial class SceneListView : UserControl
|
||||
{
|
||||
public SceneListView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaintBackground(e);
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
Rectangle rect = new Rectangle(2, 2, Width - 4, 23);
|
||||
g.FillRectangle(SystemBrushes.ControlLight, rect);
|
||||
g.DrawRectangle(SystemPens.ControlDark, rect);
|
||||
int yoff = (int)(Font.GetHeight(e.Graphics.DpiX)/2f);
|
||||
g.DrawString("Category", Font, new SolidBrush(ForeColor), 4, 2+rect.Height/2-yoff);
|
||||
rect = new Rectangle(2, 32, Width - 4, Height - 34);
|
||||
g.FillRectangle(SystemBrushes.Window, rect);
|
||||
g.DrawRectangle(SystemPens.ControlDarkDark, rect);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -1,187 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GL_EditorFramework;
|
||||
using GL_EditorFramework.EditorDrawables;
|
||||
using GL_EditorFramework.GL_Core;
|
||||
using GL_EditorFramework.Interfaces;
|
||||
using OpenGl_EditorFramework;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace Testing
|
||||
{
|
||||
//This class is supposed to show of some very basic animation stuff you could do with this framework
|
||||
//but it's highly recommended to add members like startTime and isPlaying if you want to make your own animated object class
|
||||
class AnimatedObject : SingleObject
|
||||
{
|
||||
public AnimatedObject(Vector3 pos) : base(pos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static new Vector4 Color = new Vector4(1f, 0f, 0f, 1f);
|
||||
|
||||
public override void Draw(GL_ControlModern control, Pass pass, EditorScene editorScene)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
bool hovered = editorScene.hovered == this;
|
||||
|
||||
Matrix4 mtx = Matrix4.CreateScale(1f, 0.25f, 1f);
|
||||
mtx *= Matrix4.CreateFromAxisAngle(Vector3.UnitY, -(float)Math.PI / 2f);
|
||||
mtx *= Matrix4.CreateTranslation(Position + (Selected ? editorScene.deltaTransform.Translation : new Vector3()));
|
||||
control.UpdateModelMatrix(mtx);
|
||||
|
||||
Color pickingColor = control.nextPickingColor();
|
||||
|
||||
Vector4 lineBoxColor;
|
||||
|
||||
if (hovered && Selected)
|
||||
lineBoxColor = hoverColor;
|
||||
else if (hovered || Selected)
|
||||
lineBoxColor = selectColor;
|
||||
else
|
||||
lineBoxColor = new Vector4(1, 1, 1, 1);
|
||||
|
||||
Renderers.LineBoxRenderer.Draw(control, pass, lineBoxColor, pickingColor);
|
||||
|
||||
control.UpdateModelMatrix(mtx * Matrix4.CreateTranslation(Vector3.UnitX * 3f));
|
||||
|
||||
Renderers.LineBoxRenderer.Draw(control, pass, lineBoxColor, pickingColor);
|
||||
|
||||
control.UpdateModelMatrix(mtx * Matrix4.CreateTranslation(Vector3.UnitX * (3f - Math.Abs(control.RedrawerFrame * 0.0625f % 6f - 3f))));
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, pickingColor);
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlModern control, Pass pass)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
Matrix4 mtx = Matrix4.CreateScale(1f, 0.25f, 1f);
|
||||
mtx *= Matrix4.CreateFromAxisAngle(Vector3.UnitY, -(float)Math.PI / 2f);
|
||||
mtx *= Matrix4.CreateTranslation(Position);
|
||||
control.UpdateModelMatrix(mtx);
|
||||
|
||||
Color pickingColor = control.nextPickingColor();
|
||||
|
||||
Vector4 lineBoxColor = new Vector4(1, 1, 1, 1);
|
||||
|
||||
Renderers.LineBoxRenderer.Draw(control, pass, lineBoxColor, pickingColor);
|
||||
|
||||
control.UpdateModelMatrix(mtx * Matrix4.CreateTranslation(Vector3.UnitX * 3f));
|
||||
|
||||
Renderers.LineBoxRenderer.Draw(control, pass, lineBoxColor, pickingColor);
|
||||
|
||||
control.UpdateModelMatrix(mtx);
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, pickingColor);
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass, EditorScene editorScene)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
bool hovered = editorScene.hovered == this;
|
||||
|
||||
Matrix4 mtx = Matrix4.CreateScale(1f, 0.25f, 1f);
|
||||
mtx *= Matrix4.CreateFromAxisAngle(Vector3.UnitY, (float)Math.PI / 2f);
|
||||
mtx *= Matrix4.CreateTranslation(Position + (Selected ? editorScene.deltaTransform.Translation : new Vector3()));
|
||||
control.UpdateModelMatrix(mtx);
|
||||
|
||||
Color pickingColor = control.nextPickingColor();
|
||||
|
||||
Vector4 lineBoxColor;
|
||||
|
||||
if (hovered && Selected)
|
||||
lineBoxColor = hoverColor;
|
||||
else if (hovered || Selected)
|
||||
lineBoxColor = selectColor;
|
||||
else
|
||||
lineBoxColor = new Vector4(1, 1, 1, 1);
|
||||
|
||||
Renderers.LineBoxRenderer.Draw(control, pass, lineBoxColor, pickingColor);
|
||||
|
||||
control.UpdateModelMatrix(mtx * Matrix4.CreateTranslation(Vector3.UnitX * 3f));
|
||||
|
||||
Renderers.LineBoxRenderer.Draw(control, pass, lineBoxColor, pickingColor);
|
||||
|
||||
control.UpdateModelMatrix(mtx * Matrix4.CreateTranslation(Vector3.UnitX * (3f - Math.Abs(control.RedrawerFrame * 0.0625f % 6f - 3f))));
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, pickingColor);
|
||||
}
|
||||
|
||||
public override void Draw(GL_ControlLegacy control, Pass pass)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
Matrix4 mtx = Matrix4.CreateScale(1f, 0.25f, 1f);
|
||||
mtx *= Matrix4.CreateFromAxisAngle(Vector3.UnitY, -(float)Math.PI / 2f);
|
||||
mtx *= Matrix4.CreateTranslation(Position);
|
||||
control.UpdateModelMatrix(mtx);
|
||||
|
||||
Color pickingColor = control.nextPickingColor();
|
||||
|
||||
Vector4 lineBoxColor = new Vector4(1, 1, 1, 1);
|
||||
|
||||
Renderers.LineBoxRenderer.Draw(control, pass, lineBoxColor, pickingColor);
|
||||
|
||||
control.UpdateModelMatrix(mtx * Matrix4.CreateTranslation(Vector3.UnitX * 3f));
|
||||
|
||||
Renderers.LineBoxRenderer.Draw(control, pass, lineBoxColor, pickingColor);
|
||||
|
||||
control.UpdateModelMatrix(mtx);
|
||||
|
||||
Renderers.ColorBlockRenderer.Draw(control, pass, Color, Color, pickingColor);
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
Renderers.LineBoxRenderer.Initialize();
|
||||
base.Prepare(control);
|
||||
}
|
||||
|
||||
public override uint Select(int index, I3DControl control)
|
||||
{
|
||||
Selected = true;
|
||||
control.AttachPickingRedrawer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override uint SelectDefault(I3DControl control)
|
||||
{
|
||||
Selected = true;
|
||||
control.AttachPickingRedrawer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override uint SelectAll(I3DControl control)
|
||||
{
|
||||
Selected = true;
|
||||
control.AttachPickingRedrawer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override uint Deselect(int index, I3DControl control)
|
||||
{
|
||||
Selected = false;
|
||||
control.DetachPickingRedrawer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override uint DeselectAll(I3DControl control)
|
||||
{
|
||||
Selected = false;
|
||||
control.DetachPickingRedrawer();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
</configuration>
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Testing
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new TestingForm());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
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("Testing")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Testing")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[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("860b49c9-54e3-4e10-830d-6497b845ed11")]
|
||||
|
||||
// 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")]
|
|
@ -1,71 +0,0 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <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 Testing.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("Testing.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
<?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>
|
|
@ -1,30 +0,0 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <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 Testing.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?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>
|
|
@ -1,96 +0,0 @@
|
|||
<?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>{860B49C9-54E3-4E10-830D-6497B845ED11}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Testing</RootNamespace>
|
||||
<AssemblyName>Testing</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</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="OpenTK">
|
||||
<HintPath>..\..\Toolbox\Lib\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK.GLControl">
|
||||
<HintPath>..\..\Toolbox\Lib\OpenTK.GLControl.dll</HintPath>
|
||||
</Reference>
|
||||
<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="AnimatedObject.cs" />
|
||||
<Compile Include="TestingForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TestingForm.Designer.cs">
|
||||
<DependentUpon>TestingForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="TestingForm.resx">
|
||||
<DependentUpon>TestingForm.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>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Gl_EditorFramework\Gl_EditorFramework.csproj">
|
||||
<Project>{d593a72d-554d-40fb-9967-503cb15a744f}</Project>
|
||||
<Name>Gl_EditorFramework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,128 +0,0 @@
|
|||
namespace Testing
|
||||
{
|
||||
partial class TestingForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TestingForm));
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.listBox1 = new System.Windows.Forms.ListBox();
|
||||
this.gL_ControlLegacy1 = new GL_EditorFramework.GL_Core.GL_ControlLegacy();
|
||||
this.gL_ControlModern1 = new GL_EditorFramework.GL_Core.GL_ControlModern();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(12, 208);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 3;
|
||||
this.button1.Text = "Add Object";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// listBox1
|
||||
//
|
||||
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.listBox1.FormattingEnabled = true;
|
||||
this.listBox1.Location = new System.Drawing.Point(13, 238);
|
||||
this.listBox1.Name = "listBox1";
|
||||
this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
|
||||
this.listBox1.Size = new System.Drawing.Size(278, 498);
|
||||
this.listBox1.TabIndex = 4;
|
||||
//
|
||||
// gL_ControlLegacy1
|
||||
//
|
||||
this.gL_ControlLegacy1.ActiveCamera = null;
|
||||
this.gL_ControlLegacy1.BackColor = System.Drawing.Color.Black;
|
||||
this.gL_ControlLegacy1.CameraDistance = -10F;
|
||||
this.gL_ControlLegacy1.CameraTarget = ((OpenTK.Vector3)(resources.GetObject("gL_ControlLegacy1.CameraTarget")));
|
||||
this.gL_ControlLegacy1.CamRotX = 0F;
|
||||
this.gL_ControlLegacy1.CamRotY = 0F;
|
||||
this.gL_ControlLegacy1.DragStartPos = new System.Drawing.Point(0, 0);
|
||||
this.gL_ControlLegacy1.Fov = 0.7853982F;
|
||||
this.gL_ControlLegacy1.Location = new System.Drawing.Point(13, 20);
|
||||
this.gL_ControlLegacy1.MainDrawable = null;
|
||||
this.gL_ControlLegacy1.Name = "gL_ControlLegacy1";
|
||||
this.gL_ControlLegacy1.ShowOrientationCube = false;
|
||||
this.gL_ControlLegacy1.Size = new System.Drawing.Size(278, 182);
|
||||
this.gL_ControlLegacy1.Stereoscopy = true;
|
||||
this.gL_ControlLegacy1.TabIndex = 2;
|
||||
this.gL_ControlLegacy1.VSync = false;
|
||||
this.gL_ControlLegacy1.ZFar = 1000F;
|
||||
this.gL_ControlLegacy1.ZNear = 0.01F;
|
||||
//
|
||||
// gL_ControlModern1
|
||||
//
|
||||
this.gL_ControlModern1.ActiveCamera = null;
|
||||
this.gL_ControlModern1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.gL_ControlModern1.BackColor = System.Drawing.Color.Black;
|
||||
this.gL_ControlModern1.CameraDistance = -10F;
|
||||
this.gL_ControlModern1.CameraTarget = ((OpenTK.Vector3)(resources.GetObject("gL_ControlModern1.CameraTarget")));
|
||||
this.gL_ControlModern1.CamRotX = 0F;
|
||||
this.gL_ControlModern1.CamRotY = 0F;
|
||||
this.gL_ControlModern1.CurrentShader = null;
|
||||
this.gL_ControlModern1.DragStartPos = new System.Drawing.Point(0, 0);
|
||||
this.gL_ControlModern1.Fov = 0.7853982F;
|
||||
this.gL_ControlModern1.GradientBackground = true;
|
||||
this.gL_ControlModern1.Location = new System.Drawing.Point(297, 20);
|
||||
this.gL_ControlModern1.MainDrawable = null;
|
||||
this.gL_ControlModern1.Name = "gL_ControlModern1";
|
||||
this.gL_ControlModern1.ShowOrientationCube = true;
|
||||
this.gL_ControlModern1.Size = new System.Drawing.Size(689, 715);
|
||||
this.gL_ControlModern1.Stereoscopy = false;
|
||||
this.gL_ControlModern1.TabIndex = 1;
|
||||
this.gL_ControlModern1.VSync = false;
|
||||
this.gL_ControlModern1.ZFar = 1000F;
|
||||
this.gL_ControlModern1.ZNear = 0.01F;
|
||||
//
|
||||
// TestingForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(998, 747);
|
||||
this.Controls.Add(this.listBox1);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.gL_ControlLegacy1);
|
||||
this.Controls.Add(this.gL_ControlModern1);
|
||||
this.Name = "TestingForm";
|
||||
this.Text = "Testing";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private GL_EditorFramework.GL_Core.GL_ControlModern gL_ControlModern1;
|
||||
private GL_EditorFramework.GL_Core.GL_ControlLegacy gL_ControlLegacy1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.ListBox listBox1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
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;
|
||||
using GL_EditorFramework.EditorDrawables;
|
||||
using OpenTK;
|
||||
|
||||
namespace Testing
|
||||
{
|
||||
public partial class TestingForm : Form
|
||||
{
|
||||
public TestingForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private EditorScene scene;
|
||||
|
||||
private Random rng = new Random();
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
scene = new EditorScene();
|
||||
|
||||
listBox1.Items.Add("moving platform");
|
||||
scene.objects.Add(new AnimatedObject(new Vector3(0, -4, 0)));
|
||||
for (int i = 0; i<5; i++)
|
||||
{
|
||||
listBox1.Items.Add("block");
|
||||
scene.objects.Add(new SingleObject(new Vector3(i,0,0)));
|
||||
}
|
||||
|
||||
gL_ControlModern1.MainDrawable = scene;
|
||||
gL_ControlModern1.ActiveCamera = new GL_EditorFramework.StandardCameras.InspectCamera(1f);
|
||||
|
||||
gL_ControlLegacy1.MainDrawable = new SingleObject(new Vector3());
|
||||
|
||||
scene.SelectionChanged += Scene_SelectionChanged;
|
||||
listBox1.SelectedIndexChanged += ListBox1_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
private void Scene_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
listBox1.SelectedIndexChanged -= ListBox1_SelectedIndexChanged;
|
||||
listBox1.SelectedIndices.Clear();
|
||||
int i = 0;
|
||||
foreach(EditableObject o in scene.objects)
|
||||
{
|
||||
if(o.IsSelected())
|
||||
listBox1.SelectedIndices.Add(i);
|
||||
i++;
|
||||
}
|
||||
|
||||
listBox1.SelectedIndexChanged += ListBox1_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
List<EditableObject> newSelection = new List<EditableObject>();
|
||||
foreach(int i in listBox1.SelectedIndices)
|
||||
{
|
||||
newSelection.Add(scene.objects[i]);
|
||||
}
|
||||
|
||||
scene.SelectedObjects = newSelection;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
Color rand = Color.FromArgb(rng.Next());
|
||||
listBox1.Items.Add("block"); //make sure to add the entry before you add an object because the SelectionChanged event will be fired
|
||||
scene.Add(new SingleObject(new Vector3()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="gL_ControlLegacy1.CameraTarget" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAElPcGVuVEssIFZlcnNpb249My4wLjEuMCwgQ3VsdHVyZT1uZXV0
|
||||
cmFsLCBQdWJsaWNLZXlUb2tlbj1iYWQxOTlmZTg0ZWIzZGY0BQEAAAAOT3BlblRLLlZlY3RvcjMDAAAA
|
||||
AVgBWQFaAAAACwsLAgAAAAAAAAAAAAAAAAAAAAs=
|
||||
</value>
|
||||
</data>
|
||||
<data name="gL_ControlModern1.CameraTarget" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAElPcGVuVEssIFZlcnNpb249My4wLjEuMCwgQ3VsdHVyZT1uZXV0
|
||||
cmFsLCBQdWJsaWNLZXlUb2tlbj1iYWQxOTlmZTg0ZWIzZGY0BQEAAAAOT3BlblRLLlZlY3RvcjMDAAAA
|
||||
AVgBWQFaAAAACwsLAgAAAAAAAAAAAAAAAAAAAAs=
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
|
@ -98,6 +98,9 @@
|
|||
<HintPath>..\Toolbox\Lib\ObjectListView.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenGl_EditorFramework">
|
||||
<HintPath>..\Toolbox\OpenGl_EditorFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK">
|
||||
<HintPath>..\Toolbox\Lib\OpenTK.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
|
@ -1015,11 +1018,6 @@
|
|||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GL_EditorFramework-master\Gl_EditorFramework\Gl_EditorFramework.csproj">
|
||||
<Project>{d593a72d-554d-40fb-9967-503cb15a744f}</Project>
|
||||
<Name>Gl_EditorFramework</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Switch_Toolbox_Library\Switch_Toolbox_Library.csproj">
|
||||
<Project>{96820047-2a39-4e5a-bfa4-e84fff5c66cf}</Project>
|
||||
<Name>Switch_Toolbox_Library</Name>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
eda986637e7a0ae6cb9b445f44e721c49da4aade
|
||||
727ce16767060a276a4b91b2ad2a99e5b2d6708a
|
||||
|
|
Binary file not shown.
|
@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Toolbox", "Toolbox\Toolbox.csproj", "{5E55CA2B-F181-4681-AAFA-A20FEBCF7387}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gl_EditorFramework", "GL_EditorFramework-master\Gl_EditorFramework\Gl_EditorFramework.csproj", "{D593A72D-554D-40FB-9967-503CB15A744F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testing", "GL_EditorFramework-master\Testing\Testing.csproj", "{860B49C9-54E3-4E10-830D-6497B845ED11}"
|
||||
EndProject
|
||||
Global
|
||||
|
@ -55,14 +53,6 @@ Global
|
|||
{5E55CA2B-F181-4681-AAFA-A20FEBCF7387}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5E55CA2B-F181-4681-AAFA-A20FEBCF7387}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{5E55CA2B-F181-4681-AAFA-A20FEBCF7387}.Release|x64.Build.0 = Release|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{D593A72D-554D-40FB-9967-503CB15A744F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{860B49C9-54E3-4E10-830D-6497B845ED11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{860B49C9-54E3-4E10-830D-6497B845ED11}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{860B49C9-54E3-4E10-830D-6497B845ED11}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
|
|
|
@ -94,6 +94,10 @@
|
|||
<HintPath>..\Toolbox\Lib\Octokit.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenGl_EditorFramework, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Toolbox\OpenGl_EditorFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK">
|
||||
<HintPath>..\Toolbox\Lib\OpenTK.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
|
@ -883,13 +887,6 @@
|
|||
<ItemGroup>
|
||||
<None Include="Resources\DataTyypes\IconVec4.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GL_EditorFramework-master\Gl_EditorFramework\Gl_EditorFramework.csproj">
|
||||
<Project>{d593a72d-554d-40fb-9967-503cb15a744f}</Project>
|
||||
<Name>Gl_EditorFramework</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\Cubemaps\diffuseSDR.dds" />
|
||||
</ItemGroup>
|
||||
|
|
BIN
Toolbox/OpenGl_EditorFramework.dll
Normal file
BIN
Toolbox/OpenGl_EditorFramework.dll
Normal file
Binary file not shown.
BIN
Toolbox/OpenGl_EditorFramework.pdb
Normal file
BIN
Toolbox/OpenGl_EditorFramework.pdb
Normal file
Binary file not shown.
|
@ -202,10 +202,6 @@
|
|||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GL_EditorFramework-master\Gl_EditorFramework\Gl_EditorFramework.csproj">
|
||||
<Project>{d593a72d-554d-40fb-9967-503cb15a744f}</Project>
|
||||
<Name>Gl_EditorFramework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Switch_Toolbox_Library\Switch_Toolbox_Library.csproj">
|
||||
<Project>{96820047-2a39-4e5a-bfa4-e84fff5c66cf}</Project>
|
||||
<Name>Switch_Toolbox_Library</Name>
|
||||
|
@ -378,6 +374,12 @@
|
|||
<Content Include="LZ4.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="OpenGl_EditorFramework.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="OpenGl_EditorFramework.pdb">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Projects\Recent\DUMMY.txt" />
|
||||
<Content Include="Lib\x64\DirectXTexNetImpl.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
|
Loading…
Reference in a new issue