Esempio n. 1
0
        internal CCDrawManager(GraphicsDeviceManager deviceManager, CCSize proposedScreenSize,
                               CCDisplayOrientation supportedOrientations)
        {
            Renderer = new CCRenderer(this);

            graphicsDeviceMgr = deviceManager;

            depthTest = true;
            allowNonPower2Textures = true;
            hasStencilBuffer       = true;
            currBlend           = CCBlendFunc.AlphaBlend;
            platformDepthFormat = CCDepthFormat.Depth24;
            transform           = Matrix.Identity;

            TmpVertices = new CCRawList <CCV3F_C4B_T2F>();
            matrixStack = new Matrix[100];
            blendStates = new Dictionary <CCBlendFunc, BlendState>();
            effectStack = new Stack <Effect>();

            rasterizerStatesCache = new List <RasterizerState>();

            hasStencilBuffer = (deviceManager.PreferredDepthStencilFormat == DepthFormat.Depth24Stencil8);


            if (deviceManager.GraphicsDevice == null)
            {
                initialProposedScreenSizeInPixels           = proposedScreenSize;
                graphicsDeviceMgr.PreferredBackBufferWidth  = (int)initialProposedScreenSizeInPixels.Width;
                graphicsDeviceMgr.PreferredBackBufferHeight = (int)initialProposedScreenSizeInPixels.Height;
                graphicsDeviceMgr.SupportedOrientations     = (DisplayOrientation)supportedOrientations;
                graphicsDeviceMgr.DeviceCreated            += GraphicsDeviceCreated;
                graphicsDeviceMgr.PreparingDeviceSettings  += PreparingDeviceSettings;
            }
        }
Esempio n. 2
0
        public override void OnEnter()
        {
            base.OnEnter();

			var effect = new CCSequence(new CCDelayTime (2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false));

            // cleanup
			RemoveChild(bgNode, true);

            // background
			var layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
            AddChild(layer, -10);
			var sprite = new CCSprite("Images/grossini");
            sprite.Position = new CCPoint(50, 80);
            layer.AddChild(sprite, 10);

            // foreground
			var layer2Node = new CCNode ();
			var layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
			var fog = new CCSprite("Images/Fog");

			var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA};
			fog.BlendFunc = bf;
			layer2.AddChild(fog, 1);
			AddChild(layer2Node, 1);
			layer2Node.AddChild (layer2);

			layer2Node.RepeatForever(effect);
        }
Esempio n. 3
0
 public CCBatchCommand(float globalZOrder, CCBlendFunc blendType, CCTextureAtlas texture, CCAffineTransform modelViewTransform, int flags) 
     : base(globalZOrder, modelViewTransform, flags)
 {
     CommandType = CommandType.BATCH_COMMAND;
     Texture = texture;
     BlendType = blendType;
 }
Esempio n. 4
0
        internal CCDrawManager(GraphicsDevice device)
        {
            Renderer = new CCRenderer(this);

            depthTest = true;
            allowNonPower2Textures = true;
            hasStencilBuffer       = true;
            currBlend           = CCBlendFunc.AlphaBlend;
            platformDepthFormat = CCDepthFormat.Depth24;
            transform           = Matrix.Identity;

            TmpVertices = new CCRawList <CCV3F_C4B_T2F>();
            matrixStack = new Matrix[100];
            blendStates = new Dictionary <CCBlendFunc, BlendState>();
            effectStack = new Stack <Effect>();

            InitializeRawQuadBuffers();

            rasterizerStatesCache = new List <RasterizerState>();

            hasStencilBuffer = true;

            graphicsDevice = device;
            InitializeGraphicsDevice();
        }
Esempio n. 5
0
 public CCBatchCommand(float globalZOrder, CCBlendFunc blendType, CCTextureAtlas texture, CCAffineTransform modelViewTransform, int flags)
     : base(globalZOrder, modelViewTransform, flags)
 {
     CommandType = CommandType.BATCH_COMMAND;
     Texture     = texture;
     BlendType   = blendType;
 }
Esempio n. 6
0
 public CCPrimitiveCommand(float globalZOrder, CCTexture2D texture, CCPrimitive <T, T2> primitive,
                           CCBlendFunc blendType, CCAffineTransform modelViewTransform, int flags = 0)
     : base(globalZOrder, modelViewTransform, flags)
 {
     CommandType = CommandType.PRIMITIVE_COMMAND;
     Primitive   = primitive;
     BlendType   = blendType;
     Texture     = texture;
 }
Esempio n. 7
0
 public CCQuadCommand(float globalDepth, CCAffineTransform worldTransform, 
     CCTexture2D texture, CCBlendFunc blendType, int quadCount,
     params CCV3F_C4B_T2F_Quad[] quads) 
     : base(globalDepth, worldTransform)
 {
     Quads = quads;
     QuadCount = quadCount;
     Texture = texture;
     BlendType = blendType;
 }
 public CCQuadCommand(float globalDepth, CCAffineTransform worldTransform,
                      CCTexture2D texture, CCBlendFunc blendType, int quadCount,
                      params CCV3F_C4B_T2F_Quad[] quads)
     : base(globalDepth, worldTransform)
 {
     Quads     = quads;
     QuadCount = quadCount;
     Texture   = texture;
     BlendType = blendType;
 }
