Rendering with cubes/planes/matrices

 0 Say I have a 3x3x3 cube (so 27 cubes) floating, what would the best way to go at this, memory-saving wise. Would rendering only the visible cubes (in this case.. all but 1, but in others, could be many) help save memory, and how would 1 do that. Also, would it be possible to only render the visible plain of the cube, instead of all 6 sides all the time? Because a 3x3x3 cube would have 162 cube sides, but would only have 54 visible. And if the answer, as I've run across this a few times, resides in a mesh, please link me or explain how to do that as well. Thanks Koder more ▼ asked Apr 10 '11 at 07:20 PM Koder 60 ● 6 ● 6 ● 15 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 0 I've got a problem, not yet assimilated how to make the UVs of a cube here is the code can someone help me?using UnityEngine; using System.Collections;[RequireComponent (typeof (MeshCollider))] [RequireComponent (typeof (MeshFilter))] [RequireComponent (typeof (MeshRenderer))]public class Create_Cube : MonoBehaviour {public Color ColorBloc; public Texture2D Textura;// Use this for initialization void Start () {Mesh mesh = new Mesh (); mesh=GetComponent().mesh; Vector3 p0 = new Vector3(0,0,0); Vector3 p1 = new Vector3(1,0,0); Vector3 p2 = new Vector3(0,1,0); Vector3 p3 = new Vector3(0,0,1); Vector3 p4 = new Vector3(1,0,1); Vector3 p5 = new Vector3(1,1,0); Vector3 p6 = new Vector3(0,1,1); Vector3 p7 = new Vector3(1,1,1);mesh.vertices = new Vector3[]{p0,p1,p2,p3,p4,p5,p6,p7}; mesh.triangles = new int[]{ 0,2,1, 1,2,5, //face 1 3,0,1, 1,4,3, //face 2 0,3,2, 2,3,6, //face 3 1,5,4, 5,7,4, //face 4 6,3,4, 6,4,7, //face 5 6,5,2, 7,5,6 //face 6 };//mesh.uv = new Vector2[]{new Vector2(0.0f,0.0f),new Vector2(1.0f,0.0f),new Vector2(0.0f,1.0f),new Vector2(0.0f,0.0f),new Vector2(1.0f,0.0f),new Vector2(1.0f,1.0f),new Vector2(0.0f,1.0f),new Vector2(1.0f,1.0f)};mesh.uv = new Vector2[]{ new Vector2(0,0), new Vector2(0,1), `````` new Vector2(1,0),new Vector2(0,1), new Vector2(1,1), new Vector2(0,0), new Vector2(0,0), new Vector2(1,0) }; ``````renderer.material = new Material(Shader.Find("Diffuse")); renderer.material.mainTexture = Textura; renderer.material.color = ColorBloc;mesh.RecalculateNormals(); mesh.RecalculateBounds (); mesh.Optimize();} // Update is called once per frame void Update () {} } more ▼ answered Jul 31 '12 at 10:43 PM add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x1357
x333
x58
x1

asked: Apr 10 '11 at 07:20 PM

Seen: 1459 times

Last Updated: Jul 31 '12 at 10:43 PM