mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 12:51:28 +02:00
add naturalDimensions and moved sitting points to exclusively be in properties
This commit is contained in:
parent
df0dc3bdd7
commit
44230a315b
6 changed files with 24 additions and 11 deletions
|
@ -56,6 +56,7 @@ EntityItemProperties::EntityItemProperties() :
|
|||
_animationFPS(ModelEntityItem::DEFAULT_ANIMATION_FPS),
|
||||
_glowLevel(0.0f),
|
||||
|
||||
_naturalDimensions(1.0f, 1.0f, 1.0f),
|
||||
_colorChanged(false),
|
||||
_modelURLChanged(false),
|
||||
_animationURLChanged(false),
|
||||
|
@ -161,6 +162,10 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons
|
|||
properties.setProperty("position", position);
|
||||
QScriptValue dimensions = vec3toScriptValue(engine, _dimensions);
|
||||
properties.setProperty("dimensions", dimensions);
|
||||
|
||||
QScriptValue naturalDimensions = vec3toScriptValue(engine, _naturalDimensions);
|
||||
properties.setProperty("naturalDimensions", naturalDimensions);
|
||||
|
||||
QScriptValue rotation = quatToScriptValue(engine, _rotation);
|
||||
properties.setProperty("rotation", rotation);
|
||||
properties.setProperty("mass", _mass);
|
||||
|
|
|
@ -207,6 +207,12 @@ public:
|
|||
void clearID() { _id = UNKNOWN_ENTITY_ID; _idSet = false; }
|
||||
void markAllChanged();
|
||||
|
||||
QVector<SittingPoint> getSittingPoints() const { return _sittingPoints; }
|
||||
void setSittingPoints(QVector<SittingPoint> sittingPoints) { _sittingPoints = sittingPoints; }
|
||||
|
||||
const glm::vec3& getNaturalDimensions() const { return _naturalDimensions; }
|
||||
void setNaturalDimensions(const glm::vec3& value) { _naturalDimensions = value; }
|
||||
|
||||
private:
|
||||
void setLastEdited(quint64 usecTime) { _lastEdited = usecTime; }
|
||||
|
||||
|
@ -248,6 +254,7 @@ private:
|
|||
float _animationFPS;
|
||||
float _glowLevel;
|
||||
QVector<SittingPoint> _sittingPoints;
|
||||
glm::vec3 _naturalDimensions;
|
||||
|
||||
bool _colorChanged;
|
||||
bool _modelURLChanged;
|
||||
|
|
|
@ -68,18 +68,20 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID
|
|||
EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(identity));
|
||||
|
||||
if (entity) {
|
||||
|
||||
// TODO: improve sitting points in the future, for now we've included the old model behavior for entity
|
||||
// types that are models
|
||||
results = entity->getProperties();
|
||||
|
||||
// TODO: improve sitting points and naturalDimensions in the future,
|
||||
// for now we've included the old sitting points model behavior for entity types that are models
|
||||
// we've also added this hack for setting natural dimensions of models
|
||||
if (entity->getType() == EntityTypes::Model) {
|
||||
ModelEntityItem* model = dynamic_cast<ModelEntityItem*>(entity);
|
||||
const FBXGeometry* geometry = _entityTree->getGeometryForEntity(entity);
|
||||
if (geometry) {
|
||||
model->setSittingPoints(geometry->sittingPoints);
|
||||
results.setSittingPoints(geometry->sittingPoints);
|
||||
Extents meshExtents = geometry->getUnscaledMeshExtents();
|
||||
results.setNaturalDimensions(meshExtents.maximum - meshExtents.minimum);
|
||||
}
|
||||
}
|
||||
|
||||
results = entity->getProperties();
|
||||
|
||||
} else {
|
||||
results.setIsUnknownID();
|
||||
}
|
||||
|
|
|
@ -122,6 +122,9 @@ public:
|
|||
const FBXGeometry* getGeometryForEntity(const EntityItem* entityItem) {
|
||||
return _fbxService ? _fbxService->getGeometryForEntity(entityItem) : NULL;
|
||||
}
|
||||
const Model* getModelForEntityItem(const EntityItem* entityItem) {
|
||||
return _fbxService ? _fbxService->getModelForEntityItem(entityItem) : NULL;
|
||||
}
|
||||
|
||||
EntityTreeElement* getContainingElement(const EntityItemID& entityItemID) /*const*/;
|
||||
void setContainingElement(const EntityItemID& entityItemID, EntityTreeElement* element);
|
||||
|
|
|
@ -47,7 +47,6 @@ EntityItemProperties ModelEntityItem::getProperties() const {
|
|||
properties._animationIsPlaying = getAnimationIsPlaying();
|
||||
properties._animationFrameIndex = getAnimationFrameIndex();
|
||||
properties._animationFPS = getAnimationFPS();
|
||||
properties._sittingPoints = getSittingPoints(); // sitting support
|
||||
properties._colorChanged = false;
|
||||
properties._modelURLChanged = false;
|
||||
properties._animationURLChanged = false;
|
||||
|
|
|
@ -61,7 +61,6 @@ public:
|
|||
bool hasAnimation() const { return !_animationURL.isEmpty(); }
|
||||
static const QString DEFAULT_ANIMATION_URL;
|
||||
const QString& getAnimationURL() const { return _animationURL; }
|
||||
QVector<SittingPoint> getSittingPoints() const { return _sittingPoints; }
|
||||
|
||||
void setColor(const rgbColor& value) { memcpy(_color, value, sizeof(_color)); }
|
||||
void setColor(const xColor& value) {
|
||||
|
@ -81,7 +80,6 @@ public:
|
|||
|
||||
static const float DEFAULT_ANIMATION_FPS;
|
||||
void setAnimationFPS(float value) { _animationFPS = value; }
|
||||
void setSittingPoints(QVector<SittingPoint> sittingPoints) { _sittingPoints = sittingPoints; }
|
||||
|
||||
void mapJoints(const QStringList& modelJointNames);
|
||||
QVector<glm::quat> getAnimationFrame();
|
||||
|
@ -101,7 +99,6 @@ protected:
|
|||
|
||||
rgbColor _color;
|
||||
QString _modelURL;
|
||||
QVector<SittingPoint> _sittingPoints;
|
||||
|
||||
quint64 _lastAnimated;
|
||||
QString _animationURL;
|
||||
|
|
Loading…
Reference in a new issue