lightxbulb

Members
  • Content count

    179
  • Joined

  • Last visited

Community Reputation

1164 Excellent

About lightxbulb

  • Rank
    Member
  1. Short answer: with code. Long answer: For example you usually have a level designer (depends on the game though) using some kind of editor to put the things in place, this editor can save all that data under some form. Then you'll need a piece of code (usually your programmer would write it or you'll use a library) that can make sense of the file you have from your editor (you may need to convert the format from the editor to something else before using it too). It would help a lot if you try to elaborate what exactly you are trying to do. From what I get up to now, you want to use unity's editor to create your scene - then get the output file and read it so you can use it in another engine. To do this you'll need to know the structure of a unity scene(?) file, and be able to make sense of each structure in the unity file and convert it to something that makes sense in your engine. You could also try another thing - write your own editor that does exactly what you want and not tons more(like Unity), which saves everything exactly in the format you need it.
  2. Simplify nodes in a grid

    You can run an algorithm on a grid - basically drop the nodes to begin with and when "draggin your road" just put a cell value of 1 for example and 0 for empty. Then you start at a cell with 1 and from there search horizontally till you reach an empty cell - then you register where it ends and you can save the coordinates and put a node there. You can do the same thing vertically and diagonally. Or you could create an instance of some structure Cell that would contain information on the 8 neighbouring cells then run an algorithm on all the cells. The other possibility is going with your variant, applying an algorithm to check for intersections and stuff, but the whole thing would get needlessly tricky.   Say I have a grid nxn, use an array to represent that grid, make every cell = 0 to begin with, whenever you draw a road put cell = 1. After this if you want you could create nodes by analyzing the grid - basically from a cell with value 1 you try to reach the end horizontally, when you reach the ends you put a node there, same for the other directions. Example(c++ code): const unsigned int n = 10; bool grid[n][n]; for(unsigned int i = 0; i<n;i++) { for(unsigned int j = 0; j<n; j++) { grid[i][j] = 0; } } int findEndHorizontallyRight(int cellX, int cellY) { if(grid[cellX][cellY]==0) return 0; int x = cellX; while(x<n-1) { if(grid[x+1][cellY]==0) { return x; } x++; } return x; }
  3. Simplify nodes in a grid

    By dragging the road - in which directions can I drag it(only vertically, only horizontally, alternating?)? This code helps a lot - so you basically want to merge roads if they "touch" or intersect?
  4. Simplify nodes in a grid

    This is not helping...Can you explain in steps, without references to simcity if possible, what you want to get from this: var path = []; path[0] = {'x':1,'y':3,'linksTo':[1],'id':0}; path[1] = {'x':1,'y':4,'linksTo':[0],'id':1}; path[2] = {'x':1,'y':1,'linksTo':[3] ,'id':2}; path[2] = {'x':1,'y':0,'linksTo':[2] ,'id':3}; Like type the structure you get, and explain by what rules you get it. As much as I like guessing games, I'd prefer knowing the rules to build the 2nd image from the first one. Just elaborate on the question and exactly what you want to get.
  5. Simplify nodes in a grid

    And how exactly do you get the 2nd image without doing anything from the first image, it doesn't make sense at least to me. I think defining what "building an intersection" would help a lot, or you could just define the whole thing in terms of a graph so people won't have to guess what you are trying to do. Or just take some time to elaborate on exactly what you want to happen - the more concise information you give - the better an answer would people be able to give.   P.S. The terms you use are more than ambiguous, and while you may have an idea in your head of what you want to make - I can guess at least 10 scenarios from what you're saying.
  6. Simplify nodes in a grid

    Can you show the image of where the original nodes were supposed to be, before what you are talking about happens?
  7. Simplify nodes in a grid

    "as simple points with the minimal amount required for any combination of path." - in your case it's not the minimal amount, I could get the same image without the node in the middle, so you actually want intersection to generate nodes at the intersections? "As you see if a user builds an intersection" - define builds an intersection - does he build it manually, or do you mean that by defining 2 roads that intersect - the program should recognize this intersection? "2 nodes are removed, one is added in the middle of the intersection, and 2 are added to the horizontal path." - I lost you here, I think I get how you get the central node, but why do you remove nodes and why do you add 2 nodes to the horizontal path?
  8. Making Enemies shoot bullets

    There are examples of engines that use the design I am talking about (Game objects inheriting from a base class Entity that has some basic variables), I am not saying it's god sent, but it's not wrong to use it in this case per say - especially since we're talking example + simple problem.     I cannot infer this from his original post, and he failed to mention it when I posted my code. I should also mention that I am thinking in terms of projectile in this case and not bullet in the sense of "hitscan"(and I am thinking in 3d). As for my naming conventions, maybe they are not the best suited, but I'm trying to get the idea across here and not any specific design patterns - you could revise my code if you believe it would help the OP.
  9. 3DS Max to DirectX Matrix

    Do not swap the y and z axis inside your engine, just swap y and z when storing the object in whatever form in your engine. Example: you have a list of vertices saved to some file, with y and z swapped, I suppose in your engine you have some sort of structure Mesh that contains a list of vertices and indices, so my idea is that when you write your load function (like Mesh* loadFrom3DS(char* filename)) just swap y and z. Pseudo-code: Mesh* loadFrom3DS(char* filename) { //...stuff... Mesh* temp= new Mesh(); float x,y,z; for(all vertices in the file) { //suppose you read the current vertex's coords into x,y,z=> temp->addVertex(x, z, y); } //...stuff... return temp; }
  10. Making Enemies shoot bullets

    It's a hint to make bullet inherit from a class with direction and position (the other reason being that in the beginning I thought like let's have it direction and an unit vector and add a double for speed and just multiply the vector when needed, but then I decided to not clutter the code as it's meant to be an example - basically I was trying to not emphasize a design for the class - keep it as generic as possible and just get the idea through), but I guess not explaining wasn't really helpful. I was thinking of adding a bunch of stuff like making a generic Entity class from which various things would inherit, have lookup by ids and stuff but eventually decided it would be too much useless code that would only serve to distract from the main idea.
  11. Making Enemies shoot bullets

    Well it depends on what you want to do, if I were you I'd implement some simple AI for the enemies as it doesn't make any sense for them to shoot non-stop. So basically you'll have a few states the enemies can be in, like idle, attacking, chasing etc. Since it's in c++ here's a sketch of what I would recommend: #include <set> class Bullet { private: Vector3 position; //encodes both the direction and speed of the projectile //basically velocity Vector3 direction; static std::set<Bullet*> bullets; static double speed; //...stuff... public: Bullet(const Vector3& position, const Vector3& direction) :position(position), direction(direction*speed) { bullets.insert(this); //...stuff... } void update(double dtime) { position += direction*dtime; //...stuff... } ~Bullet() { bullets.erase(bullets.find(this)); //...stuff... } }; class Enemy; class EnemyState { public: //...stuff... virtual void update(Enemy* enemy) = 0; }; class EnemyStateIdle :public EnemyState { //...stuff... void update(Enemy* enemy) { //do nothing } }; class EnemyStateAttack : public EnemyState { private: public: //...stuff... void update(Enemy* enemy) { enemy->shoot(); } }; class Enemy { private: Vector3 position; Vector3 direction; EnemyState* state; static std::set<Enemy*> enemies; private: static EnemyStateIdle idleState; static EnemyStateAttack attackState; public: void shoot() { //offset so the bullet won't appear in the enemy's center double offset;//=... Bullet* temp = new Bullet(position + offset*direction, direction); //...stuff... } void think() { //if player is in range do: if (state == &idleState) { state = &attackState; } //if the player is out of range do: if (state == &attackState) { state = &idleState; } } void update() { think(); state->update(this); } };
  12. Making Enemies shoot bullets

    It would help if you could post a code snippet and say in what language you are programming this. Each of the enemies should shoot in the direction he's looking right? Depending on how you encode orientation (quaternions, matrix, euler angles, axis-angle) you might need to do different things to get the vector you need. The fact that only one of the "enemies shoots bullets" would hint at the fact that apart from the orientation, you get the positions of the bullets wrong. Here's some code: class Bullet { private: static std::vector<Bullet*> bullets; Mesh* mesh; //... Vector3 direction; Vector3 position; public: //... Bullet(const Vector3& position, const Vector3& direction); } class Enemy { private: Vector3 position; Vector3 direction; public: void shoot() { Bullet = new Bullet(position, direction); //... } }
  13. Simplify nodes in a grid

    It's not readily evident what you're trying to do from your explanation.   What do you mean by "simplify", and "corrects the data", what do you perceive as incorrect? What do you mean by "update accordingly" and what would be "clean and simple", please define the problem more thoroughly - what is it exactly that you want to achieve? How does the current situation differ from what you'd like to achieve.
  14. Where should i start with programming?

    You might find this useful: http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
  15. Where to deeply learn Direct3D/X ?

    @Alessio: Actually Luna's book on d3d 11 uses xna for math. @Mate: Pick Frank Luna's book, it has the most practical approach, I'd recommend practical rendering after you're actually somewhat familiar with direct 3d. Rastertek's tutorials are good, but there are not enough explanations imo.