# Question
Title: How do I store and handle time in social game?
I intend to develop a social game on flash like farmville. I have got a problem in event time handling though. For Example, if I breed a horse in game and I don't feed it every hour then its health points will decrease. If I log out of the game for 3 days, when I log in again the horse will be dead. I was thinking I would save the last time the user fed the horse in a database, then when the user logs in again I will compare the current time with the time stored in the database.

The problem is, I think this is not an efficient way of doing it. Can anyone show me a more efficient way of doing that?

I'd appreciate anyone who could show me a way.

# Answer
Thinking about the bigger picture may be helpful.

First where do you store the current state of their entire "farm". It's obviously not on the user side. It must be on the server side. If you are storing the entire state of the farm which would include each horse and the amount of energy they have then you are correct.

This is how I would handle it.

You store the farms current status which is made up of everything and their current decaying energy value. The rate of decay is where time comes in. It is a function based on how much they were fed and how fast the energy from said food decays. You don't store their feed times, you store their current state and the last time of update for the entire farm.

When they send a request for an update then you look at their last overall update time and then send back the new state of the farm and all of the decayed energies.

The update request is going to be the same whether it be right when they log in, or in a polling situation every 10 seconds. Client side if you want a finer time window than 10 seconds you can have their client update the decayed values, but always verify when the new server update comes in 10 seconds. (Or whatever time frame you choose)

So Old Solution:

New Solution:

EDIT: Just to clarify to anyone that didn't get his concern, he probably didn't like storing a last update time for each and every object in the farm. My optimization is to store a global one and instead store energies and user their respective decay functions on global updates
> 2 votes

# Answer
If I am understanding your question right, while the user is logged in and playing, time moves in normal, real-time fashion. If that is the case, you could rely on a wrapped time source where you can manipulate the current reference point in time.

I know your question specifically mentions Flash and my code example here is in Java, but I believe it should be easily adaptable for your needs:

```
  public class TimeSource {
    private static Long staticStart = System.currentTimeMillis();
    private static Long fixPoint = System.currentTimeMillis();

    public static void setCurrentTimeMillis(Long currentTimeMillis) {
        staticStart = System.currentTimeMillis();
        fixPoint = currentTimeMillis;
    }

    public static Long getCurrentTimeMillis() {
        Long offset = System.currentTimeMillis() - staticStart;
        return fixPoint + offset;
    }
  }

```

Basically when the application starts up, we initialize to the current time in millis. However, if we set an alternate time as our "current" then the offset is calculated and used to generate the time whenever it is requested.

In the case of your game, you can set the current time to 0 when the game is very first initialized for a new user. Then, time will proceed as normal during play. When the user ends their session, you can store the current game time and restore that when the user logs in again.

Now all of your elapsed time logic can be based just on in-game time.
> 0 votes

# Answer
Thanks for your replies. I have an idea that I will store info of time in files. Everyboy have a separate file store their "last-times". How do you think about that? would reading and writing file speed is faster than call in database?
> 0 votes

# Answer
Having such restrictions on your players would get extremely annoying for them very quickly. You're effectively forcing them to be online and playing your game nearly 24/7.

What will happen when a user can't log on for a few days because they're on a vacation? All their animals and plants would die, there might be other disasters. Not very userfriendly.

Better to stop the timer when the user logs off, and start it again when he next logs on. Effectively their farm only exists when they're on the server (except of course that noone can buy land on its area, if you're working with such a system).
> 0 votes

# Answer
If you are concerned with the volume of operations in the database, you should have a look at a databse that supports sharding well. As your query path is essentially a key lookup you are free to choose from a number of databases. I would recomend MongoDB as it has native drivers for many languages, and is extremely easy to manage.

I would not recommend you store this in files, as a database system can better optimize performance by keeping part of the data in ram and apply indexing on keys (depending on file system file access performance can degrade quite dramatically as the number of files in a folder increases). Also, when you need to distribute load to more servers it is much easier when you have a database that can do sharding and balancing for you.
> 0 votes

---
Tags: flash
---


# Question
Title: What are some effective methods for implementing downsampled transparency?
It seems that some games have managed to implement downsampled transparency, and presumably gained a significant performance boost. (Examples: Uncharted 2, Crysis 2) A while back I attempted to implement a form of this based off of an article in GPU Gems 3, but we found that it wasn't quite fast enough to be a win for us.

I'm looking for information on other techniques of implementing downsampled transparency, especially targeting the PS3 and Xbox360.

# Answer
> 3 votes
I found a good GDC presentation on how they did it in Halo Reach.

EDIT: Found another method, for upsampling in 1 pass without redrawing the effects. It uses Bilateral Upsampling, but that one upsampling pass is apparently very expensive.

And yet another method: Nearest-Depth Upsampling. This one looks more promising, faster than Bilateral Upsampling, and it claims it was actually used in Batman: Arkham Asylum.

---
Tags: rendering, xbox360, playstation3, transparency
---


# Question
Title: Drawing a set of VBOs with one draw command in OpenGL. Is there a glMultiDrawElements for VBOs?
I have a few hundred VBOs, and I want to only draw a subset of the VBOs each frame.

Is there anything faster than binding and drawing each VBO? Is there a batched draw command for multiple VBOs?

1. How do I bind multiple VBOs?
2. Is there a version of glMultiDrawElements for sets of VBOs?

# Answer
Usually this is solved by trying to stuff as much as possible into a single VBO. You can store multiple, unrelated primitives/meshes in a single VBO and then separate them with array indices/ranges.

Binding multiple VBOs or drawing from a set of VBOs is not possible, AFAIK.
> 2 votes

# Answer
There is extension called primitive restart, which can maybe help you, but you will have to have only one big VBO.

Also - if you want to use multiple VBOs, you can try extension unified buffer memory, which is faster then binding.

But what I know, there is no way to draw multiple VBOs (you can have bound only one VBO at a time).
> 2 votes

---
Tags: opengl
---


# Question
Title: Real time shadow casting in a 2D isometric game
I'm writing a small 2d isometric engine in C++ and I'm trying to implement real time shadow casting. I followed a simple approach described on this page and here is the result (light is located at the same position than the yellow cube):

The result is very nice but there are missing shadows on walls and on the top of cubes. Here is an example of how it should look like (I've draw expected shadows in green):

All the cubes drawn are simply made of 3 2D quads located at a X-Y position and with a Z depth (z = x + y). I use OpenGL with an orthographic matrix (glOrtho). Shadows are drawn using the stencil buffer.

I'm looking for resources or solutions that would help me complete this shadow casting implementation.

Thanks a lot!

# Answer
> 7 votes
For roof and walls, you may try to determine intersections between your wall segments and generated shadows regions. You need two pass rendering of your shadows. First one will do what you are doing today (in memory storage). Second pass will calculate intersections of roof and wall. Last stage is real rendering. DeadMG is wrong, you can do that.

Note: for roof you have to intersect shadow area and roof area.

# Answer
> 1 votes
Solution described is not full 3d as he doesn't need full 3d solution. It will look like but it is not. Creation of shadow casting must be considered as intersection between volume. What he needs is less complicated. Remember (if you have kown) dooms and dooms like rendering engine. All processing were done on two dimensions.

# Answer
> 0 votes
Fundamentally, what you're looking for can't be done. You want to take a bunch of 2D objects and have them cast shadows as if they were 3D objects. If you want to have full 3D shadows, you need to have 3D objects.

# Answer
> 0 votes
Given that you want this game to be small, what about just saying that the current shadow implementation is good enough?

I admit that I have not seen this in action, that is, I have not seen how disturbing or non-disturbing the shadow imperfections will be when this games is running live with dynamic objects and dynamic light sources *but* judging from your images, I'm very tempted to say "it's good enough, now focus on getting the game completed". If the current implementation happen to be small and execute fast and fixing what you perceive to be problems will turn the code big and slow, I think you are better of not worrying about those shadows.

I know, I know, suggesting "don't try to solve the problem" as a solution to a problem might be a bad practice. Still, I honestly want to say that it really is good as it is if you want a small footprint for your code.

---
Tags: opengl, 2d, graphics-programming, shadows, isometric
---


# Question
Title: My Ambient lighting is not working correctly
I'm having a problem when using ambient lights in my opengl game.

When I first started with my program, i had a positioned light, and the code was this:

```
GLfloat AmbientColor[] = {1.0f,1.0f,1.0f,1.0f};
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT,AmbientColor);
    ////////POSITIONED LIGHT
    GLfloat LightColor0[] = {0.9f,0.9f,0.7f,1.0f};
    GLfloat LightPos0[] = {0.0f,900.0f,1000.0f,1.0f};
    glLightfv(GL_LIGHT0,GL_DIFFUSE,LightColor0);
    glLightfv(GL_LIGHT0,GL_POSITION,LightPos0);

```

When doing this, I had a well lit area with no problem.

Once I changed my matrix to `GL_MODELVIEW`, I noticed that my lights were not equal on each face.

I changed my code to look like this:

```
GLfloat AmbientColor[] = {1.0f,1.0f,1.0f,1.0f};
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT,AmbientColor);
    ////////POSITIONED LIGHT
    GLfloat LightColor0[] = {0.9f,0.9f,0.7f,1.0f};
    glLightfv(GL_LIGHT0,GL_AMBIENT,AmbientColor);

```

Once I used this code, only the mountains in my terrain were lit up, and anything perfectly flat was not lit at all(completely black...)

So my question is - How would I use my ambient light correctly?

Example code would be nice, thanks.

# Answer
I'm assuming you've already done: glEnable(GL\_LIGHTING); glEnable(GL\_LIGHT0);

After you set up your modelview matrix (a popular example is gluLookAt()), then you should call glLightfv(GL\_LIGHTi, AmbientColor). You need to do this every frame, not once. The position you give is transformed by the modelview matrix and stored. Thus, if your modelview matrix changes (which it typically changes every frame), then you need to call glLightfv(GL\_LIGHTi, GL\_POSITION, ...) again.

Getting black patches that *depend on your camera angle* is a sign that the angle between the camera and the light is taking part in the lighting. If you are truly do just ambient lighting, it should NOT - that is a factor of **DIFFUSE** lighting. Check your diffuse color on the light/material. If you ARE use diffuse color, check the glLightfv() call (as above), make sure your projection matrix is correctly initialized, and finally, that your vertex normals make sense. Remember, scaling in the modelview (e.g. glScalef()) scales the normals as well. For a simple solution, you can try enabling autonormalization by glEnable(GL\_NORMALIZE) - but generally this is frowned upon because it is usually unnecessary (see GL\_RESCALE\_NORMAL).

The fixed function light model is a long equation to say the least. What effect are you trying to achieve by ambient lighting? It is generally used to give a low default amount of light to a scene, and that is done with a global ambient factor. A simplified (no spot lights, specular, attenuation) equation is:

Color = Global.ambient\*Material.ambient + LightFactor\[0\] + LightFactor\[1\] ... + Material.emissive

where LightFactor\[i\] = Light.ambient\*Material.ambient + Light.diffuse\*Material.diffuse\*dot(Light.DirVector, Vertex.Normal)

If we apply that your example, you get:

Color = 1.0\*Material.ambient + 1.0\*Material.ambient + Light.diffuse\*Material.diffuse\*dot(Light.DirVector, Vertex.Normal)

This sums the material's ambient color twice, which almost definitely not what you want.

If you just want to apply a small uniform amount of light to everything, then set your global ambient to a small factor like {0.2, 0.2, 0.2, 1.0}, your light's ambient to {0.0, 0.0, 0.0, 0.0}, and your material's ambient to {1.0, 1.0, 1.0, 1.0}. Thus if a shape is entirely outside of a light, it gets a minimum of {0.2, 0.2, 0.2, 0.2} color (dull gray).

OpenGL fixed-function lighting confusing at first, but stick with it.

Edit: or go on to shaders.
> 5 votes

# Answer
I'm not really understanding what you've done. You say "change my matrix," and I assume "glMatrixMode(SOME\_MATRIX)." But the current matrix mode will not have any affect on anything you do until you make some GL call that changes the "current" matrix.

So it sounds to me like somewhere you changed the current matrix and then things started going awry. So I would check for calls to glFoo() made between that call (where you change the matrix mode) and where you draw your model, where glFoo() is a method that affects the current matrix.

That said, no matrix should affect ambient light, assuming the "fixed pipeline" functionality of OpenGL (this assumes you're not writing your own shaders; in other words, that you're using the built-in functionality of OpenGL that has existed for many years).

As I understand it, in the "fixed pipeline" mode (which uses "Phong Shading"), a light has a given ambient contribution, and any material has an attribute that affects how much ambient light it receives. The result is that every fragment ("potential" pixel) in an affected primitive is drawn with the same ambient lighting. In fact, if the only lighting that was enabled was ambient, you'd be drawing primitives that had a uniform color (and intensity).

You said in your original question that one of your problems is that lights are not equal on each face. This implies that either (1) the difference in lighting is not an effect of ambient light (since any primitive drawn with the same light and material will have identical ambient lighting) or (2) that the faces have different light models or different material models (or perhaps (3) you're writing your own shaders and doing something odd).

To recap, I don't think changing any matrix has anything to do with your lighting problems unless you're making a glFoo() call that would cause a primitive to effectively be oriented differently toward a particular light, in which case the problem should have nothing to do with ambient light (and may have something to do with one of the other "types" of lighting).
> 2 votes

---
Tags: opengl, c++, lighting
---


# Question
Title: How can I automate high-level user interactions to test correctness of my game?
I am trying to automatically simulate the game experience in my programming game. I think Expect is the way to do it because it creates its own tty for the process, becoming independent process of the main process but I want that some key sequence is pressed down in some pattern, such as press the key Z down every minute or press this that with this that pauses, without really expecting any specific file descriptors. Is there some ready programs to automate this kind of high-level debugging?

I have access to obsd and ubuntu.

# Answer
There are ways to do the high level testing, but I'll throw in my 2 cents about this approach first! I think if you instead implement unit testing on each aspect of your game, it would be a better test. If you make some test that runs whatever function is called when you input that key sequence, just provide the unit test with all key sequences that you think might break the function. If it works for all key sequences, then you know the internals for that function are good and you can go on to test the link between the input box and that function. That test is easier and you only need to make sure the data gets passed to the function. After all of that works, then the testing above that is usually done by play testers, or in your case you. The top level test would need to be done either way.

Now, to answer your question, before I knew what unit testing was, I used something called workspace macro recorder to do exactly what you're asking. Given, your program may need some sort of testing that I'm not thinking of, but if your program fits in the general scope that I'm thinking, my previous approach should be more helpful.
> 2 votes

# Answer
In short game event logging and replay is how you automate this. I don't know of any 3rd party software that does this (qualifier: SDK to integrate into app), but doing it yourself is both really easy and perhaps really hard.

You use game events to mean stuff like "pressed the X key" or "moved the mouse by (10,2)"

You play the game once recording each keystroke/mouse movement and the *precise time it occured* relative to the start of the recording. Once you are finished recording, you run the program again, but instead of generating the events from the mouse/keyboard, you simply play back the events you recorded, in order, at the right time. So, say if you found a reproducible bug that takes a few minutes of running around waving a sword or jumping into a wall, then you can record all of your actions and replay them again and see if you get the same results (if you have a deterministic engine, you should). Then you can make fixes, play it back again, etc. until the bug is fixed.

Though it isn't the same purpose, you've probably seen this method in old arcade games ('demo mode' before you insert a coin). It would have been too expensive to simply record a fullscreen demo to playback when the machines have \< 1024KB of RAM, so the they record the actions and play them back as a sort of "real-time video" or "compression".

Getting the game/engine to be deterministic is a lot harder though.
> 0 votes

---
Tags: testing, playtesting, debugging
---


# Question
Title: What are the texture coordinates for a tetrahedron
**EDIT** This is the WebGL code for initializing the tetrahedron points. You may want to skip to the second code block, because you may be able to answer without this.

```
    //Making a tetrahedron with equal sides
    //Using rotation matrices to determine the points

    //-120 degrees
    var q = -Math.PI/2.0 * 4.0/3.0;
    //Transformation matrix for X-axis rotation
    var rotationArrayX = [
        1.0,    0.0,            0.0,            0.0,
        0.0,    Math.cos(q),    Math.sin(q),    0.0,
        0.0,    -Math.sin(q),   Math.cos(q),    0.0,
        0.0,    0.0,            0.0,            1.0
    ];

    var rotationMatrixX = mat4.create(rotationArrayX);
    var d = vec3.create(new Array(0.0, 1.0, 0.0)); //Topmost point
    var a = vec3.create();
    mat4.multiplyVec3(rotationMatrixX, d, a);

    //Now we have the top most point and the first point of the base
    //After rotating the vector A with 120 degrees two times, we have the 3 base points

    //120 degrees
    q = -q;
    //Transformation matrix for Y-axis rotation
    var rotationArrayY = [
        Math.cos(q), 0.0, -Math.sin(q),     0.0,
        0.0,         1.0,       0.0,        0.0,
        Math.sin(q), 0.0, Math.cos(q),      0.0,
        0.0,         0.0,       0.0,        1.0
    ];

    var rotationMatrixY = mat4.create(rotationArrayY);

    //Calculating points B and C
    var b = vec3.create();
    mat4.multiplyVec3(rotationMatrixY, a, b);
    var c = vec3.create();
    mat4.multiplyVec3(rotationMatrixY, b, c);

    //The remaining point is the top point

    var vertices = new Array();

    //bottom
    vertices.push(a); vertices.push(b); vertices.push(c);
    //front
    vertices.push(b); vertices.push(c); vertices.push(d);
    //right
    vertices.push(c); vertices.push(a); vertices.push(d);
    //left
    vertices.push(a); vertices.push(b); vertices.push(d);

```

How should I imagine texturing these triangles? Is this a valid set of texture coordinates?

```
    var textureCoords = [
        //bottom
        0.5, 1.0,
        0.0, 0.0,
        1.0, 0.0,

        //front
        0.5, 1.0,
        0.0, 0.0,
        1.0, 0.0,

        //right
        0.5, 1.0,
        0.0, 0.0,
        1.0, 0.0,

        //left
        0.5, 1.0,
        0.0, 0.0,
        1.0, 0.0,
    ];

```

I based this on http://www.codeguru.com/forum/showpost.php?p=1542703&postcount=2:

```
  -------(0.5,1)-------
  |                   |
  |      Texture      |
  |      Image        |
  |                   |
  |                   |
(0,0)---------------(1,0)

```

Thanks in advance!

# Answer
> 5 votes
The simple answer is: Whatever you want them to be. There isn't a "right answer" here.

In effect, you've asked a question like "I have a tetrahedron, what is the right color?" Nobody can give you a meaningful answer.

You'll need to rephrase the question in a way that can be answered, such as "What are the texture coordinates of the 'bottom' face if I wanted to map the lower half of an image divided along a line extending from the upper-left corner to the bottom-right using OpenGL?"

You're asking someone to type out texture coordinates, which is somewhat silly. Humans really don't do well with visualizing texture coordinates -\> image relationships for anything more complicated than say a few triangles, and even then only if they form a simple and/or regular shape. This is why we have programs that allow us to visualize the changes without tediously typing out values.

Also, why does your tetrahedron have 5 faces? A tetrahedron has a triangular base and shares edges with 3 other triangular faces, who all share a common "top" vertex (and thus two edges each). If you've ever playing a pen & paper RPG such as Dungeons and Dragons, it is the canonical "four sided die". Just go Google Image Search "tetrahedron" to see what I mean.

At risk of sounding rude, I'd say it looks like this 'code' suffers from copy-paste syndrome. I think you need to take sometime out to read up on the fundamentals of texture mapping as a concept, maybe write some example that texture maps a single "flat" (parallel to screen) triangle to get some hands-on practice with it. Playing with a 3D editor's UV editor may help as well so you can see real-time changes as you modify the texture coordinates.

Best of luck.

---
Tags: textures, coordinates, webgl
---


title: What do I need to learn in 3DS Max?

text:
# Question
Title: What do I need to learn in 3DS Max?
I have joined a 3ds Max course. What are the diiferent part of 3ds Max which I need to learn?

He was saying that he will teach me architecture. What are the divisions of 3ds max, so that I know which things to learn?

Also, where do vray, mental ray, particle effects, and character modellings stand in 3ds max?

Is architecture alone going to be enough for me?

# Answer
> 3 votes
No one can give you an answer to this other than yourself. You need to ask yourself - What do you wanna be? What do you wanna do? What do you like?

Typically these are the areas you might want to consider specializing in when it comes to 3D:

* Modelling
* Animation
* Texturing
* Lighting
* Rendering (which is where vray and mental ray come to play)

alternatively, of course you can go ahead and learn all of these things!

If you want to become an architect you may want to consider Modelling, texturing and lighting, and possibly rendering. (Although for architecture there are better solutions than 3DSmax, such as AutoCAD)

If you like Disney/Pixar films like Toy Story you might want to consider Modelling and Animation.

The same thing also applies to game development (except maybe lighting and rendering). Game characters need to be modeled, they need to be textured, they need to be animated. Whichever one you want to learn to do is up to you

Also, 3DSMax does not specialize in any one of these areas. It's great for all of them.

---
Tags: 3dsmax
---


# Question
Title: How to implement Long Polling with PHP and flash?
I'm trying to make a multiplayer game but am a newbie to server side programming except that I know a little PHP. I learnt about this technique called long polling where the server can wait for fresh data to be available and then send it. How does one do long polling using PHP? Are there any libraries available. I'm already using ZendAMF, so how do I make zendamf and long-polling to co-exist?

# Answer
While you can, theoretically, write the server-side application to use the common request lifecycle (request -\> processing -\> response -\> stop) fronted by a HTTP server, like you would would with a website, this approach tends not to be practically feasible for most games.

When writing a game, you will probably want to look into a shared everything design, as opposed to the shared nothing, stateless design used for a webpage. The reason for this is that you will want to be able to scale to a number of concurrent users for any given session (a match in Counter Strike, for example) where the game logic depends on a shared state.

Running one instance of PHP for every user will tie up a lot of resources, as well as force you to push the game state outside of the PHP process, neither of which goes very well with either scalability or performance.

Your best bet is likely to write a stateful, event-based application that is then run in PHP deamon mode. You would bypass the web server, and deal with network programming directly.
> 1 votes

# Answer
On the client side (I do not have any experience using ZendAMF), you simply make a call with a very long timeout value, and as soon as you get a response, you make another call with another long timeout. The "long-polling" happens on the server.

On the server long-polling simply means that when your client application makes a "get" (or "post") to a PHP page, that page simply does not `exit();` until there is data to be sent. So a short loop that continually checks the status of the data until it has changed. The loop that checks data will "block" until there is data.

There maybe libraries available that help with this, but it shouldn't be necessary unless your situation is quite complex.
> 0 votes

---
Tags: flash, multiplayer
---


# Question
Title: Are there any video tutorials available for game programming with Max?
Are there any videos on how to make a small game using Max? I mean is it only done in Max or are there other things used? I am a newbie in game programming.

# Answer
> 3 votes
3DS Max is a 3D modelling tool. There are several video tutorials available all over the internet (of varying quality). However, **you can't make a game just using Max** -- all it does is modelling and rendering. You'll need to use something else entirely, or at least something else in conjunction with Max, in order to make a game.

**Blender is a similar kind of modelling tool that does have a built-in game engine that can be used.** It's also *much cheaper* than Max (because it's free). There's lots of documentation and educational material on Blender's website and elsewhere on the internet. You may also want to consider looking at Unity. There are several other game construction tools available as well.

You could also teach yourself to program -- I'd recommend Python as a first language, if you choose to do this. This will give you a lot of control and flexibility in the games you create, but it will involve a much steeper learning curve (for example if you choose to go this route you'll likely be learning to develop very simple text-based games for some time before you are ready to tackle the complexity of 3D graphics and loading 3D models and scenes exported from Max).

