mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 19:23:04 +02:00
image has correct orientation and is collisionless
This commit is contained in:
parent
b5c42bfeca
commit
b56c78d36c
7 changed files with 24 additions and 14 deletions
Binary file not shown.
|
@ -187,9 +187,10 @@ Windows.ScrollingWindow {
|
|||
var textures = JSON.stringify({ "tex.picture": defaultURL});
|
||||
var shapeType = "box";
|
||||
var dynamic = false;
|
||||
var collisionless = true;
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation)));
|
||||
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 {
|
||||
var SHAPE_TYPE_NONE = 0;
|
||||
var SHAPE_TYPE_SIMPLE_HULL = 1;
|
||||
|
@ -234,6 +235,7 @@ Windows.ScrollingWindow {
|
|||
var result = JSON.parse(jsonResult);
|
||||
var url = result.textInput.trim();
|
||||
var shapeType;
|
||||
var collisionless = false;
|
||||
switch (result.comboBox) {
|
||||
case SHAPE_TYPE_SIMPLE_HULL:
|
||||
shapeType = "simple-hull";
|
||||
|
@ -252,6 +254,7 @@ Windows.ScrollingWindow {
|
|||
break;
|
||||
default:
|
||||
shapeType = "none";
|
||||
collisionless = true;
|
||||
}
|
||||
|
||||
var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT;
|
||||
|
@ -273,7 +276,7 @@ Windows.ScrollingWindow {
|
|||
print("Asset browser - adding asset " + url + " (" + name + ") to world.");
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -144,7 +144,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
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) {
|
||||
return false;
|
||||
|
@ -188,9 +188,10 @@ Rectangle {
|
|||
var textures = JSON.stringify({ "tex.picture": defaultURL});
|
||||
var shapeType = "box";
|
||||
var dynamic = false;
|
||||
var collisionless = true;
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation)));
|
||||
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 {
|
||||
var SHAPE_TYPE_NONE = 0;
|
||||
var SHAPE_TYPE_SIMPLE_HULL = 1;
|
||||
|
@ -235,6 +236,7 @@ Rectangle {
|
|||
var result = JSON.parse(jsonResult);
|
||||
var url = result.textInput.trim();
|
||||
var shapeType;
|
||||
var collisionless = false;
|
||||
switch (result.comboBox) {
|
||||
case SHAPE_TYPE_SIMPLE_HULL:
|
||||
shapeType = "simple-hull";
|
||||
|
@ -253,6 +255,7 @@ Rectangle {
|
|||
break;
|
||||
default:
|
||||
shapeType = "none";
|
||||
collisionless = true;
|
||||
}
|
||||
|
||||
var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT;
|
||||
|
@ -274,7 +277,7 @@ Rectangle {
|
|||
print("Asset browser - adding asset " + url + " (" + name + ") to world.");
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6605,8 +6605,8 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q
|
|||
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
||||
} else {
|
||||
// to prevent files that aren't models from being loaded into world automatically
|
||||
if (filePath.endsWith(OBJ_EXTENSION) || filePath.endsWith(FBX_EXTENSION) ||
|
||||
filePath.endsWith(JPG_EXTENSION) || filePath.endsWith(PNG_EXTENSION)) {
|
||||
if (filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) ||
|
||||
filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION)) {
|
||||
addAssetToWorldAddEntity(filePath, mapping);
|
||||
} else {
|
||||
qCDebug(interfaceapp) << "Zipped contents are not supported entity files";
|
||||
|
@ -6623,7 +6623,7 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) {
|
|||
EntityItemProperties properties;
|
||||
properties.setType(EntityTypes::Model);
|
||||
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 {
|
||||
{"tex.picture", QString("atp:" + mapping) }
|
||||
};
|
||||
|
@ -6719,7 +6719,9 @@ void Application::addAssetToWorldCheckModelSize() {
|
|||
EntityItemProperties properties;
|
||||
properties.setDimensions(dimensions);
|
||||
properties.setVisible(true);
|
||||
properties.setCollisionless(false);
|
||||
if (!name.toLower().endsWith(PNG_EXTENSION) && !name.toLower().endsWith(JPG_EXTENSION)) {
|
||||
properties.setCollisionless(false);
|
||||
}
|
||||
properties.setUserData(GRABBABLE_USER_DATA);
|
||||
properties.setLastEdited(usecTimestampNow());
|
||||
entityScriptingInterface->editEntity(entityID, properties);
|
||||
|
|
|
@ -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,
|
||||
bool dynamic, const glm::vec3& position, const glm::vec3& gravity) {
|
||||
bool dynamic, bool collisionless, const glm::vec3& position, const glm::vec3& gravity) {
|
||||
_activityTracking.addedEntityCount++;
|
||||
|
||||
EntityItemProperties properties;
|
||||
|
@ -314,6 +314,7 @@ QUuid EntityScriptingInterface::addModelEntity(const QString& name, const QStrin
|
|||
properties.setModelURL(modelUrl);
|
||||
properties.setShapeTypeFromString(shapeType);
|
||||
properties.setDynamic(dynamic);
|
||||
properties.setCollisionless(collisionless);
|
||||
properties.setPosition(position);
|
||||
properties.setGravity(gravity);
|
||||
if (!textures.isEmpty()) {
|
||||
|
|
|
@ -165,7 +165,7 @@ public slots:
|
|||
/// temporary method until addEntity can be used from QJSEngine
|
||||
/// 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,
|
||||
const glm::vec3& position, const glm::vec3& gravity);
|
||||
bool collisionless, const glm::vec3& position, const glm::vec3& gravity);
|
||||
|
||||
/**jsdoc
|
||||
* Return the properties for the specified {EntityID}.
|
||||
|
|
|
@ -565,11 +565,12 @@ var toolBar = (function () {
|
|||
createNewEntity({
|
||||
type: "Model",
|
||||
dimensions: {
|
||||
x: 4.16,
|
||||
y: 0.02,
|
||||
z: 2.58
|
||||
x: 0.5385,
|
||||
y: 0.2819,
|
||||
z: 0.0092
|
||||
},
|
||||
shapeType: "box",
|
||||
collisionless: true,
|
||||
modelURL: IMAGE_MODEL,
|
||||
textures: JSON.stringify({ "tex.picture": DEFAULT_IMAGE })
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue