mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:44:21 +02:00
Models.addModel now returns a more accurate modelID
This commit is contained in:
parent
0bdd20abc9
commit
150477eea4
3 changed files with 11 additions and 24 deletions
|
@ -47,6 +47,12 @@ uint32_t ModelItem::getNextCreatorTokenID() {
|
|||
return creatorTokenID;
|
||||
}
|
||||
|
||||
uint32_t ModelItem::getNextModelItemID() {
|
||||
uint32_t modelID = _nextID;
|
||||
_nextID++;
|
||||
return modelID;
|
||||
}
|
||||
|
||||
void ModelItem::handleAddModelResponse(const QByteArray& packet) {
|
||||
const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(packet.data());
|
||||
int numBytesPacketHeader = numBytesForPacketHeader(packet);
|
||||
|
@ -70,31 +76,10 @@ ModelItem::ModelItem() {
|
|||
}
|
||||
|
||||
ModelItem::ModelItem(const ModelItemID& modelItemID, const ModelItemProperties& properties) {
|
||||
_id = modelItemID.id;
|
||||
_creatorTokenID = modelItemID.creatorTokenID;
|
||||
|
||||
// init values with defaults before calling setProperties
|
||||
uint64_t now = usecTimestampNow();
|
||||
_lastEdited = now;
|
||||
_lastUpdated = now;
|
||||
|
||||
_position = glm::vec3(0,0,0);
|
||||
_radius = 0;
|
||||
rgbColor noColor = { 0, 0, 0 };
|
||||
memcpy(_color, noColor, sizeof(_color));
|
||||
_shouldDie = false;
|
||||
_modelURL = MODEL_DEFAULT_MODEL_URL;
|
||||
_modelRotation = MODEL_DEFAULT_MODEL_ROTATION;
|
||||
|
||||
// animation related
|
||||
_animationURL = MODEL_DEFAULT_ANIMATION_URL;
|
||||
_animationIsPlaying = false;
|
||||
_animationFrameIndex = 0.0f;
|
||||
_animationFPS = MODEL_DEFAULT_ANIMATION_FPS;
|
||||
_glowLevel = 0.0f;
|
||||
|
||||
_jointMappingCompleted = false;
|
||||
_lastAnimated = now;
|
||||
rgbColor defaultColor = { 0, 0, 0 };
|
||||
init(glm::vec3(), 0.0f, defaultColor, modelItemID.id);
|
||||
|
||||
setProperties(properties);
|
||||
}
|
||||
|
|
|
@ -276,6 +276,7 @@ public:
|
|||
// these methods allow you to create models, and later edit them.
|
||||
static uint32_t getIDfromCreatorTokenID(uint32_t creatorTokenID);
|
||||
static uint32_t getNextCreatorTokenID();
|
||||
static uint32_t getNextModelItemID();
|
||||
static void handleAddModelResponse(const QByteArray& packet);
|
||||
|
||||
void mapJoints(const QStringList& modelJointNames);
|
||||
|
|
|
@ -28,8 +28,9 @@ ModelItemID ModelsScriptingInterface::addModel(const ModelItemProperties& proper
|
|||
|
||||
// The application will keep track of creatorTokenID
|
||||
uint32_t creatorTokenID = ModelItem::getNextCreatorTokenID();
|
||||
uint32_t modelID = ModelItem::getNextModelItemID();
|
||||
|
||||
ModelItemID id(NEW_MODEL, creatorTokenID, false );
|
||||
ModelItemID id(modelID, creatorTokenID, false );
|
||||
|
||||
// queue the packet
|
||||
queueModelMessage(PacketTypeModelAddOrEdit, id, properties);
|
||||
|
|
Loading…
Reference in a new issue