# Answer
> 2 votes
As the other two people have said, you cannot make a game in Max. If you are a designer/artist and you wanna get into game development there are a couple of tools available online that you might like to consider picking up:

1) **Construct:** http://www.scirra.com/construct/

This is an open source (free) game development tool targeted specifically for 2D games. It's also targeted at people like you who aren't programmers because you don't need to learn programming to use it. The interface allows you to build a game without writing any code

2) **Game Maker:** http://www.yoyogames.com/gamemaker/

Basically a similar thing to Construct. It has a free version as well as a pro version. Also doesn't require programming

3) **Game Salad:** http://gamesalad.com/

Another similar thing, except this one is Mac only.

Now these three are great if all you want to do is mess around with game development, have some fun and all, but if you're serious in getting into some real game development, unfortunately you **MUST** learn programming. That's not to say you need to be amazing at it, but you do need to know it relatively well. And the tool I very very much recommend you use if you want to get into it is called **Unity3d: http://www.unity3d.com**

Unity is a free game development tool that is very popular nowadays amongst indie developers. Its interface is very well made. Basically if you want to get into serious game development - it doesn't get any easier then Unity. You do need to write code to get stuff to happen in Unity, but in my opinion it's very easy to learn. The language you will be using in Unity is Javascript, C# or Boo. I recommend Javascript

The final option is.. don't develop games. If you want to stay in 3DSMax, go ahead and become amazing at it, then you can make content for games such as 3D models, animations, textures, etc.

Hope this helps

# Answer
> 1 votes
3ds Max is not used for programming games. It is frequently used in game development, but the relevance of 3ds Max to game development is that you can create 3D models using it and then export them to load in a game engine.

---
Tags: 3dsmax
---


title: Problem with DirectX scene-graph

text:
# Question
Title: Problem with DirectX scene-graph
I'm trying to implement a basic scene graph in DirectX using C++. I am using a left child-right sibling binary tree to do this. I'm having trouble updating each node's world transformation relative to its parent (and its parent's parent etc.). I'm struggling to get it to work recursively, though I can get it to work like this:

```
for(int i = 0; i < NUM_OBJECTS; i++)
{
    // Initialize to identity matrix.
    D3DXMatrixIdentity(&mObject[i].toWorldXForm);

    int k = i;
    while( k != -1 )
    {
        mObject[i].toWorldXForm *= mObject[k].toParentXForm;
        k = mObject[k].parent;
    }
}

```

toWorldXForm is the object's world transform and toParentXForm is the object's transform relative to the parent. I want to do this using a method within my object class (the code above is in my main class). This is what I've tried but it doesn't work (only works with nodes 1 generation away from the root)

```
if (this->sibling != NULL)
    this->sibling->update(toParentXForm);
D3DXMatrixIdentity(&toWorldXForm);
this->toWorldXForm *= this->toParentXForm;
this->toWorldXForm *= toParentXForm;
toParentXForm *= this->toParentXForm;
if (this->child != NULL)
    this->child->update(toParentXForm);

```

Sorry if I've not been clear, please tell me if there's anything else you need to know. I've no doubt it's merely a silly mistake on my part, hopefully an outside view will be able to spot the problem.

# Answer
> 2 votes
I believe what you are trying to do is simply stack the matrix of each child to generate the toWorldMatrix from a set of toParentMatrices?

Given:

```
class Object
{

   void GenerateWorldMats();

   cMatrix toWorld;
   cMatrix toParent;

   Object* mParent;
   Object** mChildren;
   uint32 mNumChildren;
};

```

You can...

```
void Object::GenerateWorldMats()
{
   if(mParent == NULL)
   {
      toWorld.Identity();
   }
   else
   {
      toWorld = mParent.toWorld * toParent;  //Or Swapped order depending on pre or post mult
   }

   for(int i = 0; i < mNumChildren; ++i)
   {
      mChildren[i]->GenerateWorldMats();
   }
}

```

---
Tags: c++, directx, matrix, scene-graph
---


# Question
Title: Is it legally possible to make a clone of the game?
With board games like "Monopoly", "Domino", "Checkers", or "Chess", can game developers make clones and sell them? Also, can I make a clone of ZX Spectrum games? Are there many parts of the game with which can do the same?

# Answer
Lawyer here for a change. You can copy all of gameplay without any issues at all. That is not copyrightable or enforceable. The things that matter are assets - art, sound, music, video, etc. For example if you take ZX game and clone it with your own assets you will be perfectly fine doing that. But if you take some asset and use it in different kind of game all together, it could be enforceable. There are loads of examples of this in the industry, for example first Warcraft basically copied Dune 2 gameplay mechanics and the genre was totally new at the time. For a more recent example - check out Gameloft company, the developer for iphone. What they do is copy successful game ideas as close as possible to the original but without using any art assets from originals. That is their successful business model. They copied games like Halo, Starcraft, World of warcraft and so on with huge success in their field. It is even funny that if you check their wow clone you may see that animations of orcs and their looks are very close to the original.

TL;DR version: As long as you copy gameplay and don't copy any assets (art, music, animation) you are 100% fine.
> 57 votes

# Answer
I might also add that if you are sued and you do not have the resources (money, time) to defend yourself, it is 100% irrelevant whether you would win or not.

When I consider the legal ramifications of something, I often ask myself "what is the likelihood that I will get sued if I do this?" as opposed to "if I were sued because of this, would I win?"
> 16 votes

# Answer
I am not a lawyer.

You've got two separate sets of games.

Chess, checkers, dominoes, etc. are very old - literally thousands of years. They obviously have no copyrights. You can make a chess game and sell it with no problems.

ZX Spectrum games and Monopoly are copyrighted/patented; that is, the game belongs to someone. You would need to seek out the copyright holders (that is, the creator of the ZX Spectrum games or Hasbro, who own Monopoly) to make a version.

You could, however, make a game where you have to buy property and build on them. You could not use Monopoly's names, places, or rules, but something very similar.
> 14 votes

# Answer
This will obviously vary a lot from country to country, but the basic idea is that you can't make an exact clone, but you can make a knock-off version. Board games tend to be covered by two aspects: the copyright on the written rules of the game, the trademarks and copyrights on the visual elements to the game.

The underlying mechanics and gameplay tend not to be covered by any legal protection. However, and this is a damn big however, as certain countries (like the US) offer software patents it seems possible that a company could indeed patent the gameplay itself. However, for popular games the mechanics are usually so common as not likely to be granted such protection.

Mostly however companies protect their brand. If your game does not infringe on their brand you are probably safe. Be careful about copying rules (this also applies to video games) too closely. If you have a game that behaves nearly identical to another but with distinct artwork I think most people would consider it a derivative work, and thus infringing on the original.

So, feel free to replicate a basic gameplay mechanic, but never duplicate graphics and avoid duplicating level-structure.
> 4 votes

# Answer
Not a lawyer and you should check with one for assurance.

There should not a problem as long as you don't copy any specific names, things or text since you cannot trademark or copyright gameplay & rules.
> 3 votes

# Answer
Dominoes, checkers, and chess are all ancient games that you can do whatever you want with. Modern games like Monopoly are trickier and the legalities can vary. First off, never copy the names because that is copyrighted. Similarly, change all the graphics because images are protected.

It's usually fine to copy gameplay because that can't be copyrighted, but watch out for patents on hit games. ~~For example, I wouldn't be surprised if the rules of Monopoly are patented.~~
> 3 votes

---
Tags: legal
---


title: Degrees to Coordinates

text:
# Question
Title: Degrees to Coordinates
Hey, I'm creating my second game ever, but this time - using Java. Before I used Pascal and CRT module! =D It's 2D game where you need to drag the ball with mouse from location A to location B. Right now, I have ball on location A and I want to make it "alive". With that I mean that it will move from location A in 135° direction until it reaches wall, then bounce the wall and move in 45° direction, then again wall - in 315° and so on.

Let's imagine that all board is 460x640 units big. So, as you can see in image above, ball's start location is 0. When the ball for the first time bounce the wall, location may be like x = 400, y = 480. In this example I have four possible directions like North, East, South and West, but in real game, when player drags the ball with his mouse, options may be more, right? I think so. So I think that I need to use degrees for it. I made list as example of what do I mean...

> 45°:
>
> x = x + .5, y = y - .5
>
> 90°:
>
> x = x + 1, y = y + 0
>
> 135°:
>
> x = x + .5, y = y + .5
>
> 180°:
>
> x = x + 0, y = y + 1
>
> 225°:
>
> x = x - .5, y = y + .5
>
> 270°:
>
> x = x - 1, y = y + 0
>
> 315°:
>
> x = x - .5, y = y - .5
>
> 360°:
>
> x = x + 0, y = y - 1
>
> 246°:
>
> x = ?, y = ?

The main problem is that I don't know how to covert degrees to coordinates and vice versa. For example I need to know x and y for 246°. Why? By knowing x and y I can move ball, because all my application basically is infinite loop that takes pause, then calculate x and y from degrees and then move ball. Please keep in mind that I'm very newbie to games development, I'm not good at math (unfortunately) and English isn't my native language... as you can see.

P.S. Maybe all idea about how-to is wrong!??

# Answer
This is pretty basic vector math stuff.

Basically, the answer you're looking for is that if you want to be 1 unit away for a given angle of x, your coordinate is going to be *( cos( x ), sin( x ) )*. You'll probably have to work in radians instead of degrees, though.

You can then take that unit vector and multiply it by whatever your per-frame velocity is to determine where you're going to be next frame.
> 3 votes

---
Tags: collision-detection, game-mechanics, coordinates
---


# Question
Title: Guidance for building a proper in game economy
I'm seriously thinking of building a space opera game which would share some of Machiavelli The Prince aspects regarding commerce: each player will be able to extract/build/buy/sell/donate a wide range of products (from ore to spaceships roughly).

However, I'm struggling with the economy aspect of it. Should the game define the prices once and for all? Should each player be able to determine his own buy/sell prices, and if so, how? How can I avoid over engineering this game economy mechanism, while still making it attractive for users?

Edit: thanks to your very nice input, some more information about the setup:

* it's a "player only game," with no "computer managed player."
* players start with a planet and some resources/units and then (try to) expand
* players can be of multiple "species" with no proper relationship apart from the one they might make up =\> no possible notion of "central bank" or similar in the first place
* consequently, I would prefer "not magic" on the economy, by that I mean a standard currency whose value would be determined by the system. However then I don't see how trading would be appealing, since bartering would be the only way, which feels a bit clumsy for the players. I was thinking of having some rare metal as the standard exchange medium, but then I wonder how would to include other basic economic attributes, such as the population's wealth...

Hopefully it doesn't look too daunting...

# Answer
> 10 votes
The main thing players want from an economy is control. A player wants to feel like advanced knowledge of the economy will yield economic rewards. This does place some responsibility on the dev but a lot comes from the players. I'm gonna refer to World of Warcraft here because I have quite a lot of experience with the in-game economy there.

Firstly, the developer's interaction with the economy should involve controlling supply and demand- that is, Item X is rare and only used in high-end play, so it's expensive. This basically entails understanding the value of each item, in general, so that you can implement point #2. Remember that specific players have specific playstyles, and may as a group trend towards favouring supplying some items over others, even if objectively they should have the same value. This means monitoring the in-game economy and trying to keep it balanced.

Secondly, you have to control the income and outcome of the economy, globally. Remember that money transferred between players remains in the system and is not infact lost. Buying items from computer-controlled vendors is an example of economic outcome- that money is permanently lost to the player economy. If there is too much income compared to outcome, money will devalue and you'll suffer large inflation. This can happen when unintended things occur, including bugs or exploits, that dramatically increase the player economy's income and often happens with new content. If there is too little income, then players will spend almost all their time farming money because they simply can't keep enjoying the content without a sufficient supply for, say, consumables/upgrades/whatever. This was especially true of the early days of World of Warcraft, where virtually all computer-controlled vendors charged very excessive prices for their wares, including essential skills. This means that even very low-level players had to spend a lot of time looking for money to keep up, instead of enjoying the content. This is easily seen by comparing the prices and rewards for quests and basic goods- in the expansions, the money earned by simple levelling was hugely increased, and the cost of basic essentials like mounts was dramatically decreased.

Income- quest rewards, drops, etc. Outcome- repair bills, buying from vendors, and soulbinding. If you spend 1000g buying an item, then it'll be soulbound to you and when you come to upgrade, that money is just gone, it's not transferred, even if you get it disenchanted then you won't get it all back by a long way. This means that you can inflict costs on your playerbase without necessarily making them pony up.

The final thing you want to offer player-based economies is organization. For example, in WoW then the most common organized economic activity is the Auction House. If you don't offer organized economy then it will be difficult for players to take meaningful control of their own economy and use it for their own ends. Of course, the degree to which you want to offer this depends on the degree to which you want to make an economic game, such as EvE.

In the end, you want to ensure that players can afford in most scenarios the basics that they need- consumables, item upgrades as befits some new status that you choose to give them, etc, and then if you want, you can make them work their socks off for the more elite status.

# Answer
> 8 votes
You've got a few different options. My preferred option is to (even if its not), make it look like a real world (or as it appears in your case, real galaxy) economy.

To do this, you want each region/store to have an initial price. Such an initial price should be broadly similar over every store, and then similar to the prices nearby. You could generate them using a very stretched, very blurred/low granular perlin noise generator. As well, a regions price should be determined by what is in the region. For instance, if there is a lot of iron available in a region, iron should be slightly cheaper owing to the standard principals of supply and demand. A nice touch is to change the landscape according to the economy - if iron is slowly getting more expensive, finding occasional iron sources being built.

These prices should then slowly change. You can make it look like supply and demand is working in the background by moving the prices slowly up and down generally, whilst adding some variation between regions. Regional pricing can then be influenced by some events as well. For instance, if the seller is selling massive, economy altering quantities of widgets, the price should be going down - a reasonable amount in the region, and a small amount globally. Which still doesn't preclude you from having a situation where there is a massive oversupply or lull in supply in one particular place - making the price far lower or higher respectively, creating the opportunity to 'exploit' the economy to provide or take away goods for massive profits. As such opportunities would be exploited by many people who can, you slowly push the price back to normal as the lull is fulfilled. A nice touch is to visibly return the economy to normal as the player does.

The selling/buying prices should be different, but similar - enough that you want to encourage your players to actually sell things (if that is what you want them to do in the game). In the real world, profit margins vary, but if your sellers are selling goods for more then about 30% more then what they're buying them, players (particularly in a game where you want to encourage money making via trade) will feel a bit ripped off. My selling would be to offer two spot prices - a buy, and sell price. You'd see them slowly moving up or down (like watch them move by a few cents as you're buying them), and even on occasion as somebody 'makes a big order', see the price suddenly jump up by 2 or 3% and then slowly go down.

Determining individual item prices can be done by rareity in the same way. The more rare and demanded an item, the more it should cost in general. The harder it is to get an item in a specific region, the more it should cost. The more that is available at a specific place, the less it should cost at that place. The more that is available everywhere, the less it should cost everywhere.

You don't have to fully simulate an economy to make a game feel like it has one that can be used, and is an actual influence on the world. If you remember basic supply demand (You can see a more full description Here), and make it look like that its workings (whether or not it actually is), your economy will feel real and generally be very playable.

# Answer
> 4 votes
Designing a virtual economy is a complicated task. It is a balancing act between your game design and artistic design; it can also involve meta-game design factors (such as your company's financial model).

Let's remember that the point of an economy is to facilitate the players transferring value between each other. Money is **generalized value**. That is to say, it should an abstract thing that you can convert into many different types of value.

What counts as value? Among other things, **power points** and **pretty points**. Power points include that Longsword of Dragonslaying and the Potion of Swiftness- things that will make your character more powerful, enabling you to **overcome more difficult challenges**. The addition of power-point-items is restricted by your game design. Pretty points include the barber-shop giving you a new hairstyle and that cute puppy pet that follows you around. They're aesthetic and **don't involve core game mechanics**. The addition of pretty-point-items is restricted by your artistic design.

Design of a good economy is largely **matching money flow to value flow**.

If an item of value is sold by a merchant, it introduces more value (the value of the item) into the world and takes money (the purchase price) out of the world. When money flow matches value flow, prices remain stable. It also makes it easier to keep money flowing between players. Here are some other game events and how they’ll affect the balance of money and value:

* Player buys an item from another player (no change)
* Player sells an item to an NPC (value--, money++)
* Player kills an NPC, who drops an item (value++)
* Player kills an NPC, who drops money (money++)
* Player spends money at an NPC blacksmith to repair armor (money--)
* Player completes a quest with a reward of money (money++)

The ways that money and value enter and leave the economy will depend on your game; the above list might work for WoW and not for your game. But you'll need to understand what events in your game will affect the amount of money and value in your game's economy.

**What are the benefits of a good economy?**

In a good economy, buying an item costs an amount of gold that matches its value. Super items cost more than basic items.

In a good economy, the price of a good item can be driven up by the players buying those items; crafters can see that, make more of the item, and the price will fall again.

In a good economy, money is just as useful for top-level players as it is for new players. There are high-level things that require money just as there are entry-level things that require money.

In a good economy, crafters can find a buyer for their product if they set a fair price. Not only that, they can sell it for more than the cost of materials. That's because materials (value) + **work (value)** = item (value).

**What are the problems of a bad economy?**

If money supply outpaces value, money will become less meaningful and people will stop accepting it in trades. If there's another item that ends up being better currency than actual money, they may switch to that (see the Stone of Jordan in Diablo II). If they can't find another suitable currency, trade will dry up; this will make certain playstyles (such as the crafter) less broadly appealing.

If value outpaces money supply, you'll typically run into the problem of hoarding: a few players will have all the money. This will dry up trade for most players, and only the few rich, well-established players will have access to the “real” economy. This makes your game less appealing to newcomers.

If your crafting system isn't balanced well- if the created items don't have the right amount of power points or pretty points- the work of a crafter will actually add negative value, and they'll have to sell their product for less than the cost of materials. Very few people will want to craft in that circumstance.

---
Tags: game-design, economy
---


# Question
Title: Messed-up triangles when using VertexPositionColorTexture with BasicEffect
Image of the problem:

I used Microsoft's BasicEffect tutorial here and the code sample here and got everything to work fine. Next, I changed everything to use vertexPositionNormalTexture, added a few small methods to help with the texture, and was able to render a textured cube just fine. I also made the cube spin a bit. Next, I wanted to try using vertexPositionNormalTexture. Unfortunately, I got this image instead of a cube. Here are some pieces of my code that contain major modifications.

Draw method

```
 protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.SteelBlue);

            RasterizerState rasterizerState1 = new RasterizerState();
            //backface culling
            rasterizerState1.CullMode = CullMode.None;
            //turn off texture blurring
            graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;

            graphics.GraphicsDevice.RasterizerState = rasterizerState1;
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphics.GraphicsDevice.DrawPrimitives(
                    PrimitiveType.TriangleList,
                    0,
                    12
                );
            }

            base.Draw(gameTime);
        }

```

Part of the method that sets up vertices

```
private void InitializeCube()
    {

        Vector3 topLeftFront = new Vector3(-1.0f, 1.0f, 1.0f);
        Vector3 bottomLeftFront = new Vector3(-1.0f, -1.0f, 1.0f);
        Vector3 topRightFront = new Vector3(1.0f, 1.0f, 1.0f);
        Vector3 bottomRightFront = new Vector3(1.0f, -1.0f, 1.0f);
        Vector3 topLeftBack = new Vector3(-1.0f, 1.0f, -1.0f);
        Vector3 topRightBack = new Vector3(1.0f, 1.0f, -1.0f);
        Vector3 bottomLeftBack = new Vector3(-1.0f, -1.0f, -1.0f);
        Vector3 bottomRightBack = new Vector3(1.0f, -1.0f, -1.0f);

        Vector2 textureTopLeft = new Vector2(0.0f, 0.0f);
        Vector2 textureTopRight = new Vector2(.25f, 0.0f);
        Vector2 textureBottomLeft = new Vector2(0.0f, .25f);
        Vector2 textureBottomRight = new Vector2(.25f, .25f);

        Color frontColor = new Color(255, 255, 255);
        Color backColor = new Color(255, 0, 0);
        Color topColor = new Color(0, 255, 0);
        Color bottomColor = new Color(0, 0, 255);
        Color leftColor = new Color(0, 255, 255);
        Color rightColor = new Color(0, 0, 0);

        // Front face.
        cubeVertices[0] =
            new VertexPositionColorTexture(
            topLeftFront, frontColor, GetTexPos(2));
        cubeVertices[1] =
            new VertexPositionColorTexture(
            bottomLeftFront, frontColor, GetTexPos(2) + textureBottomLeft);
        cubeVertices[2] =
            new VertexPositionColorTexture(
            topRightFront, frontColor, GetTexPos(2) + textureTopRight);
        cubeVertices[3] =
            new VertexPositionColorTexture(
            bottomLeftFront, frontColor, GetTexPos(2) + textureBottomLeft);
        cubeVertices[4] =
            new VertexPositionColorTexture(
            bottomRightFront, frontColor, GetTexPos(2) + textureBottomRight);
        cubeVertices[5] =
            new VertexPositionColorTexture(
            topRightFront, frontColor, GetTexPos(2) + textureTopRight);

```

Initializing `basicEffect`

```
private void InitializeEffect()
    {
        basicEffect = new BasicEffect(graphics.GraphicsDevice);

        basicEffect.World = worldMatrix;
        basicEffect.View = viewMatrix;
        basicEffect.Projection = projectionMatrix;

        //basicEffect.EnableDefaultLighting
    }

```

LoadContent

```
protected override void LoadContent()
    {
        canyonTexture = Content.Load<Texture2D>("CanyonTexture");
        textureSheetWidth = canyonTexture.Width / 16;
        InitializeTransform();
        InitializeEffect();
        basicEffect.TextureEnabled = true;
        basicEffect.VertexColorEnabled = true;
        basicEffect.Texture = canyonTexture;

        InitializeCube();

    }

```

Setting up the `VertexBuffer`

```
private void CreateVertexBuffer()
    {
        vertexDeclaration = new VertexDeclaration(new VertexElement[]
            {
                new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
                new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0),
                new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
            });

        vertexBuffer = new VertexBuffer(
            graphics.GraphicsDevice,
            vertexDeclaration,
            number_of_vertices,
            BufferUsage.None
            );

        cubeVertices = new VertexPositionColorTexture[number_of_vertices];
        InitializeCube();

        vertexBuffer.SetData<VertexPositionColorTexture>(cubeVertices);

        graphics.GraphicsDevice.SetVertexBuffer(vertexBuffer);
    }

    protected override void Initialize()
    {
        // TODO: Add your initialization logic here
        CreateVertexBuffer();

        base.Initialize();
    }

```

# Answer
Basically your vertex declaration is wrong.

A `Color` is only four bytes wide. So the offset of the texture-coordinate element that follows should be 16, not 24.

However you don't even need to create a vertex declaration for this in XNA 4.0. Simply pass `VertexPositionColorTexture.VertexDeclaration` or `typeof(VertexPositionColorTexture)` to the constructor of your `VertexBuffer`.

There is a blog post here that explains how this all works.
> 1 votes

---
Tags: xna, 3d, c#
---


# Question
Title: Is Google App Engine suitable for a real-time but single player game?
I'm in the planning stage of a new project. Without going into details, this is a real-time 2D game with some basic construction aspects, combat, and a large procedurally generated world.

Because of the design of the game, it really makes most sense for it to run directly in a browser with all of a player's progress stored on the server. Basically each player will have their own persistent 2D map which they can modify, and I want them to be able to access it from any computer. It's not multiplayer.

Imagine a real-time 2D action and building game that could be played completely offline, except it saves your progress to a server so it can be accessed from anywhere.

This will be my first foray into making an online game or web application, so I'm wanting it to be as painless as possible. Would GAE work well for a game like this? I've been told that GAE is simply not appropriate for a real-time game; however, this has always been said in the context of a multiplayer game, not a single player game.

I should also note that it would be acceptable for the game to have an ordinary save option and to only save data to the server when this option is used by the player. Since that means the player would lose progress if he just closed the tab or browser window without saving, it could be accompanied with a 5 minute autosave.

# Answer
> 4 votes
Yes, it is quite usable and I'm developing a game myself on the platform.

However, the limitation is you have to choose between HTTP requests or XMPP somehow. I'm going the HTTP route personally.

Most games use some form of secure socket connections from the server to the client, so for that kind of setup you need a dedicated server running your software, but if you can set it up as a web service or website then you'll be fine.

---
Tags: 2d, google-app-engine
---


title: Randomly generated story

text:
# Question
Title: Randomly generated story
I'm developing a game at the moment and I had an idea where the game's story line would randomly generate as the player progressed and their actions would affect the story.

Would this be a bad idea in terms of gameplay or would a storyline that has multiple endings be the best idea?

# Answer
This is a non-trivial problem. I spent a fair amount of time delving into it last year.

You will want to look into the implementation of the first ever dynamic storyteller program, TaleSpin. This was written in 1976 and still things have not progressed much further in terms of dynamic story generation. TaleSpin will give you an idea of the basic elements you would need to model. See this and this.

Ultimately, a dynamic story will hinge off agents' motivations and goals (and further, one might specify how a particular agent might go about achieving its goals). It will also work off their knowledge of the world and how that knowledge enables them to come up with solutions to meet goals in their goal stack. (Depending on how you model the problem space, and I don't doubt there are many ways, graph theory and discrete mathematics in general may come in very handy here).

Since real-life motivations/goals are often quite complex, you would need to look into how much realism you would want.

Essentially, if you want anything more than a very (and I do mean *very*) simple story generator, you have a good deal of work ahead of you. Beyond that, even, there lie issues of balancing that others have noted. Caveat emptor -- This problem is a hotbed of hidden complexity.
> 16 votes

# Answer
If you can find a copy I might recommend looking for the DnD book "Guide to Villains." To this day I wish I hadn't lost that.

The reason I bring it up is because they discuss a very interesting approach to doing a semi-random story that responds to the player's actions, called a "power matrix." In essence the story space is designed ahead of time with a bunch of characters, their relationships, and story pieces (ie. event X happens) but the specific order those events happen or even which events happen reacts to what the player's choose to do.

At the most basic level the story depends on the very first choice the players make: who they talk to when they first arrive. As soon as you talk to someone, their relationships to all the other characters determines which characters ultimately take on which roles within the story.

I've always wanted to experiment with a power matrix in a computerized game, and hopefully someday I'll have the time for such a project.
> 8 votes

# Answer
A hand written storyline is going to be much, MUCH better for the end player. A good writer who can write a storyline well will manage to convey the storyline across much better than a computer will.

A procedurally done storyline would also take a LOT of implementation. Even then, it's going to have to rely on some kind of random choices from data - it can't just make up the entire storyline.

Some games have incredibly immerseful storylines (Fallout 3, Amnesia), and they're hand written. Fallout's is slightly different, in terms that it has the karma system I mentioned..as such, the people will react differently to you (and you get different storyline options for the finale).
> 6 votes

# Answer
This is a very good idea, but one which requires too much research and development for an independent commercial software developer. I have been slowly working towards this lofty goal with the research and development of open source middleware for multimedia authoring and videogame creation for the past 20 years and am not even close to releasing product.

You see, I am increasingly nauseated by the current trend towards Cinematic Videogames.

It is a phrase that I regard as something of an oxymoron.

Developers could remedy this by realising that narrative is merely a symptom of an underlying theme. If it is the intention of the artist to convey this theme, then what does it matter to hold to a particular pre-scripted narrative?

Games are systems of rules within which interesting behaviour may emerge, often with some aspect of challenge, or competition for the player to measure their performance against. The designers of Chess and Football didn't need to fret about "Story", but despite this stories still emerged from interesting games:

http://en.wikipedia.org/wiki/World\_Chess\_Championship\_1972

http://en.wikipedia.org/wiki/Maradona#1986\_World\_Cup

However, there are a great many more matches that were dull. Being a passive spectator does not really help with engagement, yet the ideal would be to 'rig' the match so that the opponent either made deliberate mistakes, or suddenly got a whole lot better (e.g. equalising just before half-time).

Once the game's rules have been modified to make it seek entertaining levels of drama rather than boring old fairness the player's psychology can be probed by offering them a choice of actions (NPC proposed procedurally-generated missions), the successful completion of which would gain you "Kudos" for your competent role play and unlock more challenging and subtle missions as the game's personality model of the player's "alter-ego" was further refined.

This would allow games to get away from the thinly disguised corridor along which revelatory narrative scenes are encountered in the correct sequence. A game may seem to then be an Open World, but on extended interaction the player would find their choices constrained by their past actions and probably be oblivious to the subtle interventions of the game shaping the set of available choices (and their consequences), throughout in order to reinforce the underlying theme - forcing irreversible character developments, then stage-managing a cathartic climax.

Players would assume roles and try to play that part as best as they could being rewarded with Kudos for remaining "in character". Counter-intuitively, this would herald a break from players avoiding character death as this would no longer mean GAME OVER.

Indeed, heroic sacrifice, or a villain getting his comeuppance, could both be terminal for the player's character, but pay a handsome reward in terms of Kudos. The player would continue with the game, selecting from a choice of new, equivalently experienced, characters - adding equipment in keeping to the new role they were adopting from a cash sum each character had been allotted. As a result, play would have a different, dramatic, motivation rather than mere, hackneyed, survival and because the story was built in response to player psychology they would more likely be drawn in to its emergent story.

So, in summary:

Randomly generate? No.

Procedurally-generate in harmony with player psychology and a coherent theme? Yes.
> -1 votes

---
Tags: game-design, procedural-generation, random
---


# Question
Title: What are the most-valuable research fields to explore nowadays concerning game AI?
I'm having some troubles coming up with a subject for my master's degree thesis. I'd like to know what areas of research are valuable at this time (and the near future) so I can narrow my search and idea-creation.

Thanks in advance.

# Answer
Behaviour trees are a big thing in the industry right now, but from an academic perspective there hasn't been too much research into them, as far as I'm aware.

Parallelism with AI systems is an interesting area too, but I'm not too sure on what has been done with it.

Check out AIGameDev.com and in particular this link. It details a number of current open challenges with regards to FPS games.
> 2 votes

# Answer
I asked a more general question last week. This answer should be helpful.

I asked what the research areas are too, but I think a better question is, "Where can I find some resources showing the current research trends". This answer covers that fairly well.
> 1 votes

---
Tags: ai
---


# Question
Title: In which software do the professional game developers create 3D Model?
I am just thinking about beginning game development in xna c#. However, I don't know (and no tutorial teaches) how do professional game developers create a 3D Model/Scene. How can we create a realistic looking model and what is the hardware configuration needed in machine for using such a software?

# Answer
> 4 votes
Well, I have used blender to model 3D models for one of my projects however you have many choices such as 3ds max, maya, Rhino, Lightwave,cinema 4d,etc

Also for detailing you can use ZBrush3, Mudbox.

According to me 3ds max is what most Game developers use

for 3ds max

Must have: Quad core, with \>4GB ram. Good video card.

Nice to have: very top end quad core, 16GB ram, 4870 VC or better.

As for hard drives, pick up a couple of 500GB or larger, and you may want to look into RAID, possibly.

For 32-bit Autodesk Maya 2012

Microsoft® Windows® 7 Professional, Microsoft® Windows Vista® Business (SP2), or Microsoft® Windows® XP Professional (SP3) operating systems Windows: Intel® Pentium® 4, AMD Athlon™ processor with SSE3 instruction set support (or higher) 2 GB RAM 10 GB free hard drive space Qualified hardware-accelerated OpenGL® graphics card Three-button mouse with mouse driver software DVD-ROM drive HDD: IDE, SATA, SATA 2, SAS, SCSI Microsoft Internet Explorer 7.0 or higher, Apple Safari, or Mozilla Firefox web browsers

CINEMA 4D R12 and BodyPaint 3D R12

Detailed system requirements : http://www.maxon.net/products/general-information/general-information/system-requirements.html

# Answer
> 7 votes
Professionals use Autodesk Maya and Autodesk 3ds Max. Many indie developers use Blender, which is free. The XNA content pipeline has great support for the FBX file format, which is supported by both Maya and 3ds Max with a plugin. Google turns up this Blender extension to support the FBX file format, but I've never used it.

The web sites for these products will list minimum hardware requirements. They tend to require lots of memory and a modern graphics card.

# Answer
> 1 votes
3rd max is a professional 3d modelling tool, but it is only available at a high cost.

Blender is a free and open-source one.

This is 3ds max minimum requirements :

> Intel® Pentium® 4 1.4 GHz or equivalent AMD® processor with SSE2 technology\*
>
> 2 GB RAM (4 GB recommended)
>
> 2 GB swap space (4 GB recommended)\**
>
> 3 GB free hard drive space
>
> Direct3D® 10 technology, Direct3D 9, or OpenGL-capable graphics card† (256 MB or higher video card memory, 1 GB or higher recommended)
>
> Three-button mouse with mouse driver software
>
> DVD-ROM drive††
>
> Microsoft® Internet Explorer® 8.0 internet browser or higher or Mozilla® Firefox® 3.0
>
> internet browser or higher
>
> Internet connection for web downloads and Autodesk® Subscription-aware access

---
Tags: xna, c#, models
---


# Question
Title: Should I go with Windows Phone 7 or Try Android?
I already know C# and am familiar with XNA.

So it would make sense to develop for the Windows Phone 7, but would it be worth while to learn Java, get familiar with Android, and instead develop for Android devices?

Android has been around longer so it would probably have a larger user base. Is it really worth it to try to develop for one of the more popular mobile platforms. (Windows Phone 7 has been out for like a month?)

I haven't tried either one yet though. I'm also going to buy a phone, so this decision would probably influence the phone that I buy. (to develop/test on)

# Answer
> 13 votes
I would say try Windows Phone 7.

Couple of reasons I say this, first and foremost, if you are already familiar with C# and XNA then you don't need to use your first couple of projects to simply learn the language even before you start learning the platform. This might only be because I personally am rather lazy, but either way I think it's worth considering.

The bigger reason I would suggest Windows Phone 7 is this, while it's no Apple App Store, the android marketplace still has a whole lot of apps already released onto it, and that is going to make getting yours even noticed, much less popular, very difficult. Since it has been out for such a short time it's very much like getting in at the ground floor, and since you already have at least some of the required experience you can get in early before the marketplace becomes flooded.

That said, I've found a number of limitations in the API at the moment, there's some parts of the hardware that developers don't have access to for whatever reason, so that is something to take into consideration as well.

# Answer
> 8 votes
I would say try Android.

If you are already familiar with C# then it's easy to learn Java. There are some differences, but I think you can get comfortable with Java in a few days. On the other hand, XNA and OpenGL ES have different philosophies and you would need to spend time learning OpenGL (although you can get away with using the simpler Canvas class for 2D games). Whether spending time learning a new technology is worth it is a hard question to answer. It takes more time, but the knowledge is applicable beyond just Android as OpenGL (ES) is also available on iPhone and all major desktop operating systems.

There are relatively few applications available for Windows Phone 7 and you can't tell how viable of a platform it will be yet. On the other hand, Android has a growing market share and a wealth of tutorials and documentation to get you started (including the source code for a full 2D platformer). Android marketplace is not as saturated as Apple's App Store, especially when it comes to good games. You are also not limited to one market, there are alternative market applications, and you can event host your Android apps on your website. While Windows Phone has the full backing of Microsoft and a huge marketing campaign, it's still too early to predict its future performance, especially since they target higher end devices and might not directly compete with Android in certain markets. You can see Android market as a middle ground between the more mature iPhone store and the budding WP7 marketplace.

Personally, I'm comfortable with working with Android (and all that talk about fragmentation issues is a bit overrated). I don't have any experience with Windows Phone 7, although I know that you can use XNA to program for it. In the end it depends on whether you want to be an early adapter or not. Nothing stops you from making games for both systems; make an Android game now and then port it to WP7 when it gets popular enough. Try the tutorials on the Android developer site, and see how you like it. You can get pretty far with just using the emulator to try things out without needing to buy an actual device.

# Answer
> 2 votes
On the WP7 side is the ability to easily port the game for xbox360 sales on Xbox live Indie Games and possibly pick up some easy extra cash that way. Visual Studio does the heavy lifting for the port job.

# Answer
> 1 votes
We all can give your our opinions, but in the end, the choice is up to you, i like better Java, and really hate Windows (i'm a Linux guy, didn't notice :) ).

You should just try, the tool that feets better for you, and have more confidence with

# Answer
> 1 votes
I´m developing a game for Windows Phone 7, but I have an Android device and I´ll give you my point of view.

If you know C# and XNA, go for Windows Phone, you can jump straight to the game instead of learning the basics again. The marketplace is great for costumers to find stuff and buy. On the other hand you must pass a certification process first, and if you are new to gamedev in general you probably will get frustrated if your game does not pass the cert.

Now, on android, you can upload your game as is. The bad thing, is you must learn android´s architecture (not that difficult) plus some other concepts needed to develop a game. IMHO the marketplace is not as good as WP7´s.

Now, my final answer: if you can buy or borrow a WP7 device, make your game for WP7. If you can have an android, make your game for Android. Testing a game on the emulator will work for the first part of your project, but eventually you´ll need a device to test on.

Microsoft Mexico(where I live) lends devices for short periods of time, but is really hard to go to their offices to get the device. As soon as I finish my game, I´ll port it to android.

Hope the advice helps.

# Answer
> 1 votes
I would add two points to keep in consideration:

1) Platform popularity: this is a country-dependent factor. For example, at the present, in the country where I live (Italy) Android it seems to be more popular than WP7. Furthermore, it's difficult to find a WP7 phone at a reasonable price.

2) Platform hardware: on the other hand, WP7 gives you a baseline on hardware performance in which you can rely on. I played a famous race game on WP7 and the experience was amazing. In Android, when you develop a 3d game, you don't know in advance whick kind of hardware your application will run on. It might be a 150 euro phone with a poor hardware, or a 600 euro phone with a great hardware. Since the Android ecosystem is open, you must cope with many different devices. This could be hard to deal with.

Hope this helps.

---
Tags: xna, c#, java, android, windows-phone-7
---


title: Learning Shaders in XNA

text:
# Question
Title: Learning Shaders in XNA
I am trying to learn how to use Shaders for a 2D XNA project I am working on. To test them out, I was trying to make a white triangle become colored using a super simple Pixel Shader, and I can't get it to work.

This is my Pixel Shader:

```
float4 ThePixelShader(float4 texCoord : TEXCOORD0) : COLOR0
{
    return(125,15,105,1);
}

technique MandelbrotSet
{
    pass Pass0
    {
        PixelShader = compile ps_2_0 ThePixelShader();
    }
}

```

And this is the code I was using to draw my Plain white triangle onto the screen, and trying to use the shader to change its color.

```
        GraphicsDevice.Clear(Color.Black);
        spriteBatch.Begin();
        //MandelbrotEffect.Parameters[""].SetValue();
        MandelbrotEffect.CurrentTechnique = MandelbrotEffect.Techniques["MandelbrotSet"];
        foreach (EffectPass pass in MandelbrotEffect.CurrentTechnique.Passes)
        {
            pass.Apply();
            spriteBatch.Draw(Dot, new Rectangle(10, 10, 200, 200), Color.White);
        }
        spriteBatch.End();

```

I'm guessing I am doing something dumb, but I can't figure out what. The triangle is drawn on screen as just a plain white triangle, what it would look like without a shader.

EDIT: Changed my drawing code to look like this.

```
        GraphicsDevice.Clear(Color.Black);
        //MandelbrotEffect.Parameters[""].SetValue();
        MandelbrotEffect.CurrentTechnique = MandelbrotEffect.Techniques["MandelbrotSet"];
        spriteBatch.Begin(0, BlendState.Opaque, null, null, null, MandelbrotEffect);
        spriteBatch.Draw(blank, Vector2.Zero, Color.White);
        spriteBatch.End();

```

Now it does draws the box fullscreen, and I know the shader is working because changing the Alpha value does change the Alpha value of the full screen image, but still the colors don't change.

Thoughts?

# Answer
> 1 votes
After your edit it is unclear exactly what code you are using.

Replace the code in your question with the code that you are using (for example, we don't know what "the drawing part" is, since all of this code is "the drawing part").

The following code is all you need to draw a quad with the effect as desired:

```
GraphicsDevice.Clear(Color.Black);
MandelbrotEffect.CurrentTechnique = MandelbrotEffect.Techniques["MandelbrotSet"];
MandelbrotEffect.CurrentTechnique.Passes[0].Apply();
spriteBatch.Begin(0, BlendState.Opaque, null, null, null, MandelbrotEffect);
spriteBatch.Draw(blank, Vector2.Zero, Color.White);
spriteBatch.End();

```

# Answer
> 1 votes
Direct3D colours are RGBA, which means you're passing 0 for the Alpha component, which is totally transparent.

---
Tags: xna, shaders
---


# Question
Title: Replacing a custom 3D model format with something more standard
This is long, so the short question is: What's the best/right/standard set of technologies for creating 3D models and incorporating them into a game such that the complexity for the artist is kept to a minimum while also keeping things relatively sane for the game authors?

The long story:

I am a developer for an open source space game called Pioneer. We currently have a custom 3D model format based around a Lua script that defines how the various objects in the model hang together.

The existing format has a lot of flexibility. It can load Wavefront objects or build its own from polygon primitives. It has a dynamic function that can emit tailored geometry each frame based on game state. It can also define various attributes and properties such as special collision surfaces, simple waypoints (use for automated docking with a space station), and so forth.

The feature set is more than enough for what we need right now, but its implementation leaves a lot to be desired. The actual script reader is almost 3000 lines of spaghetti. Model scripts are messy and require too much knowledge of the game engine. Matters are made worse by that fact that the original author is not readily available at the moment, so its left to others with little understanding of this system to fix things. We're also hearing some of our users say they can drive a modelling program just fine, but find the required Lua script to be completely incomprehensible. We don't want to turn these contributors away, so we need to find a way to help them.

(Some examples of model scripts, for the interested, can be found in our models repository).

As a result, I'm looking for a replacement. Ideally, I'd like to be able to point interested parties at something like Blender, tell them to draw a ship, define a few special properties and then export it, and that'd be that. On the code side, I'd very much like to be able to integrate a good third-party library that I can hand one of these files and just poke an object to get the necessary data back out. Anything that we can shift on to other, more competent projects is a win.

My question then, is what to use? I've done some searching and the best approach at this point appears to be to require artists to export their model in COLLADA format and then write a utilty based on FCollada to convert the export to some internal format. That's a little heavier than I think I want, but keeps things as easy as possible for the artist, which is the major requirement.

I'm very new to world of 3D modelling however, so I wouldn't be at all surprised to learn that there is a better way. Recommendations of standard/best practice for this sort of thing would be greatly appreciated.

# Answer
> 9 votes
I usually keep my own format internally, and a standardised format externally. The artist only sees the standard format and my engine can only load the optimized internal format. This way you won't have to have model loading code in engine, it can all be done in some nice high level language as a compile step. I usually use a existing build system that rebuilds an art folder on demand, will only rebuild changed content.

**Pros:**

* High performance loading (data already laid out as engine wants it)
* Separation of code from engine
* Standard format for artists

**Cons:**

* Extra step for artists (can be solved with a content pipeline)
* Limited subset of features (but you have to have that anyway)

# Answer
> 5 votes
Mentioned many times on the topic of 3d model loading, AssImp is a very easy to use library that reads both .blend and COLLADA files as well as many other formats. You can use it to load models directly into your engine or use it as a conversion tool to convert to your own internal format. I think it would be a good library that suits your needs.

---
Tags: 3d, models, blender, collada
---


# Question
Title: Which game engine is compatiable with Visual Studio 2010 Ultimate and Silverlight?
I would like to use a game engine with Visual Studio 2010 Ultimate. Flat Red Ball only seems to work with Visual Studio 2008 or express edition.

You will receive "You can't add a reference to as it was not built against FlatRedBall.dll the silverlight runtime" when you try to add this reference to a Silverlight Navigation Application.

Which game engine is compatiable with Visual Studio 2010 Ultimate with Silverlight, if not Flat Red Ball?

**EDIT**

I found the solution. It is compatiable. You just need to use the right "template" and with a bit of hacking, I now have the Flat Silver Ball "template" working in Visual Studio 2010 Ultimate.

# Answer
Read widely to find your answer and hack around with the Flat Silver Ball "template".

First, download the Flat Silver Ball "template" from here: FlatSilverBallTemplate.zip

**CAUTION**: This is not exactly a VS2010 template but just a solution file containing a couple of projects. So, do not try to install it like a *real* template. This can cause you no end of pain.

Second, ensure that:

1) You unblock the three library files
2) Comment out the line `FlatRedBall.Debugging.Debugger.DestroyText();`

After that, we are ready to use Flat Silver Ball with Visual Studio 2010 Ultimate and Silverlight.
> -5 votes

# Answer
Contrary to the statements in your question, Flat Red Ball uses XNA 4 and therefore ***does*** work with Visual Studio 2010.
> 6 votes

# Answer
Unity3D
UDK using nFringe
XNA (framework, not engine)
Silverlight (2D framework, not engine)
Torque 3D

And pretty much every open source C/C++ engine ever

Support for debugging does vary among the engines.
> 1 votes

---
Tags: visual-studio, silverlight
---


title: Ball bouncing within polygon

text:
# Question
Title: Ball bouncing within polygon
I saw there are quite a number of articles and sample code regarding ball bouncing within a rectangle.

Is there any articles or sample code regarding **ball bouncing within a polygon**? I try to look into Box2D demo, I can't find one yet.

# Answer
> 0 votes
I don't know of any articles, but hopefully you can figure out how to rig it up from these suggestions below:

If it is a convex polygon, a convex hull is about as simple as it gets while still being a general solution. That topic is extremely well documented and I think every physics library has a "plane" primitive that can be used to build it. Basically, you have N planes for an N sided figure. Each plane divides space in half, the part in 'front' of the plane, and the part 'behind' it. If you had two planes making an 'X', the area that is in front of *both* forms a 'V'. If you add a *third* plane such that the front faces the inner point of the 'V', you get a closed off area that is ' in front' of all three planes. This is a triangle, and the planes form its convex hull. This extends to N-sided convex polygons fairly easily.