Esempio n. 9
0
        public CCDrawNode()
        {
            renderTriangles = new CCCustomCommand(FlushTriangles);
            renderLines     = new CCCustomCommand(FlushLines);
            renderStrings   = new CCCustomCommand(DrawStrings);

            BlendFunc        = CCBlendFunc.AlphaBlend;
            triangleVertices = new CCRawList <CCV3F_C4B>(DefaultBufferSize);
            lineVertices     = new CCRawList <CCV3F_C4B>(DefaultBufferSize);

            verticeBounds = CCRect.Zero;
        }
Esempio n. 10
0
        public CCDrawNode()
        {
            renderTriangles = new CCCustomCommand(FlushTriangles);
            renderLines = new CCCustomCommand(FlushLines);
            renderStrings = new CCCustomCommand(DrawStrings);

            BlendFunc = CCBlendFunc.AlphaBlend;
            triangleVertices = new CCRawList<CCV3F_C4B>(DefaultBufferSize);
            lineVertices = new CCRawList<CCV3F_C4B>(DefaultBufferSize);

            verticeBounds = CCRect.Zero;
        }
        public CCParticleSystemQuad(CCParticleSystemConfig config)
            : base(config)
        {
            InitRenderCommand();

            Texture = config.Texture;

            CCBlendFunc blendFunc = new CCBlendFunc();

            blendFunc.Source      = config.BlendFunc.Source;
            blendFunc.Destination = config.BlendFunc.Destination;
            BlendFunc             = blendFunc;
        }
Esempio n. 12
0
        public RenderTextureSave()
        {
            // create a brush image to draw into the texture with
            brush = new CCSprite("Images/fire");
            // It's possible to modify the Brushes blending function by
            CCBlendFunc bbf = new CCBlendFunc (CCOGLES.GL_ONE, CCOGLES.GL_ONE_MINUS_SRC_ALPHA);
            brush.BlendFunc = bbf;

            brush.Color = CCColor3B.Red;
            brush.Opacity = 20;


            // Save image menu
            CCMenuItemFont.FontSize = 16;
            CCMenuItemFont.FontName = "arial";
            CCMenuItem item1 = new CCMenuItemFont("Save Image", SaveImage);
            CCMenuItem item2 = new CCMenuItemFont("Clear", ClearImage);

            saveImageMenu = new CCMenu(item1, item2);
            AddChild(saveImageMenu);
        }
        void UpdateBlendFunc()
        {
            if (Texture != null)
            {
                bool premultiplied = Texture.HasPremultipliedAlpha;

                OpacityModifyRGB = false;

                if (blendFunc == CCBlendFunc.AlphaBlend)
                {
                    if (premultiplied)
                    {
                        OpacityModifyRGB = true;
                    }
                    else
                    {
                        blendFunc = CCBlendFunc.NonPremultiplied;
                    }
                }
            }
        }
Esempio n. 14
0
        public void BlendFunc(CCBlendFunc blendFunc)
        {
            BlendState bs = null;

            if (blendFunc == CCBlendFunc.AlphaBlend)
            {
                bs = BlendState.AlphaBlend;
            }
            else if (blendFunc == CCBlendFunc.Additive)
            {
                bs = BlendState.Additive;
            }
            else if (blendFunc == CCBlendFunc.NonPremultiplied)
            {
                bs = BlendState.NonPremultiplied;
            }
            else if (blendFunc == CCBlendFunc.Opaque)
            {
                bs = BlendState.Opaque;
            }
            else
            {
                if (!blendStates.TryGetValue(blendFunc, out bs))
                {
                    bs = new BlendState();

                    bs.ColorSourceBlend      = CCOGLES.GetXNABlend(blendFunc.Source);
                    bs.AlphaSourceBlend      = CCOGLES.GetXNABlend(blendFunc.Source);
                    bs.ColorDestinationBlend = CCOGLES.GetXNABlend(blendFunc.Destination);
                    bs.AlphaDestinationBlend = CCOGLES.GetXNABlend(blendFunc.Destination);

                    blendStates.Add(blendFunc, bs);
                }
            }

            graphicsDevice.BlendState = bs;

            currBlend.Source      = blendFunc.Source;
            currBlend.Destination = blendFunc.Destination;
        }
Esempio n. 15
0
        public override void OnEnter()
        {
            base.OnEnter();

			var effect = new CCSequence(new CCDelayTime (2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false));

            // cleanup
			contentLayer.RemoveChild(bgNode, true);

            // background
            var layer = new CCDrawNode();
            layer.Color = CCColor3B.Red;
            layer.Opacity = 255;

            layer.DrawRect(VisibleBoundsWorldspace);

            AddChild(layer, -10);

			var sprite = new CCSprite("Images/grossini");
            sprite.Position = new CCPoint(50, 80);
            layer.AddChild(sprite, 10);

            // foreground
            var layer2BaseGrid = new CCNodeGrid ();
            var layer2 = new CCDrawNode();
            layer2.Color = CCColor3B.Green;
            layer2.Opacity = 255;
			
            layer2.DrawRect(VisibleBoundsWorldspace);

			var fog = new CCSprite("Images/Fog");

			var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA};
			fog.BlendFunc = bf;
			layer2.AddChild(fog, 1);
			AddChild(layer2BaseGrid, 1);
			layer2BaseGrid.AddChild (layer2);

			layer2BaseGrid.RepeatForever(effect);
        }
