Jump to content
  • Advertisement

LowRad

Member
  • Content Count

    289
  • Joined

  • Last visited

Community Reputation

234 Neutral

About LowRad

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. LowRad

    Rendering Blocky Terrain Tiles

    Both of your naive solution will work very well.   I've started using your second solution: 1dynamic vb per texture. - Then i've subdivided my terrain in chunk. - Then i've added atlasing. - Then i've added what you call "skinnin" at a later stage.   My best advice, do it then optimize! Dont optimize what you dont need to. The only true thing about software design is: "The best solution is always the simplest solution". In other words, the most naive solution is ALWAYS the best one. When that first naive solution dont fit your needs/problems anymore; move forward.
  2. LowRad

    [XNA] Input Issue

    Your code do what you told it to do. Dont forget that the system is calling the Update-Draw pair as fast as it can. Hence, the lighting fast menu switch you see. It's alot simpler and elegant to simply do it like.. // Holds KeyboardState from last frame. KeyboardState _keyboardOldState; override void Update(GameTime gameTime) { // gets input for this frame KeyboardState keyboardState = Keyboard.GetState(); // process inputs if( keyboardState.IsKeyDown(Keys.Up) && keyboardOldState.IsKeyUp(Keys.Up)) { currentMenuItem ++; } if( keyboardState.IsKeyDown(Keys.Down) && keyboardOldState.IsKeyUp(Keys.Down)) { currentMenuItem --; } // keep this frame inputs as next frame old input _keyboardOldState = keyboardState; } Normally people will wrap up this OldKey "pattern" into some class input manager or whatnot. Also try not to mix your code in Update and Draw. Draw shouldnt have "logic" code (the menu selection code). Hope it helps,
  3. LowRad

    2 controllers with XNA

    From XNA Documentation GamePad class PlayerIndex enumeration And i bet player #1 is playing off the controller #1... well.. maybe he's playing from controller #2 but who cares really!?
  4. Thanks for quick response, my code looks like it performing correctly: no more weird zooming in and out even after playing a few levels. About making normalizing matrices in XNA, ive not found anything in the documentation. However, this shouldnt be too hard, its just a bit of cross-product and vectorial maths to make sure the vector are orthogonal to each other. About quaternion, after re-reading a few references i had. Would their only usefull quality is their ability to be easily interpolated? Or can you tell me or descripe me where quaternion are best used. Thanks again!
  5. Thanks for answering me. Im using quaternion since i want to turn the tradional asteroid game into a "3d" version (meaning you can rotate in any direction and chase asteroids in a 3d space rather then a 2d world). Im using them to avoid the famous gimbal lock problem. Can i achieve the same with matrices only? About your comment on normalization, do you mean something like this? And can you explain what you mean about normalizing a matrice? i dont see how i can do this (i cant find nothing in xna documentation). Quaternion ori = Quaternion.CreateFromRotationMatrix(Orientation); Quaternion rot = Quaternion.CreateFromAxisAngle(Vector3.Up, 0.2f); // i'm assuming this is the right order (or is it ori * rot) Quaternion final = rot * ori; final.Normalize(); Orientation = Matrix.CreateFromQuaternion(final); You are also talking about the multiplication order. From what i understand this should be the right way to do it? am i right? (Transformations are applied from right to left). Quaternion ori = Quaternion.CreateFromRotationMatrix(Orientation); Quaternion rotPitch = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), GetPitchInput()); Quaternion rotRoll = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), GetRollInput()); Quaternion rotYaw = Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), GetYawInput()); // Is this correct? // Should i normalize before, between each transforms or only after Quaternion final = rotPitch * rotRoll * rotYaw * ori; final.Normalize(); Orientation = Matrix.CreateFromQuaternion(final); Would an implementation like this suffer from numerical error?
  6. Hi, I am writing an Asteroid clone and i got few problems and questions. So i though i would ask here for advices and comments. Firstly, even if im planning on using quaternion to rotate my objets, im storing their orientation as a matrix. Im doing so since it seems easier to do lots of stuff, like transforming coordinates from world to local or simply getting a forward vector. Any thoughts about this, is this practice common or should i store the orientation as a quaternion? Secondly, even if all seems to work as they should, i've got some kind of error in my rotation code. Im using this code snippet to turn the ship. // Orientation is the Ship's Orientation store as a Matrix Quaternion q1 = Quaternion.CreateFromRotationMatrix(Orientation); Quaternion rot = Quaternion.CreateFromAxisAngle(Vector3.Up, 0.2f); Quaternion final = q1 * rot; Orientation = Matrix.CreateFromQuaternion(final); Question: result seems the same if im swapping quaternion multiplication order (seems odd to me). Is this a normal behavior? From what ive red, no! // in the above code, either of theses line are giving me the same result. // as if: q1 * rot = rot * q1 final = q1 * rot; final2 = rot * q1; Problem: I got a bug and it's really hard to reproduce it. Very rarely as im moving around the screen and turning the ship around. The ship go out of control and seems to zoom in/out or being tranlated up/down (instead of turning normally). I cant track the problem down, but im sure its has to do with the way im using thoses quaternion to rotate my objects. Any comments or ideas are welcome... Thanks you!
  7. I really feel bad right now... thanks for reminnding me to reinstall DX SDK so i could get the debug runtime running. My error was pretty obvious: Direct3D9: (ERROR) :Vertex stride in stream 1 is less than in the declaration I forget to change my declaration offsets to: VertexElement[] vertexDeclaration = new VertexElement[] { new VertexElement(0, 0, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), new VertexElement(0, 8, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 1), new VertexElement(1, 0, DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 2), VertexElement.VertexDeclarationEnd, }; Vertex declaration offset are stream based. duh! :) Thanks!
  8. Hi, I have converted my terrain to use multiple stream to allow me to have a bigger landscape. I've manage to make it work. However, after a few frames a rendering bug is showing up. Some triangle start to flicker and they seems to change over time or when i move the camera. I've tried to debug the problem using PIX, but everytimes a take a snapshot everythings is fine (image is ok). This is the relevent part of my shader: struct VS_INPUT { float2 Position : TEXCOORD0; float2 TexCoord : TEXCOORD1; float1 HeightPosition : TEXCOORD2; }; VS_OUTPUT VS(VS_INPUT input) { VS_OUTPUT output = (VS_OUTPUT)0; float4 position = float4(input.Position.x, input.HeightPosition.x, input.Position.y, 1); output.Position = mul(position, g_WorldViewProjection); output.TexCoord = input.TexCoord; return output; } And the relevent part from my code public struct TerrainVertex { public float x, z; public float u1, v1; } public struct TerrainHeightVertex { public float y; } VertexElement[] vertexDeclaration = new VertexElement[] { new VertexElement(0, 0, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), new VertexElement(0, 8, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 1), new VertexElement(1, 16, DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 2), VertexElement.VertexDeclarationEnd, }; public void Draw(Matrix viewMatrix, Matrix projectionMatrix) { _graphicsDevice.RenderState.ZBufferEnable = true; _graphicsDevice.RenderState.ZBufferWriteEnable = true; _graphicsDevice.RenderState.CullMode = Cull.CounterClockwise; // disabled alpha-blending and alpha testing _graphicsDevice.RenderState.AlphaBlendEnable = false; _graphicsDevice.RenderState.AlphaTestEnable = false; _graphicsDevice.SetStreamSource(0, _gridVertexBuffer, 0, Marshal.SizeOf(typeof(TerrainVertex))); _graphicsDevice.SetStreamSource(1, _heightVertexBuffer, 0, Marshal.SizeOf(typeof(TerrainHeightVertex))); _graphicsDevice.Indices = _indexBuffer; _graphicsDevice.VertexDeclaration = _vertexDeclaration; int passCount = _effect.Begin(FX.None); for (int iPass = 0; iPass < passCount; iPass++) { _effect.BeginPass(iPass); _graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, _vertexCount, 0, _primitiveCount); _effect.EndPass(); } _effect.End(); } And the results: So i'm asking here, since i dont have any good ideas on what could cause this strange behaviour. If i didnt post enought, just ask me the relevent part missing. Thanks to look into it with me ;) Lowrad
  9. Thanks all, I've setup my solution like i knew to do and it's working. But, i'll give a shot at your suggestions, they seams interesting.
  10. Wow that was fast, thanks... That's just to prove me i didnt code in c++ for too long ;) So, i really need to add the file.lib and add paths for lib and include paths right? like i do for any others 3rd party lib? Jonathan
  11. Hi all, So long i didnt used C++ for any type of project. I've start using C# 6 years ago and never look back. Today, i've decided to build a little game. And i'm stuck layouting my solution, i just can't remember how to 'link' projects together. So, to start, i've layout my solution like this.. a Win32 application project named MyGame and another win32 lib project named GameFramework. My question is how can i reference GameFramework from MyGame? I'm using Visual Studio 2008 if that matters. I got a few ideas on how to do it, i was going to do like i do to link any other lib, but since all projects are in the same solution i bet there's a better way. Thanks, Jonathan
  12. Hi all, I dont know if anyones ever realized it, but i'm getting alot of runtime errors when i'm hovering over the site's menu. I know i can disable script debugging on IE and get rid of thoses. But i'm a web developper as my day job so i just prefer to leave it like that. And so, i'm wondering if anyone will ever look at this. Any good site like gamedev.net shouldn't have thoses types of runtime scripts errors ;) Oh well, maybe it's just to proof this point: coders don't code well when they code for themselves ;) KK i'm just joking around... So, any thoughts on that ?! Jonathan
  13. LowRad

    dx9 & vb.net artifacting

    Without seeing all the code, i would say this is where the problem lies. Quote: D3DDevice.SetTexture(0,texture,0) This line of quote only tell the device which texture to use, not how to use it. Checkout the SamplerState class on MSDN. This property is accessible throught the graphicsDevice.SamplerStates indexer. The SamplerState allows you to control how the device will use that texture. And what i was suggesting you check the Addressing property of the SamplerState you are using.. In your case something similar to: D3DDevice.SamplerState[0].AddressU = TextureAddressMode.Clamp; D3DDevice.SamplerState[0].AddressV = TextureAddressMode.Clamp; In any ways, i bet you solution lies somewhere in setting the right configuration on that SamplerState. Good luck,
  14. LowRad

    dx9 & vb.net artifacting

    Hi, You should post the drawing routine instead. Normally thoses types of artefacts are due to wrong texture sampler states: read on texture CLAMPING.
  15. It looked like you somehow found a solution to your problem. But, i suggest you to take a look at the XNA Creators website, they got a sample on using XNA with WinForms, like Imgelling was saying. And, i hope, without sounding to harsh: they got the 'REAL' way of doing it. To use XNA on WinForms, you need to give up the Game class. The game class was built to create a game and an editor isn't a game. I know you can find alot of workaround solutions on the web, which are arguing theirs methods are 110% valid... But why use a workaround when the answers are here AND written by Microsoft WinForm Sample on XNA Creators and Dynamic Content Loading on XNA Creators
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!