60 lines
No EOL
2.3 KiB
C#
60 lines
No EOL
2.3 KiB
C#
using System;
|
|
using StereoKit;
|
|
|
|
class ColorCube {
|
|
static Mesh cube = Default.MeshCube;
|
|
static Material mat = new Material(Shader.FromFile("colorcube.hlsl"));
|
|
static Material unlit = Default.MaterialUnlit;
|
|
public float thicc = 0.0025f;
|
|
public float ogSize = 0.05f;
|
|
public float size = 0.05f;
|
|
public Vec3 center = Vec3.Zero;
|
|
public Vec3 cursor = Vec3.Zero;
|
|
|
|
public Color color = Color.White * 0.5f;
|
|
|
|
public ColorCube() {
|
|
// SetColor(Vec3.Zero);
|
|
}
|
|
|
|
public void Step() {
|
|
mat.SetVector("_pos", center);
|
|
mat.SetFloat("_size", size);
|
|
Vec3 c = Vec3.One / 2;
|
|
float offset = (size / 2) - (thicc / 2);
|
|
for (int i = 0; i < 4; i++) {
|
|
Quat q = Quat.FromAngles(i * 90, 0, 0);
|
|
cube.Draw(mat, Matrix.TS(center + q * new Vec3(0, offset, offset), new Vec3(size, thicc, thicc)));
|
|
for (int j = -1; j <= 1; j+=2) {
|
|
Vec3 scale = q * new Vec3(thicc, size, thicc);
|
|
scale = new Vec3(Math.Abs(scale.x), Math.Abs(scale.y), Math.Abs(scale.z));
|
|
cube.Draw(mat, Matrix.TS(center + q * new Vec3(offset * j, 0, offset), scale));
|
|
}
|
|
}
|
|
|
|
float thinn = thicc / 3;
|
|
// Vec3 p0s = pos + new Vec3((float)Math.Sin(Time.Totalf) * offset, (float)Math.Sin(Time.Totalf* 2) * offset, (float)Math.Sin(Time.Totalf * 4) * offset);
|
|
Vec3 raw = center + (cursor * offset);
|
|
Vec3 p00 = cursor;
|
|
p00.x = Math.Clamp(p00.x, -1, 1);
|
|
p00.y = Math.Clamp(p00.y, -1, 1);
|
|
p00.z = Math.Clamp(p00.z, -1, 1);
|
|
Vec3 p0s = center + (p00 * offset);
|
|
cube.Draw(mat, Matrix.TS(new Vec3(center.x, p0s.y, p0s.z), new Vec3(size, thinn, thinn)));
|
|
cube.Draw(mat, Matrix.TS(new Vec3(p0s.x, center.y, p0s.z), new Vec3(thinn, size, thinn)));
|
|
cube.Draw(mat, Matrix.TS(new Vec3(p0s.x, p0s.y, center.z), new Vec3(thinn, thinn, size)));
|
|
|
|
Vec3 col = (p00 + Vec3.One) / 2;
|
|
color = new Color(col.x, col.y, col.z);
|
|
cube.Draw(unlit, Matrix.TS(p0s, Vec3.One * thicc * 2), color);
|
|
cube.Draw(unlit, Matrix.TS(raw, Vec3.One * thicc), Color.White);
|
|
}
|
|
}
|
|
|
|
|
|
// everyone get their own color cube? * held in off hand *
|
|
// or just one?
|
|
// or context sensitive?
|
|
// can it be networked effectively? well its just a bounds with a shader and cursor, should be easy enough :)
|
|
|
|
// set your color and when you move blocks around, it changes the color of the blocks * you leave your mark * |