# Question
Title: Gravity stops when side-collision detected
Please, look at this GIF:

The label on the animation says "Move button is pressed, then released". And you can see when it's pressed (and player's getCenterY() is above wall getCenterY()), gravity doesn't work. I'm trying to fix it since yesterday, but I can't. All methods are called from game loop.

```
public void move() {
    if (left) {
            switch (game.currentLevel()) {
            case 1:
                for (int i = 0; i < game.lvl1.getX().length; i++)
                    game.lvl1.getX()[i] += game.physic.xVel;
                break;

            }
        } else if (right) {
            switch (game.currentLevel()) {
            case 1:
                for (int i = 0; i < game.lvl1.getX().length; i++)
                    game.lvl1.getX()[i] -= game.physic.xVel;
                break;
            }
        }
    }

    int manCenterX, manCenterY, boxCenterX, boxCenterY;
//gravity stop
    public void checkCollision() {
        for (int i = 0; i < game.lvl1.getX().length; i++) {
            manCenterX = (int) game.man.getBounds().getCenterX();
            manCenterY = (int) game.man.getBounds().getCenterY();
            if (game.man.getBounds().intersects(game.lvl1.getBounds(i))) {
                boxCenterX = (int) game.lvl1.getBounds(i).getCenterX();
                boxCenterY = (int) game.lvl1.getBounds(i).getCenterY();
                if (manCenterY - boxCenterY > 0 || manCenterY - boxCenterY < 0) {
                    game.man.setyPos(-2f);
                    game.man.isFalling = false;
                }
            }
        }
    }
//left side of walls
    public void colliLeft() {
        for (int i = 0; i < game.lvl1.getX().length; i++) {
            if (game.man.getBounds().intersects(game.lvl1.getBounds(i))) {
                if (manCenterX - boxCenterX < 0) {
                    for (int i1 = 0; i1 < game.lvl1.getX().length; i1++) {

                        game.lvl1.getX()[i1] += game.physic.xVel;
                        game.man.isFalling = true;

                    }
                }
            }
        }
    }
    //right side of walls
    public void colliRight() {
        for (int i = 0; i < game.lvl1.getX().length; i++) {
            if (game.man.getBounds().intersects(game.lvl1.getBounds(i))) {
                if (manCenterX - boxCenterX > 0) {
                    for (int i1 = 0; i1 < game.lvl1.getX().length; i1++) {

                        game.lvl1.getX()[i1] += -game.physic.xVel;
                        game.man.isFalling = true;
                    }
                }
            }
        }
    }
public void gravity() {
    game.man.setyPos(yVel);
}

 //not called from gameloop:    public void setyPos(float yPos) {
        this.yPos += yPos;

}

```

# Answer
Change the code that removes falling if he is on top of the block:

```
if (manCenterY - boxCenterY > 0 || manCenterY - boxCenterY < 0)
{
      game.man.setyPos(-2f);
      game.man.isFalling = false;
}

```

To code that removes falling if he is **on top of the block**:

```
if (manAboveBlock && (manCenterY - boxCenterY > 0 || manCenterY - boxCenterY < 0))
{
      game.man.setyPos(-2f);
      game.man.isFalling = false;
}

```

This is treating the symptom and not the problem however. The problem is probably that when the right key is pressed next to a wall, for a split second the player moves inside of that wall and then is corrected by moving back outside the wall. While the player is clipping into the wall his isFalling value is set to false.
> 1 votes

---
Tags: java, collision-detection
---


# Question
Title: Can an existing game be optimised by converting it to use cel-shading?
I assume it's possible to cel-shade existing games through API interception. If done properly, could this be used as a rendering optimization technique?

This means rather than doing the cel-shading on the pixel shader stage, do a few steps on the vertex side, such as reducing geometry, and lightning complexity.

# Answer
Cel shading must be done at the pixel shader level to look proper, same as most other lighting. If you do it in the vertex shader, the cel shading edges will be along triangle edges rather than smoothed across the model's shape.

Many existing games can likely be easily modded to use cel shading techniques, as you need to only replace some shaders and textures in many cases. Some engines may have a lot of extra passes and post processing work that will not look good with cel shading and which may be difficult to disable. However, the game will not look good at all without replacing a large segment of the game's existing assets.

Cel shading does tend to be less intense on hardware. It requires simpler texturing (and allows smaller and less textures to be used), simpler lighting (less lights, less shadows, simpler shaders), etc. Again, this is not something that can just be a toggle switch for optimization, because in order to look good it needs very different assets than a more realistic looking game.

Short version: a game is either made to be cel shaded or it isn't.
> 5 votes

---
Tags: directx, optimization, post-processing, cel-shading
---


# Question
Title: Looking for feedback on design pattern for simple 2D environment
I'm working in iOS.

I am trying to make a very simple 2D environment where there are some basic shapes you can drag around with your finger. These shapes should interact in various ways when dropped on each other, or when single-tapped versus double-tapped, etc.

I don't know the name for the design pattern I'm thinking of. Basically, you have a bunch of arrays named after attributes, such as "double-tappable" or "draggable" or "stackable". You assign these attributes to the shapes by putting the shapes in the arrays.

So, if there's a double-tap event, the code gets the location of it, then iterates through the "double-tappable" array to see if any of its members are in that location. And so on: every interactive event causes a scan through the appropriate array or arrays.

It seems like that should work, but I'm wondering if there's a better pattern for the purpose.

# Answer
> 0 votes
The Decorator pattern is probably what you are looking for. To quote Wikipedia: "The Decorator pattern can be used to extend (decorate) the functionality of a certain object at run-time, independently of other instances of the same class, provided some groundwork is done at design time." Please refer to the full article for implementation details.

Define DraggableDecorator, StackableDecorator, etc. and make your objects decorable as described in the article. At run-time, you can then attach whatever Decorator you want to your objects.

# Answer
> 0 votes
This might work for a small number of objects I suppose, and be convenient to code. But if you plan on having a large number of objects or shape variants I would suggest creating classes for each attribute (draggable / stackable / etc.) and have the shapes inherit the attribute classes that are to be associated with them. It would save you a lot of memory and processing on a larger scale. This method would also make the code more organized for modifying the behaviors of the attributes, it could save you a lot of time in the long run.

:)

---
Tags: 2d, iphone, sprites
---


title: Shadows shimmer when camera moves

text:
# Question
Title: Shadows shimmer when camera moves
I've implemented shadow maps in my simple block engine as an exercise. I'm using one directional light and using the view volume to create the shadow matrices. I'm experiencing some problems with the shadows shimmering when the camera moves and I'd like to know if it's an issue with my implementation or just an issue with basic/naive shadow mapping itself.

Here's a video:

http://www.youtube.com/watch?v=vyprATt5BBg&feature=youtu.be

Here's the code I use to create the shadow matrices. The commented out code is my original attempt to perfectly fit the view frustum. You can also see my attempt to try clamping movement to texels in the shadow map which didn't seem to make any difference. Then I tried using a bounding sphere instead, also to no apparent effect.

```
    public void CreateViewProjectionTransformsToFit(Camera camera, out Matrix viewTransform, out Matrix projectionTransform, out Vector3 position)
    {
        BoundingSphere cameraViewFrustumBoundingSphere = BoundingSphere.CreateFromFrustum(camera.ViewFrustum);

        float lightNearPlaneDistance = 1.0f;

        Vector3 lookAt = cameraViewFrustumBoundingSphere.Center;

        float distanceFromLookAt = cameraViewFrustumBoundingSphere.Radius + lightNearPlaneDistance;
        Vector3 directionFromLookAt = -Direction * distanceFromLookAt;
        position = lookAt + directionFromLookAt;
        viewTransform = Matrix.CreateLookAt(position, lookAt, Vector3.Up);

        float lightFarPlaneDistance = distanceFromLookAt + cameraViewFrustumBoundingSphere.Radius;

        float diameter = cameraViewFrustumBoundingSphere.Radius * 2.0f;

        Matrix.CreateOrthographic(diameter, diameter, lightNearPlaneDistance, lightFarPlaneDistance, out projectionTransform);

        //Vector3 cameraViewFrustumCentroid = camera.ViewFrustum.GetCentroid();

        //position = cameraViewFrustumCentroid - (Direction * (camera.FarPlaneDistance - camera.NearPlaneDistance));
        //viewTransform = Matrix.CreateLookAt(position, cameraViewFrustumCentroid, Up);

        //Vector3[] cameraViewFrustumCornersWS = camera.ViewFrustum.GetCorners();
        //Vector3[] cameraViewFrustumCornersLS = new Vector3[8];
        //Vector3.Transform(cameraViewFrustumCornersWS, ref viewTransform, cameraViewFrustumCornersLS);

        //Vector3 min = cameraViewFrustumCornersLS[0];
        //Vector3 max = cameraViewFrustumCornersLS[0];
        //for (int i = 1; i < 8; i++)
        //{
        //    min = Vector3.Min(min, cameraViewFrustumCornersLS[i]);
        //    max = Vector3.Max(max, cameraViewFrustumCornersLS[i]);
        //}

        //// Clamp to nearest texel
        //float texelSize = 1.0f / Renderer.ShadowMapSize;
        //min.X -= min.X % texelSize;
        //min.Y -= min.Y % texelSize;
        //min.Z -= min.Z % texelSize;
        //max.X -= max.X % texelSize;
        //max.Y -= max.Y % texelSize;
        //max.Z -= max.Z % texelSize;

        //// We just use an orthographic projection matrix. The sun is so far away that it's rays are essentially parallel.
        //Matrix.CreateOrthographicOffCenter(min.X, max.X, min.Y, max.Y, -max.Z, -min.Z, out projectionTransform);
    }

```

And here's the relevant part of the shader:

