Gamer Pro

  • Content count

  • Joined

  • Last visited

Community Reputation

172 Neutral

About Gamer Pro

  • Rank
  1. Prompting and Passing problem

    Again, without straight up giving you the answer and trying to nudge you along the right path:   What is happening is you are assigning the entire list to 'script' and 'user_name' when what you want is only one element from that list (per variable). While I disagree with Lysy with the list unpacking suggestion in this situation (simply because not every element in the list is required), that is my own personal bias and it is a valid solution. I would suggest reading up on list unpacking (good to know at any rate) and lists in general.   More specifically, to retrieve an element from a list you must 'index' into it. Don't worry, it's very easy to do.
  2. Prompting and Passing problem

    Without straight up giving you the answer and trying to nudge you along the right path:   argv is the list of arguments you give to python, in this case argv = ["", "script", "user_name"]. If you were to print argv, this is what you'll see. You assign your 'script' and 'user_name' variables to argv, this means: argv = ["", "script", "user_name"] script = ["", "script", "user_name"] user_name = ["", "script", "user_name"]   So, when you are printing either 'script' or 'user_name', you are printing the string representation of that list.
  3. I've changed my plan of attack to more inline with Theta* pathfinding (not sure if that's an actual thing or just the name the guy came up with, However, I still need to determine if two points have a 'line of sight' with each other (the entire vector is in a nav mesh, though not nessessary in the same nav mesh).    Any ideas?
  4. Hello all. I am working on pathfinding and I am using navigation meshes. I am using A* and have it working. However, as I'm sure most of you know, there's a 'jagged-ness' to the calculated path. I am using the vertices of the various navigation meshes to calculate my path (hence, for me, the jagged-ness). Now the beauty of navigation meshes so that any point on a nav mesh to reachable to any other point on the same nav mesh. So I am trying to put two and two together by using raycasting/line-of-sight/whatever to smooth out my path.   I don't know how.   My current plan is to post process my calculated path to make it smoother. This will be done by taking the starting point and checking if it has a line-of-sight to the goal, if not check if the starting point has a LoS to the point before the goal and so on. When a LoS is found a path from the start to the point is created, and the process starts again with the found point being the new 'starting point'. Sounds good, but I have a problem with the line-of-sight part.   I don't know how.   My current plan (regarding the LoS issue) is to calculate a polygon 'outline' that covers the navigation meshes (IE: I'm taking several (overlapping/connected) polygons and 'adding' them together so any overlapping parts are removed and I have a single silhouette polygon). Once I have that, I can simply check if a ray from point-to-point crosses said polygon's edge, if it does then there's no LoS. Of course, I have a problem calculating the outline polygon.   I don't know how.   So my question is: How do I calculate the polygon outline from set of overlapping/connected polygons? Or, perhaps even, is this dumb and is there a better way to do this?
  5. I'm not actually worried about efficiency, it's simply a problem I came across and what curious as to what other's have done to remedy the situtation.   The reason I am implementing my own solution and not using a framework such as Artemis, is that I am learning about ES/ECS. I have a much better understanding of something when I implement it so that when I use it I know what is going on in the background; or so I can make a more informed decision between frameworks; or any number of situations that I could find myself in where that understanding could be helpful.   So, while I may not be worried about efficiency, this is still a 'design' decision that can have serious repercussions down the line (if this were a real framework that I were to use). As such, I'm curious to what other's that done to provide a broader understanding; after all, someone could have thought of a solution that I never would have thought of.
  6. More questions, yay.   I'm looking for a way to efficently implement 'nodes'. 'Nodes' being nodes in Ash, or Aspects in Artemis; that is to say, they are a collection of components an entiy must have for a system to affect said entity. EG: The movement system affects entities with position and velocity, so entities with those components have a 'movement' node which the movement system then effects.       Background: So, my ES implementation is setup like so: I have a World object that has an entity manager and a system manager. The system manager keeps track of the various systems (that's about all I have right now, as I'm just starting to work on systems now). My entity manager manages entities and their components. It has a hash that takes in a component name and returns a component manager. It also has another hash that takes in a component name and return's a component ID. A component manager manages its (one type of) component. Basically, it keeps it's component storage (an array) as densely packed as possible (to save memory) and translates a component ID to the actual component data structure. The end result is that entity #5 may have position #0 (which the position component manager may translate to be x=100, y=50) and velocity #8 (which the velocity manager may translate to be x=-3, y=10).       The problem: I originally designed the component manager as I did to keep the array densly packed to save memory and to speed up system execution. However, system execution is now complicated because the components that belong to an entity can be spread throughout the various component arrays (as seen above). This means, as it stands, the movement system can't take velocity at index 1 and apply it to the position component at index 1 because they can belong to different entities.   However, I really like the space savings offered by my current implementation of my component manager. If I have 3,000 entities and each entity only has 3 components, then, on average, each array is 1,000 big rather than the more naive each array is 3,000 big (as an example, I'm just throwing out numbers).       My solution: The solution I've come up with is to implement 'nodes', data structures that contain components and have a one-to-one relationship with systems. EG: The movement system requires movement nodes, that contain the position and velocity components; the render system requires render nodes, that contain position and sprite components; etc.   Every time an entity is created or changed (components added/removed) a 'updateNodes' function is called that will update the nodes belonging to that entity. This means if an entity has a position, it does not have a movement node (requires position and velocity); however, when the entity has a velocity component added, a movement node is created which is then used in the movement system. Likewise for velocity being removed, the movement node is removed/destroyed and is no longer affected by the movement system.   Components in a node are pointers. This way if a component is altered (such as by the movement system), the component data is altered and is correct for all the other nodes that use that component (such as the render node, which is used by the render system and has the updated position value).   The problem I have with this potential approach is that it destroys caching. No longer can systems run along an array and update components and have prefetching work (for lack of a better term), because of the indirection I am now jumping around in memory and have lost a key aspect of Entity Component Systems.   To get around that, I could have nodes have a copy of the data; but now I run into the problem of 'what if a system changes a node's component, it's no longer the same for the other nodes that use the same component'.       So, as always, I'm curious as to what other people have done.
  7. Determining if a 3D point is in a 3D polygon

    Thanks WiredCat, I'll give your code a try but I don't understand what it's doing.
  8. Determining if a 3D point is in a 3D polygon

    I'll explain what I'm doing (the fun part of learning something new is you think you're explaing things / using the right lingo but you're not). Keep in mind this is a rough and simple implementation for learning purposes, but by all means critique it and offer suggestions.   I have several 2D SVG maps. On each map I use 1 layer for destinations (areas) and on another layer I have my nav meshes. I import the map into my program and on system startup, the pathfinding system provides a bunch of operations so pathfinding can occur faster when it's needed.   It goes through each point (vertex) and determines its neighbours. It does this by comparing each nav mesh edge to all the others and determines if they are parallel, colinear, coplanar or disjoint for O(n2) complexity. Each point is then stored in an array (so I can reference them via index) and each point's neighbour is stored in a hash with the point ID (index) as the key and it's neighbours as the value. Then it iterates through each destination and determines which points are inside it. This is stored in another hash with the destination as the key and the point IDs inside it as the value. This is done by checking each nav mesh point (vertex) is within it's area. The starting point's neighbours are determined by checking which nav mesh it's inside of and making each nav mesh vertice a neighbour of the starting point.   I'm stuck on the determining whether or not a nav mesh vertex is inside a destination area. In my first implementation, PNPOLY worked great as I had one map, with this iteration I am adding several 2D floors so the problem is now, I have a 3D point and I am trying to determine if it's side the 2D destination (polygon). However, my next step is to extrude the floors to make them 3D and the problem becomes if a 3D point is inside a 3D area (polyhedron) and I figured to just skip the 'multiple 2D floors' step and go straight 3D.
  9. Determining if a 3D point is in a 3D polygon

    I've looked at the links you've provide clb but they don't work for me. They are (from what I can see) calculating whether or not a point is contained within a polygon. This is not what I'm looking for. I used the wrong word because I was jumping back and forth between 2D and 3D and got confused. I'm looking for how to determine whether or not a point is in a polyhedron.   I have a destination 'box' in 3D and I'm trying to determine which (if any) 3D navigation mesh points are inside of it. I say my navigation meshes are in 3D is because a nav mesh at point 1,2,0 is NOT the same as a nav mesh at point 1,2,1 because the z component is different (the points are on different floors). This means the starting point can be on floor 1 and my destination area could span floors 1 and 2 with the only entrance on floor 2. So the system must figure that it needs to path to a ladder/staircase/elevator/whatever to get to level 2 so it can reach the area's goal point.   I apologize for the confusion. I never said my mapping implementation spanned multiple levels and I can see how that has caused some confusion.
  10. Determining if a 3D point is in a 3D polygon

    I saw that but I don't understand what he's talking about.   <quote> Run a semi-infinite ray up from the point, P </quote>   I'm assuming 'up' is any direction you want.   <quote> P lies below the plane of F </quote>   I'm assuming a point is below a plane if the triple product is negative?       As I said before I don't understand the math being used in the 2D section, and I don't really understand want he means in the 'Testing Point Inclusion in a Polyhedron' section. As well he says 'If the ray intersects a vertex or an edge, then you're in trouble. Consider perturbing P slightly. Simulation of Simplicity provides a better, more complicated, solution'. So because of these things, I was hoping to find another answer that would be easier to understand and not be that complicated to code.
  11. Determining if a 3D point is in a 3D polygon

    Yes, sorry I ment a polyhedron.   I'm learning navigation meshes so I'm making a mapping system to assist in the learning process. I'm starting small and adding/changing functionaliy as I get more and more indepth with navigation meshes. At this stage and had I very basic 2D implementation and am now expanding it into 3D. I have a fixed starting point (that will become moveable further down the line) and I'm trying to get the shortest path to 'area A'. When the pathfinding system intializes, it goes through all of the (at this point, fixed) destinations and tries to determine which nav mesh points are inside it; those points are stored as goal points so that when pathfinding is executed the system says 'okay, I'm starting at point #37 and I'm looking for the shortest route to either point #98, 99 or 100'.   I found to determine if a 2D point is in a 2D space (polygon), and now I'm trying to figure out how to determine if a 3D point is in a 3D space (polyhedron).       *** Edit *** Of course, now that I'm using the, you know, correct term, I'm hitting some hits on Google. Funny how that works. I'll Google around but I'd still appreciate any help. I'm thinking I good / easy way to go about it is to extend PNPoly into 3D, but unfortantly I don't understand the Math. Conceptually I understand it's firing a ray to the right and counting the number of edge's it crosses, but the Math is flying over my head.
  12. Hey guys, I need help in determining if a point is in a polygon (in 3D).   I found this:, which works great in 2D. But now I'm expanding into 3D and this method no longer works. When I Google, all i find is how to do this in 2D (such as winding numbers, or edge counting) but nothing for 3D.   Ideally, I would like an explanation of the solution with pesudo code solving the problem. This way I can understand what is going on and can confirm that I know what is going on by programing it and having it work.
  13. Alrighty, I have a question.   How do I make entities 'belong' to other entities? Such as 'this tire belongs to this car'.   In OOP: Tires: class AllWeather.... class Winter.... class Slick.... class Drag.... Car:     tires = new Slick(); So if I want to get the tires the car is using I would do something like 'tires ='.   What are the ways I can do this in ECS? I'm thinking I should add a new component (belongsTo) that I can add to entities (such as tires) that contains the entity ID of the entity that the entity belongs to. Does anyone see any problems with me doing that or have any better ideas before I go to far down this path?       *** Edit ***   I have come up with another question (I'll use the same example as above, but I'd like to have answers to both questions).   Let's say rather than being entities, a tire is a component that is built from other components (this makes more sense as a tire isn't actually a game object per se but a component of a car). How do the various ECS implementation handle having multiple components that are the same (IE: a car has 4 slick tires installed)? And since we are on the subject of components made of components, is this a good idea or should it be avoided (IE: should I have a car entity make of a body & tires components, and each body and tire component is made of smaller components)? This seems like like a stepping stone toward OOP.       To sum up: * What are the various ways to handle when an entity belongs to another entity? (This sounds to me like one of the entities should be a component, but the question stands.) * What are the various ways to handle when an entity has multiple of the same component? * Is having a component made from other components a good or bad thing?
  14. Okay, I'm making some baby steps but now I've got a question. What are some of the ways I can select an entity based on the value of a component?       Example: Say the user picks up a color bomb and uses it. They pick a color and all enemies with that color blow up. Say I have a component (A) that has several properties, one of them is color. Say I have a 'world' object responsible for the world and ideally, as game independant as possible. Say I have a 'game' object that has the world and is responsible for game specfic logic.   My first thought is there's a function (J) responsible for impleting this task somewhere inside my game object and is called when nessessary. J calls a world method that returns a list of all entities with component A (function K). K queries the entity manager for said list and returns it (K is a middle man). Now J has a list of entities with component A and can filter out those that do not have the desired color and do its thing.   This seems either like an odd way to do it, or more complicated than it needs to be; so I'm curious as to the different ways to do this.
  15. Okay, thanks guys. I think I have a better understanding that will help me get started. I think now I'll have to start coding and allow myself to get dirty and make mistakes to make the next step in learning. Thanks a lot!