ModelEntity::ModelEntity(const string& name, const ModelSP& model, float scaleX, float scaleY, float scaleZ) : OctreeEntity(), NodeOwner(), Geometry(), translateX(0.0f), translateY(0.0f), translateZ(0.0f), rotation(), scaleX(scaleX), scaleY(scaleY), scaleZ(scaleZ), modelMatrix(), normalModelMatrix(), updateNormalModelMatrix(true), position(), origin(), model(model), time(0.0f), writeBrightColor(false), brightColorLimit(1.0f), refractiveIndex(RI_AIR), debug(false), debugAsMesh(false), boundingSphere(), updateable(false), animStackIndex(-1), animLayerIndex(-1), rootInstanceNode(), name(name) { float maxScale = glusMaxf(scaleX, scaleY); maxScale = glusMaxf(maxScale, scaleZ); setBoundingSphere(BoundingSphere(model->getBoundingSphere().getCenter(), model->getBoundingSphere().getRadius() * maxScale)); setUpdateable(model->isAnimated()); if (model->isAnimated() && model->isSkinned()) { model->getRootNode()->updateBindMatrix(bindMatrices, bindNormalMatrices); model->getRootNode()->updateJointMatrix(jointMatrices, jointNormalMatrices, Matrix4x4(), 0.0f, getAnimStackIndex(), getAnimLayerIndex()); } rootInstanceNode = InstanceNodeSP(new InstanceNode(model->getRootNode()->getName())); model->getRootNode()->updateInstanceNode(rootInstanceNode); updateBoundingSphereCenter(true); }
ModelEntity::ModelEntity(const string& name, const ModelSP& model, float scaleX, float scaleY, float scaleZ) : GeneralEntity(name, scaleX, scaleY, scaleZ), NodeOwner(), model(model), time(0.0f), animStackIndex(-1), animLayerIndex(-1), rootInstanceNode(), jointIndex(-1), dirty(true), ambientLightColor() { float maxScale = glusMaxf(scaleX, scaleY); maxScale = glusMaxf(maxScale, scaleZ); setBoundingSphere(BoundingSphere(model->getBoundingSphere().getCenter(), model->getBoundingSphere().getRadius() * maxScale)); setUpdateable(model->isAnimated()); if (model->isSkinned()) { jointIndex = model->getRootNode()->getRootJointIndex(); model->getRootNode()->updateInverseBindMatrix(inverseBindMatrices, inverseBindNormalMatrices); model->getRootNode()->updateBindMatrix(bindMatrices, bindNormalMatrices, Matrix4x4(), 0.0f, animStackIndex, animLayerIndex); } rootInstanceNode = InstanceNodeSP(new InstanceNode(model->getRootNode().get())); model->getRootNode()->updateInstanceNode(*this, rootInstanceNode); updateBoundingSphereCenter(true); }