forked from bobsayshilol/engine-sim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconnecting_rod_object.cpp
More file actions
60 lines (47 loc) · 1.82 KB
/
connecting_rod_object.cpp
File metadata and controls
60 lines (47 loc) · 1.82 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
#include "../include/connecting_rod_object.h"
#include "../include/engine_sim_application.h"
#include "../include/units.h"
ConnectingRodObject::ConnectingRodObject() {
m_connectingRod = nullptr;
}
ConnectingRodObject::~ConnectingRodObject() {
/* void */
}
void ConnectingRodObject::generateGeometry() {
GeometryGenerator *gen = m_app->getGeometryGenerator();
GeometryGenerator::Line2dParameters params;
params.x0 = params.x1 = 0;
params.y0 = (float)(m_connectingRod->getBigEndLocal() + m_connectingRod->getCrankshaft()->getThrow() * 0.6);
params.y1 = (float)m_connectingRod->getLittleEndLocal();
params.lineWidth = (float)(m_connectingRod->getCrankshaft()->getThrow() * 0.5);
gen->startShape();
gen->generateLine2d(params);
gen->endShape(&m_connectingRodBody);
}
void ConnectingRodObject::render(const ViewParameters *view) {
const int layer = m_connectingRod->getJournal();
if (layer > view->Layer1 || layer < view->Layer0) return;
ysVector col = m_connectingRod->getPiston()->getCylinderBank()->getIndex() % 2 == 0
? ysColor::srgbiToLinear(0xEEEEEE)
: ysColor::srgbiToLinear(0xDDDDDD);
col = tintByLayer(col, layer - view->Layer0);
resetShader();
setTransform(
&m_connectingRod->m_body,
(float)m_connectingRod->getCrankshaft()->getThrow(),
0.0f,
(float)m_connectingRod->getBigEndLocal());
m_app->getShaders()->SetBaseColor(col);
m_app->getEngine()->DrawModel(
m_app->getShaders()->GetRegularFlags(),
m_app->getAssetManager()->GetModelAsset("ConnectingRod"),
0x32 - layer);
setTransform(&m_connectingRod->m_body);
m_app->drawGenerated(m_connectingRodBody, 0x32 - layer);
}
void ConnectingRodObject::process(float dt) {
/* void */
}
void ConnectingRodObject::destroy() {
/* void */
}