mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:28:46 +02:00
Merge pull request #7178 from Nex-Pro/20807
CR for Job #20807 - Fix vertically mirrored particles.
This commit is contained in:
commit
9273238b53
2 changed files with 107 additions and 4 deletions
101
examples/tests/particleOrientationTest.js
Normal file
101
examples/tests/particleOrientationTest.js
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
//
|
||||||
|
// particleOrientationTest.js
|
||||||
|
// examples/tests
|
||||||
|
//
|
||||||
|
// Created by Piper.Peppercorn.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
var emitterBone = 'Head'
|
||||||
|
var particleEntities = [];
|
||||||
|
|
||||||
|
function emitter(jointName) {
|
||||||
|
var jointID = MyAvatar.jointNames.indexOf(jointName);
|
||||||
|
var newEmitter = Entities.addEntity({
|
||||||
|
name: 'particleEmitter ' + jointName,
|
||||||
|
type: 'ParticleEffect',
|
||||||
|
emitterShouldTrail: true,
|
||||||
|
textures: 'https://dl.dropboxusercontent.com/u/96759331/ParticleTest.png',
|
||||||
|
position: Vec3.sum(MyAvatar.getAbsoluteJointRotationInObjectFrame(jointID), MyAvatar.position),
|
||||||
|
parentJointIndex: jointID,
|
||||||
|
position: MyAvatar.getJointPosition(jointName),
|
||||||
|
color: {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
isEmitting: 1,
|
||||||
|
maxParticles: 1,
|
||||||
|
lifespan: 2.0
|
||||||
|
,
|
||||||
|
emitRate: 1,
|
||||||
|
emitSpeed: 0.0,
|
||||||
|
speedSpread: 0.0,
|
||||||
|
/*
|
||||||
|
emitOrientation: {
|
||||||
|
x: -0.7035577893257141,
|
||||||
|
y: -0.000015259007341228426,
|
||||||
|
z: -0.000015259007341228426,
|
||||||
|
w: 1.7106381058692932
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
emitOrientation: {
|
||||||
|
x:0,
|
||||||
|
y: 0,
|
||||||
|
z: 0,
|
||||||
|
w: Math.PI
|
||||||
|
},
|
||||||
|
emitRadiusStart: 0,
|
||||||
|
polarStart: 0,
|
||||||
|
polarFinish: 0,
|
||||||
|
azimuthFinish: 3.1415927410125732,
|
||||||
|
emitAcceleration: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
accelerationSpread: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
particleRadius: 2.0,
|
||||||
|
radiusSpread: 1.0,
|
||||||
|
radiusStart: 2.0,
|
||||||
|
radiusFinish: 2.0,
|
||||||
|
colorSpread: {
|
||||||
|
red: 0,
|
||||||
|
green: 0,
|
||||||
|
blue: 0
|
||||||
|
},
|
||||||
|
colorStart: {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
colorFinish: {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
alpha: 1,
|
||||||
|
alphaSpread: 0,
|
||||||
|
alphaStart: 1,
|
||||||
|
alphaFinish: 1
|
||||||
|
});
|
||||||
|
return newEmitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(function() {
|
||||||
|
for (var i = 0; i < particleEntities.length; i++) {
|
||||||
|
// Fixes a crash on shutdown:
|
||||||
|
Entities.editEntity(particleEntities[i], { parentID: '' });
|
||||||
|
Entities.deleteEntity(particleEntities[i]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
particleEntities.push(emitter(emitterBone));
|
|
@ -44,11 +44,12 @@ out vec4 varColor;
|
||||||
out vec2 varTexcoord;
|
out vec2 varTexcoord;
|
||||||
|
|
||||||
const int NUM_VERTICES_PER_PARTICLE = 4;
|
const int NUM_VERTICES_PER_PARTICLE = 4;
|
||||||
|
// This ordering ensures that un-rotated particles render upright in the wiewer.
|
||||||
const vec4 UNIT_QUAD[NUM_VERTICES_PER_PARTICLE] = vec4[NUM_VERTICES_PER_PARTICLE](
|
const vec4 UNIT_QUAD[NUM_VERTICES_PER_PARTICLE] = vec4[NUM_VERTICES_PER_PARTICLE](
|
||||||
vec4(-1.0, -1.0, 0.0, 0.0),
|
|
||||||
vec4(1.0, -1.0, 0.0, 0.0),
|
|
||||||
vec4(-1.0, 1.0, 0.0, 0.0),
|
vec4(-1.0, 1.0, 0.0, 0.0),
|
||||||
vec4(1.0, 1.0, 0.0, 0.0)
|
vec4(-1.0, -1.0, 0.0, 0.0),
|
||||||
|
vec4(1.0, 1.0, 0.0, 0.0),
|
||||||
|
vec4(1.0, -1.0, 0.0, 0.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
float bezierInterpolate(float y1, float y2, float y3, float u) {
|
float bezierInterpolate(float y1, float y2, float y3, float u) {
|
||||||
|
@ -115,7 +116,8 @@ void main(void) {
|
||||||
float seed = inColor.y;
|
float seed = inColor.y;
|
||||||
|
|
||||||
// Pass the texcoord and the z texcoord is representing the texture icon
|
// Pass the texcoord and the z texcoord is representing the texture icon
|
||||||
varTexcoord = vec2((UNIT_QUAD[twoTriID].xy + 1.0) * 0.5);
|
// Offset for corrected vertex ordering.
|
||||||
|
varTexcoord = vec2((UNIT_QUAD[twoTriID].xy -1.0) * vec2(0.5, -0.5));
|
||||||
varColor = interpolate3Vec4(particle.color.start, particle.color.middle, particle.color.finish, age);
|
varColor = interpolate3Vec4(particle.color.start, particle.color.middle, particle.color.finish, age);
|
||||||
|
|
||||||
// anchor point in eye space
|
// anchor point in eye space
|
||||||
|
|
Loading…
Reference in a new issue