Compare commits

...

20 commits

Author SHA1 Message Date
8113b3c567 nearest raycast hit across enemy cols 2024-12-16 07:15:31 -05:00
bc79d08bbd convert revolver shot to ray data type 2024-12-16 07:12:44 -05:00
e1e15a7119 render sphere colliders on enemy_test 2024-12-16 07:08:14 -05:00
3c97e9eadc spin and shift enemy test around 2024-12-16 07:07:51 -05:00
c4989222d3 loop through enemy types for testing 2024-12-16 07:07:27 -05:00
055513d61d scoot back the bamboo placeholder 2024-12-16 07:02:49 -05:00
8a0f93090a parse enemy cols 2024-12-16 07:02:30 -05:00
8898da47ce initialize enemy types 2024-12-16 06:56:57 -05:00
695d4b7732 render particles with default cube mesh for now 2024-12-16 06:05:20 -05:00
5700f83dab dmg icon 2024-12-16 06:04:30 -05:00
988ea482c4 enemy data class 2024-12-16 06:01:13 -05:00
db09cb5495 start with the menu closed 2024-12-16 05:40:54 -05:00
e340845c09 v++ 2024-12-16 05:33:26 -05:00
f024e4dd4a enemy collider meshes 2024-12-16 05:32:58 -05:00
b5e158f4f7 how to offset annoyance inherent in spd+def enemy 2024-12-16 04:39:05 -05:00
ccc15ac357 level editor notes 2024-12-16 04:38:31 -05:00
2c56f6fe52 fading particles 2024-12-04 18:19:43 -05:00
76fbe75242 map to xr hardware 2024-12-04 18:19:16 -05:00
c4dc1e079f gun hit test 2024-12-03 02:04:21 -05:00
f5cbacd62e palette test 2024-12-03 01:33:45 -05:00
9 changed files with 278 additions and 50 deletions

BIN
Assets/meshes/assets.glb (Stored with Git LFS)

Binary file not shown.

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dofdev.slash"
android:versionCode="48"
android:versionName="1.53"
android:versionCode="7"
android:versionName="1.07"
android:installLocation="auto"
>
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="32" />
@ -17,25 +17,43 @@
<!-- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> -->
<!-- Generic OpenXR items -->
<uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1" />
<uses-feature
android:name="android.hardware.vr.headtracking"
android:required="true"
android:version="1"
/>
<uses-permission android:name="org.khronos.openxr.permission.OPENXR_SYSTEM" />
<uses-permission android:name="org.khronos.openxr.permission.OPENXR" />
<queries>
<provider android:authorities="org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker" />
<intent> <action android:name="org.khronos.openxr.OpenXRRuntimeService" /> </intent>
<intent> <action android:name="org.khronos.openxr.OpenXRApiLayerService" /> </intent>
<provider
android:authorities="org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker"
/>
<intent> <action
android:name="org.khronos.openxr.OpenXRRuntimeService"
/> </intent>
<intent> <action
android:name="org.khronos.openxr.OpenXRApiLayerService"
/> </intent>
</queries>
<!-- Vive specific items -->
<uses-feature android:name="wave.feature.handtracking" android:required="false" />
<uses-feature android:name="wave.feature.tracker" android:required="false" />
<uses-feature
android:name="wave.feature.handtracking"
android:required="false"
/>
<uses-feature android:name="wave.feature.tracker" android:required="false" />
<!-- Snapdragon specific items -->
<uses-permission android:name="com.qualcomm.qti.qxr.QXRServiceClientPermission" android:required="false" />
<uses-permission
android:name="com.qualcomm.qti.qxr.QXRServiceClientPermission"
android:required="false"
/>
<queries>
<package android:name="com.qualcomm.qti.spaces.services" />
<package android:name="com.qualcomm.qti.openxrruntime" />
<intent> <action android:name="com.qualcomm.qti.openxr.spaces.intent.action.BIND" /> </intent>
<intent> <action
android:name="com.qualcomm.qti.openxr.spaces.intent.action.BIND"
/> </intent>
</queries>
<!-- Oculus specific items -->
@ -45,11 +63,26 @@
<uses-permission android:name="com.oculus.permission.EYE_TRACKING" />
<uses-permission android:name="com.oculus.permission.USE_ANCHOR_API" />
<uses-permission android:name="com.oculus.permission.USE_SCENE" />
<uses-feature android:name="com.oculus.feature.PASSTHROUGH" android:required="true" />
<uses-feature android:name="oculus.software.handtracking" android:required="false" />
<uses-feature android:name="com.oculus.software.body_tracking" android:required="false" />
<uses-feature android:name="oculus.software.face_tracking" android:required="false" />
<uses-feature android:name="oculus.software.eye_tracking" android:required="false" />
<uses-feature
android:name="com.oculus.feature.PASSTHROUGH"
android:required="true"
/>
<uses-feature
android:name="oculus.software.handtracking"
android:required="false"
/>
<uses-feature
android:name="com.oculus.software.body_tracking"
android:required="false"
/>
<uses-feature
android:name="oculus.software.face_tracking"
android:required="false"
/>
<uses-feature
android:name="oculus.software.eye_tracking"
android:required="false"
/>
<application
android:allowBackup="false"
@ -59,11 +92,23 @@
android:supportsRtl="true"
>
<!-- Oculus -->
<meta-data android:name="com.oculus.supportedDevices" android:value="quest2|quest3|questpro" />
<meta-data android:name="com.oculus.handtracking.version" android:value="V2.0" />
<meta-data android:name="com.oculus.ossplash.background" android:value="passthrough-contextual" />
<meta-data
android:name="com.oculus.supportedDevices"
android:value="quest2|quest3|questpro"
/>
<meta-data
android:name="com.oculus.handtracking.version"
android:value="V2.0"
/>
<meta-data
android:name="com.oculus.ossplash.background"
android:value="passthrough-contextual"
/>
<meta-data android:name="com.oculus.vr.focusaware" android:value="true" />
<uses-native-library android:name="libopenxr_forwardloader.oculus.so" android:required="false" />
<uses-native-library
android:name="libopenxr_forwardloader.oculus.so"
android:required="false"
/>
<!-- Pico -->
<meta-data android:name="pvr.app.type" android:value="vr" />
<meta-data android:name="handtracking" android:value="1" />
@ -86,4 +131,4 @@
</intent-filter>
</activity>
</application>
</manifest>
</manifest>

View file

@ -56,6 +56,11 @@ todo
stretch slash
revolver
flick reload
toylike level editor
(no details to get bogged down with)
shape environment
place structures
sprinkle
enemy design
dmg
@ -63,7 +68,12 @@ todo
3 single types *fodder
dmg, spd, def
3 double types *competent
dmg+spd, spd+def, def+dmg
dmg+spd, spd+def(offset annoyance with), def+dmg
spd+def
offset annoyance with utility in gameplay
maybe it dashes into you and you can parry it back hard
and or able to sort of ride it around
bug(s)
...

View file

@ -25,10 +25,30 @@ static class Arts
{
foreach (ModelNode node in assets_model.Nodes)
{
if (node.Mesh != null)
if (node.Mesh != null && node.Child == null) // [!] sloppy way to differentiate
{
meshes.Add(node.Name, node.Mesh);
}
else
{
// parse enemy cols
for (int i = 0; i < Mono.enemy_types.Length; i++)
{
Enemy enemy_type = Mono.enemy_types[i];
if (node.Name == enemy_type.col_ref)
{
ModelNode sibling = node.Child;
while (sibling != null)
{
enemy_type.cols.Add(new(
sibling.LocalTransform.Pose.position,
sibling.LocalTransform.Scale.x * 2.0f
));
sibling = sibling.Sibling;
}
}
}
}
}
text_style = TextStyle.FromFont(
@ -55,7 +75,8 @@ static class Arts
Matrix m4_world = Mono.world_pose.ToMatrix();
Hierarchy.Push(m4_world);
meshes["Food"].Draw(
// mesh test
meshes["_dmg"].Draw(
mat_mono,
Matrix.TRS(
V.XYZ(0, 0, -1),
@ -64,13 +85,55 @@ static class Arts
)
);
// bamboo
Mesh.Cube.Draw(
mat_unlit,
Matrix.TS(
V.XYZ(0, 1, -5),
V.XYZ(0.1f, 2, 0.1f)
),
Color.Hex(0xB9E7AFFF)
);
// unit cube
// Mesh.Cube.Draw(
// mat_unlit,
// Matrix.Identity,
// Color.Hex(0x13180AFF).ToLinear()
// );
// enemy
Enemy enemy_test = Mono.enemy_types[(int)(Time.Totalf % Mono.enemy_types.Length)];
enemy_test.pose.position = V.XYZ(SKMath.Sin(Time.Totalf * 1f) * 1.0f, 0.666f, -3.0f);
enemy_test.pose.orientation = Quat.FromAngles(0, Time.Totalf * 30, 0);
for (int i = 0; i < enemy_test.cols.Count; i++)
{
Sphere col = enemy_test.cols[i];
Mesh.Sphere.Draw(
mat_mono,
Matrix.TS(
col.center,
col.radius * 2.0f
) * enemy_test.pose.ToMatrix(),
Color.Hex(0x13180AFF).ToLinear()
);
}
// eyes
// Mesh.Cube.Draw(
// mat_unlit,
// Rig.head.ToMatrix().Transform(),
// Color.Hex(0x13180AFF).ToLinear()
// );
// blade
Mesh mesh = new();
Quat hand_rot = Quat.FromAngles(0, 0, SKMath.Sin(Time.Totalf * 6f) * 30f);
Vec3 hand_pos = V.XYZ(SKMath.Sin(Time.Totalf * 1f) * 0.1f, 0, 0);
Vec3 tip_pos = hand_pos + hand_rot * V.XYZ(0, 1, 0);
Quat blade_ori = Rig.r_hld.orientation;
Vec3 blade_pos = Rig.r_hld.position;
Vec3 tip_pos = blade_pos + blade_ori * V.XYZ(0, 0, 1);
mesh.SetData(
new Vertex[] {
new( hand_pos, V.XYZ(0,0,1)),
new( blade_pos, V.XYZ(0,0,1)),
new( tip_pos, V.XYZ(0,0,1)),
new(last_tip_pos, V.XYZ(0,0,1))
},
@ -80,22 +143,80 @@ static class Arts
);
mesh.Draw(
mat_slash,
Matrix.T(0, -1.0f, -1)
Matrix.Identity,
Color.Hex(0xF9BF05FF).ToLinear()
);
last_tip_pos = Vec3.Lerp(last_tip_pos, tip_pos, Time.Stepf / 0.1f);
// revolver
Quat rvolv_ori = Rig.l_aim.orientation;
Vec3 rvolv_pos = Rig.l_aim.position;
Ray ray = new(
rvolv_pos,
rvolv_ori * Vec3.Forward
);
Lines.Add(
ray,
10.0f, // [!] hardcoded design value
Color.Hex(0xF9BF05FF).ToLinear(),
U.cm
);
if (true) // hit test
{
Matrix enemy_m4 = enemy_test.pose.ToMatrix();
Ray local_ray = enemy_m4.Inverse.Transform(ray);
bool hit = false;
float min_dist = float.MaxValue;
Vec3 min_hit_pos = Vec3.Zero;
for (int i = 0; i < enemy_test.cols.Count; i++)
{
Sphere col = enemy_test.cols[i];
Vec3 hit_pos = Vec3.Zero;
if (col.Intersect(local_ray, out hit_pos))
{
float hit_dist = Vec3.Distance(hit_pos, local_ray.position);
if (hit_dist < min_dist)
{
hit = true;
min_dist = hit_dist;
min_hit_pos = hit_pos;
}
}
}
min_hit_pos = enemy_m4.Transform(min_hit_pos);
if (hit)
{
Mesh.Sphere.Draw(
mat_unlit,
Matrix.TS(
min_hit_pos,
4 * U.cm
),
Color.White
);
if (Rig.btn_select.delta == +1)
{
VFX.Play(min_hit_pos);
}
}
}
// particles
Particle[] particles = VFX.particles;
for (int i = 0; i < particles.Length; i++)
{
Particle particle = particles[i];
meshes["FoodParticle"].Draw(
mat_mono,
Mesh.Cube.Draw(
mat_unlit,
Matrix.TRS(
particle.pos,
particle.ori,
particle.scl
)
),
Color.Hex(0xC75A09FF).ToLinear()
);
}

26
src/Data.cs Normal file
View file

@ -0,0 +1,26 @@
using StereoKit;
using System.Collections.Generic;
namespace slash;
public static class Data
{
}
public class Enemy
{
public Pose pose;
public string col_ref;
public List<Sphere> cols;
public Enemy(string col_ref)
{
this.pose = new();
this.col_ref = col_ref;
this.cols = new();
}
}

View file

@ -23,14 +23,21 @@ static class Mono
}
public static Mode mode;
public static Enemy[] enemy_types;
public static void Init()
{
game_time = 0.0;
world_pose = new(0, 0, 0);
menu = new(true);
world_pose = new(0, -1, -2);
menu = new(false);
menu_pose = new(0, 0, 0);
menu_scale = 1 * U.cm;
mode = Mode.Mount;
enemy_types = new Enemy[] {
new("d"), new("s"), new("h"),
new("ds"), new("sh"), new("hd"),
};
}
public static void Frame()

View file

@ -31,7 +31,7 @@ class Program
World.OcclusionEnabled = true;
Device.DisplayBlend = DisplayBlend.AnyTransparent;
Renderer.EnableSky = false;
Renderer.ClearColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
Renderer.ClearColor = Color.Hex(0x42A590FF).ToLinear();// new Color(0.0f, 0.0f, 0.0f, 0.0f);
Rig.Init();
Mono.Init();

View file

@ -10,6 +10,8 @@ static class Rig
public static DeltaBool btn_grip = new(false);
public static DeltaBool btn_back = new(false);
public static Pose l_hld, l_aim, r_hld, r_aim;
public static Vec3 fullstick = Vec3.Up;
public static Pose r_con_stick = Pose.Identity;
@ -30,6 +32,15 @@ static class Rig
btn_select.Step(Input.Key(Key.MouseLeft).IsActive());
btn_back.Step(Input.Key(Key.MouseRight).IsActive());
r_hld = new Pose(
V.XYZ(SKMath.Sin(Time.Totalf * 1f) * 0.1f, 0.5f, 1.0f),
Quat.FromAngles(0, 0, SKMath.Sin(Time.Totalf * 6f) * 30f)
);
l_aim = new Pose(
V.XYZ(SKMath.Sin(Time.Totalf * 2f) * 0.6f, 0.5f, 0.5f),
Quat.Identity
);
if (Input.Key(Key.A).IsJustActive()) new_dir = new(-1, 0, 0);
if (Input.Key(Key.S).IsJustActive()) new_dir = new(+1, 0, 0);
if (Input.Key(Key.W).IsJustActive()) new_dir = new(0, 0, -1);
@ -43,6 +54,12 @@ static class Rig
// Hand r_hand = Input.Hand(Handed.Right);
// [!] hand input simulates controller...
Controller r_con = Input.Controller(Handed.Right);
r_hld = r_con.pose;
r_aim = r_con.aim;
Controller l_con = Input.Controller(Handed.Left);
l_hld = l_con.pose;
l_aim = l_con.aim;
bool con_tracked = r_con.trackedPos > TrackState.Lost;
// bool hand_tracked = Input.HandSource(Handed.Right) > HandSource.None;

View file

@ -16,13 +16,13 @@ static class VFX
}
}
public static void Play(XYZi pos)
public static void Play(Vec3 pos)
{
for (int i = 0; i < 8; i++)
{
index = (index + 1) % particles.Length;
Particle particle = particles[index];
particle.pos = pos.ToVec3;
particle.pos = pos;
particle.vel = Quat.FromAngles(Random.Shared.NextSingle() * 360, 0, 0) * Quat.FromAngles(0, Random.Shared.NextSingle() * 360, 0) * Vec3.Forward * 6.0f;
particle.ori = Quat.Identity;
particle.scl = (1.0f / 3) * Maths.smooth_start(Random.Shared.NextSingle());
@ -37,17 +37,19 @@ static class VFX
if (particle.vel.MagnitudeSq > float.Epsilon)
{
particle.pos += particle.vel * Time.Stepf;
float scl_rad = particle.scl * 0.5f * 0.333f;
Vec3 next_pos = V.XYZ(
Maths.s_clamp(particle.pos.x, 1 - 0.5f - scl_rad),
Maths.s_clamp(particle.pos.y, 1 - 0.5f - scl_rad),
Maths.s_clamp(particle.pos.z, 1 - 0.5f - scl_rad)
);
if (next_pos.x != particle.pos.x || next_pos.y != particle.pos.y || next_pos.z != particle.pos.z)
{
particle.pos = next_pos;
particle.vel = Vec3.Zero;
}
particle.vel *= 1 - (3 * Time.Stepf);
particle.scl *= 1 - (3 * Time.Stepf);
// float scl_rad = particle.scl * 0.5f * 0.333f;
// Vec3 next_pos = V.XYZ(
// Maths.s_clamp(particle.pos.x, 2 - scl_rad),
// Maths.s_clamp(particle.pos.y, 2 - scl_rad),
// Maths.s_clamp(particle.pos.z, 2 - scl_rad)
// );
// if (next_pos.x != particle.pos.x || next_pos.y != particle.pos.y || next_pos.z != particle.pos.z)
// {
// particle.pos = next_pos;
// particle.vel = Vec3.Zero;
// }
}
}
}