123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- //
- // ShapeModule.h
- // cocos2d_libs
- //
- // Created by 徐俊杰 on 2020/4/24.
- //
- #ifndef ShapeModule_h
- #define ShapeModule_h
- //#include "cocos2d.h"
- #include "rparticle/Macros/RParticleMacros.h"
- //#include "Runtime/BaseClasses/BaseObject.h"
- #include "rparticle/Modules/ParticleSystemModule.h"
- #include "rparticle/Math/Random/rand.h"
- //#include "Runtime/Utilities/LinkedList.h"
- NS_RRP_BEGIN
- struct MeshTriangleData
- {
- float area;
- UInt16 indices[3];
- };
- struct ParticleSystemEmitterMeshVertex
- {
- Vector3f position;
- Vector3f normal;
- ColorRGBA32 color;
- };
- class Mesh;
- class ShapeModule : public ParticleSystemModule
- {
- public:
- DECLARE_MODULE (ShapeModule)
- ShapeModule ();
-
- enum MeshPlacementMode { kVertex, kEdge, kTriangle, kModeMax };
- enum { kSphere, kSphereShell, kHemiSphere, kHemiSphereShell, kCone, kBox, kMesh, kConeShell, kConeVolume, kConeVolumeShell, kCircle, kCircleEdge, kMax };
-
- void AwakeFromLoad (RParticleSystem* system, const ParticleSystemReadOnlyState& roState);
- void ResetSeed(const ParticleSystemReadOnlyState& roState);
- void DidModifyMeshData ();
- void DidDeleteMesh (RParticleSystem* system);
-
- //TODO: Mesh stuff
- // PPtr<Mesh> GetMeshEmitterShape () { return m_Mesh; }
-
- void Start (const ParticleSystemReadOnlyState& roState, const ParticleSystemState& state, ParticleSystemParticles& ps, const Matrix4x4f& matrix, size_t fromIndex, float t);
- void CalculateProceduralBounds(MinMaxAABB& bounds, const Vector3f& emitterScale, Vector2f minMaxBounds) const;
- void CheckConsistency ();
-
- // inline void SetShapeType(int type) { m_Type = type; };
- // inline void SetRadius(float radius) { m_Radius = radius; };
- inline int GetType() const { return m_Type; }
- inline void SetType(int value) { m_Type = value; }
- inline float GetRadius() const { return m_Radius; }
- inline void SetRadius(float value) { m_Radius = value; }
- inline float GetRadiusThickness() const { return m_RadiusThickness; }
- inline void SetRadiusThickness(float value) { m_RadiusThickness = value; }
- inline float GetAngle() const { return m_Angle; }
- inline void SetAngle(float value) { m_Angle = value; }
- inline float GetLength() const { return m_Length; }
- inline void SetLength(float value) { m_Length = value; }
- inline float GetArc() const { return m_Arc; }
- inline void SetArc(float value) { m_Arc = value; }
- inline bool GetBurstSpread() const { return m_BurstSpread; }
- inline void SetBurstSpread(bool value) { m_BurstSpread = value; }
- inline float GetSpreadSpaceThickness() const { return m_SpreadSpaceThickness; }
- inline void SetSpreadSpaceThickness(float value) { m_SpreadSpaceThickness = value; }
- inline float GetBoxX() const { return m_BoxX; }
- inline void SetBoxX(float value) { m_BoxX = value; }
- inline float GetBoxY() const { return m_BoxY; }
- inline void SetBoxY(float value) { m_BoxY = value; }
- inline float GetBoxZ() const { return m_BoxZ; }
- inline void SetBoxZ(float value) { m_BoxZ = value; }
- inline bool GetRandomDirection() const { return m_RandomDirection; }
- inline void SetRandomDirection(bool value) { m_RandomDirection = value; }
-
- template<class TransferFunction>
- void Transfer (TransferFunction& transfer);
-
- private:
- Rand& GetRandom();
-
- int m_Type;
-
- // Primitive stuff
- float m_Radius;
- float m_RadiusThickness;
- float m_Angle;
- float m_Length;
- float m_Arc;
- bool m_BurstSpread;
- float m_SpreadSpaceThickness;
- float m_BoxX;
- float m_BoxY;
- float m_BoxZ;
-
- //TODO: Mesh stuff
- /*
- // Mesh stuff
- int m_PlacementMode;
- PPtr<Mesh> m_Mesh;
- Mesh* m_CachedMesh;
- dynamic_array<ParticleSystemEmitterMeshVertex> m_CachedVertexData;
- dynamic_array<MeshTriangleData> m_CachedTriangleData;
- float m_CachedTotalTriangleArea;
- ListNode<Object> m_MeshNode;
- */
-
- bool m_RandomDirection;
- Rand m_Random;
- #if UNITY_EDITOR
- public:
- Rand m_EditorRandom;
- #endif
- };
- NS_RRP_END
- #endif /* ShapeModule_h */
|