summaryrefslogtreecommitdiff
path: root/src/simulation/elements/GRAV.cpp
blob: b913a282d45f8427ea2a2eb4814daf612c5f1d83 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_GRAV PT_GRAV 102
Element_GRAV::Element_GRAV()
{
    Identifier = "DEFAULT_PT_GRAV";
    Name = "GRAV";
    Colour = PIXPACK(0xFFE0A0);
    MenuVisible = 1;
    MenuSection = SC_POWDERS;
    Enabled = 1;
    
    Advection = 0.7f;
    AirDrag = 0.00f * CFDS;
    AirLoss = 1.00f;
    Loss = 1.00f;
    Collision = 0.0f;
    Gravity = 0.0f;
    Diffusion = 0.00f;
    HotAir = 0.000f	* CFDS;
    Falldown = 1;
    
    Flammable = 10;
    Explosive = 0;
    Meltable = 0;
    Hardness = 30;
    
    Weight = 85;
    
    Temperature = R_TEMP+0.0f	+273.15f;
    HeatConduct = 70;
    Description = "Very light dust. Changes colour based on velocity.";
    
    State = ST_SOLID;
    Properties = TYPE_PART;
    
    LowPressure = IPL;
    LowPressureTransition = NT;
    HighPressure = IPH;
    HighPressureTransition = NT;
    LowTemperature = ITL;
    LowTemperatureTransition = NT;
    HighTemperature = ITH;
    HighTemperatureTransition = NT;
    
    Update = &Element_GRAV::update;
    Graphics = &Element_GRAV::graphics;
}

//#TPT-Directive ElementHeader Element_GRAV static int update(UPDATE_FUNC_ARGS)
int Element_GRAV::update(UPDATE_FUNC_ARGS)
 {
	/*int t = parts[i].type;
	if (t==PT_LOVE)
		ISLOVE=1;
	else if (t==PT_LOLZ)
		ISLOLZ=1;
	else if (t==PT_GRAV)
		ISGRAV=1;*/
	return 0;
}

int lastIndex;

//#TPT-Directive ElementHeader Element_GRAV static int graphics(GRAPHICS_FUNC_ARGS)
int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS)

{
	int GRAV_R, GRAV_B, GRAV_G, GRAV_R2, GRAV_B2, GRAV_G2;

	GRAV_R = std::abs((ren->sim->currentTick%120)-60);
	GRAV_G = std::abs(((ren->sim->currentTick+60)%120)-60);
	GRAV_B = std::abs(((ren->sim->currentTick+120)%120)-60);
	GRAV_R2 = std::abs((ren->sim->currentTick%60)-30);
	GRAV_G2 = std::abs(((ren->sim->currentTick+30)%60)-30);
	GRAV_B2 = std::abs(((ren->sim->currentTick+60)%60)-30);


	*colr = 20;
	*colg = 20;
	*colb = 20;
	if (cpart->vx>0)
	{
		*colr += (cpart->vx)*GRAV_R;
		*colg += (cpart->vx)*GRAV_G;
		*colb += (cpart->vx)*GRAV_B;
	}
	if (cpart->vy>0)
	{
		*colr += (cpart->vy)*GRAV_G;
		*colg += (cpart->vy)*GRAV_B;
		*colb += (cpart->vy)*GRAV_R;

	}
	if (cpart->vx<0)
	{
		*colr -= (cpart->vx)*GRAV_B;
		*colg -= (cpart->vx)*GRAV_R;
		*colb -= (cpart->vx)*GRAV_G;

	}
	if (cpart->vy<0)
	{
		*colr -= (cpart->vy)*GRAV_R2;
		*colg -= (cpart->vy)*GRAV_G2;
		*colb -= (cpart->vy)*GRAV_B2;
	}
	return 0;
}


Element_GRAV::~Element_GRAV() {}