texts:
When i draw a cube using indices, the faces of the cube are skewed but only when CullMode is set to cull back. When i switch it to cull none, it draws the cube perfect. Unfortunately i cant post any code at the time because I'm using my phone, but what are some possible explanations for why the faces of my cube are skewed wjile culling the back? I was thinking the order of my indices may be the problem.

http://i.imgur.com/S1PfxCr.png

VertexType* vertices;
unsigned long* indices;
D3D10_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
D3D10_SUBRESOURCE_DATA vertexData, indexData;
HRESULT result;

m_vertexCount = 8;
m_indexCount = 36;

vertices = new VertexType[m_vertexCount];
if(!vertices)
{
    return false;
}

// Create the index array.
indices = new unsigned long[m_indexCount];
if(!indices)
{
    return false;
}

vertices[0].position = D3DXVECTOR3(-1, 1, -1);
vertices[0].color = D3DXVECTOR4(1, 0, 0, 1);

vertices[1].position = D3DXVECTOR3(1, 1, -1);
vertices[1].color = D3DXVECTOR4(1, 1, 0, 1);

vertices[2].position = D3DXVECTOR3(-1, -1, -1);
vertices[2].color = D3DXVECTOR4(1, 1, 1, 1);

vertices[3].position = D3DXVECTOR3(1, -1, -1);
vertices[3].color = D3DXVECTOR4(0, 1, 0, 1);

vertices[4].position = D3DXVECTOR3(-1, 1, 1);
vertices[4].color = D3DXVECTOR4(0, 1, 1, 1);

vertices[5].position = D3DXVECTOR3(1, 1, 1);
vertices[5].color = D3DXVECTOR4(0, 0, 1, 1);

vertices[6].position = D3DXVECTOR3(-1, -1, 1);
vertices[6].color = D3DXVECTOR4(1, 0, 0, 1);

vertices[7].position = D3DXVECTOR3(1, -1, 1);
vertices[7].color = D3DXVECTOR4(1, 0, 0, 1);

//indices = { 2, 0, 3, 3, 1, 0, 3, 1, 7, 7, 5, 1, 6, 4, 2, 2, 0, 4, 7, 5, 6, 6, 4, 5, 0, 4, 1, 1, 5, 4, 6, 2, 7, 7, 3, 2 };

indices[0] = 2;
indices[1] = 0;
indices[2] = 3;
indices[3] = 3;
indices[4] = 1;
indices[5] = 0;
indices[6] = 3;
indices[7] = 1;
indices[8] = 7;
indices[9] = 7;
indices[10] = 5;
indices[11] = 1;
indices[12] = 6;
indices[13] = 4;
indices[14] = 2;
indices[15] = 2;
indices[16] = 0;
indices[17] = 4;
indices[18] = 7;
indices[19] = 5;
indices[20] = 6;
indices[21] = 6;
indices[22] = 4;
indices[23] = 5;
indices[24] = 0;
indices[25] = 4;
indices[26] = 1;
indices[27] = 1;
indices[28] = 5;
indices[29] = 4;
indices[30] = 6;
indices[31] = 2;
indices[32] = 7;
indices[33] = 7;
indices[34] = 3;
indices[35] = 2;

vertexBufferDesc.Usage = D3D10_USAGE_DEFAULT;
vertexBufferDesc.ByteWidth = sizeof(VertexType) *m_vertexCount;
vertexBufferDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = 0;
vertexBufferDesc.MiscFlags = 0;

vertexData.pSysMem = vertices;

result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
if(FAILED(result))
{
    return false;
}

indexBufferDesc.Usage = D3D10_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = sizeof(unsigned long) *m_indexCount;
indexBufferDesc.BindFlags = D3D10_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;

indexData.pSysMem = indices;

result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);

return true;
}

void CubeClass::RenderBuffers(ID3D10Device* device)
{
unsigned int stride;
unsigned int offset;

stride = sizeof(VertexType);
offset = 0;

device->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);

device->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);

device->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

device->DrawIndexed(36, 0, 0);

}


texts: How can I achieve strong typing with a component messaging system?

texts: I'm looking at implementing a messaging system in my entity component system. I've deduced that I can use an event / queue for passing messages, but right now, I just use a generic object and cast out the data I want. I also considered using a dictionary. I see a lot of information on this, but they all involve a lot of casting and guessing. Is there any way to do this elegantly and keep strong typing on my messages?


texts:
In my code, I just have a Level class right now in the main game loop that just blits a background and spawns some enemies for testing purposes...But I can't figure out how to go about implementing multiple levels and level progression.  What is the best way to manage multiple levels and level progression in a game?

I'm thinking that I would make the Level class just read level data from a file, and create a Level vector...But I'm not sure if that's the best way to do it.


texts:
I'm trying to assess the difficulty of creating a rendering style that is more like the game Okami and the Quake mods (as shown on this page...search for 'okami','quake npr').  Here's a better page describing the Quake rendering mod.

Can a game engine such as Unity be used and programmed to achieve these kind of rendering styles?

I'm doing research and am totally new to this so any insight into this would help tremendously.


texts: What is a good method for collision detection, where I check a collision, instead of all collisions

texts:
The collision system for my game currently works fine; it lets me test a collision with an entity or specified rectangle, but that's not enough. I use to use Game Maker, and it had collision events that were simple. What I want to do is not check collision with everything, but check for a collision with everything.

Using the former method would probably be really expensive, checking all other objects, per object, per frame. What is a good method for collision detection, where if I am colliding with something, I get it's class, and can decide what to do with it?


texts: Locating point on a closed path to maximize sum of distances to a sample of weighted points

texts:
I'm doing AI for a simple puzzled game and need to solve the following problem efficiently (less than 1 sec for the range specified since I need to do many iterations in a game).

  A sample of N (1 to 100,000) monsters with strength from 1 to 10,000
  are distributed on the sides of a square (0 to 200,000,000) at 1 unit
  interval starting from the upper left corner. Move hero to a point X
  on the square to maximize sum of the weighted distances to the
  monsters. A weighted distance to each monster is calculated by
  MonsterStrength*ShortestDistanceToX (by going clockwise or
  anticlockwise). X must also be on the 1 unit interval mark and the
  monsters and hero move on the sides of the square only

I have tried several approaches but none are fast or accurate enough.

The possibly complementary of this problem (minimizing the sum of distances to set of points at furthest distance from each corresponding monsters in the original set) seems to related to finding the geometric median, facility location problem, Weber problem etc.

Linear programming is also possible but might be too slow and overkilled.

Does anyone have any idea for a good approach?

Here is an illustration on a square of sides of length 3:

1-------2(M/3)-------3------4(M/1)
|                              |
12(M/2)                        5
|                              |
11(M/1)                        6
|                              |
10--------9---------8(X)-------7

if you put a monster of strength 3 at 2, one with strenth 1 at 4, one with strength 2 at 12 and one with strength 1 at 11 and the hero(X) at 8. the sum of weighted distane is:
3*6 + 1*4 + 1*3 + 2*4 = 33, which is also the maximum in this case


texts: How to use proximity sensor in android with unity3d?

texts: I want to create a android game with unity3d using proximity sensor an I don't know how to access that sensor with java script


texts: Why does the object rotate to a random direction when I start dragging?

texts:
I'm trying to do drag to rotate sort of thing, so far the code is fine. However when starting to drag (left clicking first), the object rotate to a random direction first which looks odd.

here is my code :

public Camera cam;
public float smoothAngle, dragPower = .3f;
public bool isRadial = true;
float angle, angleOld, angleDelta, angleRef;
Vector2 mousePosOld, mousePosDelta = Vector2.zero;

void Update()
{
  Vector2 mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
  if (Input.GetMouseButton(0))
  {
    mousePosDelta = mousePos - mousePosOld;
    float rotX = (mousePosDelta.magnitude / Time.deltaTime)
                  * dragPower
                  * -Mathf.Sign(mousePos.y)
                  * Mathf.Sign(Vector2.Dot(Vector2.right, mousePosDelta));

    transform.Rotate(Vector3.forward, rotX);

    mousePosOld = mousePos;
    angleDelta = Mathf.DeltaAngle(angleOld, transform.localEulerAngles.z);
    angleOld = transform.localEulerAngles.z;
  }
  else
  {
    transform.RotateAround(transform.position, transform.forward, angleDelta);
    angleDelta = Mathf.SmoothDampAngle(angleDelta, 0, ref angleRef, smoothAngle);
  }
}

this is the effect :


texts: Are square or hex grids better for pathfinding?

texts: Is there any significant difference between using a square or hexagonal grid for the area searched by a path finding algorithm. In other words, is square or hexagonal better, and if so why.


texts: How to properly separate render thread from logic thread?

texts:
I am not asking about parallelization of physics and so on stuff with parallel_for() like stuff.

I've managed to have separate rendering thread from logic thread, in glfw3 application:

void render_thread() {
    glfwMakeContextCurrent(win);
    while( !glfwWindowShouldClose(win) ) {
        sleep(10); // emulate heavy rendering, to be sure that main loop stops event processing during this sleep
        glfwSetWindowTitle(win, "some title"); // posts message? to window queue to update title
    }
    glfwMakeContextCurrent(nullptr);
}

And init/event/input handling loop is as follows:

void main_thread() {
    set_thread_priority(highest); // to be sure this is first priority in OS sheduler, compared to render thread
    win = glfwCreateWindow(...);
    std::thread rt(&render_thread);
    while (!glfwWindowShouldClose(_glWindow))
        glfwWaitEvents(); // could put thread to sleep
    rt.join();
}

Here is the problem, when i click to close window:

rt.join() never returns, because it waits for render_thread() to return
render_thread() could not return from glfwSetWindowTitle() call, seems no message processing goes on, or something other that i dont know.

Maybe my whole approach is wrong, but how should i solve that in a sane way?


texts:
what is the most used method or algorithm for saving game state (profiles), databases text files how there encryption goes and things related.

I have seen Caesar IV used mySQL.

any suggestions.


texts: Does "Object.ToString().GetHashCode()" return a truly unique character seed?

texts: In my game I'm generating a character seed from a bunch of traits that the player chooses. The traits are all part of a Enum. In unity I've attached a script to a bunch of toggles. When the player selects a toggle I do this :  charGen.testCharHash += trait.ToString().GetHashCode(); Does this guarantee that I will have a unique number generated based on the players choice ?


texts: How can I send effects to joystick connected to my PC USB using C# and sharpdx?

texts:
I can get a list of the joysticks connected to my PC.
But now I want to send effects for example to send a command that will make a button click for example the triangle button or the square button.

But I'm not sure how to continue with the effects and how to send the commands to the buttons.

I'm stuck in the HandleJoystick method.

namespace Ps4_Controller
{
    public partial class Form1 : Form
    {
        DirectInput input = new DirectInput();
        Joystick stick;

        public Form1()
        {
            InitializeComponent();

            stick = ListJoysticks()[0];
        }

        private Joystick[] ListJoysticks()
        {
            List<Joystick> sticks = new List<Joystick>();

            foreach (DeviceInstance device in input.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly))
            {
                Joystick stick = new Joystick(input, device.InstanceGuid);
                stick.Acquire();

                foreach (DeviceObjectInstance deviceObject in stick.GetObjects(DeviceObjectTypeFlags.Axis))
                {
                    stick.GetObjectPropertiesById(deviceObject.ObjectId).Range = new InputRange(-100, 100);
                }
                sticks.Add(stick);
            }
            return sticks.ToArray();
        }

        private void HandleJoystick()
        {
            Joystick stick = ListJoysticks()[0];
            int[] axis = new int[0];

            foreach (DeviceObjectInstance doi in stick.GetObjects())
            {
                axis = new int[axis.Length + 1];
                axis[axis.Length - 1] = doi.Offset;
            }

            EffectParameters ep = new EffectParameters();
            DeviceInstance stick1 = new DeviceInstance();

            Effect effect = new Effect(stick.);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
}


texts:
Here's the scenario:

I procedurally generate terrain on the fly, creating an isosurface which is an overlay on top of a scalar field of data points. These underlying data points are basically voxel data, and I use the Marching Cubes algorithm to interpolate vertices, which are used to create the triangles for the meshes.

What I end up with is a contiguous terrain, which is split into chunks, with each chunk split into "blocks". Each block's outline, when looking from directly above, is a square, made up of up to 5 triangles.

The underlying mesh data (vertices, indices, texture coords, normals), are calculated for each "block", and then a mesh is built for each "chunk" (collection of blocks' data). Texture coords are determined for each triangle, and as such, you can see separate texture mappings for each triangle when looking at the textured mesh.

At a minimum, I would like to figure out how to apply the textures to each block as a whole, i.e.- stretch it over all the triangles in a block.

Better yet, I would like to implement something like texture-splatting on arbitrary regions of the terrain, spanning accross chunk and block boundaries, so that I can arbitrarily paint different textures where every I want them.

Ideally, I would like to do the splatting I mentioned procedurally, so that aspects of the terrain, (altitude, proximity), will determine what texture is used in what location.

Can someone clue me in to what is involved in achieving this?
I am using Ardor3D (Java) for mesh creation/texturing/etc...


texts: How can I represent location in a massive world?

texts:
I've been thinking about No Man's Sky a lot recently and all the technical challenges they must face. For example, how on earth do you store a players location in a world that is so enormous?

I assume x,y,z isn't feasible. I notice the advertised number of planets (18 quintillion) is exactly double the maximum integer you can store on 64-bits, if that is relevant.

From watching tech videos of him (Sean Murray) describing the architecture, he seems to say everything is generated by formula where the inputs are x and y. Obviously he's simplifying, but how might one accomplish this?


texts: Scaling Sound Effects and Physics with Framerate

texts:
(I'm using XNA and C#)
Currently, my game (a shooter) runs flawlessly with 60 FPS (which I developed around).
However, if the framerate is changed, there are two major problems:

Gunshot sound effects are slower
Jumping gets messed up

Here's how I play gunshot sounds:

update(gametime)
{
    if(leftMouseButton.down)
    {
        enqueueBulletForSend();
        playGunShot();
    }
}

Now, obviously, the frequency of playGunShot depends on the framerate.  I can easily fix the issue if the FPS is higher than 60 FPS by capping the shooting rate of the gun, but what if the FPS is less than 60?
At first I thought to just loop and play more gunshots per frame, but I found that this can cause audio clipping or make the bullets fire in "clumps."

Now for the second issue:
Here's how jumping works in my game:

if(jumpKey.Down && canJump)
{
    velocity.Y += 0.224f;
}

// ... (other code) ...
if(!onGround)
    velocity.Y += GRAVITY_ACCELERATION * elapsedSeconds;

position += velocity;

The issue here is that at < 60 FPS, the "intermediate" velocity is lost and therefore the character jumps lower.  At > 60 FPS, the game adds more "intermediate" velocities, and therefore the character jumps higher.

For example, at 60 FPS, the following occurs:

Velocity increased to 0.224
Not on ground, so velocity decreased by X
Position increased by (0.224 - X) <-- this is the "intermediate" velocity

At 30 FPS, the following occurs:

Velocity increased to 0.224
Not on ground, so velocity decreased by 2X
Position increased by (0.224 - 2X) <-- the "intermediate" velocity was lost

All help is appreciated!


texts:
so I am making multiplayer game and I stuck on one thing, I have blood overlay canvas in my scene(you know, in fps games if somebody shoots you your screen becomes red and this stuff), and when I shoot enemy, his screen becomes red, but mine also.

thats what i ahve now: if raycast hits enemy, player script calls: ColorController.MakeItred(); color controller is attached to this canvas image, here is its code:

`

 void Start () {
       if (current == 100 || current == 0)
        {
        opacity = 0;
        }
    }

// Update is called once per frame
void Update () {
          image = GetComponent<Image>();
    image.color = new Color32(reds, greens, blues, opacity);

    if (current == 0)
    {
        opacity = 0;
    }
    if (!playing)
    {
        if (opacity > 0)
        {
            StartCoroutine(toLower());
        }
        }
    if (opacity == 255)
    {
        playaudio();

    }

}

public static void MakeItred()
{
    opacity = 255;

}
public static void MakeItOff()
{
    opacity = 0;

}
 void playaudio()
{
    AudioSource audio = GetComponent<AudioSource>();
    audio.Play();
}
private IEnumerator toLower()
{
    playing = true;
    opacity -= 1;

    yield return new WaitForSeconds(interval);
    playing = false;
}`

btw thats function in player code that calls colorcontroller.makeitred,

[ClientRpc]
    public void Rpcdoit()
    {
        ColorController.MakeItred();
    }

-Nick
thanks.


texts:
I am currently working on a C++ + SDL2 game engine and I am stuck on a problem. The problem is that whenever I pass SDL_WINDOW_OPENGL to SDL_CreateWindow(), it return null and so my program stops. But it works fine if I pass any other flag while not passing SDL_WINDOW_OPENGL.
This is the function I am calling SDL_CreateWindow():

Game::Game(const char* title, int w, int h, int x, int y, int glmajversion, int glminversion, Uint32 flags){
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
        std::cout<<"[Error]: Unable to initialize SDL2."<<std::endl;
    }

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, glminversion);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, glmajversion);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);
    window = SDL_CreateWindow(title, x, y, w, h, flags);
    if (!window){
        std::cout<<"[Error]: Unable to create SDL2 window."<<std::endl;
        exit(-1);
    }
    context = SDL_GL_CreateContext(window);
    SDL_GL_MakeCurrent(window, context);
}

If I call SDL_GetError() before exiting, it returns "Couldn't find matching GLX visual".


texts: How should I configure firewall for online game server?

texts:
I'm complete newbie on game server work.
As I know, online (massively multiplay) game server should keep some TCP or UDP connection from the user. As I (=newbie) guess, maybe huge count of socket port should be opened. So how should I configure firewall for game server? Or should I use some other special method to security?  Any advise will be appreciated.


texts:
I define and set viewport using this piece of code:

D3D11_VIEWPORT viewport;

viewport.Width = (FLOAT)pBspWindow->GetWidth();
viewport.Height = (FLOAT)pBspWindow->GetHeight();
viewport.TopLeftX = 0.0f;
viewport.TopLeftY = 0.0f;
viewport.MaxDepth = 1.0f;
viewport.MinDepth = 0.0f;

pD3DContext->RSSetViewports(1, &viewport);

If I remove MaxDepth/MinDepth members and run my application under debug session triangle will not be shown.

This behaviour doesn't appear under release session.

I searched on MSDN, but couldn't find anything.

I'm interested why is this happening?


texts: Which is better a computer science degree or a Software engineer degree?

texts:
I'm asking here so since you all have experience in or around game programming, that's what I want to do, and I’m trying to find as many options as I can before my senior year, which is next year. So do you have any opinions on the matter of which would give me a better education in programming?

Please no talking about anything other than the two degrees because I know of game programming degrees out there but I like to see which of these would provide the best alternate choice.


texts:
For business reasons, I would like to know what constitutes satire in a game.

Also, is there a better place to ask questions like this on the business side of game development?


texts: I want to know some good reasons to use jMonkeyEngine for a Java 3d game development tool instead of just creating a game with LWJGL myself? I want to know a good reason I should choose this tool. Does anyone have a list of pros and cons for me to work with?


texts: Making an object orbit using c# script for Unity+Vuforia

texts:
I have written a simple c# script for Unity+Vuforia. I want to create a simple sample project where an object like a sphere is revolving (orbiting) origin (0,0,0) above image target.

The code I have written is here

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

public class Orbit : MonoBehaviour
{
    float angles;
    float radiuss;
    float angleSpeed;

    // Start is called before the first frame update
    void Start()
    {
        angles = 0;
        radiuss = 0.2f;
        angleSpeed = 1;

    }

    // Update is called once per frame
    void Update()
    {
        angles += Time.deltaTime * angleSpeed;

        float x = radiuss * Mathf.Cos(Mathf.Deg2Rad * angles);
        float z = radiuss * Mathf.Sin(Mathf.Deg2Rad * angles);
        float y = 0;

        transform.position = new Vector3(x, y, z);
    }
}

It works perfectly fine if I am not using it with Vuforia, but when I attach this script as component to an object in Vuforia, it does not work and acts weird.
These are the configurations and hierarchy

Please help me out, I tried a lot of things.


texts: How do I slice a 3D object at runtime in Unity?

texts: I'm specifically looking for some sort of algorithm or way that can "cut" a 3 dimensional mesh with some other game object. How would I implement this?


texts: Unity 2D Following player on the x-axis only, at a constant speed

texts:
This following code does work, but I have one issue with it. Once the gameobject starts getting close to the player that it is chasing it slows down and does not continue going at a constant speed to the target. Is there another way I can code this to keep the speed constant even if the gameobject is close to the target?

Vector3 followXonly = new Vector3(target_position.x, transform.position.y, transform.position.z);
transform.position = Vector3.Lerp(transform.position, followXonly, speed * Time.deltaTime);


texts: What's the purpose of OpenGL's Vertex Array Objects?

texts:
I've just started out with OpenGL I still haven't really understood what Vertex Array Objects are and how they can be employed.

If Vertex Buffer Object are used to store vertex data (such as their positions and texture coordinates) and the VAOs only contain status flags, where can they be used? What's their purpose?

As far as I understood from the (very incomplete and unclear) GL Wiki, VAOs are used to set the flags/statūs for every vertex, following the order described in the Element Array Buffer, but the wiki was really ambiguous about it and I'm not really sure about what VAOs really do and how I could employ them.


texts: how to make a seemingly endless backdrop in Unity

texts:
Potential solution at the bottom.

I have a rocket which flies straight up, as it gets higher you can see the edge of the terrain. I want the rocket to eventually leave the atmosphere and then the landscape to disappear from view as the player would be so high up.

How do i make it appear that the landscape is endless?

image pre launch:

image post launch:

My solution to anyone who has the same type of question

firstly i made a mountain range using the terrain, a 3x3 tiled one worked for me. I then used the lighting settings to add fog to the scene, to slightly obscure the mountains. Lastly i rotated the camera upward by -5 when the rokcet reached a certain position to further hide the blankness behind the mountains. images shown below:

pre-camera rotation

post-camera rotation


texts: Update the UI Rotation According to camera rotation

texts:
I have a camera which is showing the userInterface (canvas) object into the front of my camera. I am only updating my userinterface position if the camera raycast is not hitting my userInterface object collider. something like this

public class UIPlacerAtCamFront : MonoBehaviour {

    public GameObject userInterface;
    public float placementDistance;
    Vector3 uiPlacementPosition;
    RaycastHit  objectHit;

    void Update () {

        Vector3 fwd = this.transform.TransformDirection(Vector3.forward);
        //Debug.DrawRay(this.transform.position, fwd * 50, Color.green);

        if (Physics.Raycast(this.transform.position, fwd, out objectHit, 50))
        {
            //raycast hitting the userInterface collider, so do nothing, userinterface is infornt of the camrea already
        }
        else
        {
            //raycast is not hitting userInterfae collider, so update UserInterface position accoding to the camera
            uiPlacementPosition = this.transform.position + this.transform.forward * placementDistance;
            userInterface.transform.position = uiPlacementPosition;
        }

        //Continuously update userInterface rotation according to camera
        userInterface.transform.rotation = this.transform.rotation;
    }
}

The above script has attached with my camera, it displaying the object correctly but as i start to rotate my camera my UI object rotation looks very strange as below image suggested

As i rotate, this problem occurs

I know that the problem is in rotation, so I tired to change my this rotation code

    userInterface.transform.rotation = this.transform.rotation;

to this

userInterface.transform.localEulerAngles = new Vector3 (this.transform.localEulerAngles.x,
            0,
            this.transform.localEulerAngles.z);

but it bring another strange rotation for me, like given below

I want that my userinteface object face my camera correclty, even my camera watching the start or end of my userinteface object. How can i rotate my UI according to camera rotation correctly?


texts:
I'm working on Unity and I use node for my serverside.

I'm starting a multiplayer project on mobile. I'm searching for a good structure for my game that how server controls the events. For example my players do some requests like upgrades and... simply my server receives those requests and after validation saves them in database and... but in some parts 2 player should start the game and get sync to play the game. in that part a copy of game for server should run to calculate ingames parts and respond to player requests like move inputs and...

The problem is should my server for every game for 2 players run a copy of game and send and receive data with socket from that copy to run the game or there is other ways to do that?


texts: general routine of creating real video games?

texts:
i'm new to game developement and i want to fill the missing spots in the proccess of creating games for PC. my intentions are for first person action games like "return to castle wolfenstein", "hitman" or "call of duty" series. i've done some interior designs in autodesk 3ds max and also wrote web/windows programs in c#. so now i like to know how games works. here is what i came up with:

first: create models and export them in whatever format your rendering engine prefers. so any object has to be modeled seperatly no mater what kind of object it is.

second: tell the engine where and when to render which object.

Q1) what about object behaviors?do you use the 3d software built in scripting like maxscript? or is there some other way to create behaviors in advanced levels?

Q2) how do you create clipping for objects? since by default graphical shapes don't have such a feauture.

Q3) most of those games played in a virtual world. so do you have to create the world at once? or is it actually seperate pieces that will be assembled by rendering engine?

i know these are very deep questions that can't be simply answered in a few lines. so if there is any book that is not too detailed and not too general, i'll be really appreciate knowing about it. in any case i really appreciate your answers.


texts: How do I tag an empty space for an 'InAir' Boolean?

texts:
I've been working with my game's settings to get the perfect jump height, gravity and movement that suits the player, however my problem is my player essentially floats back down to the ground, when I want them to fall much faster (it's a 3D game) but I don't want to tamper the gravity anymore solely for the player.

What I've done is created 2 extra Booleans alongside my Grounded Boolean, one for In Air and another for Extra Gravity, and this is where my problem comes in.

I have no idea how to set a tag to the empty space in the air, and I was wondering if anyone knew how to do this, or if there is a better method for detecting when my player is in the air?

This is what my script currently looks like:

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

public class PlayerScript : MonoBehaviour
{
    public float movementSpeed = 5f;
    public float jumpForce = 7;
    public float jumpSpeed = 7;
    public Rigidbody rigidbody;
    private Vector3 input;
    public GameObject Player;
    public bool grounded;
    public bool inAir;
    public float ExtraGravity;

    // Use this for initialization
    void Start()
    {
        var rigidbody = GetComponent<Rigidbody>();
        var col = GetComponent<CapsuleCollider>();
        Player = GameObject.FindWithTag("Player");
    }
    void FixedUpdate()
    {
        if (Input.GetKeyDown("space"))
        {

            if (grounded)
            {
                Debug.Log("Spacebar pressed");
                rigidbody.AddForce(0, jumpForce, 0);
            }

            if(inAir)
            {
                Vector3 vel = rigidbody.velocity;
                vel.y -= ExtraGravity * Time.deltaTime;
                rigidbody.velocity = vel;
            }

        }
    }

    // Update is called once per frame
    void Update()
    {

        if (Input.GetKey("w"))
        {
            transform.position += transform.TransformDirection(Vector3.forward) * Time.deltaTime * movementSpeed * 5.5f;
        }
        else if (Input.GetKey("s"))
        {
            transform.position -= transform.TransformDirection(Vector3.forward) * Time.deltaTime * movementSpeed * 4.5f;
        }
        else if (Input.GetKey("d"))
        {
            transform.position += transform.TransformDirection(Vector3.right) * Time.deltaTime * movementSpeed * 5.5f;
        }
        else if (Input.GetKey("a"))
        {
            transform.position -= transform.TransformDirection(Vector3.right) * Time.deltaTime * movementSpeed * 5.5f;
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            transform.position += transform.TransformDirection(Vector3.forward) * Time.deltaTime * movementSpeed * 20.5f;
        }

    }

    void OnCollisionStay(Collision collision)
    {
        if (collision.gameObject.CompareTag("Floor"))
        {
            grounded = true;
        }
    }

    void OnCollisionExit(Collision collision)
    {
        if (collision.gameObject.CompareTag("Floor"))
        {
            grounded = false;
        }
    }

}


texts:
I'm trying to use a different Thread for the whole WinAPI-Message-Loop stuff, so the window always keeps being responsive. Of course I'm using the main thread as the "window thread", because I need a context before loading textures etc. and I can't just call Get/PeekMessage for a different thread.

Now there are a few things I'm wondering about though:

Can I use the OpenGL context handle from a different thread? I'm relatively sure I can since otherwise there would be no way to do multi-threaded rendering, but maybe there's more to it.
At some point I have to call SwapBuffers() from inside the render loop - that means in this case, from a different thread. Can I just use the HDC I usually use? Is this handle thread-safe? I'm not so sure about that, but I can't really find a definitive answer on the subject.

If the answer is no, what would be a good method to deal with the issue? Maybe I can send a message from the render-thread?


texts: Vibration/Rumble with PS4 Pad and LPDIRECTINPUTDEVICE8

texts:
I actually try to make my PS4 Pad rumble.
I get the pad capabilities with

DIDEVCAPS capabilities;
capabilities.dwSize = sizeof(DIDEVCAPS);
ps4pad->GetCapabilities(&capabilities);

the next step is to check if the flag DIDC_FORCEFEEDBACK is ok

But capabilities.dwFlags & DIDC_FORCEFEEDBACK always return false.

As my pad is a ps4, I know it support feedback.

Have you an idea why it's return false, what I missed?


texts:
How can I build Assimp with cMake and MinGW?

I tried, but I don't get a functioning library...

Details of my attempt:

I am trying to build the Open Asset Import Library (Assimp) but I have been running into problems. The assimp documentation is really poor and expects you to know exactly what you are doing. The developers haven't been particularly helpful either. I hope someone here has successfully built assimp and can let me know where I am going wrong. I suspect that I have several problems that are contributing to my failure. I am using 64 bit Windows 8.1 pro and using MinGW version 4.8.1.

The first thing I tried was downloading assimp 3.1.1 and boost 1.57. I extracted both folders and tried to use cMake to generate the makefile for MinGW. I haven't used cMake before and the assimp instructions are use cMake as you normally would, so I have no idea if I configured it right. I pointed BOOST_ROOT to the boost folder I extracted from the download, set it to build static libraries and generated the makefile.

I then tried running the makefile and got a number of errors. The first was

IFCReaderGen.cpp.obj: too many sections and was too big.

After some googling, I found a workaround was to set CMAKE_BUILD_TYPE to release. That seemed to work and it finished the build but I only got the files assimp32.dll and libassimp.dll.a, which I thought was odd because I was expecting lib/relese/libassimp.a to be generated as per the details on the assimp website. Though the website might also be wrong or out of date.

I linked with -lassimp.dll and that allowed me to build my program. However it crashed upon start-up - the error that appeared immediately at start-up was

  Program has stopped working

(There was no additional info.) I guessed that this was a dll problem—which was odd because I had (tried) to build the static libraries through cMake. I copied assimp32.dll into my executable folder. This time, the program wouldn't crash but the screen would be blank. I'm guessing that there was something wrong with the library I build that was causing it to link incorrectly.

At this point, I deleted everything to try a fresh start. I tried to follow this article:

I downloaded assimp 3.1.1 and boost 1.57 and extracted them.
I opened cmd, changed to the boost root directory and ran

bootstrap.bat mingw

I then ran

b2 --build-dir="C:/Libraries/boost/" variant=release link=static address-model=32 toolset=gcc

The result of this was

598 targets updates, 3 targets skipped, 2 targets failed.

I now have a folder C:\Libraries\boost\boost\bin.v2 with two folders libs and standalone, but I'm not certain what my BOOST_ROOT directory is anymore.
I opened cMake, selected the assimp folder I had extracted, and configured the following:

BOOST_ROOT = "C:/Libraries/boost/boost/"
ASSIMP_BUILD_STATIC_LIB = TRUE
ASSIMP_BUILD_TESTS = FALSE
ASSIMP_ENABLE_BOOST_WORKAROUND = FALSE
BUILD_SHARED_LIBS = FALSE

I then pressed configure and got the error that the boost libraries were not found.

I'm only guessing what these cMake settings do, as I can't find any documentation for assimp. I'd like to build some version of assimp that I can then link to and use in a simple test program. At some point I will go back and build the shared libraries, but first I just want to get something working and understand how to do it again.

Can someone see what has gone wrong?


texts: Is there a way to use other fonts, besides the default ones in OpenGLUT?

texts:
I'm using OpenGLUT functions like glutBitmapString to render sentences and words in a game. However, there is a limited set of fonts to use and I need some bigger size fonts. Is there a way to add new fonts to these functions/API?

Thanks


texts: Collision Detection and Bounding Box Creation

texts:
I am trying to create bounding boxes. My goal is not to create them with giving x,y and z coordinates. But rather, I will be loading a model or else rendering a shape - say an aeroplane. The algorithm then should be able to create efficient bounding boxes around it. I am coding in opengl.

Can you help me out with the same?


texts: Best (Most Popular?) Image Format For Texturing

texts: Okay, so I am using C++ with OpenGL, and I am going to create a loader to load in textures for my 3D game. (But the textures are 2D). I want the option of transparency, even if I decide not to use it. I need decent quality, although it doesn't have to be top notch. What do you guys suggest for format (PNG, TGA, etc.). Also, maybe make it something that is easy to create a loader for (I'm not going to use an already created one.). And also, if you have any links/tips to help out with the loader, that would be appreciated.


texts: How to apply fast & slow camera transition

texts: I know there is a lerp function there that smoothens the camera but I wanted it to work the other way around. Lets say starting position of the player is at the left side of the camera/screen and when the players goes around the right edge (or as long as more than half width) screen travelled I want to camera to snap to the player but with smooth transition and this is the hard part I wanted to make the camera move fast as long as it is less than half of the players distance travelled and apply a slow speed as the camera travels more than half the distance of player.


texts: When do you have inflation and when deflation in a virtual economy

texts:
In a virtual economy, you can calculate all the income and all the costs (money that sinks) from every user in the game. You can calculate the percentage of the new money on the system or the money that has been lost from the system by the income and the costs.

I believe that having a small positive percentage is not inflation, but from the other side, crucial for the economy. However, I was wondering if there are any rough limits of this percentage that could lead to an inflation or deflation for negative percentage.

For example, if you have every week a result of 1-2%, will not be a serious problem. But if you have 30% or -30%, obviously you will.

Have you found from your experience or from any research limits that could ring a bell?


texts: Why don't ShaderToy shaders work with LibGDX?

texts:
Can someone tell me what is different about the shader implementation in LibGDX that makes it incompatible with the shaders from ShaderToy? It looks like you can use ShaderToy shaders directly with other frameworks so am wondering what the difference is.
People talk about converting shadertoy shaders from GLSL to HLSL for use with Unity or Monogame, but as far as I know LibGDX uses GLSL so I don't see why the code is different?


texts:
Before integrating the Bullet Physics, the camera worked fine. But instead of using my own simple struct for transform data, I use rigid body structs provided by the physics library now.

There are two issue with the first person camera at the moment. First, it is stuck in the ground and when I try to move it, it slips back to it's position. Second, When I get the camera out of the ground, which sometimes happens, The applied rotation isn't in the way I move the mouse. When I move the mouse straight, the camera is moved in circles.

This is how the rigid body it set up.

float mass = 1.0f;
btCollisionShape* shape = new btBoxShape(btVector3(0.5f, 0.5f, 0.5f));
btDefaultMotionState* state = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, mass), btVector3(0, 0, 0)));
btVector3 inertia;
shape->calculateLocalInertia(mass, inertia);
Body = new btRigidBody(mass, state, shape, inertia);

This is how I get and set rotations and positions of rigid bodies.

vec3 Position()
{
    btVector3 pos = Body->getWorldTransform().getOrigin();
    return vec3(pos.getX(), pos.getY(), pos.getZ());
}
void Position(vec3 Position)
{
    btTransform transform = Body->getCenterOfMassTransform();
    transform.setOrigin(btVector3(Position.x, Position.y, Position.z));
    Body->setCenterOfMassTransform(transform);
}
vec3 Rotation()
{
    vec3 rot;
    Body->getWorldTransform().getBasis().getEulerZYX(rot.z, rot.y, rot.x);
    return rot;
}
void Rotation(vec3 Rotation)
{
    btTransform transform = Shape->getCenterOfMassTransform();
    transform.setRotation(btQuaternion(Rotation.y, Rotation.x, Rotation.z));
    Shape->setCenterOfMassTransform(transform);
}

And this is how I calculate the view matrix of the camera.

const float pi = glm::pi<float>();
if      (Rotation().x < -pi) Rotation(vec3(Rotation().x + pi*2, Rotation().y, Rotation().z));
else if (Rotation().x >  pi) Rotation(vec3(Rotation().x - pi*2, Rotation().y, Rotation().z));

const float margin = 0.2f;
if      (Rotation().y < -pi/2+margin) Rotation(vec3(Rotation().x, -pi/2+margin, Rotation().z));
else if (Rotation().y >  pi/2-margin) Rotation(vec3(Rotation().x,  pi/2-margin, Rotation().z));

vec3 lookat(
    sinf(Rotation().x) * cosf(Rotation().y),
                         sinf(Rotation().y),
    cosf(Rotation().x) * cosf(Rotation().y)
);

cam->View = lookAt(Position(), Position() + lookat, vec3(0, 1, 0));

How can I move and rotate a rigid body to use it as camera?


texts: Tile based collision detection errors if player is smaller than tiles

texts:
I have implemented a tilemap where each tile is at a non-negative x and y position. (So at the moment think like chess)

At the moment a tile is 16, 16 pixels in size

Tile 0,0 is at the left bottom corner

Some tiles should be collidable. I've never implemented something like that and during research stumbled upon: https://jonathanwhiting.com/tutorial/collision/

The general idea + collision response handling:

let mut new_pos = Point2::new(curr_pos.x + x_offset, curr_pos.y);

let collision_on_x = collide_with_world(&new_pos, &world);

if !collision_on_x  {
    transform.translate_x(x_offset);
}

new_pos.y = curr_pos.y + y_offset;

let collision_on_y = collide_with_world(&new_pos, &world);

if !collision_on_y  {
    transform.translate_y(y_offset);
}

The collision detection

fn collide_with_world(new_pos: &Point2<f32>, world: &World) -> bool {
    // TODO make these sizes i16 instead so we can grow in any direction!
    let mut left_tile: u16 = (new_pos.x / TILE_SIZE_IN_PIXELS as f32) as u16;
    // -1 so that we do not collide until we are exactly at the thing
    let mut right_tile: u16 = ((new_pos.x + PLAYER_WIDTH - 1.0) / TILE_SIZE_IN_PIXELS as f32) as u16;
    let mut top_tile: u16 = ((new_pos.y + PLAYER_HEIGHT - 1.0) / TILE_SIZE_IN_PIXELS as f32) as u16;
    let mut bottom_tile: u16 = (new_pos.y / TILE_SIZE_IN_PIXELS as f32) as u16;

    println!("new_pos: {:?}, left {}, right {}, top {}, bottom {}", (new_pos.x, new_pos.y), left_tile, right_tile, top_tile, bottom_tile);

    // Useless as long as we use unsigned coordinates
    //if left_tile < 0 {
    //    left_tile = 0;
    //}

    if right_tile > WORLD_WIDTH_IN_TILES {
        right_tile = WORLD_WIDTH_IN_TILES;
    }

    // Useless as long as we use unsigned coordinates
    //if bottom_tile < 0 {
    //    bottom_tile = 0;
    //}

    if top_tile > WORLD_HEIGHT_IN_TILES {
        top_tile = WORLD_HEIGHT_IN_TILES;
    }

    let mut any_collision = false;

    for i in left_tile..=right_tile {
        for j in bottom_tile..=top_tile {
            let tile = world.get_tile(i, j);
            println!("tile at {:?} is {:?}", (i, j), tile);

            match tile {
                Some(tile) => {
                    if tile == WALL {
                        println!("hit a wall at {:?}!", (i, j));
                        any_collision = true;
                    }
                }
                None => (),
            }
        }
    }

    return any_collision;
}

I basically took (or tried to take) the optimised version of the linked blog-entry.

Now to the problems:

If PLAYER_WIDTH and PLAYER_HEIGHT are both 16.0 - collision works fine

But note that I had to put -1.0 in the calculation of the right_tile and top_tile, else the collision for UP and RIGHT would occur one pixel to early (so the player would never touch walls to their top or right)

This change alone makes me a bit suspicious - looks like I made an error there.

The real problems start if the player is smaller than a tile:

In the following screenshots the following rules apply:

*) the PLAYER_WIDTH and PLAYER_HEIGHT are both 8
*) Greenish tiles are the only walls!
*) All the screenshots were taken in ONE run - no parameters were changed during this run!

1)  -> Trying to collide with right tile -> overlapping
2)  -> Trying to collide with top tile -> cannot go any nearer than 4 pixels (half the height of the player)
3)  -> Trying to collide with left tile -> cannot go any nearer than 4 pixels (half the width of the player)
4)  -> Trying to collide with top tile -> suddenly overlapping although different tile didn't collide?
5)  -> Trying to collide with bottom tile -> cannot go any nearer than 4 pixels

I cannot grasp 2 and 4 at the moment.


texts: Graphics Raycaster of Unity; How does it work?

texts:
I'm making a small game for the first time and enjoying it thus far. The only thing that keeps bothering me is that I can't find a human explanation of what the graphics raycaster does. What's the blocking mask, what are the blocking objects etc? Should I mask the things I want clicked or the things I don't want clicked?

As an example I have the following screenshot: http://i.imgur.com/6nkVY7b.png

The overlayCanvas has the pinkish square on the top in it and the button "Button" on the pink square. Nonetheless, the whole bloody canvas is clickable instead of just the button and the pink square. Which means that all interaction seized because the canvas is on a "topLayer" which has its own camera.

The Square+button in the overlayCanvas are on "topLayer" aswell.
But I just want the button and the pink square(and what's in it) clickable because the game is relying on clicks on the background image.


texts:
I'm trying to grasp the concept of normal mapping, but I'm confused by a few things. In short, I'm not sure whether a normal map is viewpoint dependent or not (i.e. whether you'll get a different normal map of the same object when you rotate around it). Secondly, I don't get why the blueish color is the predominant color in normal maps.

How I think about normals, and their relation to RGB colors, is as follows. The unit sphere represents any unit normal possible — in other words, the X, Y and Z components of a unit normal vector range from -1 to 1. The components of an RGB color all range from 0 to 255. Therefore, it makes sense to map -1 (normal component) to 0 (color component), 0 to 127 or 128, and 1 to 255. Any value in between is just linearly interpolated.

Applying this mapping to the normals of an arbitrary 3D object results in a very colorful picture, not at all predominantly blue. For example, when taking a cube, all six faces would have a different, but uniform, color. For instance, the face with the normal (1,0,0) would be (255,128,128), the face with the normal (0,0,-1) would be (128,128,0) and so on.

However, for some reason the normal maps of a cube I found are completely blueish, i.e. (128,128,255). But clearly, the normals are not all in the positive z-direction, i.e. (0,0,1). How does this work?

[Edit]

Ok, so the approach described above seems to be referred to as the object space normal map or the world space normal map. The other one is called the tangent space normal map. I understand how such a tangent space normal map can be used to modify the normals of a geometry, but I'm still not completely sure how it is actually calculated (see my comment at Nicol Bolas' answer).

[Edit 2]

I should probably mention that I'm working with piecewise parametric surfaces. These surfaces consist of a set of surface patches, where each patch is associated with its own parametric space (u,v) = [0,1] x [0,1]. At any point on the surface, the normal can be calculated exactly. Apparently, the vectors T (tangent) and B (bi-tangent) — required to span the tangent space — are not simply the partial derivatives of the surface patch in the direction of u and v...


texts: EventSystem first selected not highlighting

texts:
I'm trying to make a menu and encountered this problem.

protected static EventSystem eventSystem
{
    get { return GameObject.Find("EventSystem").GetComponent<EventSystem>(); }
}

public static void ButtonNavigation(List<GameObject> _listButton, int firstSelected)
{
    eventSystem.SetSelectedGameObject(_listButton[firstSelected]);
    print(eventSystem.currentSelectedGameObject);
}

But when I print out the currentSelectedGameobject it clearly says that "Status" is selected but how come it's not highlighted?

I've read some article on using Co-routines but is it really necessary?


texts:
my question is about save-games format.

Look at this screenshot:

On the left I made a "simple" fake savegame (Ini format) and on the right there is a "complex" TR2 save game.

I'm wondering how does the complex one work, and why.

I thought that it was made this way to prevent from cheating-editing values, and the format was just a "simple" save encrypted with a key (like aes does).

I'm sceptic though, I don't think every game has implemented an encryption algorithm to save some data. Maybe I miss something, or maybe it's done this way.

Do you have some informations about this ? Have you ever asked yourselves how does this works ?
Thanks, have a good day !


texts: Can a 3g network work for this project and is my understanding correct?

texts:
I want to make a game for the android phone using unity.  As you can tell by my last post i wanted to use networking to make this happen.  I decided unity would be a good choice and in no time i was able to have two android devices connect to a simple game using unity master server and i was able to see both of my cubes update in real time over both phones.

My end goal is to make a game where you are a sphere and your goal is to knock your friends off the the arena(A sumo game).  The arena will slowly get smaller until only 1 sphere is remaining.  My question revolves around how doable this would be with a 3g network over the phone.  It does not appear that unity3d has bluetooth support for android and i could not find a plugin for it anywhere.  This would be ideal to have bluetooth local networking and if i am incorrect, please tell me.

The way I understand cell phone data transmission is you have your cellphone and it sends the data to the cell tower.  The closer you are to the tower the better.  Does your relative position to one another(Two clients connecting ) matter if you are both in range of the same cell tower?  While my cubes updated just fine I know that 3g can be spotty.  Is 3g viable for this idea?  Is bluetooth usable for android with unity3d if not?

Thank you


texts: How to Further My Game Dev Studies Away from Technology?

texts:
I'm a college student, and I have a really boring class every Tuesday that's 2 hours and 45 minutes long. It's an interesting situation... attendance is required and checked, and electronic devices aren't allowed, but discussion isn't required and the lectures don't really matter to the exams. So I sit there in the back of the room either dozing off, doing Sudoku, doodling on my paper, pen-spinning, or trying to secretly use my phone without getting caught. I find myself wishing I could use the time productively.

Just like when one sits down with paper and crayons and can't think of anything to draw, I find myself wanting to do something to further my game development skills (e.g. work on the design of a game) but as I sit there with a pen and paper and the professor droning on, nothing comes to mind.

Help me get through this tedious class! What are some things I could think through or work on, or how can I figure out things to think/work on? Or even things I could print out in advance and read or solve during class. Remember the constraint is that I have no access to technology...

And I'm not sure a book would be appropriate. Though now that I think of it, I should probably just read game dev books from the library. Why didn't I think of that before? Anyway I still want to hear suggestions! What would you do with this time, if you were in this situation?


texts: Choosing size of frustum based on objects

texts:
I would like to show camera frames using OpenGL and rotate the frame in 3D. The frame is placed at (0,0,-frameDepth), and will rotate about the origin.

Should I decide the size of frustum based on the frame size, or decide the frame size based on frustum? I would like the frame to cover as much of the screen as possible (maintaining camera aspect ratio), and rotate about the center to say maxPitch, maxRoll amount.

Specifically which of the following make more sense?

    /* (frameWidth, frameHeight) is calculated based on */
    screenWidth = displaySurface.getWidth();
    screenHeight = displaySurface.getHeight();
    float screenAspect = screenWidth / screenHeight;

    float l = -screenAspect, r = screenAspect, t = 1.0f, b = -1.0f, near = 1.0f, far = 10;
    frameDepthZ = 5f;

    Matrix.frustumM(projectionMatrix, 0, l, r, b, t, near, far);

    frameWidth = (r - l) * frameDepthZ / near; // fill the width of screen
    frameHeight = frameWidth / inputCamera.getCameraAspect(); // assign height based on above width and camera aspect

Or,

    /* frustum parameters are calculated based on (frameWidth, frameHeight)*/
    screenWidth = displaySurface.getWidth();
    screenHeight = displaySurface.getHeight();
    float screenAspect = screenWidth / screenHeight;

    frameWidth = inputCamera.getWidth();
    frameHeight = inputCamera.getHeight();

    float l = -frameWidth/2, r = frameWidth/2, t = r / screenAspect, b = l / screenAspect, near = 1.0f, far = 10;
    /*the above values don't work, and I can't figure out how to get my frame to fit to the screen. But hypothetically, if these were right, is this the right way to go about it?*/
    frameDepthZ = 5f;

    Matrix.frustumM(projectionMatrix, 0, l, r, b, t, near, far);

Image of Camera frame rendered to screen using method 1


texts: How to tell which face of a cube is most visible to the camera?

texts:
Imagine a camera that shows a randomly rotated cube at an arbitrary position: The cube's pivot is in the center of the cube. This way its six faces could be referred as positive/negative X, Y or Z.
How can you tell which of the faces is most visible to the camera? What's the math to calculate this?
Your help is very much appreciated.
Thank you!


texts:
Im working on a multiplatform (Pc,Mac,Linux) game that uses shaders quite extensively. Since we do not have any funding, it is pretty hard to test our game on all possible hardware configurations.

While our engine seems to run fine on different platforms, its usually the slight differences in GLSL compiling that gives us headaches. We have things set up such that we can test the shaders on Ati/Nvidia cards, but since the new Macbooks have Intel graphics, I'm really looking for a tool that can simply validate my GLSL shaders for different hardware without the need of yet another system.

Does anyone know such a tool?


texts: Move camera closer (Zoom In-Out) to object that is being followed (Unity)

texts:
I have implemented a main camera that follows and orbits around an object (player). Now I would like to implement a Zoom In-Out mechanic. This functionality would allows the camera to approach the object that is being followed (lookAt()). Zooming in and out would be done by using the mouse scroll wheel. This is my code.

    public Transform PlayerTransform;
    private UnityEngine.Vector3 _cameraOffset;
    [Range(0.01f, 1.0f)]
    public float smoothFactor = 0.5f;

    void Start()
        {
            _cameraOffset = transform.position - PlayerTransform.position;
        }
    void Update()
        {
            UnityEngine.Vector3 newPos = PlayerTransform.position + _cameraOffset;
                    transform.position = UnityEngine.Vector3.Slerp(transform.position, newPos, smoothFactor);

            if (Input.GetMouseButton(0))
                        {
                            UnityEngine.Quaternion camTurnAngle =
                                Quaternion.AngleAxis(Input.GetAxis("Mouse X") * rotSpeed, Vector3.up);
                            _cameraOffset = camTurnAngle * _cameraOffset;
                            transform.LookAt(PlayerTransform);
                        }

        }

The code should also limit how close and far away from the player can the camera move. Thank you for considering my question.


