content experimentation + set back to one oriel
11
add/megaman/license.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
Model Information:
|
||||
* title: Megaman X4 - Cyber Space
|
||||
* source: https://sketchfab.com/3d-models/megaman-x4-cyber-space-5fdca251c4734ec49e77c72903b1d234
|
||||
* author: Sah Niemeyer (https://sketchfab.com/sahailaway)
|
||||
|
||||
Model License:
|
||||
* license type: CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
|
||||
* requirements: Author must be credited. Commercial use is allowed.
|
||||
|
||||
If you use this 3D model in your project be sure to copy paste this credit wherever you share it:
|
||||
This work is based on "Megaman X4 - Cyber Space" (https://sketchfab.com/3d-models/megaman-x4-cyber-space-5fdca251c4734ec49e77c72903b1d234) by Sah Niemeyer (https://sketchfab.com/sahailaway) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
|
BIN
add/megaman/scene.bin
Normal file
37519
add/megaman/scene.gltf
Normal file
BIN
add/megaman/textures/01_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
add/megaman/textures/02_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
add/megaman/textures/03_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
add/megaman/textures/04_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 160 B |
BIN
add/megaman/textures/05_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
add/megaman/textures/06_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 515 B |
BIN
add/megaman/textures/07_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
add/megaman/textures/08_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 540 KiB |
BIN
add/megaman/textures/09_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 832 B |
BIN
add/megaman/textures/10_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
add/megaman/textures/11_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
add/megaman/textures/14_-_Default_baseColor.png
Normal file
After Width: | Height: | Size: 1,011 B |
BIN
add/megaman/textures/Cil_2_baseColor.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
add/megaman/textures/Cil_fondo_baseColor.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
add/megaman/textures/Columna_baseColor.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
add/megaman/textures/Cubo4_baseColor.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
add/megaman/textures/Cubo_5_baseColor.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
add/megaman/textures/Cubo_VI_baseColor.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
add/megaman/textures/Portal_baseColor.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
add/megaman/textures/Rombo_tipo_III_baseColor.png
Normal file
After Width: | Height: | Size: 988 B |
BIN
add/megaman/textures/material_22_baseColor.jpeg
Normal file
After Width: | Height: | Size: 618 KiB |
BIN
add/megaman/textures/material_baseColor.png
Normal file
After Width: | Height: | Size: 27 KiB |
|
@ -53,6 +53,10 @@ float sdBox(float3 p, float3 b) {
|
|||
return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
|
||||
}
|
||||
|
||||
float sdSphere(float3 p, float r) {
|
||||
return length(p) - r;
|
||||
}
|
||||
|
||||
float raymarch(float3 origin, float3 direction) {
|
||||
origin = mul(float4(origin, 1), _matrix).xyz;
|
||||
direction = mul(float4(direction, 0), _matrix).xyz;
|
||||
|
@ -60,6 +64,7 @@ float raymarch(float3 origin, float3 direction) {
|
|||
for (int i = 0; i < 256; i++) {
|
||||
float3 pos = origin + dist * direction;
|
||||
float step = sdBox(pos, _dimensions / 2.0);
|
||||
// float step = sdSphere(pos, _dimensions.y / 2.0);
|
||||
if (step < 0.0001 || dist > 100) break; // 100 == distmax
|
||||
dist += step;
|
||||
}
|
||||
|
@ -90,6 +95,13 @@ psOut ps(psIn input) {
|
|||
|
||||
|
||||
// backface
|
||||
float3 localPos = mul(float4(input.world, 1), _matrix).xyz;
|
||||
|
||||
// localPos.y < -_dimensions.y / 2.99
|
||||
if (localPos.y < -_dimensions.y / 2.99) {
|
||||
clip(-1);
|
||||
}
|
||||
|
||||
if (dot(direction, input.normal) > 0) {
|
||||
o.color = float4(0.5, 0.5, 0.5, 1);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,10 @@ float sdBox(float3 p, float3 b) {
|
|||
return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
|
||||
}
|
||||
|
||||
float sdSphere(float3 p, float r) {
|
||||
return length(p) - r;
|
||||
}
|
||||
|
||||
float raymarch(float3 ro, float3 rd) {
|
||||
ro = mul(float4(ro, 1), oriel_matrix).xyz;
|
||||
rd = mul(float4(rd, 0), oriel_matrix).xyz;
|
||||
|
@ -64,6 +68,7 @@ float raymarch(float3 ro, float3 rd) {
|
|||
for (int i = 0; i < 256; i++) {
|
||||
float3 pos = ro + dist * rd;
|
||||
float step = sdBox(pos, dimensions / 2.0);
|
||||
// float step = sdSphere(pos, dimensions.y / 2.0);
|
||||
if (step < 0.0001 || dist > 100) break; // 100 == distmax
|
||||
dist += step;
|
||||
}
|
||||
|
|
11
add/skatepark/license.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
Model Information:
|
||||
* title: Southbank Undercroft Skatepark
|
||||
* source: https://sketchfab.com/3d-models/southbank-undercroft-skatepark-add37d5dc6a2456eb0d7607c6fbd884d
|
||||
* author: artfletch (https://sketchfab.com/artfletch)
|
||||
|
||||
Model License:
|
||||
* license type: CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
|
||||
* requirements: Author must be credited. Commercial use is allowed.
|
||||
|
||||
If you use this 3D model in your project be sure to copy paste this credit wherever you share it:
|
||||
This work is based on "Southbank Undercroft Skatepark" (https://sketchfab.com/3d-models/southbank-undercroft-skatepark-add37d5dc6a2456eb0d7607c6fbd884d) by artfletch (https://sketchfab.com/artfletch) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
|
BIN
add/skatepark/scene.bin
Normal file
1868
add/skatepark/scene.gltf
Normal file
After Width: | Height: | Size: 26 MiB |
63
app/Mono.cs
|
@ -63,7 +63,7 @@ public class Mono {
|
|||
|
||||
// -------------------------------------------------
|
||||
|
||||
// rGlove.Step(); lGlove.Step();
|
||||
rGlove.Step(); lGlove.Step();
|
||||
|
||||
// rBlock.Step(); lBlock.Step();
|
||||
|
||||
|
@ -73,48 +73,51 @@ public class Mono {
|
|||
|
||||
// colorCube.Palm(lCon.device);
|
||||
|
||||
// oriel.Step();
|
||||
oriel.Step();
|
||||
////
|
||||
|
||||
|
||||
|
||||
// °board [ pseudo code ]
|
||||
// handling = 200±
|
||||
// speed = 10±
|
||||
// board.dir = Vec3.fwd
|
||||
// // handling = 200±
|
||||
// // speed = 10±
|
||||
// // board.dir = Vec3.fwd
|
||||
|
||||
// con.grip.frameDown:
|
||||
// handle = con
|
||||
// // con.grip.frameDown:
|
||||
// // handle = con
|
||||
|
||||
// board.pos = FloorCenter
|
||||
// newDir = handle.pos.X0Z - board.pos.X0Z
|
||||
// board.dir = newDir.MagSq > 0.001f ? newDir.normalized : board.dir
|
||||
// board.ori = Quat.LookDir(board.dir)
|
||||
// // board.pos = FloorCenter
|
||||
// // newDir = handle.pos.X0Z - board.pos.X0Z
|
||||
// // board.dir = newDir.MagSq > 0.001f ? newDir.normalized : board.dir
|
||||
// // board.ori = Quat.LookDir(board.dir)
|
||||
|
||||
// twist = handle.grip * -(Quat.LookDir(board.dir).Inverse * handle.backhandDir).x
|
||||
// rig.ori *= Quat(0, twist * handling * delta, 0)
|
||||
// // twist = handle.grip * -(Quat.LookDir(board.dir).Inverse * handle.backhandDir).x
|
||||
// // rig.ori *= Quat(0, twist * handling * delta, 0)
|
||||
|
||||
// accel = handle.trigger
|
||||
// rig.pos += board.dir * accel * speed * delta
|
||||
// // accel = handle.trigger
|
||||
// // rig.pos += board.dir * accel * speed * delta
|
||||
|
||||
|
||||
// °board [ implementation ]
|
||||
float handling = 200;
|
||||
float speed = 10;
|
||||
// // °board [ implementation ]
|
||||
// float handling = 200;
|
||||
// float speed = 10;
|
||||
|
||||
Vec3 boardPos = rig.FloorCenter;
|
||||
Vec3 newDir = rig.HandleCon.pos.X0Z - boardPos.X0Z;
|
||||
boardDir = newDir.MagnitudeSq > 0.001f ? newDir.Normalized : boardDir;
|
||||
Quat boardOri = Quat.LookDir(boardDir);
|
||||
// Vec3 boardPos = rig.FloorCenter;
|
||||
// Vec3 newDir = rig.HandleCon.pos.X0Z - boardPos.X0Z;
|
||||
// boardDir = newDir.MagnitudeSq > 0.001f ? newDir.Normalized : boardDir;
|
||||
// Quat boardOri = Quat.LookDir(boardDir);
|
||||
|
||||
float twist = rig.HandleCon.device.grip * -(Quat.LookDir(boardDir).Inverse * rig.HandleCon.backhandDir).x;
|
||||
rig.ori *= Quat.FromAngles(0f, twist * handling * Time.Elapsedf, 0f);
|
||||
// float twist = rig.HandleCon.device.grip * -(Quat.LookDir(boardDir).Inverse * rig.HandleCon.backhandDir).x;
|
||||
// rig.ori *= Quat.FromAngles(0f, twist * handling * Time.Elapsedf, 0f);
|
||||
|
||||
float accel = rig.HandleCon.device.trigger;
|
||||
rig.pos += boardDir * accel * speed * Time.Elapsedf;
|
||||
// float accel = rig.HandleCon.device.trigger;
|
||||
// rig.pos += boardDir * accel * speed * Time.Elapsedf;
|
||||
|
||||
// // Lines.Add(rig.HandleCon.pos, rig.HandleCon.pos + rig.HandleCon.backhandDir, Color.White, 0.01f);
|
||||
// Mesh.Cube.Draw(Material.Default, Matrix.TRS(boardPos, boardOri, new Vec3(0.18f, 0.06f, 0.6f)));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Lines.Add(rig.HandleCon.pos, rig.HandleCon.pos + rig.HandleCon.backhandDir, Color.White, 0.01f);
|
||||
Mesh.Cube.Draw(Material.Default, Matrix.TRS(boardPos, boardOri, new Vec3(0.18f, 0.06f, 0.6f)));
|
||||
|
||||
// DEPRECATED
|
||||
// PullRequest.Slerp(boardDir.Normalized, handleDelta.Normalized, handleDelta.Magnitude * handling * Time.Elapsedf) : boardDir;
|
||||
|
|
105
app/Oriel.cs
|
@ -7,6 +7,7 @@ public class Oriel {
|
|||
static Material matFrame = new Material(Shader.FromFile("wireframe.hlsl"));
|
||||
static Material matPanes = new Material(Shader.FromFile("panes.hlsl"));
|
||||
static Material matOriel = new Material(Shader.FromFile("oriel.hlsl"));
|
||||
static Model modelArena = Model.FromFile("megaman/scene.gltf");
|
||||
static Model model = Model.FromFile("colorball.glb");
|
||||
Mesh meshCube, meshFrame;
|
||||
|
||||
|
@ -28,7 +29,7 @@ public class Oriel {
|
|||
|
||||
public Oriel() {
|
||||
bounds = new Bounds(
|
||||
Input.Head.position + new Vec3(-0.5f, 0, -1f),
|
||||
new Vec3(-1.0f, -0.5f, 0.0f),
|
||||
new Vec3(0.8f, 0.5f, 0.5f)
|
||||
);
|
||||
|
||||
|
@ -42,6 +43,35 @@ public class Oriel {
|
|||
meshFrame = model.GetMesh("Wireframe");
|
||||
meshCube = Mesh.Cube;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
meshCube = Mesh.Sphere;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Gen();
|
||||
}
|
||||
|
||||
|
@ -156,10 +186,10 @@ public class Oriel {
|
|||
matFrame.Wireframe = true;
|
||||
matFrame.DepthTest = DepthTest.Always;
|
||||
matFrame.SetVector("_rGlovePos", rGlovePos);
|
||||
meshFrame.Draw(matFrame,
|
||||
Matrix.TRS(bounds.center, ori, bounds.dimensions),
|
||||
new Color(0.1f, 0.1f, 0.1f)
|
||||
);
|
||||
// meshFrame.Draw(matFrame,
|
||||
// Matrix.TRS(bounds.center, ori, bounds.dimensions),
|
||||
// new Color(0.1f, 0.1f, 0.1f)
|
||||
// );
|
||||
if (detectCount > 0) {
|
||||
meshCube.Draw(Material.Default,
|
||||
Matrix.TS(detect * (bounds.dimensions / 2), Vec3.One * 0.01f) * matrix.Inverse
|
||||
|
@ -168,10 +198,10 @@ public class Oriel {
|
|||
|
||||
// matPanes.DepthTest = DepthTest.Greater;
|
||||
matPanes["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(matrix);
|
||||
meshCube.Draw(matPanes,
|
||||
Matrix.TRS(bounds.center, ori, bounds.dimensions),
|
||||
new Color(0.0f, 0.0f, 0.5f)
|
||||
);
|
||||
// meshCube.Draw(matPanes,
|
||||
// Matrix.TRS(bounds.center, ori, bounds.dimensions),
|
||||
// new Color(0.0f, 0.0f, 0.5f)
|
||||
// );
|
||||
|
||||
matOriel.SetVector("_center", bounds.center);
|
||||
matOriel.SetVector("_dimensions", bounds.dimensions);
|
||||
|
@ -181,6 +211,15 @@ public class Oriel {
|
|||
|
||||
|
||||
|
||||
// modelArena.Draw(Matrix.TRS(
|
||||
// new Vec3(-1, -0.6f, 1.8f),
|
||||
// Quat.FromAngles(0, -90, 0),
|
||||
// Vec3.One * 0.002f
|
||||
// ));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -188,7 +227,15 @@ public class Oriel {
|
|||
// APP
|
||||
Vec3 playerWorldPos = playerPos * 0.5f * bounds.dimensions.y;
|
||||
Matrix orielSimMatrix = Matrix.TRS(
|
||||
new Vec3(0, -bounds.dimensions.y / 2, -playerWorldPos.z),
|
||||
|
||||
|
||||
|
||||
// new Vec3(0, -bounds.dimensions.y / 2, -playerWorldPos.z),
|
||||
new Vec3(0, -bounds.dimensions.y / 3, -playerWorldPos.z),
|
||||
|
||||
|
||||
|
||||
|
||||
Quat.Identity,
|
||||
Vec3.One * 0.5f * bounds.dimensions.y
|
||||
);
|
||||
|
@ -224,8 +271,9 @@ public class Oriel {
|
|||
// destroy enemies that are too close to the playerPos
|
||||
for (int i = 0; i < enemies.Count; i++) {
|
||||
if (Vec3.Distance(enemies[i], playerPos) < 0.5f) {
|
||||
enemies.RemoveAt(i);
|
||||
i--;
|
||||
// enemies.RemoveAt(i);
|
||||
// i--;
|
||||
enemies[i] = playerPos + Quat.FromAngles(0, Mono.inst.noise.value * 360f, 0) * Vec3.Forward * 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,25 +291,44 @@ public class Oriel {
|
|||
// new Color(0.9f, 0.5f, 0.5f)
|
||||
// );
|
||||
|
||||
if (Time.Totalf > spawnTime) {
|
||||
if (enemies.Count < 100 && Time.Totalf > spawnTime) {
|
||||
enemies.Add(playerPos + Quat.FromAngles(0, Mono.inst.noise.value * 360f, 0) * Vec3.Forward * 8);
|
||||
spawnTime = Time.Totalf + 1;
|
||||
spawnTime = Time.Totalf + 0.05f;
|
||||
}
|
||||
|
||||
for (int i = 0; i < enemies.Count; i++) {
|
||||
|
||||
// move towards player
|
||||
Vec3 toPlayer = (playerPos - enemies[i]).Normalized;
|
||||
float variation = Mono.inst.noise.D1(i);
|
||||
toPlayer *= Quat.FromAngles(0, MathF.Sin(Time.Totalf * variation) * 90 * variation, 0);
|
||||
Vec3 newPos = enemies[i] + toPlayer * Time.Elapsedf * 0.5f;
|
||||
|
||||
// if far enough away from other enemies than set new pos
|
||||
bool setNewPos = true;
|
||||
for (int j = 0; j < enemies.Count; j++) {
|
||||
if (i == j) continue;
|
||||
if ((newPos - enemies[j]).Length < 0.5f) {
|
||||
setNewPos = false;
|
||||
break;
|
||||
int iteration = 0;
|
||||
while (iteration < 6) {
|
||||
for (int j = 0; j < enemies.Count; j++) {
|
||||
if (i == j) continue;
|
||||
// intersection depth
|
||||
float radius = 0.5f;
|
||||
// (newPos - enemies[j]).Length
|
||||
float depth = (newPos - enemies[j]).Length - radius;
|
||||
if (depth < 0) {
|
||||
// pull back
|
||||
Vec3 toEnemy = (enemies[j] - newPos).Normalized;
|
||||
newPos = enemies[j] - toEnemy * radius * 1.01f;
|
||||
|
||||
// bump
|
||||
// enemies[j] += toEnemy * Time.Elapsedf * 0.5f;
|
||||
|
||||
// setNewPos = false;
|
||||
// break;
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
iteration++;
|
||||
}
|
||||
|
||||
if (setNewPos) {
|
||||
|
|
12
app/Scene.cs
|
@ -15,7 +15,8 @@ public class Scene {
|
|||
|
||||
Material matFloor = new Material(Shader.Default);
|
||||
// Model room = Model.FromFile("room/room.glb", Shader.FromFile("room.hlsl"));
|
||||
Model room = Model.FromFile("shed/shed.glb", Shader.FromFile("room.hlsl"));
|
||||
Model shed = Model.FromFile("shed/shed.glb", Shader.FromFile("room.hlsl"));
|
||||
// Model skatepark = Model.FromFile("skatepark/scene.gltf", Shader.FromFile("room.hlsl"));
|
||||
|
||||
|
||||
Solid floor;
|
||||
|
@ -55,7 +56,7 @@ public class Scene {
|
|||
|
||||
|
||||
|
||||
data.dimensions = Vec3.Zero;
|
||||
// data.dimensions = Vec3.Zero;
|
||||
|
||||
|
||||
|
||||
|
@ -70,7 +71,7 @@ public class Scene {
|
|||
buffer.Set(data);
|
||||
|
||||
// PullRequest.BlockOut(floor.GetPose().ToMatrix(floorScale), Color.White * 0.333f, matFloor);
|
||||
foreach (ModelNode node in room.Visuals) {
|
||||
// foreach (ModelNode node in shed.Visuals) {
|
||||
|
||||
// Console.WriteLine(i + " - " + node.Name);
|
||||
|
||||
|
@ -82,13 +83,14 @@ public class Scene {
|
|||
|
||||
// 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
|
||||
room.Draw(Matrix.TRS(new Vec3(0, -1.6f, 0), Quat.Identity, Vec3.One));
|
||||
shed.Draw(Matrix.TRS(new Vec3(0, -1.6f, 0), Quat.Identity, Vec3.One));
|
||||
// skatepark.Draw(Matrix.TRS(new Vec3(0, -5.6f, 0), Quat.Identity, Vec3.One));
|
||||
}
|
||||
}
|