texts: Top-Down Octree Generation of Procedural Terrain

texts:
I'm trying to implement a voxel-based terrain generation  system in Unity3d (C#). I have successfully implemented a uniform 3d grid system, and have extracted the isosurface out using Marching Cubes and Surface Nets algorithms.

I quickly bumped up against the inherent issues in representing all space with a 3d grid. Much of this space was either above or below the surface, and I turned to space partitioning with octrees, as it didn't seem too difficult. One of the great things about octrees is that octree nodes that that don't have edges intersected by the surface don't need to be split again.

I researched, and found a couple resources to construct my code. One is Volume GFX, and another is the original Dual Contouring paper by Ju et al. My edge-checking is done by the Marching Cube's checking from Paul Bourke's code. If the "cubeindex" is either 0 or 255, then no edge is intersected, and the octree node does not need to be split.

My Octree generation code works for something like a quarter-sphere, where the surface features are extremely normal:

As seen in the picture, only octree nodes containing the surface are subdivided. Working great.

Now, however, when we move to something more complex, like Unity3d's PerlinNoise function:

GASP! What's that hole doing in the mesh at the lower-right corner? Upon closer inspection, we see the octree didn't subdivide properly (red lines highlighting the offending node's dimensions):

This turns out to be the same issue Jules Bloomenthal highlights in her paper on polygonization, page 10, Figure 10. Traditional methods at generating top-down octrees ("Adaptive Subdivision"), are sensitive to fine surface features relative to the size of the octree node.

The gist:

X-------X
|       |
|       |  <- Node
X--/\---X     X's - tested values, all outside of the surface!
  /  \  <- surface

The surface breaks the surface, but comes back down before it goes over a vertex. Because we calculate edge intersections by looking at the signs at the two vertices, this does not flag the edge as crossed.

Is there any method to determine if these anomalies exist? Preferably, the solution would work for more than just the Unity3d noise function, but for any 3d noise function (for cliffs/overhangs/floating islands, etc).

UPDATE

Thanks to Jason's awesome answer, I was able to answer my own questions I asked (in the comments under his answer). The issue I had was that I didn't understand how I could create a bounding function for trigonometric functions (sine,cosine,etc) due to their periodic nature.

For these guys, the periodicity is the key to bounds functions. We know that sin/cos reach their extrema values at a set interval, specifically every π/2. So, if the interval we are checking contains any multiple (cos) or half-multiple (sin) than 1/-1 is the certain extrema. If it doesnt contain a multiple (i.e. the interval [0.1,0.2]), then the range is simply the values of the function evaluated at its endpoints.

UPDATE 2:

If the above doesn't make sense, check Jason's answer to my comments.


texts: Best way to go for simple online multi-player games?

texts:
I want to create a trivia game for my website. The graphic design does not have to be too fancy, probably no more advanced than a typical flash game. It needs to be secure because I want users to be able to play for real money. It also needs to run fast so users don't spend their time frustrated with game freezing. Compatibility, as with almost all online products, is key because of the large target market.

I am most acquainted with Java programming, but I don't want to do it in Java if there is something much better. I am assuming I will have to utilize a variety of different languages in order for everything to come together.

If someone could point out the main structure of everything so I could get a good start that would be great!

Language choice for simple secure online multiplayer games?
Perhaps use a database like MySQL, stored on a secure server for the trivia questions?
Free educational resources and even simpler projects to practice?

Any ideas or suggestions would be helpful...


texts: Is it ok to destroy mesh directly from MeshFilter in Unity?

texts:
Mesh.Destroy(myGameObject.GetComponent<MeshFilter>());

May it cause any problems or undefined behaviour? (the reason I ask this is that I'm trying to destroy an exiting component which is returned from function.


texts: What's the best way to track game phases?

texts:
I'm currently writing an IRC bot in Ruby to play some kind of strategy game (it doesn't matter which), but I'm hesitating between several solutions to implement a phases system the "best" way.

The system: The game has several days; the first day some phases occur to give the players their jobs and so on, but they never occur again, so phases are sometimes conditional.

What's more, when a certain condition is met, e.g. an important player dies, a phase may be started before the next one. Phases may be added by the job system; jobs are each defined in a single file and they can define their own phases and logic.

My ideas:

The game is handled by a class in which I can store an instance variable to remember the actual phase and handle all of the logic in the code. I don't think this is the best idea.
Use a phases hash to store the next phase and other parameters and methods to handle each change.

Is there a better way? I don't think those I came up with are very flexible.


texts: How to cleanly serialize/de serialize a Dictionary whose values are of a derived class using c# newtonsoft json

texts:
I am working on and entity component system and I am storing entities as a JSON file. Components are stored in an entity as a Dictionary of components. I am using newtonsoft's JSON library.

After much frustration I managed to serialize a dictionary that would store objects derived from Component using the ItemTypeNameHandling attribute

Component class:

 class Component
{
    protected String name;
    public String Name { get { return name; } }
}

Example of a derived component:

[JsonObject(MemberSerialization.OptIn)]
class Position : Component
{
    [JsonProperty(Required = Required.Always)]
    public int x = 50;
    [JsonProperty(Required = Required.Always)]
    public int y = 20;

    public Position() { this.name = "position"; }
}

Entity class with Dictionary:

class Entity
{
    ...
    [JsonProperty(Required = Required.Always, ItemTypeNameHandling = TypeNameHandling.Objects)]
    private Dictionary<String, Component> components = new Dictionary<String, Component>();
    ...
}

However I am not satisfied with how the JSON looks. I get this:

"components": {
"position": {
  "$type": "Project_Citrus.Engine.Components.Position, Project Citrus",
  "x": 50,
  "y": 20
 },
"health": {
  "$type": "Project_Citrus.Engine.Components.Health, Project Citrus",
  "HP": 100
 }
}

I want to be easily able to edit my JSON files to create new content. Having to put "$type": "..." makes it seem rather cumbersome and having someone who is not familiar with my object library would have a tough time adding new components. Is there some way to create something like below and still be able to de serialize and de serialize using the component name? Here's an example of what I would like to have.

"components": {
"position": {
  "x": 50,
  "y": 20
 },
"health": {
  "HP": 100
 }
}


texts:
I am currently contemplating the layout system for my php based game but i've run into a couple of worries. So my idea is a 9X9 grid where the center 3X3 are inner castle. The inner castle will be 6X6 if you enter it(click on it). and with the option to expand the inner castle converting one of the 9X9 tiles to a 4X4 inner castle tile.
So here is my question: What is the best way to tackle this type of layout?
my original idea was a 18X18 grid and saving it in the db as (idCastle, Y, X) where X is a string of 18 numbers long telling me if the tile is an inner/outer tile or a inner/outer building.
but i am not really fond of this idea and would like to hear some other ideas on how to tackle this.
Thanks in Advance,

Gert


texts: How to share microgame with WebGL Publisher? (Unity)

texts:
I did unity lego microgame tutorials and now I want to publish it with WebGL publisher. I created build files but I can't publish. I get this error:

I rebuild again to solve this problem. (3 more times..) And clicked "locate existing building" again but I still get this error. What should I do?


texts: Smooth camera movement between followed objects

texts:
I have 2d game where my camera follows the player. Simplified, it copies the player position as its own.

Now I have some other object in the game, that I want to camera to follow. This is easy enough by not setting the camera's position with the player's, but with the position of the other object.

The problem is that this camera movement is instant. I'd like to have a more smooth transition (e.g. panning over the level to the given object).

How can I achieve this?


texts: How should I implement units' enemy "awareness"?

texts:
I'm using Unity3d to develop a RTS/TD hybrid prototype game. What is the best approach for "awareness" between units and their enemies? Is it sane to have every unit check the distance to every enemy and engage if within range?

The approach I'm going for right now is to have a trigger sphere on every unit. If an enemy enters the trigger, the unit becomes aware of the enemy and starts distance checking. Does this save some unnecessary checks?

What's the best practice here?


texts: Drawing models and their bounding boxes using two different shaders?

texts:
I have a bunch of 3d models I want to draw and also for some of them I want to draw bounding boxes.
Calculating the boundnig boxes is no problem, but I'm not sure as to what is the best approach to rendering them.

I have a vertex and fragment shader for my 3d models and they contain a ton of information not needed to draw simple bounding boxes (textures, normals, etc) linked up in a program. Now I also want draw bounding boxes for each of the models meshes and I can think of two ways using two shader programs (one for 3d models and one for bounding boxes):

after drawing each mesh change program to boundingbox and draw its boundingbox
after drawing all meshes, change program to boundingbox and draw all boundingboxes for all meshes

I am inclined to believe the 2nd option is better, but is the overhead of glUseProgram significant enough to notice?


texts: Minecraft-style player-gound collision detection

texts:
The title pretty much says it all... (Minecraft is a game consisting of evenly-spaced cubes for terrain, like voxels)
Note: I am using C# XNA.

I am pretty sure AABB is the way to go, yet I don't know how to implement it. I admit, I'm almost looking for code, but theories/ideas are very welcome.

Important capabilities of my code: I have a function that can get a block anywhere in the world, and get a BoundingBox for that cube. Hence, I have created a BoundingBox for the player to collide with those cubes. My idea was to get the blocks around the player (maybe 4x6x4) and test against those.

The problems I have been having: Say the world is a flat plane. If I use the method of go the shortest distance out, then if the player is slightly clipped into the ground (from gravity), but even slighter into the next block over, then the player will be pushed sideways (and so cannot walk along ground). Of course, this is assuming I react to every block intersected. Another problem is knowing which direction to go (aka negative x or positive). That takes me to my final problem- Getting the amount of intersection, in the correct direction (+ or -) has been tough for me.

I hope I haven't been too hard to understand, I'm not too good at explaining things... And if this question has already been asked, I'm sorry, I looked for it... for 3 days straight.
One last thing, if someone knows exactly how minecraft does it, or has source (I know MC modders have the source, how else would they mod), please point me to it.


texts: Resolving collision with multiple objects

texts:
I already have SAT implemented for collision detection and MTV computation and it works totally fine when my character collides with only one object.

But it's possible that there is a collision with multiple objects at once. How do I handle such cases? How do I evaluate chracter translation using all computed MTVs?

Pseudocode of how my code currently looks like:

// Contains objects collision with which was detected during broadphase
list<collider> overlappingObjects;
// Collider for the character for which I'm trying to solve the collision
collider characterCollider;

response res;
vec3 translation;
for(collider in overlappingObjects){
   // test if they actally collide and put collision information in `res` if they do
   if(testCollision(characterCollider, collider, res)){
       translation += res.mtv;
   }
}

// Moving character out of the collided objects
characterCollider.offset(translation);

This code works incorrectly if overlappingObjects contains more than 1 object.

What is the correct solution for such problem?


texts: Line-Rectangle Collision Detection and Response

texts:
I've looked through Google and none of the solutions seem to pinpoint my idea. Ultimately, I want to create a level editor where I can draw lines and have them exported to a file for my engine to read. I'm having trouble getting path-rectangle to work. I'm using this in the context of a platformer, so I'm also interested in knowing which direction and distance the collision came from so I can resolve it. Which is the best algorithm for doing this? I'm only concerned about axis aligned rectangles.

EDIT: My character is represented as a rectangle and the level is represented by lines. The tools really do not matter as I'm looking for the mathematics behind it, not necessarily an implementation.


texts:
I understand that water ripples (e.g. stone thrown into a pond) are often handled with vertex shaders.  My first question is: are the ripples nothing more than an algorithm that is the function of time?

If yes, it means that the size and diameter of ripples is not "additive."  It means water vertices do not statefully "remember" their previous "disturbance" positions and accumulate more translation info.  Rather it means that, as a function of time, the position of "disturbed" water vertices are freshly computed each frame per unit time.

If no, it means that indeed the vertices accumulate disturbance / translation information - the vertices are stateful.

I hope the answer is "yes," because that actually makes sense to me.  If the answer is no, the I feel it creates tremendous burden on the CPU/GPU to keep track of all the state-per-vertice.  If the answer is "neither," do tell. :)

My second question is, assuming a "yes" above, how does such a "water disturbance shader algorithm" account for continuous interaction with irregular shapes?  For example, please look at the video 40 second mark showing a car crashing through water.  It is not so clear how the vertex shader knows how to make a rectangular disturbance shape (the shape of the car).  Perhaps, over-simplifying, the vertex shader takes both time and a vector to generate the ripples, where the vector is the speed/direction of a car (and the shader code always makes a car-shaped rectangle no matter what).

Is this the right high-level understanding of how this water trick works?


texts: How to prevent a character from going up a steep hill with a height map?

texts:
I've been trying to make my character unable to go up steep hills, but I just can't manage to make it work. I'm using a simple height map which stores the height for every (x, z) point within the map.
I've tried to do this(using C# and XNA):

float height1 = TerrainHeightAt(cam.Position);
float height2 = TerrainHeightAt(cam.Position + cam.GetVelocity());
//If the difference between the two is bigger than a certain constant, don't move.

Basically I find the current height and the future height of the camera. Then, I check if the character is attempting to go up a too steep hill, and if so, I prevent the character from moving. This is not working and I can't see why it isn't.

So my question is:
What am I doing wrong? I would appreciate any link(specially using XNA, but general articles would be great too) showing how to achieve this.

Thank you.


texts: Stuttering when using movetowards in a coroutine

texts:
I have the following problem with a WebGL project I'm working on:

I have an object which I want to zoom out and move to a specific position at the same time, for this, I've created a coroutine which is called on click. On my computer, everything works perfectly fine, but whenever I try this function on a not that high-end computer, this coroutine stutters a bit.

I've tried deactivating every single shader or sprite that this object is using in order to discard high graphic usage, but the problem persists even if the object is a blank circle.

This is the coroutine I'm using:

  IEnumerator restorePosition() {
    float counter = 0;
    while(counter < duration) {
      counter += Time.deltaTime;

      if (counter > duration) {
        counter = duration;
      }

      float framesPerTime = Vector3.Distance(zoomedTransform.position, storedPosition) / (duration - counter) * Time.deltaTime;
      zoomedTransform.position = Vector3.MoveTowards(zoomedTransform.position, storedPosition, framesPerTime);

      float framesPerTimeZoom = Vector3.Distance(zoomedTransform.localScale, storedScale) / (duration - counter) * Time.deltaTime;
      zoomedTransform.localScale = Vector3.MoveTowards(zoomedTransform.localScale, storedScale, framesPerTimeZoom);

      //restore solar system to original position
      float solarSystemFrames = Vector3.Distance(solarSystem.position, solarSystemStartPOS) / (duration - counter) * Time.deltaTime;
      solarSystem.position = Vector3.MoveTowards(solarSystem.position, solarSystemStartPOS, solarSystemFrames);
      yield return null;
    }

    //zoomedTransform.position = storedPosition;
    zoomed = false;
    spriteMask.frontSortingLayerID = originalFrontLayerID;
    spriteMask.backSortingLayerID = originalBackLayerID;
    zoomedTransform.localScale = storedScale;

    foreach(SpriteRenderer s in spriteChildren) {
      s.sortingLayerName = originalLayer;
    }

    foreach(OrbitController o in planets) {
      o.restartAnimation();
    }
    inTransition = false;

    //set moon layer  values back to original
    if (moon != null) {
      moon.gameObject.GetComponent<SpriteMask>().isCustomRangeActive = true;
      moon.gameObject.GetComponent<SpriteRenderer>().sortingLayerName = moonLayerName;
      foreach (Transform child in moon) {
        child.GetComponent<SpriteRenderer>().sortingLayerName = moonLayerName;
      }
      moon.GetComponent<MoonBehaviour>().zoomOut();
      //reset null transform and layer names
      moon = null;
      moonLayerName = null;
    }
    yield break;
  }

Could you give me an idea of what I'm doing wrong? , I've also tried Lerp and that didn't solve the problem.
Thank you!


texts:
I've set up a basic map with Tiled, imported it with STI library (https://github.com/karai17/Simple-Tiled-Implementation) and everything looks in place.

How can i get a zoom-out feature now? I can kinda zoom in using scalex and scaley and i tried the same procedure to zoom out.

However, if i set i.e. scalex = 0.5, scaley = 0.5 the map actually scales in size but it only fit 1/4 the screen size, and the remaining 3/4 are just black space.


texts: Managing Shaders and Objects in DirectX 11

texts:
The title explains my two biggest logical problems with developing a game. It's something I sit up at night thinking about, and that is "What is the most effective way to manage shaders" and "What is the most effective way to manage objects (I call them entities in my game)"

Before I actually began to create I game, I made a bunch of simple projects, and my shader and object management systems have always felt flimsy to me. The methods I usually used for shaders were:

Preload all the shaders when the game loads
All the shaders are based off of "ShaderBase"
Each class holds a pointer to a class
derived from "ShaderBase"
When the object is rendered, the app calls
the MapData and Render functions of the ShaderBase derived class
that the objects pointer contains

This had some problems, however. First of all, is I usually created a different shader when the entities that use it needed special information (Perhaps it was a water shader, and it would be tessellated, so it needed that information). I would need to map different data types to the shader. That means I'd need different versions of ShaderBase's MapData function, for example a regular entity would use:

void ShaderBase::MapData(TransformBuffer transBuf, LightingBuffer lightBuf);

but the water would use:

void ShaderBase::MapData(TransformBuffer transBuf, LightingBuffer lightBuf, WaterDataBuffer waterBuff);

Having to do this seemingly ruins the point of inheritance, because my base class would soon be loaded with different functions for different shaders.

Now the methods for object/entity management. I didn't really have any problems, I just felt like maybe there was a better way to do it. Here's this process:

Create all the objects (Maybe from a world file)
Sort all the objects by purpose and/or shader, to cut down on state changes
A class called EntityList would have an array of all the entities, and each frame would run through that array, and call each ones Render() function, and if it is time, a Think() function (Because some entities may think in steps). It also places the object in its rightful location in the world.

I can see how things like instancing can also be applied here to cut down on resource usage. However, I just have a feeling theres a better way to do this. Each entity is derived from EntityBase, so theres no real problems with inheritance. I might be wrong, but I don't want to continue and have to redo this later.

I didn't mention this above, but I have a sort of bonus question that came to mind while I was writing this:

With the new DirectX 11 features in shaders, what method is better to use: Using techniques, passes, etc. and effect (.fx) files, or the seemingly newer method (I actually don't know when it came about) with each shader in an individual file (.PS, .VS, etc.). Maybe there isn't a difference, I don't know, but I've seen both used in DirectX 11 applications, and I thought maybe people who were more keen to DirectX 10 would use the effect file method, because when I learned a little DirectX 10 before I moved to DirectX 11, I used that method.

For examples of where I've seen these two methods, I learned most of what I know from these two sites:

http://rastertek.com/tutdx11.html

http://www.braynzarsoft.net/index.php?p=DX11Lessons


texts: Is Java viable for serious game development?

texts:
I have scoured the internet, but there are not very many resources for Java game development, not nearly as many as C++. In fact, most engines are written in C++. I tried to play a game made with jMonkeyEngine, but the game was terribly slow, to the point where my computer froze. I had no other Java applications running, and nothing too resource intensive. In contrast, my computer can play most modern 3D games with ease. If I continue to learn and improve Java now, and it turns out that later I am required to learn C++, making the switch might be difficult.

Is Java an acceptable language for serious game development? By serious, I mean high quality graphics, without much lag on modern computers. I also want to consider making games for consoles.


texts: Turn-Based RPG Battle Instance Layout For Larger Groups

texts:
What a title, eh?

I'm currently designing a videogame; a turn-based RPG like Final Fantasy (because everybody knows Final Fantasy). It's a 2D sprite game.

These are my ideas for combat:

The player has a group of 15 members (main character included)
During battle, five of the group are designated as active, and appear in the battle.
These five may be switched out at leisure, or when one of the five die.
At any time, the Waiting members can cast buffs, be healed by the active members, or perform special attacks.
Battles should contain 10+ monsters at least. I'm aiming for 20, but I'm not sure if that's possible yet.
Battles should feel larger than normal due to the interaction of Waiting members, active members and the increased amount of monsters per battle.
The player has two rows in which to put the Active members:  front and back.
Depending on the implementation, I might allow comboing of player attacks and skills.

These are just design ideas, so beware! I have not been able to test this out yet- I have no idea yet if any of these ideas bunched together will make for a compelling game. What sounds good on paper doesn't necessarily have to be good in practice!

What I'm asking now is how to create the layout for this. My starting point are the battles in Final Fantasy VI, with up to 5-6 monsters on the left and the characters on the right- monsters on both sides if it's a pincer attack.

However, this view would not work feasible with my goal of 20 monsters and 5 characters. All the monsters on the left would appear cluttered unless I scale them far far back. If I create a pincer-like map, then there would be no real pincer-attack possible. If I space the monsters out, I force the player to scroll the screen- a game mechanic I've come across and not enjoyed.

Does anybody have any layouts or guides for designing battle maps in turn-based RPGs, especially with a larger number of enemies taken into consideration? How should it look?

I am not asking for specific combat mechanics, just the layout for the moment.


texts:
I am trying to make my first 3D game in OpenGL with Shaders (LWJGL3)
I read and follow a lot of tutorials but can't figure it out what kind of light I am missing here? The wall doesn't get any effect from the light

It is supposed to be like this one:

And my point light part in fragment:

vec4 calcLightColour(vec3 light_colour, float light_intensity, vec3 position, vec3 to_light_dir, vec3 normal)
{
    vec4 diffuseColour = vec4(0, 0, 0, 0);
    vec4 specColour = vec4(0, 0, 0, 0);

    // Diffuse Light
    float diffuseFactor = max(dot(normal, to_light_dir), 0.0);
    diffuseColour = diffuseC * vec4(light_colour, 1.0) * light_intensity * diffuseFactor;

    // Specular Light
    vec3 camera_direction = normalize(-position);
    vec3 from_light_dir = -to_light_dir;
    vec3 reflected_light = normalize(reflect(from_light_dir , normal));
    float specularFactor = max( dot(camera_direction, reflected_light), 0.0);
    specularFactor = pow(specularFactor, specularPower);
    specColour = speculrC * light_intensity  * specularFactor * material.reflectance * vec4(light_colour, 1.0);

    return (diffuseColour + specColour);
}

vec4 calcPointLight(PointLight light, vec3 position, vec3 normal)
{
    vec3 light_direction = light.position - position;
    vec3 to_light_dir  = normalize(light_direction);
    vec4 light_colour = calcLightColour(light.colour, light.intensity, position, to_light_dir, normal);

    // Apply Attenuation
    float distance = length(light_direction);
    float attenuationInv = light.att.constant + light.att.linear * distance +
        light.att.exponent * distance * distance;
    return light_colour / attenuationInv;
}


texts: Can I use Havok Physics for free in my game?

texts:
I found out that Microsoft purchased the Havok physics engine. Where can I get it for Windows Visual Studio 2015 Community?

I tried to look around, but I could not find anything for the latest version. There are no download links at both the official website, nor on the Microsoft site.

What do I need to do to use Havok in my own game?


texts: I want to display the total computed score in sfml

texts:
sf::RenderWindow window(sf::VideoMode(LAYOUT_WINDOW_WIDTH, LAYOUT_WINDOW_HEIGHT),
        "Tetris 2019 - A New Beginning");

    window.setFramerateLimit(30);

    int currentScore = 0;
    int numCleared = 0;

    currentScore = 5 * 100;

    sf::Font myFont;
    if (!myFont.loadFromFile("cartoon relief.ttf")) {

    }

    // Score
    sf::Text score;
    score.setFont(myFont);
    score.setFillColor(sf::Color::Green);
    score.setStyle(sf::Text::Regular);
    score.setString("Score");
    score.setCharacterSize(25);
    score.setPosition(25, 130);

    sf::Text scoreCurrent;
    scoreCurrent.setFont(myFont);
    scoreCurrent.setFillColor(sf::Color::Green);
    scoreCurrent.setStyle(sf::Text::Regular);
    scoreCurrent.setString("currentScore");
    scoreCurrent.setCharacterSize(25);
    scoreCurrent.setPosition(45, 175);

    sf::RectangleShape scoreRectangle;
    scoreRectangle.setSize(sf::Vector2f(100, 50));
    scoreRectangle.setOutlineThickness(1);
    scoreRectangle.setOutlineColor(sf::Color::White);
    scoreRectangle.setFillColor(sf::Color::Black);
    scoreRectangle.setPosition(25, 165);

    while (window.isOpen()) {

        sf::Event event;

        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.draw(score);
        window.draw(scoreRectangle);
        window.draw(scoreCurrent);
        window.display();
    }

    return 0;
}


texts: How to orient a hexagonal tile on a geodesic sphere (Goldberg polyhedron)?

texts:
I've recently ported the hexasphere implementation by Rob Scanlon at https://github.com/arscan/hexasphere.js to objective-c for use in a project I'm exploring.

As a port, it works very well, and I can render the hexasphere using SceneKit on iOS however it's terribly inefficient.  Because I want to dynamically animate individual facets of the hexasphere, I originally implemented each facet as a single SCNNode with it's own SCNGeometry object.

This produces a very slow rendering, with frame rates well below 30fps because of the high draw count.

Here is an image of the output after the original port:

With some advice from another developer, I've improved the rendering by creating a single SCNGeometry object that represents a single hexagon, and then using that single geometry multiple times, once for every hexagon in the hexasphere.

Whilst this brought down the draw count to an amazing 8 draws, it introduced a new problem.

By taking the multiple geometries generated by the original hexasphere code, each hexasphere was oriented in 3D so that they fit into the hexasphere appropriately.

Moving to the new design where I am positioning each SCNNode on the centrepoint of each hexagon, left me with a single geometry, correctly position in 3D, but incorrectly oriented, as this image shows:

After some experimentation I worked out that if I use the latitude and longitude of each hexagon, these would appear to give the correct orientation in the X and Y axes.

Applying this, I got a much better result:

But there is still a problem.  The hexagons, whilst correctly positioned, are not oriented correctly on the face of the hexasphere.

So, finally, my question.

I'm trying to work out how to rotate those hexagons on the surface of the hexasphere, but I can't see how to.  I had thought it was about rotating it on the Z axis, but that doesn't appear to work.  I think I somehow need to calculate a set of 3 angles, 2 of which much be close to the latitude and longitude.

My current thought is that given that I have the boundary points of the original hexagon generated by the original code, I should be able to calculate (somehow) a 3D vector that represents the slope/orientation of the plane formed by those points, and use that to get the hexagons looking the way they are supposed to look.

Can someone help me get this right.  Now I know I'm working with SceneKit and Objective-C, but I'm open to solutions in other languages.  What I'm hoping is that I don't just get told to read a site with arcane maths because believe me, I've tried, and I just don't get it.

[UPDATE] I've completed my project now, and have made my Objective-C implementation of the hexasphere public on git at: https://github.com/pkclsoft/HexasphereDemo


texts: How can I discourage camping while still supporting a "sniper" style of play?

texts:
I am trying to add features into a third person shooter that suit a sniper style of play, in addition to the current rush/deathmatch style it was designed for. The current gameplay is similar in style to Gears of War and Battlefield, perhaps similar to Call of Duty in terms of combat ranges but a little slower paced. The levels are similar in size to large COD maps, or medium Battlefield maps.

Two things which I was planning to add includes some long sight lines and also some "sniper nests". I am concerned though because these two features can open the door to a lot of camping. Sniping and camping are not the same things in my opinion, but it can be easy for campers to abuse such features for easy gain, when they were intended to promote tactical sniper use. That said, I don't believe in blaming the flaws of a game on a player's choice of play style.

Sniper: Uses long range rifles, may stay in a specific spot that is tactically advantageous at the time, but knows how to move to other locations good for sniping. Provides spotting and suppression for more offensive/rush style team members.

Camper: May use any weapon, always stays in the one spot and waits for players to pass by, leading to easy low risk kills. Follows the same strategy regardless of what is happening in the game/match. Is more focussed on own performance as opposed to supporting team members.

So, I am trying to think of some ways in which to try to discourage camping while still allowing legitimate sniper play and preserving the original rush gameplay.


texts: Programmatically extract textures from an arbitrary material

texts:
How do you programmatically extract the textures and other properties of an arbitrary Unity material?
Ideally runtime - I'm trying to upload the data to the server for remote access.


texts: How to play multiple sounds at once without reloading data?

texts:
I am making an HTML5 game, which involves one audio being played multiple times at once.
I searched this issue up and found this: https://stackoverflow.com/questions/25654558/html5-js-play-same-sound-multiple-times-at-the-same-time
It seemed to help, except later a question came up:
If I do cloneNode(), will it copy the sound AND the currently loaded audio data, or will it have to reload the data?
Is there a better way to play multiple sounds while making sure no data needs to be reloaded?


texts: Possible to open Hammer directly from shortcut?

texts:
I want to open Hammer(for CS:GO) directly from windows shortcut, without the SDK-launch menu. Is this possible? I've only been able to open the SDK launcher from a shortcut.

And, is it possible to open a map directly as well? So, 1 shortcut that opens Hammer, with a specific map inside of Hammer?

If there exist a launch option for this, then I can use that!


texts: Evenly distributed checkpoints in a procedurally generated world?

texts:
Got a procedurally generated world. It's succinctly described as an undirected acyclic graph where vertices are junctions and edges weights/length note the amount of time/effort guesstimated to be needed by the current player to traverse between vertices.

Now, the thing is that I'm not a big fan of permadeath as a feature to be forced on the player. It is a great thing for gamers that enjoy the added challenge but a deterrent to casual players. So now I'd like to add checkpoints evenly distributed across an existing game world.

My rule is that I don't want any spot (vertex) on the map to be more than T distance away from the nearest checkpoint with the added constraint that I want the smallest number k of checkpoints possible.

So brute force is not going to work cause the real graph has thousands of vertices. Now I'm wondering if there is a heuristic that can get a pretty good equivalent of the optimal result.
Given k or T, I'd like to find the best setup.


texts: How do I make dialogue text appear with a beeping effect?

texts:
I'm interested in old-school RPG dialogue boxes, where text appearing in dialogue boxes is accompanied by a subtle beeping sound. This is demonstrated in a video here.

Is this morse code translated to audio?

How can I achieve such an effect?


texts: Is an entity/component system appropriate for this geometry handling system?

texts:
I'm working on a Component/Entity-System based game engine atm. And I have this little dilemma. I have simple geometrical structures which might be downloaded or created in game at some point.
These structures are used to create models that are used in OpenGL and OpenGL ES and then for some collision processing. During dev and Beta I am quite ok with maintaining data copies for the physics and the display.
But I started thinking about the future of this engine as I already invested some spare time over a year and a half in it.
Now I would like to duplicate a few routines into OpenCL kernels and use the power of GPUs for the server side of my engine (and be ready for OpenCL enabled mobile hardware/software).

The structures are of variable size and moving or stationary structures can be deformed or broken... ATM the storage is very inefficient.

I thought of using a few mega arrays of GLfloat (Compatible with OpenCL) which would contain my structures depending on their size and pass only the transformations needed each frame.
My Components would then point to these arrays.

Is it the right approach?
If not, how to store the structure data to get it loaded only when needed to GPU memory and maintain the Component structure.