texts:
I'm learning OpenGL from arcsynthesis and I don't understand something about perspective projection (http://www.arcsynthesis.org/gltut/Positioning/Tut04%20Perspective%20Projection.html).

When the author gives the example "2D to 1D Perspective Projection Diagram", is R a 2D point or a scalar? When I saw the figure I thought it was a scalar because of the title and I thought that P is projected in a line (the Projection Plan). But later, when I saw the perspective computation, I realized that R has the same number of coordinates of P, because, from that equation, R is a product of the vector P with a scalar, so basically, I don't understand how many coordinates has R.

I don't know where that equation (the perspective computation) comes from, if someone could just give me some information about it I would appreciate it.


texts:
How is it possible (with the standard Java2D engine) to use small sprites like graphic objects?

For those who don't know what I mean, in all those Flash-games like on Facebook they put small sprites on the screen which react to mouse-over and clicks. I tried to do the same in Java but can't find a good method. Swing components always spread over the whole bitmap, but I only want to get a reaction from the object when the mouse is over a pixel that's not transparent.

So basically checking every time if the object below the mouse contains a non-transparent pixel (which i believe could be pretty intense in a gameloop or repaint loop). I have no idea how to implement such a thing efficiently.


texts: Deferred lighting and point light volumes

texts:
I'm doing deferred point light shadow mapping and I am drawing my point lights using light volumes. Normally I access the position/diffuse texture/normals using this in the fragment shaders:

vec2 texcoord = gl_FragCoord.xy / UnifPointLightPass.mScreenSize;

vec3 worldPos = texture(unifPositionTexture, texcoord).xyz;
vec3 normal   = texture(unifNormalTexture, texcoord).xyz;
vec3 diffuse  = texture(unifDiffuseTexture, texcoord).xyz;

When doing directional lights, I just draw a fullscreen-rectangle, but when doing point lights I use light volumes - drawing a 3d sphere from the cameras point of view to limit the amount of fragments processed.

Does light volumes change the way I get the texcoord?


texts:
A friend and I are writing a topdown RPG called NecroMonster. In the game when you defeat an enemy you can take its shape (basically morph into it) and we don't know how to make this look right.

How can I create a morph animation between several 2D sprite sets that are relatively simple and will look the part?


texts: JUst wondering the term pn triangles is the same thing as saying bezier triangle patch??/


texts: XNA: How to make particles face the camera but not alter the pitch

texts:
I'm using the particles sample from create.msdn.com/en-US/education/catalog/sample/particle_3d which by default, has all the particles look straight at the camera.  I'm trying to modify it so that the particles will still look at the camera but won't rotate up and down.  I think these are called billboard particles but I'm not really sure.

Edit:

This is what I have in the shader now.  It seems like its working but the particles are really tiny.  What did I do wrong?

float4x4 billboardRotation = CreateConstrainedBillboard(output.Position, CameraPosition, float3(0, 1, 0));

output.Position.xy += mul(input.Corner, rotation);
output.Position = mul(output.Position, billboardRotation);
output.Position = mul(mul(output.Position, View), Projection);
output.Position.xy += size * ViewportScale;


texts:
I have a car game and the idea is that the player is drunk. I want to have a delayed input from the mouse, where you move the mouse side to side to turn.

How can I setup a constant delay between the input the user gives and the turn amount of the car?

Right now I have this:

h = Mathf.Lerp(h, (((Input.mousePosition.x / Screen.width) * 2) - 1), Time.deltaTime * 2);

What happens is the turn is delayed, but is very slow, in other words, if I move the mouse very fast, the car turns very slowly, but if I crank up the multiplier for Time.deltaTime, the car turns faster, but delay effect is minimized.

How else could I do this?


texts: I have such situation in my GDX game: I have a static class that manage my Drawables. It's a Singleton. I want to load all my Textures to it in order not to load them at every turn when I switch between screens (I know this is bad practice but I need this). I pack my resources into a TextureAtlas and load them. But when I pack and load more then some amount of Textures and try to use them some of them become black. Why this is happens? How can I bypass this unfortunate case. The size of my TextureAtlas (four images and one .txt file) is about 4MB.


texts: Who owns the intellectual property to Fragile Allegiance?

texts:
Fragile Allegiance was developed by Gremlin Interactive, which was later acquired by Infogrames (Atari). I couldn't find any details of the acquisition though.

The only interesting thing I have found online is that the owner of the registered trademark Fragile Allegiance is Interplay, who published Fragile Allegiance. However, the only copyright note I've found was in one installation .ini file, claiming it for Gremlin.

What are the common business practices when it comes to old, unused IPs? What do publishers/developers actually need to legally claim an intellectual property? Does anyone have an experience with contacting big publishers with copyright/IP inquiries?

Related legal question.


texts: With GGPO rollback netcode, how many times might I need to update my game engine in one frame?

texts:
I'm working on a game that's going to use GGPO for rollback netcode. I understand the need for a deterministic engine whose state can be saved, restored, advanced from user inputs, etc. I understand that I may need to do this several times in a frame, and that therefore, from a performance point of view, updating the game engine needs to be fast enough to be called more than once in a frame.
My question is.... how many updates in a frame do I realistically need to budget for? If I can identify a realistic worst case, I'll simply run my game engine that many times a frame while I'm developing it.


texts: How to implement Fog Of War with an shader?

texts:
Okay, I'm creating a RTS game and want to implement an AgeOfEmpires-like Fog Of War(FOW).
That means a tile(or pixel) can be:

0% transparent (unexplored)
50% transparent black (explored but not in viewrange)
100% transparent(explored and in viewrange)

RTS means I'll have many explorers (NPCs, buildings, ...). Okay, so I have an 2d array of bytes byte[,] explored. The byte value correlates the transparency.

The question is, how do I pass this array to my shader? Well I think it is not possible to pass an entire array. So: what technique shall I use to let my shader know if a pixel/tile is visible or not?


texts: Shifting values or tiles on a 2D grid (1D array)

texts:
I recently turned my practice project into a match3-type game.

The game uses a 6x10 grid, internally stored into a single array, with each item being a positive integer (0-based). I have a function to detect groups of the same type of a given size, but once the group has been deleted, the tiles above need to be shifted down.

The unordered index of each deleted tile is also stored into a separate array.

The language I'm working with is Linden Scripting Language (LSL), although language-specific answers aren't needed (but very helpful), so even general examples are welcome.

Edit: My recursive function so far:

shift(integer i) // i == index of Grid, COLS == columns/width (6)
{
    if( (integer)grid[i] != -1 ) return; // blocked by deleted value

    Grid[i] = (integer)Grid[i-COLS]; // copy value from above

    if(i >= COLS) // haven't reached upper limit of grid
    {
        shift(i-COLS); // recursive call up
    }
    else
    {
        Grid[i] = (integer)llFrand(TYPES); // reached top, randomize tile
                                           // TYPES == integer, maximum amount of types
    }
}

Improvements needed:

Don't copy deleted values from above (skip over)
Stop recursing early if multiple values were deleted vertically
Move horizontally and find the lowest point to begin recursing from

Limitations of the environment:

Limited to 64KB of memory (bytecode + stack/heap)
Each call may potentially use 512 bytes of stack


texts:
Right now I am not using any depth information in my engine, but I just found out that it would be neat to be able to render the silhouette of important game objects that are "behind" something with a shader, though I am quite at a loss how to do this in a 2D scene with little to no depth information. I will propably have to use depth information for something like that, but I am not quite sure how.

I guess the abstract concept would be:

zn = depth of pixel that should be rendered
zc = depth of pixel at current position in some sort of buffer
if(zn < zc)
    render pixel with a "silhouette" color
else
    render pixel with it's intended color

Is this a proof of concept I can follow in my next few workhours?
How can I use and access stuff like the Z buffer of the current framebuffer in the shader?

As an example, I most recently saw this in Titan Souls:

Also remember that I am thinking 2D only, so application of the painter's algorithm might or might not be desirable.

EDIT: So right now, from comments and such, I got the following proof of concept:

activate stencil mechanism to set stencil
render obscuing objects
deactivate stencil
render scene, using painter's algorithm or depth checks to obscure
activate stencil mechanism to check weather or not something got rendered within the stencil area
render important objects again, using a different fragment shader to render pixels within the stencil as a dark shadow

amirite?


texts: Why did an Android update disable  the textures in my game?

texts: I recently updated my tablet to Android 4.0.3 and now the textures for my game do not show up. I'm using OpenGL-ES 2.0 for my engine. It worked fine when I was running android 3.0.  Is there any reason as to why this is happening?


texts: Libgdx screen keeping text on screen from main Game class

texts:
In my libGDX app I have some text running on the main Game class, and when I switch to a different screen the text is still there? Can anyone explain this please.
Also in my main class it is changing screens to a splash screen then to the screen I mentioned earlier. But the splash screen doesn't have the text on the top.


texts: Changing the object material without clicking on it

texts: How can I change the object material automatically without clicking on it?  The object material should change based on a timer.


texts: How do you gather and collate information you need to make a post-mortem?

texts:
After the game is done (either shipped or the project was canned), what is the best way  to make the post mortem, so that it maximizes the chances to never make the same mistakes again?

How do you gather all the needed informations from the team?
How do you condense them in the final postmortem?
How do you avoid to make the same mistakes in the following project?


texts: How to get used Resources by State/Map etc?

texts:
I'm now managing the Loading of my Resources and I got a Question in my mind.

How does my Resource Manager know which Sprites,Sounds, etc. are used by the Map I want to load?
First I thought of files which contain a list of used Sprites, Sounds etc. for every Map.
E.g. like this

Map0001.map //Map Data
Map0001.sfx //List of Sounds
Map0001.gfx //List of Sprites
Map0001.tle //Tileset

This makes x4 more files than maps and I'm not sure if this is efficient, since every File has to be loaded and it's content read separately.

Any Idea on how to do this properly?


texts: Whats a good setup/toolchain for a project?

texts:
I was thinking, what is needed for a good setup and what are good (free) tools to use? Some of what i came up with are

Bug tracking
Some good (distributed:P) source control (which means no svn fellas)
automated nightly builds or a continuous integration (or anything that automates builds and possibly sends emails when there are build errors)
wiki to document decisions, road map or milestones.
Something to backup assets (art, sound, etc)

What else? and do you have suggestions for any of the above? i pretty much clueless of all of these except for source control


texts: How to make an Alert Dialog "Rate my game" for my game

texts: I wonder if anyone can help me on how to make an alert dialog which makes user rate the game from inside the game itself or taking the user to google play to rate. Please help. I'm using andengine.


texts: How do I make a character follow behind another?

texts:
I'm creating a game in C++ using OpenGL. I want to add a character into my game who, after meeting the main player, follows the player around. The follower should position themselves directly behind the player, moving when the player does to stay in the correct position:

How can I accomplish this?


texts: Skipping glReadPixels and reading iPhone's "VRAM" directly

texts:
I'd like to rapidly capture "screenshots" of my OpenGL ES iPhone game and turn them into a video.  I've tried the following approach (it works but degrades the game play to an unacceptable level):

Use glReadPixels to copy the data from the framebuffer to a GLubyte array.  Create a CGImageRef from that data.  Then create a CVPixelBuffer from the CGImageRef.  Finally append the CVPixelBuffer to an AVAssetWriter.

I've done a fair amount of additional research.  Some people suggest copying the framebuffer and reading that piecewise with glReadPixels.  This could work... but I don't know how to copy a framebuffer. (any help is appreciated!)

I just learned that the iPhone's "VRAM" is really part of the main memory.  How can I read the contents of a framebuffer from "VRAM" without calling glReadPixels?

Hopefully this approach (or similar) will keep the frame rate of the game acceptable.


texts: Need help accessing booleans from other script Unity3D

texts:
I'm making an endless runner game where platforms move towards the player so it makes it seem like the player is running across them. I'm trying to make it so that when the player dies, the platforms stop moving. What I have isn't working, when the player dies, the platforms just keep moving as if nothing has happened. Here is the script I have that is attached to the player:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;

 public class CoinColliderScript : MonoBehaviour
 {
     void OnTriggerEnter(Collider target)
     {
         if (target.tag == "Enemy")
         {
         StartCoroutine(Died());
         }
     }

     IEnumerator Died()
     {
         PlatformMover.dead = true;
         gameObject.GetComponentInParent<Animator>().Play("Male Died");
         yield return new WaitForSeconds(0.5f);
         SceneManager.LoadScene("MainMenu");
     }
 }

Here is the script I have that is attached to the platforms:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlatformMover : MonoBehaviour
{
    private Vector3 newPlatPos;

    public float platMoveSpeed;

    public static bool dead;

    public void Start()
    {
        dead = false;
    }

    void Update()
    {
        if (dead)
        {
            newPlatPos = new Vector3(transform.position.x, transform.position.y, transform.position.z);
        } else if (!dead)
        {
            newPlatPos = new Vector3(transform.position.x, transform.position.y, transform.position.z - platMoveSpeed);
        }
        transform.position = newPlatPos;
    }
}

New Code:
Attached to platforms:
public class PlatformMover : MonoBehaviour
{
    private Vector3 newPlatPos;

    public float platMoveSpeed;

    void Update()
    {
        if (!CoinColliderScript.Dead)
        {
            newPlatPos = new Vector3(transform.position.x, transform.position.y, transform.position.z - platMoveSpeed * Time.deltaTime);
        }
        transform.position = newPlatPos;
    }
}

Attach to player:
public class CoinColliderScript : MonoBehaviour
{
    private static bool dead = false;
    public static bool Dead
    {
        get => dead;
        set
        {
            dead = value;
            print("'Dead' changed to " + value);
        }
    }

    void OnTriggerEnter(Collider target)
    {
        if (target.tag == "Enemy")
        {
            StartCoroutine(Died());

        }
    }

    IEnumerator Died()
    {
        dead = true;
        gameObject.GetComponentInParent<Animator>().Play("Male Died");
        yield return new WaitForSeconds(0.5f);
        SceneManager.LoadScene("MainMenu");
    }
}


texts: Calculating transform of arrow model pointing at some point in 3D space

texts:
I'm working on a 3D flight game and I'd like to implement a simple "navigation arrow" pointing at the next waypoint in world which the player has to fly to.

I have position of both airplane (=camera) and the target and also orientation of the airplane (in form of quaternion). But sadly I can't figure out correct way to use them to get the arrow pointing at the target regardless the airplane yaw/pitch/roll.

The arrow was already working once, but only when the airplane was in horizontal orientation. But when the airplane was tilted, the tilt was not reflected in the arrow transform.

Here's my code (it might not be accurate, as I'm desperately trying anything that could help) to get the arrow rotation