```
if (CastShadows)
{
    float4 positionLightCS = mul(float4(position, 1.0f), LightViewProj);

    float2 texCoord = clipSpaceToScreen(positionLightCS) + 0.5f / ShadowMapSize;

    float shadowMapDepth = tex2D(ShadowMapSampler, texCoord).r;

    float distanceToLight = length(LightPosition - position);

    float bias = 0.2f;

    if (shadowMapDepth < (distanceToLight - bias))
    {
        return float4(0.0f, 0.0f, 0.0f, 0.0f);
    }
}

```

The shimmer is slightly better if I drastically reduce the view volume but I think that's mostly just because the texels become smaller and it's harder to notice them flickering back and forth.

I'd appreciate any insight, I'd very much like to understand what's going on before I try other techniques.

# Answer
Have you ever noticed how when your shadow map camera moves far away from your geometry, your shadows get less accurate and more blocky around the edges? Or have you ever halved the resolution of your shadow map and noticed a similar effect? That's called a magnification artifact, and it happens when multiple pixels in screen space look up the same texel in the shadow map.

In practice, you will probably always have some magnification artifacts, it's just a matter of minimizing how obvious they are, which is what I imagine you're trying to do here. The shimmer that you see in your video comes from how you're changing the distribution of magnification artifacts every frame. If you rendered your shadow map in the corner of your screen, you would see how it's changing size and shape every frame, enlarging some areas while shrinking others.

Ideally, each pixel in screen space would have its own unique lookup value. There's been a fair amount of research into the subject, but the most straightforward solution is called Cascaded Shadow Maps. This is a technique that splits the light's frustum into several different depth groups and renders a different shadow map for each one. When your scene objects render, each pixel samples the appropriate shadow map based on the pixel's depth. With CSM you might see some artifacts around the seams where different shadow frusta intersect, but you won't have the shimmering problem.

The paper I linked discusses some other methods like Perspective Shadow Maps, which attempt to warp the shadow map such that areas that take up more screen space also take up more space in the shadow map. The advantage is that it uses less memory than CSM, but the math is pretty crunchy and supposedly some of the edge cases are tough to deal with. I haven't seen any shadow map warping schemes implemented in the wild. If you understand shadow maps well enough to implement them, CSM isn't a big step beyond that.
> 3 votes

---
Tags: xna, hlsl, shadows, shadow-mapping
---


# Question
Title: working in external actionscript file does not show anything on the screen?
I'm writing this code in Flash builder and I tested the file in flash, but nothing appears in the swf file. (no text in the screen show , i don't know why) Is there any missing property in the code? Also, when I create text or movie clip with flash tools on the stage and give it an instance name, flash builder doesn't seem to recognize it in the action script code.

```
package
{
    import flash.display.MovieClip;
    import flash.text.TextField;

    public class mark extends MovieClip
    {

        public function mark()
        {

            super();
            public var d:TextField=new TextField();

            d.text="Hello world";
            d.x=250;
            d.y=300;
            addChild(d);

        }
    }

```

# Answer
> 3 votes
The first thing I recommend you is to always start class names with a capital letter. That way you can immediately see whether something is a class or a variable.

