Compare commits
2 Commits
ba81b9f71d
...
d63d3cedd2
Author | SHA1 | Date | |
---|---|---|---|
d63d3cedd2 | |||
48d538a73a |
@ -133,8 +133,8 @@ namespace RoboidControl.Unity {
|
||||
rb.velocity = 0.9f * rb.velocity + 0.1f * forwardSpeed * transform.forward;
|
||||
rb.angularVelocity = 0.9f * rb.angularVelocity + 0.1f * turningSpeed * Vector3.up;
|
||||
|
||||
core.position = LinearAlgebra.Spherical.FromVector3(this.transform.localPosition);
|
||||
core.orientation = LinearAlgebra.SwingTwist.FromQuaternion(this.transform.localRotation);
|
||||
core.ReplacePosition(LinearAlgebra.Spherical.FromVector3(this.transform.localPosition));
|
||||
core.ReplaceOrientation(LinearAlgebra.SwingTwist.FromQuaternion(this.transform.localRotation));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -177,6 +177,7 @@ namespace RoboidControl.Unity {
|
||||
|
||||
#if GLTF
|
||||
bool loadingModel = false;
|
||||
|
||||
private async void ProcessGltfModel(RoboidControl.Thing coreThing) {
|
||||
if (!loadingModel) {
|
||||
loadingModel = true;
|
||||
@ -192,7 +193,7 @@ namespace RoboidControl.Unity {
|
||||
Thing[] things = FindObjectsOfType<Thing>();
|
||||
Thing parentThing = null;
|
||||
foreach (Thing thing in things) {
|
||||
if (thing.core.owner.networkId == coreThing.owner.networkId && thing.core.id == coreThing.id) {
|
||||
if (thing.core != null && thing.core.owner.networkId == coreThing.owner.networkId && thing.core.id == coreThing.id) {
|
||||
parentTransform = thing.transform;
|
||||
parentThing = thing;
|
||||
}
|
||||
@ -212,7 +213,8 @@ namespace RoboidControl.Unity {
|
||||
}
|
||||
else
|
||||
ScanForThings(parentTransform);
|
||||
}
|
||||
|
||||
AddMeshColliders(parentTransform); }
|
||||
else {
|
||||
this.transform.localScale = Vector3.one * 1;
|
||||
}
|
||||
@ -262,6 +264,15 @@ namespace RoboidControl.Unity {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void AddMeshColliders(Transform rootTransform) {
|
||||
MeshRenderer[] meshRenderers = rootTransform.GetComponentsInChildren<MeshRenderer>();
|
||||
foreach (MeshRenderer meshRenderer in meshRenderers) {
|
||||
MeshFilter meshFilter = meshRenderer.GetComponent<MeshFilter>();
|
||||
MeshCollider meshCollider = meshRenderer.gameObject.AddComponent<MeshCollider>();
|
||||
meshCollider.sharedMesh = meshFilter.sharedMesh;
|
||||
meshCollider.convex = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle a Pose event
|
||||
|
@ -316,6 +316,10 @@ namespace RoboidControl {
|
||||
/// </summary>
|
||||
public bool positionUpdated = false;
|
||||
|
||||
public void ReplacePosition(Spherical newPosition) {
|
||||
this._position = newPosition;
|
||||
}
|
||||
|
||||
private SwingTwist _orientation = SwingTwist.zero;
|
||||
/// <summary>
|
||||
/// The orientation of the thing in local space
|
||||
@ -336,6 +340,10 @@ namespace RoboidControl {
|
||||
/// </summary>
|
||||
public bool orientationUpdated = false;
|
||||
|
||||
public void ReplaceOrientation(SwingTwist newOrientation) {
|
||||
this._orientation = newOrientation;
|
||||
}
|
||||
|
||||
private Spherical _linearVelocity = Spherical.zero;
|
||||
/// <summary>
|
||||
/// The linear velocity of the thing in local space in meters per second
|
||||
|
Loading…
x
Reference in New Issue
Block a user