The road of Unity3d cultivation: drawing a cube with mesh

Source: Internet
Author: User

#pragma strictfunction awake () {var pmeshfilter:meshfilter = gameobject.addcomponent (typeof (Meshfilter)) as Meshfilter ;//Grid filter var pmeshrender:meshrenderer = Gameobject.addcomponent (typeof (Meshrenderer)) as meshrenderer;//grid rendering Var Pmesh : Mesh = Pmeshfilter.mesh as mesh;//the instanced mesh//u3d in the grid filter are drawn in the triangle drawing method, clockwise, so first record all the points and then in the order of determining the triangle draw var Pvector:vector3 [ ] = new VECTOR3[36]; var ptriangles:int [] = new int[pvector.length];//forwordpvector[0] = new Vector3 (0.0f,0.0f,0.0f);p vector[1] = new Vecto R3 (0.0f,1.0f,0.0f);p vector[2] = new Vector3 (1.0f,0.0f,0.0f);p vector[3] = new Vector3 (1.0f,0.0f,0.0f);p vector[4] = new Vector3 (0.0f,1.0f,0.0f);p vector[5] = new Vector3 (1.0f,1.0f,0.0f);//backpvector[6] = new Vector3 (0.0f,0.0f,1.0f); PVECTOR[7] = new Vector3 (0.0f,1.0f,1.0f);p vector[8] = new Vector3 (1.0f,0.0f,1.0f);p vector[9] = new Vector3 (1.0f,0.0f, 1.0f);p vector[10] = new Vector3 (0.0f,1.0f,1.0f);p vector[11] = new Vector3 (1.0f,1.0f,1.0f);//leftpvector[12] = new Vector3 (0.0f,0.0f,0.0f);p vector[13] = nEW Vector3 (0.0f,0.0f,1.0f);p vector[14] = new Vector3 (0.0f,1.0f,1.0f);p vector[15] = new Vector3 (0.0f,1.0f,1.0f); PVECTOR[16] = new Vector3 (0.0f,1.0f,0.0f);p vector[17] = new Vector3 (0.0f,0.0f,0.0f);//rightpvector[18] = new Vector3 ( 1.0f,0.0f,0.0f);p vector[19] = new Vector3 (1.0f,0.0f,1.0f);p vector[20] = new Vector3 (1.0f,1.0f,0.0f);p vector[21] = new Vector3 (1.0f,1.0f,0.0f);p vector[22] = new Vector3 (1.0f,0.0f,1.0f);p vector[23] = new Vector3 (1.0f,1.0f,1.0f);// UPPVECTOR[24] = new Vector3 (0.0f,1.0f,0.0f);p vector[25] = new Vector3 (0.0f,1.0f,1.0f);p vector[26] = new Vector3 (1.0f, 1.0f,0.0f);p vector[27] = new Vector3 (1.0f,1.0f,0.0f);p vector[28] = new Vector3 (0.0f,1.0f,1.0f);p vector[29] = new Vector3 (1.0f,1.0f,1.0f);//downpvector[30] = new Vector3 (0.0f,0.0f,0.0f);p vector[31] = new Vector3 (0.0f,0.0f,1.0f); PVECTOR[32] = new Vector3 (1.0f,0.0f,0.0f);p vector[33] = new Vector3 (1.0f,0.0f,0.0f);p vector[34] = new Vector3 (0.0f,0.0f , 1.0f);p vector[35] = new Vector3 (1.0f,0.0f,1.0f); for (var nindex:int = 0; nIndex < Ptriangles.length;++nindex) {Ptriangles[nindex] =nindex;} Pmesh.clear ();p mesh.vertices = pvector;//mesh Vertex pmesh.triangles = ptriangles;//triangle Pmesh.recalculatebounds ();}

The road of Unity3d cultivation: drawing a cube with mesh

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.