# Question
Title: How can I select and scale an edge loop within Blender?
I'm a web developer looking into game development as a hobby for fun and the challenge. I have just started learning blender 2.6. I am currently doing a tutorial at http://cgcookie.com/blender/2010/12/22/modeling-a-building/ at around 9:30 after making loop cuts he scales a column. I cant get the same selection as he did. he has vertices selected but selected the whole loop cut? can someone tell me how to make that selection he did.
Also what setting does he use to display the dimension numbers of his selections?

# Answer
> 2 votes
You can select edge-loops by holding `Alt` and klicking on an edge. This works both in vertex- and edge-editing mode.

To display the numbers you see in the video, press `N`. This will bring up the transform panel in your 3D view. In that panel there's a section called *Mesh display* where you can tick *Edge length*.

The scaling is explained in the video. Hit `S` this will cause blender to change into scale-mode. Then you can constrain the scale mode to the X-axis by hitting `X`. This also works for `Y` and `Z` and also in "reverse". So if you would like to scale `Z` and `Y` you would use `Shift` \+ `X`.

He also holds down `Ctrl` during scaling, so that scales snap to fractions of 1/10th (eg. `1.0`, `1.1`, `1.2` etc.)

# Answer
> 0 votes
I struggled with the tutorial taking it step by step. I suggest reading through it, first. He understandably can't give instructions for every OS at one time, and the slightly different windows keystrokes are given at the end of a stage. Seems a shame the online manual isn't searchable. Would make things so much simpler.

---
Tags: 3d-meshes, blender
---


# Question
Title: How can I find a projectile's launch angle?
I am making a 2d game in which units fire arrows at each other. I know the shooter's and the target's position and the initial velocity of the projectile. I want to know the angle the projectile should have in order to land on the target. The target could be at a different height than the shooter.

To sum up I know v0, R and g and I need to find the angle (or the height ?).

I read http://en.wikipedia.org/wiki/Projectile\_motion ,but I can't find something related to what I need.

# Answer
The formula to find the angle is

where v is initial launch speed, g is the gravity constant, x and y are the target's distance and height.

The two roots of this equation give you two possible angles. If the results are imaginary then your initial velocity is not great enough to reach the target (if you want to calculate the angle of reach read this). It's up to you which angle is selected. It would make sense to choose the most direct path i.e. the smaller angle.

You can see a GIF of this equation below with different target values and a constant launch velocity.

Resources from this wikipedia article
> 13 votes

# Answer
Earlier this year I created a simple top down shooter. I used the following method:

Earlier answer: https://stackoverflow.com/questions/15364852/move-sprite-diagonally/15365570#15365570

```
public static class Helper_Direction
{

    // Rotates one object to face another object (or position)
    public static double FaceObject(Vector2 position, Vector2 target)
    {
        return (Math.Atan2(position.Y - target.Y, position.X - target.X) * (180 / Math.PI));
    }

    // Creates a Vector2 to use when moving object from position to a target, with a given speed
    public static Vector2 MoveTowards(Vector2 position, Vector2 target, float speed)
    {
        double direction = (float)(Math.Atan2(target.Y - position.Y, target.X - position.X) * 180 / Math.PI);

        Vector2 move = new Vector2(0, 0);

        move.X = (float)Math.Cos(direction * Math.PI/180) * speed;
        move.Y = (float)Math.Sin(direction * Math.PI / 180) * speed;

        return move;
    }
}

```

It calculates a trajectory between two positions.
> 2 votes

---
Tags: 2d, projectile-physics, trajectory
---


# Question
Title: Why are normal maps in tangent space but not in normal space?
I want to implement normal mapping in my little game engine. When getting into normal mapping, I wonder why normal maps are typically in tangent space but not in normal space? That normal maps in object space would be complicated to handle is clear to me. But when in normal space, they could be easily added to the vertex normal, couldn't they? It seems that tangent space requires to construct a transformations matrix for each pixel.

# Answer
A space is not just an axis though. Tangent space has 3 axes: the U tangent, the V tangent, and the normal. In your illustration you add an offset to the normal. But *how do you know which direction to offset it*? That's what tangent space defines. If the normal is Z, the tangent space gives you the orthogonal X and Y directions in which your offset vector lives.

Now, you could define the X and Y directions for your space in any way you like. But there's a good reason to define them using the UV mapping, which is that the normal map then makes sense visually: its red channel represents horizontal offsets - horizontal *relative to the texture* \- and its green channel represents vertical offsets *relative to the texture*. It's this property of being relative to the texture that makes it possible to create a normal map matching the rest of your texture set (diffuse, specular, etc.) and apply it to surfaces of different orientations.

