Example #1
0
        protected virtual void writeParticle(int idx, SSParticle p)
        {
            _lives [idx] = p.life;
            writeDataIfNeeded(ref _positions, idx, new SSAttributeVec3(p.pos));
            writeDataIfNeeded(ref _orientationsXY, idx, new SSAttributeVec2(p.orientation.Xy));
            writeDataIfNeeded(ref _orientationsZ, idx, new SSAttributeFloat(p.orientation.Z));
            writeDataIfNeeded(ref _masterScales, idx, new SSAttributeFloat(p.masterScale));
            writeDataIfNeeded(ref _componentScalesXY, idx, new SSAttributeVec2(p.componentScale.Xy));
            writeDataIfNeeded(ref _componentScalesZ, idx, new SSAttributeFloat(p.componentScale.Z));
            writeDataIfNeeded(ref _colors, idx, new SSAttributeColor(Color4Helper.ToUInt32(p.color)));

            //writeDataIfNeeded(ref m_spriteIndices, idx, new SSAttributeByte(p.SpriteIndex));
            writeDataIfNeeded(ref _spriteOffsetsU, idx, new SSAttributeFloat(p.spriteRect.X));
            writeDataIfNeeded(ref _spriteOffsetsV, idx, new SSAttributeFloat(p.spriteRect.Y));
            writeDataIfNeeded(ref _spriteSizesU, idx, new SSAttributeFloat(p.spriteRect.Width));
            writeDataIfNeeded(ref _spriteSizesV, idx, new SSAttributeFloat(p.spriteRect.Height));

            writeDataIfNeeded(ref _velocities, idx, p.vel);
            writeDataIfNeeded(ref _angularVelocities, idx, p.angularVelocity);
            writeDataIfNeeded(ref _masses, idx, p.mass);
            writeDataIfNeeded(ref _rotationalInnertias, idx, p.rotationalInnertia);
            writeDataIfNeeded(ref _drags, idx, p.drag);
            writeDataIfNeeded(ref _rotationalDrags, idx, p.rotationalDrag);
            writeDataIfNeeded(ref _viewDepths, idx, p.viewDepth);
            writeDataIfNeeded(ref _effectorMasksHigh, idx, (byte)((p.effectorMask & 0xFF00) >> 8));
            writeDataIfNeeded(ref _effectorMasksLow, idx, (byte)(p.effectorMask & 0xFF));
        }
Example #2
0
        protected virtual void readParticle(int idx, SSParticle p)
        {
            p.life           = _lives [idx];
            p.pos            = _readElement(_positions, idx).Value;
            p.orientation.Xy = _readElement(_orientationsXY, idx).Value;
            p.orientation.Z  = _readElement(_orientationsZ, idx).Value;
            p.viewDepth      = _readElement(_viewDepths, idx);

            if (p.life <= 0f)
            {
                return;               // the rest does not matter
            }
            p.masterScale       = _readElement(_masterScales, idx).Value;
            p.componentScale.Xy = _readElement(_componentScalesXY, idx).Value;
            p.componentScale.Z  = _readElement(_componentScalesZ, idx).Value;
            p.color             = Color4Helper.FromUInt32(_readElement(_colors, idx).Color);

            //p.SpriteIndex = _readElement(m_spriteIndices, idx).Value;
            p.spriteRect.X      = _readElement(_spriteOffsetsU, idx).Value;
            p.spriteRect.Y      = _readElement(_spriteOffsetsV, idx).Value;
            p.spriteRect.Width  = _readElement(_spriteSizesU, idx).Value;
            p.spriteRect.Height = _readElement(_spriteSizesV, idx).Value;

            p.vel                = _readElement(_velocities, idx);
            p.angularVelocity    = _readElement(_angularVelocities, idx);
            p.mass               = _readElement(_masses, idx);
            p.rotationalInnertia = _readElement(_rotationalInnertias, idx);
            p.drag               = _readElement(_drags, idx);
            p.rotationalDrag     = _readElement(_rotationalDrags, idx);
            p.effectorMask       = (ushort)((int)_readElement(_effectorMasksHigh, idx) << 8
                                      | (int)_readElement(_effectorMasksLow, idx));
        }
