summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermodelpreview.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2016-01-15 16:42:39 -0500
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2016-01-15 16:42:39 -0500
commit3612d7d14b1e481402bb3d7cbfb552cd19a3fc0a (patch)
treef3dabe49f7953e24de207a6a0939da5539d5acca /indra/newview/llfloatermodelpreview.cpp
parenta6c8de97bbb2609d24e212672b192650aed91e1e (diff)
parent5a5c023e291990a463b1a91846ce82c70da8daab (diff)
merge
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rwxr-xr-xindra/newview/llfloatermodelpreview.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index deb3ccebcf..de9eb2b6a5 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -2591,6 +2591,112 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim
shader->bind();
}
}
+void LLModelPreview::genModelBBox()
+{
+ LLVector3 min, max;
+ min = this->mModelLoader->mExtents[0];
+ max = this->mModelLoader->mExtents[1];
+ std::vector<LLVector3> v_list;
+ v_list.resize(4);
+ std::map<U8, std::vector<LLVector3> > face_list;
+
+ // Face 0
+ v_list[0] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]);
+ v_list[1] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]);
+ v_list[2] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]);
+ v_list[3] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]);
+ face_list.insert(std::pair<U8, std::vector<LLVector3> >(0, v_list));
+
+ // Face 1
+ v_list[0] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]);
+ v_list[1] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]);
+ v_list[2] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]);
+ v_list[3] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]);
+ face_list.insert(std::pair<U8, std::vector<LLVector3> >(1, v_list));
+
+ // Face 2
+ v_list[0] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]);
+ v_list[1] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]);
+ v_list[2] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]);
+ v_list[3] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]);
+ face_list.insert(std::pair<U8, std::vector<LLVector3> >(2, v_list));
+
+ // Face 3
+ v_list[0] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]);
+ v_list[1] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]);
+ v_list[2] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]);
+ v_list[3] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]);
+ face_list.insert(std::pair<U8, std::vector<LLVector3> >(3, v_list));
+
+ // Face 4
+ v_list[0] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]);
+ v_list[1] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]);
+ v_list[2] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]);
+ v_list[3] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]);
+ face_list.insert(std::pair<U8, std::vector<LLVector3> >(4, v_list));
+
+ // Face 5
+ v_list[0] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]);
+ v_list[1] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]);
+ v_list[2] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]);
+ v_list[3] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]);
+ face_list.insert(std::pair<U8, std::vector<LLVector3> >(5, v_list));
+
+ U16 Idx[] = { 0, 1, 2, 3, 0, 2, };
+
+ U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0;
+ LLPointer<LLVertexBuffer> buff = new LLVertexBuffer(type_mask, 0);
+ buff->allocateBuffer(4, 6, true);
+
+ LLStrider<LLVector3> pos;
+ LLStrider<U16> idx;
+ LLStrider<LLVector3> norm;
+ LLStrider<LLVector2> tc;
+
+ buff->getVertexStrider(pos);
+ buff->getIndexStrider(idx);
+
+ buff->getNormalStrider(norm);
+ buff->getTexCoord0Strider(tc);
+
+ for (U32 i = 0; i < 6; ++i)
+ {
+ idx[i] = Idx[i];
+ }
+
+ LLVolumeParams volume_params;
+ volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
+ LLModel* mdl = new LLModel(volume_params, 0.f);
+ mdl->mLabel = "BBOX"; // please adopt name from high LOD (mBaseModel) or from original model otherwise it breaks search mechanics which is name based
+
+ mdl->setNumVolumeFaces(6);
+ for (U8 i = 0; i < 6; ++i)
+ {
+ for (U8 j = 0; j < 4; ++j)
+ {
+ pos[j] = face_list[i][j];
+ }
+
+ mdl->setVolumeFaceData(i, pos, norm, tc, idx, buff->getNumVerts(), buff->getNumIndices());
+ }
+
+ if (validate_model(mdl))
+ {
+ LLMatrix4 mat;
+ std::map<std::string, LLImportMaterial> materials;
+ std::vector<LLModelInstance> instance_list;
+ instance_list.push_back(LLModelInstance(mdl, mdl->mLabel, mat, materials));
+
+ for (S32 i = LLModel::LOD_HIGH - 1; i >= 0; i--)
+ {
+ mModel[i].clear();
+ mModel[i].push_back(mdl);
+
+ mScene[i].clear();
+ mScene[i].insert(std::pair<LLMatrix4, std::vector<LLModelInstance> >(mat, instance_list));
+ }
+ }
+}
void LLModelPreview::updateStatusMessages()
{