scene 3D, initial implementation

This commit is contained in:
Vadim Lopatin 2015-03-23 17:30:08 +03:00
parent af611fe4b4
commit 9ec5b0b1b9
8 changed files with 168 additions and 7 deletions

View File

@ -53,8 +53,8 @@
<cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>3rdparty ../DerelictGL3/source ../DerelictUtil/source ../DerelictFT/source ../de_image/source/interfaces ../de_image/source/png $(SolutionDir)/../dlib</imppath>
<fileImppath>$(SolutionDir)/views $(SolutionDir)/views/res $(SolutionDir)/views/res/i18n $(SolutionDir)/views/res/mdpi</fileImppath>
<imppath>3rdparty ../DerelictGL3/source ../DerelictUtil/source ../DerelictFT/source ../de_image/source/interfaces ../de_image/source/png $(SolutionDir)/../dlib $(SolutionDir)/../gl3n</imppath>
<fileImppath>$(SolutionDir)/views $(SolutionDir)/views/res $(SolutionDir)/views/res/i18n $(SolutionDir)/views/res/mdpi $(SolutionDir)/views/res/hdpi</fileImppath>
<outdir>$(ConfigurationName)</outdir>
<objdir>$(OutDir)</objdir>
<objname />
@ -72,7 +72,7 @@
<debuglevel>0</debuglevel>
<debugids>DebugFocus</debugids>
<versionlevel>0</versionlevel>
<versionids>EmbedStandardResources Unicode USE_FREETYPE</versionids>
<versionids>EmbedStandardResources Unicode USE_FREETYPE USE_OPENGL USE_SDL</versionids>
<dump_source>0</dump_source>
<mapverbosity>0</mapverbosity>
<createImplib>1</createImplib>
@ -290,6 +290,15 @@
<File path="..\dlib\dlib\math\vector.d" />
<File path="..\dlib\dlib\image\io\zstream.d" />
</Folder>
<Folder name="gl3n">
<File path="..\gl3n\gl3n\aabb.d" />
<File path="..\gl3n\gl3n\frustum.d" />
<File path="..\gl3n\gl3n\interpolate.d" />
<File path="..\gl3n\gl3n\linalg.d" />
<File path="..\gl3n\gl3n\math.d" />
<File path="..\gl3n\gl3n\plane.d" />
<File path="..\gl3n\gl3n\util.d" />
</Folder>
<Folder name="win32">
<File path="3rdparty\win32\basetsd.d" />
<File path="3rdparty\win32\basetyps.d" />
@ -368,6 +377,11 @@
<File path="src\dlangui\dialogs\settingsdialog.d" />
</Folder>
<Folder name="graphics">
<Folder name="scene">
<File path="src\dlangui\graphics\scene\node.d" />
<File path="src\dlangui\graphics\scene\scene3d.d" />
<File path="src\dlangui\graphics\scene\transform.d" />
</Folder>
<File path="src\dlangui\graphics\colors.d" />
<File path="src\dlangui\graphics\drawbuf.d" />
<File path="src\dlangui\graphics\fonts.d" />

View File

@ -30,6 +30,7 @@
"views",
"views/res",
"views/res/mdpi",
"views/res/hdpi",
"views/res/i18n"
],
@ -37,7 +38,8 @@
"derelict-gl3": ">=1.0.12",
"dlib": "~master",
"derelict-ft": ">=1.0.0",
"derelict-sdl2": ">=1.9.1"
"derelict-sdl2": ">=1.9.1",
"gl3n": "==1.0.0"
},
"-ddoxFilterArgs": ["--unittest-examples", "--min-protection=Protected", "--ex", "win32.", "--ex", "src.dlangui"],

View File