If it is a concave polygon, then things are a bit hairier but still manageable: just use an array of line segments. You can simulate that if a line segment isn't available by having very "thin" rectangles. This would also work for convex polygons, but it isn't as clean or as fast.

I hope this helps.

---
Tags: collision-detection, box2d
---


title: glsl demo suggestions?

text:
# Question
Title: glsl demo suggestions?
In a lot of places I interviewed recently, I have been asked many a times if I have worked with shaders. Even though, I have read and understand the pipeline, the answer to that question has been no. Recently, one of the places asked me if I can send them a sample of 'something' that is "visually polished".

So, I decided to take the plunge and wrote some simple shader in GLSL(with opengl).I now have a basic setup where I can use vbos with glsl shaders.

I have a very short window left to send something to them and I was wondering if someone with experience, could suggest an idea that is interesting enough to grab someone's attention.

Thanks

# Answer
> 10 votes
Everybody saw phong implemented. So how about:

* **water** \- there are tons of tutorials and it looks always great
* **shadow mapping** \- absolute basic in game dev. Multipass rendering is good thing to show. You can improve it with some kind of soft shadows (i highly recommend PCSS \- easy effective or Variance Shadow Maps)
* **bumpmapping**
* **parallax mapping** \- looks cool, and pretty easy if you got bump mapping done.
* **geometry shaders** (if you do hairs/fur over the polygon - could be based on lines or billboards - they will love you :)) - whitepaper from nvidia
* **mirrors**
* **post process** \- cartoon shader, old camera shader

# Answer
> 3 votes
How about metaballs ? They make for a pretty interesting demo and there is a lot you can do with shading like point lights, reflection, refraction and so on. There is also the classic terrain + water demo, in which you can have texturing, shades, displacement mapping (for the water), reflection...

# Answer
> 1 votes
I work for a school project on a rendering real time demo. Here a link to the video :http://www.youtube.com/watch?v=Gj4vvlWuL8E You will find a a link to the source code too if you are interrested. It has lots of shader effect, like water, shadow, parralax toon, motion blur, depth of field etc...

# Answer
> 0 votes
Actually making this work is way out of my depth (and it's DX11 and not OpenGL) but I found this article on Bokeh and DOF effects fascinating, and the results look really good :

How To Fake Bokeh (And Make It Look Pretty Good)

There's a follow-up here too if you're interested.

Another suggestion would be a good HDR tone-mapping algorithm, for example from Uncharted 2's John Hable's blog.

---
Tags: opengl, rendering, shaders, glsl
---


# Question
Title: How do I create menu with text in OpenGL?
How would I go about creating a menu system with fonts in OpenGL? I want to make a dungeon crawler and will need a menu for inventory and stats for the weapons. I can draw a world made out of blocks ok but I'm not quite sure how to do this.

I think I need to use the matrix that glortho applies to the matrix stack. Specifically I'm using WebGL and I don't have access to fonts so it seems like I have to create my own.

Any help with how I would go about doing this would be appreciated.

# Answer
> 2 votes
OpenGL know nothing of fonts, so you have two choices. Either use bitmap fonts (a font written into a texture) or use Canvas/HTML to display your text.

Most regular OpenGL games uses bitmap fonts.

# Answer
> 1 votes
If you're using WebGL, using the properties of the underlying 'canvas' element from which you created the context from to draw text. Don't make it harder than it needs to be until it needs to be.

# Answer
> -2 votes
Maybe I just don't understand your question, but if you want to draw text, you can use function glutBitmapCharacter.

---
Tags: opengl, webgl
---


title: Selecting all GameObjects in Unity

text:
# Question
Title: Selecting all GameObjects in Unity
I want to rotate all my GameObjects by 90 degrees. To do that I need to select all my GameObjects, how can I do so?

# Answer
To loop over all GameObjects, use the following code:

JavaScript:

```
for(var gameObj : GameObject in GameObject.FindObjectsOfType(GameObject))
{
    // modify gameObj.transform.rotation
}

```

C#:

```
foreach(GameObject gameObj in GameObject.FindObjectsOfType<GameObject>())
{
    // modify gameObj.transform.rotation
}

```

Also see the manual for FindObjectsOfType.
> 7 votes

---
Tags: unity
---


# Question
Title: How much RAM or CPU configuration is required for good rendering
I am learning 3ds max . I was just wodering if need to build a complete small village with small building , hotels , rooms , then do i need more advanced configuration . i mean how much minimum RAM will be required for to make the walk through of whole village

I am new bie so i have no idea . i mean do everything has to be in one max file or i need to make them separate then put in one scene . i am confused

# Answer
> 3 votes
How large is the village? How many polygons? How many textures? There are a lot of details left out.

Personally, in such a situation, I'd start with simple terrain rendering. Get the land working first. Second, make a single building. Get it loaded into the world and placed. Repeat step 2 until you have a village. If you're looking at being able to transition inside buildings, then you're opening up a whole new set of issues. How much detail is inside? Is a separate loading transition acceptable? Would a portal system work for that?

Third, get terrain material transitions working (road-\>grass-\>dirt).

# Answer
> 2 votes
I've noticed you're asking a lot of questions that are getting negative or zero votes, and they seem to be related to modeling. I don't know if it is a language barrier, but people here find your questions difficult to answer or somewhat off-topic.

To answer the title question directly, a modern CPU with a reasonable amount of RAM, say 1-2GB is more than sufficient. You can always check the modeling program's minimum requirements and go up from there. However, judging by the questions you ask, I think you need to spend less time asking "How much RAM or CPU configuration is required for good rendering", "Should i learn 3ds max or maya", "Should i learn 3ds max or maya", or "How much time it will take to learn 3ds Max", and just pick something and do it. Don't focus so much on the prerequisites of learning -- cut straight to the learning and doing.

Truth be told, you can use a Pentium III with a GeForce4 to model a small village if you did it in something like Wings3D. Is it ideal? For most people, probably not. Is it doable? Yes, very likely. Having a computer with more RAM/faster CPU/"Super3D Package 2011" won't make you better at modeling or learn the skills, which you seem to want to build up.

It's going to take time, blood, sweat, and tears, not computing hardware, to build a small village. Spend some time learning your programs, reading tutorials, and becoming a master of your modeling environment -- worry about your computer later. I think you'll find mundane (and mostly irrelevant) questions like "one file or many scenes" to be answered as you gain experience with you program of choice. I'd imagine the answers have a lot less to do with computer hardware and more to do with manageability and project scope.

---
Tags: rendering, 3dsmax
---


# Question
Title: What are some ways to implement variable body shapes?
Games like Ryzom and the Sims allow players to have human bodies with different shapes: wide or thin, tall or short, big noses or small, etc. It seems to me that it'd be impractical to pre-generate all possible combinations of the meshes.

What are some ways to do that? Are the meshes defined programmatically? Is it a weighted average of multiple "morph target" models?

If there is calculation to be done to determine the mesh: is it done in a "geometry shader"? Or is it done by the CPU?

Reference: The question "How to create art assets for 3d avatar editor" mentioned avatar editors and variable body elements, and that some games use morph targets and glyph bombing.

# Answer
> 3 votes
It would have to be done by the CPU- a geometry shader doesn't give the opportunity to save it's results, which would be essential, and not all devices supported by those games support geometry shaders. Achieving it could be as simple as applying a scale matrix to the whole or separate parts.

Edit: I read your related question. You should really clarify this question to be explicitly about morph target or explicitly about just scaling customization.

---
Tags: graphics, geometry, procedural, avatar
---


title: Preventing ties

text:
# Question
Title: Preventing ties
I'm working on a simple game to rate a users' preference among several styles. There are `C` classes, and the game consists of `R` rounds of comparison. At each round, the user is presented a \[pseudorandomly selected\] single representative image from each of `S` classes and chooses exactly one to be the "round winner." At the end of the `R` rounds, there cannot be a tie among any classes (i.e., one of the classes must have a higher score than all the others).

For example, say I have 3 classes (traditional, contemporary, alternative), and I want to run a 5 round game, comparing 2 classes per round.

I'm looking for an algorithm to provide as-even-as-possible sampling from each of the classes, but in such a way that it would be impossible to end the 5th round with a tie.

# Answer
Perhaps a different approach will help: You're basically after a 'winner' so perhaps a 'ladder' approach used in one-on-one sports might be what you're after. Each choice is a rung on a ladder and adjacent choices can compete, the winner swapping places. This does rely on some kind of initial ordering which could be random.

eg for C=3 Classes (a, b, c) with S=2 choices and R=5 rounds

At start: (Top) c-b-c (Bottom)

1. a vs b. b wins =\> b-a-c
2. c vs a. c wins =\> b-c-a
3. b vs c. b wins =\> b-c-a
4. c vs a. a wins =\> b-a-c (players can be fickle!)
5. b vs a. b wins =\> b-a-c (so b is overall winner!)

Admittedly the player will likely be presented with some of the same choices more than once, but you don't get a tie and in the example above, 5 rounds should be plenty to get allow the randomly placed bottom Class to 'float' to the top.

Anyway, hope this helps!
> 2 votes

# Answer
How Fixed is R? Would the Player notice if after the regular rounds of comparison, you ended the sequence with a series of direct comparisons of the tied classes?

Let's say R is 10. After 10 rounds you have A and B which are tied. Can't you do an A vs B round to force the direct comparison?

This will work better if R varies from time to time normally, so as to hide the occasions when you need a few extra rounds for tie-elimination.
> 1 votes

# Answer
Your first issue is that with your example of 3 classes and 5 rounds you can't make any selection of five comparisons where each of the three classes has an equal chance of winning given random choices by the user. That's because 5 rounds * 2 choices per round isn't a multiple of the number of classes.

Unfortunately fixing that and making it fair means you can almost always end up with a tie. The only exception I can think of is with two classes and and odd number of rounds. Other than that I don't think there's any way to rig it so that ties are impossible without adding unlimited numbers of extra rounds, or biasing the selections you present to the user.

Of course if the classes are significantly different and the number of rounds is high it's very unlikely that you'll actually get a tie. You could always just pick randomly between the tied classes if you need to pick a single winner.
> 0 votes

---
Tags: mathematics, algorithm
---