Sticking antibodies on a cell

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Sticking antibodies on a cell

Postby 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!");
         }
      }
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby Carli » Sun May 09, 2010 12:24 pm

Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am

Re: Sticking antibodies on a cell

Postby Pyritie » Mon May 10, 2010 7:07 am

Okie lemme see if MogreNewt has that function somewhere...
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby 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. :D
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby JernejL » Mon May 10, 2010 11:33 am

NewtonDestroyJoint
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Sticking antibodies on a cell

Postby 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);
        }
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby 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?
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby 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
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby Pyritie » Sat May 15, 2010 7:42 am

Anyone know? I can post a demo + source if need be.
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby JernejL » Sat May 15, 2010 8:35 am

Your description of the problem is vague and inadequte, try posting a video.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Sticking antibodies on a cell

Postby Pyritie » Sat May 15, 2010 8:50 am

here: http://www.youtube.com/watch?v=1tNV3AHfDlc


Download here: http://www.hiveworkshop.com/forums/atta ... debug3.rar (9.03MB) - need .NET runtime distributable and directx 9
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby 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.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Sticking antibodies on a cell

Postby 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.
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby 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?
User avatar
Pyritie
 
Posts: 36
Joined: Tue Mar 02, 2010 8:13 pm

Re: Sticking antibodies on a cell

Postby JernejL » Mon May 17, 2010 1:15 pm

compound collision would likely work perfect for such case.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests