it can be resize, rotated, and translate and scaled. plus is also inherit the parent scale.

now adding one of more shape to try adding multiple shape to same game objects.
as we get familiar it becomes easier and easier to make progress.

Moderators: Sascha Willems, walaber
// find the world that own this collision shape
NewtonBody body = owner.GetComponent<NewtonBody>();
while (body == null)
{
// this is a child body we need to fin the root rigid body owning the shape
owner = owner.GetComponentInParent<Transform>().gameObject;
body = owner.GetComponent<NewtonBody>();
}
NewtonBody body = owner.GetComponentInParent<NewtonBody>();
Description
Returns the component of Type type in the GameObject or any of its parents.
Recurses upwards till it finds a valid component. Returns null if no component found. Only component on active Game Objects are returned.
NewtonBody body = null;
Transform gameTransform = transform;
while (gameTransform != null)
{
// this is a child body we need to fin the root rigid body owning the shape
if (body == null)
{
body = transform.gameObject.GetComponent<NewtonBody>();
}
gameTransform = gameTransform.parent;
}
The question is, how should we treat collider components without a owning body?
Unitys own collider becomes a static collider if no body owns it, should we do the same?
Maybe adding it to a scene collider?
void Start()
{
QualitySettings.vSyncCount = 0;
InitScene();
}
serialization work on object that are no controlle but a editor script.
public class NewtonWorldEditor: Editor
{
public override void OnInspectorGUI()
...
Sweenie wrote:Regarding multithreading and callbacks. Remember that Unity doesn't allow any threads other than the Unity main thread to touch a Game Object.
Sweenie wrote:
Remember that Unity doesn't allow any threads other than the Unity main thread to touch a Game Object.
Platform assembly: C:\Unity\Editor\Data\Mono\lib\mono\2.0\Boo.Lang.Parser.dll (this message is harmless)
Platform assembly: C:\Unity\Editor\Data\Mono\lib\mono\2.0\UnityScript.Lang.dll (this message is harmless)
Registered platform support modules in: 0.0445539s.
Native extension for WindowsStandalone target not found
Load scene 'Temp/__Backupscenes/0.backup' time: 0.369476 ms
The thread 0x5504 has exited with code 0 (0x0).
The thread 0x44e8 has exited with code 0 (0x0).
Exception thrown at 0x000000001F3708E8 in Unity.exe: 0xC0000005: Access violation writing location 0xFFFFFFFFFFFFFFD8.
void dNewtonDynamicBody::ApplyExternalForces(dFloat timestep)
{
dFloat mass;
dFloat Ixx;
dFloat Iyy;
dFloat Izz;
NewtonBodyGetMass(m_body, &mass, &Ixx, &Iyy, &Izz);
const dNewtonWorld* const world = (dNewtonWorld*)NewtonWorldGetUserData(NewtonBodyGetWorld(m_body));
m_externalForce = world->GetGravity().Scale(mass);
m_externalTorque = dVector(0.0f);
// this is a unity thrad, yet calling this delegate causes unity to crash.
// m_forceCallback(timestep);
}
Ensure that your interop does not Callback into unity (if its asyncronous or fed from external thread independent inputs)
Make the callbacks call into a static function on something extending from System.Object and write the same kind of logic as above to request the information on classes extending UnityEngine.Object
public void OnApplyForceAndTorque(float timestep)
{
if (m_body != null)
{
Vector3 xxxx = new Vector3(0, 0, 0);
IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(xxxx));
Marshal.StructureToPtr(xxxx, pnt, false);
m_body.AddForceAndTorque(pnt, pnt);
Marshal.FreeHGlobal(pnt);
}
}
Users browsing this forum: No registered users and 1 guest