M_Johnson

Members
  • Content count

    19
  • Joined

  • Last visited

Community Reputation

129 Neutral

About M_Johnson

  • Rank
    Member
  1. So an agent needs to navigate a navigation mesh, he wants to get from Source to Dest   [attachment=14242:Navmesh1.jpg]   A pathfinding algorithm is run which finds a list of navigation polygons the agent must visit   [attachment=14243:Navmesh2.jpg]   In this case A, B, C, D, G, and then finally H. In the above example the agent naively navigates to the center of the "entry" edge of each polygon, i.e. when the agent wants to navigate from A to B the entrance edge would the two vertices the polygons share summed and then divided by two to give the entry point A->B which the agent will seek to. What I want to do is smooth it so it looks like this:   [attachment=14244:Navmesh3.jpg]   So that it picks the best point at which to seek each entry point on the path. Now I know that probably isn't the best example because the mesh could be simplified, but it illustrates the point; I need a better way to choose how to navigate between polygon nodes. The "picking the middle" option also wouldn't work very well if two polygons share a large edge. I was wondering what elegant ways there were to achieve this?   Any help would be appreciated.   Cheers.
  2. I'm having issues with this message in XNA 4. If I set the TextureFilter to point it fixes it for a few calls to the same object (I'm doing multi-pass lighting), but the EffectPass::Apply() function seems eventually to modify the sampler states so that sampler state 0 becomes null. I can get around that by setting the sampler state after the call to EffectPass:.Apply() however I then receieve the error on ModelMesh::Draw() (a different object that's represented by a loaded model instead of drawing the mesh manually) since the same thing seems to be happening but obviously hidden in the Draw call. [code] public void DrawGeometry(Effect effectToUse) { GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp; GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; GraphicsDevice.SetVertexBuffer(vertexBuffer); GraphicsDevice.Indices = indexBuffer; foreach (EffectPass pass in effectToUse.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawIndexedPrimitives(Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList, 0, 0, numVertices, 0, (numVerticesWidth - 1) * (numVerticesHigh - 1) * 2); } } [/code] So in one frame I call this function multiple times, once for each light in my scene, like I say, the first few calls work ok but eventually after pass.Apply() and before GraphicsDevice.DrawIndexedPrimitives the sampler states all get messed up. I thought it would be something in my shader but the fact that the first few calls work makes me doubt that's the cause. Is this a bug in XNA 4 or am I missing something?
  3. Inverse Kinematics Solver

    For what I'm doing it's going to be necessary to control one/both arms of a rigged model (within limits to prevent them bending through the characters head or something) does anyone have any information about how an Inverse Kinematic Solver can be implemented for a game? Basically I'm looking for something similar to what's used in Unreal Engine, so I'm looking for performance over quality, as long as what it comes up with doesn't look ultra-weird.
  4. Multiple Shadow Casters

    Right you were, one of my shadow maps was flipped. Still looks weird but a little less weird.
  5. Hi. I have an issue, in something I'm making I have multiple point lights, each one casting shadows on some boxes/the floor, the problem is that it looks very strange and weird when they're close to each other in the scene (see attached image). [attachment=1693:ShadowsProblem.jpg] I know what the issue is, it's that the pixels that are in the shadow of one of the lights (each light is located above each character in the scene) aren't receiving as much light as those in visible by both lights so appear much darker in comparison. I'm just wondering if anyone knows of a good way of handling this?
  6. Multiple Shaders

    Hello So I have 3 shaders in seperate files: Shader 1: Responsible for skinning, transforms vertices based current bone transforms. Shader 2: Performs normal mapping based on a single light source Shader 3: Handles shadows that are being cast on the character. What would be the best way of combining these 3 shaders so I can have a skinned model with normal mapping and able to interact with shadows? One option I thought of was to make it so the shaders contained nothing but the actual functions themselves (removal of global variables) then create an uber technique which #includes the vertex/pixel shaders from these 3 files and implements each one as a pass, then stick all the required globals in the uber technique and blend between the outputs to the render target, I'm not even sure that this would produce the desired results though or if I'd get lots of weird lighting/shadowing artifacts due to the skinning stage. I'm trying to avoid implementing the whole lot in one vertex/pixel shader. Any help would be appreciated.
  7. Constructing Buildings

    Automatic portal generation is possible, it's generally not recommended though since often the process results in portal's all over the place, for every little corner of your map which can be a performance hit. Basically the process to automatically creating portal's is similar to that of creating a leafy BSP, where the planes which you're splitting the BSP on in essence become your portals. You then have to parse all of your created portals and remove duplicate's /redundant ones.
  8. Splitting a convex polygon in two?

    Use a plane that is perpendicular to your polygon's plane (the normals are at right angles to each other) it is along this plane that the split will take place. Then if you treat edges as rays you can perform a ray-plane intersection test over all your edges to determine if they intersect the plane and if they do where. You can then classify the verticies by getting the vector from the vertex to the point on the splitter plane and performing the dot product between that and the plane's normal vector. If they're "above" the plane (their dot product >= 0) then you classify them as being in polygon A and if they're below the plane you classify them as being in polygon B. If you're verticies are defined in a clockwise order as your iterating through them you can detect when the dot product result flips from positive to minus (or vice versa) and use this to insert verticies at the points where your polygon's edges intercepted the plane.
  9. Point within rectangle problem...

    I haven't really gone over your code with a fine tooth comb but from your description it sounds like you're not taking the pivot point into account when you're calculating whether the point is inside the rectangle. So basically when you're trying to detect whether the point is inside the rectangle you're assuming that the object has been rotated about the origin of the object as oppose to being offset by the pivot. You'll need to take the pivot point into account when determining where the user has clicked.
  10. Hi, I'm just wondering if anyone knows of any good resources that cover this subject? Particularly concerning the maths behind it. I've been searching online for quite sometime and I haven't found anything that covers it in sufficient depth. Of particular interest to me is the difference operation. Any help would be much appreciated.
  11. luaL_openlibs crash

    Hi, I'm compiling using VC8 and when I call luaL_openlibs from my program I get the following error message in the console: "PANIC: unprotected error in call to Lua API (unable to get ModuleFileName)" I had a look around on google for the solution but the only solution I found was switch the project file to use the ASCII character set, which I did but the problem persists. I can't think what else could be responsible for the error.
  12. Use of Lua_State

    Quote:Original post by Sneftel Now a slight complicating factor. Some people would like to make a .lua file with an update function and a variable called "a" and want all that stuff to go into a table which is not the global table. You can make that happen: Just set the function environment of the loaded function to a new table before executing it. (Keep in mind that the script will see this empty table as its global table, so you can't really do significant computation in the script; this doesn't apply to functions which are put in the table by the script, though, if you execute them later without giving them a special function environment. Confused yet?) Do you mean something like this: Enemy_DumbEnemy = { } Enemy_DumbEnemy["Health"] = 100 Enemy_DumbEnemy["Update"] = function(param) --Do something end Enemy_DumbEnemy["OtherFunction"] = function(param) --Do something else end So by doing that I won't be able to access the globals from the functions? Could then in another file I have: Enemy_SmartEnemy = { } Enemy_SmartEnemy["Health"] = 200 Enemy_SmartEnemy["Update"] = function(param) --Do something smart end Enemy_SmartEnemy["OtherFunction"] = function(param) --Do something else smart end It should be noted I'll probably use LuaBind, so I could use lua::object variables to reference these tables. However, I'll still run into the problem of how to handle different instances of smart enemy for example. I could store the instance dependent variables (like current health) in a seperate table I suppose, and then just import them in for each entity like you said. [Edited by - M_Johnson on November 29, 2007 11:12:58 AM]
  13. Use of Lua_State

    Can global's contain different values though by using different lua_states? Did you mean a table in code or in lua? Also a quick question slightly unreleated. Let's say you load two seperate scripts using the same lua_state and both scripts contain a global variable called 'a' for example, when trying to access the global 'a' how do you specify which one to access?
  14. Use of Lua_State

    I meant global to the script, not the program as a whole. Let's say I define a variable in script called health which will initially contain the maximum possible health but decrease when the entity is hit with a bullet. I need this health variable defined inside the script to remain persistant for each entity instance, so one entity instance can have a different health value than another, and let's say each script has an update function defined in it, when the code calls this function that function should have access to the calling instaneces specific health value, so it can act accordingly like run away or something. The thing is I'm not sure how to approach this other than having seperate lua states. I'm trying to avoid having variables definied in code and then the script simply manipulating them, I'd rather the script held it's own.
  15. Use of Lua_State

    Hi, I'm making a small 2D space shooter but I want to make it an open platform so I'm going down the scripting route. I have two classes Entity and EntityInstance, Entity basically contains a map of attributes (things like health, maximum speed, weapons etc) that are common between all EntityInstances of it's kind (Entity types are loaded from XML files). EntityInstance is the instantiation of those Entities in the engine. Now each EntityInstance is pretty generic (it contains code for position, basic movement and animation but not much beyond that) so the specifics of each EntityInstance will have to be done in script. I've decided to use Lua for scripting due to it being both easy to write and also relatively easy to set up. My question is the scripts will contain their own global variables (such as current health, selected weapon etc) and it's own logic (such as an update function which is called from code) meaning that I'll need a seperate Lua stack for each EntityInstance, so does this mean each EntityInstance will have to hold it's own Lua_State and I'll have to load and compile the script each time for each EntityInstance, or could I do something like hold a single Lua_State in the Entity class and spawn child states off of this entity state for each instance, would that work, meaning manipulating the variables in script for one instance won't affect the others?