Going to change additive blending to world position prop

This commit is contained in:
ericrius1 2015-12-15 09:56:28 -08:00
parent 761dfeaccd
commit c561a53f7c
3 changed files with 102 additions and 70 deletions

View file

@ -1,81 +1,101 @@
Script.include("../../libraries/utils.js");
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({
type: "Sphere",
position: center,
dimensions: {x: .1, y: .1, z: .1},
color: {red: 50, green: 10, blue: 50},
color: {red: 1500, green: 10, blue: 50},
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({
position: center,
type: "ParticleEffect",
parentID: containerBall,
isEmitting: true,
"name": "ParticlesTest Emitter",
"colorStart": {red: 20, green: 20, blue: 255},
"colorStart": {red: 200, green: 20, blue: 40},
color: {red: 10, green: 0, 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,
"lifespan": 1,
"lifespan": 7,
"emitRate": 10000,
"emitSpeed": .1,
"emitSpeed": .02,
"speedSpread": .01,
"emitDimensions": {
"x": 0,
@ -83,9 +103,9 @@ var lightBall2 = Entities.addEntity({
"z": 0
},
"polarStart": 0,
"polarFinish": 3,
"azimuthStart": -3.1415927410125732,
"azimuthFinish": 3.1415927410125732,
"polarFinish": Math.PI,
"azimuthStart": -Math.PI,
"azimuthFinish": Math.PI,
"emitAcceleration": {
"x": 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"
})
function cleanup() {
Entities.deleteEntity(lightBall);
Entities.deleteEntity(lightBall2);
Entities.deleteEntity(containerBall);
Entities.deleteEntity(containerBall2);
Entities.deleteEntity(raveRoom);
Entities.deleteEntity(lightZone)
Entities.deleteEntity(light);
}
Script.scriptEnding.connect(cleanup);

View file

@ -240,8 +240,8 @@ void RenderableParticleEffectEntityItem::updateRenderItem() {
auto position = getPosition();
auto rotation = getRotation();
Transform transform;
transform.setTranslation(position);
transform.setRotation(rotation);
//transform.setTranslation(position);
// transform.setRotation(rotation);
render::PendingChanges pendingChanges;
pendingChanges.updateItem<ParticlePayloadData>(_renderItemId, [=](ParticlePayloadData& payload) {

View file

@ -33,6 +33,8 @@
#include <ByteCountCoding.h>
#include <GeometryUtil.h>
#include <Interpolate.h>
#include <random>
#include <cmath>
#include "EntityTree.h"
#include "EntityTreeElement.h"
@ -640,12 +642,18 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
ParticleEffectEntityItem::Particle ParticleEffectEntityItem::createParticle() {
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
if (_polarStart == 0.0f && _polarFinish == 0.0f && _emitDimensions.z == 0.0f) {
// 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;
} else {
@ -691,10 +699,11 @@ ParticleEffectEntityItem::Particle ParticleEffectEntityItem::createParticle() {
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 + uniform_dist(el) * _speedSpread) * (_emitOrientation * emitDirection);
particle.acceleration = _emitAcceleration + randFloatInRange(-1.0f, 1.0f) * _accelerationSpread;
}