nodes and follow player mechanic

This commit is contained in:
spatialfree 2022-08-03 23:54:03 -04:00
parent fd15fe1e33
commit 88c485cae6
5 changed files with 31 additions and 17 deletions

View file

@ -1,3 +1,5 @@
@REM make console window active
@REM powershell -window normal -command ""
dotnet build
pause
cd bin/Debug

View file

@ -20,7 +20,7 @@ struct psIn {
float3 campos : POSITION2;
float3 camdir : NORMAL1;
uint view_id : SV_RenderTargetArrayIndex;
uint id : SV_VertexID;
// uint id : SV_InstanceID;
};
psIn vs(vsIn input, uint id : SV_InstanceID) {
@ -37,7 +37,7 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
o.campos = sk_camera_pos[o.view_id].xyz;
o.camdir = sk_camera_dir[o.view_id].xyz;
o.id = id;
// o.id = id;
return o;
}
@ -68,7 +68,7 @@ float4 ps(psIn input) : SV_TARGET {
float3 flatnorm = (input.col.rgb - float3(0.5, 0.5, 0.5)) * 2;
flatnorm = normalize(mul(flatnorm, (float3x3)sk_inst[input.id].world));
// flatnorm = normalize(mul(flatnorm, (float3x3)sk_inst[input.id].world));
// float3 cross = input.camDir * input.norm;
float dist = length(input.world.xyz - input.campos);

View file

@ -1,8 +1,8 @@
using System.Collections.Generic;
// [X] stretch cursor move
// [ ] points *arbitrary for now
// [ ] follow player *cam? matrix? name?
// [X] nodes *point of reference rather than interest for now
// [X] follow player *cam? matrix? name?
// [ ] orbital view
// [ ] dummy enemies
// [ ] trackballer spin
@ -29,13 +29,15 @@ public class Mono {
Oriels.PullRequest.Noise noise = Oriels.Mono.inst.noise;
// place nodes around a 10x4x10 cube
float scalar = 3f;
for (int i = 0; i < nodes.Length; i++) {
nodes[i] = new Node(
new Vec3(
noise.value * 5f,
noise.value * 2f,
noise.value * 5f
)
noise.value * 5f * scalar,
noise.value * 2f * scalar,
noise.value * 5f * scalar
),
noise.uvalue
);
}
@ -47,11 +49,12 @@ public class Mono {
Oriels.Oriel oriel = Oriels.Mono.inst.oriel;
Matrix simMatrix = Matrix.TRS(
new Vec3(0, 0, 0), //-oriel.bounds.dimensions.y / 2.01f, -playerWorldPos.z),
-playerPos * 0.5f * oriel.bounds.dimensions.y, //-oriel.bounds.dimensions.y / 2.01f, -playerWorldPos.z),
Quat.Identity,
Vec3.One * 0.5f * oriel.bounds.dimensions.y
);
// stretch cursor pattern:
// stretch = dist(offHand, mainHand)
// max(stretch - deadzone, 0)
@ -65,6 +68,12 @@ public class Mono {
Vec3 cursor = rig.rCon.pos + rig.rCon.ori * Vec3.Forward * stretch * 3;
Vec3 localCursor = simMatrix.Inverse.Transform(oriel.matrix.Transform(cursor));
localCursor = new Vec3(
MathF.Sin(Time.Totalf * 2f) * 3f,
MathF.Sin(Time.Totalf * 0.5f) * 3f,
MathF.Sin(Time.Totalf * 1f) * 3f
);
// fly player towards cursor:
// playerPos += (localCursor - playerPos).Normalized * 1f * Time.Elapsedf;
pidX.p = moveP; pidY.p = moveP; pidZ.p = moveP;
@ -82,7 +91,7 @@ public class Mono {
for (int i = 0; i < nodes.Length; i++) {
meshCube.Draw(oriel.matOriel,
Matrix.TRS(nodes[i].pos, Quat.Identity, Vec3.One * 1f) * simMatrix * oriel.matrix.Inverse,
Color.White
Color.HSV(nodes[i].hue, 1f, 1f)
);
}
@ -175,8 +184,10 @@ public class Mono {
public class Node {
public Vec3 pos;
public float hue;
public Node(Vec3 pos) {
public Node(Vec3 pos, float hue) {
this.pos = pos;
this.hue = hue;
}
}

View file

@ -7,6 +7,7 @@ SKSettings settings = new SKSettings {
assetsFolder = "add",
depthMode = DepthMode.D32,
disableUnfocusedSleep = true,
displayPreference = DisplayMode.Flatscreen,
};
if (!SK.Initialize(settings))
Environment.Exit(1);

View file

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StereoKit" Version="0.3.6-preview.3" />
<PackageReference Include="StereoKit" Version="0.3.6" />
<!-- <PackageReference Include="System.Speech" Version="5.0.0" /> -->
</ItemGroup>