mirror of https://github.com/buggins/dlangui.git
3d scene, continue
This commit is contained in:
parent
762ac89fe1
commit
576d8dbb3b
|
@ -2,6 +2,32 @@ module dlangui.graphics.scene.camera;
|
||||||
|
|
||||||
import dlangui.graphics.scene.node;
|
import dlangui.graphics.scene.node;
|
||||||
|
|
||||||
|
import gl3n.linalg;
|
||||||
|
import gl3n.math;
|
||||||
|
|
||||||
/// Camera
|
/// Camera
|
||||||
class Camera : Node3d {
|
class Camera : Node3d {
|
||||||
|
|
||||||
|
protected mat4 _projectionMatrix;
|
||||||
|
|
||||||
|
/// get projection matrix
|
||||||
|
@property ref mat4 projectionMatrix() {
|
||||||
|
return _projectionMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// set custom projection matrix
|
||||||
|
@property void projectionMatrix(mat4 v) {
|
||||||
|
_projectionMatrix = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// set orthographic projection
|
||||||
|
void setOrtho(float left, float right, float bottom, float top, float near, float far) {
|
||||||
|
_projectionMatrix = mat4.orthographic(left, right, bottom, top, near, far);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// set perspective projection
|
||||||
|
void setPerspective(float width, float height, float fov, float near, float far) {
|
||||||
|
_projectionMatrix = mat4.perspective(width, height, fov, near, far);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import gl3n.linalg;
|
||||||
import gl3n.math;
|
import gl3n.math;
|
||||||
|
|
||||||
import dlangui.graphics.scene.transform;
|
import dlangui.graphics.scene.transform;
|
||||||
|
import dlangui.core.collections;
|
||||||
|
|
||||||
/// 3D scene node
|
/// 3D scene node
|
||||||
class Node3d : Transform {
|
class Node3d : Transform {
|
||||||
|
@ -12,6 +13,25 @@ class Node3d : Transform {
|
||||||
|
|
||||||
protected mat4 _worldMatrix;
|
protected mat4 _worldMatrix;
|
||||||
|
|
||||||
|
protected ObjectList!Node3d _children;
|
||||||
|
|
||||||
|
/// returns child node count
|
||||||
|
@property int childCount() {
|
||||||
|
return _children.count;
|
||||||
|
}
|
||||||
|
/// returns child node by index
|
||||||
|
Node3d child(int index) {
|
||||||
|
return _children[index];
|
||||||
|
}
|
||||||
|
/// add child node
|
||||||
|
void addChild(Node3d node) {
|
||||||
|
_children.add(node);
|
||||||
|
node.parent = this;
|
||||||
|
}
|
||||||
|
/// removes and destroys child node by index
|
||||||
|
void removeChild(int index) {
|
||||||
|
destroy(_children.remove(index));
|
||||||
|
}
|
||||||
|
|
||||||
/// parent node
|
/// parent node
|
||||||
@property Node3d parent() {
|
@property Node3d parent() {
|
||||||
|
|
|
@ -12,5 +12,6 @@ class Scene3d : Node3d {
|
||||||
@property vec3 ambientColor() { return _ambientColor; }
|
@property vec3 ambientColor() { return _ambientColor; }
|
||||||
@property void ambientColor(const ref vec3 v) { _ambientColor = v; }
|
@property void ambientColor(const ref vec3 v) { _ambientColor = v; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue