forked from bobsayshilol/engine-sim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcrankshaft_object.cpp
More file actions
67 lines (54 loc) · 1.86 KB
/
crankshaft_object.cpp
File metadata and controls
67 lines (54 loc) · 1.86 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
#include "../include/crankshaft_object.h"
#include "../include/cylinder_bank.h"
#include "../include/engine_sim_application.h"
CrankshaftObject::CrankshaftObject() {
m_crankshaft = nullptr;
}
CrankshaftObject::~CrankshaftObject() {
/* void */
}
void CrankshaftObject::generateGeometry() {
/* void */
}
void CrankshaftObject::render(const ViewParameters *view) {
const int journalCount = m_crankshaft->getRodJournalCount();
for (int i = 0; i < journalCount; ++i) {
const int layer = i;
if (layer > view->Layer1 || layer < view->Layer0) continue;
const ysVector col = tintByLayer(ysColor::srgbiToLinear(0xAAAAAA), layer - view->Layer0);
resetShader();
setTransform(
&m_crankshaft->m_body,
(float)m_crankshaft->getThrow(),
0.0f,
0.0f,
(float)m_crankshaft->getRodJournalAngle(i));
m_app->getShaders()->SetBaseColor(col);
m_app->getEngine()->DrawModel(
m_app->getShaders()->GetRegularFlags(),
m_app->getAssetManager()->GetModelAsset("Crankshaft"),
0x32 - layer);
}
setTransform(
&m_crankshaft->m_body,
(float)m_crankshaft->getThrow(),
0.0f,
0.0f,
0.0f);
m_app->getShaders()->SetBaseColor(tintByLayer(ysColor::srgbiToLinear(0xFFFFFF), 1));
m_app->getEngine()->DrawModel(
m_app->getShaders()->GetRegularFlags(),
m_app->getAssetManager()->GetModelAsset("CrankSnout"),
0x32);
m_app->getShaders()->SetBaseColor(tintByLayer(ysColor::srgbiToLinear(0xAAAAAA), 1));
m_app->getEngine()->DrawModel(
m_app->getShaders()->GetRegularFlags(),
m_app->getAssetManager()->GetModelAsset("CrankSnoutThreads"),
0x32);
}
void CrankshaftObject::process(float dt) {
/* void */
}
void CrankshaftObject::destroy() {
/* void */
}