texts: How can I improve this enemy database implementation?

texts:
I'm developing an RPG and I'm at the point where I need to start building an enemy database. There's a couple challenges associated with this and a few solutions I've been considering.

Here's what I need to do in my enemy database:

I have two primary enemy classes I need to represent data about:

A base enemy class that includes the follow:

Base Stats
Status Resistance Table
Elemental Resistance Table
Steal Table
Drop Table
Level
Unique ID
Base XP
AI Hook
Name
Display Name

And a derived class that adds the ability to add equipment, adding the following fields:

Main Weapon
Secondary Weapon/Equipment
Armor
Accessories

I may add additional fields or additional classes in the future if it makes sense. I've considered two possible formats to database enemies.

XML Files

I'd basically do it like this:

<?xml version="1.0" encoding="utf-8"?>
<Enemies>
  <Enemy name="Red Dragon" type="BaseEnemy" level="56" displayname="Red Dragon">
    <Stats HP="55000" MP="2500" SP="2500" Strength="212" Vitality="125" Magic="200" Spirit="162" Skill="111" Speed="109" Evasion="100" MgEvasion="100" Accuracy="100" Luck="55"/>
    <StatusResistances>
      <Resistance name="Sleep" value="100" />
      <Resistance name="Stop" value="100" />
    </StatusResistances>
    <ElementResistances>
      <Resistance name="Fire" value="75" />
    </ElementResistances>
    <LootTable>
      <Item name="Elixir" rate="0.03" count="1"/>
    </LootTable>
    <DropTable>
      <Item name="Elixir" rate="0.03" count="1"/>
    </DropTable>
    <AIScript value="BasicBehaviour.py" />
    <BaseXP value="4800"/>
  </Enemy>
  <Enemy name="Gaverick 1" type="HumanoidEnemy" level="33" displayname="Gaverick">
  <!--Same Stuff as above here-->
    <Equipment>
      <Weapon name="Dark Eclipse"/>
      <Armor name="Terra Defense"/>
      <Accessory name="Ribbon"/>
    </Equipment>
  </Enemy>
</Enemies>

Advantages:

Easy to extend if I need to add/rearrange parameters
easy to assign default values
I already have an XML parser (pugixml) included for config files, tiled maps and resource description loading

Disadvantages:

potentially slow (my database will likely hit several hundred
enemies)
can't query for arbitrary enemies, so will likely need to keep all
enemies in memory.
This would mean I need to restart the game to load changed enemy data
as well

SQLite

For this, I'd basically make a table with columns representing all the data I'd need and leave the unnecessary fields empty

Advantages

Arbitrary querying can keep unnecessary enemy data out of memory
Feels more structured
Smaller file size

Disadvantages

More difficult to extend/rearrange parameter orders
Unnecessary overhead to to unused fields
Will need to write a database interface wrapper for sqlite

With this in mind I was curious on getting some outside experience on what other people have done. I may be thinking about this totally wrong, and if so, please suggest an alternative to the two possibilities I have here.

Additionally, any suggestions on how to improve either of these possibilities would be appreciated. Really, I just want to know if I'm on the right track.

I'm open to using any free library and am already incorporating boost


texts:
My game has a background that I can move with the mouse. I want to add some semi-transparent buttons on top of background as DrawableGameComponent. But when I click the Button mouse click will propagate to underlying background and it will be moved. How to detect that click was handled and not to call Update methods of underlying game components?

Sorry for my bad english.


texts: Making sense of the Game State manager tutorial?

texts:
I have come across the Game State Managemnet tutorial at http://create.msdn.com/en-US/education/catalog/sample/game_state_management because I thought this would be a good place to start a game off.

I have added a new screen, but I am still a bit lost on how everything works.  When I make my game, do I only need one more additional screen? just for gameplay? or should I have a different screen for each level?


texts: Blender animation's curled fingers are splayed-out when played in Unity

texts:
I have exported my character into Unity and all the animations came with it. At first, I thought I was good to go but then I made a jogging animation. In blender the hands are gripped like this:

When this animation is exported to Unity the hands are no longer gripped and look like this:

Here are some more pictures showing the settings I have on my animation first in Blender:

Next in Unity:

So far I have tried:
Checking if the animations were updated in Unity (They were),
Reimporting the Unity model,
Looking through the animation properties in Blender,
Looking through the animation properties in Unity
I've been stuck on this for a few days now and I would appreciate some help as this is getting quite frustrating.


texts: Player's feeling towards stage selection in a platform game

texts:
In a 2D platform game with RPG elements (not that it matters much), there's three ways, among others, for the player to choose the next stage he will play:

He can only play the next stage and the ones he already beat
On game start, half of the stages are open, and the other half is released when he beats the first half
All stages are available to the player

What's the difference in perspective to the players general experience and his feelings towards a game rating of these three alternatives?

(I know it sounds like a copy of an exercise, but it isn't. I did this way so people may take this question in a more academic way)


texts: How can I generate a view or projection matrix for OpenGL 3.+

texts:
I'm transitioning from OpenGL 2 to OpenGL 3.+ and to GLSL 1.5. I'm trying to avoid using the deprecated features.

My question how do we now generate the view or projection matrix. I was using the matrix stack to calculate the projection matrix for me;

GLfloat ptr[16];
gluPerspective(...);
glGetFloatv(GL_MODELVIEW_MATRIX, ptr);
//then pass ptr via a uniform to the shader

But obviously the matrix stack is deprecated. So this approach is not the best an option going forward.

I have the 'Red Book', 7th ed, which covers 3.0 & 3.1 and it still uses the deprecated matrix functions in it's examples.

I could write some utility-code myself to generate the matrices. But I don't want to re-invent this particular wheel, especially when this functionality is required for every 3D graphics program.

What is the accepted way to generate world,view & projection matrices for OpenGL? Is there an emerging 'standard' library for this? Or is there some other hidden (to me) functionality in OpenGL/GLSL which I have overlooked?


texts: Understanding the rendering of the raycasting on flat screen

texts:
I have a misunderstanding of the raycasting formulas on flat screen because my rendering is not what I expected, this is some parts of the code to show my projection formulas that I wrote by myself

This is the code for the function intersection

int         intersection(t_wolf3d *w, int i, t_vec2f *dir, int iter){
int             mapx;
int             mapy;
unsigned int    length;

length = -1;
while (++length < w->cam->raylength)
{
    mapx = (int)(w->cam->position.x + (length * dir->x));
    mapy = (int)(w->cam->position.y + (length * dir->y));
    if ((mapy / BLOC_SIZE < w->map->h && w->map->board[mapy / BLOC_SIZE]
                    [mapx / BLOC_SIZE]) || (i == 1 && mapy >= HEIGHT_MM))
    {
        w->cam->intersection.x = mapx;
        w->cam->intersection.y = mapy;
        return (1);
    }
}
return (0);

}

Code used for the raycasting algorithm:

void                    raycasting(t_wolf3d *w, int limit){
int         i;
int         hit;
t_vec2f     dir;
t_vec2f     forward;
t_vec2f     right;
double      halfwidth;
double      offset;

i = -1;
forward.x = tcos(w->cam->angle);
forward.y = tsin(w->cam->angle);
right.x = forward.y;
right.y = -forward.x;
halfwidth = ttan(w->cam->fov / 2.0);
while (++i < limit && !(hit = 0))
{
    w->cam->rays[i].startpoint = w->cam->position;
    w->cam->rays[i].startpoint.color = 0xff0000;
    offset = ((i * 2.0 / (limit - 1.0)) - 1.0) * halfwidth;
    dir.x = forward.x + offset * right.x;
    dir.y = forward.y + offset * right.y;
    if ((hit = intersection(w, limit, &dir)))
        w->cam->rays[i].endpoint = w->cam->intersection;
    else
    {
        w->cam->rays[i].endpoint.x = w->cam->position.x + w->cam->raylength
            * dir.x;
        w->cam->rays[i].endpoint.y = w->cam->position.y + w->cam->raylength
            * dir.y;
    }
    limit == w->width ? render(w, i, hit) : 0;
}

}

For non-straight walls, I thought it was my variable types, it seems like not, I changed them from integers to double and i still got the same result, this is a look of my structures :

typedef struct      s_point{
int             x;
int             y;
int             color;}                 t_point;

typedef struct      s_vec2f{
double          x;
double          y;}                 t_vec2f;
typedef struct      s_camera{
double          radius;
double          angle;
double          fov;
double          raylength;
double          speedmove;
double          speedangle;
t_point         position;
t_point         intersection;
t_point         rays[WIDTH];}                   t_camera;
typedef struct      s_map{
int             **board;
int             w;
int             h;}                 t_map;
typedef struct      s_wolf3d{
t_map           *map;
t_camera        *cam;
int             hit;
t_image         *img;
void            *mlx_ptr;
void            *win_ptr;
char            texture;
t_image         *textures[3];
int             colors[3];
int             mini_h;
int             mini_w;
int             width;
int             height;}                    t_wolf3d;


texts: Run one cycle of animation when button is pressed in libgdx

texts:
I am looking for a way to run my animation a complete cycle when a button is pressed. The animation runs as long as the button is pressed but the animation takes a second to play so it becomes too short. I would like to have it played through once, even if the button only was pressed very fast.

It's a character's slash with the knife and it needs to be one complete cycle, I just don't get how to do this.

Anyone has an idea on how I could do this in a better way?

The specific code is now inside render():

 if(Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
        if(direction == HEADING.NORTH) {
            animation = knifeslashnorth;
        } else if (direction == HEADING.WEST) {
            animation = knifeslashwest;
        } else if(direction == HEADING.EAST) {
            animation = knifeslasheast;
        } else if(direction == HEADING.SOUTH) {
            animation = knifeslashsouth;
        }
    }


texts: Lerp problem object teleporting not moving

texts:
Hi i just wanna move my object smoothly from one position to another but object disappear and immediately teleport to position where i clicking anyone know whats happen ?

    if (Input.GetKeyDown(KeyCode.Mouse0))
    {

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, 1000.0f))
            {

                Vector3 newpos = new Vector3(hit.point.x, 0, hit.point.z);
                Cube40.transform.position = Vector3.Lerp (Cube40.transform.position, newpos, 1f);

            }
    }

Thank you Vishnu i already fix it with code below your code was better anyway but there is another problem with Lerp method itself because no matter where i click object always transform his position with the same time and it can't be use in RTS game
rather i need something like transform.Translate with from:Vector3, to:Vector3 parameters.

GameObject Cube40;
RaycastHit hit;
Vector3 newPosition;

void Start()
{

    Cube40 = GameObject.Find("Cube1");
    newPosition = Cube40.transform.position;

}

void Update()
{

    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

    if (Physics.Raycast(ray, out hit, 1000.0f))
    {

        Vector3 newpos = new Vector3(hit.point.x, 0, hit.point.z);
        if(Input.GetKeyDown (KeyCode.Mouse0))
        newPosition = newpos;
        Cube40.transform.position = Vector3.Lerp (Cube40.transform.position, newPosition, 0.1f);

    }
}
}


texts:
I'm having a few problems with collision detection in my game (written in C# with SDL.Net). Detecting the floor and roof is fine, as does detecting sides of tiles when not jumping/falling. My problem comes when the player jumps and hits one of the sides of a tile.

Sometimes the player (blue) enters the tile, like this:
http://i.stack.imgur.com/SSjtR.png
At first I thought this was because it was checking for a collision then moving the player then drawing, but changing it has no effect.

Other times it will randomly move from the overlapping position above to here:
http://i.stack.imgur.com/0esSw.png

    public void PlayerCollision2 (ref Player player)
    {
        Rectangle rectLeft = new Rectangle (new Point ((int)player.x, (int)player.y), new Size (1, Player.HEIGHT));
        Rectangle rectRight = new Rectangle (new Point ((int)(player.x + Player.WIDTH), (int)player.y), new Size (1, Player.HEIGHT));
        Rectangle rectTop = new Rectangle (new Point ((int)player.x, (int)player.y), new Size (Player.WIDTH, 1));
        Rectangle rectBot = new Rectangle (new Point ((int)player.x, (int)(player.y + Player.HEIGHT + 1)), new Size (Player.WIDTH, 1));

        List<TileDirectionRelPlayer > lst = new List<TileDirectionRelPlayer> ();
        foreach (List<Tile> r in map) {
            foreach (Tile c in r) {
                if (c.tileType == TileType.Air)
                    continue;
                TileDirectionRelPlayer t = new TileDirectionRelPlayer ();
                t.tile = c;
                if (c.rect.IntersectsWith (rectBot)) {
                    t.below = true;
                    lst.Add (t);
                } if (c.rect.IntersectsWith (rectTop)) {
                    t.above = true;
                    lst.Add (t);
                } if (c.rect.IntersectsWith (rectLeft)) {
                    t.left = true;
                    lst.Add (t);
                } if (c.rect.IntersectsWith (rectRight)) {
                    t.right = true;
                    lst.Add (t);
                }
            }
        }

        if (lst.Count == 0 && !player.jumping) {
            player.falling = true;
        } else {
            foreach (TileDirectionRelPlayer t in lst) {
                MovePlayer (ref player, t, new Rectangle[] {rectLeft, rectRight, rectTop, rectBot});
            }
        }
    }

    private void MovePlayer (ref Player player, TileDirectionRelPlayer tile, Rectangle[] rectangles)
    {
        if (tile.above && rectangles[2].IntersectsWith(new Rectangle(new Point((int)tile.tile.x,(int)tile.tile.y+Tile.HEIGHT), new Size(Tile.WIDTH,7)))) {
            player.falling = true;
            player.jumping = false;
            player.ySpeed = 0;
            player.y = tile.tile.y + Tile.HEIGHT + 1;
        }
        if (tile.left && tile.tile.y < player.y) {
            player.x = tile.tile.x + Tile.WIDTH;
        }
        if (tile.below && !player.jumping && rectangles[3].IntersectsWith(new Rectangle(new Point((int)tile.tile.x,(int)tile.tile.y), new Size(Tile.WIDTH,7)))) {
            player.y = tile.tile.y - Player.HEIGHT - 1;
            player.falling = false;
            player.ySpeed = 0;
        }
        if (tile.right && tile.tile.y < player.y) {
            player.x = tile.tile.x - Player.WIDTH - 1;
        }
    }

I have no idea why this is happening or how to fix it, can someone point me in the right direction please?

EDIT: There is a video here if it helps


texts: Attach the UIButton to Component Via Script (C# Unity)

texts:
I want to attach the UI to the MC_Streaming Option Script via Code .

What i wanted here is that this live_onOff will go to the Livestream(MC_Streaming Option) without dragging it . And i don't know where to start.

PS: The MC_Streaming Option script is being attached only when the program run

MC_StreamingOption mcStreamingOption = gameObject.AddComponent<MC_StreamingOption>();


texts:
Consider my following (abstracted) C# w/ SharpDX code:

class Game
{
    Camera _camera = new Camera();

    private void Window_KeyDown(object sender, KeyEventArgs e)
    {
        // Roll
        if (e.KeyCode == Keys.Home)
        {
            _camera.TurnRoll(-0.05f);
        }
        else if (e.KeyCode == Keys.End)
        {
            _camera.TurnRoll(0.05f);
        }
        // Other rotation / movement works...
    }
}

class Camera
{
    private Vector3 _position;
    private Vector3 _rotation;
    private Vector3 _right;
    private Vector3 _up;
    private Vector3 _forward;
    private Matrix  _view;

    public Camera()
    {
        _right = Vector3.Right;
        _up = Vector3.Up;
        _forward = Vector3.ForwardLH;
        UpdateViewMatrix();
    }

    public void TurnRoll(float roll)
    {
        // Relative rotation
        _rotation.Z += roll;
        UpdateViewMatrix();
    }

    private void UpdateViewMatrix()
    {
        Matrix cameraRotationMatrix = Matrix.RotationYawPitchRoll(_rotation.Y, _rotation.X, _rotation.Z);
        Vector3 cameraTarget = Vector3.TransformCoordinate(Vector3.ForwardLH, cameraRotationMatrix);
        cameraTarget = cameraTarget.Normalize();
        cameraTarget += _position;

        // I bet the problem lies in and/or after this line
        Matrix rotateYTempMatrix = Matrix.RotationY(_rotation.Y);

        _right   = Vector3.TransformCoordinate(Vector3.Right,     rotateYTempMatrix);
        _up      = Vector3.TransformCoordinate(Vector3.Up,        rotateYTempMatrix);
        _forward = Vector3.TransformCoordinate(Vector3.ForwardLH, rotateYTempMatrix);

        _view = Matrix.LookAtLH(_position, cameraTarget, _up);
    }
}

My problem: Even when pressing the Home and End keys, the camera roll visibly stays untouched. I have trouble correcting my UpdateViewMatrix function, and I bet that the error is in there. I'm a bit lost with the maths here and my tries to use another rotation matrix to update the _up vector all failed or created other problems.

Can anybody clear my math mind up and help me correct this method?

EDIT: Solved with the help of winged's answer below. I edited the code to be

private void UpdateViewMatrix()
{
    Matrix rotation = Matrix.RotationYawPitchRoll(_rotation.Y, _rotation.X, _rotation.Z);

    _forward = Vector3.TransformCoordinate(Vector3.ForwardLH, rotation);
    _forward += _position;

    _up = Vector3.TransformCoordinate(Vector3.Up, rotation);

    _view = Matrix.LookAtLH(_position, _forward, _up);
}

However, this is still not completely correct. The camera rolls now, which solves this question. But if it is rolled and I try to yaw it, the yaw happens like as if the camera is non-rolled and moves along the default Y-axis :/. Especially when looking downwards 90 degrees this causes something like gimble-lock to happen (or IS it gimble lock?) because rolling and yawing the camera has the same effect then.

EDIT2: I completely replaced my rotation with quaternions. I don't know why people think these are "harder" or at least "different" to understand. This solution works perfectly.

public void Turn(Vector3 turning)
{
    // Relative rotation
    Quaternion delta = Quaternion.RotationYawPitchRoll(-turning.Y, -turning.X, -turning.Z);
    _rotation = delta * _rotation;
    _rotation.Normalize();
    UpdateViewMatrix();
}

public void TurnRoll(float roll)
{
    Turn(new Vector3(0, 0, roll));
}

private void UpdateViewMatrix()
{
    Matrix view = Matrix.RotationQuaternion(_rotation);
    Matrix translation = Matrix.Translation(-_position.X, -_position.Y, -_position.Z);
    _view = translation * view;
}


texts: Is it more efficient detect when audio clip ends with AudioSource.isPlaying or with AudioClip.length?

texts:
In Unity, I want to trigger an event when an audio clip finishes playing. Would it be more CPU efficient to keep checking if the audio clip is playing with

WaitUntil(() => audioSource.isPlaying == false);

or would it be more efficient to use:
 WaitForSeconds(audioClip.length);
to simply wait a certain amount of time?

How can I run a test in Unity to see which one is more CPU efficient?


texts: In HaxeFlixel, how do I avoid hard-coding dialogue?

texts: I'm planning to develop a visual novel in Haxe Flixel and wanted to know if there is a easier way to add dialogue than to hardcode them in every square. I don't know if I can import a txt file with the dialogues or something like that so I can simple change the txt file instead of have to check the code for every typo.


texts:
Hello im trying to learn more about smoother movement in games. I have created a little program to hopefully help me understand this. As far as i can tell i am suppose to track time, and update positions accordingly. However, for some reason, this concept is very hard for me to understand. I am using python and pygame at the moment for my games, and in none of them i have been able to come up with the smoothness i wanted. Ive also tried several games off of the pygame website and so far none of them have had the smoothness i prefer.

like i said, i understand you have to track time, and update positions accordingly instead of just +1'ing location each frame/iteration. By doing it the 'wrong way' as far as i understand then it doesnt neccesarily sync up with the monitor thus creating the sense of jittery motion, even at high FPS.

i have read a few articles on the subject of time steps, however i have been unable to fully understand the concept and incorporate it in my game. so i would like to ask, if someone can explain how to implement a timestep and create smooth motion. i am not going to incorporate physics in my first games, so the accuracy of the timer does not matter too much, what is most important right now is a game that can run as smooth as a proffesional game. i am sure a revisit if not simplified explanation of timestepping, and even how to do it in a simple way with python will be of benefit to any programmer hoping to use pygame/python for his games.

Anyway this is the program i was able to write, that doesent have smooth motion. Perhaps someone can modify it, so we can get a working example with time stepping and see how it improves the smoothness. PS. you need python 2.7 and a python 2.7 pygame compatible version to run the program/game

http://bpaste.net/show/qmE362O29sq6GPGBK3fg/


texts: How to make a variable remain false after release of a button?

texts:
left_click = mouse_check_button_pressed (mb_left)

battleMode = true

if (left_click) battleMode = false

if battleMode = false then {
  if (key_right) then {
  x= x+5
  sprite_index= spr_walking
  image_speed = 0.5
  }
}

battleMode becomes true again once left click is not being held. I tried changing mouse_check_button_pressed to mouse_check_button_released and mouse_check_button, but battleMode becomes true again when left_click has done its job.


texts: Collision detected at different times depending on speed?

texts:
Imagine a scenario where there are four cubes. Two blacks that do not move, one red moving at a constant speed of two (2) straight and the other blue moving at a constant speed of five (5) also straight.

They all have equal bounding boxes.

By doing a test, I realized that if I put a command so that as soon as the red cube strikes against the black it turns left, the command does not run as soon as they collide ...

With the blue he wanted him to turn right as soon as he hit. The command takes longer to happen, I think because it is faster than red ...

Illustration of the incident:

It seems that the faster the object is, the longer it responds to the collision command. I would like you to give me a solution to this problem.

I've already moved with some bounding box options, but nothing that has given the desired result.

I also moved at the speed of the room, but it did not work either.

Sorry for any translation error. Thanks in advance!


texts: How to align angular velocity wit target rotation in 3D?

texts:
I'm making a space crew sim (controlling a ship) and have recently posted a question about how to calculate ETA between two rotations. I how now a new question more well defined.

Background:
I have Qtarget and Qcurrent(the ships rotation) and can find Qdelta using Qdelta = Qcurrent ^-1*Qtarget.
And I have the angular velocity in rotation speed around the world axis from the Unity.

I want to control the ship only using delta angular velocity around ships axis.

I want to get the angular velocity aligned with Qdelta so i can just use that angular velocities e.g. x part and the angel to solve for if I should accelerate or decelerate and just decelerate along the y and z axis. After that I want to rotate that data back to ship rotation.

I have this test code:

using UnityEngine;
using System.Collections;

public class RoationTest : MonoBehaviour {
    public Vector3 startAngularVelocity = new Vector3();
    public Vector3 targetRoation = new Vector3();
    public Vector3 maxShipDeltaAngularVelocity = new Vector3();

    // Use this for initialization
    void Start (){
        rigidbody.angularVelocity = startAngularVelocity*Mathf.Deg2Rad;
        rigidbody.WakeUp();
    }

    // Update is called once per frame
    void Update () {
        Vector3 currentAngularVelocity = rigidbody.angularVelocity*Mathf.Rad2Deg;   //This seams to work
        Quaternion deltaRoationQuat = Quaternion.Inverse(rigidbody.rotation) * Quaternion.Euler(targetRoation); //This seams to work

        float deltaAngel = Quaternion.Angle(rigidbody.rotation,Quaternion.Euler(targetRoation));    //This seams to work

        Vector3 xAxis = new Vector3(1,0,0);
        Vector3 deltaRotationAxis = deltaRoationQuat.eulerAngles;
        Vector3 deltaRotationAxisClampedToShortestDist = ClampEulerAngelsToClosest(deltaRotationAxis);
        Quaternion AlignQuat = Quaternion.FromToRotation(deltaRotationAxisClampedToShortestDist, xAxis);

        Vector3 angularVelocityAligend = AlignQuat*currentAngularVelocity;  //This should be Quaternion.Inverse(AlignQuat)*currentAngularVelocity; But that does not work as I think I should but this do.
        Vector3 maxDeltaAngularVelocityGlobalRotaion = rigidbody.rotation*maxShipDeltaAngularVelocity;  //Transform max delta angular velocity from ship rotation to global space. The same as maxShipDeltaAngularVelocity*Quaternion.Inverse(rigidbody.rotation) but Unity do not suport that.
        Vector3 maxAlignedDeltaAngularVelocity = AlignQuat*maxShipDeltaAngularVelocity;
    }

    private Vector3 ClampEulerAngelsToClosest(Vector3 rotation){
        if(rotation.x>180){
            rotation.x = rotation.x-360;
        }
        if(rotation.y>180){
            rotation.y = rotation.y-360;
        }
        if(rotation.z>180){
            rotation.z = rotation.z-360;
        }
        return rotation;
    }
}

Questions:
Why do this
Vector3 angularVelocityAligend = AlignQuat*currentAngularVelocity; align y axis with x axis?
It should be Vector3 angularVelocityAligend = Quaternion.Inverse(AlignQuat)*currentAngularVelocity; in my understanding.

Also how can Vector3 maxDeltaAngularVelocityGlobalRotaion = rigidbody.rotation*maxShipDeltaAngularVelocity; be right?

General thoughts:
Is this clear enough or am I taking the wrong approach? I general words I want to find the optimal solution in every frame on how to reach target rotation only using delta angular velocity limited by a max value (the ships engines effect) and also receive and ETA. I understand this is an approximation I state above since i assumes no rotation perpendicular to Qdelta but this solution will do for a start.


texts: Player losing alignment with tilemap after moving

texts:
I'm using an isometric tilemap(2:1) and I can't figure out how to make grid based movement on it's surface. I managed to get a code working for the grid based movement, moving my character with 0.5 along the Y axis and 0.86 ( sqrt(3)/2 ) along the X axis since I imagine it should work as if they are diamonds with the side of 1 unit, but it doesn't align with the center of the next tile. Here is my movement code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions.Must;

public class Movement : MonoBehaviour
{
    Vector3 pos;         // For movement
    float speed = 5f;   // Speed of movement
    public float x = 0.86f;
    public float y = 0.5f;

    void Start()
    {
        pos = transform.position;          // Take the initial position
    }

    void FixedUpdate()
    {
        if (Input.GetKey(KeyCode.A) && transform.position == pos)
        {        // Left
            //pos += Vector3.left;
            pos += new Vector3(-0.86f, 0.5f, 0);
        }
        if (Input.GetKey(KeyCode.D) && transform.position == pos)
        {        // Right
            //pos += Vector3.right;
            pos += new Vector3(0.86f, -0.5f, 0); // miscare in diagonala
        }
        if (Input.GetKey(KeyCode.W) && transform.position == pos)
        {        // Up
            //pos += Vector3.up;
            pos += new Vector3(0.86f, 0.5f, 0);
        }
        if (Input.GetKey(KeyCode.S) && transform.position == pos)
        {        // Down
            //pos += Vector3.down;
            pos += new Vector3(-0.86f, -0.5f, 0);
        }
        transform.position = Vector3.MoveTowards(transform.position, pos, Time.fixedDeltaTime * speed);    // Move there
}


texts:
I'm making a mobile game and I've gotten by with completely free art assets so far, but I have an explosion from metal slug. I love it and it's perfect, but I don't want to get sued. I've seen metal slug art assets posted around the internet on various clip art websites, but haven't found any statements outright saying they're free to use in one's own commercial application.

Could someone show me a link saying whether or not metal slug assets are free to use?


texts:
Can Panda3D game be served from cloud such as AWS ?
Can Panda3D be used for mobile game development (iOS, Android) ? I'm aware Unity can be used but what about Panda3D ?


texts: Are there well known algorithms for efficient map knowledge?

texts:
The question subject's is a little confusing, but I had no better way to express my train of thought. I'm working on an RPG at the moment, and I have a question. Using SARSA (State-Action-Reward-State-Action), I'm building a smart brain by training it through a reward system. Right now, what I want is to improve the learning process when moving each unit of the party, the selected actions will impact the team as a whole.

Moving to attack an enemy on which I have a tactical advantage, such as when a knight attacks a wizard, the wizard being weak on physical attacks, will get more damage out of the attack. The brain starts to understand that doing this gives a better reward. But, doing so could lead a unit to attack an enemy that has a tactical disadvantage against it but it has friends that can help him defeat the foe.

What I'm looking for is the following: Is there any algorithm that can parse a given data structure representing a map and see whether or not I'm moving toward a bad or good position depending on some variables such as moving toward target, target has friendly surrounding, moving toward treasure chest and etc.

I'm not looking for someone to write down an implementation for me, just to point me in the good direction because I have no idea what I'm looking for. If you're well versed in what I'm speaking and willing to give me a sample algorithm that I should follow and adapt for my game, I will gladly refer you in my prototype and send you a link once the prototype is playable!


texts: How to get crash reports from game Unity3d

texts:
I am working on a project and I am in need of to gather CrashReports, email crash log, along with allowing the user to describe how the crash happened. I cannot find anything on how to do this, anyone has any ideas? Thanks!

-Learning Unity User


texts: Navigation Mesh, Chunks and Funnel Algorithm

texts:
I am building a little RTS-like game as a side project and I am currently working on pathfinding. My approach to pathfinding is heavily inspired by things I saw in the Starcraft II map editor, which enables diagonal obstacles. My map consists of tiles that are subdivided into 4 triangles each and each triangle can be passable or not passable. I then build a navigation mesh by generating polygons (with holes) of the passable area and then triangulating them. See the following pictures for an example:

The colored areas are the triangulated polygons that make up the navigation mesh.

As an optimization I thought it would be a good idea to subdivide the map into chunks (i.e. 32x32 grid tiles) to allow for fast updates of the mesh (as soon as a triangle changes from passable/impassable I rebuild the whole chunk and update the navigation mesh accordingly). See the following picture for an example:

The red lines are the chunk borders (which is also why the color of the navigation mesh sometimes changes accross the borders).

The triangulation is a separate constrained delaunay triangulation for each chunk. For the chunk-wise updates to work I had to introduce constraints at the chunk borders for the triangles to line up. Up until now everything seemed to work fine. I then went to implement some pathfinding using A* on edge midpoints and path smoothing using the Simple Stupid Funnel algorithm (see "Efficient Triangulation-Based Pathfinding" by Demyen and Buro or How does the Simple Stupid Funnel Algorithm work?).

The problem is now that some triangles have their vertices at chunk borders that don't correspond to an obstacle. If such a triangle is part of a path found by A* the funnel algorithm uses it if it was a corner point of an obstacle and produces a wrong path. See the folowing picture for an example:

The red area is the passable area and has no obstacles inside. The green path is the path as it is found by e.g. A* and the blue path is the smoothed path using the funnel algorithm. Since there is an extra vertex in the navigation mesh introduced by the the chunk borders (where the 4 chunks meet) the funnel algorithm handles it the same as if it was the corner of an obstacle and thus the path is not a straight line but takes a detour around the corner. Ultimately I wanted to implement something along the lines of "Compromise-free Pathfinding on a Navigation Mesh" by Cui, Harabor and Grastien to find truly optimal paths in a navigation mesh. But all of those methods seem to assume that the navigation mesh contains no extra vertices except for the corners of obstacles (and the outer border of course).

I am looking for a solution for the problem of splitting the map into chunks for efficient updates of the navigation mesh while still being able to find optimal paths in an efficient manner (e.g. i don't want to do real line of sight checks instead of the funnel algorithm). My only other option it seems would be an algorithm for dynamic constrained delaunay triangulations and having a single triangulation for the whole map (since this would not introduce extra obstacles) which for one is pretty complicated and second (and more importantly) doesn't scale.

I know that this is a pretty open question. I hope it comes clear what I am looking for, since it was kind of difficult to phrase the problem :D
If anything needs clarification, please tell me :D


texts: Fixed timestep and interpolation question

texts:
I'm following Glenn Fiedlers excellent Fix Your Timestep! tutorial to step my 2D game. The problem I'm facing is in the interpolation phase in the end.

My game has a Tween-function which lets me tween properties of my game entites. Properties such as scale, shear, position, color, rotation etc. Im curious of how I'd interpolate these values, since there's a lot of them. My first thought is to keep a previous value of every property (colorPrev, scalePrev etc.), and interpolate between those.

Is this the correct method? To interpolate my characters I use their velocity;
renderPostion = position + (velocity * interpolation), but I cannot apply that to color for example.

So what is the desired method to interpolate various properties or a entity? Is there any rule of thumb to use?


texts:
I'm new to game development and want know how to make or load a terrain from OpenStreetMap or Google Maps in your current city. (I'm using Unity3D.)

My idea is just load or generate a map of the current location, without collisions or anything else. A good example could be the Google's game "Ingress".

I found a few tutorials but only for a static city or mountain.


texts:
In my game-loop, I am using fixed time step for physics and interpolation for rendering as suggested on Gaffer on Games | Fix Your Timestep!

However, when the framerate is varying between 30-60fps during the game, the game looks jumpy. For example, balls suddenly look accelerated when the frame rate increases from 35 to 45 suddenly.

Is there a way to make the game look smooth while framerate is varying?

Here is my game loop:

protected void update(float deltaTime) {
    //do some pre stuff

    deltaTimeAccumulator +=deltaTime; //deltaTimeAccumulator is a class-member holding the accumulated frame time
    while(deltaTimeAccumulator>FIXED_TIME_STEP) {
        world.step(FIXED_TIME_STEP, 6, 2);  //perform physics simulation
        deltaTimeAccumulator-=FIXED_TIME_STEP;
    }
    // world.step(deltaTime, 6, 2);

    destroyBodiesScheduledForRemoval();
    render(deltaTimeAccumulator /FIXED_TIME_STEP); //interpolate according to the remaining time
}

Here is the part related to the interpolation (related inner works of render() method) :
        this.prevPosition = this.position; //get previously simulated position

    this.position = body.getPosition(); //get currently simulated position

    //interpolate
    Vector2 renderedPosition = new Vector2();
    if (prevPosition != null) {//&& !isFloatApproximatelyEquals(this.prevPosition.x, this.position.x) && !isFloatApproximatelyEquals(this.prevPosition.y, this.position.y)) {
        renderedPosition.x = this.position.x * interpolationAlpha + this.prevPosition.x * (1 - interpolationAlpha);
        renderedPosition.y = this.position.y * interpolationAlpha + this.prevPosition.y * (1 - interpolationAlpha);
    } else {
        renderedPosition = position;
    }

    //Draw the object at renderedPosition


texts: How can I efficiently render a very large model?

texts:
I have a huge model I want to draw in my XNA application; due to its size I am experiencing a tremendous loss of performance.

The model has about 50,000,000 edges and has a size on disk of 205 MB in the .x format. Yes, the model has to be this big.

Is there a way to transfer the model directly to my GPU in order to let the GPU do the drawing like when transferring a VertexBuffer? When I try to fill a vertex buffer with the object I am getting an OutOfMemoryException.


texts:
I am just starting out with OpenGL, so I need a little help understanding how textures are loaded. When I look at the OpenGL manual, it gives a list of accepted image formats, e.g.

GL_UNSIGNED_BYTE_3_3_2
GL_UNSIGNED_SHORT_5_6_5
GL_UNSIGNED_SHORT_5_5_5_1
GL_UNSIGNED_INT_10_10_10_2
//and a few others...

Can I have a RGB texture with a GL_UNSIGNED_SHORT_8_8_8_8, or do I  have to pad the image so that it is RGBA (or maybe it doesn't matter either way...)?
What is the purpose of all the other internal formats (GL_R16 or GL_RGBA32I) if there is no corresponding image format type (like the ones listed above) to load that type of texture?
Oh, and one other question. Is there a maximum texture size? Or I guess, if there is no maximum size, is there an optimal size for how large textures can be?


texts: What is the difference between an alpha and a beta release? I'm surprised this question hasn't been asked here before.


texts: Adjusting collision hitbox size with Pygame

texts:
So I coded a 2d sidescrolling platform, everything is fine except this:

As you can see, the sprite is standing at the platform when her feet is not in the platform anymore. I want to adjust the collision hitbox size so that when her feet is not on the platform, she falls to the ground.

Below is the code for sprite initiation:

    class Player(pygame.sprite.Sprite):

    #Initiating the player (23 / 5)
    #because there is only one character right now, it will have no case for character selection (23 / 5)
    def __init__(self):
         super().__init__()

         #width and height of character (23 / 5)
         width = 80
         height = 120

         #character sprite goes here (23 / 5)
         self.image = pygame.image.load("Malahayati.jpg").convert_alpha()
         self.image = pygame.transform.scale(self.image,(width,height))

         #hitbox (23 / 5)
         self.rect = self.image.get_rect()

         #character speed (23 / 5)
         self.vx = 0
         self.vy = 0

         #references to the list of sprite we bumped against (24 / 5)
         self.level = None

         #current state: 0 is idle, 1 is moving right, 2 is moving left, 3 is dashing
         self.status = 0

         #character status (24 / 5)
         self.rank = 1
         self.health = 220
         self.attack = 50
         self.defense = 20
         self.speed = 52.5
         self.exp = 0
         self.jumpspeed = 125


texts: What is the best practice for future proofing my editor enumerations?

texts:
I would like to know the best practices for handling the following situation:

Suppose the project you are working on is split in to two sub-projects; the game engine library, and the editor GUI.

You have the method bool Method( const MethodParams &params ) that will be called during game-level initialization; it is a method that belongs to the game engine library. The parameters of this method, passed as a reference to the structure MethodParams, can be decided via the editor in the level design phase. The MethodParams structure is as follows:

enum Enum1
{
    E1_VAL1,
    E1_VAL2,
};

enum Enum2
{
    E2_VAL1,
    E2_VAL2,
    E2_VAL3,
};

struct MethodParams
{
    float   value;
    Enum1   e1;
    Enum2   e2;
    // some other members
}

The editor should present a dialog that will allow the user to set the values in the MethodParams structure. The editor needs to present a text box for value, and let the user set the fields e1 and e2 using a combo box, for example. Every enum option should be mapped to a string, so the user can make an informed selection (normally, the names used in the enum would be more meaningful). One could even want to map every enum to a more informative string (so, for example, E1_VAL1 could map to "Image union algorithm", and E1_VAL2 could map to "Image intersection algorithm").

The editor will include all the relevant game engine library files (.h, etc.), but this mapping is not automatic, and I am confused by how to handle it in a way that where code change will be minimal, if I add further enum options in the future.


texts: update positition data: change vertex buffer or matrix?

texts:
I am writing a small 2D SHMUP for Android at the moment. Pure 2D rendering with Bitmaps turned out to be a bit too slow, especially with a lot of alpha blending going on. So I decided to switch my rendering backend to OpenGL. Last time I used OpenGL there was still immediate mode. I now want to build a modern architecture with OpenGL ES 2.0.

Here are the details:
Most of the time I am going to display a lot of Sprites, that are essentially texure mapped quads consisting of 2 triangles each. I am probably going to want to render a lot of them :) I am going to use Vertex Buffers because of the faulty VBO implementation in Froyo.

Here's the question:
How would I manage the position data of the independent sprites? Do I need to modify my vertex buffers each time a sprite changes its position? Or is it faster to use a single draw call and translation matrix for each sprite?


texts: Why do my images take 200 MB of RAM when they are ~20KB on disk?

texts:
I am creating an Android game using libGDX. When I load my nine images it takes 200 MB of RAM. But the images are 10 to 17 KB each. Why the discrepancy? Here is where I create textures from those images:

public static HashMap<String, Texture> ground = new HashMap<String, Texture>();
for (int i = 1; i < 10; i++) {
  ground.put(
  "ground" + i,
    new Texture(Gdx.files.internal("groundImages/ground" + i + ".png"))
  );
}


texts: How can I make such exactly the same shadow using NGUI?


texts: Turning x and y difference between two points into a projectile moving between them at a fixed speed

texts:
In a libgdx project of mine, I have two units on a 2d field who want to fire at each other. They both know the x and y distance to each other by subtracting their enemies position from their own:

Vector2 path = pos.cpy().sub(target.getPos());

What's the simplest way of turning this Vector2 into a vector that'll allow the units to fire at each other, with the projectile being sent off with Projectile.maxSpeed?

I was thinking of normalizing path and multiplying both x and y with the desired bullet speed, but I fear I may be overthinking this and that applying trigonometry would be simpler.


texts: Best cross-platform solution for building 3D toolsets?

texts:
I am looking to develop an in-browser game in Unity3D, but I would like to write my builder tools for my project on a more powerful platform.

The assets I am building for the game are not traditional 3D models, so I'll probably be creating my own format. I was thinking about writing something in Blender or Maya, but that is a lot of overhead for what I want to do.

A Unity3D desktop app was also a possibility, but at the end of the day I decided I wanted to build it outside of the game engine.

Since the Unity3D app is going to be cross platform, I would like the tool to be as well.

Saying that, does anyone know of a 3D library/platform that will run well on Windows and OS X?


texts:
I used a 16x16 sprite pack to make a 640x640 map in pygame:

The problem is that everything is extremely tiny. How could I go about making the expected "JRPG" look, like this for instance:

I have tried so far to double the size of the map tiles using pygame.transform.scale(tile,(32,32)) but that makes everything look terrible:

Here is how I am rendering the map:

import pygame
import pytmx
from pytmx.util_pygame import *

class tileRender:
    def __init__(self,filename):
        tm = pytmx.load_pygame(filename)
        self.width = tm.width * tm.tilewidth
        self.height = tm.height * tm.tileheight
        self.tmxdata = tm

    def render(self,surface):
        ti = self.tmxdata.get_tile_image_by_gid
        for layer in self.tmxdata.visible_layers:
            if isinstance(layer,pytmx.TiledTileLayer):
                for x,y,gid in layer:
                    tile = ti(gid)
                    tile = pygame.transform.scale(tile,(32,32))
                    if tile:
                        surface.blit(tile,(x * self.tmxdata.tilewidth, y * self.tmxdata.tileheight))

    def makemap(self):
        temp_surface = pygame.Surface((self.width,self.height))
        self.render(temp_surface)
        return temp_surface

Is there a way of "zooming in" on the sprites in order to get the expected look?


texts: How to test if procedurally generated level for infinite runner can be passed?

texts:
I have a 2D infinite runner platformer game built in Unity 5, where the level procedurally generates itself. I need to check if it is possible to pass the holes on the level.

How could I do that?


texts: How can I enhance this keyboard handler class (remove global variables)

texts:
I would like to enhance my keyboard class to be more tight and encapsulated. The first issue I've addressed is Singleton design pattern. I've done this as follows:

/*** inside keyboard.h ***/
class Keyboard
{
public:
    static Keyboard* Instance(){
        if(s_pInstance == NULL)
            s_pInstance = new Keyboard;
        return s_pInstance;
    }
    ...
private:
    static Keyboard* s_pInstance;
    Keyboard() {}
    ...
};

/*** inside keyboard.cpp ***/
#include "keyboard.h"

Keyboard* Keyboard::s_pInstance = NULL;
...

The design pattern works just fine. Now in while(true) I can do

while(Window is Open){
...
    if ( Keyboard::Instance()->isKeyDown() ){
        if ( Keyboard::Instance()->m_key == GLFW_KEY_E )
            std::cout << "E is pressed ..." << std::endl;
    }
...
}

In GLFW, I have to declare key_callback as static member function. To store keyboard actions, I've introduced global variables and every time I call any Keyboard function, I need to update those global variables as follows:

bool Keyboard::isKeyDown()
{
    // assign global variables to data members
    update(g_key, g_scancode, g_action, g_mode);

    if( m_action == GLFW_PRESS ){
        std::cout << "Key down..." << std::endl;
        ...
        // reset global variables
        m_action = -1;
        g_action = -1;
        return true;
    }

    return false;
}

void Keyboard::update(int k, int s, int a, int m)
{
    m_key      = k;
    m_scancode = s;
    m_action   = a;
    m_mode     = m;
}

The code works but I don't believe this is the right way to encapsulate my class. Any suggestion how to remove these global variables which is a consequence due to using static function?

This is the full code

#ifndef _KEYBOARD_H
#define _KEYBOARD_H

#include <GLFW/glfw3.h>

class Keyboard
{
public:

    static Keyboard* Instance(){
        if(s_pInstance == NULL)
            s_pInstance = new Keyboard;
        return s_pInstance;
    }
    void init(GLFWwindow* window);
    void update();
    bool isKeyDown();
    bool isKeyUp();

    int m_key, m_scancode, m_action, m_mode;
private:
    static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);

    GLFWwindow* m_pWindow;
    Keyboard() {}
    static Keyboard* s_pInstance;
    bool keys[1024];

    void update(int, int, int, int);

};

#endif

keyboard.cpp is

#include "keyboard.h"
#include <iostream>

Keyboard* Keyboard::s_pInstance = NULL;

int g_key, g_scancode, g_action, g_mode;

void Keyboard::init(GLFWwindow* window)
{
    m_pWindow = window;
    glfwSetKeyCallback(window, key_callback);
}

void Keyboard::key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
{
    g_key      = key;
    g_scancode = scancode;
    g_action   = action;
    g_mode     = mode;
}

bool Keyboard::isKeyDown()
{
    update(g_key, g_scancode, g_action, g_mode);

    if( m_action == GLFW_PRESS ){
        std::cout << "Key down..." << std::endl;
        keys[m_key] = true;

        m_action = -1;
        g_action = -1;
        return true;
    }

    return false;
}

bool Keyboard::isKeyUp()
{
    update(g_key, g_scancode, g_action, g_mode);

    if( m_action == GLFW_RELEASE ){
        std::cout << "Key up..." << std::endl;
        keys[m_key] = false;

        m_action = -1;
        g_action = -1;
        return true;
    }

    return false;
}

void Keyboard::update(int k, int s, int a, int m)
{
    m_key      = k;
    m_scancode = s;
    m_action   = a;
    m_mode     = m;
}


texts:
I am working on a small game, I need to add an unlimited inventory to the game but I am not sure how to do it.

I have an inventory system with a specific amount of slots, here it is:

<?xml version="1.0"?>
<player>
 <username> XXX </username>
 <password> XXX </password>
 <slot1> X </slot1>
 <slot2> X </slot2>
 <slot3> X </slot3>
 <slot4> X </slot4>
 <slot5> X </slot5>
</player>

I am open to switching to SQL or another data storage system, but I need a solution that would let players have as many items in the inventory as they would like; with no limit.


texts:
Is there a way to request a CS 1.6, CS:Sourse or CS:GO servers to get the location coordinates of the recent deaths of players on the game map?

PS I'm using C# for my project


texts:
I have created a game that has a ghost that mimics the movement of the player after 10 seconds. The movements are stored in a list and i use a foreach loop to go through the commands. The ghost mimics the movements but it does the movements way too fast, in split second from spawn time it catches up to my current movement. How do i slow down the foreach so that it only does a command every half a second? I don't know how else to do it.
Please help

this is what i tried :
The foreach runs inside the update method

DateTime dt = DateTime.Now;

        foreach ( string commandDirection in ghostMovements )
        {
            int mapX = ( int )( ghostPostition.X / scalingFactor );
            int mapY = ( int )( ghostPostition.Y / scalingFactor );

            // If the dt is the same as current time
            if ( dt == DateTime.Now )
            {
                if ( commandDirection == "left" )
                {
                    switch ( ghostDirection )
                    {
                        case ghostFacingUp:
                            angle = 1.6f;
                            ghostDirection = ghostFacingRight;
                            Program.form.direction = "";
                            dt.AddMilliseconds( 500 );// add half a second to dt
                            break;

                        case ghostFacingRight:
                            angle = 3.15f;
                            ghostDirection = ghostFacingDown;
                            Program.form.direction = "";
                            dt.AddMilliseconds( 500 );
                            break;

                        case ghostFacingDown:
                            angle = -1.6f;
                            ghostDirection = ghostFacingLeft;
                            Program.form.direction = "";
                            dt.AddMilliseconds( 500 );
                            break;

                        case ghostFacingLeft:
                            angle = 0.0f;
                            ghostDirection = ghostFacingUp;
                            Program.form.direction = "";
                            dt.AddMilliseconds( 500 );
                            break;
                    }
                }
            }
        }


texts: Get position of point on circumference of circle, given an angle?

texts: I would like to know how to get a specific point on the circumference of a circle, given an angle. The diameter of the circle is 1, and the center point of the circle is { X: 0.5, Y: 0.5 }.


texts: What's the technology that allows programming inside a game?

texts:
There are some games which allow the player to write/create scripts in-game, for example: Space engineers or Psi.

I want to use something similar to either one, but I've had a hard time finding information so my question is:

Is there a branch of programming that covers the ability of a software once compiled to run new code created by the user?

By branch of programming I mean something like PTG (Procedural Terrain Generation).

To avoid the too broad of a question or opinion based, let me clearly state that I'm not looking for guides or places to learn, I want the name or definition (if one exists) of the technology involved.


texts:
I wanted to ask a question regarding data persistence strategies for an MMO.  I have some experience in the games industry with social synchronous games.  At Zynga, we stored static proto data in XML on both the client and the server and stored instance/runtime data in membase.  For clarity sake, proto data for a Potion would be PotionName or MaxCharges, while runtime/instance data would be something like ChargesRemaining.  So basically, if a player picks up a potion the instance is (via prediction) created from XML data on the client, the request gets sent to the server where the instance is created from XML and then added to membase.

Is the same strategy that would be used for soemthing like an MMO?  Would it be feasible to have static proto data in some kind of in-memory no-sql database on both client and server with instance data being stored on the server in a more enterprise level database?  Or should all data (proto/instance) be stored on the server and the client gets everything from server?

I know a lot of this might on certain game requirements, however, i'm basically looking for some general opinion/best practices here if there are any.


texts: How do display a "mucus spreading" effect in a 2D environment?

texts:
Here is an example of such a mucus spreading. The substance is spread around the source (in this example, the source would be the main alien building).

The game is starcraft, the purple substance is called creep.

How this kind of substance spreading would be achieved in a top down 2D environment? Recalculating the substance progression and regenerate the effect on the fly each frame or rather use a large collection of tiles or something else?


texts: Is this a good way of separating graphics from game logic?

texts:
My current architecture for me game engine looks like this, though it is not accurate:

Everything graphics related is done in by GraphicsEngine, and through its components, like Material, Mesh, etc). My problem is that I want to store the pointers in RenderData, but I have to include the Mesh, Material etc header files, which have included glew.

I currently change an objects material using GetRenderer().SetMaterial("xyz"), which sets a string in the renderData, to be processed by the graphics engine; then the correct pointer will be set, if it exists. This is not so modular, because the scene has graphics related files included, like glew. This is a problem.

My only solution is to store indices in RenderData. There wont be a material pointer, but instead, an index where the material is in the GraphicsEngines material store. This way, RenderData is just a "blind" integer and string store, in which the Renderer egy the GraphicsEngine works.

Is this a good solution?

Meshes have VertexData members (position, normal, texture). When I call GraphicEngine.CreateMesh(), passing the MeshName and FileName, where should the file processing go? I use Tiny Obj Loader, and I don't know where I should include it, and call its function.

I call the function from inside GraphicsEngine, then I transform the returned structures to my Mesh's structure, which I pass to the Mesh's constructor. The initialised list will assign it to the corresponding member variable. Inside Mesh, I pass the FileName to the Mesh constructor, and let it handle it all by itself. I think the first solution is better, but I don't really know why.

Maybe using GraphicsEngine to "create" assets is better than GraphicsEngine commanding assets to "be created"; but this is just a personal feeling. Which solution is better?


texts: How can I determine the card possibilities for a game of Scopa?

texts:
In the game of Scopa, at the player's turn, there could be anywhere from 0 to 39 cards on the table (although 10+ is an extreme). I'm trying to figure out the best way to figure out possibilities for the player to pick up cards off the table. Also, in Scopa, you can only pickup cards off the table if there's 1+ cards on the table that add to equal the value of the card in your hand.

