• 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 /
This question was closed Dec 10, 2013 at 10:16 PM by Graham-Dunnett for the following reason:

Question is off-topic or not relevant - and not asking a question

avatar image
0
Question by jaijai76 · Dec 10, 2013 at 10:13 PM · c#javascriptconvert

convert some c# to javascript please

please can somebody convert t$$anonymous$$s c# to javascript so i can make some major ajustments

using UnityEngine; using System.Collections;

public class GenerateTerrain : MonoBehaviour { public Material m_material; GameObject m_mesh;

 VoxelChunk[,,] m_voxelChunk;
 
 public int m_surfaceSeed = 4, m_caveSeed = 6;
 public int m_chunksX = 6, m_chunksY = 2, m_chunksZ = 6;
 public int m_voxelWidth = 32, m_voxelHeight = 32, m_voxelLength = 32;
 public int m_chunksAbove0 = 1;
 public float m_surfaceLevel = 0.0f;

 void Start () 
 {
     //Make 2 perlin noise objects, one is used for the surface and the other for the caves
     PerlinNoise m_surfacePerlin = new PerlinNoise(m_surfaceSeed);
     PerlinNoise  m_cavePerlin = new PerlinNoise(m_caveSeed);
 
     //Set some varibles for the marc$$anonymous$$ng cubes plugin
     Marc$$anonymous$$ngCubes.SetTarget(0.0f);
     Marc$$anonymous$$ngCubes.SetWindingOrder(2, 1, 0);
     Marc$$anonymous$$ngCubes.SetModeToCubes();
     
     //create a array to hold the voxel chunks
     m_voxelChunk  = new VoxelChunk[m_chunksX,m_chunksY,m_chunksZ];
     
     //The offset is used to centre the terrain on the x and z axis. For the Y axis
     //you can have a certain amount of chunks above the y=0 and the rest will be below
     Vector3 offset = new Vector3(m_chunksX*m_voxelWidth*-0.5f, -(m_chunksY-m_chunksAbove0)*m_voxelHeight, m_chunksZ*m_voxelLength*-0.5f);
     
     for(int x = 0; x < m_chunksX; x++)
     {
         for(int y = 0; y < m_chunksY; y++)
         {
             for(int z = 0; z < m_chunksZ; z++)
             {
                 //The position of the voxel chunk
                 Vector3 pos = new Vector3(x*m_voxelWidth, y*m_voxelHeight, z*m_voxelLength);
                 //Create the voxel object
                 m_voxelChunk[x,y,z] = new VoxelChunk(pos+offset, m_voxelWidth, m_voxelHeight, m_voxelLength, m_surfaceLevel);
                 //Create the voxel data
                 m_voxelChunk[x,y,z].CreateVoxels(m_surfacePerlin, m_cavePerlin);
                 //Smooth the voxels, is optional but I t$$anonymous$$nk it looks nicer
                 m_voxelChunk[x,y,z].SmoothVoxels();
                 //Create the normals. T$$anonymous$$s will create smoothed normal.
                 //T$$anonymous$$s is optional and if not called the unsmoothed mesh normals will be used
                 m_voxelChunk[x,y,z].CalculateNormals();
                 //Creates the mesh form voxel data using the marc$$anonymous$$ng cubes plugin and creates the mesh collider
                 m_voxelChunk[x,y,z].CreateMesh(m_material);
                 
             }
         }
     }
     
 }    
 

}

Comment
Comments Locked
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

0 Replies

  • Sort: 

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

convert c# to JavaScript Problem 0 Answers

C# to UnityScript conversion help. 0 Answers

How to make a JavaScript a C# script 1 Answer

help with creating a static Instance in javascript 2 Answers

Multiple Cars not working 1 Answer


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