texts: Correct way of texture-mapping a 2D mesh in libgdx

texts:
this is a question regarding the libGDX framework.

I have managed to UV-map a texture to vertices (in 2D) but have come across a few problems that I think might be caused by incorrect order of vertices.

In the first two pictures, you can see a rendering produced by the code-bits below (without blending enabled). It seems fine at first, but you can clearly notice that the lower triangle seems to have a rough transition. Is there an easy way to prevent this (without writing too much low level stuff) or is this an expected limitation of this approach?

The second problem occurs with the same code but with blending turned on. In the fragment shader, you can see that I adjust the alpha level of each pixel in the region, but with this mesh, it produces a rather weird and distorted image in the right triangle area.

Here's the code:

Shaders

//Vertex shader:
attribute vec4 a_position;
attribute vec4 a_color;
attribute vec2 a_texCoord0;
uniform mat4 u_projTrans;
varying vec4 v_color;
varying vec2 v_texCoords;
void main() {
 v_color = vec4(1, 1, 1, 1);
 v_texCoords = a_texCoord0;
 gl_Position =  u_projTrans * a_position;
}

//Fragment shader:
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
void main() {
 gl_FragColor = v_color * texture2D(u_texture, v_texCoords) + vec4(0, 0, 0, -0.50);
}

Mesh

Mesh m = new Mesh(true, 5, 0,
         new VertexAttribute(Usage.Position, 2, "a_position"), //x,y
         new VertexAttribute(Usage.TextureCoordinates,2,"a_texCoord" + 0)); //u,v
         m.setVertices(new float[]{20f, 360f, 0f,0f, //upper left
                                   60f, 20f, 0f, 1f, //lower left
                                   180f,20f,1f,1f, //lower right
                                   220f, 360f, 1f, 0f, //upper right
                                   20f, 360f, 0f, 0f}); //upper left (closure)

Render

//Gdx.gl.glEnable(GL20.GL_BLEND);
//Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shaderProgram_mesh.begin();
shaderProgram_mesh.setUniformMatrix("u_projTrans", camera.combined);
texture.bind();
m.render(shaderProgram_mesh, GL20.GL_TRIANGLE_STRIP, 0, 5);
shaderProgram_mesh.end();


texts: How do I wait till an animation is finished?

texts:
I am currently working on a Warfare 1917 like game. Right now I am trying to get the combat system working. I have made animations for a running and shooting soldier. It takes exactly 0.5 seconds till the animation lets the soldier shoot.
I have taken out the animations, hud etc. because I put much effort in them and I don't want someone to steal them just now. :) It currently looks like this:

 Obviously they are killing each other too fast. How can I let them wait till the animation is at the point where they can calculate if they die or not?
    This is my code. First it checks if two "soldiers" are in each others vicinity and then I calculate who of those two will die. german.stop(true); britain.stop(true);In the class where I handle the spawning and the animations of my soldiers I have a simple if else statement. Whenever stop = true then the soldier will stay at his current position and does his shooting animation. That this soldier continues to run after killing the other soldier is also a problem, but that's something for a later time.

ArrayList<britain> britainToRemove = new ArrayList<britain>();

ArrayList<germans> germansToRemove = new ArrayList<germans>();

    for (int i = german_array.size() - 1; i >= 0; i--) {
        germans german = german_array.get(i);
        for (int j = britain_array.size() - 1; j >= 0; j--) {
            britain britain = britain_array.get(j);
            if (german.getBounds().overlaps(britain.getBounds())) {
                //handle collision
                german.stop(true);
                britain.stop(true);
                int german_hit = random.nextInt(100) + 0;
                int britain_hit = random.nextInt(100) + 0;
                message = "Red: " + german_hit + "Blue: " + britain_hit;
                if (german_hit > britain_hit) {

                    britainToRemove.add(britain);

                } else {

                    germansToRemove.add(german);

                }
            }
        }
    }
    britain_array.removeAll(britainToRemove);
    german_array.removeAll(germansToRemove);


texts: Event manager/system for an open world adventure game in Unity

texts:
I'm making an adventure game set in a school (think Bully, but much less scope as I am one person) and I'm starting to program the last important systems like a sound manager and an event system and I'm a bit confused about the event system.

Basically, I want to be able to track stuff like missions completed that may cause some stuff to happen like changing dialogue of a character. One other example is that talking to one character before another will cause you to interact with them differently. I don't want to handle this kind of stuff for each indivdual NPC, especially since each NPC has one script that holds stuff like their current dialogue and other important data.

Another thing in my game is that the time is based on periods rather than a real-time system. Every time you complete a mission or some other event, it will change (the periods are Morning, Afternoon, Evening, and Midnight), which also changes the position of NPCs and may also change their dialogue.

How would I design such a system?


texts: How do I convert matrices intended for OpenGL to be compatible for DirectX?

texts:
I have finished working through the book "Game Physics Engine Development 2nd Ed" by Millington, and have got it working, but I want to adapt it to work with DirectX.

I understand that D3D9+ has the option to use either left handed, or right handed convention, but I am unsure about how to return my matrices to be usable by D3D. The source code gives returning OpenGL column major matrices (the transpose of the working transform matrix shown below), but DirectX is row major.

For those unfamiliar for the organization of the matrices used in the book:

[r11 r12 r13 t1]
[r21 r22 r23 t2]
[r31 r32 r33 t3]
[ 0   0   0   1]

r## meaning the value of that element in the rotation matrix, and t# meaning the translation value.

So the question in short is: How do I convert the matrix above to be easily usable by D3D?  All of the documentation that I have found simply states that D3D is row major, but not where to put what elements so that it is usable by D3D in terms of rotation, and translation elements.


texts: Unity3D rendering only some triangles in a mesh - and triangle fans?

texts:
In my OpenGL apps, one of my tricks that I've used often for displaying heads up displays and ui elements, is to have a sorted mesh of triangles and then only render a portion of them.

In one game I have a circular fuel gauge.  I made a mesh of triangles using a triangle fan that spans around the circle.  In code I can limit the number of triangles that it's drawing to make the fuel gauge appear at that % of fuel.

So in this example I take the % of fuel left, multiply by the number of segments in the fan, and then draw it:

    glDrawElements(GL_TRIANGLE_FAN, (int)remainingFuel+1, GL_UNSIGNED_INT, (void *) (0 * sizeof(GLuint)));

If 50% of the fuel is left it draws 50% of the triangles in the fan which appears to be half the circle shape.

Can this easily be replicated in Unity3D?  Where I can limit the range of triangles of a mesh that will render to a specific start and stop range?

Does Unity3D even do triangle fans?

Or do I need to figure out a new way to do this?

By the way I do know how to create procedural meshes in unity code (C#) but am still fairly new to Unity.  I know I could store the entire mesh in one class and then copy only a portion of it to a game object based on the fuel level.  I'd rather not create a new version of the mesh for each frame because the fuel is constantly changing.  It seems more efficient to just limit the count on a non-changing mesh.


texts: Storing game resources in the *.dat file format to reduce file size

texts: How can I store sprites(png) or audio files(wav) in the *.dat file format?


texts: How can I navigate to a target between bodies moving along fixed paths?

texts:
The problem: An autonomous ship starts at the outskirts of a solar system, and wants to move to a moving target, which is one of the planets. There are also many other planets moving at the same time, and these should be considered the only obstacles. I want to find the optimal path to the target. To keep it simple, the world is 2D, and the planets are moving in uniform circular motion around the sun as opposed to how planets actually behave.  Also, assume the ship knows pretty much everything about the world. Most importantly, the location, speed, and orbit radius of every planet.

With complete knowledge, this seems conceptually simple. For any planet and any time, you can find its location by doing some fairly simple math. But how would you apply this to pathfinding? Would it be just to pathfind in 3 dimensions: x, y, and t? In theory this makes sense, but I think working that out to an actual solution would involve a lot of complications. Is it really as simple as 'setup a* on a grid with x,y,t values'?


texts: How to make an additional in-game content download (patching) for first time launching the Mobile Store Game?

texts:
this is a pretty common but I googled everywhere and nothing.
When there is a game with very big download size, more than 500MB for example,
I often saw that the additional game content is being downloaded during first time launched.
Pretty common, most of the mobile game did this.
But I am wondering how can I did these in Unity? that split the game content out from the deployed game package? or is this method offered in Unity Plus/Pro? not Personal?


texts: giving to object velocity to the direction it facing (unity)

texts:
I making 2d game on unity5 .I want to give to an object starting velocity to the direction it is facing(looking).(I put it in the "start" method)
how can i do it?


texts: Camera view matrix from position/yaw/pitch/worldUp

texts:
I'm trying to make a basic FPS camera view matrix, using position, pitch/yaw, and worldUp.  Currently, my camera's view matrix is just a plain rotation matrix (made with yaw/pitch/roll) and the result is the view appears to be looking down the negative Z-axis, which in my case is my floor. Most tutorials I can find recommend making a view matrix by passing in an "eye" and "target" vector.  But this isn't a desirable setup for an FPS camera where I only know the position and angles (pitch/yaw/roll) of the camera -- I don't have a specific point in mind that I want the camera to be focused on!

I'm using OpenGL as a renderer, but I don't want to use GLM as I'd wish/hope to understand how to implement this without helper libs.  Also, my meshes and world matrices are made so that Z is my worldUp, X as forward, and Y as right/left. That might seem odd, but old Unreal engine games used this setup and I'm just accustomed to it for mapping/modding.

As mentioned my view matrix is currently looking down at the floor, but I'm not surprised that it's wrong because I've never incorporated or multiplied my worldUp vector into the matrix, and I don't understand how to.

So that's my question: How exactly do I incorporate my worldUp vector into my rotation matrix, to turn it into a proper view matrix -- or better yet, what is the proper method for constructing a view matrix when you have exactly these variables:
1.) Camera Position (XYZ)
2.) World Up vector ("0,0,1" for me)
3.) Camera Pitch/Yaw/Roll (Really only need Pitch/Yaw!)

I've been going through loads of tutorials and I can't find what I'm looking for.  This is how I've started, but all it is is a normal rotation matrix, so honestly a full methodology would be really appreciated as I've been pulling my hair out over this for a week now.  Thank you for any guidance on this.

MAT4X4F mrol;
MAT4X4F mpit;
MAT4X4F myaw;
float cr, cp, cy;
float sr, sp, sy;

