snapped attachment to center and scale them to fit

This commit is contained in:
Atlante45 2014-05-29 14:30:28 -07:00
parent 37613f086b
commit b91fd19f39

View file

@ -378,10 +378,10 @@ void Avatar::simulateAttachments(float deltaTime) {
model->setLODDistance(getLODDistance()); model->setLODDistance(getLODDistance());
} }
if (_skeletonModel.getJointPosition(jointIndex, jointPosition) && if (_skeletonModel.getJointPosition(jointIndex, jointPosition) &&
_skeletonModel.getJointRotation(jointIndex, jointRotation)) { _skeletonModel.getJointCombinedRotation(jointIndex, jointRotation)) {
model->setTranslation(jointPosition + jointRotation * attachment.translation * _scale); model->setTranslation(jointPosition + jointRotation * attachment.translation * _scale);
model->setRotation(jointRotation * attachment.rotation); model->setRotation(jointRotation * attachment.rotation);
model->setScale(_skeletonModel.getScale() * attachment.scale); model->setScaleToFit(true, _scale * attachment.scale);
model->simulate(deltaTime); model->simulate(deltaTime);
} }
} }
@ -749,7 +749,6 @@ void Avatar::setAttachmentData(const QVector<AttachmentData>& attachmentData) {
// make sure we have as many models as attachments // make sure we have as many models as attachments
while (_attachmentModels.size() < attachmentData.size()) { while (_attachmentModels.size() < attachmentData.size()) {
Model* model = new Model(this); Model* model = new Model(this);
model->setSnapModelToCenter(true);
model->init(); model->init();
_attachmentModels.append(model); _attachmentModels.append(model);
} }
@ -759,6 +758,8 @@ void Avatar::setAttachmentData(const QVector<AttachmentData>& attachmentData) {
// update the urls // update the urls
for (int i = 0; i < attachmentData.size(); i++) { for (int i = 0; i < attachmentData.size(); i++) {
_attachmentModels[i]->setSnapModelToCenter(true);
_attachmentModels[i]->setScaleToFit(true, _scale * _attachmentData.at(i).scale);
_attachmentModels[i]->setURL(attachmentData.at(i).modelURL); _attachmentModels[i]->setURL(attachmentData.at(i).modelURL);
} }
} }