mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
move glow effect to property of all entities, add tools for editing boxes
This commit is contained in:
parent
ebe7182ab6
commit
b7b89dcbec
7 changed files with 153 additions and 40 deletions
|
@ -1079,6 +1079,7 @@ function checkController(deltaTime) {
|
|||
}
|
||||
var newModel;
|
||||
var browser;
|
||||
var newBox;
|
||||
function initToolBar() {
|
||||
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL);
|
||||
// New Model
|
||||
|
@ -1095,6 +1096,13 @@ function initToolBar() {
|
|||
visible: true,
|
||||
alpha: 0.7
|
||||
});
|
||||
newBox = toolBar.addTool({
|
||||
imageURL: toolIconUrl + "add-model-tool.svg",
|
||||
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||
width: toolWidth, height: toolHeight,
|
||||
visible: true,
|
||||
alpha: 0.9
|
||||
});
|
||||
}
|
||||
|
||||
function moveOverlays() {
|
||||
|
@ -1159,7 +1167,8 @@ function Tooltip() {
|
|||
}
|
||||
this.updateText = function(properties) {
|
||||
var angles = Quat.safeEulerAngles(properties.rotation);
|
||||
var text = "Model Properties:\n"
|
||||
var text = "Entity Properties:\n"
|
||||
text += "type: " + properties.type + "\n"
|
||||
text += "X: " + properties.position.x.toFixed(this.decimals) + "\n"
|
||||
text += "Y: " + properties.position.y.toFixed(this.decimals) + "\n"
|
||||
text += "Z: " + properties.position.z.toFixed(this.decimals) + "\n"
|
||||
|
@ -1208,7 +1217,6 @@ function mousePressEvent(event) {
|
|||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
print(">>>>> CALLING >>>>> Entities.addEntity(newProperties);");
|
||||
Entities.addEntity({
|
||||
type: "Model",
|
||||
position: position,
|
||||
|
@ -1219,6 +1227,20 @@ print(">>>>> CALLING >>>>> Entities.addEntity(newProperties);");
|
|||
print("Can't create model: Model would be out of bounds.");
|
||||
}
|
||||
|
||||
} else if (newBox == toolBar.clicked(clickedOverlay)) {
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
Entities.addEntity({
|
||||
type: "Box",
|
||||
position: position,
|
||||
radius: radiusDefault,
|
||||
color: { red: 255, green: 0, blue: 0 }
|
||||
});
|
||||
} else {
|
||||
print("Can't create box: Box would be out of bounds.");
|
||||
}
|
||||
|
||||
} else if (browser == toolBar.clicked(clickedOverlay)) {
|
||||
var url = Window.s3Browse(".*(fbx|FBX)");
|
||||
if (url == null || url == "") {
|
||||
|
@ -1228,7 +1250,6 @@ print(">>>>> CALLING >>>>> Entities.addEntity(newProperties);");
|
|||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
print(">>>>> CALLING >>>>> Entities.addEntity(newProperties);");
|
||||
Entities.addEntity({
|
||||
type: "Model",
|
||||
position: position,
|
||||
|
@ -1583,9 +1604,11 @@ function handeMenuEvent(menuItem){
|
|||
|
||||
var array = new Array();
|
||||
var decimals = 3;
|
||||
array.push({ label: "Model URL:", value: properties.modelURL });
|
||||
array.push({ label: "Animation URL:", value: properties.animationURL });
|
||||
array.push({ label: "Animation is playing:", value: properties.animationIsPlaying });
|
||||
if (properties.type == "Model") {
|
||||
array.push({ label: "Model URL:", value: properties.modelURL });
|
||||
array.push({ label: "Animation URL:", value: properties.animationURL });
|
||||
array.push({ label: "Animation is playing:", value: properties.animationIsPlaying });
|
||||
}
|
||||
array.push({ label: "X:", value: properties.position.x.toFixed(decimals) });
|
||||
array.push({ label: "Y:", value: properties.position.y.toFixed(decimals) });
|
||||
array.push({ label: "Z:", value: properties.position.z.toFixed(decimals) });
|
||||
|
@ -1594,14 +1617,22 @@ function handeMenuEvent(menuItem){
|
|||
array.push({ label: "Yaw:", value: angles.y.toFixed(decimals) });
|
||||
array.push({ label: "Roll:", value: angles.z.toFixed(decimals) });
|
||||
array.push({ label: "Scale:", value: 2 * properties.radius.toFixed(decimals) });
|
||||
|
||||
if (properties.type == "Box") {
|
||||
array.push({ label: "Red:", value: properties.color.red });
|
||||
array.push({ label: "Green:", value: properties.color.green });
|
||||
array.push({ label: "Blue:", value: properties.color.blue });
|
||||
}
|
||||
|
||||
var propertyName = Window.form("Edit Properties", array);
|
||||
modelSelected = false;
|
||||
|
||||
var index = 0;
|
||||
properties.modelURL = array[index++].value;
|
||||
properties.animationURL = array[index++].value;
|
||||
properties.animationIsPlaying = array[index++].value;
|
||||
if (properties.type == "Model") {
|
||||
properties.modelURL = array[index++].value;
|
||||
properties.animationURL = array[index++].value;
|
||||
properties.animationIsPlaying = array[index++].value;
|
||||
}
|
||||
properties.position.x = array[index++].value;
|
||||
properties.position.y = array[index++].value;
|
||||
properties.position.z = array[index++].value;
|
||||
|
@ -1610,7 +1641,11 @@ function handeMenuEvent(menuItem){
|
|||
angles.z = array[index++].value;
|
||||
properties.modelRotation = Quat.fromVec3Degrees(angles);
|
||||
properties.radius = array[index++].value / 2;
|
||||
|
||||
if (properties.type == "Box") {
|
||||
properties.color.red = array[index++].value;
|
||||
properties.color.green = array[index++].value;
|
||||
properties.color.blue = array[index++].value;
|
||||
}
|
||||
Entities.editEntity(editModelID, properties);
|
||||
}
|
||||
} else if (menuItem == "Paste Models") {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <ModelEntityItem.h>
|
||||
#include <BoxEntityItem.h>
|
||||
|
||||
|
||||
#include "Menu.h"
|
||||
|
@ -257,12 +258,22 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
|
|||
// TODO: some entity types (like lights) might want to be rendered even
|
||||
// when they are outside of the view frustum...
|
||||
if (args->_viewFrustum->cubeInFrustum(entityCube) != ViewFrustum::OUTSIDE) {
|
||||
|
||||
|
||||
Glower* glower = NULL;
|
||||
if (entityItem->getGlowLevel() > 0.0f) {
|
||||
glower = new Glower(entityItem->getGlowLevel());
|
||||
}
|
||||
|
||||
if (entityItem->getType() == EntityTypes::Model) {
|
||||
renderEntityTypeModel(entityItem, args);
|
||||
} else if (entityItem->getType() == EntityTypes::Box) {
|
||||
renderEntityTypeBox(entityItem, args);
|
||||
}
|
||||
|
||||
if (glower) {
|
||||
delete glower;
|
||||
}
|
||||
|
||||
} else {
|
||||
args->_itemsOutOfView++;
|
||||
}
|
||||
|
@ -317,30 +328,15 @@ void EntityTreeRenderer::renderEntityTypeModel(EntityItem* entity, RenderArgs* a
|
|||
Model::RenderMode modelRenderMode = args->_renderMode == OctreeRenderer::SHADOW_RENDER_MODE
|
||||
? Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE;
|
||||
|
||||
if (entityItem->getGlowLevel() > 0.0f) {
|
||||
Glower glower(entityItem->getGlowLevel());
|
||||
|
||||
if (model->isActive()) {
|
||||
model->render(alpha, modelRenderMode);
|
||||
} else {
|
||||
// if we couldn't get a model, then just draw a sphere
|
||||
glColor3ub(entityItem->getColor()[RED_INDEX],entityItem->getColor()[GREEN_INDEX],entityItem->getColor()[BLUE_INDEX]);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glutSolidSphere(radius, 15, 15);
|
||||
glPopMatrix();
|
||||
}
|
||||
if (model->isActive()) {
|
||||
model->render(alpha, modelRenderMode);
|
||||
} else {
|
||||
if (model->isActive()) {
|
||||
model->render(alpha, modelRenderMode);
|
||||
} else {
|
||||
// if we couldn't get a model, then just draw a sphere
|
||||
glColor3ub(entityItem->getColor()[RED_INDEX],entityItem->getColor()[GREEN_INDEX],entityItem->getColor()[BLUE_INDEX]);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glutSolidSphere(radius, 15, 15);
|
||||
glPopMatrix();
|
||||
}
|
||||
// if we couldn't get a model, then just draw a sphere
|
||||
glColor3ub(entityItem->getColor()[RED_INDEX],entityItem->getColor()[GREEN_INDEX],entityItem->getColor()[BLUE_INDEX]);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glutSolidSphere(radius, 15, 15);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
bool isShadowMode = args->_renderMode == OctreeRenderer::SHADOW_RENDER_MODE;
|
||||
|
@ -407,15 +403,86 @@ void EntityTreeRenderer::renderEntityTypeModel(EntityItem* entity, RenderArgs* a
|
|||
}
|
||||
|
||||
|
||||
// vertex array for glDrawElements() and glDrawRangeElement() =================
|
||||
// Notice that the sizes of these arrays become samller than the arrays for
|
||||
// glDrawArrays() because glDrawElements() uses an additional index array to
|
||||
// choose designated vertices with the indices. The size of vertex array is now
|
||||
// 24 instead of 36, but the index array size is 36, same as the number of
|
||||
// vertices required to draw a cube.
|
||||
GLfloat vertices2[] = { 1, 1, 1, -1, 1, 1, -1,-1, 1, 1,-1, 1, // v0,v1,v2,v3 (front)
|
||||
1, 1, 1, 1,-1, 1, 1,-1,-1, 1, 1,-1, // v0,v3,v4,v5 (right)
|
||||
1, 1, 1, 1, 1,-1, -1, 1,-1, -1, 1, 1, // v0,v5,v6,v1 (top)
|
||||
-1, 1, 1, -1, 1,-1, -1,-1,-1, -1,-1, 1, // v1,v6,v7,v2 (left)
|
||||
-1,-1,-1, 1,-1,-1, 1,-1, 1, -1,-1, 1, // v7,v4,v3,v2 (bottom)
|
||||
1,-1,-1, -1,-1,-1, -1, 1,-1, 1, 1,-1 }; // v4,v7,v6,v5 (back)
|
||||
|
||||
// normal array
|
||||
GLfloat normals2[] = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, // v0,v1,v2,v3 (front)
|
||||
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, // v0,v3,v4,v5 (right)
|
||||
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, // v0,v5,v6,v1 (top)
|
||||
-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, // v1,v6,v7,v2 (left)
|
||||
0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, // v7,v4,v3,v2 (bottom)
|
||||
0, 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1 }; // v4,v7,v6,v5 (back)
|
||||
|
||||
// color array
|
||||
GLfloat colors2[] = { 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, // v0,v1,v2,v3 (front)
|
||||
1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, // v0,v3,v4,v5 (right)
|
||||
1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, // v0,v5,v6,v1 (top)
|
||||
1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, // v1,v6,v7,v2 (left)
|
||||
0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, // v7,v4,v3,v2 (bottom)
|
||||
0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1 }; // v4,v7,v6,v5 (back)
|
||||
|
||||
// index array of vertex array for glDrawElements() & glDrawRangeElement()
|
||||
GLubyte indices[] = { 0, 1, 2, 2, 3, 0, // front
|
||||
4, 5, 6, 6, 7, 4, // right
|
||||
8, 9,10, 10,11, 8, // top
|
||||
12,13,14, 14,15,12, // left
|
||||
16,17,18, 18,19,16, // bottom
|
||||
20,21,22, 22,23,20 }; // back
|
||||
|
||||
void EntityTreeRenderer::renderEntityTypeBox(EntityItem* entity, RenderArgs* args) {
|
||||
assert(entity->getType() == EntityTypes::Box);
|
||||
glm::vec3 position = entity->getPosition() * (float)TREE_SCALE;
|
||||
float size = entity->getSize() * (float)TREE_SCALE;
|
||||
glm::quat rotation = entity->getRotation();
|
||||
BoxEntityItem* boxEntityItem = static_cast<BoxEntityItem*>(entity);
|
||||
|
||||
|
||||
/*
|
||||
glColor3f(0.0f, 1.0f, 0.0f);
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glutSolidCube(size);
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
glutSolidCube(size);
|
||||
|
||||
glPopMatrix();
|
||||
*/
|
||||
|
||||
// enable and specify pointers to vertex arrays
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
//glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, 0, normals2);
|
||||
//glColorPointer(3, GL_FLOAT, 0, colors2);
|
||||
glVertexPointer(3, GL_FLOAT, 0, vertices2);
|
||||
|
||||
//glEnable(GL_BLEND);
|
||||
|
||||
glColor3ub(boxEntityItem->getColor()[RED_INDEX], boxEntityItem->getColor()[GREEN_INDEX], boxEntityItem->getColor()[BLUE_INDEX]);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
glScalef(size, size, size);
|
||||
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indices);
|
||||
glPopMatrix();
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY); // disable vertex arrays
|
||||
//glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ EntityItemProperties BoxEntityItem::getProperties() const {
|
|||
properties._color = getXColor();
|
||||
properties._colorChanged = false;
|
||||
|
||||
properties._glowLevel = getGlowLevel();
|
||||
properties._glowLevelChanged = false;
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -65,6 +68,11 @@ void BoxEntityItem::setProperties(const EntityItemProperties& properties, bool f
|
|||
somethingChanged = true;
|
||||
}
|
||||
|
||||
if (properties._glowLevelChanged || forceCopy) {
|
||||
setGlowLevel(properties._glowLevel);
|
||||
somethingChanged = true;
|
||||
}
|
||||
|
||||
if (somethingChanged) {
|
||||
bool wantDebug = false;
|
||||
if (wantDebug) {
|
||||
|
|
|
@ -90,6 +90,9 @@ public:
|
|||
|
||||
bool getShouldBeDeleted() const { return _shouldBeDeleted; }
|
||||
void setShouldBeDeleted(bool shouldBeDeleted) { _shouldBeDeleted = shouldBeDeleted; }
|
||||
|
||||
float getGlowLevel() const { return _glowLevel; }
|
||||
void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; }
|
||||
|
||||
// position, size, and bounds related helpers
|
||||
float getSize() const { return _radius * 2.0f; } /// get maximum dimension in domain scale units (0.0 - 1.0)
|
||||
|
@ -111,6 +114,7 @@ protected:
|
|||
float _radius;
|
||||
glm::quat _rotation;
|
||||
bool _shouldBeDeleted;
|
||||
float _glowLevel;
|
||||
};
|
||||
|
||||
class SphereEntityItem : public EntityItem {
|
||||
|
|
|
@ -117,6 +117,8 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons
|
|||
qDebug() << "EntityItemProperties::copyToScriptValue()... isKnownID=" << isKnownID << "id=" << _id;
|
||||
}
|
||||
|
||||
properties.setProperty("type", EntityTypes::getEntityTypeName(_type));
|
||||
|
||||
QScriptValue position = vec3toScriptValue(engine, _position);
|
||||
properties.setProperty("position", position);
|
||||
properties.setProperty("radius", _radius);
|
||||
|
|
|
@ -47,7 +47,6 @@ EntityItemProperties ModelEntityItem::getProperties() const {
|
|||
properties._animationIsPlaying = getAnimationIsPlaying();
|
||||
properties._animationFrameIndex = getAnimationFrameIndex();
|
||||
properties._animationFPS = getAnimationFPS();
|
||||
properties._glowLevel = getGlowLevel();
|
||||
properties._sittingPoints = getSittingPoints(); // sitting support
|
||||
properties._colorChanged = false;
|
||||
properties._modelURLChanged = false;
|
||||
|
@ -55,6 +54,7 @@ EntityItemProperties ModelEntityItem::getProperties() const {
|
|||
properties._animationIsPlayingChanged = false;
|
||||
properties._animationFrameIndexChanged = false;
|
||||
properties._animationFPSChanged = false;
|
||||
properties._glowLevel = getGlowLevel();
|
||||
properties._glowLevelChanged = false;
|
||||
|
||||
qDebug() << "ModelEntityItem::getProperties() getModelURL()=" << getModelURL();
|
||||
|
|
|
@ -44,7 +44,6 @@ public:
|
|||
const QString& getModelURL() const { return _modelURL; }
|
||||
bool hasAnimation() const { return !_animationURL.isEmpty(); }
|
||||
const QString& getAnimationURL() const { return _animationURL; }
|
||||
float getGlowLevel() const { return _glowLevel; }
|
||||
QVector<SittingPoint> getSittingPoints() const { return _sittingPoints; }
|
||||
|
||||
void setColor(const rgbColor& value) { memcpy(_color, value, sizeof(_color)); }
|
||||
|
@ -60,7 +59,6 @@ public:
|
|||
void setAnimationFrameIndex(float value) { _animationFrameIndex = value; }
|
||||
void setAnimationIsPlaying(bool value) { _animationIsPlaying = value; }
|
||||
void setAnimationFPS(float value) { _animationFPS = value; }
|
||||
void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; }
|
||||
void setSittingPoints(QVector<SittingPoint> sittingPoints) { _sittingPoints = sittingPoints; }
|
||||
|
||||
void mapJoints(const QStringList& modelJointNames);
|
||||
|
@ -78,7 +76,6 @@ protected:
|
|||
rgbColor _color;
|
||||
QString _modelURL;
|
||||
QVector<SittingPoint> _sittingPoints;
|
||||
float _glowLevel;
|
||||
|
||||
quint64 _lastAnimated;
|
||||
QString _animationURL;
|
||||
|
|
Loading…
Reference in a new issue