cr = cos(_cam_roll);    cp = cos(_cam_pitch);   cy = cos(_cam_yaw);
sr = sin(_cam_roll);    sp = sin(_cam_pitch);   sy = sin(_cam_yaw);

// Yaw (about Z-axis)
myaw.m[0] = cy;     myaw.m[1] = -sy;    myaw.m[2] = 0.0f;   myaw.m[3] = 0.0f;
myaw.m[4] = sy;     myaw.m[5] = cy;     myaw.m[6] = 0.0f;   myaw.m[7] = 0.0f;
myaw.m[8] = 0.0f;   myaw.m[9] = 0.0f;   myaw.m[10] = 1.0f;  myaw.m[11] = 0.0f;
myaw.m[12] = 0.0f;  myaw.m[13] = 0.0f;  myaw.m[14] = 0.0f;  myaw.m[15] = 1.0f;

// Pitch (about Y-axis)
mpit.m[0] = cp;     mpit.m[1] = 0.0f;   mpit.m[2] = sp;     mpit.m[3] = 0.0f;
mpit.m[4] = 0.0f;   mpit.m[5] = 1.0f;   mpit.m[6] = 0.0f;   mpit.m[7] = 0.0f;
mpit.m[8] = -sp;    mpit.m[9] = 0.0f;   mpit.m[10] = cp;    mpit.m[11] = 0.0f;
mpit.m[12] = 0.0f;  mpit.m[13] = 0.0f;  mpit.m[14] = 0.0f;  mpit.m[15] = 1.0f;

// Roll (about X-axis)
mrol.m[0] = 1.0f;   mrol.m[1] = 0.0f;   mrol.m[2] = 0.0f;   mrol.m[3] = 0.0f;
mrol.m[4] = 0.0f;   mrol.m[5] = cr;     mrol.m[6] = -sr;    mrol.m[7] = 0.0f;
mrol.m[8] = 0.0f;   mrol.m[9] = sr;     mrol.m[10] = cr;    mrol.m[11] = 0.0f;
mrol.m[12] = 0.0f;  mrol.m[13] = 0.0f;  mrol.m[14] = 0.0f;  mrol.m[15] = 1.0f;

_cam_matrix = myaw * mpit * mrol;


texts:
I've recently begun working on a tile-based tactical game, and I have questions regarding a couple of key moments.

Is it feasible to organize the tilemap as an array of containers, which can hold the game objects? What are the pros and cons of such an approach? Should I make a single container class for all the game objects, such as characters, walls, and terrain, or try to break it down to separate container types for every single game object class?

Any examples of a container capable of storing objects of several different classes will be greatly appreciated.


texts: How do I find the location of a GameObject in C#

texts:
I'm making an elevator script. Essentially I'm wanting to find the difference between two empty objects so that I can move the elevator between them.

To be able to do this, I need to be able to get the location of both GameObjects in my script. From a bit of searching, I haven't been able to figure it out.

How would I go about doing this?


texts: What is a good linear algebra book for game programmers?

texts:
I was told that I should start learning Linear Algebra in order to create good games with good physics.

I'm reading Linear Algebra book and it's completely foreign to me. The author starts out with solving linear equations (two equations, two variables) and I remember learning about that in school, but almost immediately he jumps into other things that seem to be taken directly from the Necronomicon.

What book can I read to learn some good math, but starting from the fundamentals?

Thanks a lot for the help.


texts: I'm using blender for the 3d stuff and am trying to make game effects for the character I made, I am using unity. I am not really familiar with creating game visual effects but I do know how to make sprite sheets. How do I create a 3d effect in unity? like a shock wave or an explosion, because I cant do it using a sprite sheet.


texts: Can the solar system be accurately represented in 3d space using doubles (or longs)?

texts: I would like know to how to best manage coordinates in a 3D game whose aim is to realistically model the entire solar system, yet be able to handle the smallest movements in a "ship" (ie: perhaps we can consider 1cm to be the smallest acceptable movement for a frame). Do 64-bit doubles (or 64-bit longs) support this, or do we run into overflow problems? If not, then should longs or doubles be used, or if so, then which alternative approach do you think is the most sensible for modelling positions in the solar system in a 3D game? (ie: only holding a bit of the system in the display at a time based on distance to ship, or having the system somehow represented in a different co-ordinate space etc)


texts: Integrating specular, diffuse reflection and refraction

texts:
I am implementing an MLT bidirectional path tracer. I have a problem integrating diffuse, specular reflection and refraction.

1) The first problem is diffuse and specular reflection. Diffuse reflection is done by sampling ray in a hemishere. But specular reflection is done by finding the ray that have an angle to the normal equal to the incident ray with the normal. However, an object can have both diffuse and specular reflection. When to use specular reflection or diffuse reflection for a ray?

2) Same as the first question but this time integrating reflection with refraction.

I've seen a few research papers and websites online where the scene have specular, diffuse reflection and refraction, but they have no tutorial on how to do this.


texts:
I am currently working on a program that should generate random noise on a screen based on the 'coordinates' of a pixel. The coordinates should have the same color every time you restart the program. However, using the Java's util.Random, the results I get are not as random as I'd like:

I thought that if I used the combined coordinates (as in one integer formed from both coordinates next to eachother) each coordinate would have a different number. By using that number as a seed I expected to get a different random numbers for each coordinate to use for the rgb value of that coordinate.

This is the code I used:

public class Generate {

static Random Random;

    public static int TileColor(int x, int y){
        Random = new Random(Integer.valueOf(Integer.toString(x)+Integer.toString(y)));
        int b = 1 + Random.nextInt(50);
        int g = 1 + Random.nextInt(50);
        int r = 1 + Random.nextInt(50);
        int color = -Color.rgb888(r, g, b);
        return color;
    }
}

Is the pattern that the program creates due to the way java's Random function works or am I doing something wrong and should I try a different approach?

Update:
I now tried to get rid of the problems surrounding concatenation by using the following code:

public static int TileColor(int x, int y){
            Randomy = new Random(y);
            Randomx = new Random(x);
            Random = new Random(Integer.valueOf(Integer.toString(Randomx.nextInt(1234))+Integer.toString(Randomy.nextInt(1234))));
            int b = 1 + Random.nextInt(100);
            int g = 1 + Random.nextInt(100);
            int r = 1 + Random.nextInt(100);
            int color = -Color.rgb888(r, g, b);
            return color;
}

Somehow, this also provided a (in my opinion) sufficiently random image:

This code does however reseed three times per pixel. Even though this is not a problem for me right now, I do consider changing this code in case I need better preformance later on.


texts: Firing a particle effect toward the tapped target

texts:
I am editing this game, where i have to destroy this pyramid when user will tap, i want to  show particle effect moving towards Pyramid Like this:

but sometime it is not moving towards pyramid like this but moving straight Like this:

Script for RayCast and Particle Effect Instantiation:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class General : MonoBehaviour
{
    public static GameObject currentPyramid;
    RaycastHit Hit;
    public GameObject LineStart;
    public GameObject ParticleEffect;

    void Awake(){
    }
    void Start(){
    }
    void Update ()
    {
        Debug.Log (currentPyramid);
        if (Input.GetMouseButtonDown (0)) {
            RaycastHit hitInfo = new RaycastHit ();
            bool Hit = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),
                                       out hitInfo);
            if (Hit) {
                currentPyramid = hitInfo.transform.gameObject;
                if (currentPyramid != null) {
                    Instantiate (ParticleEffect,
                                 LineStart.transform.position,
                                 LineStart.transform.rotation);
                }
            }
        }
    }
}

code for Pyramids

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PyramidScript : MonoBehaviour
{
    void Update () {
        if (PlayerPrefs.GetString ("Pyramid") == gameObject.name) {
            General.currentPyramid = this.gameObject;
        }
    }
}


texts:
This is a very rough sketch of how I currently have things designed.  It should, at least, give an idea of how my ECS is currently designed.

If you notice in that diagram, I have basically split the HUD out of the ECS. They have their own set of things (HudLayer, HudComponent, etc) and are handled differently. This is where I'm struggling, though.

There are many different instances in which the HUD will need to know about entities. Not just data changing (I have an event dispatcher for that), but the actual entity and all it encompasses. There are also situations where entities will need to be able to query the HUD for data. Let's take a couple examples:

First, my equipment screen. On here I can change the equipment on a character (Entity). In order for this to happen, I need to know about the entity. At least I think I do?  How can I handle this?
The second scenario involves my Systems needing to query a HudComponent for data. A specific example would be my battle system. Each "team" is given a 3x3 grid they can move around in. See here:

Skills target these cells, and not the player, so I would need a way for my systems to determine which cells are occupied and which are not. Basically I need a way for two way communication between Systems and my HUD. I know it's recommended (by some people, anyways) to take your HUD out of the ECS. Is that appropriate in my case?


texts:
I'd like to make a simple 2d car crashing game, where the player would drive his car into moving traffic and try to cause as much damage as possible in each level (some Burnout games had a mode like this).

The physics part of the game is the most important, I can worry about graphics later. Would engine like emini or box2d work for this kind of game? Would Android devices have enough power to handle this? For example if there were about 20 cars colliding, along with some buildings, it would be nice if I could get 20 fps.


texts:
I would like to rotate an FPS camera slightly upwards during a shot as an effect of recoil, but the problem is that I have a mouse look script as well and I assume it prevents me from achieving the effect i want.
So far I have tried using transform.Rotate(-10,0,0) and

transform.rotation = Quaternion.Euler(transform.rotation.x - 10, transform.rotation.y, transform.rotation.z);

both rotated the camera upwards but then the camera moved back downwards to the initial position. Does anyone know how I can rotate the camera and keep the rotation? Or if there is any better way to achieve this effect.


texts: in unity, lightmap comes out blurry on android device

texts:
as you see, shadow is blurred. (see the tree's shadow)

What settings should I add?


texts:
I would like to create a 2D game, where a character should move on a stage/level. My stage would be static, constructed some little cubes, similar to the well-known Mario game: some of the elements should represent an element of the way where the character can step, but if the element is missing, the character should fall.

My problem is, how to represent this programmatically? My first thought was to represent the stage with a vector, which should contain boolean elements, depending on the state of the element on the stage - if it's missing or not. But this means, I have to verify at my character's x or y position change if it has a stage element under or not (if not, to simulate the falling of the character) - I think it is not the best practice, it's not the beautiful solution.

Can you help me with some advice, how to represent the stage?


texts: How do I clear a specific render target when more than one are set?  Or how do I keep the depth but clear the color?

texts:
Let's say I set two render targets

GraphicsDevice.SetRenderTargets(rt0, rt1);

If I call

GraphicsDevice.Clear(Color.Transparent);

both render targets will be cleared.

Therefore, how can I clear a render target at a specific index?  For example just 'rt1' and not 'rt0'.

I would like to avoid texture baking the contents of 'rt0' to another render target and copying them back to 'rt0'.  This is because PreserveContents on the XBOX 360 can only hold one render target in memory.

EDIT:

Is there any way just clear the color for a render target?  I would like to keep the depth for depth reading.


texts:
I have the following piece of C++ code which I use to load triangle vertices from an FBX file:

FbxNode *node = scene->GetRootNode()->GetChild(0);
FbxGeometryConverter fbx_converter(node->GetFbxManager());
fbx_converter.Triangulate(node->GetNodeAttribute(), true);
mesh = node->GetMesh();
int num_vertices = mesh->GetPolygonVertexCount();
FbxVector4 *fbx_vertices = mesh->GetControlPoints();
int *fbx_triangle_vertices = mesh->GetPolygonVertices();
double x, y, z;
vector<vertex> vertices;
for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index)
{
    int index = fbx_triangle_vertices[vertex_index];
    x = (double)fbx_vertices[index][0];
    y = (double)fbx_vertices[index][1];
    z = (double)fbx_vertices[index][2];
    vertices.push_back(vertex(vector3(x, y, z), material(color(1, 0.5, 0.5), 0, 0, 0, 0, 1, 0)));
}

Currently, I am only loading vertex coordinates from the file. Now I want to load the vertex's material data (instead of assigning it manually like I did in the code snippet using material(color(1, 0.5, 0.5)...).

I see that an FbxNode object has a GetMaterial() method, but I don't know how to obtain this data since I am working with fbx vertices which are FbxVector4s, not nodes.


texts: I recently was a tutorial use substances in Unity3D. I understood that a Substance is a material we can dynamically manipulate at run time, but I am still unclear about it. Could someone shed some light on this?


texts: Could not establish connection with local server process when opening or making Unity project

texts:
Whenever i try to either create or open a Unity project, I get faced with this error.

Does Unity need a proxy server, because I dont have one. (If so, how do I get one?) And
apparently I need to add some environment variables, (HTTP_PROXY, HTTPS_PROXY and
UNITY_NOPROXY=localhost,127.0.0.1) what values do i add to these?

Unity Package Manager Diagnostics (v0.1.5)

Ran 7 checks

1 succeeded

6 failed

❌ UPM registry reachable (FAIL)
Make an HTTP request to the UPM package registry

    Connection error. This could be because a proxy is misconfigured.

❌ Ping UPM registry (FAIL)
Measure the latency of the UPM package registry API

    No successful pings could be made in 0.062 seconds (30 failed)

❌ Ping UPM download (FAIL)
Measure the latency of the UPM package download endpoint

    No successful pings could be made in 0.039 seconds (30 failed)

❌ UPM registry download speed (FAIL)
Test the Internet connection using the UPM package registry

    Connection error. This could be because a proxy is misconfigured.

❌ Speedtest.net (FAIL)
Test the Internet connection using Speedtest.net

    Connection error. This could be because a proxy is misconfigured.

✅ HTTP proxy environment variables (PASS)
Detect whether proxy-related environment variables are set (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY, UNITY_PROXYSERVER, UNITY_NOPROXY)

    Proxy support has been configured through the following environment variables:
    HTTPS_PROXY = C:\Program Files\Unity Hub\Unity Hub.exe
    HTTP_PROXY = C:\Program Files\Unity Hub\Unity Hub.exe
    UNITY_NOPROXY = C:\Program Files\Unity Hub\Unity Hub.exe

❌ UPM health check (FAIL)
Start the UPM process and call its health endpoint

    Server started but did not respond to health requests:
    Error: Invalid protocol: c:

How do I fix this?


texts: Relating a point after an image is panned and zoomed

texts:
For Android, let's say you have a image of a map that you draw inside your view. On this map there are many, many "hot spot" locations where you want your user to be able to select. Given that there are so many, you want to give the user the ability to zoom the image, and since it can be zoomed, they need the ability to pan the image too.
Once the user pans and zooms though, the coordinates that originally related to the hot spots have changed since the location the user touches will be based on the view, not the image.
How do you translate the new coordinates back to what they would have been originally before the panning and zooming were done?
Here is the question asked on JavaRanch which may make this more clear:
http://www.coderanch.com/t/567402/java/java/translation#2577725
THANKS!

You're trying to do a coordinate transform, yes?

No, not in the sense that I am doing anything like what I THINK you mean.

What you need to do is apply the transform from the map space to view space in >reverse, or rather undo said transformation.

Hmmm...there is no "map" per se, just the Android screen (the view port I guess you could say) and the image drawn onto it which CAN become larger than the screen.

First store the location and magnification of your viewing area or camera somewhere.

Well, there is no "camera" as in what I think you mean. This isn't 3D, just 2D. The original magnification is 1. Not sure what I would need to store in this case.

Assuming you store the magnification as something like real units/view units or area >of map/area of view. You can then convert from view in magnified units to real units >by doing screen location*magnification. Divide if your ratio is flipped.

Real units? I'm dealing with pixels on a phone.

Now that you have the location relative to the screen in real units you simply do >camera location + relative location which gives you your map location. This does >assume that camera position is in the map coordinate system.

Again, there is no camera position. This is just a phone with an image on it. No 3D. Just a human looking at an image on a phone.

For camera to world transform: (location * magnification) + camera position

So given that there is no camera, what would be used here instead?

For world to camera transform: (location - camera position)/magnification

Again, I am not sure that this is applicable here as there is no camera to have a position.

remember the */ signs flip for view/real rather than real/view
For something more elegant look into how graphics systems do coordinate transforms. >For a 2D system without rotation I think the above is sufficient though.

I really appreciate the effort but I do not see this answer as answering the question.
If you look at the code I linked to, I think the question will become much more clearly defined.
It's just an image on a phone that the user can pan and zoom. I keep a pan and a zoom multiplier around and know the touch point on the screen. No camera, no world coordinate system, nothing like that at all. Just an image on a phone that can be manipulated.


texts:
Simple question:

I have this image that is 200x200. I want to change it to 100x200 inside the HSLS, making it thin. Anyone have idea? I tried to do something like

output *= tex2D(CustomTextureSampler, float2(input.UV.x*2,input.UV.y));

Didn't work. it simple returns black.


texts:
I'm looking to have several icons within a label; for example a coin instead of a dollar sign. I'm using a TTF font, and as much as I'd like to keep it that way (simply because I've heard it's "better"), I've looked into using a Bitmap Font Generator to embed images and replacing some unicode characters with arbitrary icons specific to my game. Seems like you're not able to preserve color that way.

Here's an example tool I've looked at, Bitmap Font Generator, from the cocos2dx docs.

My question is there some other way to embed icons with color in either a TTF or BMP font, other than replacing arbitrary characters with icons?


texts: Elegant way to simulate large amounts of entities within a game world

texts:
Assume you have a game in which there are many (many many) entities serving some functions, not all of which are constantly needed or need to be considered in every frame. The concrete problem I am working on in which this issue is present is a detailed simulation of a body including its organs.

In the game each creature has its own body which is separated into smaller parts (torso, legs etc.) and sometimes these parts contain organs, which serve a specific function within the body. Whether or not an organ currently serves a purpose or is active is never actually clear. After all, an animal might have an empty stomach which therefore does not need to digest anything. It would be quite ridiculous to check or simulate every object in each frame and very costly as soon as you have many creatures in the world. So I was thinking about a way to smartly differentiate between objects that need to be updated and those that don't.

