Coverage Report

Created: 2025-07-18 07:08

/src/ogre/PlugIns/ParticleFX/include/OgreTextureAnimatorAffector.h
Line
Count
Source (jump to first uncovered line)
1
// This file is part of the OGRE project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at https://www.ogre3d.org/licensing.
4
// SPDX-License-Identifier: MIT
5
#ifndef __TextureAnimatorAffector_H__
6
#define __TextureAnimatorAffector_H__
7
8
#include "OgreParticleFXPrerequisites.h"
9
#include "OgreParticleAffector.h"
10
#include "OgreStringInterface.h"
11
#include "OgreParticleAffectorFactory.h"
12
13
namespace Ogre {
14
    /** \addtogroup Plugins
15
    *  @{
16
    */
17
    /** \addtogroup ParticleFX
18
    *  @{
19
    */
20
21
  /** This affector makes it possible to have an animated texture for each individual particle.
22
    */
23
    class TextureAnimatorAffector : public ParticleAffector
24
    {
25
    public:
26
        TextureAnimatorAffector(ParticleSystem* psys);
27
28
        void _affectParticles(ParticleSystem* pSystem, Real timeElapsed) override;
29
30
        void _initParticle(Particle* pParticle) override;
31
32
        /** Sets the texcoord index at which the animation should start
33
         *
34
         * default: 0
35
         */
36
0
        void setTexcoordStart(uint8 start) { mTexcoordStart = start; }
37
0
        uint8 getTexcoordStart(void) const { return mTexcoordStart; }
38
39
        /** Sets the number of texcoords to use.
40
         * @note you must set this one and start + count must not exceed the number of frames in the sprite sheet
41
         */
42
0
        void setTexcoordCount(uint8 count) { mTexcoordCount = count; }
43
0
        uint8 getTexcoordCount(void) const { return mTexcoordCount; }
44
        /** The length of time it takes to display the whole animation sequence, in seconds.
45
         *
46
         * If set to 0 (default) the duration equals the particle time to live. Using a different value here,
47
         * you can play back the animation faster (looping) or slower.
48
         * When negative, the animation is disabled. This is useful to just pick a random sprite (see below) and keep it.
49
         */
50
0
        void setDuration(float duration) { mDuration = duration; }
51
0
        float getDuration(void) const { return mDuration; }
52
53
        /** Start animation at random frame in the texture sheet. Useful to randomly phase the animation between particles.
54
         */
55
0
        void useRandomStartOffset(float enable) { mRandomStartOffset = enable; }
56
0
        float isRandomStartOffset(void) const { return mRandomStartOffset; }
57
    protected:
58
        bool mRandomStartOffset;
59
        uint8 mTexcoordStart;
60
        uint8 mTexcoordCount;
61
        float mDuration;
62
    };
63
64
    /** Factory class for TextureAnimatorAffector. */
65
    class TextureAnimatorAffectorFactory : public ParticleAffectorFactory
66
    {
67
1
        String getName() const override { return "TextureAnimator"; }
68
69
0
        ParticleAffector* createAffector(ParticleSystem* psys) override { return new TextureAnimatorAffector(psys); }
70
    };
71
72
    /** @} */
73
    /** @} */
74
}
75
76
#endif