-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeaf.h
More file actions
83 lines (77 loc) · 1.73 KB
/
Leaf.h
File metadata and controls
83 lines (77 loc) · 1.73 KB
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
#ifndef _LEAF_H
#define _LEAF_H
#include <cstring>
#include <fstream>
#include <iostream>
class Leaf {
#define MAXPATHLEN 256
#define TEXPATH_DEFAULT "textures/leaf0_256.bmp"
void initDefaults() {
strcpy(leafTexPath,TEXPATH_DEFAULT);
leafTexInitialized=LEAFTEXINITIALIZED_DEFAULT;
active=ACTIVE_DEFAULT;
leafSize=LEAFSIZE_DEFAULT;
sizeDeriviation=SIZEDERIVIATION_DEFAULT;
amount=AMOUNT_DEFAULT;
petiole.x=0.5;
petiole.y=1;
}
public:
char leafTexPath[MAXPATHLEN];
bool leafTexInitialized;
bool active;
float leafSize;
float sizeDeriviation;
float amount;
unsigned int texId; //opengl texture binding id
unsigned int maskId; //opengl mask texture binding id
Point2d petiole;//polozenie szypulki na teksturze (0-1)(0-1)
static const bool LEAFTEXINITIALIZED_DEFAULT=FALSE;
static const bool ACTIVE_DEFAULT=FALSE;
static const float LEAFSIZE_DEFAULT=1.0f;
static const float SIZEDERIVIATION_DEFAULT=0.0f;
static const float AMOUNT_DEFAULT=0.0f;
Leaf() {
initDefaults();
}
Leaf(char *path) {
initDefaults();
setLeafPath(path);
}
void setLeafPath(char *path) {
assert(strlen(path)<MAXPATHLEN);
strcpy(leafTexPath,path);
}
/* Returns texture name without dirs names*/
char *getTexName() {
char *p=strrchr(leafTexPath,'/');
if(p==NULL)
return p;
return p+1;
}
/* Serialization methods */
void save(ofstream &s)
{
#define SAVE(param) s<<param<<endl;
SAVE(leafTexPath);
SAVE(leafSize);
SAVE(sizeDeriviation);
SAVE(amount);
petiole.save(s);
#undef SAVE
}
void load(ifstream &s)
{
leafTexInitialized=FALSE;
#define LOAD(param) s>>param;
LOAD(leafTexPath);
LOAD(leafSize);
LOAD(sizeDeriviation);
LOAD(amount);
petiole.load(s);
#undef LOAD
}
};
#undef MAXPATHLEN
#undef TEXPATH_DEFAULT
#endif