示例#1
0
    THREE.Geometry AddRenderObject(THREE.Geometry geo, Material material, Vector3 position, Vector3 angle)
    {
        //int def = geo.mergeVertices();

        geo.computeFaceNormals();
        geo.copyFaceNormalToVertexNormals();
        //geo.computeVertexNormals(true);

        UnityEngine.Mesh mesh = geo.GetMesh(30.0f);
//		mesh.RecalculateBounds();
//		mesh.RecalculateNormals();

        //UnityMeshUtils.MeshSmoothNormals2(mesh);

        position.y += -95;

        GameObject gObj = new GameObject();

        gObj.transform.SetParent(this.transform);

        gObj.transform.localPosition    = position * 0.01f;
        gObj.transform.localEulerAngles = angle;
        gObj.transform.localScale       = Vector3.one * 0.01f;

        MeshFilter   mf = gObj.AddComponent <MeshFilter>();
        MeshRenderer mr = gObj.AddComponent <MeshRenderer>();

        mf.mesh     = mesh;
        mr.material = material;

        //UnityMeshUtils.checkVertices(mesh);

        return(geo);
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        THREE.Geometry geometry;

        AddRenderObject(new THREE.SphereGeometry(75, 20, 10), material, new Vector3(-400, 0, 200));

        AddRenderObject(new THREE.IcosahedronGeometry(75, 1), material, new Vector3(-200, 0, 200));

        AddRenderObject(new THREE.OctahedronGeometry(75, 2), material, new Vector3(0, 0, 200));

        AddRenderObject(new THREE.TetrahedronGeometry(75, 0), material, new Vector3(200, 0, 200));

        AddRenderObject(new THREE.PlaneGeometry(100, 100, 4, 4), material, new Vector3(-400, 0, 0));

        geometry = AddRenderObject(new THREE.BoxGeometry(100, 100, 100, 4, 4, 4), material, new Vector3(-200, 0, 0));

        AddRenderObject(new THREE.CircleGeometry(50, 20, 0, Mathf.PI * 2), material, new Vector3(0, 0, 0));

        AddRenderObject(new THREE.RingGeometry(10, 50, 20, 5, 0, Mathf.PI * 2), material, new Vector3(200, 0, 0));

        AddRenderObject(new THREE.CylinderGeometry(25, 75, 100, 40, 5, false), material, new Vector3(400, 0, 0));

        //
        List <Vector3> points = new List <Vector3>();

        for (var i = 0; i < 50; i++)
        {
            points.Add(new Vector3(Mathf.Sin(i * 0.2f) * Mathf.Sin(i * 0.1f) * 15 + 50, 0, (i - 5) * 2));
        }
        AddRenderObject(new THREE.LatheGeometry(points, 20), material, new Vector3(-400, 0, -200));

        AddRenderObject(new THREE.TorusGeometry(50, 20, 20, 20), material, new Vector3(-200, 0, -200));

        AddRenderObject(new THREE.TorusKnotGeometry(50, 10, 50, 20), material, new Vector3(0, 0, -200));


        THREE.Line     lineMesh = new THREE.Line(new THREE.Geometry(), wireMaterial);
        THREE.Geometry geo      = geometry;
        for (int i = 0; i < geo.faces.Count; i++)
        {
            THREE.Face3 _face = geo.faces[i];
            List <int>  tri   = _face.GetTriangles();

            for (int n = 0; n < tri.Count; n++)
            {
                Vector3           normal = _face.vertexNormals[n];
                THREE.ArrowHelper arrow  = new THREE.ArrowHelper(normal, geo.vertices[tri[n]], 10, Color.green);
                lineMesh.Add(arrow);
            }
        }

        AddRenderLineObject(lineMesh.geo, wireMaterial, new Vector3(-200, 0, 0));
    }
