This commit is contained in:
Pascal Serrarens 2024-12-11 15:24:05 +01:00
parent ff7fac6e8c
commit 402300960e

View File

@ -39,7 +39,7 @@ namespace Passer.Humanoid {
protected HumanoidClient client; protected HumanoidClient client;
protected Stream dataStream; protected Stream dataStream;
public byte networkId; //public byte networkId;
public const byte Pose_Position = 0x01; public const byte Pose_Position = 0x01;
public const byte Pose_Orientation = 0x02; public const byte Pose_Orientation = 0x02;
@ -149,12 +149,12 @@ namespace Passer.Humanoid {
Thing thing = Thing.GetThing(msg.networkId, msg.thingId); Thing thing = Thing.GetThing(msg.networkId, msg.thingId);
Thing parentThing = thing.transform.parent.GetComponentInParent<Thing>(); Thing parentThing = thing.transform.parent.GetComponentInParent<Thing>();
if (parentThing != null) if (parentThing != null)
ThingMsg.Send(this, thing.networkId, thing.thingId, parentThing.thingId); ThingMsg.Send(this, thing.networkId, thing.thingId, thing.objectType, parentThing.thingId);
else else
ThingMsg.Send(this, thing.networkId, thing.thingId, 0); ThingMsg.Send(this, thing.networkId, thing.thingId, thing.objectType, 0);
NameMsg.Send(this, thing.thingId, thing.name); NameMsg.Send(this, thing.networkId, thing.thingId, thing.name);
if (thing.modelUrl != null) if (thing.modelUrl != null)
ModelUrlMsg.Send(this, thing.thingId, thing.modelUrl); ModelUrlMsg.Send(this, thing.networkId, thing.thingId, thing.modelUrl);
} }
protected override void ProcessThing(ThingMsg thing) { protected override void ProcessThing(ThingMsg thing) {
@ -451,11 +451,7 @@ namespace Passer.Humanoid {
//#region NetworkId //#region NetworkId
void ProcessNetworkId(Client client, NetworkIdMsg msg) { void ProcessNetworkId(Client client, NetworkIdMsg msg) {
if (this.networkId == msg.networkId) //this.networkId = msg.networkId;
return;
this.networkId = msg.networkId;
client.networkId = msg.networkId;
GameObject networkingObj = this.GetGameObject(msg.networkId); GameObject networkingObj = this.GetGameObject(msg.networkId);
if (networkingObj == null) { if (networkingObj == null) {
if (this.debug <= HumanoidNetworking.DebugLevel.Error) if (this.debug <= HumanoidNetworking.DebugLevel.Error)
@ -470,9 +466,12 @@ namespace Passer.Humanoid {
} }
remoteHumanoid.nwId = msg.networkId; remoteHumanoid.nwId = msg.networkId;
SendThing(client, remoteHumanoid); //SendThing(client, remoteHumanoid);
SendName(remoteHumanoid, 0, "Humanoid"); ThingMsg.Send(client, msg.networkId, 0, 1, 0);
SendModel(remoteHumanoid, "https://gitlab.passervr.com/passer/models/humanoid/-/raw/main/MakeHumanPasserMedium.glb?ref_type=heads&inline=false"); NameMsg.Send(client, msg.networkId, 0, "Humanoid");
//SendName(remoteHumanoid, 0, "Humanoid");
//SendModel(remoteHumanoid, "https://gitlab.passervr.com/passer/models/humanoid/-/raw/main/MakeHumanPasserMedium.glb?ref_type=heads&inline=false");
ModelUrlMsg.Send(client, msg.networkId, 0, "https://gitlab.passervr.com/passer/models/humanoid/-/raw/main/MakeHumanPasserMedium.glb?ref_type=heads&inline=false");
InitBone(client, remoteHumanoid, remoteHumanoid.hipsTarget.hips); InitBone(client, remoteHumanoid, remoteHumanoid.hipsTarget.hips);
InitBone(client, remoteHumanoid, remoteHumanoid.hipsTarget.spine); InitBone(client, remoteHumanoid, remoteHumanoid.hipsTarget.spine);
@ -509,10 +508,10 @@ namespace Passer.Humanoid {
protected void InitBone(Client client, HumanoidControl humanoid, HumanoidTarget.TargetedBone bone) { protected void InitBone(Client client, HumanoidControl humanoid, HumanoidTarget.TargetedBone bone) {
Thing thing = Thing.Create(bone.bone.transform.gameObject, client, client.networkId, (byte)bone.boneId, 0x00); Thing thing = Thing.Create(bone.bone.transform.gameObject, client, client.networkId, (byte)bone.boneId, 0x00);
if (bone.parent != null) if (bone.parent != null)
ThingMsg.Send(client, thing.thingId, thing.objectType, (byte)bone.parent.boneId); ThingMsg.Send(client, thing.networkId, thing.thingId, thing.objectType, (byte)bone.parent.boneId);
else else
ThingMsg.Send(client, thing.thingId, thing.objectType, 0); ThingMsg.Send(client, thing.networkId, thing.thingId, thing.objectType, 0);
NameMsg.Send(client, thing.thingId, bone.bone.transform.name); NameMsg.Send(client, thing.networkId, thing.thingId, bone.bone.transform.name);
} }
//#endregion //#endregion
@ -520,74 +519,74 @@ namespace Passer.Humanoid {
//#region Thing //#region Thing
public void SendThing(Client client, HumanoidControl humanoid) { //public void SendThing(Client client, HumanoidControl humanoid) {
if (debug <= HumanoidNetworking.DebugLevel.Debug) // if (debug <= HumanoidNetworking.DebugLevel.Debug)
Debug.Log("Send Thing " + humanoid.humanoidId + " nwId: " + humanoid.nwId); // Debug.Log("Send Thing " + humanoid.humanoidId + " nwId: " + humanoid.nwId);
ThingMsg.Send(client, 0, 1, 0); // ThingMsg.Send(client, 0, 1, 0);
//ThingMsg thingMsg = new(0, 1); // //ThingMsg thingMsg = new(0, 1);
//SendMsg(thingMsg); // //SendMsg(thingMsg);
//if (udpClient != null) { // //if (udpClient != null) {
// byte[] data = thingMsg.Serialize(); // // byte[] data = thingMsg.Serialize();
// udpClient.Send(data, data.Length, "127.0.0.1", nssPort); // // udpClient.Send(data, data.Length, "127.0.0.1", nssPort);
// //}
//} //}
}
//#endregion Thing //#endregion Thing
//#region SubThing //#region SubThing
public void SendSubThing(HumanoidControl humanoid, HumanoidTarget.TargetedBone bone) { //public void SendSubThing(HumanoidControl humanoid, HumanoidTarget.TargetedBone bone) {
if (debug <= HumanoidNetworking.DebugLevel.Debug) // if (debug <= HumanoidNetworking.DebugLevel.Debug)
Debug.Log("Send SubThing " + humanoid.humanoidId + " nwId: " + humanoid.nwId); // Debug.Log("Send SubThing " + humanoid.humanoidId + " nwId: " + humanoid.nwId);
if (bone.parent != null) // if (bone.parent != null)
ThingMsg.Send(client, (byte)bone.boneId, 0x00, (byte)bone.parent.boneId); // ThingMsg.Send(client, (byte)bone.boneId, 0x00, (byte)bone.parent.boneId);
else // else
ThingMsg.Send(client, (byte)bone.boneId, 0x00, 0); // ThingMsg.Send(client, (byte)bone.boneId, 0x00, 0);
//SubThingMsg thingMsg; // //SubThingMsg thingMsg;
//if (bone.parent != null) // //if (bone.parent != null)
// thingMsg = new((byte)bone.boneId, (byte)bone.parent.boneId, bone.bone.transform.position); // // thingMsg = new((byte)bone.boneId, (byte)bone.parent.boneId, bone.bone.transform.position);
//else // //else
// thingMsg = new((byte)bone.boneId, 0, bone.bone.transform.position); // // thingMsg = new((byte)bone.boneId, 0, bone.bone.transform.position);
//if (udpClient != null) { // //if (udpClient != null) {
// byte[] data = thingMsg.Serialize(); // // byte[] data = thingMsg.Serialize();
// udpClient.Send(data, data.Length, "127.0.0.1", nssPort); // // udpClient.Send(data, data.Length, "127.0.0.1", nssPort);
// //}
// SendName(humanoid, (byte)bone.boneId, bone.bone.transform.name);
//} //}
SendName(humanoid, (byte)bone.boneId, bone.bone.transform.name);
}
//#endregion //#endregion
//#region Name //#region Name
public void SendName(HumanoidControl humanoid, byte thingId, string name) { //public void SendName(HumanoidControl humanoid, byte thingId, string name) {
if (debug <= HumanoidNetworking.DebugLevel.Debug) // if (debug <= HumanoidNetworking.DebugLevel.Debug)
Debug.Log("Send Name " + humanoid.humanoidId + " nwId: " + humanoid.nwId); // Debug.Log("Send Name " + humanoid.humanoidId + " nwId: " + humanoid.nwId);
NameMsg.Send(client, thingId, name); // NameMsg.Send(client, thingId, name);
//NameMsg nameMsg = new(thingId, name); // humanoid.name; // //NameMsg nameMsg = new(thingId, name); // humanoid.name;
//if (udpClient != null) { // //if (udpClient != null) {
// byte[] data = nameMsg.Serialize(); // // byte[] data = nameMsg.Serialize();
// udpClient.Send(data, data.Length, "127.0.0.1", nssPort); // // udpClient.Send(data, data.Length, "127.0.0.1", nssPort);
// //}
//} //}
}
//#endregion //#endregion
//#region Model //#region Model
public void SendModel(HumanoidControl humanoid, string url) { //public void SendModel(HumanoidControl humanoid, string url) {
if (debug <= HumanoidNetworking.DebugLevel.Debug) // if (debug <= HumanoidNetworking.DebugLevel.Debug)
Debug.Log("Send URL " + humanoid.humanoidId + " nwId: " + humanoid.nwId); // Debug.Log("Send URL " + humanoid.humanoidId + " nwId: " + humanoid.nwId);
ModelUrlMsg.Send(client, 0, url); // ModelUrlMsg.Send(client, 0, url);
} //}
bool loaded = false; bool loaded = false;
protected async void ProcessModelURL(Client client, ModelUrlMsg msg) { protected async void ProcessModelURL(Client client, ModelUrlMsg msg) {