Ejemplo n.º 1
0
        public void BulkReadTest()
        {
            var files = Directory.EnumerateFiles(@"E:\MDX", "*.mdx", SearchOption.AllDirectories);

            foreach (var file in files)
            //Parallel.ForEach(files, file =>
            {
                Model mdx                     = new Model(file);
                VERS  version                 = mdx.Get <VERS>();
                MODL  modl                    = mdx.Get <MODL>();
                SEQS  sequences               = mdx.Get <SEQS>();
                MTLS  materials               = mdx.Get <MTLS>();
                TEXS  textures                = mdx.Get <TEXS>();
                GEOS  geosets                 = mdx.Get <GEOS>();
                GEOA  geosetanims             = mdx.Get <GEOA>();
                HELP  helpers                 = mdx.Get <HELP>();
                ATCH  attachments             = mdx.Get <ATCH>();
                PIVT  pivotpoints             = mdx.Get <PIVT>();
                CAMS  cameras                 = mdx.Get <CAMS>();
                EVTS  events                  = mdx.Get <EVTS>();
                CLID  collisions              = mdx.Get <CLID>();
                GLBS  globalsequences         = mdx.Get <GLBS>();
                PRE2  particleemitter2s       = mdx.Get <PRE2>();
                RIBB  ribbonemitters          = mdx.Get <RIBB>();
                LITE  lights                  = mdx.Get <LITE>();
                TXAN  textureanimations       = mdx.Get <TXAN>();
                BONE  bones                   = mdx.Get <BONE>();
                BPOS  bindpositions           = mdx.Get <BPOS>();
                FAFX  faceFXes                = mdx.Get <FAFX>();
                CORN  particleEmitterPopcorns = mdx.Get <CORN>();
            }
            //);
        }
Ejemplo n.º 2
0
    public override void WhileLiving(float v)
    {
        if (active == true)
        {
            // print(Camera.main);
            cameraLeft      = -Camera.main.transform.right;
            cameraUp        = Camera.main.transform.up;
            transformFloats = HELP.GetMatrixFloats(skin.gameObject.transform.worldToLocalMatrix);
//      print( transformFloats);

            if (drawable == true)
            {
                if (touch.JustDown == 1)
                {
                    CheckForNew();// SetParticle( trace , currentID ,  )
                }

                if (dragDraw)
                {
                    if (touch.Down == 1)
                    {
                        CheckForNew();
                    }
                }
            }
        }
    }
Ejemplo n.º 3
0
    public override void WhileLiving(float v)
    {
        //set.active = false;
        force.active      = false;
        constraint.active = false;
        resolve.active    = false;
        pass.active       = false;

        //set.active = false;
        transformArray = HELP.GetMatrixFloats(transform.localToWorldMatrix);



        resolve._SetUpDispatch();
        resolve._DispatchShader();

        for (int i = 0; i < numIterations; i++)
        {
            force._SetUpDispatch();
            force._DispatchShader();

            constraint._SetUpDispatch();
            constraint._DispatchShader();

            pass._SetUpDispatch();
            pass._DispatchShader();
        }
    }
Ejemplo n.º 4
0
    public override void WhileLiving(float v)
    {
        if (Active == true)
        {
            // print(Camera.main);
            cameraLeft      = -Camera.main.transform.right;
            cameraUp        = Camera.main.transform.up;
            transformFloats = HELP.GetMatrixFloats(skin.gameObject.transform.localToWorldMatrix);

            place.Live();
            if (touch.Down == 1)
            {
                intersect.Live();
            }


            if (showBody == true)
            {
                bodyTransfer.Live();

                body.WhileLiving(1);
            }
            else
            {
                body.Hide();
            }
        }
    }
