summaryrefslogtreecommitdiff
path: root/2d/softbody/softbody_1/main.cpp
blob: 355ba1cde9227f878e3dc1fd8e27419d5cf8ed3a (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
#include "undamped.h"
#include "damped.h"
#include "../../../shared_cpp/WebglContext.h"

WebglContext context;

int main() {
    Damped::init(&context);
    Undamped::init(&context);
    return 0;
}


//
// Interactions with DOM handled below
//

extern "C" {
	// -- Undamped
    EMSCRIPTEN_KEEPALIVE void Undamped_SetLength(float length) {
        Undamped::UndampedInitVariables initVariables = Undamped::getInitVariables();
        initVariables.springLength = length;
        Undamped::setInitVariables(initVariables);
    }

    EMSCRIPTEN_KEEPALIVE void Undamped_SetDisplacement(float displacement) {
        Undamped::UndampedInitVariables initVariables = Undamped::getInitVariables();
        initVariables.initialDisplacement = displacement;
        Undamped::setInitVariables(initVariables);
    }

    EMSCRIPTEN_KEEPALIVE void Undamped_SetK(float k) {
        Undamped::UndampedInitVariables initVariables = Undamped::getInitVariables();
        initVariables.k = k;
        Undamped::setInitVariables(initVariables);
    }
    
    EMSCRIPTEN_KEEPALIVE void Undamped_SetMass(float mass) {
        Undamped::UndampedInitVariables initVariables = Undamped::getInitVariables();
        initVariables.mass = mass;
        Undamped::setInitVariables(initVariables);
    }

	// -- Damped
    EMSCRIPTEN_KEEPALIVE void Damped_SetLength(float length) {
        Damped::DampedInitVariables initVariables = Damped::getInitVariables();
        initVariables.springLength = length;
        Damped::setInitVariables(initVariables);
    }

    EMSCRIPTEN_KEEPALIVE void Damped_SetDisplacement(float displacement) {
        Damped::DampedInitVariables initVariables = Damped::getInitVariables();
        initVariables.initialDisplacement = displacement;
        Damped::setInitVariables(initVariables);
    }

    EMSCRIPTEN_KEEPALIVE void Damped_SetK(float k) {
        Damped::DampedInitVariables initVariables = Damped::getInitVariables();
        initVariables.k = k;
        Damped::setInitVariables(initVariables);
    }
    
    EMSCRIPTEN_KEEPALIVE void Damped_SetMass(float mass) {
        Damped::DampedInitVariables initVariables = Damped::getInitVariables();
        initVariables.mass = mass;
        Damped::setInitVariables(initVariables);
    }

	EMSCRIPTEN_KEEPALIVE void Damped_SetC(float c) {
        Damped::DampedInitVariables initVariables = Damped::getInitVariables();
        initVariables.c = c;
        Damped::setInitVariables(initVariables);
    }
}