예제 #1
0
 /* Copy parent attributes to another behaviour.
  */
 public void CopyParentAttributesTo(ParticleBehaviour behaviour)
 {
     if (behaviour == null)
     {
         throw new ArgumentNullException("behaviour cannot be null!");
     }
     ParticleBehaviour_CopyParentAttributesTo(nativePtr, behaviour.nativePtr);
 }
예제 #2
0
        /// <summary>
        /// Returns the first occurence of the ParticleBehaviour specified by its type.
        /// </summary>
        public ParticleBehaviour GetBehaviour(String behaviourType)
        {
            IntPtr p = Particle_GetBehaviour(nativePointer, behaviourType);

            if (p == IntPtr.Zero)
            {
                return(null);
            }
            if (behaviour != null && behaviour.nativePtr == p)
            {
                return(behaviour);
            }
            behaviour = ParticleBehaviourHelper.GetParticleBehaviour(p);
            return(behaviour);
        }
예제 #3
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);
        }