More scriptedMove

This commit is contained in:
2023-12-07 11:14:20 -05:00
parent e5334a167d
commit e1d2354dcc
6 changed files with 33 additions and 5 deletions

View File

@@ -0,0 +1 @@
start 1.0 -1.0 1.0

View File

@@ -46,6 +46,7 @@ void pre_render() {
storeEntity(camera);
getCamera()->position.set(0.0f,0.0f,5.0f);
getCamera()->angle.y = 180.0f;
getCamera()->scriptedMove.load("../scriptedMove/default.smov");
auto skybox = new(Skybox);
skybox->draw = true;
storeEntity(skybox);

View File

@@ -16,6 +16,7 @@ public:
std::vector<Angle> angles;
//We won't even need that many positions anyways.
uint16_t index = NULL;
Position start = {NULL,NULL,NULL};
void load(const std::string& filename) {
std::ifstream file(filename);
@@ -34,11 +35,20 @@ public:
float x, y, z;
stream >> x >> y >> z;
positions.push_back({x, y, z});
} else if (prefix == "angle") {
}
else if (prefix == "angle") {
float x, y, z;
stream >> x >> y >> z;
angles.push_back({x, y, z});
}
else if (prefix == "start") {
float x, y, z;
stream >> x >> y >> z;
std::cout << x << " " << y << " " << z << std::endl;
start.x = x;
start.y = y;
start.z = z;
}
}
file.close();
}

View File

@@ -34,6 +34,13 @@ public:
if (engine->keyState[SDL_SCANCODE_2] == 1)
this->cameraMode = CameraMode::THIRD_PERSON;
if (engine->keyState[SDL_SCANCODE_3] == 1)
this->cameraMode = CameraMode::SCRIPTED_MOVE;
if (cameraMode == CameraMode::SCRIPTED_MOVE) {
doScriptedMovement();
}
if (cameraMode == CameraMode::THIRD_PERSON) {
if (engine->debug)
std::cout << "Calculated Pitch: " << VectorMath::calcAngle(position,getPlayer()->position).x << " Calculated Yaw: " << VectorMath::calcAngle(position,getPlayer()->position).y << std::endl;

View File

@@ -55,9 +55,18 @@ public:
return a;
}
AngPos nextScriptedMove() {
Movement nextScriptedMove() {
//TODO: check if it'd be outside the bounds of the vector.
Angle a = scriptedMove.angles[scriptedMove.index+1];
Position p = scriptedMove.positions[scriptedMove.index+1];
Angle a = scriptedMove.angles[scriptedMove.index];
Position p = scriptedMove.positions[scriptedMove.index];
}
void doScriptedMovement() {
//If the movement has a set starting position, Then teleport the moby there
//Before the first movement.
if (scriptedMove.index == 0 && scriptedMove.start.x != NULL)
this->position = scriptedMove.start;
}
};

View File

@@ -76,7 +76,7 @@ public:
}
};
struct AngPos {
struct Movement {
Angle angle;
Position position;
};