mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 12:34:48 +02:00
dry up EntityItemProperties with macros
This commit is contained in:
parent
a37275e6b1
commit
66f519d613
3 changed files with 124 additions and 316 deletions
|
@ -24,96 +24,57 @@
|
||||||
|
|
||||||
EntityItemProperties::EntityItemProperties() :
|
EntityItemProperties::EntityItemProperties() :
|
||||||
|
|
||||||
_id(UNKNOWN_ENTITY_ID),
|
CONSTRUCT_PROPERTY(visible, EntityItem::DEFAULT_VISIBLE),
|
||||||
_idSet(false),
|
CONSTRUCT_PROPERTY(position, 0),
|
||||||
_lastEdited(0), // ????
|
CONSTRUCT_PROPERTY(dimensions, EntityItem::DEFAULT_DIMENSIONS),
|
||||||
_created(UNKNOWN_CREATED_TIME),
|
CONSTRUCT_PROPERTY(rotation, EntityItem::DEFAULT_ROTATION),
|
||||||
_type(EntityTypes::Unknown),
|
CONSTRUCT_PROPERTY(mass, EntityItem::DEFAULT_MASS),
|
||||||
|
CONSTRUCT_PROPERTY(velocity, EntityItem::DEFAULT_VELOCITY),
|
||||||
_position(0),
|
CONSTRUCT_PROPERTY(gravity, EntityItem::DEFAULT_GRAVITY),
|
||||||
_dimensions(EntityItem::DEFAULT_DIMENSIONS),
|
CONSTRUCT_PROPERTY(damping, EntityItem::DEFAULT_DAMPING),
|
||||||
_rotation(EntityItem::DEFAULT_ROTATION),
|
CONSTRUCT_PROPERTY(lifetime, EntityItem::DEFAULT_LIFETIME),
|
||||||
_mass(EntityItem::DEFAULT_MASS),
|
CONSTRUCT_PROPERTY(script, EntityItem::DEFAULT_SCRIPT),
|
||||||
_velocity(EntityItem::DEFAULT_VELOCITY),
|
CONSTRUCT_PROPERTY(color, ),
|
||||||
_gravity(EntityItem::DEFAULT_GRAVITY),
|
CONSTRUCT_PROPERTY(modelURL, ""),
|
||||||
_damping(EntityItem::DEFAULT_DAMPING),
|
CONSTRUCT_PROPERTY(animationURL, ""),
|
||||||
_lifetime(EntityItem::DEFAULT_LIFETIME),
|
CONSTRUCT_PROPERTY(animationFPS, ModelEntityItem::DEFAULT_ANIMATION_FPS),
|
||||||
_userData(EntityItem::DEFAULT_USER_DATA),
|
CONSTRUCT_PROPERTY(animationFrameIndex, ModelEntityItem::DEFAULT_ANIMATION_FRAME_INDEX),
|
||||||
_script(EntityItem::DEFAULT_SCRIPT),
|
CONSTRUCT_PROPERTY(animationIsPlaying, ModelEntityItem::DEFAULT_ANIMATION_IS_PLAYING),
|
||||||
_registrationPoint(EntityItem::DEFAULT_REGISTRATION_POINT),
|
CONSTRUCT_PROPERTY(registrationPoint, EntityItem::DEFAULT_REGISTRATION_POINT),
|
||||||
_angularVelocity(EntityItem::DEFAULT_ANGULAR_VELOCITY),
|
CONSTRUCT_PROPERTY(angularVelocity, EntityItem::DEFAULT_ANGULAR_VELOCITY),
|
||||||
_angularDamping(EntityItem::DEFAULT_ANGULAR_DAMPING),
|
CONSTRUCT_PROPERTY(angularDamping, EntityItem::DEFAULT_ANGULAR_DAMPING),
|
||||||
_visible(EntityItem::DEFAULT_VISIBLE),
|
CONSTRUCT_PROPERTY(ignoreForCollisions, EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS),
|
||||||
_ignoreForCollisions(EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS),
|
CONSTRUCT_PROPERTY(collisionsWillMove, EntityItem::DEFAULT_COLLISIONS_WILL_MOVE),
|
||||||
_collisionsWillMove(EntityItem::DEFAULT_COLLISIONS_WILL_MOVE),
|
CONSTRUCT_PROPERTY(isSpotlight, false),
|
||||||
|
CONSTRUCT_PROPERTY(diffuseColor, ),
|
||||||
_positionChanged(false),
|
CONSTRUCT_PROPERTY(ambientColor, ),
|
||||||
_dimensionsChanged(false),
|
CONSTRUCT_PROPERTY(specularColor, ),
|
||||||
_rotationChanged(false),
|
CONSTRUCT_PROPERTY(constantAttenuation, 1.0f),
|
||||||
_massChanged(false),
|
CONSTRUCT_PROPERTY(linearAttenuation, 0.0f),
|
||||||
_velocityChanged(false),
|
CONSTRUCT_PROPERTY(quadraticAttenuation, 0.0f),
|
||||||
_gravityChanged(false),
|
CONSTRUCT_PROPERTY(exponent, 0.0f),
|
||||||
_dampingChanged(false),
|
CONSTRUCT_PROPERTY(cutoff, PI),
|
||||||
_lifetimeChanged(false),
|
CONSTRUCT_PROPERTY(locked, false),
|
||||||
_userDataChanged(false),
|
CONSTRUCT_PROPERTY(textures, ""),
|
||||||
_scriptChanged(false),
|
CONSTRUCT_PROPERTY(animationSettings, ""),
|
||||||
_registrationPointChanged(false),
|
CONSTRUCT_PROPERTY(userData, EntityItem::DEFAULT_USER_DATA),
|
||||||
_angularVelocityChanged(false),
|
|
||||||
_angularDampingChanged(false),
|
|
||||||
_visibleChanged(false),
|
|
||||||
_ignoreForCollisionsChanged(false),
|
|
||||||
_collisionsWillMoveChanged(false),
|
|
||||||
|
|
||||||
_color(),
|
|
||||||
_modelURL(""),
|
|
||||||
_animationURL(""),
|
|
||||||
_animationIsPlaying(ModelEntityItem::DEFAULT_ANIMATION_IS_PLAYING),
|
|
||||||
_animationFrameIndex(ModelEntityItem::DEFAULT_ANIMATION_FRAME_INDEX),
|
|
||||||
_animationFPS(ModelEntityItem::DEFAULT_ANIMATION_FPS),
|
|
||||||
_animationSettings(""),
|
|
||||||
_glowLevel(0.0f),
|
|
||||||
_localRenderAlpha(1.0f),
|
|
||||||
_isSpotlight(false),
|
|
||||||
|
|
||||||
_colorChanged(false),
|
|
||||||
_modelURLChanged(false),
|
|
||||||
_animationURLChanged(false),
|
|
||||||
_animationIsPlayingChanged(false),
|
|
||||||
_animationFrameIndexChanged(false),
|
|
||||||
_animationFPSChanged(false),
|
|
||||||
_animationSettingsChanged(false),
|
|
||||||
|
|
||||||
_glowLevelChanged(false),
|
|
||||||
_localRenderAlphaChanged(false),
|
|
||||||
_isSpotlightChanged(false),
|
|
||||||
|
|
||||||
_diffuseColor(),
|
|
||||||
_ambientColor(),
|
|
||||||
_specularColor(),
|
|
||||||
_constantAttenuation(1.0f),
|
|
||||||
_linearAttenuation(0.0f),
|
|
||||||
_quadraticAttenuation(0.0f),
|
|
||||||
_exponent(0.0f),
|
|
||||||
_cutoff(PI),
|
|
||||||
_locked(false),
|
|
||||||
_textures(""),
|
|
||||||
|
|
||||||
_diffuseColorChanged(false),
|
|
||||||
_ambientColorChanged(false),
|
|
||||||
_specularColorChanged(false),
|
|
||||||
_constantAttenuationChanged(false),
|
|
||||||
_linearAttenuationChanged(false),
|
|
||||||
_quadraticAttenuationChanged(false),
|
|
||||||
_exponentChanged(false),
|
|
||||||
_cutoffChanged(false),
|
|
||||||
_lockedChanged(false),
|
|
||||||
_texturesChanged(false),
|
|
||||||
|
|
||||||
CONSTRUCT_PROPERTY(text, TextEntityItem::DEFAULT_TEXT),
|
CONSTRUCT_PROPERTY(text, TextEntityItem::DEFAULT_TEXT),
|
||||||
CONSTRUCT_PROPERTY(lineHeight, TextEntityItem::DEFAULT_LINE_HEIGHT),
|
CONSTRUCT_PROPERTY(lineHeight, TextEntityItem::DEFAULT_LINE_HEIGHT),
|
||||||
CONSTRUCT_PROPERTY(textColor, TextEntityItem::DEFAULT_TEXT_COLOR),
|
CONSTRUCT_PROPERTY(textColor, TextEntityItem::DEFAULT_TEXT_COLOR),
|
||||||
CONSTRUCT_PROPERTY(backgroundColor, TextEntityItem::DEFAULT_BACKGROUND_COLOR),
|
CONSTRUCT_PROPERTY(backgroundColor, TextEntityItem::DEFAULT_BACKGROUND_COLOR),
|
||||||
|
|
||||||
|
_id(UNKNOWN_ENTITY_ID),
|
||||||
|
_idSet(false),
|
||||||
|
_lastEdited(0),
|
||||||
|
_created(UNKNOWN_CREATED_TIME),
|
||||||
|
_type(EntityTypes::Unknown),
|
||||||
|
|
||||||
|
_glowLevel(0.0f),
|
||||||
|
_localRenderAlpha(1.0f),
|
||||||
|
|
||||||
|
_glowLevelChanged(false),
|
||||||
|
_localRenderAlphaChanged(false),
|
||||||
|
|
||||||
_defaultSettings(true),
|
_defaultSettings(true),
|
||||||
_naturalDimensions(1.0f, 1.0f, 1.0f)
|
_naturalDimensions(1.0f, 1.0f, 1.0f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -114,6 +114,9 @@ public:
|
||||||
EntityItemProperties();
|
EntityItemProperties();
|
||||||
virtual ~EntityItemProperties();
|
virtual ~EntityItemProperties();
|
||||||
|
|
||||||
|
EntityTypes::EntityType getType() const { return _type; }
|
||||||
|
void setType(EntityTypes::EntityType type) { _type = type; }
|
||||||
|
|
||||||
virtual QScriptValue copyToScriptValue(QScriptEngine* engine) const;
|
virtual QScriptValue copyToScriptValue(QScriptEngine* engine) const;
|
||||||
virtual void copyFromScriptValue(const QScriptValue& object);
|
virtual void copyFromScriptValue(const QScriptValue& object);
|
||||||
|
|
||||||
|
@ -131,86 +134,63 @@ public:
|
||||||
AABox getAABoxInMeters() const;
|
AABox getAABoxInMeters() const;
|
||||||
|
|
||||||
void debugDump() const;
|
void debugDump() const;
|
||||||
|
void setLastEdited(quint64 usecTime) { _lastEdited = usecTime; }
|
||||||
|
|
||||||
|
DEFINE_PROPERTY(PROP_VISIBLE, Visible, visible, bool);
|
||||||
|
DEFINE_PROPERTY_REF_WITH_SETTER(PROP_POSITION, Position, position, glm::vec3);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_DIMENSIONS, Dimensions, dimensions, glm::vec3);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_ROTATION, Rotation, rotation, glm::quat);
|
||||||
|
DEFINE_PROPERTY(PROP_MASS, Mass, mass, float);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_VELOCITY, Velocity, velocity, glm::vec3);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_GRAVITY, Gravity, gravity, glm::vec3);
|
||||||
|
DEFINE_PROPERTY(PROP_DAMPING, Damping, damping, float);
|
||||||
|
DEFINE_PROPERTY(PROP_LIFETIME, Lifetime, lifetime, float);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_SCRIPT, Script, script, QString);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, xColor);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_MODEL_URL, ModelURL, modelURL, QString);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_ANIMATION_URL, AnimationURL, animationURL, QString);
|
||||||
|
DEFINE_PROPERTY(PROP_ANIMATION_FPS, AnimationFPS, animationFPS, float);
|
||||||
|
DEFINE_PROPERTY(PROP_ANIMATION_FRAME_INDEX, AnimationFrameIndex, animationFrameIndex, float);
|
||||||
|
DEFINE_PROPERTY(PROP_ANIMATION_PLAYING, AnimationIsPlaying, animationIsPlaying, bool);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_REGISTRATION_POINT, RegistrationPoint, registrationPoint, glm::vec3);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_ANGULAR_VELOCITY, AngularVelocity, angularVelocity, glm::vec3);
|
||||||
|
DEFINE_PROPERTY(PROP_ANGULAR_DAMPING, AngularDamping, angularDamping, float);
|
||||||
|
DEFINE_PROPERTY(PROP_IGNORE_FOR_COLLISIONS, IgnoreForCollisions, ignoreForCollisions, bool);
|
||||||
|
DEFINE_PROPERTY(PROP_COLLISIONS_WILL_MOVE, CollisionsWillMove, collisionsWillMove, bool);
|
||||||
|
DEFINE_PROPERTY(PROP_IS_SPOTLIGHT, IsSpotlight, isSpotlight, bool);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_DIFFUSE_COLOR, DiffuseColor, diffuseColor, xColor);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_AMBIENT_COLOR, AmbientColor, ambientColor, xColor);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_SPECULAR_COLOR, SpecularColor, specularColor, xColor);
|
||||||
|
DEFINE_PROPERTY(PROP_CONSTANT_ATTENUATION, ConstantAttenuation, constantAttenuation, float);
|
||||||
|
DEFINE_PROPERTY(PROP_LINEAR_ATTENUATION, LinearAttenuation, linearAttenuation, float);
|
||||||
|
DEFINE_PROPERTY(PROP_QUADRATIC_ATTENUATION, QuadraticAttenuation, quadraticAttenuation, float);
|
||||||
|
DEFINE_PROPERTY(PROP_EXPONENT, Exponent, exponent, float);
|
||||||
|
DEFINE_PROPERTY(PROP_CUTOFF, Cutoff, cutoff, float);
|
||||||
|
DEFINE_PROPERTY(PROP_LOCKED, Locked, locked, bool);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_TEXTURES, Textures, textures, QString);
|
||||||
|
DEFINE_PROPERTY_REF_WITH_SETTER_AND_GETTER(PROP_ANIMATION_SETTINGS, AnimationSettings, animationSettings, QString);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_USER_DATA, UserData, userData, QString);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_TEXT, Text, text, QString);
|
||||||
|
DEFINE_PROPERTY(PROP_LINE_HEIGHT, LineHeight, lineHeight, float);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_TEXT_COLOR, TextColor, textColor, xColor);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_BACKGROUND_COLOR, BackgroundColor, backgroundColor, xColor);
|
||||||
|
|
||||||
// properties of all entities
|
public:
|
||||||
EntityTypes::EntityType getType() const { return _type; }
|
|
||||||
|
|
||||||
void setType(EntityTypes::EntityType type) { _type = type; }
|
|
||||||
|
|
||||||
const glm::vec3& getPosition() const { return _position; }
|
|
||||||
/// set position in meter units, will be clamped to domain bounds
|
|
||||||
void setPosition(const glm::vec3& value) { _position = glm::clamp(value, 0.0f, (float)TREE_SCALE); _positionChanged = true; }
|
|
||||||
|
|
||||||
|
|
||||||
const glm::vec3& getDimensions() const { return _dimensions; }
|
|
||||||
void setDimensions(const glm::vec3& value) { _dimensions = value; _dimensionsChanged = true; }
|
|
||||||
float getMaxDimension() const { return glm::max(_dimensions.x, _dimensions.y, _dimensions.z); }
|
float getMaxDimension() const { return glm::max(_dimensions.x, _dimensions.y, _dimensions.z); }
|
||||||
|
|
||||||
const glm::quat& getRotation() const { return _rotation; }
|
|
||||||
void setRotation(const glm::quat& rotation) { _rotation = rotation; _rotationChanged = true; }
|
|
||||||
|
|
||||||
float getMass() const { return _mass; }
|
|
||||||
void setMass(float value) { _mass = value; _massChanged = true; }
|
|
||||||
|
|
||||||
/// velocity in meters (0.0-1.0) per second
|
|
||||||
const glm::vec3& getVelocity() const { return _velocity; }
|
|
||||||
/// velocity in meters (0.0-1.0) per second
|
|
||||||
void setVelocity(const glm::vec3& value) { _velocity = value; _velocityChanged = true; }
|
|
||||||
|
|
||||||
/// gravity in meters (0.0-TREE_SCALE) per second squared
|
|
||||||
const glm::vec3& getGravity() const { return _gravity; }
|
|
||||||
/// gravity in meters (0.0-TREE_SCALE) per second squared
|
|
||||||
void setGravity(const glm::vec3& value) { _gravity = value; _gravityChanged = true; }
|
|
||||||
|
|
||||||
float getDamping() const { return _damping; }
|
|
||||||
void setDamping(float value) { _damping = value; _dampingChanged = true; }
|
|
||||||
|
|
||||||
float getLifetime() const { return _lifetime; } /// get the lifetime in seconds for the entity
|
|
||||||
void setLifetime(float value) { _lifetime = value; _lifetimeChanged = true; } /// set the lifetime in seconds for the entity
|
|
||||||
|
|
||||||
const QString& getUserData() const { return _userData; }
|
|
||||||
void setUserData(const QString& value) { _userData = value; _userDataChanged = true; }
|
|
||||||
|
|
||||||
float getAge() const { return (float)(usecTimestampNow() - _created) / (float)USECS_PER_SECOND; }
|
float getAge() const { return (float)(usecTimestampNow() - _created) / (float)USECS_PER_SECOND; }
|
||||||
quint64 getCreated() const { return _created; }
|
quint64 getCreated() const { return _created; }
|
||||||
void setCreated(quint64 usecTime) { _created = usecTime; }
|
void setCreated(quint64 usecTime) { _created = usecTime; }
|
||||||
bool hasCreatedTime() const { return (_created != UNKNOWN_CREATED_TIME); }
|
bool hasCreatedTime() const { return (_created != UNKNOWN_CREATED_TIME); }
|
||||||
|
|
||||||
|
|
||||||
// NOTE: how do we handle _defaultSettings???
|
|
||||||
bool containsBoundsProperties() const { return (_positionChanged || _dimensionsChanged); }
|
bool containsBoundsProperties() const { return (_positionChanged || _dimensionsChanged); }
|
||||||
bool containsPositionChange() const { return _positionChanged; }
|
bool containsPositionChange() const { return _positionChanged; }
|
||||||
bool containsDimensionsChange() const { return _dimensionsChanged; }
|
bool containsDimensionsChange() const { return _dimensionsChanged; }
|
||||||
|
|
||||||
// TODO: this need to be more generic. for now, we're going to have the properties class support these as
|
|
||||||
// named getter/setters, but we want to move them to generic types...
|
|
||||||
// properties we want to move to just models and particles
|
|
||||||
xColor getColor() const { return _color; }
|
|
||||||
const QString& getModelURL() const { return _modelURL; }
|
|
||||||
const QString& getAnimationURL() const { return _animationURL; }
|
|
||||||
float getAnimationFrameIndex() const { return _animationFrameIndex; }
|
|
||||||
bool getAnimationIsPlaying() const { return _animationIsPlaying; }
|
|
||||||
float getAnimationFPS() const { return _animationFPS; }
|
|
||||||
QString getAnimationSettings() const;
|
|
||||||
|
|
||||||
float getGlowLevel() const { return _glowLevel; }
|
float getGlowLevel() const { return _glowLevel; }
|
||||||
float getLocalRenderAlpha() const { return _localRenderAlpha; }
|
float getLocalRenderAlpha() const { return _localRenderAlpha; }
|
||||||
const QString& getScript() const { return _script; }
|
|
||||||
|
|
||||||
// model related properties
|
|
||||||
void setColor(const xColor& value) { _color = value; _colorChanged = true; }
|
|
||||||
void setModelURL(const QString& url) { _modelURL = url; _modelURLChanged = true; }
|
|
||||||
void setAnimationURL(const QString& url) { _animationURL = url; _animationURLChanged = true; }
|
|
||||||
void setAnimationFrameIndex(float value) { _animationFrameIndex = value; _animationFrameIndexChanged = true; }
|
|
||||||
void setAnimationIsPlaying(bool value) { _animationIsPlaying = value; _animationIsPlayingChanged = true; }
|
|
||||||
void setAnimationFPS(float value) { _animationFPS = value; _animationFPSChanged = true; }
|
|
||||||
void setAnimationSettings(const QString& value);
|
|
||||||
|
|
||||||
void setGlowLevel(float value) { _glowLevel = value; _glowLevelChanged = true; }
|
void setGlowLevel(float value) { _glowLevel = value; _glowLevelChanged = true; }
|
||||||
void setLocalRenderAlpha(float value) { _localRenderAlpha = value; _localRenderAlphaChanged = true; }
|
void setLocalRenderAlpha(float value) { _localRenderAlpha = value; _localRenderAlphaChanged = true; }
|
||||||
void setScript(const QString& value) { _script = value; _scriptChanged = true; }
|
|
||||||
|
|
||||||
|
|
||||||
static bool encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties,
|
static bool encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties,
|
||||||
unsigned char* bufferOut, int sizeIn, int& sizeOut);
|
unsigned char* bufferOut, int sizeIn, int& sizeOut);
|
||||||
|
@ -222,23 +202,6 @@ public:
|
||||||
static bool decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes,
|
static bool decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes,
|
||||||
EntityItemID& entityID, EntityItemProperties& properties);
|
EntityItemID& entityID, EntityItemProperties& properties);
|
||||||
|
|
||||||
bool positionChanged() const { return _positionChanged; }
|
|
||||||
bool rotationChanged() const { return _rotationChanged; }
|
|
||||||
bool massChanged() const { return _massChanged; }
|
|
||||||
bool velocityChanged() const { return _velocityChanged; }
|
|
||||||
bool gravityChanged() const { return _gravityChanged; }
|
|
||||||
bool dampingChanged() const { return _dampingChanged; }
|
|
||||||
bool lifetimeChanged() const { return _lifetimeChanged; }
|
|
||||||
bool userDataChanged() const { return _userDataChanged; }
|
|
||||||
bool scriptChanged() const { return _scriptChanged; }
|
|
||||||
bool dimensionsChanged() const { return _dimensionsChanged; }
|
|
||||||
bool registrationPointChanged() const { return _registrationPointChanged; }
|
|
||||||
bool colorChanged() const { return _colorChanged; }
|
|
||||||
bool modelURLChanged() const { return _modelURLChanged; }
|
|
||||||
bool animationURLChanged() const { return _animationURLChanged; }
|
|
||||||
bool animationIsPlayingChanged() const { return _animationIsPlayingChanged; }
|
|
||||||
bool animationFrameIndexChanged() const { return _animationFrameIndexChanged; }
|
|
||||||
bool animationFPSChanged() const { return _animationFPSChanged; }
|
|
||||||
bool glowLevelChanged() const { return _glowLevelChanged; }
|
bool glowLevelChanged() const { return _glowLevelChanged; }
|
||||||
bool localRenderAlphaChanged() const { return _localRenderAlphaChanged; }
|
bool localRenderAlphaChanged() const { return _localRenderAlphaChanged; }
|
||||||
|
|
||||||
|
@ -246,167 +209,26 @@ public:
|
||||||
void markAllChanged();
|
void markAllChanged();
|
||||||
|
|
||||||
void setSittingPoints(const QVector<SittingPoint>& sittingPoints);
|
void setSittingPoints(const QVector<SittingPoint>& sittingPoints);
|
||||||
|
|
||||||
const glm::vec3& getNaturalDimensions() const { return _naturalDimensions; }
|
const glm::vec3& getNaturalDimensions() const { return _naturalDimensions; }
|
||||||
void setNaturalDimensions(const glm::vec3& value) { _naturalDimensions = value; }
|
void setNaturalDimensions(const glm::vec3& value) { _naturalDimensions = value; }
|
||||||
|
|
||||||
const glm::vec3& getRegistrationPoint() const { return _registrationPoint; }
|
|
||||||
void setRegistrationPoint(const glm::vec3& value) { _registrationPoint = value; _registrationPointChanged = true; }
|
|
||||||
|
|
||||||
const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
|
|
||||||
void setAngularVelocity(const glm::vec3& value) { _angularVelocity = value; _angularVelocityChanged = true; }
|
|
||||||
|
|
||||||
float getAngularDamping() const { return _angularDamping; }
|
|
||||||
void setAngularDamping(float value) { _angularDamping = value; _angularDampingChanged = true; }
|
|
||||||
|
|
||||||
bool getVisible() const { return _visible; }
|
|
||||||
void setVisible(bool value) { _visible = value; _visibleChanged = true; }
|
|
||||||
|
|
||||||
bool getIgnoreForCollisions() const { return _ignoreForCollisions; }
|
|
||||||
void setIgnoreForCollisions(bool value) { _ignoreForCollisions = value; _ignoreForCollisionsChanged = true; }
|
|
||||||
|
|
||||||
bool getCollisionsWillMove() const { return _collisionsWillMove; }
|
|
||||||
void setCollisionsWillMove(bool value) { _collisionsWillMove = value; _collisionsWillMoveChanged = true; }
|
|
||||||
|
|
||||||
bool getIsSpotlight() const { return _isSpotlight; }
|
|
||||||
void setIsSpotlight(bool value) { _isSpotlight = value; _isSpotlightChanged = true; }
|
|
||||||
|
|
||||||
xColor getDiffuseColor() const { return _diffuseColor; }
|
|
||||||
xColor getAmbientColor() const { return _ambientColor; }
|
|
||||||
xColor getSpecularColor() const { return _specularColor; }
|
|
||||||
|
|
||||||
void setDiffuseColor(const xColor& value) { _diffuseColor = value; _diffuseColorChanged = true; }
|
|
||||||
void setAmbientColor(const xColor& value) { _ambientColor = value; _ambientColorChanged = true; }
|
|
||||||
void setSpecularColor(const xColor& value) { _specularColor = value; _specularColorChanged = true; }
|
|
||||||
|
|
||||||
bool diffuseColorChanged() const { return _colorChanged; }
|
|
||||||
bool ambientColorChanged() const { return _ambientColorChanged; }
|
|
||||||
bool specularColorChanged() const { return _specularColorChanged; }
|
|
||||||
|
|
||||||
float getConstantAttenuation() const { return _constantAttenuation; }
|
|
||||||
void setConstantAttenuation(float value) { _constantAttenuation = value; _constantAttenuationChanged = true; }
|
|
||||||
|
|
||||||
float getLinearAttenuation() const { return _linearAttenuation; }
|
|
||||||
void setLinearAttenuation(float value) { _linearAttenuation = value; _linearAttenuationChanged = true; }
|
|
||||||
|
|
||||||
float getQuadraticAttenuation() const { return _quadraticAttenuation; }
|
|
||||||
void setQuadraticAttenuation(float value) { _quadraticAttenuation = value; _quadraticAttenuationChanged = true; }
|
|
||||||
|
|
||||||
float getExponent() const { return _exponent; }
|
|
||||||
void setExponent(float value) { _exponent = value; _exponentChanged = true; }
|
|
||||||
|
|
||||||
float getCutoff() const { return _cutoff; }
|
|
||||||
void setCutoff(float value) { _cutoff = value; _cutoffChanged = true; }
|
|
||||||
|
|
||||||
bool getLocked() const { return _locked; }
|
|
||||||
void setLocked(bool value) { _locked = value; _lockedChanged = true; }
|
|
||||||
bool lockedChanged() const { return _lockedChanged; }
|
|
||||||
|
|
||||||
const QString& getTextures() const { return _textures; }
|
|
||||||
void setTextures(const QString& value) { _textures = value; _texturesChanged = true; }
|
|
||||||
|
|
||||||
const QStringList& getTextureNames() const { return _textureNames; }
|
const QStringList& getTextureNames() const { return _textureNames; }
|
||||||
void setTextureNames(const QStringList& value) { _textureNames = value; }
|
void setTextureNames(const QStringList& value) { _textureNames = value; }
|
||||||
|
|
||||||
void setLastEdited(quint64 usecTime) { _lastEdited = usecTime; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QUuid _id;
|
QUuid _id;
|
||||||
bool _idSet;
|
bool _idSet;
|
||||||
quint64 _lastEdited;
|
quint64 _lastEdited;
|
||||||
quint64 _created;
|
quint64 _created;
|
||||||
|
|
||||||
EntityTypes::EntityType _type;
|
EntityTypes::EntityType _type;
|
||||||
|
|
||||||
void setType(const QString& typeName) { _type = EntityTypes::getEntityTypeFromName(typeName); }
|
void setType(const QString& typeName) { _type = EntityTypes::getEntityTypeFromName(typeName); }
|
||||||
|
|
||||||
glm::vec3 _position;
|
|
||||||
glm::vec3 _dimensions;
|
|
||||||
glm::quat _rotation;
|
|
||||||
float _mass;
|
|
||||||
glm::vec3 _velocity;
|
|
||||||
glm::vec3 _gravity;
|
|
||||||
float _damping;
|
|
||||||
float _lifetime;
|
|
||||||
QString _userData;
|
|
||||||
QString _script;
|
|
||||||
glm::vec3 _registrationPoint;
|
|
||||||
glm::vec3 _angularVelocity;
|
|
||||||
float _angularDamping;
|
|
||||||
bool _visible;
|
|
||||||
bool _ignoreForCollisions;
|
|
||||||
bool _collisionsWillMove;
|
|
||||||
|
|
||||||
bool _positionChanged;
|
|
||||||
bool _dimensionsChanged;
|
|
||||||
bool _rotationChanged;
|
|
||||||
bool _massChanged;
|
|
||||||
bool _velocityChanged;
|
|
||||||
bool _gravityChanged;
|
|
||||||
bool _dampingChanged;
|
|
||||||
bool _lifetimeChanged;
|
|
||||||
bool _userDataChanged;
|
|
||||||
bool _scriptChanged;
|
|
||||||
bool _registrationPointChanged;
|
|
||||||
bool _angularVelocityChanged;
|
|
||||||
bool _angularDampingChanged;
|
|
||||||
bool _visibleChanged;
|
|
||||||
bool _ignoreForCollisionsChanged;
|
|
||||||
bool _collisionsWillMoveChanged;
|
|
||||||
|
|
||||||
// TODO: this need to be more generic. for now, we're going to have the properties class support these as
|
|
||||||
// named getter/setters, but we want to move them to generic types...
|
|
||||||
xColor _color;
|
|
||||||
QString _modelURL;
|
|
||||||
QString _animationURL;
|
|
||||||
bool _animationIsPlaying;
|
|
||||||
float _animationFrameIndex;
|
|
||||||
float _animationFPS;
|
|
||||||
QString _animationSettings;
|
|
||||||
float _glowLevel;
|
float _glowLevel;
|
||||||
float _localRenderAlpha;
|
float _localRenderAlpha;
|
||||||
bool _isSpotlight;
|
|
||||||
|
|
||||||
bool _colorChanged;
|
|
||||||
bool _modelURLChanged;
|
|
||||||
bool _animationURLChanged;
|
|
||||||
bool _animationIsPlayingChanged;
|
|
||||||
bool _animationFrameIndexChanged;
|
|
||||||
bool _animationFPSChanged;
|
|
||||||
bool _animationSettingsChanged;
|
|
||||||
bool _glowLevelChanged;
|
bool _glowLevelChanged;
|
||||||
bool _localRenderAlphaChanged;
|
bool _localRenderAlphaChanged;
|
||||||
bool _isSpotlightChanged;
|
|
||||||
|
|
||||||
xColor _diffuseColor;
|
|
||||||
xColor _ambientColor;
|
|
||||||
xColor _specularColor;
|
|
||||||
float _constantAttenuation;
|
|
||||||
float _linearAttenuation;
|
|
||||||
float _quadraticAttenuation;
|
|
||||||
float _exponent;
|
|
||||||
float _cutoff;
|
|
||||||
bool _locked;
|
|
||||||
QString _textures;
|
|
||||||
|
|
||||||
bool _diffuseColorChanged;
|
|
||||||
bool _ambientColorChanged;
|
|
||||||
bool _specularColorChanged;
|
|
||||||
bool _constantAttenuationChanged;
|
|
||||||
bool _linearAttenuationChanged;
|
|
||||||
bool _quadraticAttenuationChanged;
|
|
||||||
bool _exponentChanged;
|
|
||||||
bool _cutoffChanged;
|
|
||||||
bool _lockedChanged;
|
|
||||||
bool _texturesChanged;
|
|
||||||
|
|
||||||
DEFINE_PROPERTY_REF(PROP_TEXT, Text, text, QString);
|
|
||||||
DEFINE_PROPERTY(PROP_LINE_HEIGHT, LineHeight, lineHeight, float);
|
|
||||||
DEFINE_PROPERTY_REF(PROP_TEXT_COLOR, TextColor, textColor, xColor);
|
|
||||||
DEFINE_PROPERTY_REF(PROP_BACKGROUND_COLOR, BackgroundColor, backgroundColor, xColor);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool _defaultSettings;
|
bool _defaultSettings;
|
||||||
|
|
||||||
// NOTE: The following are pseudo client only properties. They are only used in clients which can access
|
// NOTE: The following are pseudo client only properties. They are only used in clients which can access
|
||||||
|
@ -420,6 +242,11 @@ QScriptValue EntityItemPropertiesToScriptValue(QScriptEngine* engine, const Enti
|
||||||
void EntityItemPropertiesFromScriptValue(const QScriptValue &object, EntityItemProperties& properties);
|
void EntityItemPropertiesFromScriptValue(const QScriptValue &object, EntityItemProperties& properties);
|
||||||
|
|
||||||
|
|
||||||
|
// define these inline here so the macros work
|
||||||
|
inline void EntityItemProperties::setPosition(const glm::vec3& value)
|
||||||
|
{ _position = glm::clamp(value, 0.0f, (float)TREE_SCALE); _positionChanged = true; }
|
||||||
|
|
||||||
|
|
||||||
inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
|
inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
|
||||||
debug << "EntityItemProperties[" << "\n"
|
debug << "EntityItemProperties[" << "\n"
|
||||||
<< " position:" << properties.getPosition() << "in meters" << "\n"
|
<< " position:" << properties.getPosition() << "in meters" << "\n"
|
||||||
|
|
|
@ -267,19 +267,39 @@
|
||||||
|
|
||||||
#define DEFINE_PROPERTY(P, N, n, T) \
|
#define DEFINE_PROPERTY(P, N, n, T) \
|
||||||
public: \
|
public: \
|
||||||
T get##N() const { return _##n; } \
|
T get##N() const { return _##n; } \
|
||||||
void set##N(T value) { _##n = value; _##n##Changed = true; } \
|
void set##N(T value) { _##n = value; _##n##Changed = true; } \
|
||||||
|
bool n##Changed() const { return _##n##Changed; } \
|
||||||
private: \
|
private: \
|
||||||
T _##n; \
|
T _##n; \
|
||||||
bool _##n##Changed;
|
bool _##n##Changed;
|
||||||
|
|
||||||
#define DEFINE_PROPERTY_REF(P, N, n, T) \
|
#define DEFINE_PROPERTY_REF(P, N, n, T) \
|
||||||
public: \
|
public: \
|
||||||
const T& get##N() const { return _##n; } \
|
const T& get##N() const { return _##n; } \
|
||||||
void set##N(const T& value) { _##n = value; _##n##Changed = true; } \
|
void set##N(const T& value) { _##n = value; _##n##Changed = true; } \
|
||||||
|
bool n##Changed() const { return _##n##Changed; } \
|
||||||
private: \
|
private: \
|
||||||
T _##n; \
|
T _##n; \
|
||||||
bool _##n##Changed;
|
bool _##n##Changed;
|
||||||
|
|
||||||
|
#define DEFINE_PROPERTY_REF_WITH_SETTER(P, N, n, T) \
|
||||||
|
public: \
|
||||||
|
const T& get##N() const { return _##n; } \
|
||||||
|
void set##N(const T& value); \
|
||||||
|
bool n##Changed() const; \
|
||||||
|
private: \
|
||||||
|
T _##n; \
|
||||||
|
bool _##n##Changed;
|
||||||
|
|
||||||
|
#define DEFINE_PROPERTY_REF_WITH_SETTER_AND_GETTER(P, N, n, T) \
|
||||||
|
public: \
|
||||||
|
T get##N() const; \
|
||||||
|
void set##N(const T& value); \
|
||||||
|
bool n##Changed() const; \
|
||||||
|
private: \
|
||||||
|
T _##n; \
|
||||||
|
bool _##n##Changed;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue