diff --git a/core/Mesh.cpp b/core/Mesh.cpp index ae5469c..910e418 100644 --- a/core/Mesh.cpp +++ b/core/Mesh.cpp @@ -51,6 +51,11 @@ Mesh::~Mesh() { } } +Mesh *Mesh::Duplicate() { + Mesh *dup = new Mesh(*this); + return dup; +} + void Mesh::SetupMesh() { for (SubMesh *sub : submeshes) { sub->SetupSubMesh(); diff --git a/core/Mesh.h b/core/Mesh.h index 2be4266..a4062ea 100644 --- a/core/Mesh.h +++ b/core/Mesh.h @@ -44,6 +44,7 @@ public: virtual bool IsDrawable() const {return true;} virtual void Draw(Shader *shader); virtual Name GetType() const; + Mesh *Duplicate(); protected: SubMeshList submeshes; virtual void SetupMesh(); diff --git a/demo/grass_lowres.png b/demo/grass_lowres.png new file mode 100644 index 0000000..7606b49 Binary files /dev/null and b/demo/grass_lowres.png differ diff --git a/demo/ground.mtl b/demo/ground.mtl new file mode 100644 index 0000000..390623b --- /dev/null +++ b/demo/ground.mtl @@ -0,0 +1,13 @@ +# Blender MTL File: 'None' +# Material Count: 1 + +newmtl Material.001 +Ns 20.935559 +Ka 1.000000 1.000000 1.000000 +Kd 0.800000 0.800000 0.800000 +Ks 0.000000 0.000000 0.000000 +Ke 0.000000 0.000000 0.000000 +Ni 1.450000 +d 1.000000 +illum 1 +map_Kd /home/dane/dev/games/trough/godot/environment/raw/grass_lowres.png diff --git a/demo/ground.obj b/demo/ground.obj new file mode 100644 index 0000000..f92aeae --- /dev/null +++ b/demo/ground.obj @@ -0,0 +1,16 @@ +# Blender v2.91.0 OBJ File: '' +# www.blender.org +mtllib ground.mtl +o Plane +v -1.000000 0.000000 1.000000 +v 1.000000 0.000000 1.000000 +v -1.000000 0.000000 -1.000000 +v 1.000000 0.000000 -1.000000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vn 0.0000 1.0000 0.0000 +usemtl Material.001 +s off +f 1/1/1 2/2/1 4/3/1 3/4/1 diff --git a/demo/main.lua b/demo/main.lua index 8a441bb..909b05d 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -45,6 +45,8 @@ function init() "skybox/nz.png" ) couch.Node.GetRoot().children:Append(skybox) + + make_ground() ball = couch.Mesh.FromFile("cube.obj") material = ball:GetMaterial(0) @@ -147,3 +149,17 @@ function onmousemotion(_, _, relx, rely) cam_rot_x = relx cam_rot_y = rely end + +function make_ground() + local ground = couch.TexturedMesh("ground.obj", "grass_lowres.png") + ground.transform.position = couch.Vector3(0.0, -2.0, 0.0) + ground.transform.scale = couch.Vector3(3.0, 1.0, 3.0) + + for x = -20, 20, 1 do + for z = -20, 20, 1 do + local piece = ground:Duplicate() + piece.transform.position = couch.Vector3(3.0 * x, -2.0, 3.0 * z) + couch.Node.GetRoot().children:Append(piece) + end + end +end diff --git a/roadmap.md b/roadmap.md index 5fabfaa..f203132 100644 --- a/roadmap.md +++ b/roadmap.md @@ -54,7 +54,6 @@ calling it from the lua file, so stubs aren't necessary to prevent a crash - [X] No crash on calling non-existant scripting hooks ## Lighting - I'm a bit happier with the system now, I think it's time I started the lighting. We're going to use a pretty basic Phong lighting system, with Flat and Garourd shaders available (This was all that was available on the PSX!)