Mesh duplication
This commit is contained in:
parent
5e8e7b3ce0
commit
59da3c088f
@ -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();
|
||||
|
@ -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();
|
||||
|
BIN
demo/grass_lowres.png
Normal file
BIN
demo/grass_lowres.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
13
demo/ground.mtl
Normal file
13
demo/ground.mtl
Normal file
@ -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
|
16
demo/ground.obj
Normal file
16
demo/ground.obj
Normal file
@ -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
|
@ -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
|
||||
|
@ -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!)
|
||||
|
Loading…
Reference in New Issue
Block a user