+ Leek
This commit is contained in:
parent
69cd36781b
commit
901c86eddd
2 changed files with 52 additions and 36 deletions
BIN
add/houseleek_plant.glb
Normal file
BIN
add/houseleek_plant.glb
Normal file
Binary file not shown.
88
app/Space.cs
88
app/Space.cs
|
@ -14,15 +14,41 @@ public class Space {
|
|||
|
||||
Material matFloor = new Material(Shader.Default);
|
||||
Model shed = Model.FromFile("shed/shed.glb", Shader.FromFile("/shaders/room.hlsl"));
|
||||
Model leek = Model.FromFile("houseleek_plant.glb", Shader.FromFile("/shaders/room.hlsl"));
|
||||
Mesh cube = Mesh.Cube;
|
||||
|
||||
|
||||
Solid floor;
|
||||
Solid floor;
|
||||
public Space() {
|
||||
buffer = new MaterialBuffer<BufferData>(3); // index
|
||||
|
||||
// recenter the nodes in the leek model
|
||||
// so that the leek is centered at the origin
|
||||
// and the scale is 1
|
||||
Vec3 center = new Vec3(0, 0, 0);
|
||||
foreach (ModelNode node in leek.Nodes) {
|
||||
if (node.Mesh != null) {
|
||||
// average the vertices to find the center
|
||||
foreach (Vertex vertex in node.Mesh.GetVerts()) {
|
||||
center += vertex.pos;
|
||||
}
|
||||
center /= node.Mesh.VertCount;
|
||||
}
|
||||
node.LocalTransform = Matrix.TS(
|
||||
Vec3.Zero,
|
||||
1f
|
||||
);
|
||||
// node.ModelTransform = Matrix.TS(
|
||||
// new Vec3(0, 0, 0),
|
||||
// 1f
|
||||
// );
|
||||
}
|
||||
leek.RootNode.LocalTransform = Matrix.TS(
|
||||
-center,
|
||||
1f
|
||||
);
|
||||
|
||||
floor = new Solid(World.BoundsPose.position, Quat.Identity, SolidType.Immovable);
|
||||
|
||||
floor = new Solid(World.BoundsPose.position, Quat.Identity, SolidType.Immovable);
|
||||
scale = 64f;
|
||||
floorScale = new Vec3(scale, 0.1f, scale);
|
||||
floor.AddBox(floorScale);
|
||||
|
@ -41,53 +67,43 @@ public class Space {
|
|||
public Vec3 floorScale;
|
||||
|
||||
|
||||
public void Frame() {
|
||||
// Oriel oriel = Mono.inst.oriel;
|
||||
// data.matrix = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrixInv);
|
||||
// data.dimensions = oriel.bounds.dimensions;
|
||||
public void Frame() {
|
||||
// Oriel oriel = Mono.inst.oriel;
|
||||
// data.matrix = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrixInv);
|
||||
// data.dimensions = oriel.bounds.dimensions;
|
||||
|
||||
data.matrix = (Matrix)System.Numerics.Matrix4x4.Transpose(Matrix.T(Vec3.Up));
|
||||
data.dimensions = new Vec3(0.1f, 0.1f, 0.1f);
|
||||
buffer.Set(data);
|
||||
buffer.Set(data);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// PullRequest.BlockOut(floor.GetPose().ToMatrix(floorScale), Color.White * 0.333f, matFloor);
|
||||
// foreach (ModelNode node in shed.Visuals) {
|
||||
// PullRequest.BlockOut(floor.GetPose().ToMatrix(floorScale), Color.White * 0.333f, matFloor);
|
||||
// foreach (ModelNode node in shed.Visuals) {
|
||||
|
||||
// Console.WriteLine(i + " - " + node.Name);
|
||||
// Console.WriteLine(i + " - " + node.Name);
|
||||
|
||||
// node.Material.SetVector("_center", oriel.bounds.center);
|
||||
// node.Material.SetVector("_dimensions", oriel.bounds.dimensions);
|
||||
// node.Material["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrix);
|
||||
// node.Material.SetVector("_center", oriel.bounds.center);
|
||||
// node.Material.SetVector("_dimensions", oriel.bounds.dimensions);
|
||||
// node.Material["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrix);
|
||||
|
||||
// Console.WriteLine("Shader: " + node.Material.Shader.Name);
|
||||
// Console.WriteLine("Shader: " + node.Material.Shader.Name);
|
||||
|
||||
// node.Mesh.Draw(matRoom, Matrix.TRS(new Vec3(0, World.BoundsPose.position.y, -1), Quat.Identity, Vec3.One));
|
||||
// Console.WriteLine(matRoom.ParamCount + " test " + node.Material.ParamCount);
|
||||
// }
|
||||
// room.RootNode.Material.SetVector("_center", oriel.bounds.center);
|
||||
// room.RootNode.Material.SetVector("_dimensions", oriel.bounds.dimensions);
|
||||
// room.RootNode.Material["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrix);
|
||||
// node.Mesh.Draw(matRoom, Matrix.TRS(new Vec3(0, World.BoundsPose.position.y, -1), Quat.Identity, Vec3.One));
|
||||
// Console.WriteLine(matRoom.ParamCount + " test " + node.Material.ParamCount);
|
||||
// }
|
||||
// room.RootNode.Material.SetVector("_center", oriel.bounds.center);
|
||||
// room.RootNode.Material.SetVector("_dimensions", oriel.bounds.dimensions);
|
||||
// room.RootNode.Material["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrix);
|
||||
|
||||
// Shader.
|
||||
// World.BoundsPose.position.y
|
||||
// Shader.
|
||||
// World.BoundsPose.position.y
|
||||
|
||||
|
||||
shed.Draw(Matrix.Identity);
|
||||
shed.Draw(Matrix.Identity);
|
||||
|
||||
|
||||
// draw a grid of cube pillars spaced out evenly along the XZ plane
|
||||
// for (int i = 0; i < 20; i++) {
|
||||
// for (int j = 0; j < 20; j++) {
|
||||
// float x = i * 4 - 20;
|
||||
// float z = j * 4 - 20;
|
||||
// float y = 0;
|
||||
// Matrix m = Matrix.TRS(new Vec3(x, y, z), Quat.Identity, new Vec3(0.25f, 6f, 0.25f));
|
||||
// cube.Draw(matFloor, m);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
leek.Draw(Matrix.TRS(new Vec3(2.5f, 0, -2.5f) * 1.2f, Quat.FromAngles(180f, 30f, 0f), 1.2f));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue