Skip to content

Instantly share code, notes, and snippets.

View AncientPixel's full-sized avatar

Gustave AncientPixel

  • South-Africa
  • 17:34 (UTC +02:00)
View GitHub Profile
@AncientPixel
AncientPixel / planetGen_regionColour.cs
Created April 19, 2013 10:27
Method to use the populated region list to colour our texture via height map values.
void ColourIt()
{
// COLOUR!
// Colour in elevations
// _stride - is the size in bytes of the width of the texture RGBA = 4bytes * width of texture.
// _textureSize - size (w & h) in pixels of the texture.
for (int y = 0; y < _textureSize; y++)
@AncientPixel
AncientPixel / planetGen_regionSet.cs
Created April 19, 2013 10:15
Default values to populate regions with.
void DefaultRegions()
{
// Create regions
// Sea
AddRegion("Sea", Color.FromRgb(64, 126, 150), 115);
// Low Water
AddRegion("Low Water", Color.FromRgb(81, 173, 168), 125);
// Beach
AddRegion("Beach", Color.FromRgb(255, 189, 84), 130);
@AncientPixel
AncientPixel / planetGen_region.cs
Last active December 16, 2015 10:19
Structure to hold the colour for each height map value range.
public class Region
{
public string name;
public Color baseColor;
public double[] range = new double[2];
}
public List<Region> _regions = new List<Region>();
using System;
namespace Noise
{
public static class SimplexNoise
{
private static double F2 = 0.5 * (Math.Sqrt(3.0) - 1.0);
private static double G2 = (3.0 - Math.Sqrt(3.0)) / 6.0;
private static double F3 = 1.0 / 3.0;
@AncientPixel
AncientPixel / planetGen_sphere.cs
Created April 15, 2013 14:35
Code to transform a subdivided cube mesh into a sphere using WPFs 3D classes.
// Load base mesh
_currentModel = ModelImporter.Load(_localPath + @"Models\planetCube.3ds");
Model3DGroup modelGroup = (Model3DGroup)_currentModel;
GeometryModel3D model = (GeometryModel3D)modelGroup.Children[0]; // The first child of model group is the imported mesh.
model.BackMaterial = null;
// Make spherical
MeshGeometry3D mesh = (MeshGeometry3D)model.Geometry; // Grab reference to raw mesh data.