(BTW, the offset-vector formulation of a normal map is called a partial derivative normal map. It's handy because it offers better results for blending multiple normal maps together).
> 5 votes

# Answer
To try and make reasonalby comple mathematical theory sort and concise: it is because the Normal is actually a co-vector rather than a vector. The difference between a covector and a vector is that a co-vector defines an opposite 'handedness' on sign reversal, while a vector defines an opposite 'direction' on sign reversal. For instance, reversing the normal to a plane defines the same plane, but with CW and CCW reversed.

For a more rigorous distinction you will have to get into the theory in fair depth.
> 2 votes

---
Tags: textures, normals, normal-mapping, spaces
---


title: What's the best Python 3D engine?

text:
# Question
Title: What's the best Python 3D engine?
I want a straight 3d Python engine that's easily obtainable for linux and easy to use. Soya3D failed for me because of the lack of documentation. I should be able to load common 3D models without an issue.

# Answer
Panda3D is only other one I would really call an engine per se. There are Python bindings for Ogre, but I've heard mixed review of them. Unity can be scripted in Boo which is almost, but not quite, entirely unlike Python.
> 17 votes

# Answer
You can try Panda3D, but this is more a game engine than a 3D engine.

I don't know any 3D engine using python as a main language, since 3D applications are, most of the time, required to have smooth execution speed.

I didn't tried PyOgre either, but you might want to check out PyGLet, I don't really know what it is, but it looks great.
> 4 votes

# Answer
I love panda3d myself. super easy and well supported. Cross platform and whatnot.

Here's something I made with it:

http://code.google.com/p/stableorbit
> 4 votes

# Answer
I have used pyOgre sometimes and it have a lot of documentation and the community is great. You should give it a try.

I can't say any other thing because i have never used Panda3D
> 3 votes

---
Tags: 3d, python
---


title: Time of Day Lighting / Day Cycle

text:
# Question
Title: Time of Day Lighting / Day Cycle
I'm trying to implement a simple "lighting" system that alters a value of light between 0.0-1.0, 1.0 is midday 0.0 is total blackness.

Are there any "good" information regarding this particular subject or is it something that you have to develop yourself and adjust to your game in particular. What I'm probably looking for is an algorithm that is flexible and could work by changing values like midday point and such.

My algorithm uses 12:00 / 12PM as it's center point and at that time it's 1.0 in lighting. What I'm trying to do is perhaps "change" the midday point to any value to say 10 and it should still work the same, and perhaps also be able to alter the number of hours the midday can be. Perhaps so that the lighting rises and falls exponentially. So that between night and 4 it raises slowly, between 4 and 8 it raises much faster and at 10 it's reached it high point until 14 when it starts to fall again but in the reverse order.

My simple algorithm only calculates a value between 0.0 and 1.0 and if there is any good info or some suggestions on how to "improve" this method or any other information regarding this subject it would be greatly appreciated.

My algoritm goes as following:

```
If (CurrentHour < (HoursPerDay / 2))

    Lighting = CurrentHour / (HoursPerDay / 2)
    Lighting += (CurrentMinute / MinutesPerHour) * (1 / (HoursPerDay / 2))

Else

   Lighting = 1 - ((CurrentHour / (HoursPerDay / 2)) - 1)
   Lighting -= (CurrentMinute / MinutesPerHour) * (1 / (HoursPerDay/2))

MIN_VALUE = 0.3f;
Max(MIN_VALUE, Min(Lighting, 1f))

```

or in C# code:

```
public float CalculateLighting(uint hour, uint minute, uint minutesPerHour, uint hoursPerDay)
{
    float lighting = 1f;

    if (hour < (hoursPerDay / 2))
    {
        lighting = (hour / (hoursPerDay / 2)) * lightingMax;
        lighting += ((minute / minutesPerHour) * (1f / (hoursPerDay / 2))) * lightingMax;
    }
    else
    {
        lighting = lightingMax - (((hour / (hoursPerDay / 2)) * lightingMax) - lightingMax);
        lighting -= ((minute / minutesPerHour) * (1f / (hoursPerDay / 2))) * lightingMax;
    }

    lighting = MathHelper.Clamp(lighting, lightingMin, lightingMax);
}

```

This way when the time is **6:00 AM** the value is (6/12) and the same for (12+6) and also I clamp the results so I get a value between 0.3 and 1.0 or change that to whatever in case you wanted it to be Winter season so it's darker you can raise that value. This is however a very simple implementation of this concept.

Some functions that I'd like to bring in to it is:¨

1. When is the "midday" and how long is it? Say it's 4 hours between 10-14. During this time it should always be 1.0 in lighting.
2. Change the midday point to anytime or remove it completely. During dark nights in a game perhaps the sun shouldn't rise fully.
3. "Somehow" perhaps make it increase slow and decrease fast by using some value for each. If the sun rises slowly but falls rather quickly afterwards. Exponentially raise and exponentially fall faster.

Just some ideas I'm looking for. It doesn't have to be realistic, just a sense that the weather can change. This value should be a value between 0.0 and 1.0 or adjustable (for extra bright days or something) due to the fact that it can be used to light the entire scene. A reference point to how bright it is in the game world.

**How can I best extend my algoritm and improve it and perhaps implement new features?**

Any suggestions are appreciated or some information on good implementation of a Day-Cycle system.

# Answer
My guess would be that daylight is somehow related to a sine wave rather than a line or exponential curve. For example,

```
public float CalculateLightning(float hour, float minute,
                                uint minutesPerHour, uint hoursPerDay)
{
    float time = (hour + (minute / minutesPerHour)) / hoursPerDay;
    float light = lightningMax * Math.Sin(2*Math.PI * time);
    return MathHelper.Clamp(light, lightningMin, lightningMax);
}

```

Changing whether the light is centered on noon — you're looking for “solar noon”. To change this you can add a constant to `time`.

Changing how much the sun rises — a bit more complicated but there are some wikipedia articles about it. Or if you want to be super precise, look at the demo and source of this page.
> 5 votes

# Answer
in a previous app i had to implement when the sun is going down, based on the gps location. Take a look and maybe it will surve your purpose.

https://github.com/jeancaffou/Analemma (its in java though).

What it does is it can calculate the time of the sunrise/sunset for a given GPS coordinate (only latitude is needed - you can hardcode if you want to simulate a specific place on earth).

This way you can get when the sunrise and sunset is going to take place and from that you can calculate your light value

```
curTime = currentTime;
sunset = sunsetForDate(curTime.year,curTime.month,curTime.day);
sunrise = sunriseForDate(curTime.year,curTime.month,curTime.day);

if(currentTime >= sunrise && currentTime <= sunset)
{
     // daylight
} else
{
     // night
}

```

The way you calculate the value is totally up to your needs. You can say that the light value is 1 at the mid point between sunset and sunrise eg. (sunset-sunrise)/2. And the light value is 0 when the current time is bigger than sunset + SOME\_CONSTANT and smaller than sunrise - SOME\_CONSTANT.
> 1 votes

# Answer
I would suggest to use the logistic function to simulate the sunrise and sunset.

```
float t <- time of day from 0.00 to 23.99
float rise <- time of sunrise
float set <- time of sunset
float f <- factor to vary length of sunset and sunrise
float max <- max. intensity of light during the day
float min <- min. intensity of light during the day

if(t > 0 && t < 12)
  lighting = P((t - rise) * f)
else
  lighting = 1.0 - P((t - set) * f)

lighting = min + lighting * (max - min)

```

You can achieve a yellowish/reddish light at sunrise and sunset by calculating each of the RGB channels of your light separately. The sunrise for the red channel then should start earlier resp. later for the sunset than for the other channels.
> 1 votes

---
Tags: xna, algorithm, lighting
---


# Question
Title: Why is 90° horz / 60° vert the default FPS Field of View?
As far as I understand it, *vertical* Field of View should be adjusted to:

```
fov = 2 * arctan(0.5*screenHeight / distanceEyeScreen);

```

That is, Field of View should match a user's distance to and size of the screen.

In many FPS, there's a default value of 90° for horizontal FoV, or 60° for vertical FoV (assuming 16:9). One example is CryEngine. But for a 16:9 20" screen (diagonal of visible area, i.e. about 40 cm x 25 cm), this default value would require users to have their eyes 20 cm from the screen in order to get a perspectively correct view.

So either I've made a mistake in my calculations, or there must be a reason why you'd choose an inadequate FoV value on purpose.

What is the reason for a default FoV of 90° horz / 60° vert?

# Answer
I think having a FoV of 90deg is what feels natural when you try to mimick 'looking through human eyes'. Your calculations would be correct if you would use the screen to simulate a window into a virtual world, not a first person perspective. Image you would have to see the world trough a 20" frame 80cm away from your head ...
> 6 votes

# Answer
A lot of the effect of FOV is on how fast you seem to move through the world (it's still the same speed; this is purely perceptional). With too wide a horizontal FOV you'll seem to move very fast, with too narrow you'll seem to move very slow. 90 degrees horizontal appears to be the "sweet spot", and the game developer can tune a desired movement speed for individual games from there.

It's also the case that 4 times 90 degrees is 360 degrees, which is a circle. Setting up horizontal FOV so that it maps nicely to the front/left/back/right quadrants appears to make sense.

And finally there's the old chestnut of precedence and inertia. I'm not sure if any games offered player-adjustable FOV before Quake, but Quake did and it defaulted to 90 degrees horizontal; it's easy to imagine other games just picking up on 90 degrees from there.

It's worth noting that nowadays 90 degrees is becoming less common, with games (particularly modern FPSs) setting on a slightly lower value - in or around 80.

If you want to aspect-correct your FOV you can use something like this (I don't pretend it's the only or best way, but it is consistent with the FOV calculator at http://www.emsai.net/projects/widescreen/fovcalc/; this assumes relative to a base aspect ratio of 4:3 (you can adjust that in the call to CalcFovY below))

```
float CalcFovX (float fov_y, float width, float height)
{
    float   a;
    float   y;

    if (fov_y < 1) fov_y = 1;
    if (fov_y > 179) fov_y = 179;

    y = height / tan (fov_y / 360 * M_PI);
    a = atan (width / y);
    a = a * 360 / M_PI;

    return a;
}

float CalcFovY (float fov_x, float width, float height)
{
    float   a;
    float   x;

    if (fov_x < 1) fov_x = 1;
    if (fov_x > 179) fov_x = 179;

    x = width / tan (fov_x / 360 * M_PI);
    a = atan (height / x);
    a = a * 360 / M_PI;

    return a;
}

```

Then call it like:

```
// you should use #define of const instead of magic numbers here, which are just here for illustration purposes in this sample
fov_y = CalcFovY (playerAdjustableFOV, 4, 3); // this is your base aspect that adjusted FOV should be relative to
fov_x = CalcFovX (fov_y, width, height); // this is your actual window width and height

```

The calculated fov\_x and fov\_y can then be plugged into the following perspective matrix (OpenGL convention):

```
1.0f / tan (DEG2RAD (fov_x) * 0.5f),
0,
0,
0,
0,
1.0f / tan (DEG2RAD (fov_y) * 0.5f),
0,
0,
0,
0,
(zFar + zNear) / (zNear - zFar),
-1,
0,
0,
(2.0f * zFar * zNear) / (zNear - zFar),
0

```

This will give you an aspect-adjusted horizontal FOV that maintains vertical FOV irrespective of resolution and aspect ratio.
> 4 votes

---
Tags: 3d, camera, perspective
---


# Question
Title: Establish a person's genuine interest in game programming
I teach on a 3rd level, 4 year games programming degree (B.Sc. in Computer Games Development). We find that new and prospective students often conflate interests and abilities in game-playing, game-design and game-programming. (I know the title could be a a lot more specific or descriptive, but there are internal reason why we can't change it). We do have an open day when prospective students can come and talk to faculty and current students.

This results in a lot of students signing up for our programme who find themselves with interests and/or abilities mis-aligned with their chosen degree. We have options for them to change major, but the are almost just as programming intensive. We don't have any options for students who really wanted to to game related art or design. So some students just stick at it for 4 difficult/unhappy years, as it is the closest degree available to them in gaming.

We outline the content of the programme in our prospectus, but most incoming students have little programming experience, so topics titles like data-structures, software engineering or 3D Graphics don't really mean much to them.

> "I didn't expect so much math in 3D Graphics, I assumed it would be, like, drawing..."

Is there any way to help establish a person's genuine interest in game programming, so that they can make a more informed decision about their education?

# Answer
> 16 votes
I still have a genuine interest in being able to teleport myself around. But I have my expectations based in reality. I think genuine interest is not what you should be gauging, but rather the expectations of the individuals.

Weed out classes are a must for any engineering degree. Make it clear that it's not a bachelor of arts, but one of science. Calculus, linear algebra, physics, discrete mathematics and algorithms should all be early in the program.

Additionally, implementing an **exit survey** should help you gather good information about why people are leaving and allow you to further refine your "marketing" of the course to future students.

# Answer
> 6 votes
As a graduated student from a Game Programming Bachelor I love your question. During the three years of my education the class shrunk from 60 students to 11.

While I may not answer your question, I want to share my thoughts:

1. Be transparent, post some videos of some of the scarier lectures and topics. Of course it's important that the student is informed that he's not supposed to understand it all, but the natural reaction of a talent should be curiosity and fascination. Not a squirm and a chill down the neck.
2. Don't be overly 'sexy' and selling in the description. Games are cool, 3d graphics are cool, AI is awesome, but don't forget to talk about some of the other topics they will learn. Software architecture, design patterns, debugging, vector maths, Newtonian physics, software testing, creative problem solving etc etc.
3. Give the aspiring students a task, such as formulating a best strategy for solving a 3x3 tic-tac-toe. Or how to be able to always guess a number between 0 and 100 in 10 or less guesses. This could be hosted the first day of school, in a group or otherwise.

These are my 1137 bytes.

# Answer
> 6 votes
Consider upping the **requirements** to enter the program.

When I was entering school, Engineering required at least **3** heavily math-based courses: Calculus, Algebra, Physics. At the time Programming wasn't required, but I took it anyway. You could make it a pre-req now.

The pre-reqs should give students an idea about **what they're getting into**. In addition, **be more selective** about who you let in to the program: require a minimum of 80% in Programming & Math courses.

Some light should go off in their head .. prereqs imply expectation, which imply what is to come. "Hmm.. this program seems to want us to know a lot of math!"

# Answer
> 5 votes
Well, to start, lets take a step back from 'Game Programming' and talk about programming in general. Any program/call that involves writing code needs to say so explicitly, and refer to another description of programming its self.

There are few people who can program, and fewer still who will enjoy it. Obviously anyone perusing a degree in such a field should enjoy programming.

So prior to enrollment, students should fill out a survey of sorts to help them (and any guidance counselors) understand exactly what they are getting into, and whether or not they will enjoy it.

The survey should discuss the following areas:

* Mathematics: Did the student enjoy high school algebra/precalculus?
* Puzzles: Dose the perspective student enjoy solving puzzles?
* Logic: Use some simple logic problems to see if the student has good logic skills
* Critical thinking: Use some questions that test critical thinking skills

Any student that lacks the above will not enjoy programming, and thus will not enjoy game programming. You may even explain to them some basic concepts of programming, such as variables and basic syntax, show them some code and ask them to explain what it dose. If it is simple, it should not be too difficult for them to understand. A student who will enjoy programming will see the challenge and do their best to understand, and though they may get it wrong, this shows that they really do have an interest. Those who would not enjoy programming will probably not even answer, or they will answer very poorly, or simply realize that this is not for them.

Then there will be those who think they may enjoy it, but do not. Make sure students get into some real programming as soon as possible, so they can understand what they are getting into, and see how well they enjoy it.

Personally, I am just starting a degree in computer science, though I have been programming for years. I know that I love it because when I see a problem my first thought is "How could I write a program to solve this". I like to think about program structure, how could I make this more efficient, or how could I reorganize this to be more logical. I know I love it because I have tried it, and when I am programming I lose track of time, and find myself at 4 AM without having noticed that I past midnight.

To really know if someone is going to like programming, they need to try it. And you don't need a college course either, I learned most of what I know from the internet (Thank god for stack overflow!). You could try offering some kind of online introductory course (before enrollment) to programming (I would suggest JavaScript + HTML, it's easy to understand, and the effects of working with JS on a web page are much more gratifying than console applications). With such a course they will. . .

* Learn about the importance of syntax
* Learn basic concepts like variables, operators, conditionals, loops, and functions.
* Learn problem solving skills
* Understand what programming actually is

Anyone who truly will enjoy, and have an aptitude for, programming should have little difficulty in such a course. Students why find the introductory materiel difficult will probably not enjoy learning more challenging languages like Java and C++.

Once you establish that the student will enjoy programming in general, then determining if they will enjoy game programming should be as simple as asking them the question.

# Answer
> 3 votes
Well I am a student of Computer Games Development course, although the title is not exactly the same ( Mine is Interactive Software Technology ). As a student myself, the **first** thing that matters the most to **establish interests** in game programming/development is the way the **lecturer** lectures. In my course, I have subjects like Calculus, Computer Game Development ( Game design theories ), Computer Game Programming ( Real programming stuffs ). I have excellent lecturers for Computer Game Development and Computer Game Programming.

Theories, everyone hates them ( mostly ), same goes to me. But guess what? I'm **motivated** and **interested** to **study** the theory and practicing programming **on my own** due to the lecturers, or at least the major influence came from them. The way they conduct the **lectures is fun, interactive, they encourage us to think and have fun with it.**

In my opinion, **good lecturers don't just conduct lectures**, instead, **they inspire and motivate their students**. The name of your program doesn't really matter after students enrolled in your course a week or two later. You should make it to be like this, **students enroll for the course's name**, **stay because of the interesting contents** it has. Just like in game design, game story attracts the players to play for a period of time, learn the game mechanics then it should be the game mechanics to keep the players keep on playing. In order to keep the players to keep on playing, the game mechanics must be interesting. Same goes to your course, **make it interesting**, and **your students will be motivated or at least interested** to continue learning. And oh, one thing I noticed in my course is, we will **have competitions for game designing & game programming**, winner gets the prize. And I noticed some of the lazy classmates suddenly became so passion about programming and game designing, worked through day and night without much sleep. Maybe it will help you a little bit :D

Well, just a thought of a student. Hope it helps, if it doesn't , I'm sorry :)

# Answer
> 3 votes
I'm currently in my fourth and final year of a Games Programming degree, so whilst I might not be able to answer your question directly I thought I'd share my experiences. The university I study at does have a 'Game Design' course however; which is basically 3D modelling and the use of middleware (e.g. Unity), and some students choose to switch to this course (or a hybrid design/programming).

* When I applied to my university there was a **pre-acceptance interview** in which I was basically asked about my background, what I wanted to achieve etc. I don't know how much impact the interview actually had on me being accepted, but it could help **dissuade students who don't have a genuine interest in game programming**.
* We were told up-front the programming languages used on the course, though prior programming knowledge isn't required it was **made very clear how technically involved** the course would be. There was also an **indication of the level of maths involved**, and if I recall correctly the course required at least a B in maths at A-Level.
* At the open day there was plenty of students' work on display, primarily from the first years. The stuff on show was relatively 'primitive'; simple 2D games with basic mechanics, this might help **reel in the expectations of students** who think they are going to be making the next Call of Duty, for example.
* I also had the **opportunity to speak to current students on the course** (and I got some great advice) which definitely gave me some insight into the skills necessary and challenges involved.
* Right from the start of my degree there have been **'weed out' modules**, including complex maths, programming and general graphics theory. If a student was expecting to be 3D modelling they would know fairly soon that they were on the wrong course.

Ultimately there's always going to be some students who can't keep up; over a 4 year course my class has shrunk by about 75%, but I don't think there's much else you can do other than making clear to students what the course involves.

---

> Is there any way to help establish a person's genuine interest in game programming

In an attempt to answer your question however, would the simplest solution be to **ask them?** From the quote you gave of one of your students, it seems as if they know what they wanted to do, but they misunderstood the course content.

# Answer
> 2 votes
I am not a teacher, but I'm studying computer science (though, not some game degree).

We tend to get some people every year who think they can 'do computers' when all they know is how to use an office suite or who think they know how to program when all they ever did is copy paste together a webpage. My university works hard to keep their numbers low, but there's always some who don't take hints.

---

At my university, when there's an **open day**, faculties display some of the **projects** they're working on or have been working on. They usually **exhibit** the resulting programs in the lecture halls.

To help explain the projects, they hang up **posters** with images, text and **mathematical formulas**. This might be e.g. a poster explaining pathfinding in RTS games, which also explains A\*, or a poster explaining projections, showing the math behind projection matrices, or a poster explaining traffic lights modelled using petri-nets. Often, problems are described in a way visitors can relate to (e.g. traveling salesman as the shortest sightseeing tour or taxi route), with an explanation about how the problem is solved.

This serves a twofold purpose: first, visitors can see how the topic in question works, which might spark further interest. Second, there's math right there, so it doesn't come as a suprise. (also, as a side effect, visitors informed enough will often grok it right there.)

*Upside*: Let's people take a look at interesting stuff and the concepts behind the 'magic' being pulled of.

*Downside*: Lots of preparations necessary.

---

Faculties also run **orientation courses** before the semester starts, where students can get a **refresher on programming and math**. During orientation, prospective students are also toured around the campus and they're being helped with finding the informations they need to put together their lecture plans. At this point, students will be shown the amount of math courses (The information (what courses need to be taken and a rough outline of their content) is also freely available on the faculty websites and in study guides, so students can see what they're up for long before they sign up). During orientation, faculty members and students helping with orientation will usually talk about their own experiences (stories about pulling all nighters and working more than a day on exercises/assignments are always being told).

*Upside*: People know what they're in for and have an easier start.

*Downside*: Needs preparation. Websites need to be kept up to date. Some prospective students skip this optional preparation.

---

Then, most of the **math courses** are put **at the start** and are **quite grindy**, persuading those who didn't get the broad hints upfront to go looking for greener pastures. Also, most of the interesting courses come later and have the basic courses as a requirement (e.g. graphics programming after algorithms and data structures and, above all, after the math course which covers vector spaces).

Excercises for the basic algortihm and data structures lectures require (after a one time tutorial) programming from the get go. This is another major factor contributing to drop outs. (Students can flunk up to four excercises in this lecture... after four weeks, thoose who can't program are gone.)

*Downside*: Many people quit after the first semester or change to other fields. About 50%-75% loss total after the second semester, I'd guess.

*Upside*: The remaining people know what they're doing.

# Answer
> 0 votes
I suspect that the problem is that your program isn't drawing high caliber people, because this kind of fundamental confusion is plain stupid. (Does your engineering department have students who think they would be learning to drive trains?) Stupidity shows a fairly good inverse correlation to these things called grades, especially in academic subjects.

Doesn't your department look for good grades in subjects like mathematics and the sciences? Would someone with an A+ in Algebra or Physics think that making computer games doesn't involve tough computer programming? Or did you set the bar low in order to attract applicants, so that the program looks more popular? Another thing: do you have an entrance exam?

Do you have orientation or mentoring programs or activities? Is there some organized activity in which freshmen, or prospective freshmen, can spend time interacting with third or fourth year students? Or even alumni? Keep tabs on alumni and send them spam inviting them to volunteer with froshes.

Then there is the freshman course lineup. Various university programs need students to develop skills and knowledge which are missing in generic high school programs. The courses to fill in these gaps are brought in from the beginning. For instance, CS students usually face some tough data structure and program design courses in the first and second years. Specialized branches of math necessary in disciplines are brought in as early as possible, as are special skills. For instance, freshman engineers may have to take a course in drafting, with labs doing CAD. A game development degree should bring in the math and programming right from the first semester. Students who have the wrong idea can find out that they are wrong right in the beginning.

Undergrads who drop out are cash cow for the school, right? There is hardly any additional cost in adding more bodies to a class of 200, if there is physical space, but a lot of extra income. So what is the downside? It's a fantastic racket. Every department has a narrowing "pyramid": a year by year attrition of students. Look at the sizes of the yearly grad class photographs hanging in their hallways, and then look at how many kids majoring in the same program are packed into just one first year lecture hall. Why would this game development degree program be any different? Compare your attrition to that of other departments, and only worry if it is significantly different. If almost every freshman who enters your program graduates from it, that's not necessarily a good indication, and neither is a very low rate either.

---
Tags: education
---


# Question
Title: How to remove floating terrain when generated with 3D Perlin Noise?
I'm currently using 3D Perlin Noise to generate random terrain in combination with Marching Cubes.

My issue seems to lie in scaling the noise function to get reasonable heights in my terrain. If only one octave is used, all points in relation to the noise are obviously interpolated which results in fairly smooth data. However, to get overhangs/caves/jagged terrain, I have to use multiple octaves with varying amplitudes and/or scale the resulting values to my 'max' height I want of the map.

I might be missing something, but by using marching cubes with 3D perlin noise, I regularly get floating bits of terrain.

Any ideas on how I could correct this or if there's other noise functions I might use to get results like I'm describing? I'm wanting hills/valleys/mountains/lakes/etc. No need for floating bits segregated from the rest of the map. I believe this is a similar issue to what Minecraft has when it has terrain that just floats around in the sky occasionally upon generation.

Thanks for any assistance, Mythics

# Answer
Probably the only way to completely get rid of floating terrain is to test for connectivity. Depending on the size of you map, that might be an option. You can do that by picking base point, like the very bottom of your world. Then ensure all your voxels are either:

1. Connected to the base.
2. Connected to a voxel that's connected to the base.

Likely starting at a known connected point (like the bottom of your world) then doing a breadth first traversal of connected voxels would work pretty well. Make sure you're flagging voxels as connected while you go. You can do this per-chunk.

Additionally, there are less expensive ways to minimize, but not completely remove the floating terrain.

* **Gradient bias**: You can bias the placement of solid voxels with a gradient. The gradient function would fall off somewhat sharply after you're above the "ground level". This article talks about using a gradient and has some other neat tips.
* **Height map noise**: You can generate noise as a height map instead. This would remove the overhangs and caves, but you can simulate those with an additional subtractive noise layer.
* **Less noisy noise**: Use fewer octaves in your terrain noise and generate subtractive noise to get overhangs and caves.
> 9 votes

# Answer
it may be too late to answer, but I was starting now with this voxel terrain generation thing, with Perlin Noise and I found a way to create the terrain without those floating pieces. I think that this may help you. So, to create the terrain I first generate a heightmap than I read the pixels from that heightmap. Now comes the interesting part, I read the "brightness" (actually is the grayscale) value of each pixel on that heightmap and that gives me the height for that particular part of the map, then to create the terrain I assume that this heightmap is my terrain viewed from above, so if the grayscale value of a pixel (after being maped to my terrain "maxHeight") on that height map is, let's say 30, that means that in that specific point of my terrain I will only generate 30 voxels in the y axis and this gives me a terrain with no floating parts. If you want caves and so on, you can apply another noise on the original (under the surface) to create those caves. Hope this works for you.
> 0 votes

---
Tags: 3d, algorithm, procedural-generation, terrain, perlin-noise
---


# Question
Title: Why might a body suddenly stop while moving on continue platform?
I have a 32x32 sprite and I make some to be platform like this

```
for (int i = 0; i < 15; i++) {
    attachChild(new Ground(32 * i, 200, regPlatform, vertexBufferObjectManager, physicsWorld));
}

```

And I have another sprite (32x32 also) moving over those platforms (A player object)

```
attachChild(new Player(10, 10, regPlayer, vertexBufferObjectManager, physicsWorld));

```

And the physicsWorld connects the player like this (Where move=1 when user click right button, and move=2 when user click left button)

```
physicsWorld.registerPhysicsConnector(new PhysicsConnector(this, body, true, false) {
    if (move == 1) {
        body.setLinearVelocity(new Vector2(8, body.getLinearVelocity().y));
    } else if (move == 2) {
        body.setLinearVelocity(new Vector2(-8, body.getLinearVelocity().y));
    }
}

```

The Player moves smoothly form left to right and reverse. But sometimes, it is blocked. If the player move back a bit, and back again where it is blocked, it isn't blocked any more at the same place.

Anyone has any idea to fix this? Maybe it is a bug of andengine and box2d and I need some trick here? Please help me. (The two sprites above are just normal png with 32x32px)

Player image:

Platform image:

# Answer
AndEngine's physics extension is a port of Box2D. And Box2D's faq says this about tile based environments that should be "smooth":

> Using many boxes for your terrain may not work well because box-like characters can get snagged on internal corners. A future update to Box2D should allow for smooth motion over edge chains. In general you should avoid using a rectangular character because collision tolerances will still lead to undesirable snagging.
>
> For more information see this post: http://box2d.org/forum/viewtopic.php?f=3&t=3048

Your description sounds like this problem.
> 4 votes

---
Tags: box2d, andengine
---


# Question
Title: Unable to manipulate Imported Object menu (Unity)
I've imported a model, but for some reason I can't edit any settings under the Imported Object menu, such as the Mesh Filter or the Mesh Renderer.

See this: https://i.stack.imgur.com/t7ZYR.png for a screencap.

# Answer
To do that, make the model into a prefab.. Then drag that prefab into the `Hierarchy` view. Then you should see either:

If the model is skinned and:

If it is not skinned.
> 0 votes

---
Tags: unity, 3d-meshes, importing
---


# Question
Title: How can I find all shortest paths using A*?
It is possible for A\* Path Finding to return all the shortest paths given a graph/map?

For example, given the map below:

```
-----------
--a--X--b--
-----------
```

The said map can return four (4) distinct path.

```
-----1-----
--a11X11b--
-----------
```

```
-----------
--a22X22b--
-----2-----
```

```
----333----
--a3-X-3b--
-----------
```

```
-----------
--a4-X-4b--
----444----
```

The paths follow the Manhattan Heuristic and a Eight (8) directional transition with a default G-value of 1.0f for testing.

The question given the Pseudocode of A\* will only return me one (1) of the four (4) distinct paths which I wish to return all four (4) paths instead.

# Answer
> 5 votes
Yes it is possible, but it requires that your queue of nodes can have the same node more than once with different source path. This may require some changes to the data structures you are using with the path finding. For example you can't store the visiting information directly in a tilemap, since the information on how you reached a specific node is not unique.

Anyway what you need to do is add a neighbour to the queue even if it already exists with the same (but not lower) estimated cost. When you reach the goal, get all other nodes from the queue that also reached the goal with the same cost. From this list you can reconstruct all possible shortest paths.

By the way the given example can return a lot more than those 4 paths (I counted 18) such as

```
-----------
--a--X55b--
---555-----
```

That also means that the algorithm will run a lot slower than the basic version.

**Edit:** Pseudo code as requested:

```
struct RouteNode {
    Node node;
    RouteNode previousNode;
    float cumulativeCost;
    float estimatedCost; // This specifies the ordering in priority queue
}

openSet = new PriorityQueue();
openSet.add(new RouteNode(start, null, 0, getEstimate(start, goal)));

while (!finished) {
    RouteNode current = openSet.takeFirst();
    if (current.node == goal) {
        routes = new List();
        routes.add(current);
        foreach alternative in openSet {
            if (alternative.cost == current.cost && alternative.node == goal) {
                routes.add(alternative);
            }
        }
        finished = true;
    }
    else {
        foreach neighbour in getNeighbours(current.node) {
            cost = current.cumulativeCost + distance(current.node, neighbour);
            if (openSet not contains RouteNode where RouteNode.cumulativeCost < cost && RouteNode.node == neighbour) {
                openSet.add(new RouteNode(neighbour, current, cost, cost + getEstimate(neighbour, goal));
            }
        }
    }
}

foreach route in routes {
    path = new List();
    current = route;
    while (current != null) {
        path.add(current.node);
        current = current.previousNode;
    }
    path.reverse();
}

```

I can't tell how much slower this will be, but it is proportional to the number of alternative path options.

---
Tags: path-finding
---


title: Sidescrolling troubles

text:
# Question
Title: Sidescrolling troubles
I'm making a sidescroller using java and Lwjgl. But I'm having some trouble getting the screen to actually ... well... sidescroll. The world is randomly generated and drawn in blocks. Like so:

```
block[x][y] = new Block(BlockType.STONE, x * BLOCK_SIZE, y * BLOCK_SIZE);

```

At the moment I have it so that the player's sprite just moves around independently. But when I try to move it using the glTranslatef method, nothing happens. 41 blocks by 41 blocks are seen on the screen and I have the total world at 60 blocks by 60 blocks. If you could help me actually get this to work that would be GREAT! :D
If anything is unclear just ask and I'll be sure to update you with whatever is necessary.

Thank you for your time!

EDIT: Here's the code for the map generation, sorry it's so long I'm not sure where to condense it:

```
for(int x = 0; x < worldW; x++) {
        for(int y = 0; y < worldH; y++) {
            /* Null pointer on THIS line */ block[x][y] = new Block(BlockType.AIR, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
        }
    }

    for(int y = 0; y < worldW; y++) {
        for(int x = 0; x < worldH; x++) {

            //Random dirt (world) generation//
            if(y > worldH / 6) {
                if(rand.nextInt(100) > 10) {
                    try {
                        if(block[x - 1][y - 1].getType() == BlockType.DIRT) {
                            block[x][y] = new Block(BlockType.DIRT, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
                        }
                    } catch(Exception e) { }
                }

                if(rand.nextInt(100) > 10) {
                    try {
                        if(block[x + 1][y - 1].getType() == BlockType.DIRT) {
                            block[x][y] = new Block(BlockType.DIRT, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
                        }
                    } catch(Exception e) { }
                }

                try {
                    if(block[x][y - 1].getType() == BlockType.DIRT) {
                        block[x][y] = new Block(BlockType.DIRT, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
                    }
                } catch(Exception e) { }
                if(rand.nextInt(100) < 10) {
                    block[x][y] = new Block(BlockType.DIRT, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
                }
            }

            //Random stone generation//
            if(y > worldH / 4) {
                if(rand.nextInt(100) > 20) {
                    try {
                        if(block[x - 1][y - 1].getType() == BlockType.STONE) {
                            block[x][y] = new Block(BlockType.STONE, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
                        }
                    } catch(Exception e) { }
                }

                if(rand.nextInt(100) > 20) {
                    try {
                        if(block[x + 1][y - 1].getType() == BlockType.STONE) {
                            block[x][y] = new Block(BlockType.STONE, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
                        }
                    } catch(Exception e) { }
                }

                try {
                    if(block[x][y - 1].getType() == BlockType.STONE) {
                        block[x][y] = new Block(BlockType.STONE, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
                    }
                } catch(Exception e) { }

                if(rand.nextInt(100) < 5) {
                    block[x][y] = new Block(BlockType.STONE, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
                }
            }
        }
    }

    //Placing grass blocks//
    for(int y = 0; y < block.length; y++) {
        for(int x = 0; x < block[0].length; x++) {
            if(block[x][y].getType() == BlockType.DIRT && block[x][y - 1].getType() == BlockType.AIR) {
                block[x][y] = new Block(BlockType.GRASS, (x * BLOCK_SIZE) - cam.getX(), (y * BLOCK_SIZE) - cam.getY());
            }
        }
    }

```

EDIT 2:

Ok, so here's the code that I use for rendering a block itself, not the logic for where to place it, just the block:

```
public void render() {
    texture.bind();

    glLoadIdentity();
    glTranslatef(x, y, 0);
    glBegin(GL_QUADS);
        glTexCoord2f(0, 0); //Top left texture corner
            glVertex2f(0, 0);
        glTexCoord2f(1, 0); //Top right texture corner
            glVertex2f(BLOCK_SIZE, 0);
        glTexCoord2f(1, 1); //Bottom right texture corner
            glVertex2f(BLOCK_SIZE, BLOCK_SIZE);
        glTexCoord2f(0, 1); //Bottom left texture corner
            glVertex2f(0, BLOCK_SIZE);
    glEnd();
    glLoadIdentity();
}

```

# Answer
Instead of me just giving you the classes and you not knowing what is happening in them, I will provide you with an explanation and run down of what is happening and then you can give it a go yourself.

I believe it's better to teach someone how to fish rather than catching the fish for them :)

Ok so lets get into it!

A camera is basically just an x and y offset. When we say "Move" the camera, we don't move the camera at all. We actually move everything else relative to the camera's position.

Please Note: There are a lot of different ways to implement a camera in a game and this is just one take of it. It is a very simplified version.

First thing to do is create a "Camera" class.

**What are some things we need to do with this object?**

* We need to place the camera in a designated position (x and y position)
* We want to move the camera around (x and y velocity)
* *There are other things we could do with this class. However, these 2 needs will suffice for this example (eg. follow object, zoom out, zoom in etc)*

As the above points give us an idea of the variables needed for this class lets add them to the camera class with their getters and setters.

# Creating the Camera class

**Camera Variables**

```
int x;
int y;
int xVelocity;
int yVelocity;

```

**Camera Constructor**

```
public Camera(int x, int y) {
    this.x = x;
    this.y = y;
    this.xVelocity = 0;
    this.yVelocity = 0;
}

```

now that our camera class has variables we will need to add an update method which we will call from our map class later on.

This method will be called update() and will be adding the camera velocity to the position.

**Camera update method**

```
public void update() {

    x += xVelocity;
    y += yVelocity;

}

```

Woo! that is our very very simplified camera class!

# Implementing our camera in the "Map" class

lets instantiate a Camera in the map class

```
public Camera camera = new Camera(0, 0);

```

We just created the camera and placed it's x and y position at coordinates 0, 0

Now that we have instantiated our camera we would like to move the tiles or map in relation to the camera's x and y position. One way of doing this is like so:

lets presume you have a render method in your Map class that cycles through each of your tiles in your Tile\[\]\[\] 2D array and renders each tile in it's designated position * tile size.

```
public void render(Graphics g) {
    for (int y = 0; y < mapHeight(); y++) {
        for (int x = 0; x < mapWidth(); x++) {

            Tile tile = getTile(x, y); // Custom method that gets the tile at xy coordinate

            tile.render(x * tile.getWidth(), y * tile.getHeight(), g); // renders tile at designated position
        }
    }
}

```

Now lets add the code to adjust for our camera's x and y position

**NOTE** *This render method will render the WHOLE map. This can create lag if your map is really large, to overcome this issue I suggest only rendering the tiles inside the screen bounds.*

```
public void render(Graphics g) {
    for (int y = 0; y < mapHeight(); y++) {
        for (int x = 0; x < mapWidth(); x++) {

            Tile tile = getTile(x, y); // Custom method that gets the tile at xy coordinate

            tile.render((x * tile.getWidth()) - camera.getX(), (y * tile.getHeight()) - camera.getY(), g); // renders tile at designated position
        }
    }
}

```

Now before our camera is ready to be moved we need to implement the "update()" method which is located in the camera class.

```
public void mapUpdate() {

    camera.update();

}

```

**Note:** If you were to apply an x or y velocity to the camera right now you would soon figure out that it just keeps going and wont stop at the map boundaries. I am **NOT** going to show you how to prevent the camera's x and y position from moving outside of the map bounds as i believe you would be able to implement this feature yourself. You can either place it in the "Map" class update method or the "Camera" class update method, whichever seems more logical to you do that.

# "Moving" the camera

We are now able to adjust the camera's x and y position which will adjust our maps position on screen due to the way we are rendering each tile with the camera offset.

**NOTE** Make sure you have map.update(); in a main update method.

Lets presume you have implemented a keyListener and have instantiated a Map map variable. A basic way to move the camera with keys is as follows:

```
@Override
public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();

    switch (keyCode) {
    case KeyEvent.VK_A:
    case KeyEvent.VK_LEFT:
        map.camera.setxVelocity(-1);
        break;
    case KeyEvent.VK_W:
    case KeyEvent.VK_UP:
        map.camera.setyVelocity(-1);
        break;
    case KeyEvent.VK_S:
    case KeyEvent.VK_DOWN:
        map.camera.setyVelocity(1);
        break;
    case KeyEvent.VK_D:
    case KeyEvent.VK_RIGHT:
        map.camera.setxVelocity(1);
        break;
    }

}

@Override
public void keyReleased(KeyEvent e) {
    int keyCode = e.getKeyCode();

    switch (keyCode) {
    case KeyEvent.VK_A:
    case KeyEvent.VK_LEFT:
        map.camera.setxVelocity(0);
        break;
    case KeyEvent.VK_W:
    case KeyEvent.VK_UP:
        map.camera.setyVelocity(0);
        break;
    case KeyEvent.VK_S:
    case KeyEvent.VK_DOWN:
        map.camera.setyVelocity(0);
        break;
    case KeyEvent.VK_D:
    case KeyEvent.VK_RIGHT:
        map.camera.setxVelocity(0);
        break;
    }

}

```

Now if you run the program and use the arrow keys you will see your map moving around.

Below is a picture of what is happening with the map x and y coordinates and the camera x and y coordinates.

If you were to press the Right arrow key, the process below would happen. The camera would add to it's x position and the map would minus the camera's x position.

This implementation of a camera is very basic and has been simplified for ease of learning.

I hope you learnt something from this. It is basic and it is simplified. There are many ways to implement a camera and this is just one of them. It isn't the most effective nor is it the most efficient. It is merely an implementation for teaching purposes.

Good luck with everything!

**EDIT:** Download source code here

http://code.google.com/p/camerates/downloads/list
> 7 votes

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


# Question
Title: DirectX How to Gernerate Vertices for Diamond Shape and Render it?
How to generate vertices for 3D Diamond Shape in DirectX?

**EDIT**:
I am creating an application which receive **DIAMETER**, **CROWN**, **GIRDLE** and **PAVILION** as **parameter** and render a model of diamond according to parameters.

Refer to the image:

# Answer
> 1 votes
If number of sides is a constant, then possibly best solution would be to use 3D model made in 3D modelling application and scale its parts separately.

When you have the model, you can split it height-wise into segments (crown, girdle, pavilion). Then, when you have input parameters you scale the model according to diameter and each of the parts separately.

If you take bottom as base you scale all vertices by pavilion factor, then scale girdle and crown by 1/pavilion\*girdle from girdle base and finally scale crown by 1/girdle\*crown. This way each segment will be of right size.

# Answer
> 0 votes
for generating vertices for a shape, you first must create some sort of layout of the vertices. Start with just position to keep it simple. ( add up more afterwards ). Then you have to manualy alocate an big memory chunk to fill with vertices you are using.

From there you create a BufferResource in Dx11. Then you simply specifiy that you want to bind it as an vertex buffer.

there is more detail and instructions in the link below.

CreateBuffer Information
How to create a vertex buffer information

---
Tags: directx, geometry, directx9
---


title: Problem of saturation of ram on XNA?

text:
# Question
Title: Problem of saturation of ram on XNA?
I developed a small xna games. For some time I have a problem with the saturation of RAM. In fact everything works perfectly, the game runs with a "Frame" of **60fps**. But strangely I do not know for what reason my games every 4 seconds freeze half a second.

Yet my average call time of the "Update" function is approximately **7 ms** (which is supposed to be good ..)

Here is a screen capture of the Task Manager. I can see the ram flush periodically.

Have you any idea why the ram saturates at **only 50%**?

# Answer
This is probably due to ***the Garbage Collection kicking in every x seconds***. In general, you should minimize (or even eliminate) creating "garbage" in an XNA game. Examples of things that could create garbage during the game loop:

* Calling anonymous methods or closures.
* Setting/clearing delegates or event handlers.
* Using an enum as a key in a dictionary. Simply doing a lookup creates garbage in this case.
* Pretty much any string manipulation. For example, doing "silly" things like wanting to create strings using "+" or "string.Format, etc.
* Adding/removing items out of a LinkedList. It is very common to have objects added/removed from linked lists in the game loop. So now you have to roll your own linked list, or use something other than linked lists.
* Accessing value types via an interface will cause them to be boxed (Is this really true? I was not aware of this).
* Some enumerators create garbage. Good luck figuring out which ones do and which ones don't. Quick: Does foreach() on a Dictionary ValuePair create garbage? Often it seems safer just to fall back to for() if you are unsure (where the collection allows this).
* Using yield in order to enumerate objects.
* Calling List.AddRange(), even if there is sufficient capacity to hold all items.

(Source: Channel9.MSDN.com)

As for best practices, here's a very nice collection of articles.
> 8 votes

---
Tags: xna, performance, frame-rate, frame-buffer
---


title: Object Detection

text:
# Question
Title: Object Detection
I'm building a collision system for my 2D game, broadphasing (sweep and prone + pair detection) works. But I don't know how to separate pickup objects, tiles and the player from each other. My question is; what is the best method for game object type detection? The only thing i come up with is: `if(pair.a.type == player && pair.b.type == item)` but its does not work if a and b are swapped.

# Answer
> 3 votes
What I would do is have a list of all of the entities. I would then iterate through all of them checking for collisions. Should I find a collision, I would then call some function on the entity/entities involved, `didCollideWithEntity(Entity entity)`. This is a virtual function which would be overridden in each subclass of Entity, and so each object could then have it's own collision response - this avoids the need for messy if statements.

---
Tags: c++, 2d, collision-detection
---


title: How to flip card by a corner?

text:
# Question
Title: How to flip card by a corner?
After searching "flip card" in google and our stackexchange site, there is no result and I have no ideas about **how to flip a card by a corner**. I am developing a ios card game with cocos2d, in this game, i just want to touch the right-bottom corner of back face, and hold on moving towards left-up direction. With moving a little distance, the card can flip to front face. Any ideas?

# Answer
Your image example doesn't fit reality for the card you have shown. You are showing the wrong corner, but that's just me pointing out little things ;)

I will give you the simplified version for being able to flip an area that's a triangle.

1. Calculate the x and y offset from the bottom right corner. (it's the difference between the world coords of the dragged corner and the original position of the mentioned corner)
2. Draw a similar triangular area on the bottom right corner. For U,W mapping just flip the X and Y.
> 3 votes

---
Tags: cocos2d
---


# Question
Title: Increasing flexibility of a data passing system in a component based entity system
I'm creating a Component orientated system for a small game I'm developing. The basic structure is as follows: Every object in the game is composed of a "GameEntity"; a container holding a vector of pointers to items in the "Component" class.

Components and entities communicate with one another by calling the send method in a component's parent GameEntity class. The send method is a template which has two parameters, a Command (which is an enum which includes instructions such as STEP\_TIME and the like), and a data parameter of generic type 'T'. The send function loops through the Component\* vector and calls each's component's receive message, which due to the template use conveniently calls the overloaded receive method which corresponds to data type T.

Where the problem comes in however (or rather the inconvenience), is that the Component class is a pure virtual function and will always be extended. Because of the practical limitation of not allowing template functions to be virtualised, I would have to declare a virtual receive function in the header for each and every data type which could conceivably be used by a component. This is not very flexible nor extensible, and moreover at least to me seems to be a violation of the OO programming ethos of not duplicating code unnecessarily.
**So my question is, how can I modify the code stubs provided below to make my component orientated object structure as flexible as possible without using a method which violates best coding practises**

Here is the pertinent header stubs of each class and an example of in what ways an extended component class might be used, to provide some context for my problem:

Game Entity class:

```
class Component;

class GameEntity
{

public:
GameEntity(string entityName, int entityID, int layer);

~GameEntity(void){};

//Adds a pointer to a component to the components vector.
void addComponent (Component* component);

void removeComponent(Component*);

    //A template to allow values of any type to be passed to components
template<typename T>
void send(Component::Command command,T value){
       //Iterates through the vector, calling the receive method for each component
    for(std::vector<Component*>::iterator it =components.begin();  it!=components.end();it++){
        (*it)->receive(command,value);
    }
}
private:
     vector <Component*> components;

};

```

Component Class:

```
#include "GameEntity.h"
class Component
{
public:
static enum Command{STEP_TIME, TOGGLE_ANTI_ALIAS, REPLACE_SPRITE};

Component(GameEntity* parent)
    {this->compParent=parent;};

virtual ~Component (void){};

GameEntity* parent(){
    return compParent;
}
void setParent(GameEntity* parent){
    this->compParent=parent;
}

virtual void receive(Command command,int value)=0;
virtual void receive(Command command,string value)=0;
virtual void receive(Command command,double value)=0;
virtual void receive(Command command,Sprite value)=0;
    //ETC. For each and every data type

private:
GameEntity* compParent;

};

```

A possible extension of the Component class:

```
#include "Sprite.h"
#include "Component.h"
class GraphicsComponent: Component{
    public:
          GraphicsComponent(Sprite sprite, string name, GameEntity* parent);
          virtual void receive(Command command, Sprite value){
                 switch(command){
                      case REPLACE_SPRITE: this->sprite=value; break
                 }
           }

    private:
          Spite sprite;

}

```

Should I use a void pointer and cast it as the appropriate type? This might be feasible as in most cases the type will be known from the command, but again is not very flexible.

# Answer
If you have two components that need to talk to each other, hiding the types or not letting them communicate to each other directly isn't really going to do anything other than hide the coupling that already exists.

I'd get rid of the generic "receive" method and instead just make it so you can get a component by type and call methods on it directly. Unity does this with its `GetComponent<T>` method, which in your case might look something like this (untested, and using C++11 for loops for brevity):

```
template< typename T >
T* GetComponent<T>() {
    for( auto component : components )
    {
        T componentAsT = dynamic_cast<T>( component );
        if( componentAsT != null )
            return componentAsT;
    }
    return null;
 }

```
> 3 votes

---
Tags: c++, component-based
---


# Question
Title: How do I copy box2d data from one body to another?
I want to copy all Box2D-related data (position, velocity, rotation, impulse, ...) from one body to another.

This is what I've got working (with box2djsweb):

```
var t = body.GetTransform();
other_body.SetTransform(t);

var vel = body.GetLinearVelocity();
other_body.SetLinearVelocity(vel);

```

I think that covers most things, but judging by the behaviour, I've missed something. It's as if it's a frame or tick behind. Also, this isn't placing the `other_body` in the exact location as the the original body.

Is there a better way to do this?

# Answer
Box2D has a `CreateBody` function in the b2World class that takes another body as a definition. Which uses the 'definition body' to create a new body. This does not copy the fixtures/shapes attached to the body.

However, I've not tested this function so I don't know if you'll experience the 'step behind' issue. I imagine that may have to do with *when* you're creating the copy, but it could also be from box2D queuing up the new body, and it only gets added to the world on the next frame and first simulated on the frame after that (putting it a frame behind).

It'll take some testing, and you might have to simulate a step yourself and make a copy of that or only copy bodies that are at rest.
> 3 votes

---
Tags: box2d, data
---


# Question
Title: Android: Loading bitmaps without premultiplied alpha (OpenGL ES 2.0)
Is this possible? To load textures in non-premultiplied format (Straight alpha?)?

My game has 1 or 2 images which have semi-transparent pixels and I need to be able to fade them in and out but this doesn't seem possible easily.

As far as I understand Android always loads graphics in premultiplied alpha format, but if this is the case, how to blend them correctly?

Any help would be appreciated.

**EDIT** I have included some code:

```
String strFShader =
"precision mediump float;" +
"varying vec2 v_texCoords;" +
"uniform sampler2D u_baseMap;" +
"void main()" +
"{" +
"gl_FragColor = texture2D(u_baseMap, v_texCoords);" +
"gl_FragColor.a *= "+opVal+";"+    //where opVal is a value from 0.0f to 1.0f
"}";

```

And then......

```
//Enable Alpha blending and set blending function

GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);

//Draw it
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

//Disable Alpha blending
GLES20.glDisable(GLES20.GL_BLEND);

```

Using this, the semi-transparent parts of the image will display too dark (including a dark border where anti-aliased edges should be) but will fade in and out (It's just no good though as the image isn't correct).

If I change the blending mode to:

//Enable Alpha blending and set blending function

```
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);

```

Then it will display perfectly at full opacity (1.0f) but becomes 'oversaturated' (This is the best way I can describe it) the more transparency you introduce (ie 0.9f down to 0.0f).

Thank you for the suggestions, as highlighted in the accepted answer in the end I didn't need to load without with "straight alpha" as I was able to correctly work with the pre-multiplied version that Android loads by default by changing the 2nd line of my Fragment shader to:

```
"gl_FragColor *= "+opVal+";"+

```

# Answer
> 4 votes
There are ways to load images without premultiplication in Android as suggested in this thread. It's also possible to do that without any additional memory penalty at least by doing it completely on the native side, but I don't go to the details here.

If you can use premultiplied alpha and it doesn't e.g. make your content pipeline harder, you should. It solves among some other issues bleeding of neighbour texels when using bilinear filtering for translucent images.

Premultiplied alpha just means that all input color values are already multiplied with the alpha value. Normal alpha blending then requires different blend function. Instead of SRC\_ALPHA,1-SRC\_ALPHA you need to use 1,1-SRC\_ALPHA as you have already tried. What you were missing was taking premultiplied alpha into account in the shader. Since you are multiplying your texture alpha with another value, you have to do the same for texture color channels as well. Thus

```
gl_FragColor = texture2D(u_baseMap, v_texCoords);
gl_FragColor.a *= opacity;

```

becomes simply

```
gl_FragColor = texture2D(u_baseMap, v_texCoords) * opacity;

```

This should be enough to make your fading work correctly.

# Answer
> 1 votes
I remember there was a way to do so, but I would like to suggest you use premultiplied alpha for transparencies, as it is much better than non-premultiplied.

It only makes sense to load without premultiplication when your alpha values mean something different than transparency, but that doesn't seem to be your case.

There's a more thorough explanation of why premultiplied is better in here. But for the time being, to have your code work with premultiplied alpha, you simply have to stop mutliplying by alpha when blending. This means that instead of

```
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);

```

you should do

```
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);

```

---
Tags: android, graphics, opengl-es2, transparency, alpha
---


# Question
Title: How can I use Editline for an in-game console?
I'd like to add an in-game console to a C++ game that I am creating. Although rendering the console and parsing the commands I'm fine with, the text input and editing aspect (e.g. handling left / right keys, backspaces etc...) seems like a lot of effort that I'd rather spend on more interesting things.

I've managed to find a library called Editline that handles the nitty-gritty of console-style text input complete with history and auto-completion, however I'm unsure of how to interface this with my game - in particular all of the examples that I've found use the standard input and output handles and `readline()` itself is a blocking call. I need to be able to provide my own input and render the console to my own output, and I also need to make sure that my game loop continues running.

How should I go about doing this?

# Answer
Editline library (and GNU readline) works only with terminal capabilities. To use these libraries with your in-game console, you would first need to implement a terminal emulator (TTY).

Instead (since doing that for a game would be crazy), I would recommend you to implement cursor movements and editing yourself. I once wrote a C++ class to handle this for my own in-game console for exactly this purpose. The class is aptly named EditLine. The class handles basic cursor movements, forward/backward char/word/line deletes, and history. Nothing fancy, but you may find it useful. Documentation is sparse or non-existent, hopefully you can figure it out anyway. No auto-completion, unfortunately. I implemented that in an upper layer using this class.

editline.h

```
#include <string>
#include <vector>

class EditLine {
public:
    EditLine();
    EditLine(const EditLine&);

    ~EditLine();

    // assignment operator
    EditLine& operator=(const EditLine&);

    // comparison operators
    bool operator==(const EditLine&) const;
    bool operator!=(const EditLine&) const;

    // edit commands
    void accept_line();
    void reject_line();
    void insert_char(int);
    void delete_char();
    void backward_delete_char();
    void delete_word();
    void backward_delete_word();
    void delete_line();

    // motion commands
    void beginning_of_line();
    void end_of_line();
    void forward_char();
    void backward_char();
    void forward_word();
    void backward_word();

    // history commands
    void next_history();
    void previous_history();

    // accessors
    int history_pos() const;
    inline size_t history_size() const;
    inline bool empty() const;
    inline const std::string& line() const;
    inline size_t length() const;
    inline const std::string::size_type& cursor_pos() const;

    // mutators
    void set_line(const std::string& s);
    void set_cursor_pos(std::string::size_type);
    void reset_line();

private:
    std::string line_;
    std::string::size_type cursor_pos_;
    std::vector< std::string > history_;
    std::vector< std::string >::iterator last_iter_;
};

inline size_t EditLine::history_size() const { return history_.size(); }
inline const std::string& EditLine::line() const { return line_; }
inline const std::string::size_type& EditLine::cursor_pos() const { return cursor_pos_; }
inline bool EditLine::empty() const { return line_.empty(); }
inline size_t EditLine::length() const { return line_.length(); }

```

editline.cpp

```
#include "editline.h"
#include "string_utils.h"
#include <string>

namespace {
    const std::string word_delims = " !@#$%^&*()+-={}[]:\"|;'\\<>?,./";
} // namespace

EditLine::EditLine()
    : line_(std::string()),
      cursor_pos_(0),
      last_iter_(history_.end())
{

}

EditLine::EditLine(const EditLine& rhs)
{
    *this = rhs;
}

EditLine::~EditLine()
{

}

EditLine& EditLine::operator=(const EditLine& rhs)
{
    line_ = rhs.line_;
    cursor_pos_ = rhs.cursor_pos_;
    history_ = rhs.history_;
    if (rhs.last_iter_ == rhs.history_.end())
        last_iter_ = history_.end();
    else {
        last_iter_ = history_.begin();
        std::advance(last_iter_, rhs.last_iter_ - rhs.history_.begin());
    }
    return *this;
}

void EditLine::set_line(const std::string& s)
{
    line_ = s;
    cursor_pos_ = line_.size();
}

void EditLine::set_cursor_pos(std::string::size_type pos)
{
    if (pos > line_.size())
        pos = line_.size();
    cursor_pos_ = pos;
}

void EditLine::reset_line()
{
    line_.clear();
    cursor_pos_ = 0;
}

bool EditLine::operator==(const EditLine& rhs) const
{
    return (line_         == rhs.line_       &&
            cursor_pos_   == rhs.cursor_pos_ &&
            history_      == rhs.history_    &&
            history_pos() == rhs.history_pos());
}

bool EditLine::operator!=(const EditLine& rhs) const
{
    return !operator==(rhs);
}

void EditLine::accept_line()
{
    if (!line_.empty())
        history_.push_back(line_);

    line_.clear();
    cursor_pos_ = 0;
    last_iter_ = history_.end();
}

void EditLine::reject_line()
{
    line_.clear();
    cursor_pos_ = 0;
    last_iter_ = history_.end();
}

void EditLine::insert_char(int c)
{
    line_.insert(cursor_pos_, 1, c);
    cursor_pos_++;
}

void EditLine::delete_char()
{
    line_.erase(cursor_pos_, 1);
}

void EditLine::backward_delete_char()
{
    if (cursor_pos_ > 0) {
        line_.erase(cursor_pos_ - 1, 1);
        cursor_pos_--;
    }
}

void EditLine::delete_word()
{
    std::string::size_type pos;

    // check if cursor points on a word delim
    if (word_delims.find(line_[cursor_pos_]) != std::string::npos) {
        // cursor points on a word delim - remove everything from here to
        // right up to first delim after this word.
        pos = line_.find_first_not_of(word_delims, cursor_pos_+1);
        if (pos != std::string::npos)
            pos = line_.find_first_of(word_delims, pos+1);
    } else {
        // cursor is in the middle of a word - remove everything up to first
        // delim.
        pos = line_.find_first_of(word_delims, cursor_pos_+1);
    }

    if (pos != std::string::npos)
        // removes everything right of cursor up to 'pos'
        line_.replace(cursor_pos_, pos - cursor_pos_, "");
    else
        // removes everthing right of cursor
        line_.erase(cursor_pos_);
}

void EditLine::backward_delete_word()
{
    std::string::size_type pos;

    if (cursor_pos_ == 0) return;

    // check if char left of cursor is a word delim
    if (word_delims.find(line_[cursor_pos_-1]) != std::string::npos) {
        // left of cursor is a word delim - remove everything from left of
        // cursor up to next word delim before current word.
        pos = rfind_first_not_of(line_, word_delims, cursor_pos_-1);
        if (pos != std::string::npos)
            pos = rfind_first_of(line_, word_delims, pos);
    } else {
        // left of cursor is not a word delim - remove everything left of
        // cursor up to next word delim.
        pos = rfind_first_of(line_, word_delims, cursor_pos_-1);
    }

    if (pos != std::string::npos) {
        // removes from right of pos and up to cursor
        line_.erase(pos + 1, cursor_pos_ - pos - 1);
        cursor_pos_ = pos + 1;
    } else {
        // removes everything from beginning up to cursor
        line_.erase(0, cursor_pos_);
        cursor_pos_ = 0;
    }
}

void EditLine::delete_line()
{
    line_.erase(cursor_pos_);
    cursor_pos_ = line_.size();
}

void EditLine::beginning_of_line()
{
    cursor_pos_ = 0;
}

void EditLine::end_of_line()
{
    cursor_pos_ = line_.size();
}

void EditLine::forward_char()
{
    if (cursor_pos_ < line_.size())
        cursor_pos_++;
}

void EditLine::backward_char()
{
    if (cursor_pos_ > 0)
        cursor_pos_--;
}

void EditLine::forward_word()
{
    std::string::size_type pos;

    pos = line_.find_first_of(word_delims, cursor_pos_);

    if (pos != std::string::npos)
        cursor_pos_ = pos + 1;
    else
        cursor_pos_ = line_.size();
}

void EditLine::backward_word()
{
    if (cursor_pos_ <= 1) {
        cursor_pos_ = 0;
        return;
    }

    std::string::size_type pos, cursor_pos;

    cursor_pos = cursor_pos_;

    if (cursor_pos >= 2)
        cursor_pos -= 2;

    bool found = false;

    for (int i = (int) cursor_pos; i >= 0; --i) {
        if (word_delims.find(line_[i]) != std::string::npos) {
            pos = (std::string::size_type) i;
            found = true;
            break;
        }
    }

    if (found)
        cursor_pos_ = pos + 1;
    else
        cursor_pos_ = 0;
}

void EditLine::next_history()
{
    if (!history_.empty()) {
        if (last_iter_ == history_.end() || ++last_iter_ == history_.end())
            last_iter_ = history_.begin();
        line_ = *last_iter_;
        cursor_pos_ = line_.size();
    }
}

void EditLine::previous_history()
{
    if (!history_.empty()) {
        if (last_iter_ != history_.begin())
            --last_iter_;
        else
            last_iter_ = --history_.end();

        line_ = *last_iter_;
        cursor_pos_ = line_.size();
    }
}

int EditLine::history_pos() const
{
    if (last_iter_ == history_.end())
        return -1;
    return last_iter_ - history_.begin();
}

```

string\_utils.h

```
std::string::size_type rfind_first_not_of(const std::string& s,
                                          const std::string& delims,
                                          std::string::size_type pos);

std::string::size_type rfind_first_of(const std::string& s,
                                      const std::string& delims,
                                      std::string::size_type pos);

```

string\_utils.cpp

```
std::string::size_type rfind_first_not_of(const std::string& s,
        const std::string& delims, std::string::size_type pos)
{
    std::string::size_type p = pos;
    while (delims.find(s[p]) != std::string::npos) {
        if (p == 0) // not found
            return std::string::npos;
        --p;
    }
    return p;
}

std::string::size_type rfind_first_of(const std::string& s,
        const std::string& delims, std::string::size_type pos)
{
    std::string::size_type p = pos;
    while (delims.find(s[p]) == std::string::npos) {
        if (p == 0) // not found
            return std::string::npos;
        --p;
    }
    return p;
}

```
> 4 votes

# Answer
It doesn't look like too much of a problem. The first thing you need to know is that standard in and standard out are just streams - they can be replaced with your own if needs be. There was a question on SO about this, and AFAIK, the only two ways are to either go into the code of Editline and change it to use your streams, or use `cin.rdbuf()` and `cout.rdbuf()` \- these are provided by the standard library and documentation can be found here. Personally, I would recommend using the latter - it's not hackish, and only involves adding 2 lines of code to your game.
> 0 votes

---
Tags: c++, text-based
---


# Question
Title: Where and how to smooth a voxel-based terrain surface?
I want to smooth the blocky terrain in a Minecraft-like world. The smoothing affects visual appearance and physics but not the logic of placing and picking blocks. I have my mathematical formula to smooth the cubes in a way the voxel grid stays recognizable. But I have no clue how to implement such an effect.

Moreover I do not know how to store and render the effect at all. My smoothing algorithm provides a height for each pixel of a block based on the surrounding blocks. This would result in million of triangles so I might need another approach.

Therefore I thought about calculating the smooth surface dynamically in a shader on the GPU. I never used the geometry shader or the tessellation shader before, but doing so sounds reasonable to me. But with this approach things become difficult when I want to apply correct physics to the smooth terrain surface since the triangles would only be stored on the GPU.

How can I effectively generate a detailed smoothed mesh and access the result for the physics simulation? Is there a technique to implement my idea without the creating of loads of additional triangles?

# Answer
I think a good place to start would be to make things as simple as possible because you stated you don't really know how to implement your algorithm which would make too many triangles anyway. I would like to quickly note that if you smoothed the terrain in the shader it would make huge problems with collision detection and physics since the gpu would be the only thing with access to the smoothed terrain.

The way I propose smoothing the terrain is by using rules to run through when creating the mesh for a block. This is how Castle Story does it and they have a very good blog post on it. Although it focuses on 2d tiles with different textures the bottommost picture translates it to 3d. The simplest way to make "smooth" terrain would be to connect the faces with a diagonal line.

Although I have not actually implemented this (but I will be soon) here is a good forum thread which has pictures of this implemented in games.

This method is a very simple version but it can be expanded using different rules for different sets of blocks... The good part of this method is that it makes the world look decent while still keeping the voxel feel and saving tons of time that would have been invested in a more complex algorithm.
> 1 votes

# Answer
I think you are looking for this: Marching cubes

Its an algorithm that forms a (relatively) smooth surface from a voxel field. For implementation I recommend searching with Google as there are lots of articles about it.

It's basically a technique that first determines which neighbors are the same as this voxel, then using a lookup table to determine the mesh for the given voxel in the given situation.

There are multiple implementations, some due to older patent issues(marching tetrahedrons).

You could implement this real-time in a compute shader perhaps, but if your world is static(I mean no more than one chunk is changed at a time), then doing this on the CPU multithreaded is a suitable option too.
> 0 votes

---
Tags: opengl, voxels, mesh
---


# Question
Title: Creating fake 3D character for 2D isometric game.
Characters in my 2D isometric game are composed of several sprites corresponding to particular body parts (head, torso, upper arm, lower arm, etc.) which let me extensively customize my characters in-game and do skeletal animations.

I would like to avoid creating animations in all eight directions and since I cannot use 3D models - there are many reasons for that and please do not suggest using 3D - I'm looking for a way to fake 3D so the character could be freely rotated in all directions, but use only one animation.

I imagine that this fake 3D could be achieved by an algorithm which would change body parts locations (x, y), their scale (xscale, yscale) and drawing order. How would I go about it?

Should I add to every sprite a fake z variable? What then? Are there any known examples of something similar?

Throw me some ideas

# Answer
New answer:

You can still make the skeletons 3D, in game. Animate them once in 3D or generate their animations procedurally. Now, when you're rendering in game, use that 3D skeletal information to apply z levels to the 2D sprites that make up the body parts of your characters.

Now, when the 3D bone moves, use the 2D screen translation (of the current viewing angle) of the 3D bone as your X,Y movement for your 2D sprite body part. Use the translation perpendicular to the screen as your scale factor (z axis). This will change for each viewing angle. So a character waving from the front view will only have a change in X,Y of the hand body part. From the side, the scale of the hand body part will be changing.

This will be very tricky to get looking good. But you've place a lot of restrictions on yourself, and they'll be challenging to overcome. The above is the best method I can think of. Good luck!

---

Old answer

There is no algorithm that can guess what the other side of your 2D sprite looks like.

The way to fake this is to use 3D, but export all the frames for each animation, for each direction. It's a lot of sprites, but it means your game won't have to do anything 3D. Think about implementing 3D as it might be a little more resource friendly. For example, a single animation might be 20 frames. For all 8 directions, thats 8 (directions) * 20 (frames) = 160 sprites. 160 sprites just to represent one animation, for one character.

This method is far less work than creating the 2D art by hand, but likely more work than just using 3D.

As for known examples, Project Zomboid is doing this for their isometric animation system.
> 3 votes

# Answer
I really think you will have an easier time following Clint Bellanger's method, which is assemble a fully 3D mesh and "photograph it" from the 8 isometric angles. Goblin example.
> 1 votes

---
Tags: isometric, 2.5d
---


title: XACT support outside of XNA?

text:
# Question
Title: XACT support outside of XNA?
I was building a new game in Monogame when I realized that it didn't have XACT support like XNA did. I was wondering if anyone knew another framework that could be used with or instead of MonoGame (preferably with) to get the ability to load XACT projects into the game?

# Answer
> 1 votes
XACT itself is only supported on platforms that already support the official XNA framework (specifically Windows Desktop and Xbox; and not WP7). I'm not aware of any re-implementations of XACT for other platforms.

So your choices are basically to use the official XNA framework (if you only need Windows/Xbox support). Or select another audio technology (possibly `SoundEffect` in XNA/MonoGame, possibly something else).

Also keep in mind that XACT is no longer "supported" on Windows (similar to XNA - it's not broken - it will still *work* if you choose to use it).

---
Tags: xna, c#, audio, xact
---