Ejemplo n.º 5
0
    public override void WhileLiving(float v)
    {
        if (active == true)
        {
            // print(Camera.main);
            cameraLeft      = -Camera.main.transform.right;
            cameraUp        = Camera.main.transform.up;
            transformFloats = HELP.GetMatrixFloats(skin.gameObject.transform.localToWorldMatrix);

            if (drawable == true)
            {
//        intersect.active = true;
                intersect.readBack = true;
                if (touch.Down == 1)
                {
                    intersect.active = true;
                }
                else
                {
                    intersect.active = false;
                }
            }
            else
            {
                intersect.active   = false;
                intersect.readBack = false;
            }
        }
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    public void WhileDown(Ray ray)
    {
        RaycastHit hit;

        if (person.Raycast(ray, out hit, 100.0f))
        {
            down = true;

            hitPoint  = hit.point;
            hitUV     = hit.textureCoord;
            hitNormal = hit.normal;
            traceRepresent.transform.position = hitPoint;

            triIDs = new Vector3(
                person.sharedMesh.triangles[hit.triangleIndex * 3 + 0],
                person.sharedMesh.triangles[hit.triangleIndex * 3 + 1],
                person.sharedMesh.triangles[hit.triangleIndex * 3 + 2]);


            bary = hit.barycentricCoordinate;

            hitTangent  = bary.x * HELP.ToV3(person.sharedMesh.tangents[(int)triIDs.x]);
            hitTangent += bary.y * HELP.ToV3(person.sharedMesh.tangents[(int)triIDs.y]);
            hitTangent += bary.z * HELP.ToV3(person.sharedMesh.tangents[(int)triIDs.z]);
        }
        else
        {
            down = false;
        }
    }
Ejemplo n.º 7
0
        public override void WhileLiving(float v)
        {
            for (int i = 0; i < count; i++)
            {
                tmp = HELP.GetMatrixFloats(humans[i].LeftHand.localToWorldMatrix);
                for (int j = 0; j < 16; j++)
                {
                    values[i * structSize + j] = tmp[j];
                }

                tmp = HELP.GetMatrixFloats(humans[i].RightHand.localToWorldMatrix);
                for (int j = 0; j < 16; j++)
                {
                    values[i * structSize + 16 + j] = tmp[j];
                }

                tmp = HELP.GetMatrixFloats(humans[i].Head.localToWorldMatrix);
                for (int j = 0; j < 16; j++)
                {
                    values[i * structSize + 32 + j] = tmp[j];
                }

                values[i * structSize + 48 + 0] = humans[i].LeftTrigger;
                values[i * structSize + 48 + 1] = humans[i].RightTrigger;
                values[i * structSize + 48 + 2] = humans[i].Voice;
                values[i * structSize + 48 + 3] = humans[i].DebugVal;
            }

            SetData(values);
        }
Ejemplo n.º 8
0
        public override void WhileLiving(float v)
        {
            //numFrames += 1;
            //if( numFrames == 10 ){ Set(); Activate(); }

            //set.active = false;
            transformArray = HELP.GetMatrixFloats(transform.localToWorldMatrix);
        }
Ejemplo n.º 9
0
    public override void WhileLiving(float v)
    {
        transformArray = HELP.GetMatrixFloats(((ParticlesOnMesh)Base).mesh.gameObject.transform.localToWorldMatrix);
        HairCollision.shader.SetFloat("_HairLength", Hair.length);
        HairCollision.shader.SetInt("_NumVertsPerHair", Hair.numVertsPerHair);
        HairCollision.Live();
        HairConstraint0.Live();
        HairConstraint1.Live();
        HairTransfer.Live();

        body.WhileLiving(1);
    }
Ejemplo n.º 10
0
    public override void WhileLiving(float v)
    {
        if (active == true)
        {
            transformArray = HELP.GetMatrixFloats(transform.localToWorldMatrix);


            if (showBody == true)
            {
                body.active = true;
            }
            else
            {
                body.active = false;
            }
        }
    }
Ejemplo n.º 11
0
    public void SetInfo()
    {
        for (int i = 0; i < transforms.Length; i++)
        {
            tmpVals = HELP.GetMatrixFloats(transforms[i].localToWorldMatrix);
            for (int j = 0; j < 16; j++)
            {
                values[i * 32 + j] = tmpVals[j];
            }

            tmpVals = HELP.GetMatrixFloats(transforms[i].worldToLocalMatrix);
            for (int j = 0; j < 16; j++)
            {
                values[i * 32 + j + 16] = tmpVals[j];
            }
        }

        SetData(values);
    }
Ejemplo n.º 12
0
    public override void WhileLiving(float v)
    {
        transformArray = HELP.GetMatrixFloats(this.transform.localToWorldMatrix);
        //HairCollision.shader.SetFloat("_HairLength", Hair.length );
        //HairCollision.shader.SetInt("_NumVertsPerHair", Hair.numVertsPerHair);
        HairCollision.Live();
        HairConstraint0.Live();
        HairConstraint1.Live();

        if (showBody == true)
        {
            HairTransfer.Live();

            body.WhileLiving(1);
        }
        else
        {
            body.Hide();
        }
    }
Ejemplo n.º 13
0
        public override void WhileLiving(float v)
        {
            for (int i = 0; i < count; i++)
            {
                tmp = HELP.GetMatrixFloats(humans[i].LeftHand.localToWorldMatrix);
                for (int j = 0; j < 16; j++)
                {
                    values[i * structSize + j] = tmp[j];
                }

                tmp = HELP.GetMatrixFloats(humans[i].RightHand.localToWorldMatrix);
                for (int j = 0; j < 16; j++)
                {
                    values[i * structSize + 16 + j] = tmp[j];
                }

                tmp = HELP.GetMatrixFloats(humans[i].Head.localToWorldMatrix);
                for (int j = 0; j < 16; j++)
                {
                    values[i * structSize + 32 + j] = tmp[j];
                }

                values[i * structSize + 48 + 0] = humans[i].LeftTrigger;
                values[i * structSize + 48 + 1] = humans[i].RightTrigger;
                values[i * structSize + 48 + 2] = humans[i].Voice;
                values[i * structSize + 48 + 3] = humans[i].DebugVal;
            }

            SetData(values);

            // Toggles head force
            if (Input.GetKeyDown(KeyCode.Space))
            {
                headForce = 1 - headForce;
            }
        }
Ejemplo n.º 14
0
        public override void Embody()
        {
            print("Embodying particles on dynamic mesh");

            float[] triangleAreas = new float[tris.count / 3];

            int[]   triData  = tris.GetIntData();
            float[] vertData = verts.GetFloatData();


            print(tris.count);
            print(verts.count);

            float totalArea = 0;

            int tri0;
            int tri1;
            int tri2;

            for (int i = 0; i < tris.count / 3; i++)
            {
                /*tri0 = i * 3;
                 * tri1 = tri0 + 1;
                 * tri2 = tri0 + 2;
                 *
                 * tri0 = triData[tri0];
                 * tri1 = triData[tri1];
                 * tri2 = triData[tri2];
                 *
                 * float area = 1;
                 *
                 * Vector3 p0 = extractToVector(tri0,0,vertData,verts);
                 * Vector3 p1 = extractToVector(tri1,0,vertData,verts);
                 * Vector3 p2 = extractToVector(tri2,0,vertData,verts);
                 *
                 * if( noiseType=="even"){
                 * area = HELP.AreaOfTriangle (p0, p1, p2);
                 * }else if( noiseType =="fractal" ){
                 * area = HELP.NoiseTriangleArea(noiseSize, p0, p1, p2);
                 * area = Mathf.Pow( area, 10);
                 * }*/

                triangleAreas[i] = 1;
                totalArea       += 1;
            }

            for (int i = 0; i < triangleAreas.Length; i++)
            {
                triangleAreas[i] /= totalArea;
            }

            float[] values = new float[count * structSize];

            int index = 0;


            Vector3 pos;
            int     baseTri;

            for (int i = 0; i < count; i++)
            {
                baseTri = 3 * HELP.getTri(Random.value, triangleAreas);

                tri0 = baseTri + 0;
                tri1 = baseTri + 1;
                tri2 = baseTri + 2;

                tri0 = triData[tri0];
                tri1 = triData[tri1];
                tri2 = triData[tri2];

                Vector3 v0 = new Vector3(1, 0, 0); //extractToVector(tri0,0,vertData,verts);
                Vector3 v1 = new Vector3(0, 1, 0); //extractToVector(tri1,0,vertData,verts);
                Vector3 v2 = new Vector3(0, 0, 1); //extractToVector(tri2,0,vertData,verts);

                pos = HELP.GetRandomPointInTriangle(i, v0, v1, v2);

                float a0 = HELP.AreaOfTriangle(pos, v1, v2);
                float a1 = HELP.AreaOfTriangle(pos, v0, v2);
                float a2 = HELP.AreaOfTriangle(pos, v0, v1);

                float aTotal = a0 + a1 + a2;

                float p0 = a0 / aTotal;
                float p1 = a1 / aTotal;
                float p2 = a2 / aTotal;

                //if( aTotal == 0 ){ print("hellloo"); }


                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                values[index++] = 0;
                values[index++] = 0;


                values[index++] = (float)i / (float)count;

                values[index++] = tri0;
                values[index++] = tri1;
                values[index++] = tri2;

                values[index++] = p0;
                values[index++] = p1;
                values[index++] = p2;

                values[index++] = 1;
                values[index++] = 0;
                values[index++] = 0;
            }


            SetData(values);
        }
Ejemplo n.º 15
0
        public override void Embody()
        {
            float[] triangleAreas = new float[tris.count / 3];

            int[]   triData  = tris.GetIntData();
            float[] vertData = verts.GetFloatData();

            float totalArea = 0;

            int tri0;
            int tri1;
            int tri2;

            for (int i = 0; i < tris.count / 3; i++)
            {
                tri0 = i * 3;
                tri1 = tri0 + 1;
                tri2 = tri0 + 2;

                tri0 = triData[tri0];
                tri1 = triData[tri1];
                tri2 = triData[tri2];

                float area = 1;

                Vector3 p0 = extractToVector(tri0, 0, vertData, verts);
                Vector3 p1 = extractToVector(tri1, 0, vertData, verts);
                Vector3 p2 = extractToVector(tri2, 0, vertData, verts);

                if (noiseType == "even")
                {
                    area = HELP.AreaOfTriangle(p0, p1, p2);
                }
                else if (noiseType == "fractal")
                {
                    area = HELP.NoiseTriangleArea(noiseSize, p0, p1, p2);
                    area = Mathf.Pow(area, 10);
                }

                triangleAreas[i] = area;
                totalArea       += area;
            }

            for (int i = 0; i < triangleAreas.Length; i++)
            {
                triangleAreas[i] /= totalArea;
            }

            float[] values = new float[count * structSize];

            int index = 0;


            Vector3 pos;
            Vector3 uv;
            Vector3 tan;
            Vector3 nor;
            int     baseTri;

            for (int i = 0; i < count; i++)
            {
                baseTri = 3 * HELP.getTri(Random.value, triangleAreas);

                tri0 = baseTri + 0;
                tri1 = baseTri + 1;
                tri2 = baseTri + 2;

                tri0 = triData[tri0];
                tri1 = triData[tri1];
                tri2 = triData[tri2];

                Vector3 v0 = extractToVector(tri0, 0, vertData, verts);
                Vector3 v1 = extractToVector(tri1, 0, vertData, verts);
                Vector3 v2 = extractToVector(tri2, 0, vertData, verts);

                pos = HELP.GetRandomPointInTriangle(i, v0, v1, v2);

                float a0 = HELP.AreaOfTriangle(pos, v1, v2);
                float a1 = HELP.AreaOfTriangle(pos, v0, v2);
                float a2 = HELP.AreaOfTriangle(pos, v0, v1);

                float aTotal = a0 + a1 + a2;

                float p0 = a0 / aTotal;
                float p1 = a1 / aTotal;
                float p2 = a2 / aTotal;


                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                values[index++] = 0;
                values[index++] = 0;


                values[index++] = (float)i / (float)count;

                values[index++] = tri0;
                values[index++] = tri1;
                values[index++] = tri2;

                values[index++] = p0;
                values[index++] = p1;
                values[index++] = p2;

                values[index++] = 1;
                values[index++] = 0;
                values[index++] = 0;
            }


            SetData(values);
        }
Ejemplo n.º 16
0
    public override void Embody()
    {
        float[] triangleAreas = new float[tris.count / 3];

        int[]   triData  = tris.GetIntData();
        float[] vertData = verts.GetFloatData();

        float totalArea = 0;

        int tri0;
        int tri1;
        int tri2;

        for (int i = 0; i < tris.count / 3; i++)
        {
            tri0 = i * 3;
            tri1 = tri0 + 1;
            tri2 = tri0 + 2;

            tri0 = triData[tri0];
            tri1 = triData[tri1];
            tri2 = triData[tri2];

            float area = 1;

            Vector3 p0  = extractToVector(tri0, 0, vertData, verts);
            Vector3 p1  = extractToVector(tri1, 0, vertData, verts);
            Vector3 p2  = extractToVector(tri2, 0, vertData, verts);
            Vector2 uv0 = extractToVector2(tri0, 12, vertData, verts);
            Vector2 uv1 = extractToVector2(tri1, 12, vertData, verts);
            Vector2 uv2 = extractToVector2(tri2, 12, vertData, verts);



            if (noiseType == NoiseType.MiddleBand)
            {
                float Y = 1 - ((1 - uv0.y) + (1 - uv1.y) + (1 - uv2.y)) / 3;
                area  = Mathf.Clamp(Mathf.Min(Y * 2, (1 - Y)) * 4.5f, 0, 4); //((1-uv0.y) + (1-uv1.y) + (1-uv2.y) ) / 3;
                area *= area * area;                                         // * area * area*area;
            }
            else if (noiseType == NoiseType.CenterOut)
            {
            }
            else if (noiseType == NoiseType.Even)
            {
                float Y = 1 - ((1 - uv0.y) + (1 - uv1.y) + (1 - uv2.y)) / 3;
                area = Y;
            }
            else if (noiseType == NoiseType.OuterRing)
            {
                float Y = 1 - ((1 - uv0.y) + (1 - uv1.y) + (1 - uv2.y)) / 3;
                area = Y * Y;
            }



            triangleAreas[i] = area;
            totalArea       += area;
        }

        for (int i = 0; i < triangleAreas.Length; i++)
        {
            triangleAreas[i] /= totalArea;
        }

        float[] values = new float[count * structSize];

        int index = 0;


        Vector3 pos;
        //Vector3 uv;
        //Vector3 tan;
        //Vector3 nor;
        int baseTri;

        for (int i = 0; i < count; i++)
        {
            baseTri = 3 * HELP.getTri(Random.value, triangleAreas);

            if (specialInCenter && i == 0)
            {
                baseTri = 0;
            }

            tri0 = baseTri + 0;
            tri1 = baseTri + 1;
            tri2 = baseTri + 2;

            tri0 = triData[tri0];
            tri1 = triData[tri1];
            tri2 = triData[tri2];

            Vector3 v0 = extractToVector(tri0, 0, vertData, verts);
            Vector3 v1 = extractToVector(tri1, 0, vertData, verts);
            Vector3 v2 = extractToVector(tri2, 0, vertData, verts);

            pos = HELP.GetRandomPointInTriangle(i, v0, v1, v2);

            float a0 = HELP.AreaOfTriangle(pos, v1, v2);
            float a1 = HELP.AreaOfTriangle(pos, v0, v2);
            float a2 = HELP.AreaOfTriangle(pos, v0, v1);

            float aTotal = a0 + a1 + a2;

            float p0 = a0 / aTotal;
            float p1 = a1 / aTotal;
            float p2 = a2 / aTotal;


            values[index++] = 0;
            values[index++] = 0;
            values[index++] = 0;

            values[index++] = 0;
            values[index++] = 0;
            values[index++] = 0;

            values[index++] = 0;
            values[index++] = 0;
            values[index++] = 0;

            values[index++] = 0;
            values[index++] = 0;
            values[index++] = 0;

            values[index++] = 0;
            values[index++] = 0;


            values[index++] = (float)i / (float)count;

            values[index++] = tri0;
            values[index++] = tri1;
            values[index++] = tri2;

            values[index++] = p0;
            values[index++] = p1;
            values[index++] = p2;

            values[index++] = 1;

            if (specialInCenter)
            {
                values[index++] = 1;
            }
            else
            {
                values[index++] = triangleAreas[baseTri / 3] * 1000;
            }
            values[index++] = 0;
        }


        SetData(values);
    }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            //Tests.BulkParse();

            M2 comparison = new M2();

            using (var reader = new BinaryReader(new FileStream(@"Files\Boar.m2", FileMode.Open)))
                comparison.Load(reader);


            string file = @"Files\Boar.mdx";

            if (args.Length > 0 && File.Exists(args[0]))
            {
                file = args[0];
            }

            Model mdx               = new Model(file);
            VERS  version           = mdx.Get <VERS>();
            MODL  modl              = mdx.Get <MODL>();
            SEQS  sequences         = mdx.Get <SEQS>();
            MTLS  materials         = mdx.Get <MTLS>();
            TEXS  textures          = mdx.Get <TEXS>();
            GEOS  geosets           = mdx.Get <GEOS>();
            GEOA  geosetanims       = mdx.Get <GEOA>();
            HELP  helpers           = mdx.Get <HELP>();
            ATCH  attachments       = mdx.Get <ATCH>();
            PIVT  pivotpoints       = mdx.Get <PIVT>();
            CAMS  cameras           = mdx.Get <CAMS>();
            EVTS  events            = mdx.Get <EVTS>();
            HTST  hittestshapes     = mdx.Get <HTST>();
            CLID  collisions        = mdx.Get <CLID>();
            GLBS  globalsequences   = mdx.Get <GLBS>();
            PRE2  particleemitter2s = mdx.Get <PRE2>();
            RIBB  ribbonemitters    = mdx.Get <RIBB>();
            LITE  lights            = mdx.Get <LITE>();
            TXAN  textureanimations = mdx.Get <TXAN>();
            BONE  bones             = mdx.Get <BONE>();

            M2Converter converter = new M2Converter(mdx, M2.Format.LichKing);
            var         m2        = converter.Model;

            m2.Attachments          = converter.GetAttachments();
            m2.Bones                = converter.GetBones();
            m2.BoundingBox          = converter.GetBoundingBox();
            m2.BoundingSphereRadius = converter.GetBoundingSphereRadius();
            m2.Cameras              = converter.GetCameras();
            m2.Colors               = converter.GetColors();
            m2.Events               = converter.GetEvents();
            m2.GlobalSequences      = converter.GetGlobalSequences();
            m2.GlobalVertexList     = converter.GetVertices();
            m2.Materials            = converter.GetMaterials();
            m2.Textures             = converter.GetTextures();
            m2.Sequences            = converter.GetSequences();
            m2.TexLookup            = converter.GetTextureLookup();
            m2.TexUnitLookup        = converter.GetTexUnitLookup();
            m2.TextureTransforms    = converter.GetTextureTransform();
            m2.Transparencies       = converter.GetTextureWeights();

            m2.UvAnimLookup.Add(-1);

            m2.GlobalVertexList.ForEach(x => x.TexCoords[0] = new C2Vector(x.TexCoords[0].X, x.TexCoords[0].Y * -1f));

            m2.Views.Add(converter.GetSkin());
            m2.BoneLookup = converter.GetBoneLookup();

            converter.UpdateCollisions();

            using (var fs = new FileStream(Path.ChangeExtension(file, "m2"), FileMode.Create))
                using (var bw = new BinaryWriter(fs))
                    m2.Save(bw, M2.Format.LichKing);
        }
Ejemplo n.º 18
0
 public override void WhileLiving(float v)
 {
     //set.active = false;
     transformArray = HELP.GetMatrixFloats(transform.localToWorldMatrix);
 }
Ejemplo n.º 19
0
 public override void WhileLiving(float v)
 {
     transformFloats = HELP.GetMatrixFloats(t.localToWorldMatrix);
 }
Ejemplo n.º 20
0
        public override void Embody()
        {
            Vector3[] verts  = new Vector3[count];
            Vector3[] nors   = new Vector3[count];
            Vector3[] tans   = new Vector3[count];
            Vector2[] uvs    = new Vector2[count];
            int[]     meshID = new int[count];

            int index = 0;

            for (int i = 0; i < meshes.Length; i++)
            {
                Vector3[] v = meshes[i].GetComponent <MeshFilter>().sharedMesh.vertices;
                Vector3[] n = meshes[i].GetComponent <MeshFilter>().sharedMesh.normals;
                Vector4[] t = meshes[i].GetComponent <MeshFilter>().sharedMesh.tangents;
                Vector2[] u = meshes[i].GetComponent <MeshFilter>().sharedMesh.uv;

                for (int j = 0; j < v.Length; j++)
                {
                    verts[index]  = meshes[i].transform.TransformPoint(v[j]);
                    nors[index]   = meshes[i].transform.TransformDirection(n[j]);
                    tans[index]   = meshes[i].transform.TransformDirection(HELP.ToV3(t[j]));
                    uvs[index]    = u[j];
                    meshID[index] = i;
                    index        += 1;
                }
            }


            float[] values = new float[count * structSize];
            index = 0;

            for (int i = 0; i < count; i++)
            {
                //DebugThis( "" +verts[i].x );

                values[index++] = verts[i].x;
                values[index++] = verts[i].y;
                values[index++] = verts[i].z;

                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                values[index++] = nors[i].x;
                values[index++] = nors[i].y;
                values[index++] = nors[i].z;


                values[index++] = tans[i].x;
                values[index++] = tans[i].y;
                values[index++] = tans[i].z;


                values[index++] = uvs[i].x;
                values[index++] = uvs[i].y;

                values[index++] = (float)i / (float)count;
                values[index++] = meshID[i];
            }

            SetData(values);
        }
Ejemplo n.º 21
0
    public override void Embody(Form parent)
    {
        int[]     triangles = mesh.mesh.triangles;
        Vector3[] verts     = mesh.mesh.vertices;
        Vector2[] uvs       = mesh.mesh.uv;
        Vector4[] tans      = mesh.mesh.tangents;
        Vector3[] nors      = mesh.mesh.normals;

        float[] triangleAreas = new float[triangles.Length / 3];
        float   totalArea     = 0;

        int tri0;
        int tri1;
        int tri2;

        for (int i = 0; i < triangles.Length / 3; i++)
        {
            tri0 = i * 3;
            tri1 = tri0 + 1;
            tri2 = tri0 + 2;

            tri0 = triangles[tri0];
            tri1 = triangles[tri1];
            tri2 = triangles[tri2];

            float area = 1;

            if (noiseType == "even")
            {
                area = HELP.AreaOfTriangle(verts[tri0], verts[tri1], verts[tri2]);
            }
            else if (noiseType == "fractal")
            {
                area = HELP.NoiseTriangleArea(noiseSize, verts[tri0], verts[tri1], verts[tri2]);
                area = Mathf.Pow(area, 10);
            }

            triangleAreas[i] = area;
            totalArea       += area;
        }

        for (int i = 0; i < triangleAreas.Length; i++)
        {
            triangleAreas[i] /= totalArea;
        }

        float[] values = new float[count * structSize];

        int index = 0;


        Vector3 pos;
        Vector3 uv;
        Vector3 tan;
        Vector3 nor;
        int     baseTri;

        for (int i = 0; i < count; i++)
        {
            baseTri = 3 * HELP.getTri(Random.value, triangleAreas);
            tri0    = baseTri + 0;
            tri1    = baseTri + 1;
            tri2    = baseTri + 2;

            tri0 = triangles[tri0];
            tri1 = triangles[tri1];
            tri2 = triangles[tri2];

            pos = HELP.GetRandomPointInTriangle(i, verts[tri0], verts[tri1], verts[tri2]);

            float a0 = HELP.AreaOfTriangle(pos, verts[tri1], verts[tri2]);
            float a1 = HELP.AreaOfTriangle(pos, verts[tri0], verts[tri2]);
            float a2 = HELP.AreaOfTriangle(pos, verts[tri0], verts[tri1]);

            float aTotal = a0 + a1 + a2;

            float p0 = a0 / aTotal;
            float p1 = a1 / aTotal;
            float p2 = a2 / aTotal;

            nor = (nors[tri0] * p0 + nors[tri1] * p1 + nors[tri2] * p2).normalized;
            uv  = uvs[tri0] * p0 + uvs[tri1] * p1 + uvs[tri2] * p2;
            tan = (HELP.ToV3(tans[tri0]) * p0 + HELP.ToV3(tans[tri1]) * p1 + HELP.ToV3(tans[tri2]) * p2).normalized;


//            print( pos);
            values[index++] = pos.x;
            values[index++] = pos.y;
            values[index++] = pos.z;

            values[index++] = 0;
            values[index++] = 0;
            values[index++] = 0;

            values[index++] = nor.x;
            values[index++] = nor.y;
            values[index++] = nor.z;

            values[index++] = tan.x;
            values[index++] = tan.y;
            values[index++] = tan.z;

            values[index++] = uv.x;
            values[index++] = uv.y;

            values[index++] = i;
            values[index++] = i / count;
        }


        SetData(values);
    }
Ejemplo n.º 22
0
 private static void HelpOnHelp()
 {
     Add("The command syntax for requesting additional help with NuGetHandler is:");
     Add();
     Add("  NuGetHandler -h <subject>");
     Add();
     Add("where <subject> is the desired section of help to be acquired. Given that the");
     Add("length of some of the subject matter is quite long, it is recommended that the");
     Add("output of the help system be piped to a text file for later review.");
     Add();
     Add("Some subjects will also yield the actual settings as derived from values");
     Add("present on the command line and from the various app.*.config files.");
     Add(@"To cause those values to be displayed, a verbosity value of ""detailed""");
     Add("to the command line e.g. -v detailed");
     Add();
     Add("The list of subjects follows:");
     Add(HelpSections.ToString());
     SectionBreak("Content of help sections");
     Add($"{"<none>".PadItRight()}The program summary plus this help description.");
     Add();
     Add($"{ALL.PadItRight()}Generate the entire help content (best");
     Add($"{String.Empty.PadItLeft()}redirected to a file for further perusal).");
     Add();
     Add($"{APP_CONFIG_SETTINGS.PadItRight()}Just the information as found in the appSettings");
     Add($"{String.Empty.PadItLeft()}portion of the app.config file and its possible");
     Add($"{String.Empty.PadItLeft()}app.optional.config files.");
     Add();
     Add($"{APP_CONFIG_NUSPEC_DOTNET.PadItRight()}Just the information as found in the");
     Add($"{String.Empty.PadItLeft()}DotNetNuSpecSettings section of the app.config");
     Add($"{String.Empty.PadItLeft()}file and its possible app.optional.config files.");
     Add();
     Add($"{APP_CONFIG_NUSPEC_NUGET.PadItRight()}");
     Add($"{String.Empty.PadItLeft()}NuGetNuSpecSettings section of the app.config file");
     Add($"{String.Empty.PadItLeft()}and its possible app.optional.config files.");
     Add();
     Add($"{COMMAND_LINE.PadItRight()}Help on the command line switches and named value");
     Add($"{String.Empty.PadItLeft()}pairs plus the command line introduction.");
     Add();
     Add($"{COMMAND_LINE_SWITCHES.PadItRight()}Help on just the command line switches.");
     Add();
     Add($"{COMMAND_LINE_NAMED_VALUES.PadItRight()}Help on just the command line named values.");
     Add();
     Add($"{COMMAND_SEQUENCE.PadItRight()}Complete list of commands and their respective");
     Add($"{String.Empty.PadItLeft()}command line parameters as supported in");
     Add($"{String.Empty.PadItLeft()}NuGetHandler");
     Add();
     Add($"{COMMAND_SEQUENCE_DOTNET_CORE.PadItRight()}Just the command sequence that supports .net Core");
     Add($"{String.Empty.PadItLeft()}projects (dotnet.exe)");
     Add();
     Add($"{COMMAND_SEQUENCE_NUGET.PadItRight()}Just the command sequence that supports full");
     Add($"{String.Empty.PadItLeft()}framework projects (nuget.exe)");
     Add();
     Add($"{COMMAND_SEQUENCE_DOTNET_STANDARD.PadItRight()}Just the comnmand sequence that supports .net");
     Add($"{String.Empty.PadItLeft()}standard projects (dotnet.exe)");
     Add();
     Add($"{CONFIG_INFO.PadItRight()}Display the settings for the final app.config,");
     Add($"{String.Empty.PadItLeft()}command line calculated values and other");
     Add($"{String.Empty.PadItLeft()}information as determined by the program when");
     Add($"{String.Empty.PadItLeft()}executed. If a project was designated,");
     Add($"{String.Empty.PadItLeft()}the processed project information will be");
     Add($"{String.Empty.PadItLeft()}displayed.");
     Add();
     Add($"{ENVIRONMENT.PadItRight()}Help and content for the program environment.");
     Add();
     Add($"{HELP.PadItRight()}This help description.");
     Add();
     Add($"{NUGET_PUSH.PadItRight()}The combined information concerning the locations");
     Add($"{String.Empty.PadItLeft()}(Push Repositories) of the various nuget servers");
     Add($"{String.Empty.PadItLeft()}and the corresponding destinations (Push");
     Add($"{String.Empty.PadItLeft()}Destinations) that match the repositories.");
     Add();
     Add($"{NUGET_PUSH_REPOS.PadItRight()}Just the information on the nuget server");
     Add($"{String.Empty.PadItLeft()}repositories");
     Add();
     Add($"{NUGET_PUSH_DESTINATIONS.PadItRight()}Just the information on the nuget server");
     Add($"{String.Empty.PadItLeft()}repository destinations.");
     Add();
     Add($"{POSTBUILD.PadItRight()}Emit the necessary code that should be placed");
     Add($"{String.Empty.PadItLeft()}in the Post-Build event section of the properties");
     Add($"{String.Empty.PadItLeft()}of a given project.");
     Add();
     Add($"{SETUP.PadItRight()}How to prepare to install the NuGetHandler");
     Add($"{String.Empty.PadItLeft()}program.");
     Add();
     Add($"{SUMMARY.PadItRight()}Just the summary information for the NuGetHandler");
     Add($"{String.Empty.PadItLeft()}program.");
     Add();
     Add($"{TOKENS.PadItRight()}Help on the replaceable tokens as found in the");
     Add($"{String.Empty.PadItLeft()}app.config file.");
     Add();
 }
