oriel manipulation

This commit is contained in:
spatialfree 2021-12-06 13:00:49 -05:00
parent 80eb666773
commit 19b2a23a6d
3 changed files with 47 additions and 15 deletions

View file

@ -104,15 +104,19 @@ float sdOctahedron(float3 p, float s)
}
float map(float3 pos) {
float sphere = sdSphere(pos + float3(0, 0.5, 0), 0.1);
// pos.x = _center.x + pos.x;
// pos.y = _center.y + pos.y;
// pos.z = _center.z - pos.z;
float sphere = sdSphere(pos + float3(0, 0.5, 0) - _center, 0.1);
// return sdLink(pos, 0.1, 0.1, 0.1);
float octo = sdOctahedron(pos, 0.1);
float octo = sdOctahedron(pos - _center, 0.1);
// return lerp(sphere, octo, windStrength);
float plane = sdPlane(pos, float3(0, 1, 0), 0);
float plane = sdPlane(pos - _center, float3(0, 1, 0), 0);
float phere = lerp(plane, sphere, windStrength);
return min(phere, octo);
// return octo;
}
float3 calcNormal(float3 pos)
@ -157,12 +161,17 @@ float calcAO(float3 pos, float3 nor)
float4 ps(psIn input) : SV_TARGET {
float3 ro = input.world; // ray origin
if (!(sdBox(input.campos, _dimensions / 2) > 0.0)) {
// if (!(sdBox(input.campos, _dimensions / 2) > 0.0)) {
// ro = input.campos;
// // always cull front
// // then replace the input.world with a raymarched box position
// // brings hands into the space
// }
if (dot(input.norm, input.campos - ro) < 0.0) {
ro = input.campos;
// always cull front
// then replace the input.world with a raymarched box position
// brings hands into the space
}
float3 rd = normalize(input.world - input.campos); // ray direction
// input.color = float4(float3(1,1,1) * max(tri_raycast(input.world, ray), 0.0), 1);

View file

@ -52,10 +52,11 @@ public class Mono {
Oriel oriel = new Oriel();
oriel.Start(3);
// Oriel otherOriel = new Oriel();
// otherOriel.Start(4);
MonoNet net = new MonoNet(this);
// Oriel otherOriel = new Oriel();
// otherOriel.Start(4);
MonoNet net = new MonoNet(this);
net.Start();
ColorCube colorCube = new ColorCube();
@ -74,6 +75,9 @@ public class Mono {
camMat.SetTexture("diffuse", camTex);
Mesh quad = Default.MeshQuad;
bool draggingOriel = false;
Vec3 orielOffset = Vec3.Zero;
Vec3 gripPos = Vec3.Zero;
bool domGripping = false, subGripping = false;
@ -378,6 +382,25 @@ public class Mono {
if (domCon.trigger > 0.5f && subCon.trigger > 0.5f) {
if (!draggingOriel) {
if (oriel.bounds.Contains(net.me.cursor0) || oriel.bounds.Contains(net.me.cursor3)) {
draggingOriel = true;
}
} else {
oriel.bounds.center = Vec3.Lerp(net.me.cursor0, net.me.cursor3, 0.5f);
//
float distX = Math.Abs(net.me.cursor0.x - net.me.cursor3.x);
float distY = Math.Abs(net.me.cursor0.y - net.me.cursor3.y);
float distZ = Math.Abs(net.me.cursor0.z - net.me.cursor3.z);
oriel.bounds.dimensions = new Vec3(distX, distY, distZ);
}
} else {
draggingOriel = false;
}
oriel.Step();
// otherOriel.bounds.center = Vec3.Forward * -2;
@ -574,7 +597,7 @@ public class Oriel {
MaterialBuffer<BufferData> buffer;
public void Start(int bufferIndex) {
bounds = new Bounds(Vec3.Zero, new Vec3(1f, 0.5f, 0.5f));
bounds = new Bounds(Vec3.Forward * 2, new Vec3(1f, 0.5f, 0.5f));
_dimensions = bounds.dimensions;
buffer = new MaterialBuffer<BufferData>(bufferIndex);
}
@ -626,7 +649,7 @@ public class Oriel {
// instead of a quad, just slap the same mesh to the head
// crown.SetVector("_center", bounds.center);
crown.SetFloat("_height", bounds.dimensions.y);
crown.SetFloat("_ypos", bounds.center.y);
crown.FaceCull = Cull.Front;

View file

@ -141,7 +141,7 @@ public class CubicFlow : SpatialCursor {
domTwisting = false;
} else {
if (!domTwisting) {
domUp = domCon.stick.y > 0;
domUp = domCon.stick.x > 0;
domTwisting = true;
}
}
@ -152,7 +152,7 @@ public class CubicFlow : SpatialCursor {
subTwisting = false;
} else {
if (!subTwisting) {
subUp = subCon.stick.y > 0;
subUp = subCon.stick.x < 0;
subTwisting = true;
}
}
@ -164,7 +164,7 @@ public class CubicFlow : SpatialCursor {
p3 = sub.position;
if (domUp) {
if (domUp) { // domUp
p0 = domTwist.p0;
p1 = dom.position;
}