Currently, I've got something close to:

for (Card card : cardsOnTable) {
    for (Card card2 : cardsOnTable) {
        if (card2 != card) {
           if (card.getValue() + card2.getValue() == cardInHandValue) {
              //Add to list of possibilities.
           }
        }
    }
}

But that only works out while checking the table for possibilities of two cards. The problem is that there could be possibilities of 3, 4, etc. cards, and that detecting how many cards it needs to check (how many nested loops) doesn't seem possible. What method could I go about using to check for card possibilities?


texts: Java Buffers and OpenGL ES 2.0 (Android)

texts:
I've been trying to come up with a good solution for preloading textures asynchronously, but in Android with OpenGL ES you cannot create a texture out of context.

Would the proper solution be to load up a ByteBuffer with data from my png image, then when I'm back on the render thread call glTexImage2D? What I don't understand is whether or not OpenGL will actually copy the buffer into it's own location, or directly access mine. The latter approach would be ideal.

Could anyone give me clarification?


texts: Render texture seems to ignore camera background type

texts:
I'm currently trying to pull a fog of war for an rts game, and planned it like this. (Unity 2020.2.7, URP 10.3.1)

Use units field of view to generate a texture of what is seen (alpha 0).
Create other render texture to generate fog (alpha > 0  && alpha < 1) by not clearing camera buffer.
Use the mask made between the two textures to cut the fog of war (alpha 1).