What I came up with seems like an at least ok solution. It creates a simple queue/stack (essential is that each element gets removed as soon as it's read; the order is irrelevant) called the "attention stack" where objects that need to be simulated reside. Objects that need attention would simply put themselves onto the stack or are put there by other objects. These objects would probably implement a simple interface with a simulate()-function.

Applied to my previous digestion example this would mean:

The player chooses something to eat (assume it's bread) from the inventory and puts it into the mouth of his character and the mouth is put onto the attention stack. In the next frame the the mouth is taken from the stack and its simulate()-function is called. Since it's a mouth it would be reasonable to simulate chewing here. This could go on for a few frames in which the mouth keeps putting itself onto the stack until it decides the food is ready to be swallowed. In this case the mouth puts the chewed bread into the stomach (I know it doesn't go there directly, but the esophagus is left out for simplification), which is then also put onto the attention-stack. In the next frame the simulation of the digestion-process is started. And so on for the rest of the necessary organs.

A foreseeable problem with this are idling objects. A sleeping animal is a good example of this. It could be done as previously described by keeping the sleeping animal on the stack and checking each time if it needs to wake up, but that seems wasteful since that's the only thing being done. To make idling objects more efficient I was planning to add a sort of schedule which stores jobs to be performed at a specific time. If an animal goes to sleep it would put a job on that schedule which would be scheduled for a certain amount of time after the animal went to sleep. This job would then take care of putting the sleeping animal onto the attention stack again. Now, you could say that a sleeping animal that isn't on the attention stack could miss being attacked by something because its A.I. is not simulated, but this is prevented if the attacking object takes care of putting that animal onto the stack again.

Now, I honestly don't know if this is even close to an elegant solution to this problem due to a lack of experience. Am I close to something usable? How is this usually done or does anybody have any suggestions or better solutions?


texts: Best practice/way for client to speak with server

texts:
I'm making a multiplayer game in HTML5 Canvas and Node using Express and Socket.io. It's a platformer style game and so far the players are able to see each other and move around on the screen. It works pretty well, but most of my game logic is client side which I believe might become a problem. The movement of other players at the moment isn't very smooth at all. So far, the only thing the server does is recieve the position and velocity of the players, and then broadcast it out to all the other players so they can see each other. I was wondering if there was a smarter way to go about this? Everything like collision detection, movement, key inputs etc is all used client side. Should this be server side instead? I could imagine that if I calculated things like collision detection and movement server sided, then there would be no way for the player to do things like edit their position via the browser console and change their size etc.

I hope it's not too complicated. I haven't written much code yet since I would like to make sure I do it the correct way from the start without having to change and rewrite a lot of code. Let me know if you'd like to see my code.


texts: How can I obtain in-game data from Warcraft 3 from an external process?

texts:
I am implementing a behavior algorithm and would like to test it with my lovely Warcraft III game to watch how it will fight against real players.

The problem I'm having is that I don't know how to obtain information about in-game state (units, structures, environment, etc.) from the running WC3 game. My algorithm needs access to the hard drive and possibly distributed computing, that's why JASS (WC3's editor language) isn't appropriate; I need to run my algorithm from a separate process.

Direct3D hooking is an approach, but it wasn't done for WC3 yet and a significant drawback of that approach would be the inability to watch how the AI performs online, since it uses the viewport to issue commands.

How I read in-game data from WC3 in a different process in a fastest and easiest way?

Precisely what I need for Warcraft 3 exists for Starcraft: BWAPI.


texts:
I am trying to rotate a line to point to the mouse's world coordinates (rather where the mouse lies on the plane where y=0).

I am running into a couple of problems though:

Whilst it follows the mouse the line doesn't always lie directly beneath the cursor, which is what I would expect to see. It seems to be perfect when the position is at the origin and less accurate the further away from the origin I get.
The rotation doesn't go from 0 - 360, rather 0 - 180. I think the solution here is to use a dot product but the first problem is preventing me from fixing this problem.

Here's where I calculate the angle by which to rotate:

Calculating mouse position

 Vector3 near, far, dir;
 unproject(*mouse_, near, far);
 dir = near - far;
 normalize(dir);

 float t = -near.y / dir.y;
 Vector3 point = near + (t * dir); //where the mouse lies on the plane y=0

I'm almost certain the above is correct as when I draw a point at point the rendered point is directly beneath the cursor on the plane y=0

Calculating angle between the line and the point.

 rotation_.y = angleBetween(position_ - dir_, position_ - point);
 rotation_.y = radToDeg(rotation_.y);

position_ is where I want the line to start from. Which is the player's position at the moment.
dir_ is the direction of the line, set to and never changed Vector3(0.0f, 0.0f, 5.0f);

 float angleBetween(const Vector3& a, const Vector3& b) {
     float cosTheta = dot(a, b) / (length(a) * length(b));

     return acos(cosTheta);
 }

Here's how I am drawing the line:

 glPushMatrix();
 glTranslatef(position_.x, position_.y, position_.z);
 glRotatef(rotation_.x, 1.0f, 0.0f, 0.0f);
 glRotatef(rotation_.y, 0.0f, 1.0f, 0.0f);
 glRotatef(rotation_.z, 0.0f, 0.0f, 1.0f);

 glDisable(GL_LIGHTING);
 glLineWidth(3.0f);
 glColor3f(0.0f, 1.0f, 1.0f);
 glBegin(GL_LINES);

 glVertex3f(0.0f, 0.0f, 0.0f);
 glVertex3fv(end_.toArray().data()); //toArray() returns and std::array of the vector

 glEnd();
 glPopMatrix();

And just in case it matters, for the camera I do:

void Camera::transform() {
    gluLookAt(position_.x, position_.y, position_.z,
              target_.x, target_.y, target_.z,
              0.0f, 1.0f, 0.0f);
}

target_ is also the player's position.

I hope this is enough information.


texts:
I generate a 3d isometric terrain with the help of badlogicgames. I pass a perspective camera to the spriteBatch projectionMatrix, but when I move my player (perspective camera follows my player) it seems like the terrain is moving - here's some video of my game. I think the terrain should be static. I am also using decalBatch; my decals look fine - they remain in their position instead, the terrain does not.

This is part of the code where I render terrain:

sb.setTransformMatrix(matrix);
sb.setProjectionMatrix(cam.combined);//is perspective
sb.begin();
for(int z = 0; z < 100; z++) {
    for(int x = 0; x <80; x++) {
        sprites[x][z].draw(sb);
    }
}
sb.end()

here is the third person camera

cam.lookAt(player.getX(), 0, player.getZ());

cam.position.set(player.getX(),7f,player.getZ()-10f);

playerDecal.setPosition(player.getX(), player.getY(), player.getZ());

The problem is that terrain keeps moving around along with my camera's position. Does anybody have a clue?


texts: How do I ensure that my 2D side-scroller camera stays within the world bounds?

texts:
I have tried implementing a basic 2D sidescroller camera in XNA, but I don't want it to be able to scroll past the edges of my tile map!

I tried to fix it, but when I get the left side working, the right stops working...

How do I do this right?

EDIT: After Anko

public Matrix transform;
Viewport view;
Vector2 center;

public void Update(GameTime gameTime, Player player) {
    center = new Vector2(player.Position.X + (player.Bounds.Width / 2) - (960 / 2), 0);

    float cameraX = center.X;
    float cameraWidth = view.Width;

    float worldWidth = 1760;

    if (cameraX < 0)
        cameraX = 0;
    else if  ( cameraX + cameraWidth > worldWidth)
        cameraX = worldWidth - cameraWidth;

    transform = Matrix.CreateTranslation(new Vector3(-cameraX, 0, 0));


texts:
I am creating a ski slalom game and I coded a new physics routine, because I was told the rigidbodies are pure "not overly good thing" to use by my boss. With my physics routine it indeed looks much better, but I have no idea how could I make the skier look less plastic. Which means I want to achieve similar level of control like in Skiing Yeti Mountain, because there the physics is quite enjoyable, though still arcade. Basically the requirements are that I need to set up acceleration, top speed and the amount of grip to use when turning, but it somehow bites me back

    [SerializeField]
    private Vector2 slopeDirection = -Vector2.up;

    var dt = Time.fixedDeltaTime;
    var dirVector = Vector2.zero;

    dirVector.x = Mathf.Cos( radianOrientation );
    dirVector.y = Mathf.Sin( radianOrientation );

    float actualAcceleration = Mathf.Abs(Vector2.Dot(dirVector, slopeDirection));
    actualAcceleration = Mathf.Lerp(maximumAcceleration, 0, actualAcceleration) * Mathf.Pow(maximumAcceleration, accelerationSmoothing);

    velocity.x += actualAcceleration * dirVector.x * dt;
    velocity.y += actualAcceleration * dirVector.y * dt;

    Vector2 velocityDirection = velocity;
    velocityDirection.Normalize();

    float actualFriction = Mathf.Abs(Vector2.Dot(dirVector, slopeDirection));
    actualFriction = Mathf.Lerp(minimumFriction, maximumFriction, actualFriction) * Mathf.Pow(actualFriction, frictionSmoothing);

    // Simulate friction
    velocity *= actualFriction;
    Debug.Log(velocity);

    if(!_isFinished)
    {
        this.transform.position += new Vector3(velocity.y, -velocity.x, 0);
    }

why it is overly odd is that when I turn to the side it has a very abrupt power loss and when I turn the skis to 45 degrees to the slope. how could I achieve that the skier will slow down when he turns his skis, but after a little while it will accelerate again like in Skiing Yeti Mountain?


texts:
I just started on a new project. In this project one of the main gameplay mechanics is that you can grab a ledge on certain points in a level and hang on to it.

Now my question, since I've been wrestling with this for quite a while now. How could I actually implement this? I have tried it with animations, but it's just really ugly since the player will snap to a certain point where the animation starts.


texts:
I want to create a pool game using Unity.

I added the spheres as playballs and cubes as the walls.
I added a rigidbody to all objects and Im able to do some basic collisions like in a pool game.

My Question is:

What physics settings do I need to apply to make the pool game realistic?

Right now, it's a bit weird. The ball does not bounce off the walls realistically and also the ball to ball collisions are not ok.

Any suggestions?


texts: Building a game project in C# for Unity in VS?

texts:
Say that a project needs to be created from scratch for later use in Unity, for scripts. What is the ideal way to setup this without using a template in Visual Studio?

Can this be created in C# with some simple classes and one or two game loops?


texts: How to make wall tiles overlap floor tiles a bit in Unity3D?

texts:
Currently my tiles are very strictly placed, there are wall tiles, and floor tiles, and they don't overlap at all.

What I want to achieve is to have my walls overlap my floors a bit.

So their inner edges doesn't have to be a stright line, but a free shape, with "transparent holes" which show the floor below. Resulting in a much better feeling.

My current approach is to have multiple layers. One for the floor and wall (single) tiles), and one above this, which will have the overlapping, decorative parts of the walls.

But this methods feels slow and clunky:

For one wall tile I have to place 9 tiles/tileparts to make it look nice. (the tile itself plus the neighbours).

It would be better to place just one tile which got overlapping parts


texts:
I am planning to place three cards on a view which I add to the background. However I wanted to combine two of the cards and replace the first card position with the new card position. Is there any way I can do this?

I am trying to read the selected node position by:

CGPoint position = CGPointMake([self nodeAtPoint:touchLocation].position.x, [self nodeAtPoint:touchLocation].position.y);

However what I read is (0,0).

What happened?


texts: How to efficiently map tokens to code in a script interpreter?

texts:
I'm writing an interpreter for a simple scripting language where each line is a complete, executable command. (Like the instructions in assembler)

When parsing a line I have to map the requested command to actual code. My current solution looks like this:

std::string op, param1, param2;
//parse line, identify op, param1, param2
...
//call command specific code
if(op == "MOV")
    ExecuteMov(AsNumber(param1));
else if(op == "ROT")
    ExecuteRot(AsNumber(param1));
else if(op == "SZE")
    ExecuteSze(AsNumber(param1));
else if(op == "POS")
    ExecutePos((AsNumber(param1), AsNumber(param2));
else if(op == "DIR")
    ExecuteDir((AsNumber(param1), AsNumber(param2));
else if(op == "SET")
    ExecuteSet(param1, AsNumber(param2));
else if(op == "EVL")
    ...

The more commands are supported the more string comparisions I'll have to do to identify and call the associated method.

Can you point me to a more efficient implementation in the described scenario?


texts:
I am searching for a tool that will help in writing a game script. By "script" I mean the text core of a storyboard - without the drawing drafts, which may or may not be there (yet).

What I'm thinking of will let write a piece of text of the script, define a simplified workflow from that step, and then define the text of next steps, and so on.

Searching online, I found Inform http://inform7.com/ ("A Design System for Interactive Fiction Based on Natural Language") which in theory is exactly what I am searching for, but trying to use it it has this model of a space (a dungeon, a library) where you are picking up objects and exploring them. In my case I am designing more a Sims like game, the flow is entirely different.

Considering non specific software, mind mapping tools miss the linearity of the process. What I am writing is a directed graph - simply a work-flow, but the way I want to design it is more text based than work-flow based.

SO what I'm doing now is using a text editor, which I'll transform directly in code.

Any suggestions?


texts: HPA* Pathfinding, building the hierarchical graph is too slow

texts:
So I have a graph, roughly grid shaped, that is about 300*300 nodes large. Even at this size, however, traditional a star takes 20 seconds to run in some cases. So I implemented an HPA* algorithm to shorten pathfinding time. HPA* looks somewhat like this, chopping up the graph into small chunks that can be pathed quickely:

The algorithm works by first finding places to put hierarchical nodes along certain sized edges, then, for every node, finding a path between itself and all other nodes that it shares a square with, or cluster. In the image above, this is shows as the red dots as hierarchical nodes, and the red lines as the paths between the hierarchical nodes.

To find the path between all the nodes in a cluster, I used A*. While the paths are not that big between each node, and thus the A* does not take too long, I need to find many, many of them. For my project, I have hundreds of hierarchical nodes, and, therefore, thousands of searches needed to build the hierarchical graph.

This is an annoyance for testing my game, rebuilding the graph whenever I change something in the scene, it is a nightmare when I wan to do dynamic map changes, often taking seconds and even minutes to get it done.

I have tried many things to speed up the build process, such as doing a modified flood fill for every cluster to just see if the hierarchical  nodes are connected and that making the distance between the euclidean, sacrificing accuracy. But the modified flood fill was about as slow as A*, and it did not work.

Is there anything to speed up the HPA* build time for dynamic maps, any special algorithms or speedups or shortcuts I need to know? I would be willing to sacrifice a lot of path accuracy for anything to make it faster. Thank you for all your help.

P.S. The problem is with the fact that it has to do hundreds or even, in some cases, thousands of A* pathfinds during the build phase.


texts:
I'm looking for an algorithm that will determine if a sphere is in any way touching an AABB or contained within it. Profile results indicate that this specific use is taking up a large percentage of my time, so it would be nice if it was as efficient as possible.

Edit: ATM, I've got this:

        bool IntersectsAABBWithSphere(Math::AABB rhs, Physics::Sphere sphere) const {
            // http://www.gamedev.net/topic/335465-is-this-the-simplest-sphere-aabb-collision-test/
            auto aabbcenter = (rhs.BottomLeftClosest + rhs.TopRightFurthest) / 2.0f;
            auto SepAxis = sphere.origin - aabbcenter;
            auto Dist = Math::Length(SepAxis);
            SepAxis = Math::Normalize(SepAxis);
            if( SepAxis.x >= SepAxis.y && SepAxis.x >= SepAxis.z )
                SepAxis /= SepAxis.x;
            else if( SepAxis.y >= SepAxis.x && SepAxis.y >= SepAxis.z )
                SepAxis /= SepAxis.y;
            else
                SepAxis /= SepAxis.z;

            auto extents = (rhs.TopRightFurthest - rhs.BottomLeftClosest);
            SepAxis.x *= extents.x / 2.0f;
            SepAxis.y *= extents.y / 2.0f;
            SepAxis.z *= extents.z / 2.0f;

            return Dist <= (sphere.radius + Math::Length(SepAxis));
        }

My AABB's are currently represented as min/max, and my spheres as origin/magnitude.


texts: Is this bad design to have a static class which plays sound effects?

texts:
I am trying to make a audio manager. I want this audio manager to setup itself and be accessible from everywhere. So I made a static class that creates the audio sources when you need them. Is this bad design?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NodeEditorFramework.Utilities;

public static class AudioManager {

    private static bool musicIsSetup;
    private static AudioSource musicSource;
    private static bool sfxIsSetup;
    private static AudioSource sfxSource;

    public static void ManualSetup()
    {
        SetupSFXSystem();
        SetupMusicSystem();
    }

    public static void PlaySFX(AudioClip clip)
    {
        if (!sfxIsSetup) SetupSFXSystem();
        sfxSource.PlayOneShot(clip);
    }

    public static void PlayMusic(AudioClip clip)
    {
        if (!musicIsSetup) SetupMusicSystem();
        musicSource.clip = clip;
        if (!musicSource.isPlaying) musicSource.Play();
    }

    private static void SetupMusicSystem()
    {
        musicIsSetup = true;
        GameObject MusicHandler = new GameObject("MusicHandler");
        musicSource = MusicHandler.AddComponent<AudioSource>();
    }

    private static void SetupSFXSystem()
    {
        sfxIsSetup = true;
        GameObject SFXHandler = new GameObject("SFXHandler");
        sfxSource = SFXHandler.AddComponent<AudioSource>();
    }
}


texts: How to change the version code in application created by the GameMaker?

texts:
Code that I can not change:

Image of the error:

Inside the red square is written: Upload failed You already have an APK or Android App Bundle with version code 1000000. Use another code.

It turns out that I do not know how to change. At least not by GameMaker. I've been in the settings, preferences, but I do not think so at all. This tutorial below Google itself is useless. I already contacted, I sent an email to the support for more than 1 week and no response.

https://support.google.com/googleplay/android-developer/answer/7159011?hl=pt-BR


texts: Issues with referencing experimental light class

texts:
I am trying to reference a Light2D component on a GameObject but I get the following error:
'The type or namespace name 'Universal' does not exist in the namespace 'UnityEngine.Experimental.Rendering'.

I have confirmed that I have v10.2.2 of the Universal RP package in package manager. I have also attempted regenerating all csproj files as well as deleting the Library folder and reopening Unity. I also have the library reference to 'UnityEngine.Experimental.Rendering.Universal' in my script.


texts:
I'm currently trying to implement post processing into my project.

First I configure my framebuffer:

glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);

glGenTextures(1, &textureColorbuffer);
glBindTexture(GL_TEXTURE_2D, textureColorbuffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _width, _height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureColorbuffer, 0);

glGenRenderbuffers(1, &rbo);
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, _width, _height); // use a single renderbuffer object for both a depth AND stencil buffer.
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo); // now actually attach it
                                                                                // now that we actually created the framebuffer and added all attachments we want to check if it is actually complete now
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
    cout << "ERROR::FRAMEBUFFER:: Framebuffer is not complete!" << endl;

float quadVertices[] = { // vertex attributes for a quad that fills the entire screen in Normalized Device Coordinates.
                         // positions   // texCoords
    -1.0f,  1.0f,  0.0f, 1.0f,
    -1.0f, -1.0f,  0.0f, 0.0f,
    1.0f, -1.0f,  1.0f, 0.0f,

    -1.0f,  1.0f,  0.0f, 1.0f,
    1.0f, -1.0f,  1.0f, 0.0f,
    1.0f,  1.0f,  1.0f, 1.0f
};

glGenVertexArrays(1, &quadVAO);
glGenBuffers(1, &quadVBO);
glBindVertexArray(quadVAO);
glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), &quadVertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float)));
glBindFramebuffer(GL_FRAMEBUFFER, 0);