@ -8,10 +8,12 @@
<multiobj>0</multiobj>
<singleFileCompilation>0</singleFileCompilation>
<oneobj>0</oneobj>
<mscoff>0</mscoff>
<trace>0</trace>
<quiet>0</quiet>
<verbose>0</verbose>
<vtls>0</vtls>
<vgc>0</vgc>
<symdebug>1</symdebug>
<optimize>0</optimize>
<cpu>0</cpu>
@ -44,8 +46,12 @@
<nofloat>0</nofloat>
<Dversion>2</Dversion>
<ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
<allinst>0</allinst>
<stackStomp>0</stackStomp>
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib</imppath>
<fileImppath>views views/res views/res/i18n views/res/mdpi</fileImppath>
@ -66,7 +72,7 @@
<debuglevel>0</debuglevel>
<debugids />
<versionlevel>0</versionlevel>
<versionids>Unicode USE_FREETYPE</versionids>
<versionids>Unicode USE_FREETYPE USE_SDL USE_OPENGL</versionids>
<dump_source>0</dump_source>
<mapverbosity>3</mapverbosity>
<createImplib>0</createImplib>
@ -89,6 +95,7 @@
<resfile />
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
<useStdLibPath>1</useStdLibPath>
<cRuntime>2</cRuntime>
<additionalOptions>-profile</additionalOptions>
<preBuildCommand />
<postBuildCommand />
@ -102,10 +109,12 @@
<multiobj>0</multiobj>
<singleFileCompilation>0</singleFileCompilation>
<oneobj>0</oneobj>
<mscoff>0</mscoff>
<trace>0</trace>
<quiet>0</quiet>
<verbose>0</verbose>
<vtls>0</vtls>
<vgc>0</vgc>
<symdebug>0</symdebug>
<optimize>1</optimize>
<cpu>0</cpu>
@ -138,8 +147,12 @@
<nofloat>0</nofloat>
<Dversion>2</Dversion>
<ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
<allinst>0</allinst>
<stackStomp>0</stackStomp>
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib</imppath>
<fileImppath>views views/res views/res/i18n views/res/mdpi</fileImppath>
@ -183,6 +196,7 @@
<resfile />
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
<useStdLibPath>1</useStdLibPath>
<cRuntime>1</cRuntime>
<additionalOptions />
<preBuildCommand />
<postBuildCommand />

View File

@ -8,10 +8,12 @@
<multiobj>0</multiobj>
<singleFileCompilation>0</singleFileCompilation>
<oneobj>0</oneobj>
<mscoff>0</mscoff>
<trace>0</trace>
<quiet>0</quiet>
<verbose>0</verbose>
<vtls>0</vtls>
<vgc>0</vgc>
<symdebug>1</symdebug>
<optimize>0</optimize>
<cpu>0</cpu>
@ -44,8 +46,12 @@
<nofloat>0</nofloat>
<Dversion>2</Dversion>
<ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
<allinst>0</allinst>
<stackStomp>0</stackStomp>
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib</imppath>
<fileImppath>views views/res views/mdpi views/i18n</fileImppath>
@ -66,7 +72,7 @@
<debuglevel>0</debuglevel>
<debugids />
<versionlevel>0</versionlevel>
<versionids>Unicode</versionids>
<versionids>Unicode USE_FREETYPE USE_OPENGL USE_SDL</versionids>
<dump_source>0</dump_source>
<mapverbosity>3</mapverbosity>
<createImplib>0</createImplib>
@ -89,6 +95,7 @@
<resfile />
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
<useStdLibPath>1</useStdLibPath>
<cRuntime>2</cRuntime>
<additionalOptions>-profile</additionalOptions>
<preBuildCommand />
<postBuildCommand />
@ -102,10 +109,12 @@
<multiobj>0</multiobj>
<singleFileCompilation>0</singleFileCompilation>
<oneobj>0</oneobj>
<mscoff>0</mscoff>
<trace>0</trace>
<quiet>0</quiet>
<verbose>0</verbose>
<vtls>0</vtls>
<vgc>0</vgc>
<symdebug>0</symdebug>
<optimize>1</optimize>
<cpu>0</cpu>
@ -138,8 +147,12 @@
<nofloat>0</nofloat>
<Dversion>2</Dversion>
<ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
<allinst>0</allinst>
<stackStomp>0</stackStomp>
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib</imppath>
<fileImppath>views views/res views/mdpi views/i18n</fileImppath>
@ -183,6 +196,7 @@
<resfile />
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
<useStdLibPath>1</useStdLibPath>
<cRuntime>1</cRuntime>
<additionalOptions />
<preBuildCommand />
<postBuildCommand />

View File

@ -0,0 +1,10 @@
module dlangui.graphics.scene.node;
import gl3n.linalg;
import gl3n.math;
import dlangui.graphics.scene.transform;
/// 3D scene node
class Node3d : Transform {
}

View File

@ -0,0 +1,4 @@
module dlangui.graphics.scene.scene3d;
class Scene3d {
}

View File