Esempio n. 16
0
        public CCQuadCommand(float globalZOrder, CCTexture2D texture, CCBlendFunc blendType,
                             CCV3F_C4B_T2F_Quad[] quads, int quadCount, CCAffineTransform modelViewTransform, int flags = 0)
            : base(globalZOrder, modelViewTransform, flags)
        {
            CommandType = CommandType.QUAD_COMMAND;
            Quads       = quads;
            QuadCount   = quadCount;
            Texture     = texture;
            BlendType   = blendType;

            var textureId = texture == null ? 0 : texture.TextureId;

            // +=========================================================+
            // | Material Id 24 bits                                     |
            // +============================+============================+
            // | Texture ID                 | BlendFunc (Src ^ Dest)     |
            // | 12 bits                    | 12 bits                    |
            // +============================+============================+
            MaterialId = textureId << 12 | BlendType.GetHashCode();

            System.Diagnostics.Debug.Assert(MaterialId != 0, "Material Id not set");
        }
Esempio n. 17
0
        void UpdateBlendFunc()
        {
            Debug.Assert(BatchNode == null, "Can't change blending functions when the particle is being batched");

            if (Texture != null)
            {
                bool premultiplied = Texture.HasPremultipliedAlpha;

                OpacityModifyRGB = false;

                if (blendFunc == CCBlendFunc.AlphaBlend)
                {
                    if (premultiplied)
                    {
                        OpacityModifyRGB = true;
                    }
                    else
                    {
                        blendFunc = CCBlendFunc.NonPremultiplied;
                    }
                }
            }
        }
Esempio n. 18
0
        public CCQuadCommand(float globalZOrder, CCTexture2D texture, CCBlendFunc blendType, 
            CCV3F_C4B_T2F_Quad[] quads, int quadCount, CCAffineTransform modelViewTransform, int flags = 0) 
            : base(globalZOrder, modelViewTransform, flags)
        {
            CommandType = CommandType.QUAD_COMMAND;
            Quads = quads;
            QuadCount = quadCount;
            Texture = texture;
            BlendType = blendType;

            var textureId = texture == null ? 0 : texture.TextureId;

            // +=========================================================+
            // | Material Id 24 bits                                     |
            // +============================+============================+
            // | Texture ID                 | BlendFunc (Src ^ Dest)     |
            // | 12 bits                    | 12 bits                    |
            // +============================+============================+
            MaterialId = textureId << 12 | BlendType.GetHashCode();

            System.Diagnostics.Debug.Assert(MaterialId != 0, "Material Id not set");
                
        }
Esempio n. 19
0
 protected virtual void OnHandlePropTypeBlendFunc(CCNode node, CCNode parent, string propertyName, CCBlendFunc blendFunc,
                                                  CCBReader reader)
 {
     CCLog.Log("Unexpected property type: '{0}'!", propertyName);
     Debug.Assert(false);
 }
Esempio n. 20
0
        protected virtual CCBlendFunc ParsePropTypeBlendFunc(CCNode node, CCNode parent, CCBReader reader)
        {
            int source = reader.ReadInt(false);
            int destination = reader.ReadInt(false);

            CCBlendFunc blendFunc = new CCBlendFunc();
            blendFunc.Source = source;
            blendFunc.Destination = destination;

            return blendFunc;
        }
Esempio n. 21
0
        public CCBatchCommand(float globalZOrder, CCBlendFunc blendType, CCTextureAtlas texture) 
            : this(globalZOrder, blendType, texture, CCAffineTransform.Identity, 0)
        {


        }
Esempio n. 22
0
 public CCPrimitiveCommand(float globalZOrder, CCPrimitive <T, T2> primitive,
                           CCBlendFunc blendType, CCAffineTransform modelViewTransform, int flags = 0)
     : this(globalZOrder, null, primitive, blendType, modelViewTransform, flags)
 {
 }
Esempio n. 23
0
 public CCQuadCommand(float globalDepth, CCAffineTransform worldTransform, 
     CCTexture2D texture, CCBlendFunc blendType, 
     params CCV3F_C4B_T2F_Quad[] quads) 
     : this(globalDepth, worldTransform, texture, blendType, quads.Length, quads)
 {  }
Esempio n. 24
0
 public bool Equals(CCBlendFunc other)
 {
     return(this == other);
 }
        CCParticleSystemConfig(PlistDictionary dictionary, string directoryName, bool loadingAsync)
        {
            ParticleSystemType = CCParticleSystemType.Cocos2D;

            MaxParticles = dictionary ["maxParticles"].AsInt;
            Duration     = dictionary["duration"].AsFloat;
            Life         = dictionary["particleLifespan"].AsFloat;
            LifeVar      = dictionary["particleLifespanVariance"].AsFloat;

            Angle    = dictionary["angle"].AsFloat;
            AngleVar = dictionary["angleVariance"].AsFloat;

            CCBlendFunc blendFunc = new CCBlendFunc();

            blendFunc.Source      = dictionary["blendFuncSource"].AsInt;
            blendFunc.Destination = dictionary["blendFuncDestination"].AsInt;
            BlendFunc             = blendFunc;

            CCColor4F startColor = new CCColor4F();

            startColor.R = dictionary["startColorRed"].AsFloat;
            startColor.G = dictionary["startColorGreen"].AsFloat;
            startColor.B = dictionary["startColorBlue"].AsFloat;
            startColor.A = dictionary["startColorAlpha"].AsFloat;
            StartColor   = startColor;

            CCColor4F startColorVar = new CCColor4F();

            startColorVar.R = dictionary["startColorVarianceRed"].AsFloat;
            startColorVar.G = dictionary["startColorVarianceGreen"].AsFloat;
            startColorVar.B = dictionary["startColorVarianceBlue"].AsFloat;
            startColorVar.A = dictionary["startColorVarianceAlpha"].AsFloat;
            StartColorVar   = startColorVar;

            CCColor4F endColor = new CCColor4F();

            endColor.R = dictionary["finishColorRed"].AsFloat;
            endColor.G = dictionary["finishColorGreen"].AsFloat;
            endColor.B = dictionary["finishColorBlue"].AsFloat;
            endColor.A = dictionary["finishColorAlpha"].AsFloat;
            EndColor   = endColor;

            CCColor4F endColorVar = new CCColor4F();

            endColorVar.R = dictionary["finishColorVarianceRed"].AsFloat;
            endColorVar.G = dictionary["finishColorVarianceGreen"].AsFloat;
            endColorVar.B = dictionary["finishColorVarianceBlue"].AsFloat;
            endColorVar.A = dictionary["finishColorVarianceAlpha"].AsFloat;
            EndColorVar   = endColorVar;

            StartSize    = dictionary["startParticleSize"].AsFloat;
            StartSizeVar = dictionary["startParticleSizeVariance"].AsFloat;
            EndSize      = dictionary["finishParticleSize"].AsFloat;
            EndSizeVar   = dictionary["finishParticleSizeVariance"].AsFloat;

            CCPoint position;

            position.X = dictionary["sourcePositionx"].AsFloat;
            position.Y = dictionary["sourcePositiony"].AsFloat;
            Position   = position;

            CCPoint positionVar;

            positionVar.X = dictionary["sourcePositionVariancex"].AsFloat;
            positionVar.Y = dictionary["sourcePositionVariancey"].AsFloat;
            PositionVar   = positionVar;

            StartSpin    = dictionary["rotationStart"].AsFloat;
            StartSpinVar = dictionary["rotationStartVariance"].AsFloat;
            EndSpin      = dictionary["rotationEnd"].AsFloat;
            EndSpinVar   = dictionary["rotationEndVariance"].AsFloat;

            EmitterMode = (CCEmitterMode)dictionary["emitterType"].AsInt;

            if (EmitterMode == CCEmitterMode.Gravity)
            {
                CCPoint gravity;
                gravity.X = dictionary["gravityx"].AsFloat;
                gravity.Y = dictionary["gravityy"].AsFloat;
                Gravity   = gravity;

                GravitySpeed              = dictionary["speed"].AsFloat;
                GravitySpeedVar           = dictionary["speedVariance"].AsFloat;
                GravityRadialAccel        = dictionary["radialAcceleration"].AsFloat;
                GravityRadialAccelVar     = dictionary["radialAccelVariance"].AsFloat;
                GravityTangentialAccel    = dictionary["tangentialAcceleration"].AsFloat;
                GravityTangentialAccelVar = dictionary["tangentialAccelVariance"].AsFloat;
                GravityRotationIsDir      = dictionary["rotationIsDir"].AsBool;
            }

            else if (EmitterMode == CCEmitterMode.Radius)
            {
                RadialStartRadius        = dictionary["maxRadius"].AsFloat;
                RadialStartRadiusVar     = dictionary["maxRadiusVariance"].AsFloat;
                RadialEndRadius          = dictionary["minRadius"].AsFloat;
                RadialEndRadiusVar       = 0.0f;
                RadialRotatePerSecond    = dictionary["rotatePerSecond"].AsFloat;
                RadialRotatePerSecondVar = dictionary["rotatePerSecondVariance"].AsFloat;
            }
            else
            {
                Debug.Assert(false, "Invalid emitterType in config file");
                return;
            }

            TextureName = dictionary["textureFileName"].AsString;
            TextureData = dictionary["textureImageData"].AsString;

            if (!loadingAsync)
            {
                LoadParticleTexture();
            }
        }
Esempio n. 26
0
 public CCQuadCommand(float globalZOrder, CCTexture2D texture, CCBlendFunc blendType, 
     CCV3F_C4B_T2F_Quad[] quads) 
     : this(globalZOrder, texture, blendType, quads, quads.Length, CCAffineTransform.Identity, 0)
 {}
        CCParticleSystemConfig(PlistDictionary dictionary, string directoryName, bool loadingAsync) 
        {
            ParticleSystemType = CCParticleSystemType.Cocos2D;

            MaxParticles = dictionary ["maxParticles"].AsInt;
            Duration = dictionary["duration"].AsFloat;
            Life = dictionary["particleLifespan"].AsFloat;
            LifeVar = dictionary["particleLifespanVariance"].AsFloat;

            Angle = dictionary["angle"].AsFloat;
            AngleVar = dictionary["angleVariance"].AsFloat;

            CCBlendFunc blendFunc = new CCBlendFunc();
            blendFunc.Source = dictionary["blendFuncSource"].AsInt;
            blendFunc.Destination = dictionary["blendFuncDestination"].AsInt;
            BlendFunc = blendFunc;

            CCColor4F startColor = new CCColor4F();
            startColor.R = dictionary["startColorRed"].AsFloat;
            startColor.G = dictionary["startColorGreen"].AsFloat;
            startColor.B = dictionary["startColorBlue"].AsFloat;
            startColor.A = dictionary["startColorAlpha"].AsFloat;
            StartColor = startColor;

            CCColor4F startColorVar = new CCColor4F();
            startColorVar.R = dictionary["startColorVarianceRed"].AsFloat;
            startColorVar.G = dictionary["startColorVarianceGreen"].AsFloat;
            startColorVar.B = dictionary["startColorVarianceBlue"].AsFloat;
            startColorVar.A = dictionary["startColorVarianceAlpha"].AsFloat;
            StartColorVar = startColorVar;

            CCColor4F endColor = new CCColor4F();
            endColor.R = dictionary["finishColorRed"].AsFloat;
            endColor.G = dictionary["finishColorGreen"].AsFloat;
            endColor.B = dictionary["finishColorBlue"].AsFloat;
            endColor.A = dictionary["finishColorAlpha"].AsFloat;
            EndColor = endColor;

            CCColor4F endColorVar = new CCColor4F();
            endColorVar.R = dictionary["finishColorVarianceRed"].AsFloat;
            endColorVar.G = dictionary["finishColorVarianceGreen"].AsFloat;
            endColorVar.B = dictionary["finishColorVarianceBlue"].AsFloat;
            endColorVar.A = dictionary["finishColorVarianceAlpha"].AsFloat;
            EndColorVar = endColorVar;

            StartSize = dictionary["startParticleSize"].AsFloat;
            StartSizeVar = dictionary["startParticleSizeVariance"].AsFloat;
            EndSize = dictionary["finishParticleSize"].AsFloat;
            EndSizeVar = dictionary["finishParticleSizeVariance"].AsFloat;

            CCPoint position;
            position.X = dictionary["sourcePositionx"].AsFloat;
            position.Y = dictionary["sourcePositiony"].AsFloat;
            Position = position;

            CCPoint positionVar;
            positionVar.X = dictionary["sourcePositionVariancex"].AsFloat;
            positionVar.Y = dictionary["sourcePositionVariancey"].AsFloat;
            PositionVar = positionVar;

            StartSpin = dictionary["rotationStart"].AsFloat;
            StartSpinVar = dictionary["rotationStartVariance"].AsFloat;
            EndSpin = dictionary["rotationEnd"].AsFloat;
            EndSpinVar = dictionary["rotationEndVariance"].AsFloat;

            EmitterMode = (CCEmitterMode)dictionary["emitterType"].AsInt;

            if (EmitterMode == CCEmitterMode.Gravity)
            {

                CCPoint gravity;
                gravity.X = dictionary["gravityx"].AsFloat;
                gravity.Y = dictionary["gravityy"].AsFloat;
                Gravity = gravity;

                GravitySpeed = dictionary["speed"].AsFloat;
                GravitySpeedVar = dictionary["speedVariance"].AsFloat;
                GravityRadialAccel = dictionary["radialAcceleration"].AsFloat;
                GravityRadialAccelVar = dictionary["radialAccelVariance"].AsFloat;
                GravityTangentialAccel = dictionary["tangentialAcceleration"].AsFloat;
                GravityTangentialAccelVar = dictionary["tangentialAccelVariance"].AsFloat;
                GravityRotationIsDir = dictionary["rotationIsDir"].AsBool;

            }

            else if (EmitterMode == CCEmitterMode.Radius)
            {
                RadialStartRadius = dictionary["maxRadius"].AsFloat;
                RadialStartRadiusVar = dictionary["maxRadiusVariance"].AsFloat;
                RadialEndRadius = dictionary["minRadius"].AsFloat;
                RadialEndRadiusVar = 0.0f;
                RadialRotatePerSecond = dictionary["rotatePerSecond"].AsFloat;
                RadialRotatePerSecondVar = dictionary["rotatePerSecondVariance"].AsFloat;
            }
            else
            {
                Debug.Assert(false, "Invalid emitterType in config file");
                return;
            }

            TextureName = dictionary["textureFileName"].AsString;
            TextureData = dictionary["textureImageData"].AsString;

            if (!loadingAsync)
                LoadParticleTexture();

        }
