• Create Account

# M_Johnson

Member Since 05 Nov 2007
Offline Last Active Mar 18 2013 11:25 AM

### In Topic: Multiple Shadow Casters

22 March 2011 - 12:18 PM

Right you were, one of my shadow maps was flipped. Still looks weird but a little less weird.

### In Topic: Constructing Buildings

26 February 2009 - 08:41 PM

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.

### In Topic: Splitting a convex polygon in two?

21 February 2009 - 06:05 AM

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.

### In Topic: Point within rectangle problem...

20 February 2009 - 11:06 AM

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.

### In Topic: Use of Lua_State

29 November 2007 - 05:12 AM

Quote:
 Original post by SneftelNow 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"] = 100Enemy_DumbEnemy["Update"] = function(param)--Do somethingendEnemy_DumbEnemy["OtherFunction"] = function(param)--Do something elseend`

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"] = 200Enemy_SmartEnemy["Update"] = function(param)--Do something smartendEnemy_SmartEnemy["OtherFunction"] = function(param)--Do something else smartend`

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]

PARTNERS