Пример #1
0
        public void AddParticle(Vector3f posS, float time)
        {
            if (!in_deposit)
            {
                return;
            }

            //ParticleSystem.EmitParams p = new ParticleSystem.EmitParams() {
            //    position = posS,
            //    velocity = Vector3f.Zero,
            //    startSize3D = Vector3f.One,
            //    startLifetime = 3.0f,
            //    startColor = Colorf.VideoRed
            //};
            //ps.Emit(p, 1);

            sparksGO.SetLocalPosition(posS);

            int shift = 0;

            for (int i = 0; i < trailVerts.Count; ++i)
            {
                if (time - trailVerts[i].time > TrailTime)
                {
                    shift++;
                }
            }
            if (shift > 0)
            {
                trailVerts.RemoveRange(0, shift);
            }

            TrailVert newv = new TrailVert()
            {
                pos = posS, time = time
            };

            if (trailVerts.Count == 0)
            {
                trailVerts.Add(newv);
            }
            else
            {
                TrailVert last = trailVerts[trailVerts.Count - 1];
                if (posS.Distance(last.pos) > 0.1f)
                {
                    trailVerts.Add(newv);
                }
                else
                {
                    trailVerts[trailVerts.Count - 1] = newv;
                }
            }

            trailGO.SetVertices(TrailPosArray());
            trailGO.SetLineWidth(0.1f, 0.5f);

            //trailGO.SetLocalPosition(posS);
        }
Пример #2
0
        fPolylineGameObject make_path <T>(LinearToolpath3 <T> path, fMaterial material, float width, Vector3d origin) where T : IToolpathVertex
        {
            Vector3d prev = Vector3d.Zero;

            tempPolyLine.Clear();
            foreach (T vtx in path)
            {
                Vector3d v = origin + vtx.Position;
                v = MeshTransforms.ConvertZUpToYUp(v);
                v = MeshTransforms.FlipLeftRightCoordSystems(v);

                // [RMS] because of the sharp turns we make, unity polyline will get twisted up unless we put
                // in some duplicate vertices =\
                if (tempPolyLine.Count > 0)
                {
                    tempPolyLine.Add((Vector3f)Vector3d.Lerp(prev, v, 0.001));
                    tempPolyLine.Add((Vector3f)Vector3d.Lerp(prev, v, 0.998));
                    tempPolyLine.Add((Vector3f)Vector3d.Lerp(prev, v, 0.999));
                }
                tempPolyLine.Add((Vector3f)v);
                prev = v;
            }

            fPolylineGameObject go = PolylinePool.Allocate();

            go.SetMaterial(material, true);
            go.SetLineWidth(width);
            go.SetVertices(tempPolyLine.ToArray(), false, true);
            return(go);
        }