Пример #1
0
 /// <summary>Create this joint in the simulation</summary>	
 public void Initialise(LPManager man)
 {
     if (BodyA !=null && BodyB !=null && BodyA.GetComponent<LPBody>() != null && BodyB.GetComponent<LPBody>() != null)
     {
         lpman = man;
         Initialise2(lpman.GetPtr());
     }
     else Debug.LogError("This Joint must be assigned 2 Bodies to connect in order to be created");
 }
Пример #2
0
 /// <summary>Create this joint in the simulation</summary>
 public void Initialise(LPManager man)
 {
     if (BodyA != null && BodyB != null && BodyA.GetComponent <LPBody>() != null && BodyB.GetComponent <LPBody>() != null)
     {
         lpman = man;
         Initialise2(lpman.GetPtr());
     }
     else
     {
         Debug.LogError("This Joint must be assigned 2 Bodies to connect in order to be created");
     }
 }
Пример #3
0
    private void oneshot2(Vector3 pos)
    {
        IntPtr partsysptr       = lpman.ParticleSystems[ParticleSystemImIn].GetPtr();
        IntPtr worldPtr         = lpman.GetPtr();
        IntPtr particlesPointer = LPAPIParticleSystems.GetParticlesInShape(worldPtr, partsysptr
                                                                           , shape, pos.x, pos.y
                                                                           , transform.rotation.eulerAngles.z);

        int[] particlesArray = new int[1];
        Marshal.Copy(particlesPointer, particlesArray, 0, 1);
        int foundNum = particlesArray[0];

        if (foundNum > 0)
        {
            int[] Indices = new int[foundNum + 1];
            Marshal.Copy(particlesPointer, Indices, 0, foundNum + 1);

            LPAPIParticles.SetSelectedParticleFlags(partsysptr, Indices, DebrisMaterial.GetInt());
            LPAPIParticles.SetSelectedParticleUserData(partsysptr, Indices, 2);
            LPAPIParticles.ExplodeSelectedParticles(partsysptr, Indices, pos.x, pos.y, ExplosionStrenght);
        }
    }
Пример #4
0
    public LPRayCastHit[] RaycastWorld()
    {
        IntPtr RayCastInfo = LPAPIRaycast.RaycastWorld(lpman.GetPtr()
                                                       , StartPoint.transform.position.x, StartPoint.transform.position.y
                                                       , EndPoint.transform.position.x, EndPoint.transform.position.y
                                                       , (int)Mode, QueryParticleSystem);

        //find out how many hits there were
        float[] info = new float[2];
        Marshal.Copy(RayCastInfo, info, 0, 2);
        int fixnum    = (int)info[0];
        int partnum   = (int)info[1];
        int totalhits = fixnum + partnum;

        //get the hit data
        int num = 2 + (totalhits * 7);

        float[] allinfo = new float[num];
        Marshal.Copy(RayCastInfo, allinfo, 0, num);
        //LPAPIUtility.ReleaseFloatArray(RayCastInfo);

        //create and return objects to represent the data
        LPRayCastHit[] hits = new LPRayCastHit[totalhits];

        for (int i = 0; i < totalhits; i++)
        {
            LPRayCastHitType hittype;
            if (i < fixnum)
            {
                hittype = LPRayCastHitType.LPFixture;
            }
            else
            {
                hittype = LPRayCastHitType.LPParticle;
            }

            hits[i] = new LPRayCastHit()
            {
                WhatDidIHit   = hittype
                , ParentIndex = (int)allinfo[2 + (7 * i)]
                , Index       = (int)allinfo[3 + (7 * i)]
                , Position    = new Vector3(allinfo[4 + (7 * i)], allinfo[5 + (7 * i)])
                , Normal      = new Vector3(allinfo[6 + (7 * i)], allinfo[7 + (7 * i)])
                , Fraction    = allinfo[8 + (7 * i)]
            };
        }

        return(hits);
    }
Пример #5
0
    //This creates the body and its fixtures in the physics simulation
    public void Initialise(LPManager man)
    {
        StartRotation = transform.localEulerAngles.z;
        lpman         = man;
        myIndex       = lpman.AddBody(this);
        ThingPtr      = LPAPIBody.CreateBody(lpman.GetPtr(), (int)BodyType, transform.position.x, transform.position.y
                                             , 0f
                                             , LinearDamping, AngularDamping, AllowSleep, FixedRotation, IsBullet, GravityScale
                                             , myIndex);

        foreach (LPFixture _fix in gameObject.GetComponents <LPFixture>())
        {
            _fix.Initialise(this);
        }
        Initialised = true;
    }
Пример #6
0
 /// <summary>Create this joint in the simulation</summary>
 public void Initialise(LPManager man)
 {
     lpman = man;
     if (BodyA != null && BodyB != null && BodyA.GetComponent <LPBody>() != null && BodyB.GetComponent <LPBody>() != null)
     {
         if (BodyA.GetComponent <LPBody>().Initialised&& BodyB.GetComponent <LPBody>().Initialised)
         {
             Initialise2(lpman.GetPtr());
             initialised = true;
         }
     }
     else
     {
         Debug.LogError("The " + gameObject.name + " Joint must be assigned 2 Bodies to connect in order to be created");
     }
 }
Пример #7
0
    /// <summary>
    /// Returns an array of the indices of every particle in this particle system within the shape passed to it
    /// Note that the 1st element of the array is the lenght of the array</summary>
    public int[] GetParticlesInShape(IntPtr shape, Transform tran)
    {
        IntPtr worldPtr         = lpMan.GetPtr();
        IntPtr particlesPointer = LPAPIParticleSystems.GetParticlesInShape(worldPtr, PartSysPtr
                                                                           , shape, tran.position.x, tran.position.y
                                                                           , tran.rotation.eulerAngles.z);

        int[] particlesArray = new int[1];
        Marshal.Copy(particlesPointer, particlesArray, 0, 1);
        int partsNum = particlesArray[0];

        int[] particlePositions = new int[partsNum + 1];

        if (partsNum > 0)
        {
            Marshal.Copy(particlesPointer, particlePositions, 0, partsNum + 1);
        }
        return(particlePositions);
    }
Пример #8
0
    public void Splode()
    {
        IntPtr partsysptr       = lpman.ParticleSystems[ParticleSystemImIn].GetPtr();
        IntPtr worldPtr         = lpman.GetPtr();
        IntPtr particlesPointer = LPAPIParticleSystems.GetParticlesInShape(worldPtr, partsysptr
                                                                           , shape, transform.position.x, transform.position.y
                                                                           , transform.rotation.eulerAngles.z);

        int[] particlesArray = new int[1];
        Marshal.Copy(particlesPointer, particlesArray, 0, 1);
        int foundNum = particlesArray[0];


        if (foundNum > 0)
        {
            int[] Indices = new int[foundNum + 1];
            Marshal.Copy(particlesPointer, Indices, 0, foundNum + 1);

            LPAPIParticles.ExplodeSelectedParticles(partsysptr, Indices, transform.position.x, transform.position.y, ExplosionStrenght);
        }
        GetComponent <LPBody>().Delete();
        Destroy(gameObject);
    }
Пример #9
0
    void Splode(Vector3 splodepos)
    {
        Vector3 pos = Camera.main.ScreenToWorldPoint(splodepos);

        IntPtr partsysptr       = lpman.ParticleSystems[ParticleSystemImIn].GetPtr();
        IntPtr worldPtr         = lpman.GetPtr();
        IntPtr particlesPointer = LPAPIParticleSystems.GetParticlesInShape(worldPtr, partsysptr
                                                                           , shape, pos.x, pos.y
                                                                           , 0f);

        int[] particlesArray = new int[1];
        Marshal.Copy(particlesPointer, particlesArray, 0, 1);
        int foundNum = particlesArray[0];


        if (foundNum > 0)
        {
            int[] Indices = new int[foundNum + 1];
            Marshal.Copy(particlesPointer, Indices, 0, foundNum + 1);

            LPAPIParticles.ExplodeSelectedParticles(partsysptr, Indices, pos.x, pos.y, ExplosionStrenght);
        }
    }
Пример #10
0
    //This creates the body and its fixtures in the physics simulation
    public void Initialise(LPManager man)
    {
        StartRotation = transform.localEulerAngles.z;
        lpman = man;
        myIndex = lpman.AddBody(this);
        ThingPtr = LPAPIBody.CreateBody(lpman.GetPtr(),(int)BodyType,transform.position.x,transform.position.y
                                          ,0f
                                          ,LinearDamping,AngularDamping,AllowSleep,FixedRotation,IsBullet,GravityScale
                                          ,myIndex);

        foreach (LPFixture _fix in gameObject.GetComponents<LPFixture>())
        {
            _fix.Initialise(this);
        }
        Initialised = true;
    }
Пример #11
0
 //Delete the body (and its fixtures) from the physics simulation, also destroy the gameobject in unity.
 public override void Delete()
 {
     lpman.RemoveBody(myIndex);
     LPAPIBody.DeleteBody(lpman.GetPtr(), ThingPtr);
     Destroy(gameObject);
 }
Пример #12
0
 /// <summary>Delete this joint, in the simulation and in unity</summary>
 public override void Delete()
 {
     LPAPIJoint.DeleteJoint(lpman.GetPtr(), ThingPtr);
     Destroy(this);
 }