A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Pyritie » Sun May 09, 2010 11:50 am
Or in other words, making smaller bodies stick to the sides of a larger one. (They all have spheres as collision thingies)
I'm doing this by using a ball and socket joint but sometimes the smaller bodies go inside the bigger one. How do I make them not do this? I tried setting the cone angle to 0 but that didn't seem to work.
Also I made a joint to keep everything on the XZ plane. But when the smaller bodies attach to a bigger one, I want that joint to be removed. How do I do that?
I'm using MogreNewt.
Also one more small problem: if I have a smaller body and a create a larger body on top of it, then I sorta get this loop where it constantly checks to see if the two bodies are connected without actually connecting them. Really though it should be connecting it and then stopping. (Though I do realise this probably wouldn't occur in a normal playthrough it still would be nice to fix.) Sometimes it even connects an antibody to a completely different big sphere even if the two are far away from each other!
- Code: Select all
void Projectile_EnemyCallback_OnBodyContact(ContactMaterial eventArgs, Body body0, Body body1) {
Console.WriteLine("Checking antibody/enemy contact...");
// first we need the colour of the antibody that contacted it
Antibody antibody = body0.UserData as Antibody;
if (antibody == null) {
antibody = body1.UserData as Antibody;
if (antibody == null) {
// neither of them are antibodies so this must've been some other projectile
return;
}
}
if (antibody.AttachedEnemy != null) {
// don't attach the antibody to more than one thing
Console.WriteLine("Antibody already attached");
return;
}
AntigenColour ac = antibody.Colour;
if (Colours.Contains(ac) && BallJoint == null) {
BallJoint = Kernel.Get<PhysicsMain>().AddBallJoint(MeshBody, body1, eventArgs);
Antibodies.Add(antibody);
antibody.AttachedEnemy = this;
//antibody.XZJoint.Dispose();
Launch.Log("Antibody attached to enemy!");
}
}
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by Carli » Sun May 09, 2010 12:24 pm
-
Carli
-
- Posts: 245
- Joined: Fri Oct 02, 2009 5:28 am
by Pyritie » Mon May 10, 2010 7:07 am
Okie lemme see if MogreNewt has that function somewhere...
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by Pyritie » Mon May 10, 2010 11:30 am
Okay that worked. Also I fixed the third question.
I only want to know how to disconnect that joint now.

-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by JernejL » Mon May 10, 2010 11:33 am
NewtonDestroyJoint
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Pyritie » Mon May 10, 2010 11:53 am
I can't find that in MogreNewt, only .Dispose() but when I call that I get an AccessViolationException on:
- Code: Select all
addLinearRow(globalPos, newGlobalPos, Vector3.UNIT_Y);
(full method for that: )
- Code: Select all
public override void SubmitConstraint(float timeStep, int threadIndex) {
Vector3 globalPos;
Quaternion globalOrient;
// get the global position and orientation
// Not sure if we need the orientation but we need the position at least
this.m_body0.GetPositionOrientation(out globalPos, out globalOrient);
// Set the Y of the new position to 0
// TODO: since we're only constraining it to Y, couldn't this just be 0?
newGlobalPos = globalPos;
newGlobalPos.y = 0f;
// I wonder if there's a way to do this without needing the two rows. Oh well.
// The first argument is the position we'd like to move, the second argument is where we'd like
// to move it to, and the third argument says which vector we want to move it along
addLinearRow(globalPos, newGlobalPos, Vector3.UNIT_Y);
}
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by Pyritie » Mon May 10, 2010 1:40 pm
Also my big bodies start spazzing out and flailing everywhere if they have a bunch of smaller bodies attached to them and I apply a bunch of force. What can I do to fix this?
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by Pyritie » Wed May 12, 2010 9:04 am
Pyritie wrote:Also my big bodies start spazzing out and flailing everywhere if they have a bunch of smaller bodies attached to them and I apply a bunch of force. What can I do to fix this?
bump
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by Pyritie » Sat May 15, 2010 7:42 am
Anyone know? I can post a demo + source if need be.
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by JernejL » Sat May 15, 2010 8:35 am
Your description of the problem is vague and inadequte, try posting a video.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Pyritie » Sat May 15, 2010 8:50 am
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by JernejL » Sat May 15, 2010 11:34 am
It looks like your antibodies collide with themselves a lot, you could try disabling collision between them or attach them more properly.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Pyritie » Sat May 15, 2010 11:44 am
I did, the antibodies do not collide with each other at all.
I think it has something to do with how they're connected to the enemies - I'm using a ball and socket joint and the "pin" (or whatever the connecting point is) of the joint is the point of collision that I get from the material callback.
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by Pyritie » Mon May 17, 2010 11:51 am
Is there any sort of joint I can use that just simply connects things together without providing any of the functionality of a ball-and-socket joint or whatever?
-

Pyritie
-
- Posts: 36
- Joined: Tue Mar 02, 2010 8:13 pm
by JernejL » Mon May 17, 2010 1:15 pm
compound collision would likely work perfect for such case.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 0 guests