-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathicc_loader.cpp
More file actions
57 lines (53 loc) · 2.07 KB
/
icc_loader.cpp
File metadata and controls
57 lines (53 loc) · 2.07 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
#include "icc_loader.h"
#include <stdio.h>
void loadCarProperties(const char* fname, SCarProperties& props, char* carMesh, char* hullMesh, char* wheelMesh)
{
FILE* f = fopen(fname, "r");
if (!f)
{
fprintf(stderr, "Could not open file %s!\n", fname);
return;
}
char type[50];
while (fscanf(f, "%s", &type) > 0)
{
if (!strcmp(type, "WheelPositionFrontLeft")) {
fscanf(f, "%f %f %f", &props.WheelPositionFrontLeft.X, &props.WheelPositionFrontLeft.Y, &props.WheelPositionFrontLeft.Z);
} else if (!strcmp(type, "WheelPositionBackRight")) {
fscanf(f, "%f %f %f", &props.WheelPositionBackRight.X, &props.WheelPositionBackRight.Y, &props.WheelPositionBackRight.Z);
} else if (!strcmp(type, "WheelRestLength")) {
fscanf(f, "%f", &props.WheelRestLength);
} else if (!strcmp(type, "WheelRadius")) {
fscanf(f, "%f", &props.WheelRadius);
} else if (!strcmp(type, "BumperCamera")) {
fscanf(f, "%f %f %f", &props.BumperCamera.X, &props.BumperCamera.Y, &props.BumperCamera.Z);
} else if (!strcmp(type, "MaxSteer")) {
fscanf(f, "%f", &props.MaxSteer);
} else if (!strcmp(type, "SteerSpeed")) {
fscanf(f, "%f", &props.SteerSpeed);
} else if (!strcmp(type, "EngineForce")) {
fscanf(f, "%f", &props.EngineForce);
} else if (!strcmp(type, "BrakeForce")) {
fscanf(f, "%f", &props.BrakeForce);
} else if (!strcmp(type, "Mass")) {
fscanf(f, "%f", &props.Mass);
} else if (!strcmp(type, "SuspensionStiffness")) {
fscanf(f, "%f", &props.SuspensionStiffness);
} else if (!strcmp(type, "SuspensionDamping")) {
fscanf(f, "%f", &props.SuspensionDamping);
} else if (!strcmp(type, "SuspensionCompression")) {
fscanf(f, "%f", &props.SuspensionCompression);
} else if (!strcmp(type, "FrictionSlip")) {
fscanf(f, "%f", &props.FrictionSlip);
} else if (!strcmp(type, "RollInfluence")) {
fscanf(f, "%f", &props.RollInfluence);
} else if (!strcmp(type, "CarMesh")) {
fscanf(f, "%s", carMesh);
} else if (!strcmp(type, "HullMesh")) {
fscanf(f, "%s", hullMesh);
} else if (!strcmp(type, "WheelMesh")) {
fscanf(f, "%s", wheelMesh);
}
}
fclose(f);
}