image has correct orientation and is collisionless

This commit is contained in:
Elisa Lupin-Jimenez 2018-02-23 17:06:29 -08:00
parent b5c42bfeca
commit b56c78d36c
7 changed files with 24 additions and 14 deletions

View file

@ -187,9 +187,10 @@ Windows.ScrollingWindow {
var textures = JSON.stringify({ "tex.picture": defaultURL}); var textures = JSON.stringify({ "tex.picture": defaultURL});
var shapeType = "box"; var shapeType = "box";
var dynamic = false; var dynamic = false;
var collisionless = true;
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation))); var position = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation)));
var gravity = Vec3.multiply(Vec3.fromPolar(Math.PI / 2, 0), 0); var gravity = Vec3.multiply(Vec3.fromPolar(Math.PI / 2, 0), 0);
Entities.addModelEntity(name, modelURL, textures, shapeType, dynamic, position, gravity); Entities.addModelEntity(name, modelURL, textures, shapeType, dynamic, collisionless, position, gravity);
} else { } else {
var SHAPE_TYPE_NONE = 0; var SHAPE_TYPE_NONE = 0;
var SHAPE_TYPE_SIMPLE_HULL = 1; var SHAPE_TYPE_SIMPLE_HULL = 1;
@ -234,6 +235,7 @@ Windows.ScrollingWindow {
var result = JSON.parse(jsonResult); var result = JSON.parse(jsonResult);
var url = result.textInput.trim(); var url = result.textInput.trim();
var shapeType; var shapeType;
var collisionless = false;
switch (result.comboBox) { switch (result.comboBox) {
case SHAPE_TYPE_SIMPLE_HULL: case SHAPE_TYPE_SIMPLE_HULL:
shapeType = "simple-hull"; shapeType = "simple-hull";
@ -252,6 +254,7 @@ Windows.ScrollingWindow {
break; break;
default: default:
shapeType = "none"; shapeType = "none";
collisionless = true;
} }
var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT; var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT;
@ -273,7 +276,7 @@ Windows.ScrollingWindow {
print("Asset browser - adding asset " + url + " (" + name + ") to world."); print("Asset browser - adding asset " + url + " (" + name + ") to world.");
// Entities.addEntity doesn't work from QML, so we use this. // Entities.addEntity doesn't work from QML, so we use this.
Entities.addModelEntity(name, url, "", shapeType, dynamic, addPosition, gravity); Entities.addModelEntity(name, url, "", shapeType, dynamic, collisionless, addPosition, gravity);
} }
} }
}); });

View file

@ -144,7 +144,7 @@ Rectangle {
} }
function canAddToWorld(path) { function canAddToWorld(path) {
var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i]; var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i, /\.jpg\b/i, /\.png\b/i];
if (selectedItemCount > 1) { if (selectedItemCount > 1) {
return false; return false;
@ -188,9 +188,10 @@ Rectangle {
var textures = JSON.stringify({ "tex.picture": defaultURL}); var textures = JSON.stringify({ "tex.picture": defaultURL});
var shapeType = "box"; var shapeType = "box";
var dynamic = false; var dynamic = false;
var collisionless = true;
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation))); var position = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation)));
var gravity = Vec3.multiply(Vec3.fromPolar(Math.PI / 2, 0), 0); var gravity = Vec3.multiply(Vec3.fromPolar(Math.PI / 2, 0), 0);
Entities.addModelEntity(name, modelURL, textures, shapeType, dynamic, position, gravity); Entities.addModelEntity(name, modelURL, textures, shapeType, dynamic, collisionless, position, gravity);
} else { } else {
var SHAPE_TYPE_NONE = 0; var SHAPE_TYPE_NONE = 0;
var SHAPE_TYPE_SIMPLE_HULL = 1; var SHAPE_TYPE_SIMPLE_HULL = 1;
@ -235,6 +236,7 @@ Rectangle {
var result = JSON.parse(jsonResult); var result = JSON.parse(jsonResult);
var url = result.textInput.trim(); var url = result.textInput.trim();
var shapeType; var shapeType;
var collisionless = false;
switch (result.comboBox) { switch (result.comboBox) {
case SHAPE_TYPE_SIMPLE_HULL: case SHAPE_TYPE_SIMPLE_HULL:
shapeType = "simple-hull"; shapeType = "simple-hull";
@ -253,6 +255,7 @@ Rectangle {
break; break;
default: default:
shapeType = "none"; shapeType = "none";
collisionless = true;
} }
var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT; var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT;
@ -274,7 +277,7 @@ Rectangle {
print("Asset browser - adding asset " + url + " (" + name + ") to world."); print("Asset browser - adding asset " + url + " (" + name + ") to world.");
// Entities.addEntity doesn't work from QML, so we use this. // Entities.addEntity doesn't work from QML, so we use this.
Entities.addModelEntity(name, url, "", shapeType, dynamic, addPosition, gravity); Entities.addModelEntity(name, url, "", shapeType, dynamic, collisionless, addPosition, gravity);
} }
} }
}); });

View file

