コード例 #1
0
 /// <summary>
 /// Copy parent attributes to another affector.
 /// </summary>
 public void CopyParentAttributesTo(ParticleAffector affector)
 {
     if (affector == null)
     {
         throw new ArgumentNullException("affector cannot be null");
     }
     ParticleAffector_CopyParentAttributesTo(nativePtr, affector.nativePtr);
 }
コード例 #2
0
        public static IElement GetIElementByPointer(IntPtr ptr)
        {
            if (ptr == null || ptr == IntPtr.Zero)
            {
                return(null);
            }
            try
            {
                Particle.ParticleType partype = Particle.Particle_GetParticleType(ptr);

                if (partype == Particle.ParticleType.PT_TECHNIQUE)
                {
                    return(ParticleTechnique.GetInstances(ptr));
                }
                else if (partype == Particle.ParticleType.PT_SYSTEM)
                {
                    return(ParticleSystem.GetInstances(ptr));
                }
                else if (partype == Particle.ParticleType.PT_AFFECTOR)
                {
                    return(ParticleAffector.GetParticleAffectorByType(ptr));
                }
                else if (partype == Particle.ParticleType.PT_EMITTER)
                {
                    return(ParticleEmitter.GetParticleEmitterByPointer(ptr));
                }
                //else if (partype == Particle.ParticleType.PT_VISUAL)
                //    return new Particle(ptr);

                //For Some reason Particle.Particle_GetParticleType(ptr) doesn't return a valid type for PT_SYSTEM.
                //So test for ParticleSystem_GetCategory if it throws an exception then we know it really isn't one! ;)
                ParticleSystem.ParticleSystem_GetCategory(ptr);
                return(ParticleSystem.GetInstances(ptr));
            }
            catch (Exception) { }

            try
            {
                String behaviourType = Marshal.PtrToStringAnsi(ParticleBehaviour.ParticleBehaviour_GetBehaviourType(ptr));
                //ParticleBehaviourFactory
                if (behaviourType == "SlaveBehaviour")
                {
                    return(SlaveBehaviour.GetInstance(ptr));
                }
            }
            catch (Exception)
            {
                return(null);
            }

            try
            {
                DynamicAttributeType type = DynamicAttributeTypeHelper.DynamicAttribute_GetType(ptr);

                if (type == DynamicAttributeType.DAT_CURVED ||
                    type == DynamicAttributeType.DAT_FIXED ||
                    type == DynamicAttributeType.DAT_OSCILLATE ||
                    type == DynamicAttributeType.DAT_RANDOM)
                {
                    return(DynamicAttributeTypeHelper.GetDynamicAttribute(ptr));
                }
            }
            catch (Exception)
            {
            }

            return(null);
        }