mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 09:44:33 +02:00
more model naming cleanup and fixing example scripts
This commit is contained in:
parent
5b8be780a7
commit
3e1401014d
4 changed files with 39 additions and 38 deletions
|
@ -21,6 +21,7 @@ var roll = 0.0;
|
|||
var rotation = Quat.fromPitchYawRollDegrees(pitch, yaw, roll)
|
||||
|
||||
var originalProperties = {
|
||||
type: "Model",
|
||||
position: { x: MyAvatar.position.x,
|
||||
y: MyAvatar.position.y,
|
||||
z: MyAvatar.position.z },
|
||||
|
@ -37,8 +38,8 @@ var originalProperties = {
|
|||
animationIsPlaying: true,
|
||||
};
|
||||
|
||||
var modelID = Models.addModel(originalProperties);
|
||||
print("Models.addModel()... modelID.creatorTokenID = " + modelID.creatorTokenID);
|
||||
var modelID = Entities.addEntity(originalProperties);
|
||||
print("Entities.addEntity()... modelID.creatorTokenID = " + modelID.creatorTokenID);
|
||||
|
||||
var isPlaying = true;
|
||||
var playPauseEveryWhile = 360;
|
||||
|
@ -48,6 +49,7 @@ var resetFrameEveryWhile = 600;
|
|||
|
||||
function moveModel(deltaTime) {
|
||||
var somethingChanged = false;
|
||||
print("count= " + count);
|
||||
if (count % playPauseEveryWhile == 0) {
|
||||
isPlaying = !isPlaying;
|
||||
print("isPlaying=" + isPlaying);
|
||||
|
@ -56,11 +58,11 @@ function moveModel(deltaTime) {
|
|||
|
||||
if (count % adjustFPSEveryWhile == 0) {
|
||||
if (animationFPS == 30) {
|
||||
animationFPS = 30;
|
||||
} else if (animationFPS == 10) {
|
||||
animationFPS = 10;
|
||||
} else if (animationFPS == 60) {
|
||||
} else if (animationFPS == 10) {
|
||||
animationFPS = 60;
|
||||
} else if (animationFPS == 60) {
|
||||
animationFPS = 30;
|
||||
}
|
||||
print("animationFPS=" + animationFPS);
|
||||
isPlaying = true;
|
||||
|
@ -78,7 +80,7 @@ function moveModel(deltaTime) {
|
|||
// delete it...
|
||||
if (count == moveUntil) {
|
||||
print("calling Models.deleteModel()");
|
||||
Models.deleteModel(modelID);
|
||||
Entities.deleteEntity(modelID);
|
||||
}
|
||||
|
||||
// stop it...
|
||||
|
@ -107,7 +109,7 @@ function moveModel(deltaTime) {
|
|||
resetFrame = false;
|
||||
}
|
||||
|
||||
Models.editModel(modelID, newProperties);
|
||||
Entities.editEntity(modelID, newProperties);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ function mousePressEvent(event) {
|
|||
// Compute trajectories related values
|
||||
var pickRay = Camera.computePickRay(mouseLastX, mouseLastY);
|
||||
var voxelIntersection = Voxels.findRayIntersection(pickRay);
|
||||
var modelIntersection = Models.findRayIntersection(pickRay);
|
||||
var modelIntersection = Entities.findRayIntersection(pickRay);
|
||||
|
||||
position = Camera.getPosition();
|
||||
|
||||
|
@ -218,7 +218,7 @@ function mousePressEvent(event) {
|
|||
|
||||
if (modelIntersection.intersects && modelIntersection.accurate) {
|
||||
distance = modelIntersection.distance;
|
||||
center = modelIntersection.modelProperties.position;
|
||||
center = modelIntersection.properties.position;
|
||||
string = "Inspecting model";
|
||||
}
|
||||
|
||||
|
|
|
@ -42,16 +42,16 @@ function mouseMoveEvent(event) {
|
|||
print("voxelAt.red/green/blue=" + voxelAt.red + ", " + voxelAt.green + ", " + voxelAt.blue);
|
||||
}
|
||||
|
||||
intersection = Models.findRayIntersection(pickRay);
|
||||
intersection = Entities.findRayIntersection(pickRay);
|
||||
if (!intersection.accurate) {
|
||||
print(">>> NOTE: intersection not accurate. will try calling Models.findRayIntersectionBlocking()");
|
||||
intersection = Models.findRayIntersectionBlocking(pickRay);
|
||||
print(">>> NOTE: intersection not accurate. will try calling Entities.findRayIntersectionBlocking()");
|
||||
intersection = Entities.findRayIntersectionBlocking(pickRay);
|
||||
print(">>> AFTER BLOCKING CALL intersection.accurate=" + intersection.accurate);
|
||||
}
|
||||
|
||||
if (intersection.intersects) {
|
||||
print("intersection modelID.id=" + intersection.modelID.id);
|
||||
print("intersection modelProperties.modelURL=" + intersection.modelProperties.modelURL);
|
||||
print("intersection entityID.id=" + intersection.entityID.id);
|
||||
print("intersection properties.modelURL=" + intersection.properties.modelURL);
|
||||
print("intersection face=" + intersection.face);
|
||||
print("intersection distance=" + intersection.distance);
|
||||
print("intersection intersection.x/y/z=" + intersection.intersection.x + ", "
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// EntityScriptingInterface.cpp
|
||||
// libraries/models/src
|
||||
// libraries/entities/src
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/6/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
|
@ -19,7 +19,6 @@ EntityScriptingInterface::EntityScriptingInterface() :
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
|
||||
EntityItemID entityID, const EntityItemProperties& properties) {
|
||||
getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties);
|
||||
|
@ -35,7 +34,7 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro
|
|||
// queue the packet
|
||||
queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
||||
|
||||
// If we have a local model tree set, then also update it.
|
||||
// If we have a local entity tree set, then also update it.
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForWrite();
|
||||
_entityTree->addEntity(id, properties);
|
||||
|
@ -93,20 +92,20 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID
|
|||
EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {
|
||||
EntityItemID actualID = entityID;
|
||||
|
||||
// if the model is unknown, attempt to look it up
|
||||
// if the entity is unknown, attempt to look it up
|
||||
if (!entityID.isKnownID) {
|
||||
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
||||
}
|
||||
|
||||
// if at this point, we know the id, send the update to the model server
|
||||
// if at this point, we know the id, send the update to the entity server
|
||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||
entityID.id = actualID.id;
|
||||
entityID.isKnownID = true;
|
||||
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
|
||||
}
|
||||
|
||||
// If we have a local model tree set, then also update it. We can do this even if we don't know
|
||||
// the actual id, because we can edit out local models just with creatorTokenID
|
||||
// If we have a local entity tree set, then also update it. We can do this even if we don't know
|
||||
// the actual id, because we can edit out local entities just with creatorTokenID
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForWrite();
|
||||
_entityTree->updateEntity(entityID, properties);
|
||||
|
@ -119,19 +118,19 @@ void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {
|
|||
|
||||
EntityItemID actualID = entityID;
|
||||
|
||||
// if the model is unknown, attempt to look it up
|
||||
// if the entity is unknown, attempt to look it up
|
||||
if (!entityID.isKnownID) {
|
||||
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
||||
}
|
||||
|
||||
// if at this point, we know the id, send the update to the model server
|
||||
// if at this point, we know the id, send the update to the entity server
|
||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||
entityID.id = actualID.id;
|
||||
entityID.isKnownID = true;
|
||||
getEntityPacketSender()->queueEraseEntityMessage(entityID);
|
||||
}
|
||||
|
||||
// If we have a local model tree set, then also update it.
|
||||
// If we have a local entity tree set, then also update it.
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForWrite();
|
||||
_entityTree->deleteEntity(entityID);
|
||||
|
@ -167,12 +166,12 @@ QVector<EntityItemID> EntityScriptingInterface::findEntities(const glm::vec3& ce
|
|||
QVector<EntityItemID> result;
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForRead();
|
||||
QVector<const EntityItem*> models;
|
||||
_entityTree->findEntities(center/(float)TREE_SCALE, radius/(float)TREE_SCALE, models);
|
||||
QVector<const EntityItem*> entities;
|
||||
_entityTree->findEntities(center/(float)TREE_SCALE, radius/(float)TREE_SCALE, entities);
|
||||
_entityTree->unlock();
|
||||
|
||||
foreach (const EntityItem* model, models) {
|
||||
EntityItemID thisEntityItemID(model->getID(), UNKNOWN_ENTITY_TOKEN, true);
|
||||
foreach (const EntityItem* entity, entities) {
|
||||
EntityItemID thisEntityItemID(entity->getID(), UNKNOWN_ENTITY_TOKEN, true);
|
||||
result << thisEntityItemID;
|
||||
}
|
||||
}
|
||||
|
@ -219,11 +218,11 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c
|
|||
QScriptValue obj = engine->newObject();
|
||||
obj.setProperty("intersects", value.intersects);
|
||||
obj.setProperty("accurate", value.accurate);
|
||||
QScriptValue modelItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
|
||||
obj.setProperty("entityID", modelItemValue);
|
||||
QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
|
||||
obj.setProperty("entityID", entityItemValue);
|
||||
|
||||
QScriptValue modelPropertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties);
|
||||
obj.setProperty("properties", modelPropertiesValue);
|
||||
QScriptValue propertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties);
|
||||
obj.setProperty("properties", propertiesValue);
|
||||
|
||||
obj.setProperty("distance", value.distance);
|
||||
|
||||
|
@ -262,13 +261,13 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c
|
|||
void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {
|
||||
value.intersects = object.property("intersects").toVariant().toBool();
|
||||
value.accurate = object.property("accurate").toVariant().toBool();
|
||||
QScriptValue modelIDValue = object.property("entityID");
|
||||
if (modelIDValue.isValid()) {
|
||||
EntityItemIDfromScriptValue(modelIDValue, value.entityID);
|
||||
QScriptValue entityIDValue = object.property("entityID");
|
||||
if (entityIDValue.isValid()) {
|
||||
EntityItemIDfromScriptValue(entityIDValue, value.entityID);
|
||||
}
|
||||
QScriptValue modelPropertiesValue = object.property("properties");
|
||||
if (modelPropertiesValue.isValid()) {
|
||||
EntityItemPropertiesFromScriptValue(modelPropertiesValue, value.properties);
|
||||
QScriptValue entityPropertiesValue = object.property("properties");
|
||||
if (entityPropertiesValue.isValid()) {
|
||||
EntityItemPropertiesFromScriptValue(entityPropertiesValue, value.properties);
|
||||
}
|
||||
value.distance = object.property("distance").toVariant().toFloat();
|
||||
|
||||
|
|
Loading…
Reference in a new issue