Do I even need a system and components to display and manipulate the structures?

Note: This is not a homework. It is more a question of interest to get a little multiplayer side project running as nicely as possible.

Note: I can't create an OpenCL tag so if someone else could and add it to the question it would be appreciated.


texts: Unity - Creating light that's visible to a shader but not to the camera/player?

texts:
I'm writing a vertex deformation shader that can react to the presence of certain objects. Originally I was passing coordinates to the shader with SetVector, but from my understanding having the CPU set properties on a shader is somewhat expensive. So another idea I had was to have the shader react to light, and do some matrix multiplication to have the shader deform itself based on the intensity of the light hitting it. My question is, how could I approach writing a shader that would react to a light source, when that light would be invisible to the camera/player? In such a scenario I could write a fast & reasonably simple shader that could react to a special light source that would allow it to dynamically react to the light's location and distance. Only, such a light source would need to be invisible to the player, since its just being used as a representation of location and distance (with the added benefit of mixing multiple different sources easily). Or is there some other equally fast better way to do this that I'm not thinking of?

Thanks for the help!

EDIT: Imagine a shader that causes a surface to grow outwards when a certain type of object is near it, and its extrusion distance is proportional to the distance and "intensity" (some float) of the object. If there were several of these objects near the surface then it will form a pattern taking into account all of these nearby objects.


texts: 2D Map Editor Tiles Palette - Best suited Java Elements to use?

texts:
I'm making a 2D RTS Map Editor and here came the moment to make a Palette which is just a popup frame showing tiles to be clicked on and then applied on the map.

I'm wondering which Java Elements to use for this palette?
At the moment I have set a JFrame which will contain Jlabels which have their Icon set as some ImageIcon (which are the tiles of my game).
(I have a List<ImageIcon> tiles which contains every tiles)

mainFrame.setLayout(new GridLayout(tiles.size() / 2, 2, 5,5));
    JLabel tilePanel;

    for (int i = 0; i < tiles.size() ; i++) {
        tilePanel = new JLabel();
        tilePanel.setIcon(tiles.get(i));
        mainFrame.add(tilePanel);
    }

Here's what I have:

However, I want to be able to click on these JLabels to be selected and so that I can use a function like getSelectedTile in my main JFrame to place them on the Map. But adding a mouseListener/Event to each and every JLabel doesn't seem right.

My questions are:

Am I going the right way? If so, how should listen to my JLabels to know which tile is selected.
What SHOULD I use if this isn't the way to go?

Thanks in advance! All suggestions will be taken into consideration :)


texts:
I found a strange problem while programming keyboard input in Unity (v5.3.5).

public class AvatarInputMapperUnityContext : MonoBehaviour {

    private AvatarController _avatarController;

    public KeyCode JumpKey = KeyCode.Space;
    public KeyCode LeftKey = KeyCode.A;
    public KeyCode RightKey = KeyCode.D;
    public KeyCode UpKey = KeyCode.W;
    public KeyCode DownKey = KeyCode.S;
    private Dictionary<KeyCode, WeaponTags> ShotKeys;

    void Awake () {
        _avatarController = GetComponent<AvatarController>();
        ShotKeys.Add(KeyCode.I, WeaponTags.Pistol);
        ShotKeys.Add(KeyCode.O, WeaponTags.Shotgun);
    }

    void Update () {

        if (Input.GetKeyDown(JumpKey)){
            _avatarController.JumpSignal();
        }
    }
}

Now, when the ShotKeys.Add... lines are commented out everything works fine. But when I uncomment them, the program never reaches the _avatarController.JumpSignal() line, and none of the other directional keys (w,a,s,d) work. What can be the reason?


texts: FPS - How to handle accuracy with red dot sight on guns

texts:
I have a gun which you can aim down the red dot sight. If you are moving while aimed down sight, there is some bobbing that comes into play. The arms are bobbing, not the camera itself.

Currently when the player fires their gun, I fire a ray from the center of the camera and check for a hit on a player.

The problem is, if the player is aiming and moving, the red dot is bobbing(since the arms are) but because the camera isn't, the ray always fires down the center which doesn't line up with the red dot. It Doesn't feel right in gameplay.

I was hoping someone may have some ideas to offer on how to handle this..


texts: How to "piece together" an image in code, to render later?

texts:
I want to make a game in Dart and have decided to use the available port of the JS Phaser game engine. This will be my first time really making a game involving graphics so I guess I'll have a lot to learn as I go along...

The main thing I'm trying to reason about doing in code at the moment is as follows: a key part of the game will be that the grid-based map that will be rendered onscreen will be previously generated to be composed of various "tiles" by an algorithm. You could think of it as analogous to a patchwork quilt I suppose in that regard. So naturally with a map like this I need to have some way of piecing together multiple copies of all my base tile images to form the appropriate map configuration to render. So essentially my question is how would I approach doing this in code so that I can indeed programmatically put together the image of my map and not render it tile-by-tile or something like that.


texts:
I need collision detection for my 3D racing game but it isn't going well right now. I think I understand the concept of testing boxes and generating a response, however implementation part is a nightmare for me. OpenGL makes everything more complicated than it has to be.

How can I use a shape that is constructed with glVertex*? Should I create the bounding boxes with some Vector3D class?


texts: Is there a known most efficient version of A* search algorithm?

texts: Is there a known 'most efficient' version of the A* search algorithm? I know some people write papers on the most efficient way to compute common operations, has this been done for A*?


texts:
The situation is I work in my free time on one study project. I have resources of one game packed in it's own format. My intent was to use those  with Unity without converting them into Unity's inner format.

But with brief analysis of Unity Api Reference I did not find anything that would help my in my efforts. Like I have custom binary files I would need to parse with Unity and upon that data create geometry, lights and so on using Unity's classes.

So I wonder if it's even possible? I would really appreciate if anyone would show make a hint on this subject


texts: How would I load two diffuse maps onto one mesh. I have a mesh with multiple sub meshes but each one of those sub meshes has a vertex buffer and I don't think that's very efficient. How could I have two diffuse maps on one mesh without having to go into 3d modeling software and merge the Uv coordinates of the two objects. I'm using directX and C++.


texts:
Can you add any good ways to indicate enemy strength to this list:
 - physical size
 - equipment quality
 - narration or preview scene
 - demeanour

Background
I'm designing a spell-casting/stealth game where some enemies are cannon-fodder, others are decent fights, and some (initially) will be lethal - hence the stealth requirement.
It's a VR title so I don't want UI elements (like stars, health-bars etc) messing up the immersion.
At the moment my inclination is to avoid cartoony art style so it'll be as 'realistic' looking as I can manage while keeping 90fps.


texts: Using proxy servers to tunnel data between clients and world servers

texts:
Background
I've read up a little on the concept of splitting the world into regions which in turn can each be run on a node within a cluster. However my game concept revolves less around zones but rather bubbles.
In short, a bubble is a region of space defined by a radius which dynamically expands and contracts depending on how many players are in close enough proximity.

For example if two players are over 1000KM apart and there is no one else that close to them, then those two players will be in their own bubbles. However once they come within 1000KM to each other, their bubbles connect, effectively creating a larger bubble.
In terms of the server space, one of those players is switched to the others instance. In practice it may be the case that a single server node could handle multiple bubbles, but for arguments sake we'll say that each bubble is run on a different server.
Problem
Secrecy may well be a big part of this game, so its important that when one player is close to another they aren't able to detect this by listening for connections to new instances.
My current thinking is that players would be grouped into proxy servers which in turn dynamically connect and disconnect from the bubbles therefore separating the client from this process.

The problem of course is latency. There is already latency in the communication itself, and I am concerned that this additional step of tunneling data like this may unnecessarily make it worse.

I would also love to find material to read on this type of instancing.


texts: How can I remove sprites when they are outside viewport, but then add them again if I return to their location to save memory

texts:
I'm creating an open-world RPG like Neverwinter nights. But I’m worried about memory and am afraid if I just populate a huge world with physics based sprite nodes, I won't have any memory for anything else.

The method I thought of is to remove the sprites when they go far outside of the viewport and then re-add those sprites when I get close to their location.

How could I accomplish this?


texts: Loading dynamically created files with XNA

texts:
I'm trying to implement a structured save/load functionality so if the user saves, it will take up one of 10 slots, and if the user loads, they would select one of these slots.

To do this, I need the game to load files from a predefined location, but I can't seem to find a good way to do this. I tried using TitleContainer, but this requires the files to be explicitly added to the project and their properties changed to copy to the output directory in the bin. I've also looked at User data loading, but all the examples I can find are for asynchronous file loading where the user selects a file.

Is there any way to load dynamically created files from a fixed location with XNA, such as save files?


texts:
I've written this C# code to handle movement in my testing project. The game is supposed to be 2D, some kind of a platformer, just to get me started with Unity. However, it seems there's something odd going on. The movement isn't particularly smooth (especially in Editor, it's a bit better when built and ran as .exe file) and jumping is very inconsistent, meaning sometimes it jumps to a certain height and sometimes it jumps ridiculously high. Seems random.

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {

    public float MaxSpeed = 10f;
    public float JumpForce = 700f;
    public Transform GroundCheck;
    public LayerMask WhatIsGround;

    bool facingRight = true;
    bool isOnGround = false;
    float groundRadius = 0.2f;

    void FixedUpdate()
    {
        isOnGround = Physics2D.OverlapCircle(GroundCheck.position, groundRadius, WhatIsGround);
        if (isOnGround && Input.GetAxis("Jump") > 0)
        {
            rigidbody2D.AddForce(new Vector2(0, JumpForce));
        }

        float move = Input.GetAxis("Horizontal") * MaxSpeed;
        rigidbody2D.velocity = new Vector2(move, rigidbody2D.velocity.y);

        if ((move < 0 && facingRight) || (move > 0 && !facingRight))
            Flip ();
    }

    void Flip()
    {
        Vector3 scale = transform.localScale;
        scale.x *= -1;
        transform.localScale = scale;

        facingRight = !facingRight;
    }
}

Can anyone tell me what's wrong? There are just two simple platforms and one character, everything done in 2D mode with 2D psychics. The funny thing is that every tutorial handles movement differently and as a beginner in game development I'm kinda baffled by it.

Oh, and the version of Unity is 4.5.3f3, if that changes anything... I'm considering trying the newest beta of 4.6 to see if it is any better, because they're bragging about the new GUI and better 2D physics..
Also, I'm using Windows 8.1.


texts: Java - LibGDX low fps on completely empty project

