Skip to main content
gamedev.net
🔒 Locked

Converting some code?

Started by zulbaric 0 replies 950+ views
Original Post
zulbaric
zulbaric
Hi would it be possible to convert some DirectX code to XNA C#? float Noise(int x) { x = (x<<13) ^ x; return (1.0 - ((x * (x*x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); } float CosInterpolate(float v1, float v2, float a) { float angle = a * D3DX_PI; float prc = (1.0f - cos(angle)) * 0.5f; return v1*(1.0f - prc) + v2*prc; } HRESULT HEIGHTMAP::CreateRandomHeightMap(int seed, float noiseSize, float persistence, int octaves) { //For each map node for(int y=0;y 255)b = 255; //Save to heightMap m_pHeightMap[x + y * m_size.x] = (b / 255.0f) * m_maxHeight; } return S_OK; } thanks
Wan
Wan
This isn't really DirectX specific code apart from the pi constant and to a lesser extent the hresult enumeration.
I haven't tested it, but replacing them with a C# equivalent (Math.PI and functions in the Math namespace, your own defined return type) should probably make most of it working in XNA.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.