Esempio n. 28
0
 public bool Equals(CCBlendFunc other)        
 {            
     return this == other;       
 } 
Esempio n. 29
0
 public CCBatchCommand(float globalZOrder, CCBlendFunc blendType, CCTextureAtlas texture)
     : this(globalZOrder, blendType, texture, CCAffineTransform.Identity, 0)
 {
 }
Esempio n. 30
0
        void UpdateBlendFunc()
        {
            Debug.Assert(BatchNode == null, "Can't change blending functions when the particle is being batched");

            if (Texture != null)
            {
                bool premultiplied = Texture.HasPremultipliedAlpha;

                OpacityModifyRGB = false;

                if (blendFunc == CCBlendFunc.AlphaBlend)
                {
                    if (premultiplied)
                    {
                        OpacityModifyRGB = true;
                    }
                    else
                    {
                        blendFunc = CCBlendFunc.NonPremultiplied;
                    }
                }
            }
        }
Esempio n. 31
0
 public CCQuadCommand(float globalZOrder, CCTexture2D texture, CCBlendFunc blendType, 
     CCV3F_C4B_T2F_Quad quad, CCAffineTransform modelViewTransform, int flags = 0) 
     : this(globalZOrder, texture, blendType, new CCV3F_C4B_T2F_Quad[] { quad }, 1,
         modelViewTransform, flags)
 { }
Esempio n. 32
0
        public CCParticleSystem(CCParticleSystemConfig particleConfig) : this(particleConfig.MaxParticles, false)
        {
            Duration     = particleConfig.Duration;;
            Life         = particleConfig.Life;
            LifeVar      = particleConfig.LifeVar;
            EmissionRate = TotalParticles / Life;

            Angle    = particleConfig.Angle;
            AngleVar = particleConfig.AngleVar;

            CCBlendFunc blendFunc = new CCBlendFunc();

            blendFunc.Source      = particleConfig.BlendFunc.Source;
            blendFunc.Destination = particleConfig.BlendFunc.Destination;
            BlendFunc             = blendFunc;

            CCColor4F startColor = new CCColor4F();

            startColor.R = particleConfig.StartColor.R;
            startColor.G = particleConfig.StartColor.G;
            startColor.B = particleConfig.StartColor.B;
            startColor.A = particleConfig.StartColor.A;
            StartColor   = startColor;

            CCColor4F startColorVar = new CCColor4F();

            startColorVar.R = particleConfig.StartColorVar.R;
            startColorVar.G = particleConfig.StartColorVar.G;
            startColorVar.B = particleConfig.StartColorVar.B;
            startColorVar.A = particleConfig.StartColorVar.A;
            StartColorVar   = startColorVar;

            CCColor4F endColor = new CCColor4F();

            endColor.R = particleConfig.EndColor.R;
            endColor.G = particleConfig.EndColor.G;
            endColor.B = particleConfig.EndColor.B;
            endColor.A = particleConfig.EndColor.A;
            EndColor   = endColor;

            CCColor4F endColorVar = new CCColor4F();

            endColorVar.R = particleConfig.EndColorVar.R;
            endColorVar.G = particleConfig.EndColorVar.G;
            endColorVar.B = particleConfig.EndColorVar.B;
            endColorVar.A = particleConfig.EndColorVar.A;
            EndColorVar   = endColorVar;

            StartSize    = particleConfig.StartSize;
            StartSizeVar = particleConfig.StartSizeVar;
            EndSize      = particleConfig.EndSize;
            EndSizeVar   = particleConfig.EndSizeVar;

            CCPoint position;

            position.X = particleConfig.Position.X;
            position.Y = particleConfig.Position.Y;
            Position   = position;

            CCPoint positionVar;

            positionVar.X = particleConfig.PositionVar.X;
            positionVar.Y = particleConfig.PositionVar.X;
            PositionVar   = positionVar;

            StartSpin    = particleConfig.StartSpin;
            StartSpinVar = particleConfig.StartSpinVar;
            EndSpin      = particleConfig.EndSpin;
            EndSpinVar   = particleConfig.EndSpinVar;

            EmitterMode = particleConfig.EmitterMode;

            if (EmitterMode == CCEmitterMode.Gravity)
            {
                GravityParticles = new CCParticleGravity[TotalParticles];

                GravityMoveMode newGravityMode = new GravityMoveMode();

                CCPoint gravity;
                gravity.X = particleConfig.Gravity.X;
                gravity.Y = particleConfig.Gravity.Y;
                newGravityMode.Gravity = gravity;

                newGravityMode.Speed              = particleConfig.GravitySpeed;
                newGravityMode.SpeedVar           = particleConfig.GravitySpeedVar;
                newGravityMode.RadialAccel        = particleConfig.GravityRadialAccel;
                newGravityMode.RadialAccelVar     = particleConfig.GravityRadialAccelVar;
                newGravityMode.TangentialAccel    = particleConfig.GravityTangentialAccel;
                newGravityMode.TangentialAccelVar = particleConfig.GravityTangentialAccelVar;
                newGravityMode.RotationIsDir      = particleConfig.GravityRotationIsDir;

                GravityMode = newGravityMode;
            }
            else if (EmitterMode == CCEmitterMode.Radius)
            {
                RadialParticles = new CCParticleRadial[TotalParticles];

                RadialMoveMode newRadialMode = new RadialMoveMode();

                newRadialMode.StartRadius        = particleConfig.RadialStartRadius;
                newRadialMode.StartRadiusVar     = particleConfig.RadialStartRadiusVar;
                newRadialMode.EndRadius          = particleConfig.RadialEndRadius;
                newRadialMode.EndRadiusVar       = particleConfig.RadialEndRadiusVar;
                newRadialMode.RotatePerSecond    = particleConfig.RadialRotatePerSecond;
                newRadialMode.RotatePerSecondVar = particleConfig.RadialRotatePerSecondVar;

                RadialMode = newRadialMode;
            }
            else
            {
                Debug.Assert(false, "Invalid emitterType in config file");
                return;
            }

            // Don't get the internal texture if a batchNode is used
            if (BatchNode == null)
            {
                Texture = particleConfig.Texture;
            }
        }
Esempio n. 33
0
 public CCQuadCommand(float globalZOrder, CCTexture2D texture, CCBlendFunc blendType, 
     CCV3F_C4B_T2F_Quad quad) 
     : this(globalZOrder, texture, blendType, new CCV3F_C4B_T2F_Quad[] { quad }, 1,
         CCAffineTransform.Identity, 0)
 { }
Esempio n. 34
0
 public CCDrawNode()
 {
     BlendFunc = CCBlendFunc.AlphaBlend;
     triangleVertices = new CCRawList<CCV3F_C4B>(DefaultBufferSize);
     lineVertices = new CCRawList<CCV3F_C4B>(DefaultBufferSize);
 }
Esempio n. 35
0
        public CCParticleSystem(CCParticleSystemConfig particleConfig) : this(particleConfig.MaxParticles, false)
        {
            Duration = particleConfig.Duration;;
            Life = particleConfig.Life;
            LifeVar = particleConfig.LifeVar;
            EmissionRate = TotalParticles / Life;

            Angle = particleConfig.Angle;
            AngleVar = particleConfig.AngleVar;

            CCBlendFunc blendFunc = new CCBlendFunc();
            blendFunc.Source = particleConfig.BlendFunc.Source;
            blendFunc.Destination = particleConfig.BlendFunc.Destination;
            BlendFunc = blendFunc;

            CCColor4F startColor = new CCColor4F();
            startColor.R = particleConfig.StartColor.R;
            startColor.G = particleConfig.StartColor.G;
            startColor.B = particleConfig.StartColor.B;
            startColor.A = particleConfig.StartColor.A;
            StartColor = startColor;

            CCColor4F startColorVar = new CCColor4F();
            startColorVar.R = particleConfig.StartColorVar.R;
            startColorVar.G = particleConfig.StartColorVar.G;
            startColorVar.B = particleConfig.StartColorVar.B;
            startColorVar.A = particleConfig.StartColorVar.A;
            StartColorVar = startColorVar;

            CCColor4F endColor = new CCColor4F();
            endColor.R = particleConfig.EndColor.R;
            endColor.G = particleConfig.EndColor.G;
            endColor.B = particleConfig.EndColor.B;
            endColor.A = particleConfig.EndColor.A;
            EndColor = endColor;

            CCColor4F endColorVar = new CCColor4F();
            endColorVar.R = particleConfig.EndColorVar.R;
            endColorVar.G = particleConfig.EndColorVar.G;
            endColorVar.B = particleConfig.EndColorVar.B;
            endColorVar.A = particleConfig.EndColorVar.A;
            EndColorVar = endColorVar;

            StartSize = particleConfig.StartSize;
            StartSizeVar = particleConfig.StartSizeVar;
            EndSize = particleConfig.EndSize;
            EndSizeVar = particleConfig.EndSizeVar;

            CCPoint position;
            position.X = particleConfig.Position.X;
            position.Y = particleConfig.Position.Y;
            Position = position;

            CCPoint positionVar;
            positionVar.X = particleConfig.PositionVar.X;
            positionVar.Y = particleConfig.PositionVar.X;
            PositionVar = positionVar;

            StartSpin = particleConfig.StartSpin;
            StartSpinVar = particleConfig.StartSpinVar;
            EndSpin = particleConfig.EndSpin;
            EndSpinVar = particleConfig.EndSpinVar;

            EmitterMode = particleConfig.EmitterMode;

            if (EmitterMode == CCEmitterMode.Gravity)
            {
                GravityParticles = new CCParticleGravity[TotalParticles];

                GravityMoveMode newGravityMode = new GravityMoveMode();

                CCPoint gravity;
                gravity.X = particleConfig.Gravity.X;
                gravity.Y = particleConfig.Gravity.Y;
                newGravityMode.Gravity = gravity;

                newGravityMode.Speed = particleConfig.GravitySpeed;
                newGravityMode.SpeedVar = particleConfig.GravitySpeedVar;
                newGravityMode.RadialAccel = particleConfig.GravityRadialAccel;
                newGravityMode.RadialAccelVar = particleConfig.GravityRadialAccelVar;
                newGravityMode.TangentialAccel = particleConfig.GravityTangentialAccel;
                newGravityMode.TangentialAccelVar = particleConfig.GravityTangentialAccelVar;
                newGravityMode.RotationIsDir = particleConfig.GravityRotationIsDir;

                GravityMode = newGravityMode;
            }
            else if (EmitterMode == CCEmitterMode.Radius)
            {
                RadialParticles = new CCParticleRadial[TotalParticles];

                RadialMoveMode newRadialMode = new RadialMoveMode();

                newRadialMode.StartRadius = particleConfig.RadialStartRadius;
                newRadialMode.StartRadiusVar = particleConfig.RadialStartRadiusVar;
                newRadialMode.EndRadius = particleConfig.RadialEndRadius;
                newRadialMode.EndRadiusVar = particleConfig.RadialEndRadiusVar;
                newRadialMode.RotatePerSecond = particleConfig.RadialRotatePerSecond;
                newRadialMode.RotatePerSecondVar = particleConfig.RadialRotatePerSecondVar;

                RadialMode = newRadialMode;
            }
            else
            {
                Debug.Assert(false, "Invalid emitterType in config file");
                return;
            }

            // Don't get the internal texture if a batchNode is used
            if (BatchNode == null)
                Texture = particleConfig.Texture;
        }
