Skip to content

Commit

Permalink
[DEV] Cleaning, polishing
Browse files Browse the repository at this point in the history
removing the clutter (all the model not required are no longer
loaded and shown)
Changing the initial camera position for a better view
Modifying the frag shader, so that big body can now become
a bit purple and are no longer exactly all the same color.
-> this could be further properly refactored in the future
  • Loading branch information
havetc committed Nov 5, 2023
1 parent 904a544 commit ca052f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
39 changes: 9 additions & 30 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,12 @@ int main()
return EXIT_FAILURE;
}

Model gridModel, ruinsModel, carModelLeft, carModelRight, beetleModel, bikeModel, handModelLeft, handModelRight,
Model gridModel, handModelLeft, handModelRight,
logoModel, particleModel;
std::vector<Model*> models = { &particleModel, &gridModel, &ruinsModel, &carModelLeft, &carModelRight,
&beetleModel, &bikeModel, &handModelLeft, &handModelRight, &logoModel };
std::vector<Model*> models = { &particleModel, &gridModel, &handModelLeft, &handModelRight, &logoModel };
gridModel.type = PipeType::Grid;
particleModel.type = PipeType::Part;
gridModel.worldMatrix = ruinsModel.worldMatrix = particleModel.worldMatrix = glm::mat4(1.0f);
carModelLeft.worldMatrix =
glm::rotate(glm::translate(glm::mat4(1.0f), { -3.5f, 0.0f, -7.0f }), glm::radians(75.0f), { 0.0f, 1.0f, 0.0f });
carModelRight.worldMatrix =
glm::rotate(glm::translate(glm::mat4(1.0f), { 8.0f, 0.0f, -15.0f }), glm::radians(-15.0f), { 0.0f, 1.0f, 0.0f });
beetleModel.worldMatrix =
glm::rotate(glm::translate(glm::mat4(1.0f), { -3.5f, 0.0f, -0.5f }), glm::radians(-125.0f), { 0.0f, 1.0f, 0.0f });
gridModel.worldMatrix = particleModel.worldMatrix = glm::mat4(1.0f);
logoModel.worldMatrix = glm::translate(glm::mat4(1.0f), { 0.0f, 3.0f, -10.0f });

MeshData* meshData = new MeshData;
Expand All @@ -70,35 +63,19 @@ int main()
return EXIT_FAILURE;
}

if (!meshData->loadModel("models/Ruins.obj", MeshData::Color::White, models, 1u, 1u))
if (!meshData->loadModel("models/Hand.obj", MeshData::Color::White, models, 1u, 2u))
{
return EXIT_FAILURE;
}

if (!meshData->loadModel("models/Car.obj", MeshData::Color::White, models, 2u, 2u))
if (!meshData->loadModel("models/Logo.obj", MeshData::Color::White, models, 3u, 1u))
{
return EXIT_FAILURE;
}

if (!meshData->loadModel("models/Beetle.obj", MeshData::Color::White, models, 4u, 1u))
{
return EXIT_FAILURE;
}

if (!meshData->loadModel("models/Bike.obj", MeshData::Color::White, models, 5u, 1u))
{
return EXIT_FAILURE;
}
//Set initial position
cameraMatrix = glm::translate(cameraMatrix, glm::vec3(0,-1,-2.5));

if (!meshData->loadModel("models/Hand.obj", MeshData::Color::White, models, 6u, 2u))
{
return EXIT_FAILURE;
}

if (!meshData->loadModel("models/Logo.obj", MeshData::Color::White, models, 8u, 1u))
{
return EXIT_FAILURE;
}

Particles p;

Expand Down Expand Up @@ -160,8 +137,10 @@ int main()
handModelRight.worldMatrix = inverseCameraMatrix * controllers.getPose(1u);
handModelRight.worldMatrix = glm::scale(handModelRight.worldMatrix, { -1.0f, 1.0f, 1.0f });

/* Example of moving a model by editing its world matrix.
bikeModel.worldMatrix =
glm::rotate(glm::translate(glm::mat4(1.0f), { 0.5f, 0.0f, -4.5f }), time * 0.2f, { 0.0f, 1.0f, 0.0f });
*/

// Render
renderer.render(cameraMatrix, swapchainImageIndex, time);
Expand Down
5 changes: 3 additions & 2 deletions src/shaders/particle.vert
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ void main ()
outColor.g *= inMass / 50.0;
outColor.b *= inMass / 20.0;
outColor = clamp(outColor,vec4(0),vec4(1));
outColor.g -= clamp(0.2*(inMass-70)/30,0,1);
outColor.r -= clamp(0.4*(inMass-70)/30,0,1);
float oversize = clamp(2-log(inMass)/6,0,1);
outColor.g -= clamp(0.2*(inMass-70)/30,0,oversize);
outColor.r -= clamp(0.4*(inMass-70)/30,0,oversize);
gl_Position = viewProjection.matrices[gl_ViewIndex] * world.matrix * vec4(inPos, 1.0);
//point size depending on the distance!!
gl_PointSize = 4 * pow(inMass,1.0/3.0) / ((gl_Position.z)); // try mass / 10 mass is between 10 and 100 At the moment
Expand Down

0 comments on commit ca052f2

Please sign in to comment.