Now i'm currently stuck at the 2nd step. Please check the image

As you can see, the camera is doing what I want, but the render texture somehow clears the buffer, which  just gives me the "Use units field of view to generate a texture of what is seen (alpha 0)." part again.
This whole buffer thing has been hard to understand, i'm not sure if this implementation is right or not.
I would be really thankful for any pointers given! :D
Cheers guys!


texts: Merging OpenGL rendering result with other graphical elements like user interface. Concepts

texts:
For my application, there are several elements drawing: An user interface elements, and several libraries for rendering part of the content of the window. Lets imagine some kind of Google Earth where a library render the earth geoid and several buttons and texts on top (possibly with transparency).

Something like that seem trivial, but it is not, cause OpenGL rendering on double-buffer at ~60fps and GUI elements are redrawn only on demand/changes for small portion of the window. One is by GPU and the other by CPU. One use a endless main loop that peek event, the other stay blocked until some event happens.

The idea is to draw the 3D elements on an internal buffer (in Thread A) and from the QT user interface (Thread B) just take the picture and put it at its correct place. Thread A and B could also have some mutex/signal to synchronize.

Questions are:

What are the correct concepts involved? FBO? PBO? Any other?
Where to found up-to-date information about how to implements it correctly. (meaning for example PBO with OpenGL 3+, not using ARB or deprecated stuff).
Is this image transfer a good idea? any better solution? what about efficiency implications?

As a starting hypothesis (for simplification), I could make modification on any library/source as required.


texts: Face-Click Detection ( like in Minecraft )

texts:
I am working on a box-based game engine like minecraft and I was wondering how to detect the "clicked face" when placing blocks.

I have created this engine in C++ ( DirectX / D3D ), C# ( XNA ) and Flash ( away3d & papervision3d ).

The engine code is pretty much the same on each, however as one is C# and the other C++ I'm just looking for the pseudo code, theory or advice on how to "snap" placed blocks on the face that has been clicked on.

How should I get its orientation and then place a block on that face in that position with the corresponding orientation.

UPDATE

For now, I've decided to go with a simple but effective method:

First I've remembered the basic 3D to 2D Projection Algorythm.

If I now have a click-point on the screen, I can simply trace a line from the camera ( eye ) through the screen, up to a specific distance.

With this line "in mind" and a modified ( 3D ) version of Bresenham's ( 2D ) line algorithm,
I was now able to see, if my imagined line is "pointing" onto a Block in my 3D grid.

thx for all of your suggestions.

UPDATE 2

I hope it explains my solution. ( red is the original algorythm, green is my modified version )

also: with "rounded" i mean that the original algorythm is just rounding the x-y-factor-value to get the nearest pixel. hope u guys know what i'm talking about.


texts:
There is an idea for (soft) sf strategy game following me for a long time but I need to get a grasp of some math before moving further with it.

Lets assume there is a spaceship traveling (in space) with some velocity and its engines can generate some acceleration - with maximum acceleration much smaller in magnitude than obtainable velocity. Now given the planned use of engine (acceleration in time) I think ti is fairly straightforward to calculate movement of the ship.

But the problem I need to solve is reverse - given starting position, velocity and desired destination I need to find a plan of engine usage (acceleration over time) that will guide the ship to the destination in minimal time.

There may be some complications like

The ship can only accelerate in one direction and turning (changing direction) takes time
There are some large bodies with gravitational pull that affects ship course
The destination point is moving in time - for example it is relative to planet or moon orbiting larger body
The timing is important - for example the ship is flying in fleet and need to arrive on target at roughly same time as her companions

Now I do not expect to get ready to use solution but my question is where I could look for clues? What I should study? What similar problems or related algorithms can help?

As this is for a game the solution may be simplified and even involve some "cheating" that would not work in real life.


texts:
Let's say we have a game, with enemies you fight, items to get and also chests to find and loot. Imagine a RPG game if you will.
We also have a table with x items that the player can loot from these mentioned chests. Some of these items are "one drop only", while others can drop more than one time. We might set that as a variable in the table.
Now to the question: When would you scatter the items in the table to the chests?

Would you do this as soon as the level loads?
Would you do a lookup when the player opened a chest?

As far as I see it, if you scatter the items when the level starts, the player could miss a unique item, if the player skipped that specific chest containing that unique one-time-only item.
But, if you do a lookup when the player opens a chest, the player does not need to worry (if the player knew exactly how it was coded) about actually missing unique items.
How would you handle this design wise? Is it ok for players to miss unique items for being lazy/bad/unlucky? Or, do we always want the player to be able to get just about all the items in this table at one point?
Which way would you prefer as a dev? Which way would you prefer as a player? Have I missed an important factor, a third way to handle it, or something else?


texts: How can I change the anchor point of a Pyglet sprite?

texts:
while trying to make my game, I noticed that you can't change the anchor point of Sprites in pyglet.
I use some convoluted way(see bottom of the post) to draw my minimap(WIP) so that the rooms are centered and lined-up correctly, however, I thought of the following occurence.

I'll be using the mouse-pointer to direct a 2D person from the top. However, if the anchor point of a sprite is the bottom-left corner of the orginal image, how can you make it feel as though the anchor point is in the middle of the sprite.

This may not be so important for the Player, but it would be hell to algorithmically controll the NPC's that fight.

Any help and input appreciated.

Code:

        pic_img = image.load(imgPath)
        picX, picY = window.width/2,window.height/2
        pic = pyglet.sprite.Sprite(pic_img, x=picX, y=picY)
        pic.rotation = roomType.ImageRotation

        if pic.rotation == 0:
            picX = picX - pic.width / 2
            picY = picY - pic.height / 2
        elif pic.rotation == 90:
            picX = picX - pic.width / 2
            picY = picY + pic.height / 2
        elif pic.rotation == 180:
            picX = picX + pic.width / 2
            picY = picY + pic.height / 2

        elif pic.rotation == 270 or pic.rotation == -90:
            picX = picX + pic.width / 2
            picY = picY - pic.height / 2
        pic.x,pic.y = picX, picY


texts: Ground texture comes up blurry using the UV Rect Tool

texts:
Im trying to recreate the ground as this sample sprite sheet: https://opengameart.org/content/post-apocalyptic-expansion

I downloaded the sprite sheet and extracted the top left block and saved it separately and added it as a default object not Sprite/UI. I then added a UI > Raw Image to my scene, added the imported texture. But as I expand it, it becomes blurry, even the UV rect does not seem to help. I though the UV rect was supposed to repeat the texture.

Am I doing this wrong?


texts: How to construct a propeller clock in Unity?

texts:
I am considering the possibility of using Unity to construct a propeller clock https://www.youtube.com/watch?v=-6JnAxTXApw .
It's an array of LEDs on a PCB board connected to motor that spins at a high RPM. The LEDS flash on and off such that it generates the appearance of a clock face.
So far, I've tried turning a red pointer in a circular path with high RPM in Unity, but I don't get an image of a circular red disc. Instead I see a pointer showing random discrete movement in a circular path.
Is there any suggestion to rectify this issue?


texts:
I use in Java Artemis(entity system library) and Slick2D(graphics library) for a game.
Now I wonder me, how I should handle graphics(sprites, textures...).
In the demos of the page from Artemis it was made so:

SourceCode

I hope the diagram is good enough.
So someone asks now "Whats the problem ?":
The Problem is, that this method is not very efficient and it feels not very good, because:

The spatial forms are created and initialized at run time
The spatial forms are created individually for every entity(Load
textures or create a shape...)

I think there a better ways, so I hope someone have a better idea.
And if someone have the idea to make simply a sprite or a texture component, that's not a solution, because some entities have for example more textures than one.

And a supplementary question, how I should handle animated graphics ?

Thanks for reading :) and sorry for my bad English :(


texts: I have a large number of png files that I need resize so the sides are in powers of 2 without stretching the images in those files. Basically add/remove white-space so the image is in the upper left corner of the image and it is sized appropriately. Because of the large number of files I would rather not edit them individually if at all possible.


texts: Different shader programs but same buffer drawing

texts:
I've setup 3 different instances of the same shader code (e.g. I've compiled the code into 3 separate programs)

For each program, I've gone through the whole route of something like this:

//Setup
gl.useProgram(program);
const buffer = gl.createBuffer();
const location = gl.getAttribLocation(program, aName);

//Upload (each uses the buffer/location it created in Setup
gl.useProgram(program);
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, data, usagePattern);
gl.vertexAttribPointer(location, nComponents, dataType, false, 0, 0);
gl.enableVertexAttribArray(location);

//Draw
gl.useProgram(program);
gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);

However, no matter what I pass into data - e.g. different sized quads, all three are the same size.

Notably, changes to other uniforms/attributes like matrices and color do change per object

How do I change this so that the changes to data per instance will be drawn properly?