示例#3
0
    THREE.Geometry AddRenderObject(THREE.Geometry geo, Material material, Vector3 position, float smooth = 0.0f)     // 60
    {
        UnityEngine.Mesh mesh = geo.GetMesh(smooth);

        GameObject gObj = new GameObject();

        gObj.transform.SetParent(this.transform);
        gObj.transform.localPosition = position;

        MeshFilter   mf = gObj.AddComponent <MeshFilter>();
        MeshRenderer mr = gObj.AddComponent <MeshRenderer>();

        mf.mesh     = mesh;
        mr.material = material;

        return(geo);
    }
示例#4
0
    THREE.Geometry AddRenderLineObject(THREE.Geometry geo, Material material, Vector3 position)
    {
        UnityEngine.Mesh mesh = geo.GetLineMesh();

        GameObject gObj = new GameObject();

        gObj.transform.SetParent(this.transform);
        gObj.transform.localPosition = position * 0.01f;
        gObj.transform.localScale    = Vector3.one * 0.01f;

        MeshFilter   mf = gObj.AddComponent <MeshFilter>();
        MeshRenderer mr = gObj.AddComponent <MeshRenderer>();

        mf.mesh     = mesh;
        mr.material = material;

        return(geo);
    }
    // Use this for initialization
    protected override void Init()
    {
        base.Init();

        THREE.Geometry boxGeo = new THREE.BoxGeometry(200, 200, 200, 2, 2, 2);
//		THREE.Mesh threeMesh = new THREE.Mesh( new THREE.BoxGeometry( 200, 200, 200, 2, 2, 2 ), material );
//		threeMesh.position = new Vector3( 0, 0, 0 );
//		//scene.Add( threeMesh );

        int subdivisions = 2;

        THREE.SubdivisionModifier modifier = new THREE.SubdivisionModifier(subdivisions);

        //THREE.Geometry smooth = threeMesh.geo;
        THREE.Geometry smooth = boxGeo;

        modifier.modify(smooth);


        THREE.MeshThreeJs subdivisionMesh = new THREE.MeshThreeJs(smooth, material);
        subdivisionMesh.position = new Vector3(0, 0, 0);

        scene.Add(subdivisionMesh);
    }
示例#6
0
 public static void explode(Geometry geometry) { }
示例#7
0
 public static void triangulateQuads(Geometry geometry) { }
示例#8
0
 public static void normalizeUVs(Geometry geometry) { }
示例#9
0
 public static Vector3 center(Geometry geometry) { return null; }
示例#10
0
 public static Geometry clone(Geometry geometry) { return null; }
示例#11
0
 public Mesh(Geometry geometry) { }
    // Use this for initialization
    protected override void Init()
    {
        base.Init();

        THREE.MeshThreeJs drawNormalMesh;

        THREE.MeshThreeJs threeMesh;
        threeMesh          = new THREE.MeshThreeJs(new THREE.SphereGeometry(75, 20, 10), material);
        threeMesh.position = new Vector3(-400, 0, 200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.IcosahedronGeometry(75, 1), material);
        threeMesh.position = new Vector3(-200, 0, 200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.OctahedronGeometry(75, 2), material);
        threeMesh.position = new Vector3(0, 0, 200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.TetrahedronGeometry(75, 0), material);
        threeMesh.position = new Vector3(200, 0, 200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.PlaneGeometry(100, 100, 4, 4), material);
        threeMesh.position = new Vector3(-400, 0, 0);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.BoxGeometry(100, 100, 100, 4, 4, 4), material);
        threeMesh.position = new Vector3(-200, 0, 0);
        scene.Add(threeMesh);

        drawNormalMesh = threeMesh;         // Draw Normal Mesh

        threeMesh          = new THREE.MeshThreeJs(new THREE.CircleGeometry(50, 20, 0, Mathf.PI * 2), material);
        threeMesh.position = new Vector3(0, 0, 0);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.RingGeometry(10, 50, 20, 5, 0, Mathf.PI * 2), material);
        threeMesh.position = new Vector3(200, 0, 0);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.CylinderGeometry(25, 75, 100, 40, 5, false), material);
        threeMesh.position = new Vector3(400, 0, 0);
        scene.Add(threeMesh);


        //
        List <Vector3> points = new List <Vector3>();

        for (var i = 0; i < 50; i++)
        {
            points.Add(new Vector3(Mathf.Sin(i * 0.2f) * Mathf.Sin(i * 0.1f) * 15 + 50, 0, (i - 5) * 2));
        }

        threeMesh          = new THREE.MeshThreeJs(new THREE.LatheGeometry(points, 20), material);
        threeMesh.position = new Vector3(-400, 0, -200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.TorusGeometry(50, 20, 20, 20), material);
        threeMesh.position = new Vector3(-200, 0, -200);
        scene.Add(threeMesh);

        threeMesh          = new THREE.MeshThreeJs(new THREE.TorusKnotGeometry(50, 10, 50, 20), material);
        threeMesh.position = new Vector3(0, 0, -200);
        scene.Add(threeMesh);

        /*
         * threeMesh = new THREE.AxisHelper( 50 );
         * threeMesh.position.set( 200, 0, -200 );
         * scene.Add( threeMesh );
         *
         * threeMesh = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50 );
         * threeMesh.position.set( 400, 0, -200 );
         * scene.Add( threeMesh );
         */

        THREE.Line lineMesh = new THREE.Line(new THREE.Geometry(), wireMaterial);
        lineMesh.position = drawNormalMesh.position;

        THREE.Geometry geo = drawNormalMesh.geo;
        for (int i = 0; i < geo.faces.Count; i++)
        {
            THREE.Face3 _face = geo.faces[i];
            int[]       tri   = _face.GetTriangles();

            for (int n = 0; n < tri.Length; n++)
            {
                Vector3           normal = _face.vertexNormals[n];
                THREE.ArrowHelper arrow  = new THREE.ArrowHelper(normal, geo.vertices[tri[n]], 10, Color.green);
                lineMesh.Add(arrow);
            }
        }

        scene.Add(lineMesh);
    }
示例#13
0
	        public UV[] generateSideWallUV(Geometry geometry, Shape extrudedShape, object wallContour, object extrudeOptions,JsNumber indexA, JsNumber indexB, JsNumber indexC, JsNumber indexD, object stepIndex, object stepsLength, object contourIndex1, object contourIndex2 ) 
            {
		        throw new NotImplementedException();
		    }
示例#14
0
	        public UV[] generateBottomUV(Geometry geometry, Shape extrudedShape, object extrudeOptions, JsNumber indexA, JsNumber indexB, JsNumber indexC ) 
            {
	            throw new NotImplementedException();
	        }
示例#15
0
 public ParticleSystem(Geometry geometry, Material material)
 {
 }
示例#16
0
 public static void tessellate(Geometry geometry, JsNumber maxEdgeLength) { }
示例#17
0
 public static void merge(Geometry geometry1, Mesh object2) { }
示例#18
0
 public Mesh(Geometry geometry, Material material) { }
示例#19
0
 public static Vector3 randomPointInFace(Face4 face, Geometry geometry, JsBoolean useCachedAreas) { return null; }
示例#20
0
 public static Vector3[] randomPointsInGeometry(Geometry geometry, JsNumber n) { return null; }
示例#21
0
    // Use this for initialization
    protected override void Init()
    {
        base.Init();

        // NURBS curve
        List <Vector4> nurbsControlPoints = new List <Vector4>();
        List <float>   nurbsKnots         = new List <float>();
        int            nurbsDegree        = 3;

        for (int i = 0; i <= nurbsDegree; i++)
        {
            nurbsKnots.Add(0);
        }

        for (int i = 0, j = 20; i < j; i++)
        {
            nurbsControlPoints.Add(
                new Vector4(
                    Random.value * 400 - 200,
                    Random.value * 400,
                    Random.value * 400 - 200,
                    1                     // weight of control point: higher means stronger attraction
                    )
                );

            float knot = (float)(i + 1) / (j - nurbsDegree);
            nurbsKnots.Add(Mathf.Clamp(knot, 0, 1));
        }

        THREE.NURBSCurve nurbsCurve    = new THREE.NURBSCurve(nurbsDegree, nurbsKnots.ToArray(), nurbsControlPoints.ToArray());
        THREE.Geometry   nurbsGeometry = new THREE.Geometry();
        List <Vector3>   pts           = nurbsCurve.getPoints(200);

        nurbsGeometry.vertices = pts;

        THREE.Line nurbsLine = new THREE.Line(nurbsGeometry, wireMaterial);
        nurbsLine.position = Vector3.zero;
        scene.Add(nurbsLine);

        // controlPoints
        THREE.Geometry nurbsControlPointsGeometry = new THREE.Geometry();
        nurbsControlPointsGeometry.vertices = new List <Vector3>(nurbsCurve.getVec3ControlPoints());

        THREE.Line nurbsControlPointsLine = new THREE.Line(nurbsControlPointsGeometry, wireMaterial);
        nurbsControlPointsLine.position = nurbsLine.position;
        scene.Add(nurbsControlPointsLine);


        // NURBS surface

        Vector4[][] nsControlPoints = new Vector4[][] {
            new Vector4[] {
                new Vector4(-200, -200, 100, 1),
                new Vector4(-200, -100, -200, 1),
                new Vector4(-200, 100, 250, 1),
                new Vector4(-200, 200, -100, 1)
            },
            new Vector4[] {
                new Vector4(0, -200, 0, 1),
                new Vector4(0, -100, -100, 5),
                new Vector4(0, 100, 150, 5),
                new Vector4(0, 200, 0, 1)
            },
            new Vector4[] {
                new Vector4(200, -200, -100, 1),
                new Vector4(200, -100, 200, 1),
                new Vector4(200, 100, -250, 1),
                new Vector4(200, 200, 100, 1)
            }
        };

        int degree1 = 2;
        int degree2 = 3;

        float[] knots1 = new float[] { 0, 0, 0, 1, 1, 1 };
        float[] knots2 = new float[] { 0, 0, 0, 0, 1, 1, 1, 1 };
        nurbsSurface = new THREE.NURBSSurface(degree1, degree2, knots1, knots2, nsControlPoints);

        THREE.ParametricGeometry geometry = new THREE.ParametricGeometry(getSurfacePoint, 20, 20);
        THREE.MeshThreeJs        mesh     = new THREE.MeshThreeJs(geometry, material);
        mesh.position = new Vector3(0, 0, 0);
        scene.Add(mesh);


        t_nsControlPoints = nsControlPoints;
    }
示例#22
0
    // Use this for initialization
    protected override void Init()
    {
        base.Init();

        closedSpline = new THREE.ClosedSplineCurve3(new List <Vector3>(new Vector3[] {
            new Vector3(-60, -100, 60),
            new Vector3(-60, 20, 60),
            new Vector3(-60, 120, 60),
            new Vector3(60, 20, -60),
            new Vector3(60, -100, -60)
        }));

        THREE.ExtrudeGeometry.Option extrudeSettings = new THREE.ExtrudeGeometry.Option();
        extrudeSettings.steps        = 100;
        extrudeSettings.bevelEnabled = false;
        extrudeSettings.extrudePath  = closedSpline;

        pts = new List <Vector2>();
        int count = 3;

        for (int i = 0; i < count; i++)
        {
            float l = 20;
            float a = 2 * (float)i / count * Mathf.PI;
            pts.Add(new Vector2(Mathf.Cos(a) * l, Mathf.Sin(a) * l));
        }

        THREE.Shape shape = new THREE.Shape(pts);


        THREE.MeshThreeJs threeMesh;

        testGeometry = new THREE.ExtrudeGeometry(new List <THREE.Shape>(new THREE.Shape[] { shape }), extrudeSettings);
        //THREE.ShapeGeometry.Option op0 = new THREE.ShapeGeometry.Option();
        //op0.curveSegments = 12;
        //THREE.Geometry geometry = new THREE.ShapeGeometry(new List<Shape>( new Shape[]{shape} ), op0);
        threeMesh = new THREE.MeshThreeJs(testGeometry, material);
        scene.Add(threeMesh);

        /////
        List <Vector3> randomPoints = new List <Vector3>();

        for (int i = 0; i < 10; i++)
        {
            randomPoints.Add(new Vector3((i - 4.5f) * 50, Random.Range(-50.0f, 50.0f), Random.Range(-50.0f, 50.0f)));
        }

        SplineCurve3 randomSpline = new SplineCurve3(randomPoints);

        THREE.ExtrudeGeometry.Option extrude0Settings = new THREE.ExtrudeGeometry.Option();
        extrude0Settings.steps        = 200;
        extrude0Settings.bevelEnabled = false;
        extrude0Settings.extrudePath  = randomSpline;


//		List<Vector2> pts0 = new List<Vector2>();
//		int numPts = 5;
//
//		for ( int i = 0; i < numPts * 2; i ++ ) {
//			int l = i % 2 == 1 ? 10 : 20;
//			float a = (float)i / numPts * Mathf.PI;
//			pts0.Add( new Vector2 ( Mathf.Cos( a ) * l, Mathf.Sin( a ) * l ) );
//		}
//
//		Shape shape0 = new Shape( pts0 );


        // star path
        List <Vector2> pts0     = new List <Vector2>();
        List <Vector2> normals0 = new List <Vector2>();
        int            numPts   = 5;

        for (int i = 0; i < numPts * 2; i++)
        {
            int   l = i % 2 == 1 ? 10 : 20;
            float a = (float)i / numPts * Mathf.PI;
            pts0.Add(new Vector2(Mathf.Cos(a) * l, Mathf.Sin(a) * l));
        }
        for (int i = 0; i < pts0.Count; i++)
        {
            int     endI = (i == pts0.Count - 1) ? 0 : i + 1;
            Vector2 vec  = pts0[endI] - pts0[i];
            vec.Normalize();
            normals0.Add(new Vector2(vec.y, -vec.x));
        }

        THREE.Shape shape0 = new Shape(pts0, normals0);

        testGeometry = new THREE.ExtrudeGeometry(new List <Shape>(new Shape[] { shape0 }), extrude0Settings);
        threeMesh    = new THREE.MeshThreeJs(testGeometry, material);
        scene.Add(threeMesh);

        ////////////
        THREE.ExtrudeGeometry.Option extrude1Settings = new THREE.ExtrudeGeometry.Option();
        extrude1Settings.amount         = 20;
        extrude1Settings.steps          = 1;
        extrude1Settings.bevelEnabled   = false;
        extrude1Settings.bevelThickness = 2;
        extrude1Settings.bevelSize      = 4;
        extrude1Settings.bevelSegments  = 1;

        testGeometry       = new THREE.ExtrudeGeometry(new List <Shape>(new Shape[] { shape0 }), extrude1Settings);
        threeMesh          = new THREE.MeshThreeJs(testGeometry, material);
        threeMesh.position = new Vector3(50, 100, 50);
        scene.Add(threeMesh);

        //
        // Sphere
//		threeMesh = new THREE.Mesh( new THREE.SphereGeometry( 75, 20, 10 ), material );
//		threeMesh.position = new Vector3( -400, 0, 200 );
//		scene.Add( threeMesh );

//		//
//		Shape shapeTri = new Shape();
//		shapeTri.moveTo(  0, 100 );
//		shapeTri.lineTo(  100, -50 );
//		shapeTri.lineTo( -100, -50 );
//		shapeTri.lineTo(  0, 100 );
//
//		THREE.ShapeGeometry.Option op = new THREE.ShapeGeometry.Option();
//		op.curveSegments = 12;
//		THREE.Geometry geometryShape = new THREE.ShapeGeometry(new List<Shape>( new Shape[]{shapeTri} ), op);
//		threeMesh = new THREE.Mesh( geometryShape, material);
//		scene.Add( threeMesh );
    }