Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by iamthecoolguy11 · Sep 28, 2014 at 05:26 PM · javascripttexturemeshvoxel

How do I texture this voxel cube?

I am still trying to understand voxel programming and just starting to understand it. Right now I have it so it generates a cube. I decided I would try to get it to generate a texture on the cube but looking at other peoples code I didn't understand it enough to put it in the script. So if you could put it in and explain a little I would like that:). This is the texture I am using for now

alt text

this is the script so far

 var newVertices : Vector3[];
 var newUV : Vector2[];
 var newTriangles : int[];
 var material : Texture2D;
  
 function Start () {
 var mesh : Mesh = new Mesh ();
 GetComponent(MeshFilter).mesh = mesh;
 mesh.Clear();
 
 var p1 = Vector3(0,0,0);
 var p2 = Vector3(1,0,0);
 var p3 = Vector3(0,1,0);
 var p4 = Vector3(0,0,1);
 var p5 = Vector3(1,0,1);
 var p6 = Vector3(1,1,0);
 var p7 = Vector3(0,1,1);
 var p8 = Vector3(1,1,1);
  
 newVertices = new Array (p1,p2,p3,p4,p5,p6,p7,p8);
  
 newTriangles = [0,2,1, 1,2,5, 3,0,1, 1,4,3, 0,3,2, 2,3,6, 1,5,4, 5,7,4, 6,3,4, 6,4,7, 6,5,2, 7,5,6];
  
 mesh.vertices = newVertices;
 mesh.triangles = newTriangles;
 mesh.uv = newUV;
 
 
 
 mesh.RecalculateNormals();  
 mesh.RecalculateBounds();  
 mesh.Optimize(); 
 
 }

what this dose

alt text

image.png (113.0 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Cherno · Sep 28, 2014 at 06:54 PM

Take a look at this tutorial, it includes code for UVs:

http://unitycoder.com/blog/2012/02/15/dummy-craft-chunk-renderer-js/

You just imagine each face of the cube as lying on a 2-dimensional plane, and then you just give each vertice you defined a xy coordinate on this plane from 0 to 1. I would suggest using lists for vertices, triangles and uvs so you can just add new elements on the fly instead of having to deicde the array sizes beforehand.

If you want to learn more, take a look at this thread:

http://forum.unity3d.com/threads/after-playing-minecraft.63149/

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image iamthecoolguy11 · Sep 28, 2014 at 07:02 PM 0
Share

Thanks I well look at this a bit

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to assign texture to a specific mesh in a chunk for a minecraft game? 1 Answer

Dynamic Runtime Decals 0 Answers

Render voxels with RGB data passed to them 1 Answer

Save a procedurally generated mesh and load it after? 0 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges