mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
use many colors for collision hull rendering
This commit is contained in:
parent
2a3da60ed4
commit
c73757f740
1 changed files with 43 additions and 7 deletions
|
@ -35,7 +35,46 @@ int vec3VectorTypeId = qRegisterMetaType<QVector<glm::vec3> >();
|
||||||
float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f;
|
float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f;
|
||||||
#define HTTP_INVALID_COM "http://invalid.com"
|
#define HTTP_INVALID_COM "http://invalid.com"
|
||||||
|
|
||||||
model::MaterialPointer Model::_collisionHullMaterial;
|
const int NUM_COLLISION_HULL_COLORS = 24;
|
||||||
|
std::vector<model::MaterialPointer> _collisionHullMaterials;
|
||||||
|
|
||||||
|
void initCollisionHullMaterials() {
|
||||||
|
// generates bright colors in red, green, blue, yellow, magenta, and cyan spectrums
|
||||||
|
// (no browns, greys, or dark shades)
|
||||||
|
float component[NUM_COLLISION_HULL_COLORS] = {
|
||||||
|
0.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.2f, 0.4f, 0.6f, 0.8f,
|
||||||
|
1.0f, 1.0f, 1.0f, 1.0f,
|
||||||
|
1.0f, 1.0f, 1.0f, 1.0f,
|
||||||
|
0.8f, 0.6f, 0.4f, 0.2f
|
||||||
|
};
|
||||||
|
_collisionHullMaterials.reserve(NUM_COLLISION_HULL_COLORS);
|
||||||
|
|
||||||
|
// each component gets the same cuve
|
||||||
|
// but offset by a multiple of one third the full width
|
||||||
|
int numComponents = 3;
|
||||||
|
int sectionWidth = NUM_COLLISION_HULL_COLORS / numComponents;
|
||||||
|
int greenPhase = sectionWidth;
|
||||||
|
int bluePhase = 2 * sectionWidth;
|
||||||
|
|
||||||
|
// we stride through the colors to scatter adjacent shades
|
||||||
|
// so they don't tend to group together for large models
|
||||||
|
for (int i = 0; i < sectionWidth; ++i) {
|
||||||
|
for (int j = 0; j < numComponents; ++j) {
|
||||||
|
model::MaterialPointer material;
|
||||||
|
material = std::make_shared<model::Material>();
|
||||||
|
int index = j * sectionWidth + i;
|
||||||
|
float red = component[index];
|
||||||
|
float green = component[(index + greenPhase) % NUM_COLLISION_HULL_COLORS];
|
||||||
|
float blue = component[(index + bluePhase) % NUM_COLLISION_HULL_COLORS];
|
||||||
|
material->setAlbedo(glm::vec3(red, green, blue));
|
||||||
|
material->setMetallic(0.02f);
|
||||||
|
material->setRoughness(0.5f);
|
||||||
|
_collisionHullMaterials.push_back(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Model::Model(RigPointer rig, QObject* parent) :
|
Model::Model(RigPointer rig, QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
|
@ -1217,13 +1256,10 @@ void Model::segregateMeshGroups() {
|
||||||
int totalParts = mesh.parts.size();
|
int totalParts = mesh.parts.size();
|
||||||
for (int partIndex = 0; partIndex < totalParts; partIndex++) {
|
for (int partIndex = 0; partIndex < totalParts; partIndex++) {
|
||||||
if (showingCollisionHull) {
|
if (showingCollisionHull) {
|
||||||
if (!_collisionHullMaterial) {
|
if (_collisionHullMaterials.empty()) {
|
||||||
_collisionHullMaterial = std::make_shared<model::Material>();
|
initCollisionHullMaterials();
|
||||||
_collisionHullMaterial->setAlbedo(glm::vec3(1.0f, 0.5f, 0.0f));
|
|
||||||
_collisionHullMaterial->setMetallic(0.02f);
|
|
||||||
_collisionHullMaterial->setRoughness(0.5f);
|
|
||||||
}
|
}
|
||||||
_collisionRenderItemsSet << std::make_shared<MeshPartPayload>(networkMesh, partIndex, _collisionHullMaterial, transform, offset);
|
_collisionRenderItemsSet << std::make_shared<MeshPartPayload>(networkMesh, partIndex, _collisionHullMaterials[partIndex % NUM_COLLISION_HULL_COLORS], transform, offset);
|
||||||
} else {
|
} else {
|
||||||
_modelMeshRenderItemsSet << std::make_shared<ModelMeshPartPayload>(this, i, partIndex, shapeID, transform, offset);
|
_modelMeshRenderItemsSet << std::make_shared<ModelMeshPartPayload>(this, i, partIndex, shapeID, transform, offset);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue