コード例 #1
0
        // Given a face, splits it into a uniform grid and extrudes each grid face
        // out and back in again, making an exhaust shape.
        private void AddExhaustToFace(GenMesh genmesh, GenMeshFace faceForExhaust)
        {
            // The more square the face is, the more grid divisions it might have
            var num_cuts = Random.Range(1, (int)(4 - faceForExhaust.AspectRatio));
            var result   = genmesh.Subdivide(faceForExhaust, num_cuts);

            var exhaust_length = Random.Range(0.1f, 0.2f);
            var scaleOuter     = 1f / Random.Range(1.3f, 1.6f);
            var scale_inner    = 1f / Random.Range(1.05f, 1.1f);

            for (var i = 0; i < result.Count(); i++)
            {
                var face = result[i];
                face.MaterialIndex = 2;// Material.hull_dark;

                face = ExtrudeFace(genmesh, face, exhaust_length);
                ScaleFace(genmesh, face, scaleOuter, scaleOuter, scaleOuter);

                face = ExtrudeFace(genmesh, face, 0);
                ScaleFace(genmesh, face, scaleOuter * 0.9f, scaleOuter * 0.9f, scaleOuter * 0.9f);

                var extruded_face_list = new List <GenMeshFace>();
                face = ExtrudeFace(genmesh, face, -exhaust_length * 0.9f, extruded_face_list);

                foreach (var extruded_face in extruded_face_list)
                {
                    extruded_face.MaterialIndex = 3;// Material.exhaust_burn
                }
                ScaleFace(genmesh, face, scale_inner, scale_inner, scale_inner);
            }
        }
コード例 #2
0
        private void AddGridToFace(GenMesh genmesh, GenMeshFace fac)
        {
            var result     = genmesh.Subdivide(fac, Random.Range(2, 4));
            var gridLength = Random.Range(0.025f, 0.15f);
            var scale      = 0.8f;

            for (var i = 0; i < result.Length; i++)
            {
                var face             = result[i];
                var materialIndex    = Random.value > 0.5f ? 1 /*Material.hull_lights*/ : 4 /*Material.hull*/;
                var extrudedFaceList = new List <GenMeshFace>();

                face = ExtrudeFace(genmesh, face, gridLength, extrudedFaceList);

                foreach (var f in extrudedFaceList)
                {
                    if (Mathf.Abs(face.Normal.z) < 0.707) // # side face
                    {
                        f.MaterialIndex = materialIndex;
                    }
                }

                ScaleFace(genmesh, face, scale, scale, scale);
            }
        }