1
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2
// DirtProjectile.cpp: implementation of the CDirtCloudProjectile class.
4
//////////////////////////////////////////////////////////////////////
7
6
#include "DirtProjectile.h"
8
7
#include "Game/Camera.h"
9
8
#include "Map/Ground.h"
9
#include "Rendering/GlobalRendering.h"
10
#include "Rendering/ProjectileDrawer.hpp"
10
11
#include "Rendering/GL/VertexArray.h"
11
#include "Sim/Projectiles/ProjectileHandler.h"
12
#include "GlobalUnsynced.h"
12
#include "Rendering/Textures/TextureAtlas.h"
13
#include "System/GlobalUnsynced.h"
14
15
CR_BIND_DERIVED(CDirtProjectile, CProjectile, );
31
32
// Construction/Destruction
32
33
//////////////////////////////////////////////////////////////////////
34
CDirtProjectile::CDirtProjectile(const float3 pos, const float3 speed, const float ttl, const float size, const float expansion, float slowdown, CUnit* owner, const float3& color GML_PARG_C):
35
CProjectile(pos, speed, owner, false, false, false GML_PARG_P),
35
CDirtProjectile::CDirtProjectile(const float3 pos, const float3 speed, const float ttl, const float size, const float expansion, float slowdown, CUnit* owner, const float3& color):
36
CProjectile(pos, speed, owner, false, false, false),
38
39
sizeExpansion(expansion),
79
80
void CDirtProjectile::Draw()
81
float partAbove=(pos.y/(size*camera->up.y));
82
float partAbove = (pos.y / (size * camera->up.y));
85
} else if (partAbove > 1) {
87
89
unsigned char col[4];
88
col[0]=(unsigned char) (color.x*alpha);
89
col[1]=(unsigned char) (color.y*alpha);
90
col[2]=(unsigned char) (color.z*alpha);
91
col[3]=(unsigned char) (alpha)/*-gu->timeOffset*alphaFalloff*/;
93
float interSize=size+gu->timeOffset*sizeExpansion;
94
float texx = texture->xstart + (texture->xend-texture->xstart)*((1-partAbove)*0.5f);//0.25f*(1-partAbove)
96
va->AddVertexTC(drawPos-camera->right*interSize-camera->up*interSize*partAbove,texx,texture->ystart,col);
97
va->AddVertexTC(drawPos+camera->right*interSize-camera->up*interSize*partAbove,texx,texture->yend,col);
98
va->AddVertexTC(drawPos+camera->right*interSize+camera->up*interSize,texture->xend,texture->yend,col);
99
va->AddVertexTC(drawPos-camera->right*interSize+camera->up*interSize,texture->xend,texture->ystart,col);
90
col[0] = (unsigned char) (color.x*alpha);
91
col[1] = (unsigned char) (color.y*alpha);
92
col[2] = (unsigned char) (color.z*alpha);
93
col[3] = (unsigned char) (alpha)/*-globalRendering->timeOffset*alphaFalloff*/;
95
const float interSize = size + globalRendering->timeOffset * sizeExpansion;
96
const float texx = texture->xstart + (texture->xend - texture->xstart) * ((1.0f - partAbove) * 0.5f);
98
va->AddVertexTC(drawPos - camera->right * interSize - camera->up * interSize * partAbove, texx, texture->ystart, col);
99
va->AddVertexTC(drawPos + camera->right * interSize - camera->up * interSize * partAbove, texx, texture->yend, col);
100
va->AddVertexTC(drawPos + camera->right * interSize + camera->up * interSize, texture->xend, texture->yend, col);
101
va->AddVertexTC(drawPos - camera->right * interSize + camera->up * interSize, texture->xend, texture->ystart, col);