Archived
Added a test OnKeyPressed callback to window, made Viewport class, tweaks
This commit is contained in:
@@ -17,6 +17,6 @@ namespace Worldbuilder.Core
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,20 +2,6 @@ namespace Worldbuilder.Core
|
|||||||
{
|
{
|
||||||
public class Mesh : Object
|
public class Mesh : Object
|
||||||
{
|
{
|
||||||
public struct Point
|
|
||||||
{
|
|
||||||
public Vector3 v;
|
|
||||||
public Vector2 uv;
|
|
||||||
public Vector3 n;
|
|
||||||
|
|
||||||
public Point (Vector3 v = Vector3(), Vector2 uv = Vector2(), Vector3 n = Vector3())
|
|
||||||
{
|
|
||||||
this.v = v;
|
|
||||||
this.uv = uv;
|
|
||||||
this.n = n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct Face
|
public struct Face
|
||||||
{
|
{
|
||||||
public Point p[3];
|
public Point p[3];
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ namespace Worldbuilder.Core
|
|||||||
float z = data.parse_float ();
|
float z = data.parse_float ();
|
||||||
normals += Vector3 (x, y, z).normalized ();
|
normals += Vector3 (x, y, z).normalized ();
|
||||||
} else if (data.skip_symbol ("f")) { // face
|
} else if (data.skip_symbol ("f")) { // face
|
||||||
Mesh.Point points[3];
|
Point points[3];
|
||||||
int npoints = 0;
|
int npoints = 0;
|
||||||
|
|
||||||
while (!data.at_end_of_line) {
|
while (!data.at_end_of_line) {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
namespace Worldbuilder.Core
|
||||||
|
{
|
||||||
|
public struct Point
|
||||||
|
{
|
||||||
|
public Vector3 v;
|
||||||
|
public Vector2 uv;
|
||||||
|
public Vector3 n;
|
||||||
|
|
||||||
|
public Point (Vector3 v = Vector3(), Vector2 uv = Vector2(), Vector3 n = Vector3())
|
||||||
|
{
|
||||||
|
this.v = v;
|
||||||
|
this.uv = uv;
|
||||||
|
this.n = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-1
@@ -2,10 +2,12 @@ worldbuilder_sources = [
|
|||||||
'main.vala',
|
'main.vala',
|
||||||
'application.vala',
|
'application.vala',
|
||||||
'window.vala',
|
'window.vala',
|
||||||
|
'viewport.vala',
|
||||||
|
|
||||||
|
'core/point.vala',
|
||||||
|
'core/vector2.vala',
|
||||||
'core/vector3.vala',
|
'core/vector3.vala',
|
||||||
'core/matrix4x4.vala',
|
'core/matrix4x4.vala',
|
||||||
'core/vector2.vala',
|
|
||||||
'core/camera.vala',
|
'core/camera.vala',
|
||||||
'core/mesh.vala',
|
'core/mesh.vala',
|
||||||
'core/texture2d.vala',
|
'core/texture2d.vala',
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<template class="WorldbuilderViewport" parent="GtkGLArea">
|
||||||
|
<property name="hexpand">true</property>
|
||||||
|
<property name="vexpand">true</property>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using Gtk;
|
||||||
|
|
||||||
|
namespace Worldbuilder
|
||||||
|
{
|
||||||
|
[GtkTemplate(ui = "/com/brodybrooks/WorldBuilder/viewport.ui")]
|
||||||
|
public class Viewport : Gtk.GLArea
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-4
@@ -10,6 +10,12 @@
|
|||||||
<property name="default-width">1280</property>
|
<property name="default-width">1280</property>
|
||||||
<property name="default-height">720</property>
|
<property name="default-height">720</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkEventControllerKey">
|
||||||
|
<signal name="key-pressed" handler="OnKeyPressed"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="AdwOverlaySplitView" id="split_view">
|
<object class="AdwOverlaySplitView" id="split_view">
|
||||||
<property name="sidebar-width-fraction">0.25</property>
|
<property name="sidebar-width-fraction">0.25</property>
|
||||||
@@ -69,10 +75,7 @@
|
|||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGLArea" id="draw_area">
|
<object class="WorldbuilderViewport" id="viewport"/>
|
||||||
<property name="hexpand">true</property>
|
|
||||||
<property name="vexpand">true</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
+13
-4
@@ -22,22 +22,31 @@ namespace Worldbuilder {
|
|||||||
[GtkTemplate(ui = "/com/brodybrooks/WorldBuilder/window.ui")]
|
[GtkTemplate(ui = "/com/brodybrooks/WorldBuilder/window.ui")]
|
||||||
public class Window : Adw.ApplicationWindow {
|
public class Window : Adw.ApplicationWindow {
|
||||||
[GtkChild]
|
[GtkChild]
|
||||||
private unowned Gtk.GLArea draw_area;
|
private unowned Viewport viewport;
|
||||||
|
|
||||||
private SceneRenderer renderer;
|
private SceneRenderer renderer;
|
||||||
|
|
||||||
public Window(Gtk.Application app) {
|
public Window(Gtk.Application app) {
|
||||||
Object(application: app);
|
Object(application: app);
|
||||||
|
|
||||||
|
viewport.set_has_depth_buffer (true);
|
||||||
renderer = new SceneRenderer();
|
renderer = new SceneRenderer();
|
||||||
|
|
||||||
draw_area.realize.connect(renderer.Setup);
|
viewport.realize.connect(renderer.Setup);
|
||||||
draw_area.render.connect(renderer.Render);
|
viewport.render.connect(renderer.Render);
|
||||||
draw_area.resize.connect(renderer.OnResize);
|
viewport.resize.connect(renderer.OnResize);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Window()
|
~Window()
|
||||||
{
|
{
|
||||||
print("Closing!!\n");
|
print("Closing!!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GtkCallback]
|
||||||
|
private bool OnKeyPressed(Gtk.EventControllerKey controller, uint keyval, uint keycode, Gdk.ModifierType mod_state)
|
||||||
|
{
|
||||||
|
print("Key pressed!\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<gresources>
|
<gresources>
|
||||||
<gresource prefix="/com/brodybrooks/WorldBuilder">
|
<gresource prefix="/com/brodybrooks/WorldBuilder">
|
||||||
<file preprocess="xml-stripblanks">window.ui</file>
|
<file preprocess="xml-stripblanks">window.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">viewport.ui</file>
|
||||||
<file preprocess="xml-stripblanks">shortcuts-dialog.ui</file>
|
<file preprocess="xml-stripblanks">shortcuts-dialog.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user