Beispiel #1
0
 /// <summary>
 /// Create VGO_PS_Renderer from ParticleSystemRenderer.
 /// </summary>
 /// <param name="particleSystemRenderer"></param>
 /// <param name="gltf"></param>
 /// <returns></returns>
 protected virtual VGO_PS_Renderer CreateVgoPsRenderer(ParticleSystemRenderer particleSystemRenderer, glTF gltf)
 {
     return(new VGO_PS_Renderer()
     {
         enabled = particleSystemRenderer.enabled,
         renderMode = particleSystemRenderer.renderMode,
         cameraVelocityScale = particleSystemRenderer.cameraVelocityScale,
         velocityScale = particleSystemRenderer.velocityScale,
         lengthScale = particleSystemRenderer.lengthScale,
         normalDirection = particleSystemRenderer.normalDirection,
         sharedMaterial = GetMaterialIndex(particleSystemRenderer.sharedMaterial, gltf),
         trailMaterialIndex = GetMaterialIndex(particleSystemRenderer.trailMaterial, gltf),
         sortMode = particleSystemRenderer.sortMode,
         sortingFudge = particleSystemRenderer.sortingFudge,
         minParticleSize = particleSystemRenderer.minParticleSize,
         maxParticleSize = particleSystemRenderer.maxParticleSize,
         alignment = particleSystemRenderer.alignment,
         flip = particleSystemRenderer.flip.ReverseZ().ToArray(),
         allowRoll = particleSystemRenderer.allowRoll,
         pivot = particleSystemRenderer.pivot.ReverseZ().ToArray(),
         maskInteraction = particleSystemRenderer.maskInteraction,
         enableGPUInstancing = particleSystemRenderer.enableGPUInstancing,
         shadowCastingMode = particleSystemRenderer.shadowCastingMode,
         receiveShadows = particleSystemRenderer.receiveShadows,
         shadowBias = particleSystemRenderer.shadowBias,
         motionVectorGenerationMode = particleSystemRenderer.motionVectorGenerationMode,
         forceRenderingOff = particleSystemRenderer.forceRenderingOff,
         rendererPriority = particleSystemRenderer.rendererPriority,
         renderingLayerMask = particleSystemRenderer.renderingLayerMask,
         sortingLayerID = particleSystemRenderer.sortingLayerID,
         sortingOrder = particleSystemRenderer.sortingOrder,
         lightProbeUsage = particleSystemRenderer.lightProbeUsage,
         reflectionProbeUsage = particleSystemRenderer.reflectionProbeUsage,
         probeAnchor = VgoTransformConverter.CreateFrom(particleSystemRenderer.probeAnchor),
     });
 }
Beispiel #2
0
        /// <summary>
        /// Create VGO_PS_MainModule from MainModule.
        /// </summary>
        /// <param name="module"></param>
        /// <returns></returns>
        protected virtual VGO_PS_MainModule CreateVgoModule(MainModule module)
        {
            var vgoModule = new VGO_PS_MainModule()
            {
                duration                  = module.duration,
                loop                      = module.loop,
                prewarm                   = module.prewarm,
                startDelay                = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startDelay),
                startDelayMultiplier      = module.startDelayMultiplier,
                startLifetime             = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startLifetime),
                startLifetimeMultiplier   = module.startLifetimeMultiplier,
                startSpeed                = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSpeed),
                startSpeedMultiplier      = module.startSpeedMultiplier,
                startSize3D               = module.startSize3D,
                startRotation3D           = module.startRotation3D,
                flipRotation              = module.flipRotation,
                startColor                = VgoParticleSystemMinMaxGradientConverter.CreateFrom(module.startColor),
                gravityModifier           = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.gravityModifier),
                gravityModifierMultiplier = module.gravityModifierMultiplier,
                simulationSpace           = module.simulationSpace,
                simulationSpeed           = module.simulationSpeed,
                customSimulationSpace     = VgoTransformConverter.CreateFrom(module.customSimulationSpace),
                useUnscaledTime           = module.useUnscaledTime,
                scalingMode               = module.scalingMode,
                playOnAwake               = module.playOnAwake,
                emitterVelocityMode       = module.emitterVelocityMode,
                maxParticles              = module.maxParticles,
                stopAction                = module.stopAction,
                cullingMode               = module.cullingMode,
                ringBufferMode            = module.ringBufferMode,
            };

            if (module.startSize3D)
            {
                vgoModule.startSizeX           = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSizeX);
                vgoModule.startSizeY           = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSizeY);
                vgoModule.startSizeZ           = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSizeZ);
                vgoModule.startSizeXMultiplier = module.startSizeXMultiplier;
                vgoModule.startSizeYMultiplier = module.startSizeYMultiplier;
                vgoModule.startSizeZMultiplier = module.startSizeZMultiplier;
            }
            else
            {
                vgoModule.startSize           = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSize);
                vgoModule.startSizeMultiplier = module.startSizeMultiplier;
            }

            if (module.startRotation3D)
            {
                vgoModule.startRotationX           = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startRotationX);
                vgoModule.startRotationY           = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startRotationY);
                vgoModule.startRotationZ           = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startRotationZ);
                vgoModule.StartRotationXMultiplier = module.startRotationXMultiplier;
                vgoModule.StartRotationYMultiplier = module.startRotationYMultiplier;
                vgoModule.StartRotationZMultiplier = module.startRotationZMultiplier;
            }
            else
            {
                vgoModule.startRotation           = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startRotation);
                vgoModule.StartRotationMultiplier = module.startRotationMultiplier;
            }

            if (module.ringBufferMode == ParticleSystemRingBufferMode.LoopUntilReplaced)
            {
                vgoModule.ringBufferLoopRange = module.ringBufferLoopRange.ToArray();
            }

            return(vgoModule);
        }