texts:
I started working on a really really small prototype and when I ran the application i noticed the FPS was only half of what it's supposed to be at. FPS stays at around 30-31 instead of 60 - even when I literally erased all code from running sitting with an empty project it's still 30. I even tried to import an old project which used to work fine with high fps but it also runs at 30.

I also tried importing a LWJGL project and it worked fine with 60 FPS.

I've tried restarting my computer as well and other games run fine on my computer. Note that I've developed in LibGDX for quite a long time and never encountered this before - any help is appreciated!


texts:
The point lights in my scene cast shadows when it's in the editor mode but the light passes through walls in the build or play mode.
I checked the quality settings and set it to hard and soft shadows for all quality settings but that didn't fix it.
It does work when I increase the quality when I build it for Standalone but not when I build for Android.
I've removed the dx11 option in the PC/Mac Standalone settings.
I've changed both forward and deferred rendering options.
I'm testing it on a Moto G 1st Gen [XT 1033].


texts: How to calculate where specular highlights converge with an anisotropic shader?

texts:
If you look at a rendering with an anisotropic shader applied you will notice that there are special spots on the 3D surface/mesh where the lights seems to converge, a point where a given vector radiates from or converges to.

For example:

The specular highlights seem to converge to the corner of the mouth.

Now given a 3D mesh I would like to calculate those points programmatically: what is the formula for that in linear algebra with vectors ?


texts: Uncharted 2 tone mapping and an eye adaptation

texts:
I found an example of uncharted 2 tone mapping on  this site. Here is the code:

float A = 0.15;
float B = 0.50;
float C = 0.10;
float D = 0.20;
float E = 0.02;
float F = 0.30;
float W = 11.2;

float3 Uncharted2Tonemap(float3 x)
{
     return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
}

float4 ps_main( float2 texCoord  : TEXCOORD0 ) : COLOR
{
     float3 texColor = tex2D(Texture0, texCoord );
     texColor *= 16;  // Hardcoded Exposure Adjustment
     float ExposureBias = 2.0f;
     float3 curr = Uncharted2Tonemap(ExposureBias*texColor);
     float3 whiteScale = 1.0f/Uncharted2Tonemap(W);
     float3 color = curr*whiteScale;
     float3 retColor = pow(color,1/2.2);
     return float4(retColor,1);
}

I use Reinhard tone mapping. I calculate an average luminance and max luminance in screen space.
Based on those parameters I get an eye adaptation, for example when a camera is moved from a bright
outdoor area to the dark room. How an eye adaptation process is achieved in Uncharted 2 tone mapping ?
In my engine I render results of the shading to the floating point texture. I assume that I don’t need
hardcoded exposure adjustment (texColor *= 16) and exposure bias = 2.0f. Or maybe I should interpret
those parameters based on the average luminance ? What about “w” parameter ? Can I assign to “w” a maximum
luminance from the screen space ?


texts: The most efficient and accurate game loop?

texts:
Obviously for a game to work you need a game loop... Normally, my game loop would consist of something like this:

while(running){
    update();
    render();
    Thread.sleep(10);
}

This seemed to work fine at first, but then after I started to make my games a bit more complicated the frame rate of my game dropped by 90% in most cases, sometimes they would hang at around <10fps on a high spec system just by simply rendering a couple of 2D image. So I thought to myself: "Should I try putting the render loop on a different thead?". With that in mind, I made a system similar to this:

new Thread(new Render()).start();
new Thread(new GameLogic()).start();

private class Render implements Runnable{
    public void run(){
       while(running){
          render();
      }
    }

private class GameLogic implements Runnable{
public void run(){
   while(running){
      update();
      Thread.sleep(10);
  }
}
}
}

This then caused the graphics to become out of sync with the game update, which then caused the occasional jitter which got quite annoying, later on, I then discovered a use where there is no wait in the loop itself and everything runs as fast as it can, but then you multiply everything in the gameLogic by a deltaTime variable to ensure the game movement is solid. Basically I want to know which way of implementing a game loop is most efficient and whether or not you should render and do gameLogic on the same loop.


texts:
I need to intersect 1 million spatial polygons (specified using their Minimum Bounding Rectangles) with 4 completely disjoint MBR's (MBR1,MBR2,MBR3,MBR4) in space. MBR1, MBR2, MBR3 and MBR4 divide the entire space into 4 disjoint parts. For doing so, I wrote the following code. However, it turns out that for 1 million points the code is running very slowly. Is there some way by which I may improve the code so that it may run a bit faster. If yes, then can someone please help with the same

//---------------------------------------------------------------------------
struct MBR
{
    double xRight, xLeft, yBottom, yTop;
};
bool intersects(MBR spatialId,MBR mbr)
{
    if (mbr.yBottom > spatialId.yTop || mbr.yTop < spatialId.yBottom) return false;
    if (mbr.xLeft > spatialId.xRight || mbr.xRight < spatialId.xLeft) return false;
    return true;
}
//---------------------------------------------------------------------------
bool contains(MBR spatialId,MBR mbr)
{
    if (mbr.yBottom > spatialId.yBottom || mbr.yTop < spatialId.yTop) return false;
    if (mbr.xLeft > spatialId.xLeft || mbr.xRight < spatialId.xRight) return false;
    return true;
}
//---------------------------------------------------------------------------
bool touches(MBR spatialId,MBR mbr)
{
    if (    (mbr.yBottom >= spatialId.yBottom + std::numeric_limits<double>::epsilon() &&
            mbr.yBottom <= spatialId.yBottom - std::numeric_limits<double>::epsilon()) ||
            (mbr.yTop >= spatialId.yTop + std::numeric_limits<double>::epsilon() &&
            mbr.yTop <= spatialId.yTop - std::numeric_limits<double>::epsilon()))
            return true;
    if (    (mbr.xLeft >= spatialId.xLeft + std::numeric_limits<double>::epsilon() &&
            mbr.xLeft <= spatialId.xLeft - std::numeric_limits<double>::epsilon()) ||
            (mbr.xRight >= spatialId.xRight + std::numeric_limits<double>::epsilon() &&
            mbr.xRight <= spatialId.xRight - std::numeric_limits<double>::epsilon()))
            return true;
    return false;
}
//---------------------------------------------------------------------------
MBR MBR1,MBR2,MBR3,MBR4;
vector<unsigned> spatialIds; //contain 1 million spatial identifiers which are intersected with MBR1, MBR2, MBR3, MBR4
//MBR1, MBR2, MBR3, MBR4 are again specified using their Minimum Bounding Rectangles
vector<unsigned> resultMBR1, resultMBR2, resultMBR3, resultMBR4; //contains the resulting intersecting spatial ids
for(vector<MBR>::iterator itSpatialId=spatialIds.begin(),lSpatialId=spatialIds.end();itSpatialId!=lSpatialId;++itSpatialId)
{
    if(intersects((*itSpatialId),MBR1)||contains((*itSpatialId),MBR1)||touches((*itSpatialId),MBR1))
    {
        resultMBR1.push_back((*itSpatialId));
    }

    if(intersects((*itSpatialId),MBR2)||contains((*itSpatialId),MBR2)||touches((*itSpatialId),MBR2))
    {
        resultMBR2.push_back((*itSpatialId));
    }

    if(intersects((*itSpatialId),MBR3)||contains((*itSpatialId),MBR3)||touches((*itSpatialId),MBR3))
    {
        resultMBR3.push_back((*itSpatialId));
    }

    if(intersects((*itSpatialId),MBR4)||contains((*itSpatialId),MBR4)||touches((*itSpatialId),MBR4))
    {
        resultMBR4.push_back((*itSpatialId));
    }
}


texts: Texture artifacts depending on texture size

texts:
I get some strange artifacting with textures depending on their size. I run OpenGL 3.3 with an GTX 580 so it should definitely support non power of two textures. I've narrowed down the problem specifically to the texture's size, I've tried checking if transparency had anything to do with it, color channels etc.

As you can see, the 512x512 and 300x300 textures look just fine but the 437x437 is all distorted. What could be the cause of this and how can it be fixed? I could of course just stick to power of two textures which seem to work fine but since this is an personal educational project I really want to understand what's going on.


texts: Bump and push entities without a physics engine

texts:
I have seen on many games the ability to push entities around and bump into enemies/characters. What is this called?

I have implemented Matterjs to accomplish this with Pixijs but it seems overkill when I just need the ability to bump and push. I'm not really interested in an accurate physics model, just collision enough to allow the character to interact with the environment.

I can't seem to find out what this is called. My idea is to have all entities defined by a circle collision boundary, and move away from the character based on primitive collision detection and a tangent force calculation to displace.


texts: Understanding how to go from a scene to what's actually rendered to screen in OpenGL?

texts:
I want something that explains step by step how, after setting up a simple scene I can go from that 'world' space, to what's finally rendered on my screen (ie, actually implement something). I need the resource to clearly show how to derive and set up both orthographic and perspective projection matrices... basically I want to thoroughly understand what's going on behind the scenes and not plug in random things without knowing what they do.

I've found lots of half explanations, presentation slides, walls of text, etc that aren't really doing much for me. I have a basic understanding of linear algebra/matrix transforms, and a rough idea of what's going on when you go from model space -> screen, but not enough to actually implement it in code.


texts:
Lets say that you want to rotate simple cube around fixed point in center.

Is it possible to use such coordinate system, that you need to use only sine and cosine in order to rotate?

I have done some 3d stuff in VHDL, but i screwed whith coordinate system and is not working correct. I need to make rotation that works in at least two axes.


texts:
When I create a toolbox such is in this tutorial. How do I defend against breaking the pattern with multiple instances like this:

gameObject.AddComponent<Toolbox>();
gameObject.AddComponent<Toolbox>();

I when calling Toolbox.Instance I get following message:

[Singleton] Something went really wrong  - there should never be more than 1 singleton! Reopening the scene might fix it.

Is there a way to defend against it ?


texts: SetRenderTarget(null) clearing previous draw calls

texts:
I'm not sure if everything's working as it should be or whether I'm just not doing something properly, but I couldn't find anything that discussed this so I thought I'd ask here.

I'm using Monogame 3.2 for Windows.

In my game I'm drawing sprites to the back buffer, then I set a render target and draw to that, then I switch back to the back with SetRenderTarget(null) so I can draw my render target but I find that all the drawing I did before I set the render target the first time has been cleared. Is this just how it works or have I done something wrong?

EDIT: The pink rectangle is the render target.

