浏览代码

Add coriolis apply demo

/main
Juozas Kasiliauskas 3 年前
当前提交
184cfb09
共有 6 个文件被更改,包括 1099 次插入0 次删除
  1. 39
      Assets/ID_CoriolisCentrifugal/ApplyCoriolisCentrifugal.cs
  2. 11
      Assets/ID_CoriolisCentrifugal/ApplyCoriolisCentrifugal.cs.meta
  3. 30
      Assets/ID_CoriolisCentrifugal/ButtonController.cs
  4. 11
      Assets/ID_CoriolisCentrifugal/ButtonController.cs.meta
  5. 1001
      Assets/ID_CoriolisCentrifugal/ID_CoriolisCentrifugalApply_Scene.unity
  6. 7
      Assets/ID_CoriolisCentrifugal/ID_CoriolisCentrifugalApply_Scene.unity.meta

39
Assets/ID_CoriolisCentrifugal/ApplyCoriolisCentrifugal.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ApplyCoriolisCentrifugal : MonoBehaviour
{
public bool applyForce = false;
private ArticulationBody[] abs;
void Start()
{
abs = FindObjectsOfType<ArticulationBody>();
}
void FixedUpdate()
{
if (!applyForce)
{
for (int i = 0; i < abs.Length; i++)
{
abs[i].jointForce = new ArticulationReducedSpace(0);
}
return;
}
List<float> results = new List<float>();
List<int> indices = new List<int>();
abs[0].GetJointCoriolisCentrifugalForces(results);
abs[0].GetDofStartIndices(indices);
for (int i = 0; i < abs.Length; i++)
{
// Since all joints in this articulation only have 1 DoF we can get away with writing it like this
abs[i].jointForce = new ArticulationReducedSpace(results[indices[abs[i].index]]);
}
}
}

11
Assets/ID_CoriolisCentrifugal/ApplyCoriolisCentrifugal.cs.meta


fileFormatVersion: 2
guid: 35bd8e3f39ac24b16b4c15e2a5ba1ef2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

30
Assets/ID_CoriolisCentrifugal/ButtonController.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonController : MonoBehaviour
{
public Text toggleButtonText;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnToggleApplyForce()
{
ApplyCoriolisCentrifugal applyScript = FindObjectOfType<ApplyCoriolisCentrifugal>();
applyScript.applyForce = !applyScript.applyForce;
toggleButtonText.text = "Toggle counteracting: " + applyScript.applyForce;
}
}

11
Assets/ID_CoriolisCentrifugal/ButtonController.cs.meta


fileFormatVersion: 2
guid: a595e492eb5554ee3bb9071926396bca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

1001
Assets/ID_CoriolisCentrifugal/ID_CoriolisCentrifugalApply_Scene.unity
文件差异内容过多而无法显示
查看文件

7
Assets/ID_CoriolisCentrifugal/ID_CoriolisCentrifugalApply_Scene.unity.meta


fileFormatVersion: 2
guid: aa5ebdde9f847408e84f84575b39dad4
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存