Example #3
0
            protected override void writeParticle(int idx, SSParticle p)
            {
                #if false
                // attempt of only writing things that are relevant; skipping the rest
                _lives [idx] = p.life;
                writeDataIfNeeded(ref _positions, idx, new SSAttributeVec3(p.pos));
                writeDataIfNeeded(ref _viewDepths, idx, p.viewDepth);
                writeDataIfNeeded(ref _effectorMasksHigh, idx, (ushort)((p.effectorMask & 0xFF00) >> 8));
                writeDataIfNeeded(ref _effectorMasksLow, idx, (ushort)(p.effectorMask & 0xFF));
                writeDataIfNeeded(ref _colors, idx, new SSAttributeColor(Color4Helper.ToUInt32(p.color)));
                #else
                // for some reason the above doesn't work, so lets just do things slightly less efficiently for now
                base.writeParticle(idx, p);
                #endif

                var ts         = (STrailsSegment)p;
                var innerColor = Color4Helper.ToUInt32(ts.cylInnerColor);
                writeDataIfNeeded(ref _cylInnerColors, idx, new SSAttributeColor(innerColor));
                writeDataIfNeeded(ref _innerColorRatios, idx, new SSAttributeFloat(ts.innerColorRatio));
                writeDataIfNeeded(ref _outerColorRatios, idx, new SSAttributeFloat(ts.outerColorRatio));
                writeDataIfNeeded(ref _cylAxes, idx, new SSAttributeVec3(ts.cylAxis));
                writeDataIfNeeded(ref _prevJointAxes, idx, new SSAttributeVec3(ts.prevJointAxis));
                writeDataIfNeeded(ref _nextJointAxes, idx, new SSAttributeVec3(ts.nextJointAxis));
                writeDataIfNeeded(ref _cylLengths, idx, new SSAttributeFloat(ts.cylLendth));
                writeDataIfNeeded(ref _cylWidths, idx, new SSAttributeFloat(ts.cylWidth));
                writeDataIfNeeded(ref _nextSegmentData, idx, ts.nextSegmentIdx);
                writeDataIfNeeded(ref _prevSegmentData, idx, ts.prevSegmentIdx);
            }
Example #4
0
            protected override void readParticle(int idx, SSParticle p)
            {
                base.readParticle(idx, p);
                var ts = (STrailsSegment)p;

                ts.cylInnerColor   = Color4Helper.FromUInt32(_readElement(_cylInnerColors, idx).Color);
                ts.innerColorRatio = _readElement(_innerColorRatios, idx).Value;
                ts.outerColorRatio = _readElement(_outerColorRatios, idx).Value;
                ts.cylAxis         = _readElement(_cylAxes, idx).Value;
                ts.prevJointAxis   = _readElement(_prevJointAxes, idx).Value;
                ts.nextJointAxis   = _readElement(_nextJointAxes, idx).Value;
                ts.cylWidth        = _readElement(_cylWidths, idx).Value;
                ts.cylLendth       = _readElement(_cylLengths, idx).Value;
                ts.nextSegmentIdx  = _readElement(_nextSegmentData, idx);
                ts.prevSegmentIdx  = _readElement(_prevSegmentData, idx);
            }
Example #5
0
        public static SSColorMaterial fromMtl(SSWavefrontMTLInfo info)
        {
            Color4 diffuse = Color4Helper.Zero;

            if (info.hasDiffuse)
            {
                diffuse = Color4Helper.fromVector4(info.vDiffuse);
            }
            Color4 ambient = Color4Helper.Zero;

            if (info.hasAmbient)
            {
                ambient = Color4Helper.fromVector4(info.vAmbient);
            }
            Color4 specular = Color4Helper.Zero;

            if (info.hasSpecular)
            {
                specular = Color4Helper.fromVector4(info.vSpecular);
            }
            return(new SSColorMaterial(diffuse, ambient, specular,
                                       Color4Helper.Zero));
        }