(I realize if they actually use the same shader I should maybe keep a reference to one program and use some sort of buffer pool- but I'm not there yet, just getting started with WebGL)


texts:
I copied a script off the internet and changed it a bit:

void LateUpdate()
{
    if (target)
    {
        x += Input.GetAxis("Mouse X") * xSpeed * distance * 0.02f;
        y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;

        y = ClampAngle(y, yMinLimit, yMaxLimit);

        Quaternion rotation = Quaternion.Euler(y, x, 0);

        RaycastHit hit;
        //Over here is probably where the problem occurs
        if (Physics.Linecast(target.position, transform.position, out hit))
        {
            if (!hit.collider.CompareTag("Player"))
            {
                distance = hit.distance;
            }
        }
        else
        {
            distance = 10f;
        }
        Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
        Vector3 position = rotation * negDistance + target.position;

        transform.rotation = rotation;
        transform.position = position;
    }
}

I made it so that if the RaycastHit's collider is null, that the distance would be reset at 10. Whenever the RaycastHit is hit, it will move the camera distance closer to the player as to get in front of the object blocking the view. All nice and dandy, but when I run the game, when I get in front of and object, it works as planned but it is very stuttery, I have a hunch it has something to do with the if statement for the linecast but I have no idea how to fix it, I tried changing LateUpdate to FixedUpdate and to Update but it still occurs. I'm still new to unity and c# so forgive me if this was a simple mistake.

Here is a video showing it happening:
https://www.youtube.com/watch?v=n6ffVmq1UWs


texts: Is there a "Least Terrible Method" for sharing Entities over Network?

texts:
(Preface: Using C++, Box2D, and built UDP client and server classes that are reasonable efficient for a built-from-scratch game using client-server model.)

This question is specifically in regards to an MMORPG (WoW, Rift, Maplestory) / ARPG (Diablo, Path of Exile, etc) setup. My conundrum is this: How to efficiently share only what the client needs to know, without running the server (performance) into the floor?

To elaborate, I have narrowed down to three separate approaches, but all of them feel horrifyingly inefficient and "iteration-spammy". I will detail each below as succintly as I can, though (hopefully) with enough actionable information. My concern is keeping the CPU time as short as possible as a physical server may be running 20+ zones (or "level", if that makes more sense). I will not be sending full data each time, more of full data "as needed" (ex: id, health, x/y/z, velocity), then changes as they occur (ex: [id, x/y/z], [id, new health], [id, velocity]).

To keep things consistent, I will give the following example "setup" that will be referenced with each approach.

Map size is 20 'units' by 6 'units'
Players / NPCS are 0.5 'units'
squared.
Sight Range: 1.5 'units' from player center, in a circle.
Number of Players: 3
Number of NPCs: 10

Approach A: Entity-based Checking

This consists of the server either iterating over all NPCs from each player's perspective (or all players from each NPC's perspective). This would look something like "for each player, loop through npcs and check if within n "units" of player. Once player's iteration is done, create and send payload to said player before next player's iteration" (where 'n' = sight range). This is fine in principle, until there are 10-20 players and 100+ NPCs. That ends up with 1,000+ iterations occurring each round (1-3 rounds per second). Again, not horrible by iteself, but 20+ zones could make this exceptionally slow and ruining the player experience.

Approach B: Tile-based Checking

By the use of tiles of size 'n' squared (again, 'n' = sight range), divide up the map. With the example map size, let's say it becomes 10 nearly perfectly fitting tiles. For this, the server would maintain the data per tile, then send concatenated entity data (e.g. vector) of tiles which the player is inside and adjacent tiles. This does have the advantage of breaking up the into much more managable areas, though it feels like maintaining the location checking for these tiles may become just as tedious as Approach A in that each 'round' (again, 1-3 rounds per second) the bounds checking will need to be performed against each entity multiplied by the number of tiles; 10 tiles x (10 NPCs + 3 Players) = 130 possible iterations.

Approach C: Lazy Physics-based Checking

I believe this is either the least terrible or the absolute most terrible (with no middle ground), though I cannot definitively prove which side of the fence it is standing. This would consist of creating an invisible circle around the player equal to their sight range as a radius. This has the advantage of using the Box2D collision detection and 'sensor' functionality to lazily determine what is and is not in range. Though, given what I've seen from working with Box2D, this is likely similar to simply iterating over the Entities themselves. The obvious con would be the requirement to either maintain a list of 'visible' entities or simply rebuild it each 'round'.

If you made it this far, you are a scholar and a saint. I appreciate any feedback, insight, or constructive criticism.

Again, in all seriousness and sincerity, thank you for reading!


texts:
I saw a lot oft tutorials about the mvc pattern, but always it was only a small example/Situation explained.
There was always only one model, one controller and one view.
But what if I have a lot oft models with complex logic, I cant put all the rendering code in one view and all the logic code in one controller.
How I split all in smaller pieces, because the models logic depends in each other(for example collision).
Know someone a good tutorial, or example game that explains this pattern in advanced games?


texts: How common is arachnophobia among gamers?

texts:
I am currently designing a spider as a monster for my game. During my research I found that there seems to be a surprisingly large amount of players who suffer from extreme arachnophobia and get panic attacks when they see a spider on their screen, even when in a context of a video game. This makes it impossible for them to enjoy games which feature spiders. There is a whole community of modders who work on mods to remove any spiders from popular games and thus make them playable for these people.

So I wondered if I might alienate a part of my target audience by adding spiders to my game. Are there any reliable numbers about how large the community of arachnophobic gamers really is?


texts: Space partitioning when everything is moving

texts:
Background

Together with a friend I'm working on a 2D game that is set in space. To make it as immersive and interactive as possible we want there to be thousands of objects freely floating around, some clustered together, others adrift in empty space.

Challenge

To unburden the rendering and physics engine we need to implement some sort of spatial partitioning. There are two challenges we have to overcome. The first challenge is that everything is moving so reconstructing/updating the data structure has to be extremely cheap since it will have to be done every frame. The second challenge is the distribution of objects, as said before there might be clusters of objects together and vast bits of empty space and to make it even worse there is no boundary to space.

Existing technologies

I've looked at existing techniques like BSP-Trees, QuadTrees, kd-Trees and even R-Trees but as far as I can tell these data structures aren't a perfect fit since updating a lot of objects that have moved to other cells is relatively expensive.

What I've tried

I made the decision that I need a data structure that is more geared toward rapid insertion/update than on giving back the least amount of possible hits given a query. For that purpose I made the cells implicit so each object, given it's position, can calculate in which cell(s) it should be. Then I use a HashMap that maps cell-coordinates to an ArrayList (the contents of the cell). This works fairly well since there is no memory lost on 'empty' cells and its easy to calculate which cells to inspect. However creating all those ArrayLists (worst case N) is expensive and so is growing the HashMap a lot of times (although that is slightly mitigated by giving it a large initial capacity).

Problem

OK so this works but still isn't very fast. Now I can try to micro-optimize the JAVA code. However I'm not expecting too much of that since the profiler tells me that most time is spent in creating all those objects that I use to store the cells. I'm hoping that there are some other tricks/algorithms out there that make this a lot faster so here is what my ideal data structure looks like:

The number one priority is fast updating/reconstructing of the entire data structure
Its less important to finely divide the objects into equally sized bins, we can draw a few extra objects and do a few extra collision checks if that means that updating is a little bit faster
Memory is not really important (PC game)


texts:
Is there a way to retrieve the deph from directional lights ? I can access the _ShadowMapTexture but this is not the depth.

I found how to access the shadow map of, I think, every light type by using the defines such as SHADOW_ATTENUATION(a) or directly the _ShadowMapTexture, everything is located in the built-in shaders.

But I am wondering how could I access the depth of those lighting type. I found a way to access it for the spot light this way : _ShadowCoord.z which gives the depth scaled with _ShadowCoord.w, which could be considered to the far plane, but am I right ?

How could I do the same for the other light types such as directional or point lights ? For the moment I am stuck with directional lights, any clues ?

Because if I try to access the depth for a directional light by using _ShadowCoord.z it seems that it's more related to the depth view and not the light. Here I am, totally stuck with this directional lights.


texts: Targeting a vehicle with complex movement?

texts:
Targeting a vehicle with known constant velocity is simple, and collision is guaranteed (see Predicting enemy position in order to have an object lead its target, Find meeting point of 2 objects in 2D, knowing (constant) speed and slope). Imprecise AI can be modeled by adding a small error factor.

But how would one go about targeting a vehicle whose movements are more complex? Perhaps it's evading the AI or another game object.

I've been thinking about how I'd do it myself in a FPS (in which bullets have finite speed) and think there might need to be at least couple of targeting modes based on the target's movement in the previous second or so:

If it's near linear (peak acceleration in a certain range) target with the linear model
If it's highly irregular (perhaps size of bounding box of recent positions could be used?) , target at an average

For now I can assume 2d space, AI is stationary and projectile is unguided and moves linearly.


texts:
I'm working on a 3D game in Unity.  The primary view is a top-down view, but I am also looking to do target profiles that are true animated versions that reflect the actions of the target.  The easiest way to do this, as far as I can see, is to create a second camera, a set offset from my target, facing at it.  But how do I show the view from that camera in a small area of the screen?

A possibly related question - how to handle a mini-map?  I considered doing this the same way - with a camera fixed high above the character that would show the area around him, but there may be a better way to do this, I'm open to any suggestions.


texts: client-server network model for top-down WASD game

texts:
I'm currently working on a multiplayer game with top-down camera view and WASD player control, similar to Bloodline Champions. Projectiles, spawned by players are relatively slow and clearly visible, e.g. a fireball. The most difficult part so far - designing an appropriate networking model. The main goal is to find a fair balance between state consistency and player input lag.
Three alternatives I've came with so far are as follows:

Plain Authoritative server
Clients simply send user input to server, which advances the world according to the input provided, and then sends the latest state to all clients. Clients interpolate between two last received states to provide smooth movement.
This variant provides perfect consistency, since all clients see the same world state, but user's input feedback time suffers a lot, because total lag sums from the following parts:

Sample lag = T(client sends sampled command) - T(command was sampled)
Client-Server lag = T(packet was received by server) - T(packet was sent by client)
Simulation lag = T(command was simulated by server) - T(command was received by server)
Replication lag = T(state was sent by server) - T(command was simulated by server)
Server-Client lag = T(state was received by client) - T(state was sent by server)
Interpolation lag = time interval between two states: the last received and the one received before that, so that client can interpolate between them ~ server send interval

Authoritative server with Prediction
To minimize player feedback lag, client code has to use some prediction, i.e. execute sampled commands before updated state is received from server. The drawback here is that it creates state inconsistency between entity controlled by the player and the rest of the world, since the former is in the present and the later is in the past.
First person games with instant-hit weapons can use some lag compensation algorithms, since the player sees only some portion of his or her surrounding and most of the time does not sees bullets. But in top-down viewed games with slowly moving visible projectiles,  those correction can be considered as unfair and buggy.

Thus, with authoritative server we have to choose between better state consistency and smaller input lag.

