• Content count

  • Joined

  • Last visited

Community Reputation

102 Neutral

About sofakng

  • Rank
  1. [font=Verdana, Arial, sans-serif][size=2]What are some good prototyping frameworks/engines for an AI/NPC type game? I'd like to create something where you setup a hero and have him act on his own (eg. Majesty, Godville, NPC Quest, etc) I don't have a lot of ideas yet though so I'd like something something where I can throw together a few tiles and then program some simple AI and see what I can design before I go "full blown" with XNA or iOS, etc.[/size][/font]
  2. I'd like to write a small MUD just for fun but I can't seem to find a lot of information on command-line parsing. For example, I need to parse commands such as: * put ring on finger / equip ring * cast magic fire spell on monster * fill bottle with water from fountain I'm sure you get the idea. Where can I find some good information? Also, I'll be using C# as my programming language if that matters.
  3. Where can I find some information on 2D tile maps and lighting effects? I've searched all over the place and found a few bits of scattered information but much of is it extremely old and references old versions of DirectX/OpenGL, etc. I'm also interested in any 2D engine that has built-in support for tile-maps and lighting and hopefully networking. Thanks so much for any help!
  4. What do you mean by your last statement? (eg. feeding trimesh data into the physics engine to create the grid) Actually, can you explain a little about how you plan to create/draw the grid? I was thinking about drawing a bunch of planes on top of my cubes which seems fairly simple...
  5. Thanks again for the advice. I've created a simple prototype in XNA using cubes and mesh instancing and it actually works pretty good but I'm having second thoughts about the artistic aspect. My terrain of 50x50 cubes (2500 cubes, 25000 triangles?) is rendering at over 3000 fps on my 8800 GTX and even gets 200 fps on another machine that only has a very cheap integrated graphics card). However, I'm really not sure if I want to proceed with the cube terrain and might just use a real 3D model like you originally suggested...
  6. Ok, I've found my problem but I'm really confused what is causing it. After checking MouseState.MiddleButton (or any button) the X, Y mouse coordinates change! For example: MouseState ms = Mouse.MouseState() if (ms.MiddleButton == ButtonState.Pressed) { // Do something } // ms.X and ms.Y might be (0, 0) at this point, but if you check Mouse.GetState().X/Y you might see (203, 481) or something extremely different. This was causing my mouse pick ray to have incorrect coordinates...
  7. Thanks for all of the replies. I've found half of my problem: The nearSource Z coordinate must be 0 and the farSource Z coordinate must be 1. I was using my actual near and far plane values (1, and 1000). Now my line shows up! However, it seems to be drawn a little off-center from where I click. Are my source and destination vertices correct for the line? ray.Position (for the starting point), and ray.Position * (ray.Direction * 100) for the destination? (eg. I just want to draw the actual ray for about 100 units of length)
  8. I'm following the mouse picking tutorial but instead of trying to intersect objects with the ray I'm just trying to draw the ray itself. (I know that a ray is infinite but I'm trying to draw from it's starting position to 1000 units away from it) Here is how I'm creating my ray: Vector3 nearSource = new Vector3(Mouse.GetState().X, Mouse.GetState().Y, camera.nearPlane); Vector3 farSource = new Vector3(Mouse.GetState().X, Mouse.GetState().Y, camera.farPlane); Vector3 nearPoint = Game.GraphicsDevice.Viewport.Unproject(nearSource, camera.projection, camera.view, Matrix.Identity); Vector3 farPoint = Game.GraphicsDevice.Viewport.Unproject(farSource, camera.projection, camera.view, Matrix.Identity); // find the direction vector that goes from the nearPoint to the farPoint // and normalize it.... Vector3 direction = farPoint - nearPoint; direction.Normalize(); // and then create a new ray using nearPoint as the source. lastRay = new Ray(nearPoint, farPoint); VertexPositionColor[] v = new VertexPositionColor[2]; v[0] = new VertexPositionColor(lastRay.Position, Color.Blue); v[1] = new VertexPositionColor(lastRay.Position * (lastRay.Direction * 1000), Color.Red); vb = new VertexBuffer(Game.GraphicsDevice, VertexPositionColor.SizeInBytes * 2, BufferUsage.WriteOnly); vb.SetData(v); ...and here is how I'm drawing it: if (vb != null) { GraphicsDevice.RenderState.DepthBufferEnable = true; GraphicsDevice.RenderState.AlphaBlendEnable = false; GraphicsDevice.VertexDeclaration = new VertexDeclaration(Game.GraphicsDevice, VertexPositionColor.VertexElements); GraphicsDevice.Vertices[0].SetSource(vb, 0, VertexPositionColor.SizeInBytes); effect.World = Matrix.Identity; effect.View = camera.view; effect.Projection = camera.projection; effect.Begin(); effect.EnableDefaultLighting(); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Begin(); GraphicsDevice.DrawPrimitives(PrimitiveType.LineList, 0, 1); pass.End(); } effect.End(); } Am I doing something wrong? I'm just trying to see the mouse-picking line before I use it...
  9. Thanks for the reply! I must be doing something wrong because it's not quite working for me. I seem to getting a little too much of the texture (eg. it's grabbing part of the next texture)... Here are some examples: Here is my tilemap: EDIT: The examples above are several cubes placed right next to each other. The lines you see must be because each texture is grabbing part of the next texture (although, this does help to illustrate that they are infact several cubes and not just one).
  10. Let's say I have textures that are each 128x128 and I have a 4x4 grid of them inside one file. What is the math for getting the UV coordinates of each tile? For example, the first tile should be: (I think) float tileSizeX = 127 / 511; float tileSizeY = 127 / 511; topLeft = (0, 0) topRight = (tileSizeX, 0) bottomLeft = (0, tileSizeY) bottomRight = (tileSizeX, tileSizeY) I'm using 127 because it's 128 - 1 and I'm using 511 because it's (128 * 4) - 1. Let's say I want tile position (2, 2) now. How do I get that? ...and is my math even correct for tile (0, 0)?
  11. I'd like to create a tactical game similar to Final Fantasy Tactics and Disgaea (and many others I'm sure). The game will be in true 3D but will use orthographic projection (for an isometric look and feel). Here are some examples of what I'm trying to achieve: (many more pictures located here: (more pictures located here: It seems like both use "3D tiles" but I'm not sure. Does 3D tiles imply no height? ...or would you need a tilemap including height? (eg. 200x200x15) The other problem is that there are additional structures (trees, building, etc) on the map. I think that some of them can be climbed (eg. flat buildings) but others cannot (trees). What are some ideas on how to create/render these levels? Should I use a 3d tilemap that includes height (eg. 200x200x15) and then have an additional array of buildings or something? An alternative is to create entire 3D level as a single model or like a regular BSP map (or whatever), but this seems more difficult, I think. Thanks for any advice!
  12. Simple 3D cube: triangle list or strip?

    What about a triangle list with an index buffer?
  13. What is the best way to draw a 3D cube? A triangle list or triangle strip? According to this site (, multiple triangle strips are the best way to do it. Is this true?
  14. Does a scaling matrix affect rotations?

    Ok, I think I understand. Thanks! Instead of starting a new topic, let me ask one more question but this time about backface culling. If we are using a backface culling mode of counter-clockwise (eg. counter-clockwise vertices are not drawn), than why does this rectangle still work: // Triangle-strip: verts = new VertexPositionColor[4]; verts[0] = new VertexPositionColor(new Vector3(-1, 1, 0), Color.Blue); verts[1] = new VertexPositionColor(new Vector3(1, 1, 0), Color.Yellow); verts[2] = new VertexPositionColor(new Vector3(-1, -1, 0), Color.Green); verts[3] = new VertexPositionColor(new Vector3(1, -1, 0), Color.Red); The first three vertices are clockwise so that makes sense, but the last three (eg. 2nd triangle strip) are actually counter-clockwise... EDIT: Apparently DirectX (XNA) flips the culling flag for every even numbered triangle. Sorry for the wasteful post. [Edited by - sofakng on May 12, 2009 8:28:58 AM]