Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/chest model #214

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"server": {
"lobby_name": "Hope you're doing well!",
"lobby_broadcast": true,
"max_players": 1,
"max_players": 4,
"disable_dm": false,
"skip_intro": true
"skip_intro": false
},
"client": {
"default_name": "Conan O'Brien",
Expand All @@ -25,6 +25,6 @@
"draw_bboxes": false,
"fps_counter": true,
"presentation": false,
"render": 75
"render": 80
}
}
1 change: 1 addition & 0 deletions include/client/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class Client {
std::unique_ptr<Model> lava_vertical_model;
std::unique_ptr<Model> lava_horizontal_model;
std::unique_ptr<Model> lightning_model;
std::unique_ptr<Model> chest_model;

GLFWwindow *window;

Expand Down
3 changes: 2 additions & 1 deletion include/shared/game/sharedmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ enum class ModelType {
SunGod,
Mirror,
LightCut,
TorchPost
TorchPost,
Chest
};
47 changes: 17 additions & 30 deletions src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ bool Client::init() {
auto lava_cross_model_path = env_models_dir / "lava" / "lava_cross.obj";
this->lava_cross_model = std::make_unique<Model>(lava_cross_model_path.string(), false);

auto chest_model_path = item_models_dir / "Chest1" / "Chest1 1.obj";
this->chest_model = std::make_unique<Model>(chest_model_path.string(), false);

auto lava_row_model_path = env_models_dir / "lava" / "lava_row.obj";
this->lava_horizontal_model = std::make_unique<Model>(lava_row_model_path.string(), false);
// thank you openai!
Expand Down Expand Up @@ -838,7 +841,8 @@ void Client::geometryPass() {
sharedObject->type == ObjectType::ArrowTrap ||
sharedObject->type == ObjectType::SpikeTrap ||
sharedObject->type == ObjectType::TeleporterTrap ||
sharedObject->type == ObjectType::Projectile)
sharedObject->type == ObjectType::Projectile ||
sharedObject->modelType == ModelType::Chest)
&& dist > this->config.client.render / 2) {
continue;
}
Expand All @@ -853,7 +857,8 @@ void Client::geometryPass() {
sharedObject->type == ObjectType::ArrowTrap ||
sharedObject->type == ObjectType::SpikeTrap ||
sharedObject->type == ObjectType::Projectile ||
sharedObject->type == ObjectType::Torchlight) // dont render post from far away
sharedObject->type == ObjectType::Torchlight || // light post
sharedObject->modelType == ModelType::Chest)
&& dist > this->config.client.render) {
continue;
}
Expand Down Expand Up @@ -1164,14 +1169,7 @@ void Client::geometryPass() {
}
case ObjectType::Potion: {
if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) {
Model* model = this->item_model.get();
if (sharedObject->modelType == ModelType::HealthPotion) {
model = this->item_model.get();
} else if (sharedObject->modelType == ModelType::NauseaPotion || sharedObject->modelType == ModelType::InvincibilityPotion) {
model = this->item_model.get();
} else if (sharedObject->modelType == ModelType::InvisibilityPotion) {
model = this->item_model.get();
}
Model* model = this->chest_model.get();

model->setDimensions(sharedObject->physics.dimensions);
model->translateAbsolute(sharedObject->physics.getCenterPosition());
Expand All @@ -1183,20 +1181,9 @@ void Client::geometryPass() {
}
case ObjectType::Spell: {
if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) {
glm::vec3 color;
if (sharedObject->modelType == ModelType::FireSpell) {
color = glm::vec3(0.9f, 0.1f, 0.0f);
}
else if (sharedObject->modelType == ModelType::HealSpell) {
color = glm::vec3(1.0f, 1.0f, 0.0f);
}
else {
color = glm::vec3(0.8f, 0.7f, 0.6f);
}

this->item_model->setDimensions(sharedObject->physics.dimensions);
this->item_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->item_model->draw(this->deferred_geometry_shader.get(),
this->chest_model->setDimensions(sharedObject->physics.dimensions);
this->chest_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->chest_model->draw(this->deferred_geometry_shader.get(),
this->cam->getPos(),
true);
}
Expand Down Expand Up @@ -1224,9 +1211,9 @@ void Client::geometryPass() {
}
case ObjectType::Weapon: {
if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) {
this->item_model->setDimensions(sharedObject->physics.dimensions);
this->item_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->item_model->draw(this->deferred_geometry_shader.get(),
this->chest_model->setDimensions(sharedObject->physics.dimensions);
this->chest_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->chest_model->draw(this->deferred_geometry_shader.get(),
this->cam->getPos(),
true);
}
Expand Down Expand Up @@ -1259,9 +1246,9 @@ void Client::geometryPass() {
}
case ObjectType::Mirror: {
if (!sharedObject->iteminfo->held && !sharedObject->iteminfo->used) {
this->item_model->setDimensions(sharedObject->physics.dimensions);
this->item_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->item_model->draw(this->deferred_geometry_shader.get(),
this->chest_model->setDimensions(sharedObject->physics.dimensions);
this->chest_model->translateAbsolute(sharedObject->physics.getCenterPosition());
this->chest_model->draw(this->deferred_geometry_shader.get(),
this->cam->getPos(),
true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/* Constructors and Destructors */
Item::Item(ObjectType type, bool movable, glm::vec3 corner, ModelType model, glm::vec3 dimensions):
Object(type, Physics(movable, Collider::Box, corner, dimensions), ModelType::Cube),
Object(type, Physics(movable, Collider::Box, corner, dimensions), ModelType::Chest),
iteminfo(SharedItemInfo{ .held = false, .used = false })
{}

Expand Down
3 changes: 2 additions & 1 deletion src/server/game/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ std::unordered_map<ModelType, glm::vec3> Object::models ({
{ModelType::FloorSpikeHorizontal, FLOOR_SPIKE_DIMENSIONS},
{ModelType::FloorSpikeVertical, FLOOR_SPIKE_DIMENSIONS},
{ModelType::Lightning, glm::vec3(3.0f, 100.0f, 3.0f)},
{ModelType::Orb, glm::vec3(0.887116, 0.941508, 0.950092)}
{ModelType::Orb, glm::vec3(0.887116, 0.941508, 0.950092)},
{ModelType::Chest, glm::vec3(1.377020, 1.355794, 1.092905)}
});

/* SharedGameState generation */
Expand Down
Loading