Vector3 target = ...;
target.subtract(airplane.position);
target.normalize();

Vector3 dir = new Vector3(0, 0, -1); // initial airplane direction
dir.rotateBy(airplaneQuat); // current airplane direction

double angle = Math.acos(target.dot(dir));
Vector3 axis = target.cross(dir);

I think my problem is the fact that the airplane can fly upside down and in other riddiculous orientations, and I just cannot visualize all the transforms in my head.
I'll be happy for any help.

UPDATE:
Based on Cong's answer I came up with working solution. Here's the pseudocode. It could be improved, but the arrow behaves sufficiently accurate by now, just the way I indended.

Vector3 dir = target.position;
dir.subtract(airplane.position);
dir.normalize();

Quaternion q = airplane.orientation;
q = q.conjugate();
dir.rotateBy(q);

Vector3 up = Vector3(0, 1, 0);
Matrix4 mat = Matrix4.createLookAt(dir, up);

Matrix4 transform = Matrix4(); // identity
transform.translate(0, -0.85, 0); // move to the bottom of the screen
transform.mul(mat);
transform.scale(0.2); // just scaling the model


texts: Textures "don't work" when I don't specify any texture parameters. Is this a driver bug or intended behavior?

texts:
Whenever I try to use textures, I have to at least specify the sample filtering parameters (GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER) for textures to work at all. If I don't, sampling the textures in a shader will usually just return a value of 0 for all texels in the texture, even though glReadPixels return the correct values, and rendering to the textures actually works. Debugging tools like Nsight and gDebugger confirm this.

I tested this on two NVIDIA GPUs (GTX 970, GT 555m) with the latest driver versions (347.09), and the behavior is the same.

However, I can't find any reference to this in docs like this or this

I assumed that not specifying these parameters just made them take on their default values. So is this actually intended standard behavior (probably meaning "undefined behavior") or can I assume this is a driver bug?


texts:
I already found this question, but it only talks about the kind of software used - not the actual methods. Were they drawn at a high resolution first and then shrunk down? Or did you just zoom way in? Do you do a vague outline first, then make it more detailed? How was the coloring done? And when you have to do long animations, do you hand draw each frame, or are there tools to help automate the process? Or do you just copy paste the basic sprite and only change the moving parts?

Etc.


texts:
I would like to change a camera's rotation and position from its current position and rotation to a destination position and rotation.

This should happen within a specific time (seconds).

I call this void "pRotateAndPosition" in each Public void Update().

However, I'm having trouble getting the 3rd argument for Lerp (time) correct.

Could anybody tell me where my mistake(s) are?

Thank you.

private void pRotateAndPosition()
{
    _TimeElapsed += (Time.deltaTime / TimeInSecondsInWhichWeWantToGetToFinalRotationAndPosition);

    if (_TimeElapsed >= TimeInSecondsInWhichWeWantToGetToFinalRotationAndPosition)
    {
        _StopCallingThisVoid = true;//don't call this anymore

        //set the final position and rotation in case we're not completely there yet
        _camera.transform.localRotation = Quaternion.Euler(goalRotation);
        _camera.transform.localPosition = goalPosition;
        return;
    }

    float fTime = _TimeElapsed;//absolutely not sure about this one

    _camera.transform.localRotation = Quaternion.Lerp(_camera.transform.localRotation, Quaternion.Euler(goalRotation), fTime);
    _camera.transform.localPosition = Vector3.Lerp(_camera.transform.localPosition, goalPosition, fTime);
}


texts: Unity: How to manage a large amount of prefab variations?

texts:
The project that I'm working on demands the ability for game designers to be very flexible when balancing, customizing items, etc. The most difficult requirement to meet at the moment is that they want to drag-drop, say, a weapon prefab onto a weapon field in some game entity component and from there be able to tweak the prefab's parameters. If I provide some tools that create derived prefabs at such moments, then we'll end up with possibly hundreds of pretty much same prefab variations and also loose the ability to edit the initial prefab and transfer the changes to derivatives.

What I'm starting to consider is introducing a "Data Map" structure in every entity that requires high level of parameter customization. Every parameter would be set through methods like Set/GetFloat("key", "value"), Set/GetFloatArray, Set/GetInt, etc. So basically a dictionary that maps a string to a predefined set of data types. When a prefab of such entity would be drag-dropped into a field of another component, an editor tool would separate the "Data Map" from the prefab, allow the game designer to tweak the values of the keys and eventually serialize it to json. During runtime uppon instantiation of a prefab with a "Data Map" a manager would check the deserialized overrides and override the "Data Map" with the tweaked values if needed.

Though to me this sounds overly complicated and maybe some of you had a similar situation and came up with a simple solution? Maybe it's worth trying the ECS approach? Thanks.

An example: Let's say there are prefabs: Axe, Sword, Bow with a bunch of parameters configured, say Damage, Durability, etc. There are many other components that can accept a weapon prefab and once it's dropped, the designers want to have "on the spot editing" say, okay, for this situation here the Axe prefab needs to be a little different and have Damage+3. Creating a new prefab means that the link to the initial Axe prefab is lost and there are now two Axe prefabs that need to be managed - this is the problem we're trying to address.


texts:
I'm writing a simple geometry shader to create 3D "primitives" in place of a single point. I am performing all of the world-view-projection conversions within the geometry shader after creating the triangle strips to form the 3D primitive. Unfortunately, it seems to be creating the triangles in projection space, and giving me incorrect results. The following pictures demonstrate this problem. Any advice on how to work around this problem?

As can be seen here, the second top face seems to be rendered as if it was pulled off the top and splayed out.

Here is the geometry shader I am using, and a set of coordinates I use to generate these faces

static float3 cube_coords[8] =
{

float3(1, -1, 1),
float3(-1, -1, 1),
float3(1, 1, 1),
float3(-1, 1, 1),

float3(1, 1, 1),
float3(-1, 1, 1),
float3(1, 1, -1),
float3(-1, 1, -1),

};

[maxvertexcount(8)]
void GSMain(point GSInput input[1], inout TriangleStream< GSOutput > output)
{
GSOutput p;

for(unsigned int j = 0; j < 2; j++)
{
    for(unsigned int i = 0; i < 4; i++)
    {
        p.Pos = input[0].Pos;
        p.Pos += float4(cube_coords[i + (4*j)],1.0);
        p.Pos = mul(p.Pos, worldViewProjection);
        p.Color = input[0].Color;
        p.Light = input[0].Light;
        p.Norm = normals[j];
        output.Append(p);
    }
    output.RestartStrip();
}
}


texts: Blend multiple regions from same texture atlas

texts:
I'm representing terrain in my game as a grid with at each node a composition, for example 100% rock, or 50% grass, 50% soil. I'd like to use this composition vector to blend textures together. I'm using a single texture atlas which contains all my terrain textures.

I've tried various ideas but I always seem to stumble on the rasterization part of the pipeline, because the interpolation does not work correctly between coordinates across the texture atlas.

What is the recommended way to accomplish this?


texts: How should I manage my data that needs to be associated with rank (Unity)

texts:
So I am making a game with a similar content progression to Clash Royale. Essentially u have ranking points (Identified as Trophies), and the number of trophies you have will determine what content you will have access to in the game. So for example every 100 ranking points, you will be able to find new types of cards in chests, new chests in general or new maps. In my game, I want it to be somewhat similar, but I also have some other data that changes based on rank points that is more specific to my game, such as army supply. I'm trying to figure out how I can implement this in a manageable way.
Maybe this is overkill, but this is my design so far:

Basically I have my RankContentItemBase class which has a ranking points int and an IsUnlocked method that returns whether or not the passed in rank is > than the rank passed in. Then I extend this with classes with classes that add the data type I wanna work with (Int, Troop, Map, w/e).
I then have a Generic base container class that has a method for getting all unlocked item in the list of T contents that is extended to contain the concrete RankUnlockItembase types.
I've basically structured things this way so it's easy for me to add new types of items that I want unlocked by rank without having to do much work. Also it prevents things from being coupled together.
Just curious what ppl think of this setup, and what kinda setup you would go with? One concern I have with this design was that if I wanted to see whether a troop was unlocked or not, I can't just say troop.IsUnlocked(). Instead I have to create a new means of determining whether or not a troop is unlocked yet, like for example maybe a method on the RankUnlockedTroopContainer that determines this. Maybe this is ok? I feel like I'm sacrificing simplicity for the sake of maintainability/flexibility.
Thanks