Then I initialize the shader:

Vertex Shader:

    #version 430 core
    layout (location = 0) in vec2 aPos;
    layout (location = 1) in vec2 aTexCoords;
    out vec2 TexCoords;
    void main()
    {
        gl_Position = vec4(aPos.x, aPos.y, 0.0, 1.0);
        TexCoords = aTexCoords;
    }

Fragment Shader:

    #version 430 core
    out vec4 FragColor;
    in vec2 TexCoords;
    uniform sampler2D screenTexture;
    void main()
    {
        FragColor = vec4(vec3(1.0 - texture(screenTexture, TexCoords)),1.0);
    }

I then set the uniform for the texture:

    shader.get()->use();
    shader.get()->setUniform("screenTexture", 0);

Then before drawing my Scene I set to draw to the framebuffer:

    glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
    glEnable(GL_DEPTH_TEST);

Then I draw my scene. After that I try to draw the framebuffer (after some post processing, just inverting the color to test)

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glDisable(GL_DEPTH_TEST);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);

    shader.get()->use();
    glBindVertexArray(quadVAO);
    glBindTexture(GL_TEXTURE_2D, textureColorbuffer);
    glDrawArrays(GL_TRIANGLES, 0, 6);

Unfortunately the whole screen is drawn full white.
When I turn on wire-frame mode, i can see that 2 triangles were drawn, which is correct.. but I don't know why it doesn't work.


texts: My point light shadows only really work if my point light is at the world origin (0,0,0)

texts:
When I move the light, the shadows will fall apart as if their occluders aren't occluding them in certain areas.

For example, in the following scene, I move a pointlight 400 units down the Z axis, I get a scene like this, where somehow occluded fragments are passing the shadow test:

The shadowmap texture appears fine to me. Since I'm working with a pointlight, I need a cubemap, so here are the relevant portions of its texture:

I'm fairly certain my issue has to be somewhere in one of my shaders.

My point light's shadowing logic subtracts the lights' position from the fragment's world position, takes the length of that vec3 and outputs that as the FragColor.

#version 330

in vec3 WorldPos; // aka ViewMatrix*ModelMatrix*Vertex

layout (location = 0) out float FragColor;

uniform vec3 LightPos;

void main()
{
    vec3 LightToVertex = WorldPos - LightPos;
    float LightToPixelDistance = length(LightToVertex);

    FragColor = LightToPixelDistance;
}

And then within the actual lighting logic, I do this to calculate a shadow factor (where 1.0 == full illumination, and 0.0 == full darkness)

uniform samplerCubeShadow ShadowMap;
in vec3 WorldPos;

float CalcShadowFactor()
{
    vec3 LightDirection = WorldPos - pointLight.position;
    float Distance = length(LightDirection);
    vec3 Direction = normalize(LightDirection);

    float Factor = 0.2;
    vec4 UVC = vec4(Direction, (Distance + EPSILON));
    Factor += texture(ShadowMap, UVC) +0.05;

    return Factor;
}


texts: can i show logs in unity with different colors or different icon signs?

texts:
I'm working on a project that has a lot of logging messages that pass very fast.

I can use error logs or warning logs but is there any way to log something with different colors so it is easier to find?

Right now, I just use something like this:

Debug.LogError("show missing gold popup accepted");


texts: Unit selection - logic & screen communication

texts:
I'm building a game using SFML, with disconnected logic & screen systems that run on different threads and communicate through synchronised buffers. Now, this system worked perfectly well when I only ran independent AI units, but now comes the time to handle player input, and I'm not sure what's the best way to handle it.

Currently, when a player clicks the screen, the input manager creates a MouseClick event, which goes to the logic buffer. The logic manager checks if that spot contains a controllable entity, and if it does, creates a SelectUnit event with the relevant information in the display buffer. When the display manager reads that event it updates the screen with the relevant piece of GUI, and any click on the GUI again sends an update to the logic component. The two problems I see are that the SelectUnit event will need to contain a lot of logic info which might harm the info decoupling, or just make it useless, and that I fear (still not tested) that since the communication will bounce several times between the two threads, some might be lost.

Now, I wonder if this system could be handled better, with less transferred information.

Note about the tech: SFML creates a RenderWindow object which handles input and display. I'm still not sure what library to use for GUI (probably GWEN.net), so I can't currently name tech limitations on it.

EDIT: this is supposed to be a RTS multiplayer game. So far, it seems to me there'll have to be a central logic unit (on the host computer?) that'll receive all the inputs from all players, and send the responses accordingly. This, obviously, makes this system even more complex. Again, suggestions are welcome.


texts: GLSL: How can I optimize this lighting (fragment) shader? Basic 2D game, 30+ light sources cause significant frame loss

texts:
I am using a fragment shader to create circular light sources in my 2D game. Full code at the bottom.
Essentially, an array of light source objects (called Lights in the code) are passed into the shader in groups of 40. The shader runs through a for loop for each light source in the batch (up to four) and attenuates the brightness of that pixel based on how far away from the light source it is. If there are more than forty light sources, additional passes of this shader are done until all the light sources on the screen are processed. Limiting the lights per shader pass is done to limit how much data is pushed to the GPU at once (this is what the book I am reading is telling me to do) to improve performance.
It works fine, but I notice pretty dramatic frame rate loss when the number of light sources on the screen exceeds 30 or so. By the time I'm at 80 or 90 light sources, the frame rate is down to about 10 fps. Not cool.
Some questions:

What sticks out in the loop as the most expensive operations, and how can they be done better? I have been commenting out some of these I try to see what effect each line has. Is there a better way to do this? How do I profile a shader program? I am new to this. Any help would be appreciated.
As you can see, I am using an older version of GLSL because I am using macOS X (version 1.20). Would this shader work more efficiently on a different platform with a new version of OpenGL?
I'm considering the possibility that 30+ light sources is simply too much I need to seek a way to optimize the shading process outside of this shader loop. I am using a deferred rendering process, but I have read about how some games render lighting using a partition light sources into different regions. I.e., a light source only affects pixels within a region around it (that it could reasonably affect), so that you don't have to run a calculation for every single pixel on the screen for each light source. Kind of like doing a broad-phase pass for collision detection. How do 2D games typically handle many light sources?

#version 120
uniform sampler2D LastPass;
uniform sampler2D DiffuseMap;
uniform vec3 AmbientLight;
uniform int LightCount;
uniform int PassNumber;

struct LightInfo {
    vec3 position;
    vec3 color;
    float radius;
    float falloff;
};

const int MaxLights = 40;
uniform LightInfo Lights[MaxLights];

void main()
{
    vec4 pixel = texture2D(LastPass, gl_TexCoord[0].xy);
    vec4 diffusepixel = texture2D(DiffuseMap, gl_TexCoord[0].xy);

    vec4 finalPixel = gl_Color * pixel;

    for(int i = 0; i < LightCount; ++i) {

        LightInfo light = Lights[i];
        vec3 L = light.position - gl_FragCoord.xyz;
        float distance = length(L);
        float d = max(distance - light.radius, 0);
        L /= distance;
        // calculate basic light attenuation
        float attenuation = 1 / pow(d/light.radius + 1, 2);
        // scale and bias attenuation such that:
        //   attenuation == 0 at extent of max influence
        //   attenuation == 1 when d == 0
        attenuation = (attenuation - light.falloff) / (1 - light.falloff);
        attenuation = max(attenuation, 0);

        //This line runs VERY slow when there are many light sources.
        finalPixel += (diffusepixel * ((vec4(light.color, 0.4) * attenuation)));

    }
    gl_FragColor = finalPixel;

}

Thanks for any help.


texts: How can I handle multiple simultaneous skeletal animations?

texts:
I wonder how skeletal animations in games work. I am writing my own graphics engine for fun, and I have come across several problems with animations.

Here is how I do it right now:

Load the mesh with animations
Simulate every animation with the CPU and then send it to my GPU via a texture that I make from the final transformation matrices.
In my shader I multiply every vertex by the transformation matrices that are tied to that vertex.

This method works very good (until now). Now to the problem, if I have two animations that I want to use at the same time (running and shooting for example) then I have to do a "height check". It still works but I am getting serious doubts about it. If I want to render custom directions with this shoot animation (to where the camera is heading) I just don't know how I could fix this with my current method.

How can I accomplish this?


texts: What is a reasonable terminal size across Linux distributions?

texts:
I'm working on a Curses-based roguelike; it should (and does) work in both Linux and Windows (various flavours of each).

Currently, I'm enforcing a hard requirement of "your terminal size must be 80x25 to play. Please fix it and come back" to ensure I have a consistent UI.

This works on Windows. But not on Linux; it seems that Ubuntu, at least, uses a terminal size of 80x24 instead.

Since Google is not useful, what can I reasonably expect as far as terminal size support across various Linux distros?

(If it is 80x24 or even as low as 80x20, I can probably work with that.)


texts: How to prevent "underwater sight" in games

texts:
In many games where the player can go underwater, it seems like when you look where the top half of the screen is in the air, and the bottom half the screen is in the water, it's almost like the water doesn't exist and the player is... flying slowly with water sounds?

Is  there a logical way to solve this? An algorithm? Doesn't seem like any solution has come up yet since many games still have this. I don't want to make the same mistake.


texts: gl_FrontFacing - is there perfomance cost?

texts: If I use gl_FrontFacing in my PS, is there any performance cost during vertex transformation (like cross product from triangle  vertices), or is this value computed any time ?


texts: How does one integrate Game Center leaderboards in Monogame?

texts:
Do anyone know how to integrate a Game Center leaderboards for an iOS game using MonoGame framework?

I have searched high and low yet I haven't gotten any luck of finding articles or tutorials that talks about the topic of Game Centre leaderboard integration. A direct link to where I can learn how to do the implementation will be very much appreciated. Thank you!


texts: What method should I use to create a story game which is about making decisions?

texts:
I am planning to create a story game in VB.Net which is about making decisions and from there, there's different possible endings.

I want to know ( if there're any ) ways that can be used, other than using If Else Statements which will take a long time if that's to be used.

The game will only have texts and buttons for answers so it's really just a simple story game.


texts: How to make OpenGL rendering resolution independent from its window context resolution?

texts: Can the rendering resolution of OpenGL and the window size (at least for the Windows OS) be separated? For example, I may only want to render at 400x300 resolution, but I want my window size to be 800x600. If so, how is this done?


texts: How to modify this old pre-3.0 OpenGL code to modern OpenGL?

texts:
I've done the getting started section on learnopengl website. However, that means I don't understand the old way of doing things, so I am struggling to understand some code I want to take a look at to better understand cloth simulation. In particular, I wanted to know how to create the main structure of the cloth in OpenGL. I know how to create a box right now, maybe not instinctively yet but by looking at the code I could see what is happening.
Here is the github repository to this code: https://github.com/bailus/Cloth
I am looking at the Cloth.cpp and see that it is created through the use of many triangles.cpp objects:
glBegin(mode);
    for (std::vector<Triangle>::size_type i = 0; i < triangles.size(); i++)
        triangles[i].display();
    glEnd();

The display method of triangles looks like this:
void Triangle::display() {

    for (int i = 0; i < 3; i++) {
        glTexCoord2fv(glm::value_ptr(particles[i]->texCoord));
        glNormal3fv(glm::value_ptr(particles[i]->normal));
        glVertex3fv(glm::value_ptr(particles[i]->pos));
    }
}

so my question is... what would be going on here in terms of VBOs? I can see there are texture coordinates and vertex coordinates... I don't know about the normals. I would assume two VBOs from this, but how would I modify my display function and drawing function to support the latest opengl? Would the current object orientated structure work..? I am not sure how to go about it.


texts:
I want to simulate Kinetic sand's behavior in my game. I could implement operations such as slicing and cutting using simple mesh cutting algorithms but I want to implement complicated operations such as follows:

Ref video link: https://www.youtube.com/watch?v=3clqk2U3T9Y

Squishing (Time frame 1:37 to 1:40 in the ref video)
Scooping (Time frame 8:53 to 8:57 in the ref video)

I have the following questions:

What physics simulation algorithms can be used to implement the above 2 operations?
I want to implement this concept for mobile devices. Will it be computationally heavy to simulate such physics on mobile devices? if yes, are there any workaround solutions for this type of simulations?

I would appreciate any suggestions and thoughts on this topic. Thank you.


texts: Why is my zooming-in + changing scenes not woking in Unity?

texts:
I'm zooming on a map using Math.Lerp and then I use the scene manager to change the scene. Here is my attempt but it doesn't work on the map.

I have attached it to the main camera, in the worldView:

public class zoom : MonoBehaviour {

    // Use this for initialization
    private bool zoomedIn = false;
    int zooom = 20;
    float smooth = 5f;
    void Start () {
        SceneManager.LoadScene("worldView");
    }
    // Update is called once per frame
    void Update () {
        if (Input.GetMouseButtonDown (0)) {
            zoomedIn = !zoomedIn;
        }
        if (zoomedIn == true) {
            Camera.current.fieldOfView = Mathf.Lerp (Camera.current.fieldOfView, zooom, Time.deltaTime*smooth);
            SceneManager.LoadScene("countryView");
        }
    }
}


texts: What is an efficient mobile rendering order supporting transparent and opaque objects?

texts:
I'm interested to know how others would do / have done this.

Part 1. Constraints.

My current renderer is being built to support OpenGL ES 2.0 primarily and so aims for performant mobile as well as desktop. Separate render paths for mobile and desktop are avoided for simplicity's sake, so I'm discussing a single, unified ES 2.0 render path here, minimally targeting devices that support glDrawInstanced().

I have different categories of renderables. Terrain chunks, for example, are fully opaque and with the depth buffer turned on, can be rendered in any order. So far, so good. Foliage OTOH consists of semi-transparent objects suited to alpha testing / discard given a desktop GPU.

But because of the mobile requirement, alpha testing is not an option - see impacts of alpha testing / discard on graphics pipeline for mobile GPUs like the PowerVR SGX series: source, and source.

Part 2. Approach.

As a result, I must fall back to alpha blending and the painter's algorithm for transparent objects. So it seems there are two sort-categories of renderables, to be rendered separately and in this order:

solid objects: no explicit sorting (or front-to-back for optimised z-reject), depth buffer write on
transparent objects: back-to-front sort, depth buffer write off

(could there be more of these?)

Given this, I now wish to sort my display lists as efficiently as possible by minimising GL API calls. To this end, it seems best to:

order the display list primarily by sort-category (as 1 & 2 above),
(within same sort-category) order secondarily by similar material and thus shader program,
(within same material-bucket) order tertiarily by similar mesh / vertex data.

And then of course render everything.

This way if we have same sort-category, same material, and same mesh on each of two objects, glDrawInstanced() becomes a viable option to combine those two objects into a single draw call, and even if not, we've (hopefully) minimised the number of context changes that need occur.

Does the proposed render order 1-2-3 sound right? If not, explain differently, and justify.


texts:
I am creating a model with Blender which looks like this:

and I am importing it into an XNA project.
There seems to be some kind of transparency issue.
The model looks like that:

When the camera looks on one side, the side is not shown.
Why do I have this problem and what can I do to fix it?

PS: I am using a custom Effect but I don't think that the issue has something to do with that.


texts: Should "games played this week" be computed from a fixed or running time span?

texts:
I'd like to create a leaderboard that shows how many games each player has played. This works fine for the "all time" section in Game Center, since I can just submit the total number. But what I really want to display is the number of games each player has played in a week, not for all time.

As I understand it, I would have to calculate the weekly numbers myself (if I submitted the all-time totals, the weekly tab in Game Center would still just show the total all time numbers from that week, not the weekly totals).

What would be the best way to do this? Count a user's tasks beginning on Monday, and reset them on Sunday? Or have everyone on their own unique 7 day timer?


texts: Doing legacy DirectX Coding on Windows 10

texts:
I decided to study couple of old computer graphics books like Andre LaMothe's Tricks of 3D Game Programming Gurus. I feel like this book is full of great general computer graphics knowledge and I want this to be an exploration.

The problem is, since the book is old, it uses a very old DirectX API. It is DirectX 7 I guess. I want to be able to code the presented ideas myself and I have a Windows 10 machine. And I have couple of more old books which uses old APIs like DirectX 7 and 8. The question is;

What are my options if I want to code the examples in these books? Is there a way to write DirectX 7,8 and 9 code in Windows 10? I checked the articles "Where is the DirectX SDK?" from MSDN but they are mainly about how to move from D3D9 to new APIs. I want to code in those APIs for the sake of doing the exercises in the book, not move from those APIs. I think this should be possible because I am playing games from these eras in my computer today. If my computer is able to run them, there should be a way for me to write them as well.

If this is not possible or is very hard, how hard it would be for me to convert and try these ideas on modern OpenGL while I read the books?

In the case that I am completely lost, do you think I can still learn the computer graphics ideas presented in the books by reading the code and making sense of it, even if I don't code them myself?

NOTE: I have fundamental knowledge of computer graphics and modern OpenGL. It is not like I am choosing these books to begin my CG exploration. There are probably better, modern books for those and I read couple of them. The reason I want to read these books is because I like old books :) and I want to explore old wisdom lay in these.


