diff --git a/examples/d3d/src/d3d.d b/examples/d3d/src/d3d.d index b350fd47..75b07b00 100644 --- a/examples/d3d/src/d3d.d +++ b/examples/d3d/src/d3d.d @@ -70,23 +70,14 @@ class UiWidget : VerticalLayout, CellVisitor { // arrange controls as form - table with two columns TableLayout { colCount: 2 + TextWidget { text: "Translation X" } + ScrollBar { id: sbTranslationX; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 300 } + TextWidget { text: "Translation Y" } + ScrollBar { id: sbTranslationY; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 300 } + TextWidget { text: "Translation Z" } + ScrollBar { id: sbTranslationZ; orientation: horizontal; minValue: -100; maxValue: 100; position: 0; minWidth: 300 } TextWidget { text: "param 1" } EditLine { id: edit1; text: "some text" } - TextWidget { text: "param 2" } - EditLine { id: edit2; text: "some text for param2" } - TextWidget { text: "some radio buttons" } - // arrange some radio buttons vertically - VerticalLayout { - RadioButton { id: rb1; text: "Item 1" } - RadioButton { id: rb2; text: "Item 2" } - RadioButton { id: rb3; text: "Item 3" } - } - TextWidget { text: "and checkboxes" } - // arrange some checkboxes horizontally - HorizontalLayout { - CheckBox { id: cb1; text: "checkbox 1" } - CheckBox { id: cb2; text: "checkbox 2" } - } } VSpacer { layoutWeight: 30 } HorizontalLayout { @@ -101,6 +92,15 @@ class UiWidget : VerticalLayout, CellVisitor { childById("glView").backgroundDrawable = DrawableRef(new OpenGLDrawable(&doDraw)); + mat4 m; + m.translate(1, 2, -1); + Log.d("M*v=", m * vec3(0, 0, 0)); + Log.d("M*v=", m * vec3(10, 10, 10)); + m.translate(0, 0, -2); + Log.d("M*v=", m * vec3(0, 0, 0)); + Log.d("M*v=", m * vec3(10, 10, 10)); + + _scene = new Scene3d(); _cam = new Camera(); @@ -109,8 +109,8 @@ class UiWidget : VerticalLayout, CellVisitor { _scene.activeCamera = _cam; int x0 = 0; - int y0 = 11; - int z0 = 0; + int y0 = 0; + int z0 = 2; _mesh = Mesh.createCubeMesh(vec3(x0+ 0, y0 + 0, z0 + 0), 0.3f); for (int i = 0; i < 10; i++) { @@ -127,12 +127,17 @@ class UiWidget : VerticalLayout, CellVisitor { _minerMesh = new Mesh(VertexFormat(VertexElementType.POSITION, VertexElementType.NORMAL, VertexElementType.COLOR, VertexElementType.TEXCOORD0)); _world = new World(); - for (int x = -1000; x < 1000; x++) - for (int z = -1000; z < 1000; z++) - _world.setCell(x, 10, z, 1); + for (int x = -100; x < 100; x++) + for (int z = -100; z < 100; z++) + _world.setCell(x, 0, z, 1); _world.setCell(0, 11, 10, 2); _world.setCell(5, 11, 15, 2); - _world.camPosition = Position(Vector3d(0, 13, 0), Vector3d(0, 0, 1)); + Random rnd; + rnd.setSeed(12345); + for(int i = 0; i < 1000; i++) + _world.setCell(rnd.next(6)-32, rnd.next(4), rnd.next(6)-32, 3); + + _world.camPosition = Position(Vector3d(0, 3, 0), Vector3d(0, 0, 1)); updateMinerMesh(); //CellVisitor visitor = new TestVisitor(); //Log.d("Testing cell visitor"); @@ -196,19 +201,20 @@ class UiWidget : VerticalLayout, CellVisitor { } _cam.setPerspective(rc.width, rc.height, 45.0f, 0.1f, 100.0f); _cam.setIdentity(); - //_cam.translate(vec3(0, 14, -1.1)); // - angle/1000 - _cam.translate(vec3(0, 14, - angle/1000)); // - _cam.rotateZ(30.0f + angle * 0.3456778); + _cam.translate(vec3(-1, -1.5, -1)); // - angle/1000 + //_cam.translate(vec3(0, 0, -1.1)); // - angle/1000 + //_cam.translate(vec3(0, 3, - angle/1000)); // + //_cam.rotateZ(30.0f + angle * 0.3456778); mat4 projectionViewMatrix = _cam.projectionViewMatrix; // ======== Model Matrix ================== mat4 modelMatrix; //modelMatrix.scale(0.1f); - modelMatrix.rotatez(30.0f + angle * 0.3456778); + //modelMatrix.rotatez(30.0f + angle * 0.3456778); //modelMatrix.rotatey(25); //modelMatrix.rotatex(15); modelMatrix.rotatey(angle); - modelMatrix.rotatex(angle * 1.98765f); + //modelMatrix.rotatex(angle * 1.98765f); mat4 projectionViewModelMatrix = projectionViewMatrix * modelMatrix; diff --git a/examples/d3d/src/dminer/core/blocks.d b/examples/d3d/src/dminer/core/blocks.d index c8a3270f..cca18ec4 100644 --- a/examples/d3d/src/dminer/core/blocks.d +++ b/examples/d3d/src/dminer/core/blocks.d @@ -162,10 +162,10 @@ static void fillFaceMesh(float * data, const float * src, float x0, float y0, fl case 2: // z v += z0; break; - case 9: // tx.u + case 10: // tx.u v = ((tileX + v * BLOCK_SPRITE_SIZE)) / cast(float)BLOCK_TEXTURE_DX; break; - case 10: // tx.v + case 11: // tx.v v = (BLOCK_TEXTURE_DY - (tileY + v * BLOCK_SPRITE_SIZE)) / cast(float)BLOCK_TEXTURE_DY; break; } diff --git a/src/dlangui/core/math3d.d b/src/dlangui/core/math3d.d index 64041e39..66143e4a 100644 --- a/src/dlangui/core/math3d.d +++ b/src/dlangui/core/math3d.d @@ -1,6 +1,7 @@ module dlangui.core.math3d; import std.math; +import std.string : format; /// 2 dimensional vector struct vec2 { @@ -530,6 +531,9 @@ struct vec3 { return vec3(xx / ww, yy / ww, zz / ww); } + @property string toString() { + return "(%f,%f,%f)".format(x, y, z); + } } /// 4 component vector @@ -859,6 +863,9 @@ struct vec4 { return vec4(xx, yy, zz, ww); } + @property string toString() { + return "(%f,%f,%f,%f)".format(x, y, z, w); + } } bool fuzzyNull(float v) { @@ -937,14 +944,17 @@ struct mat4 { m[1*4 + 0] = 0.0f; m[2*4 + 0] = 0.0f; m[3*4 + 0] = 0.0f; + m[0*4 + 1] = 0.0f; m[1*4 + 1] = f; m[2*4 + 1] = 0.0f; m[3*4 + 1] = 0.0f; + m[0*4 + 2] = 0.0f; m[1*4 + 2] = 0.0f; m[2*4 + 2] = (nearPlane + farPlane) * d; m[3*4 + 2] = 2.0f * nearPlane * farPlane * d; + m[0*4 + 3] = 0.0f; m[1*4 + 3] = 0.0f; m[2*4 + 3] = -1.0f; diff --git a/src/dlangui/dml/parser.d b/src/dlangui/dml/parser.d index ec8dd3f3..1ff1e46a 100644 --- a/src/dlangui/dml/parser.d +++ b/src/dlangui/dml/parser.d @@ -691,6 +691,10 @@ class MLParser { setIntProperty(propName, Align.Center); else if (value.equal("topleft") || value.equal("TopLeft")) setIntProperty(propName, Align.TopLeft); + else if (propName.equal("orientation") && (value.equal("vertical") || value.equal("Vertical"))) + setIntProperty(propName, Orientation.Vertical); + else if (propName.equal("orientation") && (value.equal("horizontal") || value.equal("Horizontal"))) + setIntProperty(propName, Orientation.Horizontal); else if (!_currentWidget.setStringProperty(propName, value)) error("unknown ident property " ~ propName); } diff --git a/src/dlangui/graphics/glsupport.d b/src/dlangui/graphics/glsupport.d index 0cc6782f..2879fe11 100644 --- a/src/dlangui/graphics/glsupport.d +++ b/src/dlangui/graphics/glsupport.d @@ -930,6 +930,7 @@ final class GLSupport { void clearDepthBuffer() { glClear(GL_DEPTH_BUFFER_BIT); + //glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } /// projection matrix diff --git a/src/dlangui/widgets/controls.d b/src/dlangui/widgets/controls.d index c20144e2..eb796e5f 100644 --- a/src/dlangui/widgets/controls.d +++ b/src/dlangui/widgets/controls.d @@ -621,8 +621,17 @@ class AbstractSlider : WidgetGroup { } /// set int property value, for ML loaders - mixin(generatePropertySettersMethodOverride("setIntProperty", "int", - "minValue", "maxValue", "pageSize", "position")); + //mixin(generatePropertySettersMethodOverride("setIntProperty", "int", + // "minValue", "maxValue", "pageSize", "position")); + /// set int property value, for ML loaders + override bool setIntProperty(string name, int value) { + if (name.equal("orientation")) { // use same value for all sides + orientation = cast(Orientation)value; + return true; + } + mixin(generatePropertySetters("minValue", "maxValue", "pageSize", "position")); + return super.setIntProperty(name, value); + } /// set new range (min and max values for slider) AbstractSlider setRange(int min, int max) {