Esempio n. 36
0
 public CCDrawNode()
 {
     BlendFunc = CCBlendFunc.AlphaBlend;
     triangleVertices = new CCRawList<VertexPositionColor>(DefaultBufferSize);
     lineVertices = new CCRawList<VertexPositionColor>(DefaultBufferSize);
 }
 public CCQuadCommand(float globalDepth, CCAffineTransform worldTransform,
                      CCTexture2D texture, CCBlendFunc blendType,
                      params CCV3F_C4B_T2F_Quad[] quads)
     : this(globalDepth, worldTransform, texture, blendType, quads.Length, quads)
 {
 }
Esempio n. 38
0
 public CCQuadCommand(float globalZOrder, CCTexture2D texture, CCBlendFunc blendType,
                      CCV3F_C4B_T2F_Quad[] quads)
     : this(globalZOrder, texture, blendType, quads, quads.Length, CCAffineTransform.Identity, 0)
 {
 }
Esempio n. 39
0
 public CCQuadCommand(float globalZOrder, CCTexture2D texture, CCBlendFunc blendType,
                      CCV3F_C4B_T2F_Quad quad, CCAffineTransform modelViewTransform, int flags = 0)
     : this(globalZOrder, texture, blendType, new CCV3F_C4B_T2F_Quad[] { quad }, 1,
            modelViewTransform, flags)
 {
 }
Esempio n. 40
0
 public CCDrawNode()
 {
     BlendFunc        = CCBlendFunc.AlphaBlend;
     triangleVertices = new CCRawList <CCV3F_C4B>(DefaultBufferSize);
     lineVertices     = new CCRawList <CCV3F_C4B>(DefaultBufferSize);
 }
Esempio n. 41
0
 public CCQuadCommand(float globalZOrder, CCTexture2D texture, CCBlendFunc blendType,
                      CCV3F_C4B_T2F_Quad quad)
     : this(globalZOrder, texture, blendType, new CCV3F_C4B_T2F_Quad[] { quad }, 1,
            CCAffineTransform.Identity, 0)
 {
 }
Esempio n. 42
0
        public override void OnEnter()
        {
            base.OnEnter();

            Color = CCColor3B.Black;
            RemoveChild(Background, true);
            Background = null;

            Emitter = new CCParticleSystemQuad("Particles/BoilingFoam");

            // Particle Designer "normal" blend func causes black halo on premul textures (ignores multiplication)
            //this->emitter.blendFunc = (ccBlendFunc){ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA };

            // Cocos2d "normal" blend func for premul causes alpha to be ignored (oversaturates colors)
            var tBlendFunc = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE_MINUS_SRC_ALPHA);
            Emitter.BlendFunc = tBlendFunc;

            //Debug.Assert(Emitter.OpacityModifyRGB, "Particle texture does not have premultiplied alpha, test is useless");

            // Toggle next line to see old behavior
            //  this->emitter.opacityModifyRGB = NO;

            Emitter.StartColor = new CCColor4F(1, 1, 1, 1);
            Emitter.EndColor = new CCColor4F(1, 1, 1, 0);
            Emitter.StartColorVar = new CCColor4F(0, 0, 0, 0);
            Emitter.EndColorVar = new CCColor4F(0, 0, 0, 0);

            AddChild(Emitter, 10);
        }
Esempio n. 43
0
 public CCDrawNode()
 {
     BlendFunc        = CCBlendFunc.AlphaBlend;
     triangleVertices = new CCRawList <VertexPositionColor>(DefaultBufferSize);
     lineVertices     = new CCRawList <VertexPositionColor>(DefaultBufferSize);
 }