texts: Performance of many canvas drawImage calls is very slow

texts:
I'm developing a top-down 2D tile-based canvas game. I have a single sprite sheet of all my tiles, and then a JSON tile map array of where they're placed.
Previously I would render all the layers of tiles out to a single canvas element once, and then re-render that every frame. This would give me 300+ FPS because it would just be a single draw call each frame to redraw this canvas.
However, the issue with this is that the map is not just a "flat" image. Sometimes tiles need to be destroyed, or sometimes the player needs to stand behind certain tiles (such as when the player is above them), which doesn't seem possible if the map is just a static image.
As a result, I believe I instead need to re-render all the tiles every frame. However, even if I only re-render the tiles that the user can see, the FPS drops tremendously. With just two tile layers and a 100x100 map, the FPS drops to 20.
I would have assumed that, despite there being 100 * 100 * 2 canvas.context.drawImage calls per frame, that it would still be fine, because it was leveraging the GPU, and I'm using a single sprite sheet, so there should be no texture swapping. Apparently this is not the case.
I was looking for a way to possibly speed this up, but the recommendations seem to be extremely heavy-handed and opinionated libraries like three.js and pixi.js. These libraries would be great, except they do too much. In PIXI and Three.js you need to add objects to a scene and they're automatically redrawn each frame. This is not what I need, as my current ECS architecture demands an immediate-mode renderer, and I have my own scene graph already, so I can't (and don't want to) use theirs.
Is there a solution here? The only thing I really need to do is draw images clipped from a spritesheet quickly. Can this be done using immediate-mode rendering? Or is it doomed to be 20 FPS?


texts:
I can understand when to use lists, but I don't understand when it is better to use vectors than using lists in video games: when it is better to have fast random access ?

(And I understand why it's faster to insert/delete in lists because it just removes/adds pointers, but it still has to find the corresponding item...)


texts: High-definition Full-motion background system in XNA

texts:
I'm mostly just working on this as a hobbyist thing, but here's my problem:
I got a bit excited over finding the 'Video' and 'VideoPlayer' classes in XNA 4, and hoped to make a game that works a little bit like how Myst does - with very active backgrounds, but no actual 3D graphics. (Technically, Myst 1 had static backgrounds, but maybe you get the idea) I threw together a small test game in XNA, with a pretty simple WMV included.

The problem I have is that it's not quite responsive enough. I'd like my system to be able to swap the current video in a millisecond, so that the player could click a contraption in the background and instantly see it move. Right now, when I press my trigger key that calls this code:

    private void cycleVideos()
    {
        videoIndex++;
        if (videoIndex == videos.Count)
        {
            videoIndex = 0;
        }
        activeVideo = videos[videoIndex];

        vp.Stop(); // Couldn't find a 'Seek(0)' method
        vp.Play(activeVideo);

    }

...it takes about a full second to re-seek the position it needs, and start playing again. In this example, I hadn't even encoded my video to the HD (1920x1080) resolution I had been planning on. I can understand if XNA's video system is really only meant for full cutscenes between missions or that sort of thing; I'm willing to use additional memory to have large parts of my videos cached, or even include a bit of a dynamic caching system so that things are loaded/unloaded over time (after all, this is the main visual of the game), but I'd like to hear if I have any decent options to accomplish this.

I'm also somewhat open to the idea of using a different engine or coding environment entirely.

EDIT: I've been doing some experimentation in my eagerness to solve this. I can definitely get some faster responsiveness by avoiding the 'stop()' calls, and by maintaining multiple instances of VideoPlayer. A paused video will resume much more quickly; and it's possible to play(), then pause() a video immediately (at the beginning of the program, in order to 'cache' it). It's not a full solution yet - I want to be able to seek back to the beginning of a video, and I still feel like there should be some possibility of that somewhere.


texts: Need info on creating a tile grid data structure in Java

texts:
I'm trying to create a game with a fixed size map (2D Tile array).
I suppose I can inherit other tiles from this base Tile, e.g.: a BankTile.
Placing and removing tiles is all too easy, but forming rooms keeps me puzzled.

Rooms can only be formed by adjacent tiles (4-way: above, below, left and right)

This way, 2 tiles can form a 'room', e.g. a Bank with a maximum amount of resources it can hold (sum of both its tiles).

I am wondering on how I should be implementing this, if there are any existing (and optimal) solutions to this.

Some things I considered:

Tiles must keep a reference to the Room they are in AND rooms must keep a vector of all tiles they hold. So adding tiles and removing tiles becomes pretty efficient.
Only obstacle this poses is the splitting of rooms: if 1 tile connects 2 rooms and this tile is removed, it should split the room and creating a new room for the split-off part.
Rooms will be 2D vectors with a begin-position (the room will be a surrounding square of the actual room polygon)
Rooms are 4-way linked lists of tiles
?

What needs to be done with rooms:

tiles need to be added and removed
allowing rooms to merge and split
calculating size of a room
finding a room quickly on a map

This image clarifies what I need:

Should I pick data structure 1? Rooms are 2D arrays with null-pointers for not-room-tiles.
Or should I pick data structure 2? Rooms are 4-way linked lists of tiles.
Or should I think of something else, e.g. vector of tiles = room?
Given the operations I need to be able to perform on them, which is best?


texts: Looking for a 2D spatial partitioning method for my top down browser game

texts:
Hi I am currently using a modified version of spatial hashing algorithm written by Christer Bystrom. This algorithm is OK for collision detection. However when I use it for detecting entities in interested range it has its limits.

I use a huge map. (10000 x 10000 pixels) When I am moving my player, I expect to see what are around my player on the screen. Sometimes some entities are right in front of me or just behind me but I can't see anything on the screen until I get really close.

Here is a visual demo I created for that algorithm. I modified it to work with circle objects. In the demo picture I have already set the powerOfTwo attribute to 9, which is pretty big. The green circle is my mouse position. The red circles are those entities within my player's interested area. But this is not a good solution. The player should be able to see things on all directions around itself and stretch out further to about the same size of the rectangle area holding those red circles.

So I am looking for a better solution out there to implement in my game. I hope it is accurate and fast for detecting entities within interested area, and better not too hard to understand. It can be any other way (quadtree, dynamic tree, RTree or whatever fits the type of game I am making). I have also read about this, but not sure if those methods work well with interests management.


texts: Why do I are my quads outlined when rendered?

texts:
I have a 3x3 quad wall I am rendering to. I render to a 3x3 because the complete image exceeds the maximum single texture limit. So I've cut the image into a 3x3.

The issue I'm having is that when rendered to screen as I move the camera along the Z axis I am seeing the quads outlined most of the time. The image is cut exactly at he correct height and with to allow perfect 8532 x 5832 squares.

Does anyone have any ideas how to prevent the outlines from showing up?

This is an example of expected image:

This is an example of the same area at different Z and the quad out lines are visible.


texts: New to OpenGL , having trouble understanding matrix transformation

texts:
I have modest experience of developing games with sdl , libgdx , unity etc. But never got into learning any low level API. So I thought about learning OpenGL and got started with tutorials provided by lazyfoo.net.(Yes I know he is using the legacy OpenGL but he migrates to modern OpenGL as he progresses through the tutorials).
On the fourth chapter he shows the use of glPushMatrix() and glPopMatrix (). Up until then I had the understanding that whenever I translate the modelview matrix that translates the whole gameworld. Now this process of saving the current matrix on stack has put me into some confusions. They are:
1.If I push the current matrix on the matrix stack and make change to current state, then pop that saved state again; how are these transformations combined into one matrix?
2.In the tutorial he shows how to do scrolling background with four quads in the background.He translates the matrix to position the camera in the proper place based on user input. Then he pops the matrix from the stack in the render method and translates it to four different positions to draw four quads. My question is why don't we see the quads moving with the camera(which means not moving at all relative to the camera) since they are drawn relative to the camera.
In key input function:

//Take saved matrix off the stack and reset it
glMatrixMode( GL_MODELVIEW );
glPopMatrix();
glLoadIdentity();

//Move camera to position
glTranslatef( -gCameraX, -gCameraY, 0.f );

//Save default matrix again with camera translation
glPushMatrix();

in render function:

//Pop default matrix onto current matrix
glMatrixMode( GL_MODELVIEW );
glPopMatrix();

//Save default matrix again
glPushMatrix();

//Move to center of the screen
glTranslatef( SCREEN_WIDTH / 2.f, SCREEN_HEIGHT / 2.f, 0.f );

//Red quad
glBegin( GL_QUADS );
    glColor3f( 1.f, 0.f, 0.f );
    glVertex2f( -SCREEN_WIDTH / 4.f, -SCREEN_HEIGHT / 4.f );
    glVertex2f(  SCREEN_WIDTH / 4.f, -SCREEN_HEIGHT / 4.f );
    glVertex2f(  SCREEN_WIDTH / 4.f,  SCREEN_HEIGHT / 4.f );
    glVertex2f( -SCREEN_WIDTH / 4.f,  SCREEN_HEIGHT / 4.f );
glEnd();

 These all might be very silly questions and I believe they are. I think there is a problem in my understanding of how matrices work in OpenGL. It would be very nice of you to enlighten me on this matter :)


texts: Method for procedurally creating spawn points

texts:
I have a world made of floating islands that are procedurally generated. I would like to spawn enemies or the player in logical-non-falling-into-space spawn points. Ideas on how to accomplish this?  My thoughts were this:

Drop a bunch of spawn checking items and if they fall for too long then that is a bad spawn point.
Build logic into how the randomly generated world is built so that there are regions pre-recongnized as the place to place NPCs, baddies, player, etc.

If anyone has links to some blogs or reports concerning this or your own ideas on this please post!


texts: 1 kb swf file created when building to flash in unity

texts: I am trying to build a project in flash that I have made. It goes through its building process, but when it is done the swf file that it creates is 1 kb in size. I am not sure what I am doing wrong or what is going on. I have built to flash before and never ran into this problem until recently.


texts: Generating nav meshes from tile based map (2D)

texts:
I'm working on a pathfinder for a MMORPG game, it's not mine; I'm RE it, now I need to create a pathfinder for monsters. But I figured that the client uses tiles for it's pathfinder (for players). Inside map files, there is a set of walkable and not walkable tiles. (Every coord XY is one tile). Now I wan't to implement the server side path finder, but the problem with these tiles is performance, some maps are 500x500 (250000 tiles). I need to reduce the number of tiles, so I guess I should convert them into navigations meshes, either triangles or bigger squares or rectangles. Is there a tool or an example code to do that?
Thanks


texts:
I am currently developing a bot for a game board called Fanorona. The game is not as popular as other board games such as chess or backgammon, but still it brings a lot of fun. Some of you may know it from Assassins Creed 3, specifically the game Connor and Achilles play together.

http://gasy-fanorona.sourceforge.net/docs/fanorona_rules.html

In this link I provided the basic rules.

I have studied what people usually use for bots for chess, algorithms like Alpha-Beta Minimax. These algorithms require a score system in order to make specific decisions, take into account the branching factor, which in this game is hard to estimate. Additionally, the bot could be trained to recognize patterns.

I have never worked with AI algorithms before, therefore I would like find out your opinion concerning this subject. What course of action would you employ in order to build a bot for this kind of game?


texts: I am a little confused on the difference between a game engine and an actual game. By making a game, are you making a game engine, or is a game engine a library used to make a game?


texts: Smallest, most memory-efficient way to have tiles? (C++/OpenGL)

texts: I need to have tiles in my game, just 16x16 images, there would be hundreds (or even thousands) that make up a level. Of course it's not viable to have thousands of memory-hog normal entities, but tiles are just repeated images. What's the most memory-efficient way to do tiles?


texts: gluLookAt vs glTranslate + glRotate and camera transformation matrices

texts:
I'm getting my hands dirty in OpenGL and something is bothering me a bit.

It's my understanding from reading about the subject that a call to gluLookAt basically multiplies a matrix on the stack that moves the world in a way such as to "emulate" a camera.  After my reading, I came under the impression that calling:

glTranslatef(0.0f, 0.0f, -10.0f);

then perform some drawing was equivalent to calling:

gluLookAt(0.0f, 0.0f, 10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);

However it is not and I'm at a loss as to where the flaw is in my reasoning.  I also tried manually computing a matrix from a position, a direction vector and an up vector but failed to find texts describing this process.

Can anyone shed some light on this?  I'd much rather like to understand the underlying matrix creation process to create a transformation matrix that corresponds to an inverse camera transform, but just getting gluLookAt to behave the way I want would be great as well.  Thank you.

EDIT:  Turns out my mistake was that I mistakenly set the up vector to [0, 0, 1] instead of [0, 1, 0].  I'm checking the answer below to see if it's giving me satisfying results regarding matrix creation.


texts:
I have a box that is drawn around my game that I want to check collisions with. Currently my BoundingBox is made in a way that whatever is inside the box is colliding with it:

BoundingBox bb = new BoundingBox(new Vector3(position.X - 0.1f, position.Y - 0.1f, position.Z - width - 0.1f), new Vector3(position.X + width + 0.1f, position.Y + width + 0.1f, position.Z + 0.1f));

(Note: the +0.1f is added so that it doesn't cause collision when an object is touching it, only when it passed through)

What I want is the inverse. I want a BoundingBox around this box so that only objects outside of the box will cause collision.

Is there an easy way of doing this or am I supposed to make different BoundingBoxes around this existing one? Thanks


texts: LibGDX controllers: how to fix crashes in JRuby?

texts:
I'm using JRuby with LibGDX and it's been going quite swimmingly, save for a crash I experience every time I try to use the controllers extension.

Here's a basic rundown:

I've required all the related jars (gdx-controllers.jar, gdx-controllers-desktop.jar, and gdx-controllers-desktop-natives.jar).
I've imported the controllers package via import "com.badlogic.gdx.controllers".
I call Controllers.controllers, which goes to the getControllers method.
My game crashes with this error:

libc++abi.dylib: terminating with uncaught exception of type OIS::Exception: CocoaInputManager::_parseConfigSettings >> Unable to find a window or event target

I think the error is due to a lack of a view being passed to OIS library (here's an online view of a related source).

How do I prevent the controllers extension from crashing my game? More importantly, how do I make it work? :)


texts: Make LibGDX game responsive to different phone screen sizes?

texts:
I've been experimenting with small games to learn design concepts, LibGDX, and Box2D. I am wondering how you would implement "responsiveness," so to say. For example, this is the rendering part of my game and its just drawing to coordinates. https://github.com/Elsealabs/Stacker/blob/master/com/elsealabs/stacker/ScreenGame.java

For example I'd like it to look good on Android phones of different resolutions or if the user resizes it on desktop. I am asking about design patterns or practices that would make this possible. Any solutions I can think of seem like they wouldn't scale or would over-complicate the game.

If you know of any articles or design practices that cover this topic, or have any of your own knowledge, or example LibGDX/Java games, I'd love to see them.


texts: Canvas isometric translations to integer coordinates

texts:
I'm creating a canvas based game with an isometric playing board. I use the following transformations to get my square tiles to render on the screen:

'applyViewportTransformation' : function() {
    context.translate(this.settings.camera_x, this.settings.camera_y);
},
'applyIsometricTilt' : function() {
    context.scale(1, this.settings.tilt_ratio);
    // Rotating the grid around it's center.
    context.translate(this.settings.pixel_grid_width / 2, this.settings.pixel_grid_height / 2);
    context.rotate(Grid.degreesToRadians(45));
    context.translate(-this.settings.pixel_grid_width / 2, -this.settings.pixel_grid_height / 2);
},

My issue is I would now like elements rendered on specific tiles that aren't translated like this. I also need to be able to map mouse clicks to isometrically drawn elements etc.

So as far as I can tell I need a formula to go into the grid and a formula to go out of the grid.

Mathematically I'm lost and also a little stunned the 2d context doesn't have a public way of simply applying these transformations to a set of coordinates.

Help would be much appreciated.

Edit, if anyone wants a peek at the source or would like to suggest some edits you can view the source on github.


texts: Unity Android: Truecolor texture performance hit and alternatives for truecolor

texts:
After integrating the graphics assets to my application, I noticed that when the textures are compressed they look very bad compared to truecolor. This happens to all the textures and it did not seem to help changing the texture type to GUI nor did it help to switch the 32-bit display buffering on.

Does using truecolor textures make the application much heavier to run? Or does it just increase the size of the .APK? Are there alternatives to getting a good texture quality and a smaller texture size instead of using truecolor?

EDIT:
I did some experiments with the dithering. I created a textures in GIMP 2.8, one which was RGB and one which was indexed with 255 colours and Floyd-Steinberg dithering with reduced colour bleeding. In the Windows Explorer this looked promising, the image quality had hardly been reduced but the size was halved.

But when they were imported to Unity, they were exactly the same size. And trying out different formats, there was not much noticeable difference between the image quality. Although the banding was a little bit less pronounced but still clearly seen.

EDIT 2:
I played around with the importing settings. And the only conclusion I can come up with is: Don't use alpha! Without the alpha channel, there is no banding with the ETC-compression which is supported by all OpenGL ES 2.0 GPUs.

To have an alpha channel and no banding. I had to go all the way to RGBA 32-bit, which increased the texture file size to 64Kb compared to the no alpha channel ETC's 8Kb.

Here again: not much difference between the GIMP dithered and the RGB versions. So conclusion with this: Dithering in GIMP did next to nothing.