Peer-to-peer with server
The only other solution I can come with is where client broadcasts sampled commands to other clients and server, but instead of immediately executing them, client delays them at a constant amount of time, e.g. 150ms.
Other peers (including server) do not execute received commands immediately either. Each peer computes time, that is left until 150ms and waits that time:

time_to_wait = 150 - (peer_received_time - client_sent_time)

Thus, every command is, theoretically, executed simultaneously on every peer, which provides good state consistency and moderate input lag. To address possible unsync, server periodically sends its state to all clients.
Problems with this solutions include:

much more complicated code base.
much more cheating-prone client, since it contains the same logic as the server.
all players' IPs are exposed to all others.

Problem
I tried to find any info about BLC or LoL net models, but all I've found so far is that they use client-server architecture without any P2P communications.
I personally prefer the Auth-with-prediction variant, but have to stick with P2P one for now, since I have no idea how to solve inconsistency caused by prediction. Is there any way to compensate this inconsistency without increasing input lag too much, or I have to use P2P solution?


texts: Planet Surface Rendering: Precision issues

texts:
I have been experimenting with C++ and OpenGL, and I am currently writing a program that renders the surface of a planet; specifically, our moon. It's a modified version of the GPU Gems implementation of Geometry Clipmaps which is normalized to the unit sphere and then offset by a heightmap in the terrain's vertex shader. On small scale scale this works rather well:

However, I want to scale this up to the size of the actual moon. Unfortunately, when I do so, stepping artifacts appear:

Now I am (almost) certain that this is simply an issue with floating point precision; 32-bit floats just simply don't have enough precision for planets of this size. However, I am in an interesting situation where I cannot simply change one of my numbers to a double to gain more precision. My vertex shader code is this:

layout (location = 0) in vec3 VertexPosition;

uniform mat4 MVP; //projection and camera rotation matrix
uniform mat4 PLM; //scale and translation matrix
uniform dmat4 SurfaceRotationMatrix; //transforms vertices to be the correct position on surface

uniform samplerCube bump_map; //heightmap cubemap

uniform dvec3 PlayerLocation;

uniform double PlanetRadius;
uniform double TerrainHeightScalar;

void main(){

    //find the world space position of the flat grid (high precision)
    dvec4 worldSpacePosition = PLM * vec4(VertexPosition, 1.0);

    ...

    //offset the y position by the planets radius
    worldSpacePosition.y += PlanetRadius;

    //vertex position in relation to camera (located at origin)
    dvec4 OriginNormal = normalize(worldSpacePosition);
    //vertex position in relation to planets surface
    dvec4 surfaceHighP = SurfaceRotationMatrix * OriginNormal;
    //also calculate surface normals at this point
    dvec4 tangentHighP = SurfaceRotationMatrix * vec4(1.0, 0.0, 0.0, 1.0);
    dvec4 bitangentHighP = dvec4(cross(surfaceHighP.xyz, surfaceHighP.xyz), 1.0);

    // vvv I think this is the problem vvv
    // dvec4 surfaceHighP has to be cast to a vec3 (float) in order for the
    // shader to compile
    double height = texture(bump_map, vec3(surfaceHighP.xyz)).x;

    //set position by multiplying the normal by the distance the point should be from the surface
    worldSpacePosition.xyz = (PlanetRadius + height * TerrainHeightScalar) * OriginNormal.xyz;

    //move the position back to the origin
    worldSpacePosition.y -= PlanetRadius;

    //offset y position by the player's height (both statements are split for best precision)
    worldSpacePosition.y -= PlayerLocation.y;

    //final position: multiply by projection matrix
    gl_Position = MVP * vec4(worldSpacePosition);
}

OpenGL's texture() function only seems to take float parameters as an input. This makes me believe that this stepping is a result of the cast down to a lower-precision vector, where the program cannot distinguish the tiny change in angle between each grid position. At first I thought it might have been a texture precision error, so I tried switching the heightmap texture to an 8-bit copy but I didn't see any difference in step size or quantity. The texture filtering is linear, so the heights should be smoothly blended between one another, and at large scales big landforms like mountains and hills seem to have no associated problems.

Can anyone confirm that this cast in the texture() call is the reason for the stepping? If so, is there a way to pass high-precision numbers into a GLSL texture call, or, failing that, a solution to this problem that doesn't involve a complete redesign? I was thinking about maybe getting a weighted average of each neighboring "step", and then linearly interpolating between them, averaging between the areas where the float breaks down. Would something like that be possible, or is there a better alternative?


texts: Can the player character and static entities use behavior trees instead of state machines?

texts: When I read discussions about state machines vs. behavior trees, it is often in favor of using one over the other. However, this seems odd to me that you wouldn't still need a state machine to manage the player character and static game entities (weapons, equipment, food, money, etc.). Do behavior trees translate to those concepts as well, even though they aren't technically AI?


texts: Can't load own .obj-files from Blender to DX11

texts:
I'm currently trying to import objects to my game. My problem is that I'm able to load objects from online-sites but it doesn't work for my own objects. It gives me an error:

  Debug assertion failes. Expression: vector subscript out of range.

So I watched the value of my vector and realized that the faces are empty. The difference between my obj and these from the internet are that in mine the faces are like:

  f 53//51 69//51 54//51

And in the files from online they look like:

  f 3551/5154/3181 3666/5155/3182 3543/5151/3178

What do I wrong at exporting my blender-object. I took a screenshot of my settings:

I hope you can help me.


texts:
I've been writing an OpenGL renderer as a learning process for the past few weeks. Now I wanted to test my renderer against some known numbers, for instance:

How many vertices/tris should it be able to render at 60 fps (rough estimate?)
How many draw calls before it is expected to drops the fps?
etc?

This is all assuming simple shaders (one that outputs a single texture) and a reasonable video card (3~4 yrs old).


texts: get the new vertices after rotating in JOGL

texts:
I had rotate an object with openGL (JOGL).
Is there a simply way how I can get the new vertices?


texts: How to make expanding ring with constant thickness?

texts:
I need to generate this burst or (donut-shaped) pulse.
I'm having a difficult time how to generate such shape.
At first, I was thinking of scaling the image but that didnt work out because the line or "diameter" of the donut shape gets bigger accordingly..

https://www.youtube.com/watch?v=ewnEE5mt1ZM


texts:
Pretty short question, when I load unity, I get this error:

Is this fixable with driver downloads, or do I need a new PC?*
*if so, how do I find out my computer's default built-in graphics driver?


texts:
Thinking along the lines of this question, and the too awesome to use trope in general.  Why do game designers want to include consumable items in their games?

Mortal Kombat 11 got me thinking...  Why include consumables that give you an edge in battle at all?

I’m looking for concrete answers for what it is that consumables add to gameplay, whether it be about those that one can buy with real money, or those that you just get by playing the game, or whether they are available in limited or unlimited quantities.


texts:
NOTE: I am moving this question here from Stack Overflow because I feel it belongs better on this forum. I am deleting the original question from Stack Overflow.

I'm working on a game in Slick2D and I want to have some versatility with the resolutions I can use for fullscreen. Is there a way to make the game's fullscreen add black bars around the game instead of stretching the game to whatever resolution the graphics card can support for fullscreen? I'm not terribly familiar with openGL so if the only way to fix that requires openGL, I would appreciate some detailed explanation on how to implement the code. Currently I'm using the

arg0.setDisplayMode(X_resolution, Y_resolution, true); //arg0 is my AppGameContainer

method. But it means I have to stretch my game to one of the compatible resolutions.


texts: Unity: Adjusting 2D physics for different mobile resolutions

texts:
I created a test project to see how different mobile resolutions affects Unity's 2D Physics.

They way I handled the resolutions was to contain all the objects (including non-UI objects) in a Canvas and use a Canvas Scaler component to adjust for multiple resolutions. Although this approach is probably not one of the ways the Canvas was not meant to be used, it works well when working with a single orientation.

Despite the quick solution to handle the multiple resolutions, there seems to be the issue of the physics acting differently depending on what aspect ratio is being used.

Images can be viewed here: http://imgur.com/a/p5wmf

The green and blue blocks both have the Rigidbody2D and Box Collider 2D components. The floor (big white block) only has a Box Collider 2D component.

As you can see from the images above, the different aspect ratios cause the blocks to collide with the floor at different times. Also, when using rigidbody.addforce in the Y direction, the different aspect ratios cause the blocks to jump at different heights.

Obviously these issues could cause an unfair advantage in a game with support for several resolutions.

So how would I go about adjusting the physics so that the blocks fall and jump at the same rates relative to the different resolutions?

Also if there is a more practical way to adjust for multiple resolutions that doesn't involve a plugin and doesn't break physics, let me know!


texts: Is Rigidbody needed and what move function to use in 2D games?

texts:
I don't really fully understand how to use rigidbody and which movement functions in a 2D game. There seems to be so many options and it's just a mess in my head right now. If I'm making a game like those classic 2D zelda games, do I need rigidbody at all? I don't think I will need any physics but I obviously need to check if two objects have collided so I can do some logic on them, like destroying an object on collision or hurt the player, or stop movement if player walks into a wall.

Is going with no Rigidbody and moving only with transform.translate a good choice with these types of games?


texts: Unity google play services login dont work properly

texts:
I have searched everywhere on the internet and I have found nothing about the problem I am encountering.

I am trying to implement google play services to my game (leaderboards especially) and I have made that "work" somehow. Here is the code:

void Start()
{
    PlayGamesPlatform.Activate ();

    Social.localUser.Authenticate((bool success) =>
    {
        if (success)
        {
            Debug.Log("Logging in: Success");
        }
        else
        {
            Debug.Log("Logging in: Failed");
        }
    });
}

The game opens properly and it shows that green window which then disappears and a "loading" icon appears turning in a circle. But after that it disappears too and the window which lists and ask you which account to link with the game does not appear, as it is supposed to do(which "ends" the logging in).

Any help would be much appreciated.


texts:
Given a point in space, a direction of travel, and a time since start, what's a convincing, non-sickening formula to simulate head bob? What's been successful in previous games? Has there been any research on what bobs induce sickness the least?

An example naive head bob formula, applied to the up axis:

http://www.wolframalpha.com/input/?i=abs%28sin%28x%29%29


texts: What is actually done by the deferred rendering pipeline in this context?

texts:
I have been reading a student's thesis regarding deferred rendering and have stumbled across a piece of his work that I couldn't quite understand.

The thesis; in chapter 1.3 it says:

  Stalker (see Figure 02) for example is using only deferred lighting
  to calculate their light accumulation due to complex lighting conditions in the environment, while the rest of
  the engine still runs in forward rendering

Could someone possibly explain what he means by this? What is the deferred pipeline actually being used for?