@ -0,0 +1,103 @@
module dlangui.graphics.scene.transform;
import gl3n.linalg;
import gl3n.math;
/// 3d transform: scale + translation + rotation
class Transform {
private bool _dirtyTransform = true;
private vec3 _scale = vec3(1.0f, 1.0f, 1.0f);
private vec3 _translation = vec3(0.0f, 0.0f, 0.0f);
private mat4 _rotation = mat4.identity;
private mat4 _matrix;
/// get scale vector
public @property ref const(vec3) scaling() const { return _scale; }
/// get scale X
public @property float scalingX() const { return _scale.x; }
/// get scale Y
public @property float scalingY() const { return _scale.y; }
/// get scale Z
public @property float scalingZ() const { return _scale.z; }
/// set scale vector
public @property void scaling(const ref vec3 value) { _scale = value; _dirtyTransform = true; }
/// set scale vector x, y, z to the same value
public @property void scaling(float value) { _scale.x = _scale.y = _scale.z = value; _dirtyTransform = true; }
/// set scale X
public @property void scalingX(float value) { _scale.x = value; _dirtyTransform = true; }
/// set scale Y
public @property void scalingY(float value) { _scale.y = value; _dirtyTransform = true; }
/// set scale Z
public @property void scalingZ(float value) { _scale.z = value; _dirtyTransform = true; }
/// get translation vector
public @property ref const(vec3) translation() const { return _translation; }
/// get translation X
public @property float translationX() const { return _translation.x; }
/// get translation Y
public @property float translationY() const { return _translation.y; }
/// get translation Z
public @property float translationZ() const { return _translation.z; }
/// set translation vector
public @property void translation(const ref vec3 value) { _translation = value; _dirtyTransform = true; }
/// set translation vector x, y, z to the same value
public @property void translation(float value) { _translation.x = _translation.y = _translation.z = value; _dirtyTransform = true; }
/// set translation x
public @property void translationX(float value) { _translation.x = value; _dirtyTransform = true; }
/// set translation y
public @property void translationY(float value) { _translation.y = value; _dirtyTransform = true; }
/// set translation z
public @property void translationZ(float value) { _translation.z = value; _dirtyTransform = true; }
/// translate by vector
public void translate(vec3 value) { _translation += value; _dirtyTransform = true; }
/// translate X
public void translateX(float value) { _translation.x += value; _dirtyTransform = true; }
/// translate Y
public void translateY(float value) { _translation.y += value; _dirtyTransform = true; }
/// translate Z
public void translateZ(float value) { _translation.z += value; _dirtyTransform = true; }
/// scale by vector
public void scale(vec3 value) { _scale.x *= value.x; _scale.y *= value.y; _scale.z *= value.z; _dirtyTransform = true; }
/// scale all axis by the same values
public void scale(float value) { _scale *= value; _dirtyTransform = true; }
/// scale X
public void scaleX(float value) { _scale.x *= value; _dirtyTransform = true; }
/// scale Y
public void scaleY(float value) { _scale.y *= value; _dirtyTransform = true; }
/// scale Z
public void scaleZ(float value) { _scale.z *= value; _dirtyTransform = true; }
/// rotate around X axis
public void rotateX(float angle) { _rotation.rotatex(angle); _dirtyTransform = true; }
/// rotate around Y axis
public void rotateY(float angle) { _rotation.rotatey(angle); _dirtyTransform = true; }
/// rotate around Z axis
public void rotateZ(float angle) { _rotation.rotatez(angle); _dirtyTransform = true; }
/// rotate around custom axis
public void rotate(float angle, const ref vec3 axis) { _rotation.rotate(angle, axis); _dirtyTransform = true; }
/// set transform to identity transform
public void setIdentity() {
_dirtyTransform = true;
_scale = vec3(1.0f, 1.0f, 1.0f);
_translation = vec3(0.0f, 0.0f, 0.0f);
_rotation = mat4.identity;
}
/// get transform matrix, recalculates if needed
public @property ref const(mat4) matrix() {
if (_dirtyTransform) {
_matrix = mat4.translation(_translation.x, _translation.y, _translation.z);
_matrix = _matrix * _rotation;
_matrix.scale(_scale.x, _scale.y, _scale.z);
_dirtyTransform = false;
}
return _matrix;
}
}

View File

@ -1192,7 +1192,7 @@ version (Windows) {
SCREEN_DPI = GetDeviceCaps(dc, LOGPIXELSY);
DeleteObject(dc);
//SCREEN_DPI = 96 * 3 / 2;
SCREEN_DPI = 96 * 3 / 2;
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
Log.i("calling Runtime.terminate()");