# Budinga

Member

28

331 Neutral

• Rank
Member
1. ## Problems Porting Eric Bruneton's Water to XNA

Ok a little update I managed to figure out a few things now the flat version I found quite simple to get working , but I am aiming for the spherical version and I am stuck on the code for the matrix generation if anybody can give me a little insite in to what im doing wrong. At the moment I am using this code, but I am sure it dosent work properly as I only get a broken up sphere , so is there something im doing wrong do I need to construct the matrix in a different way.   [code]Vector3 ux, uy, uz, oo; if (radius == 0) { // flat ocean ux = Vector3.UnitX; uy = Vector3.UnitY; uz = Vector3.UnitZ; oo = new Vector3(camtolocal.X, camtolocal.Y,0);   } else { // spherical ocean uz = Vector3.Normalize(camtolocal);// unit z vector of ocean frame, in local space ? if (oldcamtolocal != Matrix.Identity) {     ux = Vector3.Normalize(Vector3.Cross(new Vector3(oldcamtolocal.M21, oldcamtolocal.M22, oldcamtolocal.M23), uz));     ? ? } else { ux = Vector3.Normalize(Vector3.Cross(Vector3.UnitZ, uz));   } uy = Vector3.Cross(uz, ux);// unit y vector // negate this ?? oo = uz * radius; // origin of ocean frame, in local space     }   Matrix localtoocean = new Matrix( ux.X, ux.Y, ux.Z, -Vector3.Dot(ux, oo), uy.X, uy.Y, uy.Z, -Vector3.Dot(uy, oo), uz.X, uz.Y, uz.Z, -Vector3.Dot(uz, oo), 0.0f, 0.0f, 0.0f, 1.0f);[/code]
2. ## Problems Porting Eric Bruneton's Water to XNA

Ok I am getting some ware now on the flat plane ocean, just gotta work on the spherical one. Just wanted to ask some advice on one more thing. When I load the precomputed scattering textures any advice on how to do this in xna, ive used the io.file to load the raw data I have tried to load it single by single. Af far as I can see he uses a half float to store each pixel, how the heck do I load this in to xna. P.S still don't have the vertex shader working100% thanx smasherprog at least I am now getting someware. :)
3. ## Problems Porting Eric Bruneton's Water to XNA

Hi,   Thanx for your answer I gathered it was something like that, the main thing I need to ask is did you transpose your Matrix before you passed them to the shader or did you just pass them the same way as the example and just change the y and z components. I did actually try swapping the whole everything first and I got nothing so I had to start again.

5. ## Best way to see if mouse clicked in a certain area

The simplest way to do it is to just check the mounse has clicked within the bounds of the rectangle. example: This is just a psudo example. [code] if (mouse.leftclick) { if (mouse.x > rectangle.position.x && mouse.x < (rectangle.position.x+width)) { if (mouse.y < rectangle.position.y && mouse.y < (rectangle.position.y + height)) { do something when rectangle is cliked. } } } [/code] If you mean what i think you mean about win32 to d3d you mean you need to compensate for the clientsize verses windows size have a look at this link. [code] [url="http://www.directxtutorial.com/Tutorial11/A-A/AA4.aspx"]http://www.directxtutorial.com/Tutorial11/A-A/AA4.aspx[/url] [/code]
6. ## What are you working on?

I am currently working on a Planet renderer uses a geomipmaps for the terrain, and realtime atmospheric scattering, water and clouds are a bit crappy at the moment, but i am getting there i have just managed to get the fps from 20fps to max of 150fps so still heavy work in progress. But thought i mite post some screenshots. [url="http://imageshack.us/photo/my-images/685/screeny80.jpg/"][img]http://img685.imageshack.us/img685/1241/screeny80.jpg[/img][/url]
7. ## Snycing Clipmap Cube Face Cenetrs

Well i am having a problem trying to snc the clipmap cube face centers from my procedural planet renderer, im very stuck at the moment. I want to get the same cube center no matter were the camera is i think i need some sort of projection. heres a pic of the clipmaps synced, but they do that as i move away and when i move close the move away from me. Anybody got any ideas. [url="http://imageshack.us/photo/my-images/339/screeny55.jpg/"][img]http://img339.imageshack.us/img339/4744/screeny55.jpg[/img][/url] Maybe i could have some sort of virtual box and project, from the camera and get an x,z coord on that box, just a bit stumped on how to go about it. Any ideas will be great.
8. ## SOLVED [XNA] Is there a right way to generate a sphere for an atmosphere

I just noticed all my code is msessed up i cant seem to get it posted right, i will just explain the prob i got. Well when i draw the atmosphere after the planet like i am suppost to i get a white sphere in the middle no blending, and then when i enable alphablending which as far as i can tell is right i get some strange triangle anomolies, maybe i have written the shader wrong or the sphere is wrong i am very confused as far as i know the sphere is above 20k verts, wnybody got any ideas.
9. ## SOLVED [XNA] Is there a right way to generate a sphere for an atmosphere

[quote name='Budinga' timestamp='1295988330' post='4764657'] <P>Well i have spent loadz of time working on procedural planet based on oneal's sandbox all written in vb.net and xna.i have the basic shaders working down to a T, but i have 1 problem, as i have to render the atmosphere mesh after the planet and cull the front faces as i understand when i do this i get gaps in the triangles and it overlays the planet, am i generating it wrong or am i doing something else wrong. the way i got round it is to render the atmosphere after the planet with not depth buffer but this does not work properly as when you go round the planet the atmosphere lookes strange. here is the code i am using to generate and render the sphere. i also got a slight prob using the bitshifting to calculate the quadtrees but im getting there, i think i should fix this first as the rest works ok for now.<BR><BR>[code]<BR> Public Sub New(ByVal Dev As GraphicsDevice, ByVal Cam As Camera, ByVal PlMap As PlanetaryMap, ByVal FromSpaceShader As Effect, ByVal Stacks As Integer, ByVal Slices As Integer, ByVal Radius As Single)<BR> Device = Dev<BR> Camera = Camera<BR> Planet = PlMap<BR> Dim elm() As VertexElement = {New VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0)}<BR> Declaration = New VertexDeclaration(Device, elm)</P> <P> ' Calculates the resulting number of vertices and indices<BR> Dim numberVertices = (Stacks + 1) * (Slices + 1)<BR> Dim numberIndices = (3 * Stacks * (Slices + 1)) * 2<BR> Dim indices As Integer() = New Integer(numberIndices - 1) {}<BR> Dim vertices As Vector3() = New Vector3(numberVertices - 1) {}</P> <P> Dim StackAngle As Single = MathHelper.Pi / CSng(Stacks)<BR> Dim SliceAngle As Single = CSng(Math.PI * 2.0) / CSng(Slices)</P> <P> ' Generate the group of Stacks for the sphere <BR> Dim wVertexIndex As Integer = 0<BR> Dim vertexCount As Integer = 0<BR> Dim indexCount As Integer = 0</P> <P> For stack As Integer = 0 To (Stacks + 1) - 1</P> <P> Dim r As Single = CSng(Math.Sin(CSng(stack) * StackAngle))<BR> Dim y As Single = CSng(Math.Cos(CSng(stack) * StackAngle))</P> <P> ' Generate the group of segments for the current Stack <BR> For slice As Integer = 0 To (Slices + 1) - 1<BR> Dim x As Single = r * CSng(Math.Sin(CSng(slice) * SliceAngle))<BR> Dim z As Single = r * CSng(Math.Cos(CSng(slice) * SliceAngle))<BR> vertices(vertexCount) = New Vector3(x * Radius, y * Radius, z * Radius)</P> <P> 'vertices(vertexCount).Normal = Vector3.Normalize(New Vector3(x, y, z))</P> <P> 'vertices(vertexCount).TextureCoordinate = New Vector2(CSng(slice) / CSng(Slices), CSng(stack) / CSng(Stacks))<BR> vertexCount += 1<BR> If Not (stack = (Stacks - 1)) Then<BR> ' First Face<BR> indices(indexCount) = wVertexIndex + (Slices + 1)<BR> indexCount += 1</P> <P> indices(indexCount) = wVertexIndex<BR> indexCount += 1</P> <P> indices(indexCount) = wVertexIndex + 1<BR> indexCount += 1</P> <P> ' Second Face<BR> indices(indexCount) = wVertexIndex + (Slices)<BR> indexCount += 1</P> <P> indices(indexCount) = wVertexIndex<BR> indexCount += 1</P> <P> indices(indexCount) = wVertexIndex + (Slices + 1)<BR> indexCount += 1</P> <P> wVertexIndex += 1<BR> End If<BR> Next<BR> Next</P> <P> Me.IndexCount = indexCount<BR> Me.VertexCount = wVertexIndex</P> <P> Vertexbuffer = New VertexBuffer(Device, GetType(Vector3), numberVertices, BufferUsage.None)<BR> Vertexbuffer.SetData(vertices, 0, vertices.Length)<BR> IndexBuffer = New IndexBuffer(Device, GetType(Integer), numberIndices, BufferUsage.None)<BR> IndexBuffer.SetData(indices, 0, indices.Length)<BR> AtmosphereEffect = FromSpaceShader<BR> End Sub<BR>[/code]<BR><BR><BR>and the render code<BR><BR>[code]<BR> Public Sub Draw(ByVal gametime As GameTime)</P> <P> Device.VertexDeclaration = Declaration</P> <P> </P> <P> Device.Vertices(0).SetSource(Vertexbuffer, 0, 12)<BR> Device.Indices = IndexBuffer</P> <P> SetAtmosphereFromSPaceShaderVariables(gametime)<BR><BR> If IsInAtmosphere Then<BR> AtmosphereEffect.CurrentTechnique = AtmosphereEffect.Techniques("SkyFromAtmosphere")<BR> Else<BR> AtmosphereEffect.CurrentTechnique = AtmosphereEffect.Techniques("SkyFromSpace")<BR> End If</P> <P><BR> AtmosphereEffect.Begin()</P> <P> For Each pass As EffectPass In AtmosphereEffect.CurrentTechnique.Passes<BR> pass.Begin()</P> <P> Device.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, VertexCount, 0, IndexCount)</P> <P> pass.End()<BR> Next</P> <P> AtmosphereEffect.End()</P> <P> Device.RenderState.DepthBufferEnable = True<BR></P> <P> End Sub<BR>[/code]<BR><BR>you can see the progress screenshots at budinga.blogspot.com. Help is always much apreciated. </P> [/quote]

11. ## Problem referencing DirectX in managed C++ project

I could be wrong but as far as i remember the libs are in C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0 this is what i use for my vb.net apps, hope this helps. and im not sure , but for unmanaged dx you have to set the include and lib dir's for the dx sdk.
12. ## [Solved] Another Atmosphere from Space post

Right i have noticed what i was well asuming wrong the shader works, the only problem is it assumes that the sphere i am using the shader on is the planet so the white very obvious is the lit areas, now i just need to find a way to make it look cool and transparent enough for my planet. The code works well to an extent, i have changed it a bit. But i hope it comes in usefull to somebody, its not really my code anyways so thanx.