mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Going to change additive blending to world position prop
This commit is contained in:
parent
761dfeaccd
commit
c561a53f7c
3 changed files with 102 additions and 70 deletions
|
@ -1,81 +1,101 @@
|
||||||
|
|
||||||
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
|
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
|
||||||
|
var modelURL = "file:///C:/Users/Eric/Desktop/RaveRoom.fbx?v1" + Math.random();
|
||||||
|
|
||||||
|
var raveRoom = Entities.addEntity({
|
||||||
|
type: "Model",
|
||||||
|
modelURL: modelURL,
|
||||||
|
position: center,
|
||||||
|
visible:false
|
||||||
|
});
|
||||||
|
|
||||||
|
var colorPalette = [{
|
||||||
|
red: 250,
|
||||||
|
green: 137,
|
||||||
|
blue: 162
|
||||||
|
}, {
|
||||||
|
red: 204,
|
||||||
|
green: 244,
|
||||||
|
blue: 249
|
||||||
|
}, {
|
||||||
|
red: 146,
|
||||||
|
green: 206,
|
||||||
|
blue: 116
|
||||||
|
}, {
|
||||||
|
red: 240,
|
||||||
|
green: 87,
|
||||||
|
blue: 129
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
var containerBall = Entities.addEntity({
|
var containerBall = Entities.addEntity({
|
||||||
type: "Sphere",
|
type: "Sphere",
|
||||||
position: center,
|
position: center,
|
||||||
dimensions: {x: .1, y: .1, z: .1},
|
dimensions: {x: .1, y: .1, z: .1},
|
||||||
color: {red: 50, green: 10, blue: 50},
|
color: {red: 1500, green: 10, blue: 50},
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
gravity: {x: 0, y: -.1, z: 0}
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
spatialKey: {
|
||||||
|
relativePosition: {
|
||||||
|
x: 0,
|
||||||
|
y: 2,
|
||||||
|
z: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
invertSolidWhileHeld: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// gravity: {x: 0, y: -.1, z: 0}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var lightZone = Entities.addEntity({
|
||||||
|
type: "Zone",
|
||||||
|
shapeType: 'box',
|
||||||
|
keyLightIntensity: 0.2,
|
||||||
|
keyLightColor: {
|
||||||
|
red: 50,
|
||||||
|
green: 0,
|
||||||
|
blue: 50
|
||||||
|
},
|
||||||
|
keyLightAmbientIntensity: .2,
|
||||||
|
position: MyAvatar.position,
|
||||||
|
dimensions: {
|
||||||
|
x: 100,
|
||||||
|
y: 100,
|
||||||
|
z: 100
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var light = Entities.addEntity({
|
||||||
|
type: 'Light',
|
||||||
|
position: center,
|
||||||
|
parentID: containerBall,
|
||||||
|
dimensions: {
|
||||||
|
x: 30,
|
||||||
|
y: 30,
|
||||||
|
z: 30
|
||||||
|
},
|
||||||
|
color: colorPalette[randInt(0, colorPalette.length)],
|
||||||
|
intensity: 5
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var lightBall = Entities.addEntity({
|
var lightBall = Entities.addEntity({
|
||||||
position: center,
|
position: center,
|
||||||
type: "ParticleEffect",
|
type: "ParticleEffect",
|
||||||
parentID: containerBall,
|
parentID: containerBall,
|
||||||
isEmitting: true,
|
isEmitting: true,
|
||||||
"name": "ParticlesTest Emitter",
|
"name": "ParticlesTest Emitter",
|
||||||
"colorStart": {red: 20, green: 20, blue: 255},
|
"colorStart": {red: 200, green: 20, blue: 40},
|
||||||
color: {red: 10, green: 0, blue: 255},
|
color: {red: 10, green: 0, blue: 255},
|
||||||
"colorFinish": {red: 250, green: 200, blue:255},
|
"colorFinish": {red: 250, green: 200, blue:255},
|
||||||
"maxParticles": 20000,
|
|
||||||
"lifespan": 1,
|
|
||||||
"emitRate": 10000,
|
|
||||||
"emitSpeed": .1,
|
|
||||||
"speedSpread": .01,
|
|
||||||
"emitDimensions": {
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
"z": 0
|
|
||||||
},
|
|
||||||
"polarStart": 0,
|
|
||||||
"polarFinish": 3,
|
|
||||||
"azimuthStart": -3.1415927410125732,
|
|
||||||
"azimuthFinish": 3.1415927410125732,
|
|
||||||
"emitAcceleration": {
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
"z": 0
|
|
||||||
},
|
|
||||||
"accelerationSpread": {
|
|
||||||
"x": .01,
|
|
||||||
"y": .01,
|
|
||||||
"z": .01
|
|
||||||
},
|
|
||||||
"particleRadius": 0.04,
|
|
||||||
"radiusSpread": 0,
|
|
||||||
"radiusStart": 0.05,
|
|
||||||
"radiusFinish": 0.0003,
|
|
||||||
"alpha": 0,
|
|
||||||
"alphaSpread": .5,
|
|
||||||
"alphaStart": 0,
|
|
||||||
"alphaFinish": 0.5,
|
|
||||||
"additiveBlending": 0,
|
|
||||||
"textures": "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png"
|
|
||||||
})
|
|
||||||
|
|
||||||
var containerBall2 = Entities.addEntity({
|
|
||||||
type: "Sphere",
|
|
||||||
position: Vec3.sum(center, {x: 0.5, y: 0, z: 0}),
|
|
||||||
dimensions: {x: .1, y: .1, z: .1},
|
|
||||||
color: {red: 200, green: 10, blue: 50},
|
|
||||||
collisionsWillMove: true,
|
|
||||||
gravity: {x: 0, y: -.1, z: 0}
|
|
||||||
});
|
|
||||||
|
|
||||||
var lightBall2 = Entities.addEntity({
|
|
||||||
position: Vec3.sum(center, {x: 0.5, y: 0, z: 0}),
|
|
||||||
type: "ParticleEffect",
|
|
||||||
parentID: containerBall2,
|
|
||||||
isEmitting: true,
|
|
||||||
"name": "ParticlesTest Emitter",
|
|
||||||
"colorStart": {red: 200, green: 20, blue: 0},
|
|
||||||
color: {red: 255, green: 0, blue: 10},
|
|
||||||
"colorFinish": {red: 250, green: 200, blue:255},
|
|
||||||
"maxParticles": 100000,
|
"maxParticles": 100000,
|
||||||
"lifespan": 1,
|
"lifespan": 7,
|
||||||
"emitRate": 10000,
|
"emitRate": 10000,
|
||||||
"emitSpeed": .1,
|
"emitSpeed": .02,
|
||||||
"speedSpread": .01,
|
"speedSpread": .01,
|
||||||
"emitDimensions": {
|
"emitDimensions": {
|
||||||
"x": 0,
|
"x": 0,
|
||||||
|
@ -83,9 +103,9 @@ var lightBall2 = Entities.addEntity({
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"polarStart": 0,
|
"polarStart": 0,
|
||||||
"polarFinish": 3,
|
"polarFinish": Math.PI,
|
||||||
"azimuthStart": -3.1415927410125732,
|
"azimuthStart": -Math.PI,
|
||||||
"azimuthFinish": 3.1415927410125732,
|
"azimuthFinish": Math.PI,
|
||||||
"emitAcceleration": {
|
"emitAcceleration": {
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 0,
|
"y": 0,
|
||||||
|
@ -108,11 +128,14 @@ var lightBall2 = Entities.addEntity({
|
||||||
"textures": "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png"
|
"textures": "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
Entities.deleteEntity(lightBall);
|
Entities.deleteEntity(lightBall);
|
||||||
Entities.deleteEntity(lightBall2);
|
|
||||||
Entities.deleteEntity(containerBall);
|
Entities.deleteEntity(containerBall);
|
||||||
Entities.deleteEntity(containerBall2);
|
Entities.deleteEntity(raveRoom);
|
||||||
|
Entities.deleteEntity(lightZone)
|
||||||
|
Entities.deleteEntity(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
|
@ -240,8 +240,8 @@ void RenderableParticleEffectEntityItem::updateRenderItem() {
|
||||||
auto position = getPosition();
|
auto position = getPosition();
|
||||||
auto rotation = getRotation();
|
auto rotation = getRotation();
|
||||||
Transform transform;
|
Transform transform;
|
||||||
transform.setTranslation(position);
|
//transform.setTranslation(position);
|
||||||
transform.setRotation(rotation);
|
// transform.setRotation(rotation);
|
||||||
|
|
||||||
render::PendingChanges pendingChanges;
|
render::PendingChanges pendingChanges;
|
||||||
pendingChanges.updateItem<ParticlePayloadData>(_renderItemId, [=](ParticlePayloadData& payload) {
|
pendingChanges.updateItem<ParticlePayloadData>(_renderItemId, [=](ParticlePayloadData& payload) {
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include <ByteCountCoding.h>
|
#include <ByteCountCoding.h>
|
||||||
#include <GeometryUtil.h>
|
#include <GeometryUtil.h>
|
||||||
#include <Interpolate.h>
|
#include <Interpolate.h>
|
||||||
|
#include <random>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "EntityTree.h"
|
#include "EntityTree.h"
|
||||||
#include "EntityTreeElement.h"
|
#include "EntityTreeElement.h"
|
||||||
|
@ -640,12 +642,18 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
||||||
ParticleEffectEntityItem::Particle ParticleEffectEntityItem::createParticle() {
|
ParticleEffectEntityItem::Particle ParticleEffectEntityItem::createParticle() {
|
||||||
Particle particle;
|
Particle particle;
|
||||||
|
|
||||||
particle.seed = randFloatInRange(0.0f, 1.0f);
|
std::random_device rd;
|
||||||
|
|
||||||
|
std::mt19937_64 el(rd());
|
||||||
|
std::uniform_real_distribution<float> uniform_dist(-1.0, 1.0);
|
||||||
|
|
||||||
|
particle.seed = randFloatInRange(-1.0f, 1.0f);
|
||||||
|
particle.position = getPosition();
|
||||||
// Position, velocity, and acceleration
|
// Position, velocity, and acceleration
|
||||||
if (_polarStart == 0.0f && _polarFinish == 0.0f && _emitDimensions.z == 0.0f) {
|
if (_polarStart == 0.0f && _polarFinish == 0.0f && _emitDimensions.z == 0.0f) {
|
||||||
// Emit along z-axis from position
|
// Emit along z-axis from position
|
||||||
particle.velocity = (_emitSpeed + randFloatInRange(-1.0f, 1.0f) * _speedSpread) * (_emitOrientation * Vectors::UNIT_Z);
|
|
||||||
|
particle.velocity = (_emitSpeed + 0.2f * _speedSpread) * (_emitOrientation * Vectors::UNIT_Z);
|
||||||
particle.acceleration = _emitAcceleration + randFloatInRange(-1.0f, 1.0f) * _accelerationSpread;
|
particle.acceleration = _emitAcceleration + randFloatInRange(-1.0f, 1.0f) * _accelerationSpread;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -691,10 +699,11 @@ ParticleEffectEntityItem::Particle ParticleEffectEntityItem::createParticle() {
|
||||||
radii.z > 0.0f ? z / (radii.z * radii.z) : 0.0f
|
radii.z > 0.0f ? z / (radii.z * radii.z) : 0.0f
|
||||||
));
|
));
|
||||||
|
|
||||||
particle.position = _emitOrientation * emitPosition;
|
particle.position += _emitOrientation * emitPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
particle.velocity = (_emitSpeed + randFloatInRange(-1.0f, 1.0f) * _speedSpread) * (_emitOrientation * emitDirection);
|
particle.velocity = (_emitSpeed + randFloatInRange(-1.0f, 1.0f) * _speedSpread) * (_emitOrientation * emitDirection);
|
||||||
|
// particle.velocity = (_emitSpeed + uniform_dist(el) * _speedSpread) * (_emitOrientation * emitDirection);
|
||||||
particle.acceleration = _emitAcceleration + randFloatInRange(-1.0f, 1.0f) * _accelerationSpread;
|
particle.acceleration = _emitAcceleration + randFloatInRange(-1.0f, 1.0f) * _accelerationSpread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue