// Use this for initialization protected override void Init() { base.Init(); // Smiley var smileyShape = new THREE.Shape(); smileyShape.moveTo(80, 40); smileyShape.absarc(40, 40, 40, 0, Mathf.PI * 2, false); var smileyEye1Path = new THREE.Path(); smileyEye1Path.moveTo(35, 20); // smileyEye1Path.absarc( 25, 20, 10, 0, Mathf.PI*2, true ); smileyEye1Path.absellipse(25, 20, 10, 10, 0, Mathf.PI * 2, true); smileyShape.holes.Add(smileyEye1Path); var smileyEye2Path = new THREE.Path(); smileyEye2Path.moveTo(65, 20); smileyEye2Path.absarc(55, 20, 10, 0, Mathf.PI * 2, true); smileyShape.holes.Add(smileyEye2Path); var smileyMouthPath = new THREE.Path(); // ugly box mouth // smileyMouthPath.moveTo( 20, 40 ); // smileyMouthPath.lineTo( 60, 40 ); // smileyMouthPath.lineTo( 60, 60 ); // smileyMouthPath.lineTo( 20, 60 ); // smileyMouthPath.lineTo( 20, 40 ); smileyMouthPath.moveTo(20, 40); smileyMouthPath.quadraticCurveTo(40, 60, 60, 40); smileyMouthPath.bezierCurveTo(70, 45, 70, 50, 60, 60); smileyMouthPath.quadraticCurveTo(40, 80, 20, 60); smileyMouthPath.quadraticCurveTo(5, 50, 20, 40); smileyShape.holes.Add(smileyMouthPath); // Shape arcShape = new Shape(); // arcShape.moveTo( 20, 10 ); // arcShape.absarc( 10, 10, 10, 0, Mathf.PI*2, false ); THREE.ExtrudeGeometry.Option extrudeSettings = new THREE.ExtrudeGeometry.Option(); //extrudeSettings.steps = 100; //extrudeSettings.bevelEnabled = false; extrudeSettings.amount = 20; extrudeSettings.curveSegments = 3; extrudeSettings.bevelEnabled = true; extrudeSettings.bevelSegments = 2; extrudeSettings.steps = 1; addShape(smileyShape, extrudeSettings, -200, 250, 0, 0, 0, Mathf.PI, 1); }
// Use this for initialization void Start() { List <Vector3> vertices = new List <Vector3>(); List <Vector3> normals = new List <Vector3>(); List <Vector2> uvs = new List <Vector2>(); float meshSmooth = 60; THREE.Geometry testGeometry; THREE.ClosedSplineCurve3 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; List <Vector2> 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); testGeometry = new THREE.ExtrudeGeometry(new List <THREE.Shape>(new THREE.Shape[] { shape }), extrudeSettings); //testGeometry.computeVertexNormals(); UnityEngine.Mesh mesh0 = testGeometry.GetMesh(meshSmooth); vertices.AddRange(mesh0.vertices); normals.AddRange(mesh0.normals); uvs.AddRange(mesh0.uv); // 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); testGeometry = new THREE.ExtrudeGeometry(new List <Shape>(new Shape[] { shape0 }), extrude0Settings); UnityEngine.Mesh mesh1 = testGeometry.GetMesh(meshSmooth); vertices.AddRange(mesh1.vertices); normals.AddRange(mesh1.normals); uvs.AddRange(mesh1.uv); // // 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); UnityEngine.Mesh mesh2 = testGeometry.GetMesh(meshSmooth); vertices.AddRange(mesh2.vertices); normals.AddRange(mesh2.normals); uvs.AddRange(mesh2.uv); // unity submesh MeshRenderer mr = this.gameObject.AddComponent <MeshRenderer>(); MeshFilter mf = this.gameObject.AddComponent <MeshFilter>(); UnityEngine.Mesh mesh = new UnityEngine.Mesh(); mesh.vertices = vertices.ToArray(); mesh.normals = normals.ToArray(); mesh.uv = uvs.ToArray(); mesh.subMeshCount = 3; mesh.SetTriangles(mesh0.triangles, 0); int offsetIndex1 = mesh0.vertexCount; int[] orgTris = mesh1.triangles; int[] tris = new int[orgTris.Length]; for (int j = 0; j < tris.Length; j++) { tris[j] = orgTris[j] + offsetIndex1; } mesh.SetTriangles(tris, 1); int offsetIndex2 = offsetIndex1 + mesh1.vertexCount; int[] orgTris2 = mesh2.triangles; int[] tris2 = new int[orgTris2.Length]; for (int j = 0; j < tris2.Length; j++) { tris2[j] = orgTris2[j] + offsetIndex2; } mesh.SetTriangles(tris2, 2); //mesh.RecalculateNormals(); mf.mesh = mesh; mr.materials = materials; }
public ShapeGeometry(Shape[] shapes, ShapeGeometryOptions options) { }
public ShapeGeometry addShapeList(Shape[] shapes, ShapeGeometryOptions options) { return null; }
public void addShape(Shape shape, ShapeGeometryOptions options){}
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(); }
public UV[] generateBottomUV(Geometry geometry, Shape extrudedShape, object extrudeOptions, JsNumber indexA, JsNumber indexB, JsNumber indexC ) { throw new NotImplementedException(); }
// Use this for initialization protected override void Init() { base.Init(); List <int> ary = new List <int> (new int[] { 0, 1, 2, 3, 4, 5, 6 }); result = ary.GetRange(2, ary.Count - 2); // Triangle var triangleShape = new THREE.Shape(); triangleShape.moveTo(80, 20); triangleShape.lineTo(40, 80); triangleShape.lineTo(120, 80); triangleShape.lineTo(80, 20); // close path // Square float sqLength = 80; THREE.Shape squareShape = new THREE.Shape(); squareShape.moveTo(0, 0); squareShape.lineTo(0, sqLength); squareShape.lineTo(sqLength, sqLength); squareShape.lineTo(sqLength, 0); squareShape.lineTo(0, 0); // Rectangle float rectLength = 120, rectWidth = 40; THREE.Shape rectShape = new THREE.Shape(); rectShape.moveTo(0, 0); rectShape.lineTo(0, rectWidth); rectShape.lineTo(rectLength, rectWidth); rectShape.lineTo(rectLength, 0); rectShape.lineTo(0, 0); // Rounded rectangle var roundedRectShape = new THREE.Shape(); float x = 0; float y = 0; float width = 50; float height = 50; float radius = 20; roundedRectShape.moveTo(x, y + radius); roundedRectShape.lineTo(x, y + height - radius); roundedRectShape.quadraticCurveTo(x, y + height, x + radius, y + height); roundedRectShape.lineTo(x + width - radius, y + height); roundedRectShape.quadraticCurveTo(x + width, y + height, x + width, y + height - radius); roundedRectShape.lineTo(x + width, y + radius); roundedRectShape.quadraticCurveTo(x + width, y, x + width - radius, y); roundedRectShape.lineTo(x + radius, y); roundedRectShape.quadraticCurveTo(x, y, x, y + radius); // Heart x = 0; y = 0; Shape heartShape = new Shape(); // From http://blog.burlock.org/html5/130-paths heartShape.moveTo(x + 25, y + 25); heartShape.bezierCurveTo(x + 25, y + 25, x + 20, y, x, y); heartShape.bezierCurveTo(x - 30, y, x - 30, y + 35, x - 30, y + 35); heartShape.bezierCurveTo(x - 30, y + 55, x - 10, y + 77, x + 25, y + 95); heartShape.bezierCurveTo(x + 60, y + 77, x + 80, y + 55, x + 80, y + 35); heartShape.bezierCurveTo(x + 80, y + 35, x + 80, y, x + 50, y); heartShape.bezierCurveTo(x + 35, y, x + 25, y + 25, x + 25, y + 25); // Circle float circleRadius = 40; var circleShape = new THREE.Shape(); circleShape.moveTo(0, circleRadius); circleShape.quadraticCurveTo(circleRadius, circleRadius, circleRadius, 0); circleShape.quadraticCurveTo(circleRadius, -circleRadius, 0, -circleRadius); circleShape.quadraticCurveTo(-circleRadius, -circleRadius, -circleRadius, 0); circleShape.quadraticCurveTo(-circleRadius, circleRadius, 0, circleRadius); // Fish x = y = 0; Shape fishShape = new Shape(); fishShape.moveTo(x, y); fishShape.quadraticCurveTo(x + 50, y - 80, x + 90, y - 10); fishShape.quadraticCurveTo(x + 100, y - 10, x + 115, y - 40); fishShape.quadraticCurveTo(x + 115, y, x + 115, y + 40); fishShape.quadraticCurveTo(x + 100, y + 10, x + 90, y + 10); fishShape.quadraticCurveTo(x + 50, y + 80, x, y); // // Arc circle Shape arcShape = new Shape(); arcShape.moveTo(50, 10); arcShape.absarc(10, 10, 40, 0, Mathf.PI * 2.0f, false); Path holePath = new Path(); holePath.moveTo(20, 10); holePath.absarc(10, 10, 10, 0, Mathf.PI * 2.0f, true); arcShape.holes.Add(holePath); // Smiley var smileyShape = new THREE.Shape(); smileyShape.moveTo(80, 40); smileyShape.absarc(40, 40, 40, 0, Mathf.PI * 2, false); var smileyEye1Path = new THREE.Path(); smileyEye1Path.moveTo(35, 20); // smileyEye1Path.absarc( 25, 20, 10, 0, Math.PI*2, true ); smileyEye1Path.absellipse(25, 20, 10, 10, 0, Mathf.PI * 2, true); smileyShape.holes.Add(smileyEye1Path); var smileyEye2Path = new THREE.Path(); smileyEye2Path.moveTo(65, 20); smileyEye2Path.absarc(55, 20, 10, 0, Mathf.PI * 2, true); smileyShape.holes.Add(smileyEye2Path); var smileyMouthPath = new THREE.Path(); // ugly box mouth // smileyMouthPath.moveTo( 20, 40 ); // smileyMouthPath.lineTo( 60, 40 ); // smileyMouthPath.lineTo( 60, 60 ); // smileyMouthPath.lineTo( 20, 60 ); // smileyMouthPath.lineTo( 20, 40 ); smileyMouthPath.moveTo(20, 40); smileyMouthPath.quadraticCurveTo(40, 60, 60, 40); smileyMouthPath.bezierCurveTo(70, 45, 70, 50, 60, 60); smileyMouthPath.quadraticCurveTo(40, 80, 20, 60); smileyMouthPath.quadraticCurveTo(5, 50, 20, 40); smileyShape.holes.Add(smileyMouthPath); // Shape arcShape = new Shape(); // arcShape.moveTo( 20, 10 ); // arcShape.absarc( 10, 10, 10, 0, Mathf.PI*2, false ); THREE.ExtrudeGeometry.Option extrudeSettings = new THREE.ExtrudeGeometry.Option(); //extrudeSettings.steps = 100; //extrudeSettings.bevelEnabled = false; extrudeSettings.amount = 20; extrudeSettings.curveSegments = 12; extrudeSettings.bevelEnabled = true; extrudeSettings.bevelSegments = 2; extrudeSettings.steps = 1; addShape(triangleShape, extrudeSettings, -180, 0, 0, 0, 0, 0, 1); addShape(roundedRectShape, extrudeSettings, -150, 150, 0, 0, 0, 0, 1); //addShape( rectShape, extrudeSettings, -150, 150, 0, 0, 0, 0, 1 ); addShape(squareShape, extrudeSettings, 150, 100, 0, 0, 0, 0, 1); addShape(heartShape, extrudeSettings, 60, 100, 0, 0, 0, Mathf.PI, 1); addShape(circleShape, extrudeSettings, 120, 250, 0, 0, 0, 0, 1); addShape(fishShape, extrudeSettings, -60, 200, 0, 0, 0, 0, 1); addShape(smileyShape, extrudeSettings, -200, 250, 0, 0, 0, Mathf.PI, 1); addShape(arcShape, extrudeSettings, 150, 0, 0, 0, 0, 0, 1); }
// Use this for initialization void Start() { THREE.Geometry testGeometry; // --------------- // closed path 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.SplineCurve3 closedSpline = new THREE.SplineCurve3( new List<Vector3>(new Vector3[]{ // new Vector3( 0, 0, 0 ), // new Vector3( 150, 0, 0 ), // new Vector3( 0, 150, 0 ), // })); extrudeSettings = new THREE.ExtrudeGeometry.Option(); extrudeSettings.steps = 30; // 30, 100 extrudeSettings.bevelEnabled = false; extrudeSettings.extrudePath = closedSpline; extrudeSettings.curveSegments = 4; List <Vector2> pts = new List <Vector2>(); List <Vector2> normals = new List <Vector2>(); int count = 7; float normOffset = Mathf.PI / count; for (int i = 0; i < count; i++) { float l = 20; float a = (float)i / count * Mathf.PI * 2; pts.Add(new Vector2(Mathf.Cos(a) * l, Mathf.Sin(a) * l)); normals.Add(new Vector2(Mathf.Cos(a + normOffset), Mathf.Sin(a + normOffset))); } THREE.Shape shape = new THREE.Shape(pts, normals); THREE.ShapeGeometry.Option op = new THREE.ShapeGeometry.Option(); op.curveSegments = 12; // test THREE.Geometry shapeGeo; shapeGeo = new THREE.ShapeGeometry(shape, op); AddRenderObject(shapeGeo, materials[0], Vector3.zero); // // Fish // THREE.Shape fishShape = new THREE.Shape (); // fishShape.moveTo (0, 0); // fishShape.quadraticCurveTo (50, 80, 90, 10); // fishShape.quadraticCurveTo (100, 10, 115, 40); // fishShape.quadraticCurveTo (115, 0, 115, 40); // fishShape.quadraticCurveTo (100, 10, 90, 10); // fishShape.quadraticCurveTo (50, 80, 0, 0); testGeometry = new THREE.ExtrudeGeometry(new List <THREE.Shape>(new THREE.Shape[] { shape }), extrudeSettings); //testGeometry.computeVertexNormals(); //THREE.ShapeGeometry.Option op0 = new THREE.ShapeGeometry.Option(); //op0.curveSegments = 12; //THREE.Geometry geometry = new THREE.ShapeGeometry(new List<Shape>( new Shape[]{shape} ), op0); AddRenderObject(testGeometry, materials[0], Vector3.zero); // random path 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 ) ) ); randomPoints.Add(new Vector3((i) * 50, Random.Range(-50.0f, 50.0f), Random.Range(-50.0f, 50.0f))); //randomPoints.Add( new Vector3( i * 50, i, i*2 ) ); } // for ( int i = 0; i < 3; i ++ ) { // randomPoints.Add( new Vector3( 0, i * 30, i * 40 ) ); // } randomSpline = new SplineCurve3(randomPoints); extrude0Settings = new THREE.ExtrudeGeometry.Option(); extrude0Settings.steps = 80; // 80 extrude0Settings.bevelEnabled = false; extrude0Settings.extrudePath = randomSpline; // star path List <Vector2> pts0 = new List <Vector2>(); List <Vector2> normals0 = new List <Vector2>(); int numPts = 5; // normOffset = Mathf.PI / numPts + Mathf.PI / 2.0f; // 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 ) ); // // normals0.Add( new Vector2 ( Mathf.Cos( a + normOffset ), Mathf.Sin( a + normOffset ) ) ); // } 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)); } Shape startShape = new Shape(pts0, normals0); testGeometry = new THREE.ExtrudeGeometry(new List <Shape>(new Shape[] { startShape }), extrude0Settings); //testGeometry.computeVertexNormals(); AddRenderObject(testGeometry, materials[1], Vector3.zero); // star Extrude THREE.ExtrudeGeometry.Option extrude1Settings = new THREE.ExtrudeGeometry.Option(); extrude1Settings.amount = 20; extrude1Settings.steps = 2; extrude1Settings.bevelEnabled = true; extrude1Settings.bevelThickness = 2; extrude1Settings.bevelSize = 1; extrude1Settings.bevelSegments = 1; testGeometry = new THREE.ExtrudeGeometry(new List <Shape>(new Shape[] { startShape }), extrude1Settings); AddRenderObject(testGeometry, materials[2], new Vector3(50, 100, 50), 0.0f); // test THREE.Geometry startShapeGeo; startShapeGeo = new THREE.ShapeGeometry(startShape, op); AddRenderObject(startShapeGeo, materials[0], Vector3.zero); }
// 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 ); }