File: ProjectileDrawer.h

package info (click to toggle)
spring 98.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 41,928 kB
  • ctags: 60,665
  • sloc: cpp: 356,167; ansic: 39,434; python: 12,228; java: 12,203; awk: 5,856; sh: 1,719; xml: 997; perl: 405; php: 253; objc: 194; makefile: 72; sed: 2
file content (137 lines) | stat: -rw-r--r-- 5,000 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef PROJECTILE_DRAWER_HDR
#define PROJECTILE_DRAWER_HDR

#include "Rendering/GL/myGL.h"
#include <list>
#include <set>

#include "lib/gml/ThreadSafeContainers.h"
#include "Rendering/GL/FBO.h"
#include "Sim/Projectiles/ProjectileFunctors.h"
#include "System/EventClient.h"

class CTextureAtlas;
struct AtlasedTexture;
class CGroundFlash;
struct FlyingPiece;
class IWorldObjectModelRenderer;
class LuaTable;


typedef ThreadListSimRender<std::list<CGroundFlash*>, std::set<CGroundFlash*>, CGroundFlash*> GroundFlashContainer;
typedef ThreadListSimRender<std::set<FlyingPiece*, FlyingPieceComparator>, void, FlyingPiece*> FlyingPieceContainer;


class CProjectileDrawer: public CEventClient {
public:
	CProjectileDrawer();
	~CProjectileDrawer();

	typedef std::set<CProjectile*, ProjectileDistanceComparator> SortedProjectileSet;
	typedef std::list<CProjectile*> UnsortedProjectileList;

	void Draw(bool drawReflection, bool drawRefraction = false);
	void DrawProjectilesMiniMap();
	bool DrawProjectileModel(const CProjectile* projectile, bool shadowPass);
	void DrawGroundFlashes();
	void DrawShadowPass();

	void LoadWeaponTextures();
	void UpdateTextures();

	void Update();


	bool WantsEvent(const std::string& eventName) {
		return (eventName == "RenderProjectileCreated" || eventName == "RenderProjectileDestroyed");
	}
	bool GetFullRead() const { return true; }
	int GetReadAllyTeam() const { return AllAccessTeam; }

	void RenderProjectileCreated(const CProjectile* projectile);
	void RenderProjectileDestroyed(const CProjectile* projectile);

	void IncPerlinTexObjectCount() { perlinTexObjects++; }
	void DecPerlinTexObjectCount() { perlinTexObjects--; }


	CTextureAtlas* textureAtlas;  ///< texture atlas for projectiles
	CTextureAtlas* groundFXAtlas; ///< texture atlas for ground fx

	// texture-coordinates for projectiles
	AtlasedTexture* flaretex;
	AtlasedTexture* dguntex;            ///< dgun texture
	AtlasedTexture* flareprojectiletex; ///< texture used by flares that trick missiles
	AtlasedTexture* sbtrailtex;         ///< default first section of starburst missile trail texture
	AtlasedTexture* missiletrailtex;    ///< default first section of missile trail texture
	AtlasedTexture* muzzleflametex;     ///< default muzzle flame texture
	AtlasedTexture* repulsetex;         ///< texture of impact on repulsor
	AtlasedTexture* sbflaretex;         ///< default starburst  missile flare texture
	AtlasedTexture* missileflaretex;    ///< default missile flare texture
	AtlasedTexture* beamlaserflaretex;  ///< default beam laser flare texture
	AtlasedTexture* explotex;
	AtlasedTexture* explofadetex;
	AtlasedTexture* heatcloudtex;
	AtlasedTexture* circularthingytex;
	AtlasedTexture* bubbletex;          ///< torpedo trail texture
	AtlasedTexture* geosquaretex;       ///< unknown use
	AtlasedTexture* gfxtex;             ///< nanospray texture
	AtlasedTexture* projectiletex;      ///< appears to be unused
	AtlasedTexture* repulsegfxtex;      ///< used by repulsor
	AtlasedTexture* sphereparttex;      ///< sphere explosion texture
	AtlasedTexture* torpedotex;         ///< appears in-game as a 1 texel texture
	AtlasedTexture* wrecktex;           ///< smoking explosion part texture
	AtlasedTexture* plasmatex;          ///< default plasma texture
	AtlasedTexture* laserendtex;
	AtlasedTexture* laserfallofftex;
	AtlasedTexture* randdotstex;
	AtlasedTexture* smoketrailtex;
	AtlasedTexture* waketex;
	AtlasedTexture* perlintex;
	AtlasedTexture* flametex;

	AtlasedTexture* groundflashtex;
	AtlasedTexture* groundringtex;

	AtlasedTexture* seismictex;

	std::vector<const AtlasedTexture*> smoketex;

private:
	void ParseAtlasTextures(const bool, const LuaTable&, std::set<std::string>&, CTextureAtlas*);

	void DrawProjectiles(int modelType, int numFlyingPieces, int* drawnPieces, bool drawReflection, bool drawRefraction);
	void DrawProjectilesSet(std::set<CProjectile*>& projectiles, bool drawReflection, bool drawRefraction);
	void DrawProjectile(CProjectile* projectile, bool drawReflection, bool drawRefraction);
	void DrawProjectilesShadow(int modelType);
	void DrawProjectileShadow(CProjectile* projectile);
	void DrawProjectilesSetShadow(std::set<CProjectile*>& projectiles);
	void DrawFlyingPieces(int modelType, int numFlyingPieces, int* drawnPieces);

	void UpdatePerlin();
	void GenerateNoiseTex(unsigned int tex, int size);

	GLuint perlinTex[8];
	float perlinBlend[4];
	FBO perlinFB;
	int perlinTexObjects;
	bool drawPerlinTex;

	/// projectiles without a model
	std::set<CProjectile*> renderProjectiles;
	/// projectiles with a model
	std::vector<IWorldObjectModelRenderer*> modelRenderers;

	/**
	 * z-sorted set of projectiles without models; used
	 * to render particle effects in back-to-front order
	 */
	SortedProjectileSet zSortedProjectiles;
	UnsortedProjectileList unsortedProjectiles;
};

extern CProjectileDrawer* projectileDrawer;

#endif // PROJECTILE_DRAWER_HDR