@ -6605,8 +6605,8 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q
addAssetToWorldError(filenameFromPath(filePath), errorInfo); addAssetToWorldError(filenameFromPath(filePath), errorInfo);
} else { } else {
// to prevent files that aren't models from being loaded into world automatically // to prevent files that aren't models from being loaded into world automatically
if (filePath.endsWith(OBJ_EXTENSION) || filePath.endsWith(FBX_EXTENSION) || if (filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) ||
filePath.endsWith(JPG_EXTENSION) || filePath.endsWith(PNG_EXTENSION)) { filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION)) {
addAssetToWorldAddEntity(filePath, mapping); addAssetToWorldAddEntity(filePath, mapping);
} else { } else {
qCDebug(interfaceapp) << "Zipped contents are not supported entity files"; qCDebug(interfaceapp) << "Zipped contents are not supported entity files";
@ -6623,7 +6623,7 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) {
EntityItemProperties properties; EntityItemProperties properties;
properties.setType(EntityTypes::Model); properties.setType(EntityTypes::Model);
properties.setName(mapping.right(mapping.length() - 1)); properties.setName(mapping.right(mapping.length() - 1));
if (filePath.endsWith(PNG_EXTENSION) || filePath.endsWith(JPG_EXTENSION)) { if (filePath.toLower().endsWith(PNG_EXTENSION) || filePath.toLower().endsWith(JPG_EXTENSION)) {
QJsonObject textures { QJsonObject textures {
{"tex.picture", QString("atp:" + mapping) } {"tex.picture", QString("atp:" + mapping) }
}; };
@ -6719,7 +6719,9 @@ void Application::addAssetToWorldCheckModelSize() {
EntityItemProperties properties; EntityItemProperties properties;
properties.setDimensions(dimensions); properties.setDimensions(dimensions);
properties.setVisible(true); properties.setVisible(true);
if (!name.toLower().endsWith(PNG_EXTENSION) && !name.toLower().endsWith(JPG_EXTENSION)) {
properties.setCollisionless(false); properties.setCollisionless(false);
}
properties.setUserData(GRABBABLE_USER_DATA); properties.setUserData(GRABBABLE_USER_DATA);
properties.setLastEdited(usecTimestampNow()); properties.setLastEdited(usecTimestampNow());
entityScriptingInterface->editEntity(entityID, properties); entityScriptingInterface->editEntity(entityID, properties);

View file

@ -305,7 +305,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
} }
QUuid EntityScriptingInterface::addModelEntity(const QString& name, const QString& modelUrl, const QString& textures, const QString& shapeType, QUuid EntityScriptingInterface::addModelEntity(const QString& name, const QString& modelUrl, const QString& textures, const QString& shapeType,
bool dynamic, const glm::vec3& position, const glm::vec3& gravity) { bool dynamic, bool collisionless, const glm::vec3& position, const glm::vec3& gravity) {
_activityTracking.addedEntityCount++; _activityTracking.addedEntityCount++;
EntityItemProperties properties; EntityItemProperties properties;
@ -314,6 +314,7 @@ QUuid EntityScriptingInterface::addModelEntity(const QString& name, const QStrin
properties.setModelURL(modelUrl); properties.setModelURL(modelUrl);
properties.setShapeTypeFromString(shapeType); properties.setShapeTypeFromString(shapeType);
properties.setDynamic(dynamic); properties.setDynamic(dynamic);
properties.setCollisionless(collisionless);
properties.setPosition(position); properties.setPosition(position);
properties.setGravity(gravity); properties.setGravity(gravity);
if (!textures.isEmpty()) { if (!textures.isEmpty()) {

View file

@ -165,7 +165,7 @@ public slots:
/// temporary method until addEntity can be used from QJSEngine /// temporary method until addEntity can be used from QJSEngine
/// Deliberately not adding jsdoc, only used internally. /// Deliberately not adding jsdoc, only used internally.
Q_INVOKABLE QUuid addModelEntity(const QString& name, const QString& modelUrl, const QString& textures, const QString& shapeType, bool dynamic, Q_INVOKABLE QUuid addModelEntity(const QString& name, const QString& modelUrl, const QString& textures, const QString& shapeType, bool dynamic,
const glm::vec3& position, const glm::vec3& gravity); bool collisionless, const glm::vec3& position, const glm::vec3& gravity);
/**jsdoc /**jsdoc
* Return the properties for the specified {EntityID}. * Return the properties for the specified {EntityID}.

View file

@ -565,11 +565,12 @@ var toolBar = (function () {
createNewEntity({ createNewEntity({
type: "Model", type: "Model",
dimensions: { dimensions: {
x: 4.16, x: 0.5385,
y: 0.02, y: 0.2819,
z: 2.58 z: 0.0092
}, },
shapeType: "box", shapeType: "box",
collisionless: true,
modelURL: IMAGE_MODEL, modelURL: IMAGE_MODEL,
textures: JSON.stringify({ "tex.picture": DEFAULT_IMAGE }) textures: JSON.stringify({ "tex.picture": DEFAULT_IMAGE })
}); });