Example #6
0
        /// <summary>
        /// To be used by derived classes for shared particle setup
        /// </summary>
        /// <param name="p">particle to setup</param>
        protected virtual void configureNewParticle(SSParticle p)
        {
            p.life = Interpolate.Lerp(lifeMin, lifeMax, nextFloat());

            p.componentScale.X = Interpolate.Lerp(componentScaleMin.X, componentScaleMax.X, nextFloat());
            p.componentScale.Y = Interpolate.Lerp(componentScaleMin.Y, componentScaleMax.Y, nextFloat());
            p.componentScale.Z = Interpolate.Lerp(componentScaleMin.Z, componentScaleMax.Z, nextFloat());

            if (billboardXY)
            {
                p.billboardXY = true;
            }
            else
            {
                p.orientation.X = Interpolate.Lerp(_orientationMin.X, _orientationMax.X, nextFloat());
                p.orientation.Y = Interpolate.Lerp(_orientationMin.Y, _orientationMax.Y, nextFloat());
            }
            p.orientation.Z = Interpolate.Lerp(_orientationMin.Z, _orientationMax.Z, nextFloat());

            p.angularVelocity.X = Interpolate.Lerp(angularVelocityMin.X, angularVelocityMax.X, nextFloat());
            p.angularVelocity.Y = Interpolate.Lerp(angularVelocityMin.Y, angularVelocityMax.Y, nextFloat());
            p.angularVelocity.Z = Interpolate.Lerp(angularVelocityMin.Z, angularVelocityMax.Z, nextFloat());

            p.vel.X = Interpolate.Lerp(velocityComponentMin.X, velocityComponentMax.X, nextFloat());
            p.vel.Y = Interpolate.Lerp(velocityComponentMin.Y, velocityComponentMax.Y, nextFloat());
            p.vel.Z = Interpolate.Lerp(velocityComponentMin.Z, velocityComponentMax.Z, nextFloat());

            p.masterScale = Interpolate.Lerp(masterScaleMin, masterScaleMax, nextFloat());

            p.mass = Interpolate.Lerp(massMin, massMax, nextFloat());
            p.rotationalInnertia = Interpolate.Lerp(rotationalInnertiaMin, rotationalInnertiaMax, nextFloat());
            p.drag           = Interpolate.Lerp(dragMin, dragMax, nextFloat());
            p.rotationalDrag = Interpolate.Lerp(rotationalDragMin, rotationalDragMax, nextFloat());

            // color presets
            Color4 randPreset;

            if (colorPresets != null && colorPresets.Length > 0)
            {
                randPreset = colorPresets [_rand.Next(0, colorPresets.Length)];
            }
            else
            {
                randPreset = new Color4(0f, 0f, 0f, 0f);
            }

            // color offsets
            Color4 randOffset;

            randOffset.R = Interpolate.Lerp(colorOffsetComponentMin.R, colorOffsetComponentMax.R, nextFloat());
            randOffset.G = Interpolate.Lerp(colorOffsetComponentMin.G, colorOffsetComponentMax.G, nextFloat());
            randOffset.B = Interpolate.Lerp(colorOffsetComponentMin.B, colorOffsetComponentMax.B, nextFloat());
            randOffset.A = Interpolate.Lerp(colorOffsetComponentMin.A, colorOffsetComponentMax.A, nextFloat());

            // color presets + offsets
            p.color = Color4Helper.Add(ref randPreset, ref randOffset);

            //p.SpriteIndex = SpriteIndices [s_rand.Next(0, SpriteIndices.Length)];
            p.spriteRect = spriteRectangles [_rand.Next(0, spriteRectangles.Length)];

            p.effectorMask = effectorMasks [_rand.Next(0, effectorMasks.Length)];
        }
Example #7
0
 public SSVertex_PosColor(Vector3 pos, Color4 color)
 {
     Position = pos;
     Color    = Color4Helper.ToUInt32(color);
 }
Example #8
0
 public Color4 readColor(int i)
 {
     return(Color4Helper.FromUInt32(_readElement(colors, i).Color));
 }