Beispiel #3
0
        /// <summary>
        /// Set ParticleSystem main field value.
        /// </summary>
        /// <param name="particleSystem"></param>
        /// <param name="vgoModule"></param>
        protected virtual void SetModuleValue(ParticleSystem particleSystem, VGO_PS_MainModule vgoModule)
        {
            if (vgoModule == null)
            {
                return;
            }

            MainModule module = particleSystem.main;

            // @notice
            if (Application.isPlaying == false)
            {
                module.duration = vgoModule.duration;
            }

            module.loop                    = vgoModule.loop;
            module.prewarm                 = vgoModule.prewarm;
            module.startDelay              = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startDelay);
            module.startDelayMultiplier    = vgoModule.startDelayMultiplier;
            module.startLifetime           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startLifetime);
            module.startLifetimeMultiplier = vgoModule.startLifetimeMultiplier;
            module.startSpeed              = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSpeed);
            module.startSpeedMultiplier    = vgoModule.startSpeedMultiplier;

            module.startSize3D = vgoModule.startSize3D;

            if (vgoModule.startSize3D)
            {
                module.startSizeX           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSizeX);
                module.startSizeY           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSizeY);
                module.startSizeZ           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSizeZ);
                module.startSizeXMultiplier = vgoModule.startSizeXMultiplier;
                module.startSizeYMultiplier = vgoModule.startSizeYMultiplier;
                module.startSizeZMultiplier = vgoModule.startSizeZMultiplier;
            }
            else
            {
                module.startSize           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSize);
                module.startSizeMultiplier = vgoModule.startSizeMultiplier;
            }

            module.startRotation3D = vgoModule.startRotation3D;

            if (vgoModule.startRotation3D)
            {
                module.startRotationX           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotationX);
                module.startRotationY           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotationY);
                module.startRotationZ           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotationZ);
                module.startRotationXMultiplier = vgoModule.StartRotationXMultiplier;
                module.startRotationYMultiplier = vgoModule.StartRotationYMultiplier;
                module.startRotationZMultiplier = vgoModule.StartRotationZMultiplier;
            }
            else
            {
                module.startRotation           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotation);
                module.startRotationMultiplier = vgoModule.StartRotationMultiplier;
            }

            module.flipRotation              = vgoModule.flipRotation;
            module.startColor                = VgoParticleSystemMinMaxGradientConverter.CreateMinMaxGradient(vgoModule.startColor);
            module.gravityModifier           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.gravityModifier);
            module.gravityModifierMultiplier = vgoModule.gravityModifierMultiplier;

            module.simulationSpace = vgoModule.simulationSpace;
            module.simulationSpeed = vgoModule.simulationSpeed;
            VgoTransformConverter.SetComponentValue(module.customSimulationSpace, vgoModule.customSimulationSpace);

            module.useUnscaledTime     = vgoModule.useUnscaledTime;
            module.scalingMode         = vgoModule.scalingMode;
            module.playOnAwake         = vgoModule.playOnAwake;
            module.emitterVelocityMode = vgoModule.emitterVelocityMode;
            module.maxParticles        = vgoModule.maxParticles;
            module.stopAction          = vgoModule.stopAction;
            module.cullingMode         = vgoModule.cullingMode;
            module.ringBufferMode      = vgoModule.ringBufferMode;

            if (vgoModule.ringBufferMode == ParticleSystemRingBufferMode.LoopUntilReplaced)
            {
                module.ringBufferLoopRange = ArrayConverter.ToVector2(vgoModule.ringBufferLoopRange);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Set particleSystemRenderer field value.
        /// </summary>
        /// <param name="particleSystemRenderer"></param>
        /// <param name="vgoRenderer"></param>
        /// <param name="materialList"></param>
        public virtual void SetComponentValue(ParticleSystemRenderer particleSystemRenderer, VGO_PS_Renderer vgoRenderer, IList <Material> materialList)
        {
            if (vgoRenderer == null)
            {
                return;
            }

            particleSystemRenderer.enabled    = vgoRenderer.enabled;
            particleSystemRenderer.renderMode = vgoRenderer.renderMode;

            // Billboard
            particleSystemRenderer.cameraVelocityScale = vgoRenderer.cameraVelocityScale;
            particleSystemRenderer.velocityScale       = vgoRenderer.velocityScale;
            particleSystemRenderer.lengthScale         = vgoRenderer.lengthScale;
            particleSystemRenderer.normalDirection     = vgoRenderer.normalDirection;

            // Material
            if ((materialList != null) && (-1 < vgoRenderer.sharedMaterial) && (vgoRenderer.sharedMaterial < materialList.Count))
            {
                particleSystemRenderer.sharedMaterial = materialList[vgoRenderer.sharedMaterial];
            }

            if ((materialList != null) && (-1 < vgoRenderer.trailMaterialIndex) && (vgoRenderer.trailMaterialIndex < materialList.Count))
            {
                particleSystemRenderer.trailMaterial = materialList[vgoRenderer.trailMaterialIndex];
            }

            particleSystemRenderer.sortMode        = vgoRenderer.sortMode;
            particleSystemRenderer.sortingFudge    = vgoRenderer.sortingFudge;
            particleSystemRenderer.minParticleSize = vgoRenderer.minParticleSize;
            particleSystemRenderer.maxParticleSize = vgoRenderer.maxParticleSize;
            particleSystemRenderer.alignment       = vgoRenderer.alignment;
            particleSystemRenderer.flip            = ArrayConverter.ToVector3(vgoRenderer.flip, reverseZ: true);
            particleSystemRenderer.allowRoll       = vgoRenderer.allowRoll;
            particleSystemRenderer.pivot           = ArrayConverter.ToVector3(vgoRenderer.pivot, reverseZ: true);

            particleSystemRenderer.maskInteraction     = vgoRenderer.maskInteraction;
            particleSystemRenderer.enableGPUInstancing = vgoRenderer.enableGPUInstancing;

            // Shadow
            particleSystemRenderer.shadowCastingMode = vgoRenderer.shadowCastingMode;
            particleSystemRenderer.receiveShadows    = vgoRenderer.receiveShadows;
            particleSystemRenderer.shadowBias        = vgoRenderer.shadowBias;

            particleSystemRenderer.motionVectorGenerationMode = vgoRenderer.motionVectorGenerationMode;
            particleSystemRenderer.forceRenderingOff          = vgoRenderer.forceRenderingOff;
            particleSystemRenderer.rendererPriority           = vgoRenderer.rendererPriority;
            particleSystemRenderer.renderingLayerMask         = vgoRenderer.renderingLayerMask;
            particleSystemRenderer.sortingLayerID             = vgoRenderer.sortingLayerID;
            particleSystemRenderer.sortingOrder         = vgoRenderer.sortingOrder;
            particleSystemRenderer.lightProbeUsage      = vgoRenderer.lightProbeUsage;
            particleSystemRenderer.reflectionProbeUsage = vgoRenderer.reflectionProbeUsage;

            // @notice
            VgoTransformConverter.SetComponentValue(particleSystemRenderer.probeAnchor, vgoRenderer.probeAnchor);

            if (particleSystemRenderer.sharedMaterial != null)
            {
                //SetVertexStream(particleSystemRenderer, particleSystemRenderer.sharedMaterial);
            }
        }