But that is style and shouldn't ruin your code. What actually is wrong as far as I know is the `public` keyword before `var d:TextField`. You declare that variable inside a function, and variables declared inside functions can only be accessed by code that can access the scope of that function. Declaring it as public doesn't make sense (and probably doesn't work) because the outside world doesn't even know that variable exists (and can't access it).

You'll probably solve the problem by either removing the `public` keyword or moving the variable declaration out of the `mark( )` method.

---
Tags: flash, actionscript-3, flash-cs5, flex
---


# Question
Title: OpenGL Learning Material (that's up to date)
> **Possible Duplicate:**
> What are some good learning resources for OpenGL?
> Good resources for learning modern OpenGL (3.0 or later)?

So im sure there are topics on this, but alot of them list older material. And the last book: http://www.amazon.com/OpenGL-SuperBible-Comprehensive-Tutorial-Reference/dp/0321712617/ref=sr\_1\_1?ie=UTF8&qid=1346116133&sr=8-1&keywords=opengl

REALLY REALLY disappointed me. I DO NOT want to use someone else's library to learn this stuff, that bothers me SOOO much.

So I was hoping there was a newer book that goes into detail, and doesn't use some sort of library "Hiding" everything from you.

Or should I just look at older material? If so....anything thats not "too" out of date. Terrain tutorials are a plus (that's kinda my "goal").

Thanks

# Answer
> 5 votes
There are very few. Here are the only two I know of, one of which is still quite incomplete.

This first one is slowly becoming the "de facto" OpenGL tutorial.

http://www.arcsynthesis.org/gltut/

This second one is only several chapters in with no updates in a while, but hopefully if enough people pester the author he'll keep working on it. I found the writing style to be pretty good for a technical topic.

http://openglbook.com/

---
Tags: opengl, books
---


# Question
Title: Java getResourceAsStream as local resource
Before using LWJGL, I used the `Graphic` method, and there I displayed `imageicons`, and I had the picture file located in the resources. I used:

```
ImageIcon tcard = new ImageIcon(this.getClass().getResource("RCA.png"));

```

to load the image.

Now when I load textures in LWJGL, I have to use absolute paths to locate the file:

```
tcard = TextureLoader.getTexture("PNG",  ResourceLoader.getResourceAsStream("C:/RCA.png"));

```

I tried Googling, but I didn't find anything helpful. How can I load the image from the local resources like in the first example?

# Answer
> 3 votes
You can use the class file you're running your code in as a reference. So if you have the file `RCA.png` in the root directory you would use:

```
tcard = TextureLoader.getTexture("PNG", this.getClass().getResourceAsStream("RCA.png"));

```

Or if you were to have it inside an `art` directory in the root you would use:

```
TextureLoader.getTexture("PNG", this.getClass().getResourceAsStream("/art/RCA.png"));

```

---
Tags: java, textures, lwjgl, assets
---


title: Number of iterations to real time

text:
# Question
Title: Number of iterations to real time
I have an animation of traffic. I have 20 cars in road network, each car have a starting node and end node. Each car know how much distance does it need to travel in order to reach the end node. I move cars each 20 ms for 10 px. To move all cars from their start node to end node I need 60 iterations. That is 60\*20ms = 1200ms.

Now I want to convert this time, or use data that I have, to a real time where car move 50km/h. How can I do that? Any idea?

# Answer
`Distance between nodes` / `Speed` = `Travel time`

1km / 50kmh = 0.02hours

That means that if you have 1km between your nodes the time it should take a car to drive it is 1.2minutes.

Each update then should move a car by `Update step` * `Speed`. In you case that is 1/60/60/50hours * 50 = 0,00027777 kilometers. (Note that measurement units should match) More conveniently put - each 20ms car travels 0.27meters.
> 4 votes

---
Tags: animation
---


# Question
Title: Render a 3D scene in multiple windows - extended panoramic view
Is there any resource location on how to view a 3D scene from an application or a game on multiple windows or monitors? Each window should continue drawing from where the neighbouring one left off (in the end, the result should be a mosaic of the scene). My idea is to use a camera for each window and have a reference position and orientation for a meta-camera object that is used to correctly offset the other cameras (e.g. like in the above figure where the render targets of the two cameras reproduce the star when stitched together). Since there are quite some elements to consider (window specs, viewport properties, position-orientation of each render camera), what is the correct way to update the individual cameras considering the position and orientation of the central, meta-camera? I currently cannot make the cameras present the scene contiguously (and I am reluctant in working out the transformations without checking whether this is the actual way of doing things).

# Answer
> 2 votes
I've thought about doing this myself, so here are some of my thoughts

If you're lucky, you can get a good part of the information you need from the EDID data of the screens, such as supported resolutions and physical dimensions (and hence aspect ratio). On linux read-edid and parse-edid will work just fine, provided the video driver is being nice.

Unless the screens used are in a fixed, known setup, you *will* need user input though.

So personally, I would avoid AMD's Eyefinity or nvidia's Surround because they impose restrictions on what you can do.

Surround for example will only let you use screens if they support a common resolution, refresh rate and sync polarity. Eyefinity is not that strict, but different size screens of the same resolution will show the rendered image at different scales.

If you were to roll your own, there is no reason you couldn't support arbitrary mixed resolutions, display sizes, orientations, and screen setups.

Let the user specify how the screens are arranged (relative position, rotation; portrait/landscape, bezel width), and if you can't acquire the EDID of a screen automatically, also maximum resolution and screen size (diagonal) in inches.

That gives you the basic properties you need to set up the individual cameras/their projection matrices.

Now choose or let the user choose a "center" screen, this will be your camera pointing straight forward. The other screens' positions and rotations should relative to this one.

To move your entire camera setup through the world, first apply the relative translation and rotation to the two other cameras, then apply the center camera's translation and rotation to all three. This will keep your peripheral cameras in the same relative position as your center camera moves.

Now, usually you might just use the render target's resolution to set up the camera's screen size in the world. However, if instead you make the virtual size proportional to the individual screen's physical dimensions, content will appear at the same size on each screen, accounting for different pixel densities.

To make the user input easier, I suppose you could have 3D representations of the screens and let the user manipulate their properties directly, or relative to each other. (for example, allow "hinging" the secondary screens to the center one, to make adjusting the rotation easy while maintaining the aligned bezels).

Edit: As for the FOV, depending on if you use horizontal or vertical (or both, or diagonal) FOV, a screen with a wider physical size should have a proportionally wider FOV.

If you also let the user specify a rough position from which they will be viewing, this eliminates guessing though and you can just calculate the viewing angles and hence FOV for each screen from that.

# Answer
> 0 votes
There are different technologies for this, there is no standard, at least no one that i'm aware of.

The multi-monitor technology from ATI is named *eyefinity* and it's probably the most mature technology among the ones available on the market.

The eyefinity capabilities are accessible through the AMD display library SDK .

Nvidia calls its multi-monitor technology *nVidia Surround* and there are little to none informations for the developers, there is this page that mix the surround technology with the 3D technology and i don't think that is useful at all. If you are interested in this you can try to browser and ask in the Developer Zone.

---
Tags: camera, multiple-render-targets, viewport
---


# Question
Title: EXC_BAD_ACCESS error when box2d joint is destroyed
When I destroy the weldJoint in the update method (see below) I get an EXC\_BAD\_ACCESS error pointing to the line

```
world->DestroyJoint(weldJoint);

```

in the update method below:

```
    -(void) update: (ccTime) dt
{

int32 velocityIterations = 8;
int32 positionIterations = 1;

// Instruct the world to perform a single step of simulation. It is
// generally best to keep the time step and iterations fixed.
world->Step(dt, velocityIterations, positionIterations);

// using the iterator pos over the set
std::set<BodyPair *>::iterator pos;

for(pos = bodiesForJoints.begin(); pos != bodiesForJoints.end(); ++pos)
{

    b2WeldJointDef weldJointDef;

    BodyPair *bodyPair = *pos;
    b2Body *bodyA = bodyPair->bodyA;
    b2Body *bodyB = bodyPair->bodyB;

    weldJointDef.Initialize(bodyA, bodyB, bodyA->GetWorldCenter());

    weldJointDef.collideConnected = false;
    weldJoint = (b2WeldJoint*) world->CreateJoint(&weldJointDef);

    // Free the structure we allocated earlier.
    free(bodyPair);

    // Remove the entry from the set.
    bodiesForJoints.erase(pos);
}

for(b2Body *b = world->GetBodyList(); b; b=b->GetNext())    {
    if (b->GetUserData() != NULL)
    {
        CCSprite *mainSprite = (CCSprite*)b->GetUserData();
        if (mainSprite.tag == 1) {
            mainSprite.position = CGPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO);
            CGPoint mainSpritePosition = mainSprite.position;
            if (mainSprite.isMoved) {

                        world->DestroyJoint(weldJoint);

                    }
            }
        }
    }

}

```

In the HelloWorldLayer.h I set the weldJoint with the assign property. Am I destroying the joint in the wrong way? I would really appreciate any help. Thanks

# Answer
Are you sure you are not calling DestroyJoint(weldJoint) more than once?

You have a for next and as far as I can tell, weldJoint is never set to a different value during this loop. Should the if condition matches more than once in this loop you will certainly have a problem if memory is being deleted each call to DestroyJoint().

Either add a break to exit the loop once DestroyJoint is called or set the value of weldJoint during the loop.

Also, make sure the DestroyJoint() function won't mess up the for next loop either if you don't intend to exit the loop on first match.

```
for(b2Body *b = world->GetBodyList(); b; b=b->GetNext())    {

```

If you call DestroyJoint() will it effectively delete what b is pointing at? If the answer is yes, then b = b-\>GetNext() is unsafe and unpredictable.
> 1 votes

---
Tags: cocos2d-iphone, box2d, cocos2d
---


# Question
Title: GLSL vertex shaders with movements vs vertex off the screen
If i have a vertex shader that manage some movements and variations about the position of some vertex in my OpenGL context, OpenGL is smart enough to just run this shader on only the vertex visible on the screen?

This part of the OpenGL programmable pipeline is not clear to me because all the sources are not really really clear about this, they talk about fragments and pixels and I get that, but what about vertex shaders?

If you need a reference i'm reading from this right now and this online book has a couple of examples about this.

# Answer
Pretty much the vertex shader has to run on all the vertexes you provide to the pipeline. The reason is simply because the vertex shader can alter the position of the vertex. Before the vertex shader runs the renderer will have no idea whether the vertex is in or out of the frustum. I suppose more correctly it doesn't even know what a position is until told via `glPosition`; prior to this point the pipeline has no knowledge whatsoever where the vertexes are -- thus it couldn't possibly filter them.

The fragment shader will of course not be called if none of it vertexes lie within the display (this isn't guaranteed of course, but we assume the card is at least half-intelligent).

So if your question really is do you have to do your own culling of vertexes, the answer is yes.

*Of course there may be extensions which could alter this flow, but I think this covers the general case.*
> 10 votes

---
Tags: opengl, glsl, vertex, pipeline
---


title: Cocos2D Command-Line Application

text:
# Question
Title: Cocos2D Command-Line Application
Is it possible to create a terminal application which uses cocos2d? I've tried to make one using cocos2d 2.x, but it requires a MacGLView to be initialized.

I need it so that I could program a terminal application that generates a screenshot given a TMX file and an optional preferred width or height parameter (for resizing). Then I can automate the generation of map previews for my game, instead of manually taking screenshots. It's not practical to load the actual TMX and resize it inside the game (what I'm currently doing), because each TMX file has 7 layers, my tile sheet is huge, and I have lots of levels.

# Answer
After hours of doing weird stuff (like creating an app that hides the window and terminates itself upon load just to make it appear like a command line app), it turns out the solution is too simple. **Create that CCGLView yourself**. Duh.

Steps to create a skeleton cocos2d command-line application Xcode project: (Note: I'm using cocos2d 2.x, so if you're using cocos2d 1.0.1 or something, make changes where necessary)

1. Create a command line utility project with "Foundation" as its type.
2. Copy the libs folder from a generated cocos2d Xcode project into the same folder as the .xcodeproj of this project. Then drag it into Xcode, and make sure it is added to the target.
3. In target build settings, add "libs/kazmath/include" (without quotes) to "Header Search Paths", and make sure the **check box is ticked** (so that search is recursive)
4. In target build settings, Add -ObjC and -lz to "Other Linker Flags".
5. In target build phases, under "Link Binary with Binaries", add these frameworks:

* AppKit.framework
    * AudioToolBox.framework
    * OpenAL.framework
    * OpenGL.framework
    * QuartzCore.framework

Here's the source code:

```
// main.m
#import <Foundation/Foundation.h>
#import "cocos2d.h"

int main(int argc, char *argv[])
{
    @autoreleasepool
    {
        // Just create it with any rect, since it's not going to be displayed anyway
        CCGLView *view = [[[CCGLView alloc] initWithFrame:NSRectFromCGRect(CGRectMake(0, 0, 800, 600))] autorelease];

        // Update: this needs to be called, or transparencies don't work
        [view prepareOpenGL];

        [[CCDirector sharedDirector] setView:view];

        // Do stuff here
    }

    return EXIT_SUCCESSFUL;
}

```

And, voila! But without any modifications, 3 lines of error will be output (program still runs though):

```
ImageIO: <ERROR>  CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR>  CGImageSourceCreateWithData data parameter is nil
ImageIO: <ERROR>  CGImageSourceCreateWithData data parameter is nil

```

This happens because the director attempts to create the FPS labels when setView: is called, but the FPS texture file is missing. Simply comment out the method call to createStatsLabel inside CCDirector's setView: to solve the problem (CCDirector.h, around line 319).
> 3 votes

---
Tags: cocos2d, automation
---


title: jMonkey Quest Database

text:
# Question
Title: jMonkey Quest Database
I am building a game in jMonkey (Java) and I have so far only used default quest text. But now I need to start populating a lot of quests with text. My design requires A LOT of quests texts.

What is the best way to build a database of quest texts in jMonkey? I don't have a lot of real experience with databases. Is there a database that integrates well with jMonkey?

Here are the ideal properties I want in my database, in order of priority:

1. Reasonably light learning curve
2. Easy portability (in Java) to Windows, Linux, and Mac OSX
3. Good interface with Java
4. Good interface with jMonkey
5. The ability to add properties to the quests: ID, level, gender, quest chain ID, etc.

Or am I wrong in thinking I need to use some giant monster like SQL? I haven't been able to find much information on this, so are people using some non-database methods for storing things like quest text in jMonkey?

# Answer
> 3 votes
If you want an SQL database, i would recommend you the H2 database engine. It is pretty lightweight, written in pure Java and you can use it in embedded and server mode. It doesn't have so many features as "bigger" db engines do, but I think it will be enough in your case.

Also, consider Object databases. There are several options out there, but I would recommend you db4o. In my opinion, object databases are more intuitive to learn than SQL ones if you are akin to object-oriented design.

Hope this helps, and good luck with your game.

P.S. also, if you intend to sell your game, watch out for licensing

# Answer
> 1 votes
Why not try Json or XML if you want to hold large amounts of data. In my own jMonkey project I use XML currently to store all of my relevant information; though I plan to switch to JSON. Both are simple to use and parse and quest information can be edited by hand. You could maybe save a file for each quest and then place all of the quests in an archive to be loaded by reference ID when needed. I wouldn't really use SQL for this but thats just my opinion.

You could try using DOM, SAX or JAXB for XML or Kyro, Moxy or Jettison for JSON

HopeThisHelps

---
Tags: java, databases, jmonkeyengine, quests
---


title: LWJGL GL_QUADS texture artifact

text:
# Question
Title: LWJGL GL_QUADS texture artifact
I managed to get working LWJGL in Java, and I loaded a test image (tv test card), but I keep getting weird artifacts outside the image.

Code:

```
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2i(10, 10);
glTexCoord2f(1, 0);
glVertex2i(500, 10);
glTexCoord2f(1, 1);
glVertex2i(500, 500);
glTexCoord2f(0, 1);
glVertex2i(10, 500);
glEnd();

```

What could be the cause?

# Answer
Unless you explicitly set up non-power-of-two (often imprecisely called "rectangle") textures using an extension, each dimension of your texture must be a power of two.

To draw an image with a different size, add margins so that it has power-of-two sizes, then adjust your *texture coordinates* (‛glTexCoord‛) to crop off the margins.
> 3 votes

# Answer
Try setting your textures to clamp to the size of your quad and ensure that you're not setting the textures to linear interpolation. When initializing your OpenGL code, do something like this:

```
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

```
> 1 votes

---
Tags: opengl, java, lwjgl
---


# Question
Title: Free texture sites – is it safe to use their content
There are multiple free texture sites, like: texturemate.com or plaintextures.com. I am wondering how safe it is to use their content? I imagine that the texture could be withdrawed from the site, making it difficult to prove it was really there. Or: a file can origin from other, restricted source.

I am thinking about using wikipedia Commons, as there is the OTRS system. However most media requires attributing.

# Answer
Use your best judgment. I am not a lawyer, but I suspect that if you use reasonable care to ensure that the creator of the site actually has the rights to license you the images, you don't have to worry about legal concerns. If the site doesn't look shady and says that the textures are original to the site, it's unlikely that you'll get sued.

If you're especially concerned about covering your ass, perform careful documentation. Copy down the license text from the texture site as well as the source URL. If archive.org's Wayback Machine archives the site, you will be able to use it as proof that you acquired the texture in good faith.

As far as attribution goes, it's a good policy in general. Note that the attribution doesn't need to be obtrusive. Unless the content owner specifies a more draconian attribution format, you can just put a note in the credits like "concrete textures from cctextures.blah."
> 2 votes

# Answer
All "free" texture sites have terms of use and such that you can examine to see what they don't want you to do with them. Many don't want you making any money from the use of their images, especially if the site didn't charge for them.

If in doubt, email them and ask. The worst they can do is say no.
> 0 votes

# Answer
A lot of sites have their own guidelines on how you use their work. I would assume it has a terms of service/usage guidelines on how you are permitted to use the content. A lot of the sites just prefer you don't use the content to make your own profits. If you really like something you see, trying to get in contact with the original creator might be a good idea.
> 0 votes

# Answer
I'm no lawyer but for me there is a simple rule: don't use anything that don't have clearly stated information about copyright holder and usage license for particular material. Especially for the content that will be used commercially.

Also is a good idea to have written (via e-mail is enough I think) approval / permission for commercial usage. In worst case scenario, when get sued, there is a prove that this material was indeed received by xxx at yyy terms.
> 0 votes

# Answer
Safe? No, in theory and in practice not even the ones that you pay are *safe*, the fact that this images are free or not tells you nothing about their copyright and most important of all, who is the copyright holder.

The real solution is more like a good suggestion: always mix and work with this textures in way that you will never use just 1 big texture alone. If you really need a complete big texture of something you better go out with your camera and take some pictures of the natures avoiding famouse places/buildings and private spaces.
> -2 votes

---
Tags: textures, legal
---


title: Game software design

text:
# Question
Title: Game software design
I have been working on a simple implementation of a card game in object oriented Python/HTML/Javascript and building on the top of Django.

At this point the game is in its final stage of development but, while spotting a big issue about how I was keeping the application state (basically using a global variable), I reached the point that I'm stuck. The thing is that ignoring the design flaw, in a single-threaded environment such as under the Django development server, the game works perfectly.

While I tried to design classes cleanly and keep methods short I now have in front of me an issue that has been keeping me busy for the last 2 days and that countless print statements and visual debugging hasn't helped me spot. The reason I think has to do with some side-effects of functions and to solve it I've been wondering if maybe refactoring the code entirely with static classes that keep no state and just passing the state around might be a good option to keep side-effects under control. Or maybe trying to program it in a functional programming style (although I'm not sure Python allows for a purely functional style).

I feel that now there's already too many layers that the software (which I plan to make incredibly more complex by adding non trivial features) has already become unmanageable.

How would you suggest I re-take control of my code-base that (despite being still only at \< 1000 LOC) seems to have taken a life of its own?

# Answer
> 7 votes
What you experience right now is a typical consequence of keeping a complex global state. Global states, and complex global states in particular, make side effects hard to track and your code impossible to test. Which is why, whenever something goes wrong, you have to debug your system the hard way.

Your program has "only" 1.000 LOC, so not everything is lost. Just do the following:

* Watch http://www.youtube.com/watch?v=-FRm3VPhseI
* Take pen and paper and think about how you can redesign your system without global states
* Implement unit tests and make sure that your classes pass these tests
* Reassemble your classes according to your new design

---
Tags: game-design, python
---


# Question
Title: Breakout... Getting the ball reflection X angle when htitting paddle / bricks
Im currently creating a breakout clone for my first ever C# / XNA game. Currently Ive had little trouble creating the paddle object, ball object, and all the bricks. The issue im currently having is getting the ball to bounce off of the paddle and bricks correctly based off of where the ball touches the object. This is my forumala thus far:

```
if (paddleLocation.Intersects(ballLocation))
{
    position.Y = paddleLocation.Y - texture.Height;
    motion.Y *= -1;

    // determine X
    motion.X = 1 - 2 * (ballLocation.X - paddleLocation.X) / (paddleLocation.Width / 2);
}

```

The problem is, the ball goes the opposite direction then its supposed to. When the ball hits the left side of the paddle, instead of bouncing back to the left, it bounces right, and vise versa. Does anyone know what the math equation is to fix this?

# Answer
change

```
ballLocation.X - paddleLocation.X

```

to

```
paddleLocation.X - ballLocation.X

```
> 3 votes

---
Tags: xna, c#, mathematics, physics
---


title: Asset missing problem XNA

text:
# Question
Title: Asset missing problem XNA
I'm using VS2010 with XNA 4.0 and I'm trying to load an FBX model with texture on the screen. The problem I'm having is this error:

**Missing Asset: C:\Users\ChocoMan\Documents\Visual Studio 2010\Projects\XNAGame\Documents\Visual Studio\Projects\XNAGame\XNAGameContent\Textures\texture.bmp**

but the actual path to the texture is

**C:\Users\ChocoMan\Documents\Visual Studio\Projects\XNAGame\XNAGameContent\Textures\texture.bmp**

Also, when I linked the texture in Maya, I used the above address.

Does anyone know why VS is looking for an incorrect address that doesnt exist?

# Answer
Figured it out. In Maya (since I didnt create the model myself), I had to import the model, save it as an \*.mb file, delete all but the default materials, apply the default lambert materials back to the model (because removing the texture made the model green), apply a new texture (phong in my case) and attach the UV map back on it, then export it again like normal into XNA. Now the model loads plus it's textured.
> 0 votes

---
Tags: xna, 3d, textures, loading, microsoft
---


title: Matrix camera, movement concept

text:
# Question
Title: Matrix camera, movement concept
Someone told me that the movement concept in my 2D game is bad. When left or right arrow is pressed I'm scrolling the background which makes you feel that player avatar is moving (the avatar's X-position remains the same).

So... he told me something about matrix view. I should create all walls and platforms static and scroll only the camera and move the player's rectangle. I did a little research in Google, but found nothing.

Can you tell me anything about it? How to start? Maybe links, books and resources?

# Answer
> 4 votes
I don't recall where I saw the demo but I think I know what he is talking about -- or at least can provide related information.

The problem with the character not moving on the screen, being fixed at the center, is that the human player will not perceive any motion. The user will immediately feel that something is wrong, but perhaps not be able to pinpoint it. If the character is moving it is essential that some kind of actual motion is done.

One of the concepts used here is the player box. This is a region of the screen where the character always resides. Unlike a fixed location however the character can actually move all around in this box. The screen only starts to scroll as they approach the edge of the box. This means that each time the user changes directions they'll actually see their sprite move on the screen (regardless of what the background is doing).

From here you can start improving the effect by experimenting. Some games slowly center the character in the box again. Some have a kind of logrithmic box so that the first movements move the sprite a lot, but less and less as they get to the side of the box -- or this may be tied to the character's speed as well. What works well depends on your game, and by no means is there a definitive "best" solution.

# Answer
> 0 votes
In a 2D game you don't need to care about matrices regarding camera. What you should do is still add a camera to the game. In the simplest case it's just x and y coordinates, but it can also contain rotation and/or zoom.

When pressing left or right, your character X position should be updated accordingly. The world should stay static. Don't move the background or objects when the player is the one moving. You should then update the camera position to follow the player movement. You can either set the camera position to match the player position or implement something better as edA-qa mort-ora-y described. When rendering, you need to subtract the camera position from all other positions.

---
Tags: camera, movement, view
---


title: Creating a navmesh from a voxel terrain

text:
# Question
Title: Creating a navmesh from a voxel terrain
My world is represented by a 3D density field, where a positive density means solid ground and a negative (or zero) density means air. How can I generate a navmesh from that voxel data, with surfaces with a slope of 45 degrees or less being "walkable"?

# Answer
If you're already building a triangle mesh for rendering these voxels, it shouldn't be too hard to do.

For each triangle, take (or calculate if you haven't) the normal vector, make sure this vector is normalized. Then take the dot product of your "up" direction (for example \[0,0,1\] if Z is up) and this normal vector. The result is the cosine of the angle between the X/Y plane and the plane the triangle lies in.

If the result is \<= cos(degToRad(45)) it meets your criteria and can be added to the nav mesh.

Perhaps perform some pruning of islands of single triangles, or collections of triangles with a small area.
> 4 votes

# Answer
*rifles through source code*

I implemented something like this when I was still using python - it's the primary reason I moved to C++, the array work was getting too large. The solution is a little lost to time, but it went something along the lines of:

Find a value in the 3Grid that is \> 0, and has (n) values above it that are \< 0 and has not already been defined. This is the definition of "walkable" in a second 3Grid, add this point.

Find all adjacent spaces that meet the same criteria - and adjacent spaces up, and down one unit.

For each point, add a value to the original point to link, and add new point to second 3Grid with link back to original point (so the path goes both ways).

When no more consecutive points can be added, continue to scan through grid, and repeat.

This gives you a grid that you should be able to navigate without issue - my plan was to measure height at run-time.

The 45 degrees is implicit rather than explicit - an incline or decline of 1:1 is ~45 but if you're using a full marching cubes implementation you may encounter a bit of variation on this.

There are variations on this - you could generate the mesh based on the current location and ignore disconnected meshes. Or, select a range where the grid expires.

Edit: You could extend this to a nav-mesh using marching squares, if neighbouring node (including up or down) is valid, add it to the square's bitmask, otherwise leave it blank.
> 0 votes

---
Tags: ai, path-finding, voxels, navmesh
---


title: How can I implement a matchmaker?

text:
# Question
Title: How can I implement a matchmaker?
I'm making a multiplayer game, where players are separated in to rooms that would ideally have about 20 players.

So I need a few pointers on an algorithm to distribute the players in to these rooms.

A few more constraints:

* When a players gets in to a room, he should stay there until he decides to exit (the room itself changes levels)
* There may be more room servers, every server should create more rooms until near full capacity
* There's a central server that manages all the room servers, and directs the players towards their room

**EDIT**

Because the question is too specific to my game and it is very likely that I will never mention all the details necessary (because they are hidden in my brain until someone asks) I'm considering deleting this question.

I'm not deleting it any longer because I've received an interesting answer.

Although for now I'm implementing a trivial solution, and I will improve it later if needed.

# Answer
Draw a coordinate system with "number of players in a game" on the x-axis (the independent variable) and "fun" on the y-axis (the dependent variable). Add data points for each of the 1 - 20 player scenarios. Connect the data points and look at the graph you just plotted. Try to come up with a formula that characterizes the graph.

You can now compute the maximum accumulated expected fun value for all players given a certain number of players ready to play and allocate players accordingly.

You can make this system more sophisticated by adjusting the expected fun formula in various ways:

* Are there friends of the player playing in the current game (/ in a different game) that the player would like to keep (/ start) playing with?
* Has the player specified a number of players with which they like playing the game most? (I.e. has the player defined a fun graph different from your generic one?)
* Does the fun graph depend on the players' experience and skill level? For example, the game might be more fun for beginners if there are only a couple of other players around, whereas more experienced players might want to have lots of other players around.
* Does the fun graph depend on the map?
> 1 votes

---
Tags: game-design
---


# Question
Title: How can i jump to game development and continue career in 7 months?
How can i jump to game development and continue career in 7 months?

# Answer
> 2 votes
Before trying to switch your career to game development you should get some experience on actually making games. I don't believe any company would hire a game programmer without any game programming experience even as a junior.

This may sound hard. How can you get the experience if you can't get a job in the industry? You should start by programming games on your free time or by studying game development in a school. There is also the possibility of starting as an independent game developer, but it doesn't pay you any salary until you succeed.

---
Tags: game-industry, career, interview
---


title: MenuStrip in XNA 4.0

text:
# Question
Title: MenuStrip in XNA 4.0
Is it possible to place a MenuStrip into a XNA 4.0 project. This project is intended for PC-s only and I already have openFile dialogs, but I cant get the MenuStrip drawn. If this is not possible what would be a good alternative. I've been trying to get find it on create.msdn but it keeps redirecting me to the WinPhone/XBox selection page and I cant access the tutorials at all.

# Answer
> 3 votes
The way to do this is to embed it in a proper WinForms container. Here are the current links to the WinForms samples, since MS *still* haven't fixed up the old links :(

# Answer
> 1 votes
Use the official sample, depending on what you want you may need more functionality. You can find more information at the link below. It includes a link to the PC template and sample.

http://code.google.com/p/xna-game-menu/

---
Tags: xna-4.0, windows-forms
---


# Question
Title: Making a mobile app from a board game. Copyright infringement?
Me and a friend got hooked on a board game and soon realized that we didn't need the board game to play, instead we could play it with pen and paper with extreme ease and satisfaction. The next step was to develop a simple android app to play it. We have been using this to play and it's fun, and we are interested in publishing it, but we are worried eventual copyright issues. The concept of the game - itself very simple, merely a type of trivia game, where each round has different rules - is the same, the name is different as is all the art. Does anybody know if we infringe copyrights if we were to publish it?

Thanks

# Answer
There are other intellectual property rights that may protect parts of such a game. Patents and trademark, for example. Concepts or mechanics are not subject to copyright in any jurisdiction I am familiar with and no international treaties governing copyright extend the protection to game mechanics. As far as copyright is concerned, you can mimic those freely and it's done en masse.

Make sure the game is not patented and stay clear of its name and art. This will leave the creators of the original board game with very little ammunition. Of course, the usual side note applies; you don't have to do something wrong or illegal to get into legal trouble. That aside, the answer is no. You're not infringing copyrights by publishing such a game and you are as safe as you can reasonably expect to be.
> 1 votes

# Answer
As always, I am not a lawyer. If you want sound legal advice, get a lawyer.

With that said, everyone else has hit it spot on. There are things like art, titles, mechanics, words and the like you would not be able to use. In other words, **loose adaptations** of a game that are independent are usually okay.

**Examples of content to stay away from: **

* Monopoly Man Mascot
* Titles such as "The Game of Life", "Boggle", and "Word Boggle"
* Art, such as token pieces of the game board layout
* Sound and other multimedia the game may use
> 1 votes

# Answer
It probably is. What I recommend is that you contact the creator of the board game and ask them if you can publish it. If you're lucky they'll pay you to publish it, if you're not so lucky they won't even let you publish it.
> 0 votes

---
Tags: copyright
---


title: Grid based collision - How many cells?

text:
# Question
Title: Grid based collision - How many cells?
The game I'm creating is a bullet hell game, so there can be quite a few objects on the screen at any given time. It probably maxes out at about 40 enemies and 200 or so bullets. That being said, I'm splitting up the playing field into a grid for my collision checking. Right now, it's only 8 cells. How many would be optimal? I'm worried that if I use too many, I'll be wasting CPU power. My main concern is processing power, to make the game run smoothly. RAM is not a big concern for me.

# Answer
> 3 votes
you could use an algorithm to determine the number of cells based upon the number of items contained within a given cell. dynamically increasing or decreasing the number of cells dependant on the content start for example with 4 areas if one of the 4 become congested, split this up into 4 new areas. (cant for the life of me remember the name)

---
Tags: xna, collision-detection, optimization
---


# Question
Title: Is there a grey-area with Copyright infringement?
Currently a student, I'm trying to put together a game for iOS. From everywhere I've read, it seems any game's sound and art are apart of their IP and covered under their Copyright.

That being said, say I wanted to use the coin sound effect from the original Mario (less than 1s long and used sparsely)... would anyone really care? Having no experience with this, I'm just wondering if cases like this are treated like "Ya you're driving slightly over the speed limit, but nobody cares" or as "you stole that car".

Thanks for any insight anyone may be able to provide.

# Answer
The safe answer is to never use content you did not originally create. Any knowledge of using copyright protected content is obvious infringement. You can always try contacting the owner of the content and explain to them how you want to use something. They may give you permission to use it for free(for a student project or something) or may license it to you for a cost(for commercial use).

In the end though, I would definitely treat this like a "You stole that car" moment, just to be safe. You can get sunk fast when it comes to copyright.

EDIT: Found another interesting article/blog that goes into law with games. Pretty interesting blog. Going to bookmark it myself for reading later :)

NOTE: the above article seems to be based on UK law. But it gives a lot of examples about how it applies to america. So it is still relevant to both area's.
> 7 votes

# Answer
**\[Discalimer: I'm not a lawyer. I've just researched the topic a bit.\]**

In some countries, there is (what I would call) a grey area in copyright known as fair use. I believe its considered a grey area because:

> The distinction between what is fair use and what is infringement in a particular case will not always be clear or easily defined. There is no specific number of words, lines, or notes that may safely be taken without permission.

You can also determine from the article that there are certain areas where fair use is usually applied:

> Section 107 contains a list of the various purposes for which the reproduction of a particular work may be considered fair, such as criticism, comment, news reporting, teaching, scholarship, and research.

The list of bullets that follow are the reasons people justify their fair use, but are not always successful due to the grey area I mentioned above.

> * The purpose and character of the use, including whether such use is of commercial nature or is for nonprofit educational purposes
> * The nature of the copyrighted work
> * The amount and substantiality of the portion used in relation to the copyrighted work as a whole
> * The effect of the use upon the potential market for, or value of, the copyrighted work

That all being said, based on what you are asking the only argument you might have is from the third bullet above and it would be best you just make your own sound effect. As the other answers have pointed out, you really don't want to get into a lawsuit revolving around copyright.
> 7 votes

# Answer
You can't compare copyright infringement with "stealing a car" or "driving too fast" because it's not enforced by the executive. To sue you the copyright owners themselves must know you "stole" their IP, they must care enough about it and they must have the resources to sue you. Unless your product gets quite popular and isn't a complete disgrace it's unlikely.

However copyright law-suits hurts your purse, a lot. So the chance that you are sued is rather low, but if you get sued you have a biiig problem.
> 1 votes

---
Tags: ios, copyright
---


# Question
Title: Android performance/issues with Corona SDK?
I know this is a fairly broad question. We are looking to develop a mobile game and want to use a multi-platform engine/SDK. We like what we see with Corona but in doing some reading, we are seeing a lot of references to poor performance on the 'droid platforms. I am unsure how much of this is still relevant? Many of the articles/posts/references/discussions vary in date from 18 months ago to earlier this year.

Is there a reason we should not pursue Corona if Android support is important to us?

The game is going to be 2D isometric view. Thanks!

# Answer
I have worked with Corona Labs (creators of the Corona SDK) as a contractor for almost 2 years now and I can safely tell you that the majority of these issues have been resolved - Android performance has taken a lot of work to improve but it is at the stage now it's very, very solid and the threads from 18 months ago, 12 months ago and even 6 months ago can be largely disregarded. (For more info you can look at build notes summary, you will see many tweaks and improvements to Android.)

Some Android devices will always suffer poor performance, be that with a Corona made app or a native app. There are a lot of dirt cheap devices out there and having toyed with these fairly extensively myself (I develop for Android and iOS personally and for clients) I can tell you that these are going to be a problem regardless, they just aren't powerful enough for games.

Of course, Corona has an unlimited free trial so you can also test on your own Android devices without any money down, simply to see for yourself :-)
> 3 votes

---
Tags: corona-sdk
---


title: Hammer BSP file size inefficiency

text:
# Question
Title: Hammer BSP file size inefficiency
I haven't posted here before but I came across a problem, when I save a map in Hammer as `.bsp` it ends up being over 10x bigger than all of the source files put together. I found the source for one map `rp_downtown_v2.bsp`, which the map is 2mb but when I used the source and compiled it in hammer its 40MB? Why would this be? Any further help will aid thanks!

# Answer
> 1 votes
The BSP file format stores a lot of information in it. For one it takes your brushes from Hammer and performs CSG on them to create all the triangles that are to be rendered. It then calculates other complex information such as planes, edges, surfaces, visibility, etc. that is not part of the source file.

But the largest contributor to the file size would probably be the lightmaps, which are textures used to give the map shadows. Each face in the map will have a lightmap texture, so the more faces you have the more lightmaps you need. Being a texture, they take up a fair amount of space (compared to other binary data).

See this article for more information: Source BSP File Format.

---
Tags: steam
---


title: Blender: Having trouble moving vertices

text:
# Question
Title: Blender: Having trouble moving vertices
I've been using Blender for two days now, and ran into an issue while following a tutorial.

Before anything else, I'd like to show you all what my problem precisely is. Here is a short video I uploaded: click here. I thought it may be easier for you all to help me identify and solve my problem more accurately with a visual aid.

I would like to emphasize that this issue began to occur after I extruded that trapezoidal region (misstated as a parallelogram in the video). I decided that I did not want the extruded region, and just hit undo. Ever since then, I began to experience the problem you viewed.

Thanks.

# Answer
You have extra vertices overlapping. You can merge them so you can get what you're expecting.

1. Switch to edit mode like you are in your video
2. Press `B` to go into box selection mode
    1. Ensure you have deselected "Limit Selection to Visible" or switch to wireframe mode
3. Draw a box around one of the four corners your having issues with (to select all the vertices there)
4. Press `Alt+M` to merge and select center
5. Repeat for each of the 4 corners
6. Observe that you now have 1 vertex per corner and they move like you expect.
> 2 votes

---
Tags: blender
---


# Question
Title: What are some valuable conferences for game developers?
Lately I was thinking of visiting a Game Developer Conference and so I search the Internet, but I didn't find a thorough list of available Conferences. Now I know some of them, like the GDC in San Francisco but I was wondering, what other Game Developer Conferences are out there.

So my question is: What Game Dev Conferences do you know, that are valuable for Game Developers and Game Designers? Have you visited one of these Conferences yourself? Is there a skill level needed to appreciate such a Conference?

I am aware, that there is no "true" answer to this question, but I think, that an overview over existing Conferences could be usefull for all levels of game developers.

# Answer
> 4 votes
In addition to GDC, which you already noted, there are the spin-off conventions (GDC Europe, GDC China, and GDC Online in Austin, plus the Serious Games Summit).

There's also the LOGIN conference, which caters specifically to online games (casual Facebook games and MMOs, et cetera). You've also got Microsoft's Gamefest and the recently-launched PAX spinoff, PAX Dev.

Then there are the more localized conferences, such as the Christian Game Developers Conference or the Russian Game Developers Conference or something like IndieCade.

Finally, many game developers would also be interested in more generalized programming/software/technology conferences such as Build or GoingNative.

Most conferences offer a variety of different sessions or talks that will cater to a range of skill levels, so you can usually get something out of them if that's your thing. If you are unsure, try browsing the session material from previous years to get a feel for what the conference might involve -- many of them are expensive so it's good to have an idea of what you're going to get out of them beforehand.

I personally feel like the best benefit from most of the conferences I ever attended was networking, and not so much the sessions themselves -- unfortunately, very often lectures and presentations will be necessarily high-level. But the people you meet can be valuable contacts elsewhere in your career.

# Answer
> 1 votes
If you go to a conference like GDC and are worried about it being too high a level technically, there are very often tutorial days or "bootcamps" either directly associated with the conference or run nearby.
There are also specialized conferences, focusing on art or music for example:

For game art, there's CODE and SCAD's GDX to name a couple.

For Game Audio, there is also the AES conference on Game Audio, GameSoundCon and several sessions on game audio at the yearly Audio Engineering Society Conference.

Prior to attending, do some research on what's current in the game industry. Probably more important than the sessions is the networking opportunities. If you find yourself in a conversation with a potential employer and not know some of the current games, you'll be easily forgotten. Likewise, if you can talk about the good/bad things about several of the current games, you'll just as likely be well remembered.

---
Tags: game-industry
---


# Question
Title: Easiest turn-base games you can think of?
I'm planning to get into the process of programming multiplayer turn-base games. I would like to start off by making some of the simplest (yet fun) multiplayer turn-base games out there. What are some that you can provide? For example:

* Tic-Tac-Toe
* Rock-Paper-Scissors
* Checkers

Some not so easy games:

* 4 in a row
* chess
* poker

In terms of "ease" of implementation I'm mainly looking at logic. For example, Rock-Paper-Scissors has very simple logic, while chess has logic that is more complicated.

So far I have the following:

* Hexagon
* Heroes of Might and Magic
* Nine Men's Morris
* Connect 4
* 21 (card game)
* Pen the Pig (The Dot game)
* Memory Match

# Answer
> 3 votes
Board games are easy to implement, also there is a very old turn based DOS game named Hexagon, which can be fun to make, add new features and stuff. But the board/table games are fun too. (other random ideas: minesweeper, heroes of m&m, )

# Answer
> 2 votes
Othello/Reversi comes to mind. Should be a piece of cake to code.

# Answer
> 1 votes
Connect 4, 21 (cards), Pen the Pig, Memory match

# Answer
> 1 votes
Nine Men's Morris, damn I loved that game as a kid, had one of those little pocket-sized magnetic boards (yeah I was *that* kid...)

# Answer
> 1 votes
Nim is probably the simplest multiplayer turn-based game. It is simple enough that a designer hacked "playing" it into static dialog trees in *Shin Megami Tensei: Strange Journey*.

# Answer
> 1 votes
The punch in the face game would be the simplest and easiest form of turn base game to me.

# Answer
> 1 votes
An easy old turnbased dos game called Galactic.exe (not galactic conquest) -- pick the number of planets and you randomly get attach ships and defense percentage... simple

---
Tags: game-design
---


# Question
Title: How to prevent one account from unlocking products on other devices using Apple StoreKit?
We are currently wrapping up a free-to-play game on iOS in which you can purchase non-consumable products. We have been discussing this case internally and are not quite sure what the best practices are as this is our first title.

For example, if a user downloads our app, and makes some purchases. These can be restored should the app ever be deleted and reinstalled as long as the user uses the same Apple ID. What is to stop him from making a fake Apple account, purchasing items and then posting this account on the web allowing everyone to get the items for free?

That is obviously a worst case situation. But a smaller case would be a user unlocking items for his friends. We do not want this to be an always online game but have considered doing a check on startup if there is internet available. If the currently logged in account doesn't own the products do we lock them again? Probably not because people may simply sign into the device with different Game Center logins at which point we don't want to constantly lock and unlock items.

At some point we will be adding multiplayer at which point we can definately do a check with the currently logged in account. This is because A, they will be online when attempting multiplayer, and B, they will want to use their own account for multiplayer. Unfortunately we aren't quite ready for this yet.

Has anyone tackled this issue. Are we overthinking here?

# Answer
> 1 votes
Firstly, if someone is going to "steal" the purchasable digital items from you, it's going to happen eventually. The only thing you can do it make it difficult for them.

1. Store the AppleID with the log-in info (or associate it somehow - I don't know anything about Apple StoreKit so I'm assuming they're logging in somehow and you have access to their ID/Username.
2. Encrypt purchases and keep them locked unless a user who "owns" the purchase is logged in. This would require access to the internet. Some developers outright disable downloadable content if there is no internet connection (i.e. Dragon Age) and others will cache profiles (encrypted, of course) and check to see if purchases belong to that profile.

So, when someone logs in and buys something, the access flag to it gets stored on their profile (which would have to be stored on your database but also cached locally). If someone else logs in, the access to the encrypted content isn't there unless the access flag is on the account. So even if someone downloads all the content, moving it to someone else computer would only allow them to not have to download it but they'd still have to buy it online to access it.

All in all, there is no possible way to nicely prevent someone from sharing an account with all unlocked content (unless you require an internet connection to initially enable the content each time you start the game). But, if you're adding multiplayer, it would be easy to prevent a lot of people from using the same account by only allowing it to log-in once which would hamper online use of the given account.

---
Tags: ios, monetization, appstore
---


# Question
Title: What is an achievable way of setting content budgets (e.g. polygon count) for level content in a 3D title?
In answering this question for swquinn, the answer raised a more pertinent question that I'd like to hear answers to. I'll post our own strategy (promise I won't accept it as the answer), but I'd like to hear others.

Specifically: how do you go about setting a sensible budget for your content team. Usually one of the very first questions asked in a development is: what's our polygon budget? Of course, these days it's rare that vertex/poly count alone is the limiting factor, instead shader complexity, fill-rate, lighting complexity, all come into play.

What the content team want are some hard numbers / limits to work to such that they have a reasonable expectation that their content, once it actually gets into the engine, will not be too heavy. Given that 'it depends' isn't a particularly useful answer, I'd like to hear a strategy that allows me to give them workable limits without being a) misleading, or b) wrong.

# Answer
> 6 votes
From my understanding its much easier to reduce the complexity of a model than it is to add detail for a model that has been skinned and rigged. I know some companies take advantage of this by pooling very detailed assets and scaling them down depending on the situation.

Valve does this with their NPCs. The NPC are modeled in extreme detail without any sort of mapping and then scale down the detail to a level acceptable by the current technology and tricks such as various mapping techniques applied based upon detailed models (or even automatically created).

This also helps with future proofing as you will never need to recreate the assets, only tweek them for each new project. This also has the advantage that there is no need to wait for a team to perform benchmarking that is context specific before the assets can begin to be developed. The artists can be fully involved from day 1.

# Answer
> 16 votes
Okay, so our strategy is:

* Make up some placeholder geometry, of roughly the right scale for the final content. That can be buildings or characters. It doesn't have to look anything like the final content, it can be boxes / spheres / etc., but it should be tessellated so that it has a decent number of polygons. If you're doing characters, make them have a representative number of bones.
* Alternatively, use someone else's geometry. If you have a title whose quality level you're trying to match, find some way to grab their models (perhaps using a DirectX scene grabber).
* Make sure your geometry has a representative shader on it. If you're expecting to blend several textures, do that, even if the textures are all single colour. Make sure the textures are non-trivial resolutions, even if they are all one colour.
* Put in a sensible number of lights.
* Put the camera in a realistic place, pointing at the largest amount of geometry you can (e.g. standing on a hilltop looking over the level)
* Load the scene on your slowest and fastest target hardware, and measure FPS.
* Vary the amounts of geometry / lights / shaders / texture resolution up or down to get a sense of what the trade-offs are (e.g. you can have a dozen extra lights but you'd have to cut the poly count in half).

Finally: be conservative with your numbers. Rendering is not the only thing your game will have to do, so decide one what proportion of your frame you want to spend rendering, and make that your target. E.g. if you want to spend two thirds of your frame at 30fps rendering, then target 1s/22ms (45 fps) in your tests.

Out of all of that, you should be able to give example scenes. E.g. here's a scene with 200K polygons, 5 static lights and no more than 3 dynamic lights per model, with 15 characters of 50K polys and 30 bones, and it runs at 60fps and occupies 30MB in memory.

# Answer
> 4 votes
# Vertex Count

I have researched "Polygon Count" for over 15 years. There is no strict way to tell how many is your limit, especially with more modern software and hardware. Limits were much more useful in engines that only supported 4,000 triangles for an entire level. Now, you will find most objects in the game environment will exceed that individually.

**What ultimately matters is what the engine is doing with the polygon strips.**

When the engine renders each model, it takes your UV mapped coordinates, the texture/material represented on the triangles, and creates triangle strips. In most cases, a triangle fan is broken up into separate triangle strips per triangle. This increases the number of triangle strips, decreasing performance.

A prime example of fixing this is the flat top of a cylinder. 3D packages generally set up a triangle fan with a vertex in the centre. I delete the edges and the centre vertex, then create quads across the face. This should then triangulate into a single triangle strip instead of multiple single-face strips, without changing polygon count.

Take the polygon count as a guide, and take care of how you model, and UV Map the mesh. Less splits in the mesh when UV Mapping can often be more beneficial.

Next, consider what can be faked with normal maps. A flat face with a lot of detail case usually be normal mapped. Curves only need to be round where you can see a silhouette. When looking at the curved faces front-on, you should not notice the difference between your high-resolution assett, and the game-resolution assett. The silhouette is what makes the difference in your model when normal maps are involved. Silhouette can now be modified with DirectX 11, using tessellation and displacement mapping.

# Game Design

Consider the following when designing your game:

1. Define game type (eg. action/adventure/racing/scroller)
2. Define view type (eg. first person/third person/orthographic)
3. Define computational power for your market. (eg. enthusiast/casual gamer)
4. Create a visual style you wish to achieve. Do you want it to look like, for example, Crysis 2, Borderlands, Bloodforge or Gears of War?
5. Define important objects to the player. Are your props going to be a centre of focus or merely backdrop?
6. Are the visual meshes also the collision mesh?

Using the game and view types, decide what the depth of view will be. Are you going to see distant objects, and with what clarity? Are you making something with limited view, such as a corridor shooter? (eg. Gears of War) Are you making something free-roaming with open landscapes? (eg. Skyrim)

Once you know what it should look like, you can research the games which are similar.

Animation will then limit your ability to increase polygon count. Static meshes, anything that remains in the same position is cheapest on the GPU and CPU. Especially if they are not physics objects. For physics objects, you can often create simple collision hulls, and complex visual meshes. There is not enough interaction in most games to notice the difference. Animation moves your model 3-Dimensionally, with several bones per vertex, blending between the weighting from each of them. This can be expensive on CPU time, which can clash with AI and software-based physics. The more vertices being affected by the number of bones in the entire model will decrease CPU performance. This is the other reason game characters are considered "art". It is very difficult to define a polygon limit.

## My Example

I use the UDK, making a slow-paced third person shooter, with limited numbers of players and NPC's on screen at any time. For this, I am aiming for approximately 10,000 triangles per player, 5,000 triangles for typical, generic enemies, and if I were making a "boss" style character, around 15,000. Additionally, weapons for the third person around 4,000 triangles will come up highly detailed. Vehicles around 10,000 triangles. Everything will require Level of Detail, because I require long view distances.

If making a first person, I would base the arms on around 2,000 triangles, weapon around 5,000 triangles, with normal mapping for each.

# Conclusion

This is what "It depends" probably means, but I thought it might clarify some things that people often wonder about.

1. Use polygon count as a guide.
2. Look at areas which could be normal mapped instead of modelled.
3. Be careful when placing triangle fans, if possible, create a strip.
4. Use less splits on the mesh when UV mapping, keeping strips in mind.

# Answer
> 2 votes
One method I can think of is using automatically constructed scenes to generate statistical data from which you can decipher the information you're looking for.

1. Get a large volume of assets (could potentially be automatically generated).
2. Create a tool to generate scenes which can be loaded by your engine using the asset pool.
3. Run a bot which will move your camera around the scene. You may also want to run some other bots to make the scene more dynamic, including lights.
4. Collect as much information as possible and throw it into a database; fps, poly count, shader changes, number of lights, draw calls etc.
5. Make/get some tools to display the data in your database in as many ways as possible.

This link may provide some more ideas: Dead Rising Tools

---
Tags: rendering, art, pre-production
---


# Question
Title: Render 3d object to 2d surface (embedded system)
i am working on an embedded system of a sort, and in some free time i would like to test its drawing capabilities.

System in question is ARM Cortex M3 microcontroller attached to EasyMX Stellaris board. And i have a small 320x240 TFT screen :)

Now, i have some free time each day and i want to create rotating cube. Micro C PRO for ARM doesnt have 3d drawing capabilities, which means it must be done in software.

From the book Introduction to 3D Game Programming with DirectX 10 i know matrix algebra for transformations but that is cool when you have DirectX to set camera right.

I gues i could make 2d object to rotate, but how would i go with 3d one?

Any ideas and examples are welcome. Although i would prefer advices. I'd like to understand this.

# Answer
You do realize that a directX camera is just a couple of matrix transformations? You have a ModelView, Projection, then Viewport matrix transformation to each vertex in that order to change the 3d coordinates to 2d coordinates.

More details about transformation along the standard pipeline (I believe DirectX and OpenGL both work the same way).

Then you rasterize the triangles based on the 2d locations(that resulted from your transformations) of the now 2d array of vertices you have. This can get complicated quick but using the PIT test and fully coloring any pixel that collides should be simple enough and effective in your case.

The other way to do this and the easier way is to make a ray tracer. Simply un-project the ray by using the transformation matrix you wish to apply on your object.

Haven't played around with low level sort of stuff in a while so I may be misremembering but either route shouldn't be too hard. Understand how the hardware pipeline works and implement it in software or write a ray tracer.

Btw this is where I learned what I know about the graphics pipeline.
> 7 votes

# Answer
In the days when 3D hardware was not available, we had to build our own 3D engines and polygon rasterizers. 3DICA is a great tutorial explaining all the basics of a software 3D engine. For me the images won't show up in Firefox, but in Internet Explorer they work fine.

Chapters 2.1 and 3.1 should be enough to cover your needs, but reading the whole tutorial should teach you a lot.
> 3 votes

---
Tags: 3d, mathematics, rotation
---


# Question
Title: using per pixel collision for an elastic response
I realize this might be open ended ended but curious if I just did some over kill...

I had this

http://xbox.create.msdn.com/en-US/education/catalog/tutorial/collision\_2d\_perpixel

and i reworked it to work with my animation code in XNA and what not. It works well, but now I want to use this to decide if there was a collision and to have the items (characters) bounce off eachother elastically. Was the per pixel too much and I could of just used a bounding box ? (in fact would that of been preferred for what needs to be calculated in the response for an elastic collision?)

Looking for guidance really.

# Answer
> 1 votes
It depends on how much realism you are aiming for. There is generally a trade-off between realism and algorithm complexity. I recommend starting with the simplest algorithms, then adding complexity until the desired realism is achieved.

There are two parts to collision simulation that must be considered:

1. Collision detection: determining if two objects are touching
2. Collision response: deciding what happens to two objects that are touching

First, **collision detection**:

Of course, pixel-perfect collision detection gives nicer results, but at the cost of more processing power. This adds up because for N sprites, roughly N\*N collision checks are needed. Recommended for sprites with complex collision areas that don't move particularly quickly.

Bounding box is computationally much cheaper, but will tend to give false-positive collisions, especially if you have funky shaped sprites. Two objects may be touching according to their bounding boxes, but visually they don't appear to touch. Recommended for (almost) rectangular shaped sprites and sprites that move very quickly (false-positives will be imperceptible).

A related test, bounding-circle, is slightly more computationally taxing than bounding box, and good for round-shaped sprites.

As Bloodyaugust recommended, it is wise to first test for a bounding box collision, then only execute a pixel-pixel perfect test when necessary.

Next, **collision response**:

In order to accurately model the angles objects rebound from a collision, the exact point of collision and the two collision surface normal vectors are needed.

Pixel-perfect tests can give a more accurate collision point than bounding box, but don't necessarily provide more information about the collision normal vectors. I would guess both pixel perfect and bounding box would estimate collision normal vectors based on the coordinates of the two colliding objects. They may not even use the actual point of collision when calculating the collision response. The collision response algorithm is not necessarily tied to the collision detection algorithm.

Finally, most physics-based game engines use something *more* accurate than pixel-perfect collision. (Even pixels are rough approximations of the actual objects they represent.) These engines model sprites with 2D/3D models that describe the objects in terms of geometrical shapes. Thus they can achieve sub-pixel accuracy!

I will close with a demo of a game that uses bounding-circle detection, and calculates the collision response based on exact point of collision (of the bounding circles) and the collision normal vectors. Make sure to press `Backspace` to see the behind-the-scenes bounding circle collision stuff: Leftium's Asteroids.

# Answer
> 0 votes
What you did is not necessarily overkill, but perhaps more work than you needed to do. Quick tip: use bounding boxes collision first, then use per-pixel after confirming a general area collision. It will save you a lot of processing.

---
Tags: xna, c#, collision-resolution
---


title: Why lib3ds can't open this max model?

text:
# Question
Title: Why lib3ds can't open this max model?
I'm using lib3ds's 3dsplay example to load this model, whose suffix is `.max`

but get this error:

```
3dsplayer: Error: Loading 3DS file failed.

```

But it can load the `.3ds` model shipped with lib3ds.

Why lib3ds can't open this `.max` model?

# Answer
> 1 votes
.3ds format is (fairly) standard format used by very, very old 3d studio. It's supported by many modelling packages as one export format.

3ds max's format is different. 3ds max is actually a framework with lots and lots of plugins, and each of these store their data in different ways, and thus the .max format isn't very well defined (I doubt anyone has even tried).

In short: lib3ds won't load .max files, because they are not .3ds files.

---
Tags: 3dsmax
---


# Question
Title: How to implement auto-aiming / auto-targeting
We all know how *auto-aiming* or *auto-targeting* works in games.

Now, I need to find how to implement it in my game.

In fact I should implement it in UDK and I would be glad if anyone gave me more specific explanation for UDK. But conceptual explanation is also enjoyable and I'll implement it myself in my way.

# Answer
As far as my knowledge goes, auto aiming is simply looking at a specific coordinates on screen, that are tied to players viewpoint, and bullets travel relatively from the center of the screen (crosshair) anyways.

For multiplayer FPS games, like Quake and CS, the model has bone structure beneath, and all the aimbots are working by specifying which of them to track.

Same for you, in your camera script or player controller or something (don't know how UDK handles all the stuff), in order to autoaim through walls and everything (the most brutal way), you'd simply:

* scan around to find objects you want to be auto-targetable. It could be as simple as `foreach` loop through all the game objects of particular type or simply, all game objects.
* find the object that is the closest to the player, lock to it. The locking part could be done with a simple Camera lookAt call. And, if it's tied to player, you're done. If it's not, you have to transform the camera pivot coordinates to player.

That's basicly it, you can then add an extra flavor, like: to select only (loop through) only visible objects; to select only objects within certain distance; to apply auto-targeting only when players raw aim is in particular range from the target (on screen, you'd need some math here).

That's the raw concept, unformatted.
> 1 votes

# Answer
I've never actually implemented that so I'll remain quite vague. But what you have to do is test the auto-aim of your favorite game and decompose it in a few steps, then the implementation can be very straightforward.

E.g., in pseudo-code, for reticule magnetism, that's what you could have in an update function:

```
If the crosshair is close to an enemy
And if the pad's right stick is close to its center position
    Then start auto-aim to enemy

If auto-aim is started
    If the pad's right stick is still close to its center position
        Move view point towards the enemy
    Else
        Stop auto-aim

```

Then test it a lot, have other people test it, see if matches your reference game. If it doesn't, tweak your algorithm, rinse, and repeat. After a few iterations you should be satisfied with the results.
> 0 votes

---
Tags: algorithm, software-engineering, udk
---


# Question
Title: get coordinates of origin of coordinate system in second coordinate system by knowin matrices of one point in bith systems
Situation, two coordinate systems A, B. origins Oa, Ob. I have one point, for which i know modelview matrix (translatoin/orientation) in both systems. And what i need to get is modelview matrix of Ob in system A. Can please someone help me what to do with that two matrixes to get it?

thank you.

# Answer
Your question sounds a bit confused; there's no such thing as "the matrix of a point"; matrices just convert from one coordinate system to another. Did you mean that you have the two matrices that go from A to world coordinates, and B to world coordinates? And you want to find the matrix that converts from B to A? In that case, you'd just want `B_to_world * inverse(A_to_world)` if you're using row vectors, or `inverse(A_to_world) * B_to_world` if you're using column vectors.
> 5 votes

# Answer
This juggling between frames has been a very popular topic among the graphics programmers since always. There are tons of books (Linear Algebra covers it much more thoroughly, especially at College level), tons of websites, tons of courses that revise it and even source code that has comments on the issue.

Nathan Reed made a good point and gave the straight result that just works. Also, it is quite unclear what you're really saying and trying to achieve with this question, especially if the readers themselves look for some similar facts. For, yet again, another reference, your problem (and answer) is described as follows:

You have three frames: the general, omnipotent world frame **Fworld**, and two arbitrary local frames: **Fa** and **Fb**. When a critter that "lives"in a certain frames is asked to provide the coordinates of a certain point with respect to his frame of reference, that critter responds with a triplet of numbers that tell him how much one has to move along each axis of the reference frame in order to reach that point (i.e. projecting the vector from the origin to that point *P* onto the three axes of the local frame). This is called "*writing the vector as a linear combination of the base vectors of your frame*".

The vectors that make up a base for a reference frame can be packed and stacked in a *matrix form*. When you multiply that matrix with the triplet from the above linear combination sentence, you get the vector we were talking about. Naturally, we take this as granted when referring to the *world frame*: the base matrix is the identity and this makes things a lot easier to work with.

Nobody tells you that the *Fworld* is the one and only frame to work in. Critters living in either *Fa* or *Fb* can provide their own correct view of what happens in the geometric world. But for a being living in *Fworld* to fully understand where things are with respect to themselves, you need to *translate* (read transform) the coordinates of a certain perceived point from a frame to your world frame. This is done by actually finding a way to describe the *vectors* that make up the base of that other frame in your own *world* frame. **This** is done via a transformation matrix (rotation + translation).

---

Now, let's return to the problem at hand: we have a point **P** somewhere in the universe. Critters in frame *Fa* see it as a triplet *Pa*, while those in *Fb* as a triplet *Pb*. *Pa* and *Pb*, although numerically different describe the same position in space.

Why? Well, if you consider the world frame, *Fworld* to be the universal reference frame, you should try and express *Pa*'s coordinates in that frame, then do the same for *Pb*.

How? Using the transformation matrices: \_M\_B\_to\_World\_ and \_M\_A\_to\_World\_. You multiply each *Pa* and *Pb* with these transformation matrices and you get:

```
P = M_B_to_World * Pb
P = M_A_to_World * Pa

```

Say now you want to find out *how* to transform directly a point *Qb* into a point *Qa* (notices that the *b* and *a* following the letter stand for the frame that vector/point is expressed in - Q is the same physical point, but it is seen from different places with different measurements). You do the same and express *Qb* in the world frame as *Q* and then take this *Q* and express it as *Qa*:

```
Q = M_B_to_World * Qb
Qa = M_world_to_A * Q

```

What is `M_world_to_A` then? We only know how to go from *Fa* to *Fworld* using `M_A_to_world`, but not vice-versa. That is true, but there's a property of base change/transformation matrices: they're invertible! So we can go just as easy from *Fworld* to *Fa* using the *inverse*:

```
Qa = inv(M_A_to_world) * Q

```

and thus:

```
Qa= inv(M_A_to_world) * M_B_to_world * Qb

```

Of course, it depends how you store your vectors, but that is a convention (i.e. as rows or columns). That convention is not to affect the rationale of how you can jump from one frame to another passing through the world frame: just take care of matrix multiplication consistency and you'll be fine.
> 0 votes

---
Tags: matrix, coordinates
---


title: UDK iOS ; base Class

text:
# Question
Title: UDK iOS ; base Class
I want to make a game with UDK for mobile and I wonder if There is any limits?

I mean, for example, can I use `UTPawn` as my base Pawn class when making a game for my mobile(iOS) game?

How can I know which classes are legal in my case?

# Answer
> 0 votes
After one month working on my iOS game, As Nate Bross said in comment, I understand that there is no special limitation and if my codes compile and work in mobile previewer, Everything will work in iDevice too.

---
Tags: ios, udk, mobile
---