-
Notifications
You must be signed in to change notification settings - Fork 0
/
grass.cpp
46 lines (38 loc) · 960 Bytes
/
grass.cpp
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
#include "grass.hpp"
#include <stdio.h>
#include <math.h>
Grass::Grass(string path, Loader* loader, btVector3 pos, double r)
: Object(path, loader){
this->path = path;
this->loader = loader;
this->r = r;
receives_shadows = 0;
}
Grass::Grass(string path)
: Object(path){
this->path = path;
this->r = 1;
receives_shadows = 0;
}
void Grass::render_texture(){
Object::render_texture();
}
void Grass::render_glass(int* order){
glDisable(GL_CULL_FACE);
Object::render_glass(this->order);
glEnable(GL_CULL_FACE);
}
void Grass::sort_groups(){
btVector3 v = world->camera->get_obs_pos() - get_position();
v.normalize();
btScalar angle = atan2(v.getX(), v.getZ()) / (1.0467) + 3;
int left = (int)(6 - (int)angle) % 6, right;
right = (left + 1) % 6;
int f_pos[] = { (left-2 + 6)%6, (right+2)%6, (left-1 +6 )%6, (right+1)%6, left, right };
order[0] = 0;
for(int i=0; i<6; i++){
if(f_pos[i] == 0)
f_pos[i] = 6;
order[i+1] = f_pos[i];
}
}