Here is example code:

        // Render some stuff first
        spriteBatch.Begin();
        spriteBatch.Draw(mPixel, new Rectangle(10, 10, 500, 50), Color.Red);
        spriteBatch.End();

        // Render to target
        GraphicsDevice.SetRenderTarget(renderTarget);
        GraphicsDevice.Clear(Color.Pink);
        spriteBatch.Begin();
        spriteBatch.Draw(mPixel, new Rectangle(10, 10, 500, 50), Color.Blue);
        spriteBatch.End();

        // Render back to backbuffer
        GraphicsDevice.SetRenderTarget(null);
        spriteBatch.Begin();
        spriteBatch.Draw(renderTarget, Vector2.Zero, Color.White);
        spriteBatch.End();

Here is the result, I expected the first red rectangle to remain behind the render target:


texts: if you had a bunch of good server hardware - what would you do with it? make it game related?

texts: i've just scored 8 Dell 2950's and a Dell Blade Chassis with 10 Dell 1855 Blades, including a NetApp NAS. i'm interested to hear what other game devs would do with the gear. :)


texts: Raycasting - weird lines on walls when ray is facing up or right

texts:
I am trying to make a raycasting game. Everything is rendered correctly except when the ray is facing up (angle > PI) or facing right(angle > 0.5PI and < 1.5PI) lines are drawn on walls. I am not sure what is causing it to happen but I know that the lines are not affected by the rotation of the player only by the players position. I also tried rounding the rays position but that did not help.
Right and up ray walls.

The walls up close.

Left and down ray walls.

Code:
        let rayX, rayY, rayAngle, rayDeltaX, rayDeltaY

        for (let i = 0; i < this.screen.width; i ++) {
            rayAngle = this.angle - this.fov / 2 + i * (this.fov / this.screen.width)

            if (rayAngle < 0) {
                rayAngle += Math.PI * 2
            }
            else if (rayAngle > Math.PI * 2) {
                rayAngle -= Math.PI * 2
            }

            rayX = this.x
            rayY = this.y

            let stepY

            if (rayAngle > Math.PI) {
                stepY = -this.tileSize
                rayY = Math.floor(rayY / this.tileSize) * this.tileSize - 1
            }
            else {
                stepY = this.tileSize
                rayY = Math.floor(rayY / this.tileSize) * this.tileSize + this.tileSize
            }

            rayX = this.x  + (rayY - this.y) / Math.tan(rayAngle)

            rayDeltaY = stepY
            rayDeltaX = stepY / Math.tan(rayAngle)

            while(true) {
                if (this.Map.map[Math.floor(rayY / this.tileSize) * this.Map.width + Math.floor(rayX / this.tileSize)] == '#') {
                    break
                }

                rayX += rayDeltaX
                rayY += rayDeltaY
            }

            let rayHorizontalX = rayX
            let rayHorizontalY = rayY
            let rayDistanceHorizontal = Math.sqrt((this.x - rayHorizontalX) ** 2 + (this.y - rayHorizontalY) ** 2)

            rayX = this.x
            rayY = this.y

            let stepX

            if (rayAngle > 0.5 * Math.PI && rayAngle < 1.5 * Math.PI) {
                stepX = -this.tileSize
                rayX = Math.floor(rayX / this.tileSize) * this.tileSize - 1
            }
            else {
                stepX = this.tileSize
                rayX = Math.floor(rayX / this.tileSize) * this.tileSize + this.tileSize
            }

            rayY = this.y + (rayX - this.x) * Math.tan(rayAngle)

            rayDeltaY = stepX * Math.tan(rayAngle)
            rayDeltaX = stepX

            while(true) {
                if (this.Map.map[Math.floor(rayY / this.tileSize) * this.Map.width + Math.floor(rayX / this.tileSize)] == '#') {
                    break
                }

                rayX += rayDeltaX
                rayY += rayDeltaY
            }

            let rayVerticalX = rayX
            let rayVerticalY = rayY
            let rayDistanceVertical = Math.sqrt((this.x - rayVerticalX) ** 2 + (this.y - rayVerticalY) ** 2)

            let rayFinalDistance

            if (rayDistanceHorizontal < rayDistanceVertical) {
                rayFinalDistance = rayDistanceHorizontal
                ctx.fillStyle = 'darkblue'
            }
            else {
                rayFinalDistance = rayDistanceVertical
                ctx.fillStyle = 'blue'
            }

            let rayCorrectedDistance = rayFinalDistance * Math.cos(rayAngle - this.angle)

            let lineHeight = this.tileSize * (this.screen.width / 2 / Math.tan(this.fov / 2)) / rayCorrectedDistance
            let lineBottom = this.projectionPlane.centerY + lineHeight * 0.5
            let lineTop = this.projectionPlane.height - lineBottom

            ctx.fillRect(i, lineTop, 1, lineHeight)
        }

Any help would be appreciated.


texts: Complex system-component dependencies in entity-component-system?

texts:
I am trying to design a data-oriented ECS engine. The issue I am struggling with is that my rendering system have to rely on two different sets of entities to actually do rendering.

My current idea is to have (usually one, but possibly more) entities representing cameras (e.g. sets of components describing views and viewports). Then, I can have RenderingSystem that iterates through all CameraComponents and renders everything they 'see' to appropriate viewports.

However, this requires RenderingSystem to query for two non-intersecting sets of components: cameras and renderables. My current approach allows systems to select a set of nodes that have one or several required components. It does not allow for more complex queries, like either CameraComponent or RenderableComponent. This is not the first time when more complex system-component dependencies (using unions of component sets insetead of their intersections) seem useful to me.

Plain old data components have crucial advantages:

They are trivially serializable
Can be changed by game designers without recompilation or coding knowledge
Describe behaviors in purely declarative way

That is why I would like to put cameras among other things in the ECS.

Use case: if we are implementing mirrors, we may put Renderable, Position and Camera components on them, then Renderable's texture will also be a render target for Camera. RenderingSystem then will render them in some efficient way.

