~ubuntu-branches/ubuntu/natty/spring/natty

« back to all changes in this revision

Viewing changes to rts/Sim/Projectiles/Unsynced/DirtProjectile.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Ritchie
  • Date: 2010-09-23 18:56:03 UTC
  • mfrom: (3.1.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100923185603-st97s5chplo42y7w
Tags: 0.82.5.1+dfsg1-1ubuntu1
* Latest upstream version for online play
* debian/control: Replace (rather than conflict) spring-engine
  - spring-engine will be a dummy package (LP: #612905)
  - also set maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
 
2
 
1
3
#include "StdAfx.h"
2
 
// DirtProjectile.cpp: implementation of the CDirtCloudProjectile class.
3
 
//
4
 
//////////////////////////////////////////////////////////////////////
5
4
#include "mmgr.h"
6
5
 
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"
13
14
 
14
15
CR_BIND_DERIVED(CDirtProjectile, CProjectile, );
15
16
 
31
32
// Construction/Destruction
32
33
//////////////////////////////////////////////////////////////////////
33
34
 
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),
36
37
        alpha(255),
37
38
        size(size),
38
39
        sizeExpansion(expansion),
41
42
{
42
43
        checkCol = false;
43
44
        alphaFalloff = 255 / ttl;
44
 
        texture = &ph->randdotstex;
 
45
        texture = projectileDrawer->randdotstex;
45
46
}
46
47
 
47
48
CDirtProjectile::CDirtProjectile() :
53
54
        slowdown(1.0f)
54
55
{
55
56
        checkCol = false;
56
 
        texture = &ph->randdotstex;
 
57
        texture = projectileDrawer->randdotstex;
57
58
}
58
59
 
59
60
CDirtProjectile::~CDirtProjectile()
78
79
 
79
80
void CDirtProjectile::Draw()
80
81
{
81
 
        float partAbove=(pos.y/(size*camera->up.y));
82
 
        if(partAbove<-1)
 
82
        float partAbove = (pos.y / (size * camera->up.y));
 
83
        if (partAbove < -1) {
83
84
                return;
84
 
        else if(partAbove>1)
85
 
                partAbove=1;
86
 
        inArray=true;
 
85
        } else if (partAbove > 1) {
 
86
                partAbove = 1;
 
87
        }
 
88
        inArray = true;
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*/;
92
 
 
93
 
        float interSize=size+gu->timeOffset*sizeExpansion;
94
 
        float texx = texture->xstart + (texture->xend-texture->xstart)*((1-partAbove)*0.5f);//0.25f*(1-partAbove)
95
 
 
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*/;
 
94
 
 
95
        const float interSize = size + globalRendering->timeOffset * sizeExpansion;
 
96
        const float texx = texture->xstart + (texture->xend - texture->xstart) * ((1.0f - partAbove) * 0.5f);
 
97
 
 
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);
100
102
}