Ejemplo n.º 23
0
        public override void Embody()
        {
            Vector3[] verts = mesh.vertices;
            Vector2[] uvs   = mesh.uv;
            Vector3[] nors  = mesh.normals;
            Vector4[] tans  = mesh.tangents;
            DebugThis("" + mesh.tangents.Length);
            DebugThis("" + mesh.vertices.Length);

            bool hasTan = false;

            if (tans.Length == verts.Length)
            {
                hasTan = true;
            }

            bool hasUV = false;

            if (uvs.Length == verts.Length)
            {
                hasUV = true;
            }

            int index = 0;


            // print("Creatings");

            float[] values = new float[count * structSize];
            for (int i = 0; i < count; i++)
            {
                if (transformVerts)
                {
                    verts[i] = transform.TransformPoint(verts[i]);
                }
                values[index++] = verts[i].x;
                values[index++] = verts[i].y;
                values[index++] = verts[i].z;

                values[index++] = 0;
                values[index++] = 0;
                values[index++] = 0;

                if (transformVerts)
                {
                    nors[i] = transform.TransformDirection(nors[i]);
                }
                values[index++] = nors[i].x;
                values[index++] = nors[i].y;
                values[index++] = nors[i].z;


                if (hasTan)
                {
                    Vector3 tT = transform.TransformDirection(HELP.ToV3(tans[i]));
                    if (i < 10)
                    {
                        DebugThis("" + tT.x);
                    }

                    if (transformVerts)
                    {
                        tans[i] = new Vector4(tT.x, tT.y, tT.z, tans[i].w);
                    }

                    values[index++] = tans[i].x;
                    values[index++] = tans[i].y;
                    values[index++] = tans[i].z;
                }
                else
                {
                    values[index++] = 0;
                    values[index++] = 0;
                    values[index++] = 0;
                }

                if (hasUV)
                {
                    values[index++] = uvs[i].x;
                    values[index++] = uvs[i].y;
                }
                else
                {
                    values[index++] = 0;
                    values[index++] = 0;
                }

                values[index++] = (float)i / (float)count;
                values[index++] = 0;
            }

            SetData(values);
        }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            string path          = @"shivr.txt";
            string text_for_test = "";

            using (StreamReader reader = File.OpenText(path))
            {
                text_for_test = reader.ReadToEnd();
            }
            Stream input  = Console.OpenStandardInput();
            Stream output = Console.OpenStandardOutput();
            Stream stderr = Console.OpenStandardError();
            HELP   help   = new HELP();

            string problem = "";

            if (args[0] == "-help")
            {
                problem = help.help(problem);
                stderr.Write(Encoding.ASCII.GetBytes(problem), 0, problem.Length);
                Environment.Exit(0);
            }

            byte[] Header             = new byte[2];
            byte[] Lenght             = new byte[2];
            byte[] title_for_comments = new byte[2];
            title_for_comments[0] = (byte)0XFF;
            title_for_comments[1] = (byte)0XFE;

            byte[] comments_conteins = new byte[32000];
            byte[] text   = Encoding.ASCII.GetBytes(text_for_test);
            int    i      = text.Length / 32000;
            bool   repeat = true;

            byte[] lenght_mass_1 = new byte[2];
            int    p             = 0;

            input.Read(Header, 0, 2);
            output.Write(Header, 0, 2);

            uint j = 2;

            if (BitConverter.ToUInt16(Header, 0) != 0XD8FF)
            {
                problem = "It is not JPEG";
                stderr.Write(Encoding.ASCII.GetBytes(problem), 0, problem.Length);
                Environment.Exit(1);
            }

            while (input.Read(Header, 0, 2) == 2)
            {
                output.Write(Header, 0, 2);
                j += 2;
                if (input.Read(Lenght, 0, 2) < 2)
                {
                    j += 2;

                    problem = "Problems with the Lenght";
                    stderr.Write(Encoding.ASCII.GetBytes(problem), 0, problem.Length);

                    problem = "the location of problem is " + j;
                    stderr.Write(Encoding.ASCII.GetBytes(problem), 0, problem.Length);

                    Environment.Exit(2);
                }

                j += 2;

                output.Write(Lenght, 0, 2);

                Array.Reverse(Lenght);

                UInt16 L = (UInt16)(BitConverter.ToUInt16(Lenght, 0) - 2);
                j += L;
                byte[] mass_1 = new byte[L];
                int    l      = input.Read(mass_1, 0, (int)L);

                if (l != L)
                {
                    problem = "Jpeg is Currupted";
                    stderr.Write(Encoding.ASCII.GetBytes(problem), 0, problem.Length);

                    problem = "Expect" + L;
                    stderr.Write(Encoding.ASCII.GetBytes(problem), 0, problem.Length);

                    problem = "read" + l;
                    stderr.Write(Encoding.ASCII.GetBytes(problem), 0, problem.Length);

                    problem = "in the unit" + j;
                    stderr.Write(Encoding.ASCII.GetBytes(problem), 0, problem.Length);

                    Environment.Exit(3);
                }
                output.Write(mass_1, 0, mass_1.Length);
                if (BitConverter.ToUInt16(Header, 0) == 0xFEFF)
                {
                    if (args[0] == "-DEC")
                    {
                        stderr.Write(mass_1, 0, mass_1.Length);
                    }

                    continue;
                }
                if (args[0] == "-Enc")
                {
                    if (text_for_test.Length >= 32000)
                    {
                        if (repeat == true)
                        {
                            string warning = "Warning: the size of comment is very big";
                            stderr.Write(Encoding.ASCII.GetBytes(warning), 0, warning.Length);
                            while (p != (i))
                            {
                                output.Write(title_for_comments, 0, 2);
                                UInt16 text_of_lenght_to_byte = (UInt16)(32000 + 2);
                                lenght_mass_1 = BitConverter.GetBytes(text_of_lenght_to_byte);
                                Array.Reverse(lenght_mass_1);
                                output.Write(lenght_mass_1, 0, lenght_mass_1.Length);
                                Array.Copy(text, p * 32000, comments_conteins, 0, 32000);
                                output.Write(comments_conteins, 0, 32000);
                                p++;
                            }
                            if (text.Length % 32000 != 0)
                            {
                                output.Write(title_for_comments, 0, 2);
                                UInt16 text_of_lenght_to_byte = (UInt16)(text.Length - (32000 * i) + 2);
                                lenght_mass_1 = BitConverter.GetBytes(text_of_lenght_to_byte);
                                Array.Reverse(lenght_mass_1);
                                output.Write(lenght_mass_1, 0, lenght_mass_1.Length);
                                Array.Copy(text, i * 32000, comments_conteins, 0, text.Length - (32000 * i));
                                output.Write(comments_conteins, 0, text.Length - (32000 * i));
                            }
                            repeat = false;
                        }
                    }
                    else
                    {
                        output.Write(title_for_comments, 0, 2);
                        UInt16 text_of_lenght_to_byte = (UInt16)(text_for_test.Length + 2);
                        lenght_mass_1 = BitConverter.GetBytes(text_of_lenght_to_byte);
                        Array.Reverse(lenght_mass_1);
                        output.Write(lenght_mass_1, 0, lenght_mass_1.Length);
                        output.Write(Encoding.ASCII.GetBytes(text_for_test), 0, text_for_test.Length);
                    }
                }
                if (BitConverter.ToUInt16(Header, 0) == 0XDAFF)
                {
                    int bytes = input.ReadByte();
                    output.WriteByte((byte)bytes);

                    while (bytes != -1)
                    {
                        bytes = input.ReadByte();

                        if (bytes == -1)
                        {
                            break;
                        }

                        output.WriteByte((byte)bytes);
                    }
                }
            }
        }