So, is defining more complex relations with components (like "this system should receive all nodes that have Camera and Position as 'cameras' collection and all nodes with Renderable and Position as 'renderables') the most flexible solution in this case, or is there a better way?

UPDATE(1): I ended up allowing systems to define their dependencies like this (the word "aspect" is borrowed from Artemis ECS framework):

aspects: {
    renderables: Aspect.all(['Transform', 'Sprite']),
    cameras: Aspect.all(['Transform', 'Camera']),
    emitters: Aspect.all(['Transform', 'ParticleEmitter']),
    ...
}

These lists are gathered, passed to a system, cached and rendered in an efficient way. This actually works quite nicely (in other systems too), as well as cameras being entities. Is this a common way to do it?

UPDATE(2): I have spent some time working with ECS-like architectures and added a conclusion as an answer. I hope it makes clear that the approach I have suggested in the first update is just one of available options.


texts:
For my 2d game, I want to set background image. So that I am using multiple background images for that purpose.

But it can't set correctly on screen that illustrated in following image.

Also for setting background correctly, I am calculating camera orthographic size based current resolution and loading that sprite dynamically.

My camera inspector setting illustrated in following image.

My basic target is to display my background image in full screen without any bar. For example, If I have resolution of 600x1024 resolution and I am loading same resolution image then it should be display in full screen.

But you see that I can't able to get this result. So please some one help me to come out of this. If you want any more detail then I will provide at any time.


texts: How do Minecraft know where village's buildings are if the village is not generated yet?

texts:
I'm trying to understand how chunk generation works in a deep level and all the information I found does not explain how the villages are generated properly without visual glitches during generation.

I mean, if you are in an area where you should see some buildings from a village, how does Minecraft know that they must be rendered?
Minecraft generates villages from a main "structure" that probably it is not generated yet.

This video explains the village's generation properly.

So with that in main what should happen is that you could see builds appear from time to time when the "village center" of a village is generated in a new-generated chunk.

Here you have a visual representation of the circumstances I'm describing. The buildings inside the loaded area shouldn't be shown if the village is not generated yet:

The only explanation I can think about is that Minecraft generates way more chunks than the ones that are visually loaded to avoid this problem.

If this what happens, what is the generation area compared to the visual loaded area?


texts: How do I price a game that sells internationally online?

texts: If I have a downloadable game or in-game item that I need to sell for a fixed amount in all countries, how do I work out how to set the price? My local currency is UK pounds. Would I come up with a round number figure in £ and let customers in other countries deal with the currency fluctuations? Should I try to display the figure in the local currency if possible? Would it be better to price the game in dollars or euros and deal with the currency fluctuations myself? How are other games handling this?


texts: Handling sound effects for Multiple Collisions

texts:
How can I generate somewhat realistic sound effects for collisions in a physics engine that simulates lots of objects?

E.g. take >10 marbles that are bouncing off walls and off each other.

If I generate a sound for each collision I would quickly overload the system (Windows Phone 7).

Is there an algorithm that lets me combine multiple collisions to create fewer sound effect instances?


texts: How to detect and collide two elastic line segments?

texts:
There are 4 moving physical nodes in 3D space. They are paired with two elastic line segments / strings (1 <-> 2; 3 <-> 4).

Part I: How to detect the collision of two segments?

Part II: On the moment of collision, fifth node is created at the intersection point and here you have the force-based graph. 5-th node (bend point) can slide among the strings as in a real world. Given the new coordinates of 4 nodes, how to calculate the position of the 5-th node on the next frame? I assume string force on the nodes to be F = -k * x where x is the string length.

All I came up to is that the force between 5 and 1 equals 5 and 2 (the same with 3 and 4). What are the other properties?.


texts: Side scroller terrain generating and scrolling

texts:
I am creating a side scroller game for android devices but I encountered a problem. The game looks like this:

The black dot is a player. Player's x doesn't change, only the y does. When the player collides with the green terrain the game is over.

I have a problem with how should I handle a map storing and drawing. What I did is store the level file in a large png file (like 1k px height and 20k px width), same with the collision mask (basically the same file but with black colored collision terrain). I guess this approach isn't to good beacuse I was getting the out of memory exceptions due to large bitmap on some devices. I've learned that some people use tile based maps but with this sinusoidal map it could be to hard for me to do small tiles and collsion masks for them. I want the map to be as long as possible and if it's possible random-generated but I don't know what's the best approach to do this with this kind of terrain and how to handle pixel perfect collisions when doing so.


texts: Get direction vector of camera in voxel game

texts:
I am currently working on a Minecraft clone (a voxel game). The feature I'm working on is the ability to break blocks. I have a ray-casting/ray tracing algorithm for traversing the voxels, but the only thing I don't know how to do is find the direction vector of the ray.
How can I find a unit vector representing the direction of a ray in 3D space given the pitch and yaw degrees of the ray (and the ray origin, of course)?


texts: Can an individual apple developer account have your own name/studio's name?

texts: I just purchased the iOS developer program for $99. It said on the website that the sellers name would be your name. I think Ketchapp (the creator of 2048) also uses individual. So are you allowed to use a name you created yourself to be your individual account's name? Thanks in advance!


texts:
Recently I worked on a game on Spritekit Engine. My question is not about spritekit, but generaly about game engines.
When I write a loop code and run it (eg while i< 100000) my CPU usage goes to 100%, but when I run the test game there is no changes specially on CPU usage ,why is this so?
(We know game engines runs in a loop that includes logic and graphic commands )


texts: C++ Thread, structuring thread so Gameloop can continue

texts:
I want my thread to run seperately, but I want to be able to keep executing the game loop without killing the thread scope, If I remove the join there is a crash ?

What can I do ?

My desired result is for the unit just to wait while the path is being calculated, but I don't want the game loop to pause, now while it is alot quicker, there are freezes of atleast 1 second over long distances while its stuck in the pl and hpl threads.

thread pl

thread hpl

are my seperate pathfinding threads.

path requester--- only execute path for selected unit if there is a unit requesting in the pathingrequester vector, this is stored in an abstract class.
The units waypoints get pushed onto its waypoint queue when its done.

void pathingrequester()
{
    // executes the requested paths for A* pathing
    if (AWorld.RequestingPath.empty() != true)
    {
        AWorld.RequestingPath.front();
        //cout << "Completed "<< AWorld.RequestingPath.front()->pf_Source->warpPointNO<<"to:"<< AWorld.RequestingPath.front()->UltimateDestination->warpPointNO<<endl;
        astarpathfinder(AWorld.HiFiWaypoints, AWorld.RequestingPath.front()->pf_Source->ret_posX(), AWorld.RequestingPath.front()->pf_Source->ret_posY(),
        AWorld.RequestingPath.front()->UltimateDestination->ret_posX(), AWorld.RequestingPath.front()->UltimateDestination->ret_posY(), AWorld.RequestingPath.front(), AWorld.lines, AWorld.pointsInLine, MainAB.Path);
        AWorld.RequestingPath.pop_front();
    }
}

------------------------------- program execution loop

while (ConqEngine->IsRunning())
{
    bool running = ConqEngine->IsRunning();
    // Draw the scene
    ConqEngine->DrawScene();
    updateTime = ConqEngine->Timer(); // Frame Timer

    thread pl(pathingrequester);
    thread hpl(hpa_pathin_requester);

    if (MainAB.bmenuloop)
    {
        initial_menu_loop(MainAB.loaded_men_interface, MainAB.bmenuloop, MainAB.bloadloop, MainAB.binfoloop ,textControl);
    }
    else if (MainAB.bloadloop)
    {
        preconqload(MainAB.bloadloop, MainAB.bgameloop, MainAB.startingx, MainAB.pipnumber);
    }
    else if (MainAB.binfoloop)
    {
        if (ConqEngine->AnyKeyHit())
        {
            ConqEngine->RemoveSprite(MainAB.LoadingSprite);
            MainAB.binfoloop = false;
            MainAB.bmenuloop = true;

        }
    }
    else if (MainAB.bgameloop)
    {

        thread gl(gameloop, ref(myFont), ref(myFont2), ref(textControl));
        gl.join();

    }

    hpl.join();
    pl.join();

Can anyone give me good example code how to set this up ? or a library that helps handle this?


texts: Simplst possible TBN-Matrix giving weird results

texts:
I'm implementing normal mapping and was trying different techniques of doing that. All seemed not to give me a correct result (e.g. the normals point in weird directions). To find the problem, I broke everything down to the simplest possible solution, but I cant find the problem.

Here is a picture of my scene outputting only the world-space normals:

And here is the scene outputting the transformed normals with the normal map:

As you can see, the normals are not pointed the way they should be (green should be to the right, for example).
Here is the way I caluclate the TBN-Matrix (I know, its not the correct way of doing that, but I tried the "correct" ways too).

vec3 tangent = cross(worldspaceNormal, vec3(0,0,1));
vec3 biTangent = cross(tangent, worldspaceNormal);
mat3 tbn = mat3(tangent, biTangent, worldspaceNormal);

vec3 map = texture(normal, texCoord).rgb;
map = 2 * map - vec3(1);

outNormal = vec4(tbn * map, 0.0);

The worldspaceNormal is just the normal of the surface multiplied by the model-matrix, with w-component 0.0, of course.


texts: How can I play an RTSP video stream in Unity3D?

texts:
I want to play an RTSP video stream on a Texture2D. The stream is coming from an IP camera and is encoded with  H.264, MJPEG or MPEG4.

I know about VLC's libraries, ffmpeg, direct show, media foundation and such, but how do I connect them to Mono develop?


texts: Binary Space Partitioning of 3d Triangle Mesh (for finding nearest points)

texts:
I'm writing a Binary Space Partitioning (BSP) tree for the purpose of optimizing finding the nearest point on the surface of a 3d triangle mesh with respect to another point. I'm currently following a method similar to the one described here to build the tree and then using Barycentric coordinates to locate the nearest points on the surface of the triangles.

I'm having an issue on how to resolve when a triangle is split by the splitting plane (i.e. all three points in the triangle are not on the same side of the splitting plane). One solution presented in the previous link would be to attach these conflicting triangles to the root node, but I'm not sure how this would impact tree traversal. When traversing through the tree and eventually getting to a leaf node containing a set of triangles that are nearest to your query point, which you would have to check each to see which is nearest, would you be also required to check against all triangles in parent nodes?

A different method I thought of would be to just include the conflicting triangles in both the positive and negative children of a node that is split (positive children being above the plane, negative below). This way, they could still be excluded in further iterations of the splitting plane, but it seems a bit redundant.

A final alternative is to instead use vertices to build my tree and once having found the nearest vertex to the query point reference nearby triangles. This would make building the tree much simpler, but because the nearest point is not necessarily a part of the nearest triangle, you are required to retrieve multiple nearest points and query against multiple nearest triangles to ensure you have the correct nearest one.

Each of these methods seems a bit inelegant so I'm hoping there's a simpler solution out there.


texts: Unreal Engine 4.25.4 - CreateDefaultSubobject inside a child component attached to an actor loses values in blueprint editor

texts:
I have the following actor:
UCLASS()
class X_API AMoveableRigidBodyActor : public AActor
{
    GENERATED_BODY()

public:

    // Sets default values for this actor's properties
    AMoveableRigidBodyActor();

public:

    UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Custom")
        USceneComponent* SceneComponent;

    UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Custom")
        UMoveableRigidBodyComponent* MoveableRigidBodyComponent;

};

This Actor makes a reference to a UMoveableRigidBodyComponent and a USceneComponent which I run CreateDefaultSubobject on and attach in the following fashion in the constructor:
AMoveableRigidBodyActor::AMoveableRigidBodyActor()
{

    SceneComponent = CreateDefaultSubobject<USceneComponent>(FName("AMoveableRigidBodyActor_SceneComponent"));
    SetRootComponent(SceneComponent);

    MoveableRigidBodyComponent = CreateDefaultSubobject<UMoveableRigidBodyComponent>(FName("AMoveableRigidBodyActor_MoveableRigidBodyComponent"));
    MoveableRigidBodyComponent->SetupAttachment(SceneComponent);

}

So far, so good.
Now inside my UMoveableRigidBodyComponent I instantiate a few components that are relevant to that component. I expect these components to be visible and manageable from within my blueprint:
UCLASS()
class X_API UMoveableRigidBodyComponent : public USceneComponent
{
    GENERATED_BODY()

public:

    // Sets default values for this component's properties
    UMoveableRigidBodyComponent();

override;

    UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Custom")
        USceneComponent* SceneComponent;

    UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Custom")
        UStaticMeshComponent* StaticMeshComponent;

};

Here I use CreateDefaultsuboject to attach everything to this component:
UMoveableRigidBodyComponent::UMoveableRigidBodyComponent()
{
    SceneComponent = CreateDefaultSubobject<USceneComponent>(FName("UMoveableRigidBodyComponent_SceneComponent"));
    SceneComponent->SetupAttachment(this);

    StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(FName("UMoveableRigidBodyComponent_StaticMeshComponent"));
    StaticMeshComponent->SetupAttachment(SceneComponent);
}

So, all of this feels pretty normal so far. So I go into my editor, create a blueprint that's based off of the AMoveableRigidBodyActor and I assign a static mesh to my component:

Still good. But then I hit the compile button:

The selected static mesh has now vanished from the editor but still seems to be filling the value correctly.
Furthermore, if I put this into the game world you can see that the static mesh sure enough isn't there in the instance:

What am I misunderstanding here?


texts: 2D lighting theory: day-and-night cycle, spot lights at night

texts:
I am writing a rogue-like  'zombie' management game. The game map will be similar to Prison Architect. A top-down 50 X 50 grid.

I want to implemented a day night cycle and during the night I would like the player to be able to position lights.

I would like to be able to lighten and dark to whole map to display the day and night cycle.

Then lights would be a circle of light blocked by game entities such as walls, players, trees etc.

How would I achieve and what is the standard way of achieving this?


texts: C++ property is none when accessed in bp

texts:
I have a class in C++ that I want to access in BP. It appears to be fine in C++ but in BP I get Accessed None errors when I try to use it in BP. Here is the class declaration that I am trying to use in BP

UCLASS(BlueprintType)
class ZOMBIEHORDE_API UQualitySettings : public UObject
{
    GENERATED_BODY()

public:

    // constructors

    UQualitySettings();

    // class functions and properties
};

I am holding on to it in the GameInstance as below so I can access it through the GameInstance reference.

CLASS(Blueprintable)
class ZOMBIEHORDE_API UZombieHordeGameInstance : public UGameInstance
{
    GENERATED_BODY()

public:

    UZombieHordeGameInstance();

    UPROPERTY(BlueprintReadOnly, Category = "Zombie Game Instance")
    UQualitySettings *QualitySettings = nullptr;
};

And GameInstance .cpp

UZombieHordeGameInstance::UZombieHordeGameInstance()
{
    QualitySettings = NewObject<UQualitySettings>();
    ensure(QualitySettings);// this passes and does not throw an error
}

This shows how I am accessing it in a widget blueprint.

So how can it be that accessing QualitySettings in BP is None?


texts:
In the game I have, I'm using an architecture close to what I've seen of Unity components :

Basically, the universe implements the game loop, entities implement and update method, which always delegates to each entity's components.

Components are where the actual data and behaviors sit, quite like a MonoBehavior in Unity I guess.

And I use this architecture to model my whole game.

I use child classes of Entity as prefabs:

class Player extends Entity {
   constructor() {
      this.addComponent(new Transform())
      this.addComponent(new KeyboardControlledMovement(()
      this.addComponent(new PlayerCanvasRender())
      this.addComponent(new Gun())
   }
}

So, I get this kind of Universe - Entity - Component tree :

Question time!

Aside from the entities and the components, there exist Settings, such as ell the key bindings, the reference to the output canvas, the player buffs, ...

They all have to reach various components, and I don't know how to get them there.

So far, I've thought of several possible solutions:

Passing data in parameter of the entities' and components' constructor would be a KISS way of cascading external values. It looks like — if it isn't actually — manual dependency injection. However, in order to — as an example — feed the BulletCanvasRender with a reference on the canvas it has to draw on, it has to be passed through the Gun component, which has nothing to do with rendering; I'm mainly afraid of code cluttering here.
Until now, I've been using the universe as a global crap-bag. This is great since it eliminates the boilerplate associated with manual dependency injection, but it makes the universe initialization function quite large — plus, I have to come up with names for all those new settings properties...
Another option would be to switch to real ECS architecture by completely separating the raw data, which would stay in the components, from the behavior, which would go into external systems, and make use of the external settings from only within the systems. I would still have to perform some kind of manual dependency injection, but it would be limited to a set of non-nested systems. I don't like this solution either since it would cause quite a big change in the code.
Using an DIC, or a service locator to create all the components — or at least those that require injected data.


texts: Why are symbols placed in front of UI texts?

texts:
I've been to play testing sessions from both large and indie studios, and I often see a symbol in front of UI texts during development builds. It most commonly appear in buttons texts, but can also be seen in NPC names and etc.

The symbols are typically a dollar sign ($) or a exclamation sign (!).

A game at Ubisoft for example had exclamation marks in front of every UI text:

!Start
!Load

When someone breaks Skyrim by modding, a dollar sign could be seen as well:

What do these symbols mean / are used for? Placeholder? To be localized? Do the symbols used vary from studio to studio or is there a notation standard of some sort and different symbol mean different things?

Are there any reasons at all for the rest of us to adopt this?


texts: Specular map: What about the specular reflection's highlight' size?

texts:
I think I know what a specular map is and what it's used for (here is an example).

http://www.rastertek.com/dx10tut21.html

One of the models of specularity that are highly popular is Phong.
In Phong there is a parameter sometimes called "shininess" which basically controls the size of the highlight. A large value yields a tiny highlight.

How is that value expressed in the specular map?
It appears to me it is common to use the specular map to control the brightness but not the size of the specular highlight in games.

Am I wrong in thinking so? Mind you I'm not adept in game rendering and well aware that the naive implementation of Phong (with ray-tracing) raises the dot product of the vector from the camera source with the reflected vector of the light beam by the power of shininess which appears computationally heavy but still I wonder:

Are specular maps by definition without Phong's shininess value? Is that rarely or never used at all in interactive rendering? Is the value simply set to a small constant?


texts:
I'm wondering how and where to save the positions my enemies should spawn.

My idea was to use a struct such as:

struct enemy{
    int x,y,type;
}

And save an array of it in a .dat with fwrite() but I'm not sure if it's a good idea.

I want to know how it's commonly done. Also I recently asked a question about events and was answered something about scripting languages like Lua, is this related to the enemy positions too? Could I create a file in a scripting language with them?


texts: Unity3d: Box collider attached to animated FBX models through scripts at run-time have wrong dimension

texts:
I have several scripts attached to static and non static models of my scene.
All models are instantiated at run-time (and must be instantiated at run-time because I'm procedural building the scene).

I'd like to add a BoxCollider or SphereCollider to my FBX models at runtime.

With non animated models it works simply requiring BoxCollider component from the script attached to my GameObject. BoxCollider is created of the right dimension.
Something like:

[RequireComponent(typeof(BoxCollider))]
public class AScript: MonoBehavior
{

}

If I do the same thing with animated models, BoxCollider are created of the wrong dimension.
For example if attach the script above to penelopeFBX model of the standard asset, BoxCollider is created smaller than the mesh itself.

How can I solve this?


texts:
I'm still at the very early stages of my game design -- nowhere near actually needing the sprites yet -- but a thought occurred to me: What's the best way to approach sprites of different dimensions?

In context, my game will use sprites to represent different space ships (long-range plans include a 3D engine with actual ship models, but for now it's 2D with simple sprites). I've always thought of using sprite sheets as the best way to handle multiple different sprites in games. But some of my ships will be bigger than others. So while one ship might be represented by a 20x15 sprite, another might be 25x18.

How should I best approach this? One sprite sheet and somehow include in my sprite objects the dimension of each frame? Or should I group the sprites into different sprite sheets based on their size? Or should every frame on the sheet be the same size (the "biggest"), and just not use up the entire area for every sprite? Maybe abandon sprite sheets entirely in this case?


texts: What are "supporting points" in the context of the SAT?

texts:
I am currently implementing a separating axis theorem collision response. It can be used by oriented bounding boxes and axis-aligned bounding boxes.

So far I have covered face-something contacts. I struggle witth the edge-edge cases. I know the all the axis, penetration depth and the collision normal. But I don't understand the how I can receive a contact point. I read something about using supporting points but what is a supporting point? There are just a few explanations with even less information.

Do you know a good source which explains something? I already digged into some source code of different physic engines. But every engine calculates it different and the comments often don't even exist.


texts:
I am using unity 4.6.6 to create a Xcode build. When I create a build I am getting following error

Cannot initialize return object of type 'Singleton_1_t6738 *' with an rvalue of type 'Singleton_1_t6737 *'


texts: Complex Models using bounding boxes in xna 4

texts:
I'm new to XNA, and have just started looking into collision detection.
I've managed to get a bounding sphere around my first person camera object and i want to check the collision between that and the walls of my cube.
e.g.

this is a cube i have built in Maya and it is 1 combined mesh.
What i want to do i check my bounding sphere against the inside of the walls. and also allow the myself to enter in and out of the holes in the sides and th top.
My first thought would be using each vertex to test against collision but i have no idea how to do this, since this is the first time attempting.
Can anyone point me in the right direction?


texts: Efficient removal and adding of Components in ECS

texts:
i'm working with the Ashley Entity-Component-System (related to libGDX) to program a server-side simulation for an online game and i stumbled upon a serious performance drawback, that is probably caused by how it manages Entity-Sets:

"Family", these are basically descriptors for Entities with a specific set of components.
Removing a component is an costly operation because the Family-instance needs to search through an Array of entities that it manages and remove the Entity from that Array. This is O(n) for every single removal at worst.

And here's my problem:
I have a Family that describes all Entities that do have a position and a velocity component. If i want to remove the velocity-component, for example, to turn it into an static entity and re-add it later to make it move again, this completely eats up my budget of frame time (50ms->20fps) with only ~7000 Entities changing Family back and forth within a frame. At the same time, moving 100000 entities takes only about 15ms at max (without multithreading ~30ms).

I have thought of these options yet:

-Change the data-structure that the Entities are sorted into, this creates new problems, but may still be the most viable Solution, i thought of mapping the Entity IDs to Objects or keeping them in a sorted data-structure.

-Sort everything once after a System has finished execution, requires redesigning a lot of code but probably reduces the time-consumption greatly

-Changing the Entity System, i know of Artemis, but it would be great if you could point me at something else for Java if you know a library that does it better.

-This whole thing may not even become a bottleneck when running the final game-simulation, it might or might not, so just going on and thinking about this later may be acceptable, since I'm probably over-engineering again.

What do you think is the way to go?


texts: Why is my OpenGL triangle not drawing on the screen?

texts:
I am currently following this tutorial to create a simple game engine, but I am doing it using SDL and C++. I am stumped, however, because I can't get a triangle to draw on the screen, and I'm getting no errors from OpenGL. I have read tens of questions regarding the same problem, but I have already implemented the solutions to those problems (missing VAO, missing shaders, wrong size given to glBufferData). I'm only seeing a one-coloured window.
My shaders are defined like this:
#version 330 core

layout(location = 0) in vec3 position;

void main()
{
    gl_Position = vec4(position, 1.0);
}

and
#version 330 core

precision highp float;

out vec4 frag_color;

void main()
{
    frag_color = vec4(0.0, 1.0, 1.0, 1.0);
}

and I load/use them like this:
void Shader::add_program(const std::string& shader_code, GLenum shader_type)
{
    const GLuint shader = glCreateShader(shader_type);
    if (shader == 0) {
        throw std::runtime_error{"Could not create shader"};
    }

    if (shader == GL_INVALID_ENUM) {
        throw std::runtime_error{"Invalid shader type: " + std::to_string(shader_type)};
    }

    const GLchar* programs[1]{shader_code.c_str()};
    const GLint lengths[1]{static_cast<GLint>(shader_code.length())};

    glShaderSource(shader, 1, programs, lengths);
    glCompileShader(shader);

    // Error check using glGetShaderiv

    glAttachShader(shader_program, shader);
}

void Shader::compile_shader()
{
    glLinkProgram(shader_program);
    // Error checks using glGetProgramiv
}

void Shader::bind()
{
    glUseProgram(shader_program);
}

Finally, I have the vertices of the triangle stored like this (Math::Vector3 is just a POD struct with three floats):
std::vector<Math::Vector3> vertices{
    {-1.0, -1.0, 0.0},
        {0.0, 1.0, 0.0},
        {1.0, -1.0, 0.0}
};

and the init/draw code is:
Mesh::Mesh(const std::vector<Math::Vector3>& vertices)
{
    size = vertices.size();

    glGenVertexArrays(1, &vao_id);
    glBindVertexArray(vao_id);

    glGenBuffers(1, &vbo_id);
    glBindBuffer(GL_ARRAY_BUFFER, vbo_id);

    glBufferData(
            GL_ARRAY_BUFFER,
            size * sizeof(Math::Vector3),
            vertices.data(),
            GL_STATIC_DRAW
            );
}

void Mesh::draw() const
{
    glBindVertexArray(vao_id);
    glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);

    glDrawArrays(GL_TRIANGLES, 0, 3);
    glDisableVertexAttribArray(0);
}

On every frame I first clear the window, then call the shader's bind method and then the draw method of the mesh.
Any help is highly appreciated, as I have been trying to tackle this for a long time now!