texts:
So I'm creating a system of caves below my random terrain generation, and I'm using 2D Simplex Noise to do so and I have a pretty good grasp on generating the random caves.  However, the cutoff from the terrain to where the cave layer starts is a bit abrupt, and I was wondering how I could prevent this.

Random Level Generation:

public static Level GetRandomLevel(int rows, int cols, float scale = 1f)
{
    Tile[][] tiles = new Tile[rows][];
    for (int i = 0; i < rows; i++)
    {
        tiles[i] = new Tile[cols];
        for (int x = 0; x < cols; x++)
        {
            tiles[i][x] = new Tile(0, new Vector2(x, i), scale);
        }
    }
    int left = Main.rand.Next(rows / 4, rows / 2);

    double seed = Main.rand.NextDouble() * 255;
    for (int i = 0; i < cols; i++)
    {
        float noise = Noise.Generate((float)seed);
        noise *= 7;
        int height = left + (int)noise;
        height = (int)MathHelper.Clamp(height, 0, rows - 1);
        tiles[height][i] = new Tile(2, new Vector2(i, height), scale);
        FillLower(tiles, height, i, scale);
        seed += .05f;
    }

    int[] heightmap = new int[cols];
    for (int i = 0; i < cols; i ++)
    {
        for (int j = 0; j < rows; j++)
        {
            if (tiles[j][i].TileID == 2)
            {
                heightmap[i] = j;
                break;
            }
        }
    }

    //Smoothing out terrain
    for (int i = 0; i < cols - 1; i++)
    {
        if (heightmap[i] > heightmap[i + 1])
        {
            tiles[heightmap[i] - 1][i] = new Tile(6, new Vector2(i, heightmap[i] - 1), scale);
            tiles[heightmap[i]][i] = new Tile(3, new Vector2(i, heightmap[i]), scale);
        }
    }
    for (int i = cols - 1; i > 0; i--)
    {
        if (heightmap[i] > heightmap[i - 1])
        {
            tiles[heightmap[i] - 1][i] = new Tile(5, new Vector2(i, heightmap[i] - 1), scale);
            tiles[heightmap[i]][i] = new Tile(4, new Vector2(i, heightmap[i]), scale);
        }
    }

    //Caves
    for (int y = 0; y < rows && left + 10 + y < rows; y++)
    {
        for (int x = 0; x < cols; x++)
        {
            double noise = Noise.Generate(x / (70 * scale), (y + 1) / (70 * scale));
            //Not air
            if (tiles[left + 10 + y][x].TileID != 0 && noise > 0)
            {
                tiles[left + 10 + y][x] = new Tile(0, new Vector2(x, left + 10 + y), scale);
            }

        }
    }

    return new Level(tiles);
}

Here is a picture demonstrating what I mean about the 'cave layer cutoff' being to abrupt.


texts:
I am trying to make a fighting game where two characters are fighting with hands or can have some weapon in their hands. It's a multiplayer game targeting initially for mobile devices. In Game, there would be some animation and when that weapon hit other character body, its health will decrease.

I have two different updates implemented. One is Fixed update which calls after every 100ms and all game logic is implemented there and other update is for drawing, running at 60 fps. Now when two players are fighting and one player is animating to hit other, I need to show others player's decrease of health at the time of hit. Now as drawing update is different, I got a hit event in an update but When should I have to decrease the health?

As my all game logic is running in fixed update, I am updating characters health in fixed update and decide whether it's still alive or dead but due to this, on screen, it shows some delay in decreasing health. I want to know am I doing something wrong? What is the standard way to achieve this?

Thanks


texts:
This is my sprite sheet, when I select the frames and drag them into the scene view to create the animation, it just creates an animation with the selected frames in sequence and I can't figure out how to change that sequence.
If we numbered the frames from left to right and top to botom, I'd need the sequence to be: 2-3-5-2-4-6- and loop.

I can just repeat the frames in the intended sequence, but there must be a smarter way to do this.


texts: 3D space indexing for nearest neighbor searching

texts:
I am developing a CAD-like application where the user can draw (digitize) new geometries (points, polylines & polygons). While digitizing, I want the user to be able to (optionally) snap the points of the new shape onto points or lines of existing geometries. I have already written the snapping algorithm that computes a ray from the mouse position and finds a line segment between the ray and the closest geometry (point or line segment). My scene is totally static but may contain too many shapes, which makes brute force searching inefficient.

What would be a good way to index the existing geometries so that I could quickly filter most of them out and consider a smaller set (the ones roughly within distance X) in my snapping algorithm?

I was thinking of doing something similar to what OpenGL (I am using DirectX 9 in my app) provides with the GL_SELECT option, i.e. render my geometries on a bitmap, each one coded with a different color. However I am a bit worried since I will have to use a second device with a hidden window to achieve this.

Is there a 3D space partitioning data structure that I can use, which can efficiently compute the nearest neighbour to a ray?


texts: How can I get animated bone's transformation in LibGDX?

texts:
I am trying to get transformation from a bone, but i can't, I exported just a animated armature with just a bone from blender, then I converted to .g3dj, so I just need the bone transformations so that I can get it value for some effects like moving sprites and other things.

any ways to read just transformation in "render()" method, seems bones animation does not effect on bone's value!
I want to use just openGL ES 1.x.


texts: How can I tell how much video card memory I'm using?

texts:
I want to programmatically determine at runtime how much video card memory is being used by my program.  Specifically I'm wondering about how to do it on a Windows machine using OpenGL, but am interested of ways to do it on other platforms as well.

I know there are utilities out there that will show me the memory usage as my program is running, but I want to be able to query that information from my code.


texts: How do 3D games create the illusion of depth?

texts:
How do libraries like OpenGL convert three dimensional coordinates into the two dimensional pixels we see on our screens? I'm not talking about the 3DS or games that require 3D glasses, but rather the illusion of three dimensions.

I don't need any code to create this effect - I'm just curious about the concept.


texts: XNA 4.0 - Strange Behavior when using RenderTarget2D

texts:
My Problem is similar to XNA 4.0 - Why does using a RenderTarget2d cause transparency on models?.

I want to render my scene to a Texture2D and then draw the texture.
If I set no RenderTarget at all (render directly to the back buffer), everything looks fine.

I draw my models/textures with:

graphics.GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.Opaque, SamplerState.AnisotropicClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise);

[...Drawing methods for models etc. are called here...]

spriteBatch.End();

If I change that code to:

RenderTarget2D target = new RenderTarget2D(this.GraphicsDevice,this.GraphicsDevice.PresentationParameters.BackBufferWidth,this.GraphicsDevice.PresentationParameters.BackBufferHeight);
this.GraphicsDevice.SetRenderTarget(target);

graphics.GraphicsDevice.Clear(Color.Black);

spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.Opaque, SamplerState.AnisotropicClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise);

[...Drawing methods for models etc. are called here...]

spriteBatch.End();
this.GraphicsDevice.SetRenderTarget(null);

And render the texture / save it as an image-file, some objects get transparent and the drawing order changes sort of randomly.


texts:
I am creating a 'Minecraft clone' and the game is going to be only multiplayer. I currently have a limited world (it's not going to be infinite) that is 512 chunks.

Each chunk is 16(X) * 16(Z) * 128(Y) of blocks.

Each block is represented by a byte. This means I have a 3D array of bytes that represents which block is in which position in the chunk (0 means Air). I got to the part where I want to send the world though the TCP connection.

I am using KryoNet for my multiplayer needs. Currently what I do is I flatten the 3D array to the highest Y coordinate that is not air, making my (16 * 16 * 128) array into a (16 * 16 * less than 128) array. After doing this I take the 3D array and flatten it into a 1D array. After doing that I have a 1D array of size ~32,000. Obviously sending the entire 32KB of data through the connection at once is stupid and it also crashes KryoNet.

My question is how would I efficiently go about sending 512 chunks (512*32 KB of data) through the connection?

I thought about separating the 1D array (32,000 bytes) into 32 packets each of 1KB of data but it seems odd to send 512 * 32 packets to send the world (~16,000 packets).
Is there any way to compress this data or send it in a more efficient way through my TCP connection? Obviously this is done once per session but still 16,000 seems a lot.

Progress update:

I have separated the chunks into 33 packets each, and I send them one after the other. It seems to be working well, but I have a slight ordering issue that is unrelated. At the times that it works it loads quite quickly and with no problem! If there is a more efficient way of going about this please do post it here!


texts: Real-time multiplayer game server development

texts:
I'm an Android developer, and I want to start developing a real-time multiplayer game, like Pocket Legends.

Would this type of server be good for a real-time multiplayer action game - http://systembash.com/content/a-simple-java-udp-server-and-udp-client/?

I'm absolutly new to server development, so it would be great if you explaind even more about this stuff ...


texts: Multiple render targets and pixel shader outputs terminology

texts:
I'm a little confused on the jargon: does Multiple Render Targets (MRT) refer to outputting from a pixel shader to multiple elements in a struct? That is, when one says "MRT is to write to multiple textures", are multiple elements interleaved in a single output texture, or do you specify multiple discrete output textures?

By the way, from what I understand, at least for DX9, all the elements of this struct need to be of the same size. Does this restriction still apply to DX11?


texts: What are the downsides of only explicitly informing the player of *success*?

texts:
I'm working on educational software and trying to increase Engagement ("fun").

Clear Progress toward a Goal (one of the tenets of Engagement) would suggest we need to let the player know how they are doing. But we don't want the player to become demoralized. (These "players" have brain injuries, and so can become very demoralized easily.)

So I'm thinking that we'll want to only explicitly show forward progress ("You 'leveled up'"), but we wouldn't have "lives" (because you can "lose" them).

Clarification:

Think of this as Education "Tutoring" Software (sort of like the Kahn Academy)
We already give them feedback when they get an answer wrong. We also help them get the right answer.

But when they do very well they Graduate to a higher level. If they do very well for a long time they get some sort of award/recognition that they are doing exceptionally well.

What I'm wondering is if they have a sustained period of poor performance, should we also give them recognition (obviously something kinder than "Hey, you suck"), so that this "failure recognition" doesn't really give them more information?

This is the roman emperor giving a thumbs down (the Gladiator already knows how he did in the battle).

Any downsides to that?
(I guess one might be that they lose faith in feedback from the game because it's not telling the whole story. Sort of like if a parent only gives you praise, you might start to think they're saying it to be nice.)


texts:
I want to implement a particle system in my game, but I've never programmed a particle system and don't know where to start.

I only want to display pixels (GL_POINTs) with different sizes in different places, something like Terraria or Minecraft when you hit a block, without the texture.  Just a dead simple example.

Google search results for this tend to be very complex, or don't explain the concepts, or are written in hard-to-read C without OOP…

I'm using Java and OpenGL.