~ubuntu-branches/ubuntu/oneiric/blobandconquer/oneiric

« back to all changes in this revision

Viewing changes to src/cplusplus/CDecal.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Guus Sliepen
  • Date: 2008-06-15 12:04:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080615120429-5ss7cbb4z9mpywj5
Tags: 0.95-1
New upstream release. Closes: #486310

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 2006 Parallel Realities
 
3
 
 
4
This program is free software; you can redistribute it and/or
 
5
modify it under the terms of the GNU General Public License
 
6
as published by the Free Software Foundation; either version 2
 
7
of the License, or (at your option) any later version.
 
8
 
 
9
This program is distributed in the hope that it will be useful,
 
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
12
 
 
13
See the GNU General Public License for more details.
 
14
 
 
15
You should have received a copy of the GNU General Public License
 
16
along with this program; if not, write to the Free Software
 
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
18
 
 
19
*/
 
20
 
 
21
#include "../headers.h"
 
22
 
 
23
Decal::Decal()
 
24
{
 
25
        remove = false;
 
26
        alternativeBlend = false;
 
27
        type = 0;
 
28
        health = 150;
 
29
        texture = NULL;
 
30
        cluster = -1;
 
31
        
 
32
        x1 = y1 = x2 = y2 = 0;
 
33
        
 
34
        uv1 = 0;
 
35
        uv2 = 0;
 
36
        uv3 = 1;
 
37
        uv4 = 1;
 
38
}
 
39
 
 
40
Decal::~Decal()
 
41
{
 
42
}
 
43
 
 
44
void Decal::rotate(Vector normal)
 
45
{
 
46
        rotation.x = toDegrees(asin(normal.x));
 
47
        rotation.y = toDegrees(-asin(normal.y));
 
48
        rotation.z = toDegrees(asin(normal.z));
 
49
}
 
50
 
 
51
void Decal::load(Properties *props)
 
52
{
 
53
        alternativeBlend = props->getInt("alternativeBlend", alternativeBlend);
 
54
        type = props->getInt("type", type);
 
55
        health = props->getFloat("health", health);
 
56
        color = props->getColor("color");
 
57
        position = props->getVector("position", position);
 
58
        rotation = props->getVector("rotation", rotation);
 
59
        cluster = props->getInt("cluster", cluster);
 
60
        x1 = props->getFloat("x1", x1);
 
61
        y1 = props->getFloat("y1", y1);
 
62
        x2 = props->getFloat("x2", x2);
 
63
        y2 = props->getFloat("y2", y2);
 
64
        uv1 = props->getFloat("uv1", uv1);
 
65
        uv2 = props->getFloat("uv2", uv2);
 
66
        uv3 = props->getFloat("uv3", uv3);
 
67
        uv4 = props->getFloat("uv4", uv4);
 
68
}
 
69
 
 
70
void Decal::save(FILE *fp)
 
71
{
 
72
        Properties props;
 
73
        
 
74
        props.setName("Decal");
 
75
        
 
76
        props.setProperty("type", type);
 
77
        props.setProperty("alternativeBlend", alternativeBlend);
 
78
        props.setProperty("health", health);
 
79
        props.setProperty("color", color);
 
80
        props.setProperty("position", position);
 
81
        props.setProperty("rotation", rotation);
 
82
        props.setProperty("cluster", cluster);
 
83
        props.setProperty("x1", x1);
 
84
        props.setProperty("y1", y1);
 
85
        props.setProperty("x2", x2);
 
86
        props.setProperty("y2", y2);
 
87
        props.setProperty("uv1", uv1);
 
88
        props.setProperty("uv2", uv2);
 
89
        props.setProperty("uv3", uv3);
 
90
        props.setProperty("uv4", uv4);
 
91
        
 
92
        props.save(fp);
 
93
}