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 /
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 this 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 marching cubes plugin
     MarchingCubes.SetTarget(0.0f);
     MarchingCubes.SetWindingOrder(2, 1, 0);
     MarchingCubes.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 think it looks nicer
                 m_voxelChunk[x,y,z].SmoothVoxels();
                 //Create the normals. This will create smoothed normal.
                 //This 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 marching 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: 

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

Help with conversion from javascript to c# 3 Answers

Convert Javascript to C# 1 Answer

Need help converting Javascript to C# 3 Answers

Convert this string formatting from C# to JS 1 Answer

Can someone help me translate this to c#? 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