texts: Libgdx: How to setZIndex for pause dialog?

texts:
Pause dialog has to appear on top of the play screen, it has to appear on top of other objects.

I have tried to use

dialog.setZIndex(10); // or whatever number and I tried adding it in many places

It just doesn't work, how to make the dialog be on top of other objects? for a ccomplete version here

I'm using only one batch and the stage is used only to add background and dialog

  stage = new Stage();
  Gdx.input.setInputProcessor(stage);
  stage.addActor(bg); // somewhere else in the code
  stage.addActor(btnPause);
  camera.update();
  game.batch.setProjectionMatrix(camera.combined);
  stage.act(delta);
  stage.draw(); // and thats about it for stage
  game.batch.begin();
  font.setColor(Color.YELLOW);
  font.draw(game.batch, myScore + score, Gdx.graphics.getWidth(), camY);
  // and here I draw the game   game.batch.draw(game) and I'm using only one batch

I hope I didn't miss anything

If I put the game batch in state.RUN in an effort to hide objects when the pause dialogue appears, then when I resume, it will go to batch.end and exit the game

Pause

public void pause() {
 this.state = State.PAUSE;
 final Dialog dialogP = new Dialog("", skin, "pauseDialog") {};

 dialogP.setScale(4, 6);
 dialogP.setPosition(Align.center, Gdx.graphics.getHeight());

 dialogP.addAction(sequence(alpha(0),
  parallel(fadeIn(.5 f)),
  moveBy(0, -1000 f, .30 f, Interpolation.smooth),
  moveBy(0, 30 f, .40 f, Interpolation.smooth)));

 //PlayOn
 ImageButton btnPlayOn = UIFactory.createButton(txtrPlayOn);
 btnPlayOn.setSize(40, 40);
 btnPlayOn.setPosition(75, 75, Align.center);
 dialogP.addActor(btnPlayOn);

 //EndGame
 ImageButton btnEndGame = UIFactory.createButton(txtrEndGame);
 btnEndGame.setSize(40, 40);
 btnEndGame.setPosition(75, 55, Align.center);
 dialogP.addActor(btnEndGame);

 stage.addActor(dialogP);

 //playOnAction
 btnPlayOn.addListener(new ClickListener() {
  @Override
  public void clicked(InputEvent event, float x, float y) {
   dialogP.hide();
   resume();
  }
 });

 //EndGameAction
 //PlayButtonAcion
 btnEndGame.addListener(
  new InputListener() {
   @Override
   public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
    super.enter(event, x, y, pointer, fromActor);

    Actions.scaleTo(0.7 f, 0.7 f, 0.5 f, Interpolation.bounceOut);
    stage.addAction(Actions.sequence(Actions.moveBy(-stage.getWidth(), 0, .5 f), Actions.run(new Runnable() {
     @Override
     public void run() {
      game.setScreen(new MainMenuScreen(game));
     }
    })));

   }

  });

}

The basic principle is implemented from the accepted answer to this question


texts: Character jittering with this tile based collision code

texts:
I have been trying to get my collision code working for hours now but with every resource I have tried my character still jitters. First I tried using the platformer sample but my character still jittered up and down really quickly, even when standing still. Then I took to these forums and found this post and I used his code and eventually found out that in order for his to work you have to:

Move the character's position along the x-axis only.
Check if the character collided with something along the x-axis

Then do the same thing for the y axis. In other words, the character could only move one direction at a time and with my game there are a lot of different forces, velocities, accelerations, et cetera. all pulling on the target at once and this kind of solution didn't really work.

I heavily simplified the code in the sample and ended up with this:

Rectangle playerBounds = GetPlayerBounds(motion.Position.X, motion.Position.Y, characterWidth, characterHeight);

// Get the player's bounding rectangle and find neighboring tiles.
Rectangle bounds = playerBounds;
int leftTile = (int)Math.Floor((float)bounds.Left / TileSize);
int rightTile = (int)Math.Ceiling(((float)bounds.Right / TileSize)) - 1;
int topTile = (int)Math.Floor((float)bounds.Top / TileSize);
int bottomTile = (int)Math.Ceiling(((float)bounds.Bottom / TileSize)) - 1;

for (int y = topTile; y <= bottomTile; ++y) // For each potentially colliding tile,
{
    for (int x = leftTile; x <= rightTile; ++x)
    {
        Tile collision = stage.CustomLayer.GetTile(x, y);

        if (collision.Value == Tile.CollisionTile)
        {
            Vector2 depth = Extensions.GetIntersectionDepth(bounds, collision.Bounds); // Determine collision depth (with direction) and magnitude.

            if (depth != Vector2.Zero)
            {
                if (Math.Abs(depth.Y) < Math.Abs(depth.X)) // Resolve the collision along the shallow axis.
                {
                    motion.Position = new Vector2(motion.Position.X, motion.Position.Y + depth.Y); // Resolve the collision along the Y axis.
                }
                else // Ignore platforms.
                {
                    motion.Position = new Vector2(motion.Position.X + depth.X, motion.Position.Y); // Resolve the collision along the X axis.
                }

                bounds = playerBounds; // Perform further collisions with the new bounds.
            }
        }
    }
}

The code produces the jittering effect as well. I have debugged it for hours and I think I found the cause but I do not know how to fix it.

For example, if the character's Y position is 500 and is found to be colliding with a tile with a depth of 5 pixels, he will be pushed to Y position 495. At this time, though, the loop will continue based off of old topTile and bottomTile values and he may still be found to be colliding with those tiles, and will be pushed up to Y position of 490. Next time this function is called though when the character has moved back down to Y position of 495 due to gravity, he won't be colliding because of different initial topTile and bottomTile values and will continue moving downwards.

I believe this is what causes the jittering effect but I do not understand why it is happening to me. As far as I know, I am using the same algorithm as everyone else and their code doesn't produce any jittering. All my tiles are of equal size (32x32) and I am using the same GetIntersectionDepth method found in the platformer sample.

Thanks to anyone who can help me solve this problem.


texts: Given a RGB color x, how to find the most contrasting color y?

texts:
Possible Duplicate:
  Making a symbol appear on any colour

I have to mark a certain item in a way that will make it stick-out in the background. I need it to be surrounded with the color that contrasts the background as much as possible so it will pop out and easily noticeable by the player.

Lets say I know the background is color 'x', how do I find 'y' such that it will be very contrasting to 'x' and easy to notice in a background where 'x' is a dominant color?

I first thought about inverting color 'x' and then I noticed that when 'x' is a medium shade of gray, if I invert 'x' to get 'y', then 'y' is also a medium shade of gray which does not work.


texts: Tile Map Collision in 2D Platformer (C# Monogame)

texts:
I am trying my hand at making a small 2D platformer. Currently I am trying to implement collision on a tile map. I have been trying to experiment with different ideas but can not find a way for the life of me. Currently, bounding boxes have been set up around the player and the blocks.

My current algorithm is as follows:

        for (int i = 0; i < blockBound.GetLength(0); i++)
        {
            if (playerBound.Intersects(blockBound[i]))
            {

                if (playerBound.Bottom > blockBound[i].Top)
                {
                    jumping = false;
                    player.pos.Y = player.prevPos.Y;
                }
            }
        }

I have tried using an intersect amount by subtracting the blockBound[i].Top value from the playerBound.Bottom value and moving the player by that much back to their previous position but it only caused the player to move in and out of the block rapidly.

When doing the same thing with all sides, you could probably guess, always makes the collision code run.

Also with this code, when the player jumps, it appears to have somewhat of a jolt for lack of a better word when it begins jumping, compared to the normal smooth jump it has without any collision.

Is there a better way of doing this and if so, how?


texts: How do I create a view matrix directly from a quaternion and a position vector?

texts:
Given a quaternionic camera such that:

typedef struct
{
    vector3 upReference;
    vector3 rightReference;
    vector3 forwardReference;

    vector3 position;
    quaternion orientation;

    float pov;
} camera_t;

Where:

upReference, rightReference, forwardReference are always (0,1,0,
1,0,0, 0,0,-1) respectively
pov is the viewing angle

and quaternion is:

typedef struct
{
    float x, y, z, w;
} quaternion;

Is there some way to create a view matrix directly from all of this and skip gluLookAt?


texts:
I have a lot of experience with programming but I'm new in game development world, so I don't know what I don't know.

I want to create a MMORPG sandbox game. When I say sandbox game I have something in mind like Minecraft where you can make changes in the game world and they persist and all the players on the server can see them. Like if you plant a tree it will stay there even if you log out or if you dig the hole in the ground it will be there when you log out and other players would be able to see it.

For now I'm thinking about Unity as a game engine for this game. I also did some research and found some tutorials about RPG game creation. But I haven't found any information about how to create sandbox game. To be more precise about how to create editable world and how to save changes which were made to the initial game world.

Can you point me in the right direction? What should I search for? What would you suggest me to read so I would understand more about the things I'm getting in.


texts: OBB Collision Resolution: Jittering with Long Rectangles

texts:
I have been working on a physics simulation module. Almost everything works properly, but I am having an issue, which I have demonstrated in the following video.

http://youtu.be/2L17y9Lme0Q

As you can see in the video, if an object doesn't have an angular velocity, everything is OK. But once an angular velocity (even just a little) is applied to the object and it collides with the ground, it begins to shake.

I check for collision and get the normal and MTD (Minimum Translation Distance) using SAT (Separating Axis Theorem).

To get the contact point, I check for intersections between the two polygons. If there is more than one point of intersection, I then find the point in between the two intersection points.

Then I resolve overlapping objects by using the normal, MTD, and mass factor.
To solve the collision, I use the Impulse theory.

Do you have any idea what might be causing this shaking effect? Could it be caused by a wrong choice of contact points?


texts:
So I was watching Ikaruga:
http://www.youtube.com/watch?v=Aj23K8Ri68E

And then raystorm:
http://www.youtube.com/watch?v=TQ4V0G5ykAg

After looking at their 3D backgrounds for a little bit, it appears that they use a lot of repeated segments.

How would one start with the development with such systems?  Would there be editors that can be used (or at least help) with creating the environments?  Perhaps a 3D map with splines describing the path of the ship, as well as events on the splines?


texts: How to render a model that consists of individually transformable parts?

texts:
Consider a 3D model for a spider that consists of a body and eight legs. The legs can be transformed (rotated) relative to the body. I am not sure what the common ways of rendering such a scene are, at a low level. Two ways I could think of:

Render the body and legs separately, using different VBOs (or different indices) (one for the body, one for the leg) and separate draw calls.
Encode in each vertex which body part it belongs to, and decide based on this information how to transform the vertex in the vertex shader.

I searched a bit and could find some tutorials on skeletal animation and similar techniques, but they still boil down to this question.


texts: How to handle the top of a slope in a 2D tile-based platformer?

texts:
I'm working on a 2D tile-based platformer that supports 45-degree slope tiles.

There are several questions on the topic, but none seem to cover this precise problem that I have. This excellent article covers almost everything I'd want to know. I'll copy the salient bits:

  Make sure that you step X position before Y position.
  During collision detection, the slope only counts as a collision if its closest edge is the taller (smaller y coordinate) one. This will
  prevent characters from “popping” through the slope from the opposite
  side. [...]
  A full obstacle tile adjacent to the slope the character is currently on should not be considered for collision if it connects to
  the slope, that is, if the character (that is, his bottom-center
  pixel) is on a {0, *} slope, ignore left tile, and, if on a {*, 0}
  slope, ignore the right tile. You may have to do this for more tiles
  if your character is wider than two tiles – you might simply skip
  checking on the entire row if the player is moving towards the upper
  side of slope. The reason for this is to prevent the character from
  getting stuck at those tiles (highlighted yellow above) while still
  climbing the slope, as his foot will still be below the “surface
  level” by the time he comes into contact with the otherwise solid
  tile.

So if the character is going uphill, we essentially allow him to penetrate the slope after we've stepped the x coordinate, and then rectify that when we step the y coordinate. Let's assume we're using one contact point for the characters feet:

However, when the character reaches the top of the slope, at some point he'll step into the next tile:

As per the last bullet point above, we allowed him to move into the solid tile because it's ajacent to the slope. But now we're inside the floor, which needs to be fixed somehow.

What logic is needed to correctly resolve this situation? Simply saying "if we penetrate a solid tile, move up until we're out of it" doesn't always work, because there might be another solid tile on top of it, and we don't want the player to be teleported all the way to the top.

Can this be done without any communication between the x update and the y update, or do we need to keep some state like "I was on a slope at the start of this frame"? What is the most robust and elegant way to handle this?


texts: Correct way to "randomly" generate flowing terrain

texts:
I'm creating a simple top down RTS game.  I plan on it "randomly" generating maps on the fly when I need to.  I plan on it all working in 'passes':

Fill the terrain in with all grass
Go back and add some random spurts of gravel
Round out the gravel
Draw Mountain Landscape on second layer
Round out mountains
etc. etc.

Now, take a look at this picture below:

I hand created this using my map editor but I plan on this basically being the result after hopefully pass/step 3.

How should I go about deciding when and were to place my gravel so that it is at least irregularly shaped and sporadic enough to look natural?

Thanks if you can!  Any and all help is appreciated!

As a side note:

Each pass is basically me iterating through all of my tiles (The map is divided into 40x40 tiles) similar to this:

for (int x = 0; x <= GRIDMAX - 1; x++) {
    for (int y = 0; y <= GRIDMAX - 1; y++) {
        //Terrain(x, y, 0) = SomethingHere;
    }
}


texts: Minecraft/OpenGL - Create Multiple viewports

texts:
I'm working on a project for the game and i have been trying to draw a second smaller "window" that would act like a second camera, independent from the player.

I have looked into glViewport however i keep running into issues where the second viewport is the only one being drawn (the first one gets covered  by the second and has a blank screen where the first viewport should be:

So i guess the question is: How can i have multiple windows on screen and make it so it plays nice with the game's default rendering system?
I know it is possible since the game uses OpenGL, and maybe its just a simple case of putting the code in the right class.


texts:
I have been working on a game for a while using glut for basic window creation.
I was rendering to an offscreen buffer so that I could implement various effects like screen bulging, motion blur, refraction, etc. I also used the screen texture with antialiasing (fxaa).

Now I have changed from glut to sfml. I switched on the in-built antialiasing and it looked much better than my version, but now I don't have the screen in a texture so I can't use the screen effects.

So my question is, how to people normally deal with this issue? Can I take advantage of sfml's antialiasing functionality and retain my effects? I thought about using glReadPixels, but that seems way too slow. Does sfml do offscreen rendering behind the scenes and can I access that texture?

This is not specific to sfml. How do AAA games do it? Do they always implement their own antialiasing techniques?


texts: How to write a shader that only uses a bump map without a normal map

texts:
So I understand that for best results one uses a height (or bump) map and a normal map together.

And I also understand that one can calculate a normal map from a height map using some sobel operator.

But out of curiosity I wonder how the first games that supported bump mapping did it.

I found this fragment shader code that seems to do it, but I am not sure:
OpenGL Bump Map -- Texture artifacts ?

If the code above does exactly what I am looking for, can someone explain the line

vec3 normalDirection = normalize(tangenteSpace*(texture2D( bump_tex, f_texcoord ).rgb*2.0 - 1.0));

How can you get a normal from a bump ?
I understand what tangent space is mathematically but how does it work here ?
Is it a vec4 or a matrix ?

So basically my question is:
How was bump mapping done without a normal map in the old days ?


texts: Why won't character stay at the x-axis rotation I set In the inspector?

texts:
Here is a snippet of my Update function, which contains everything regarding my rotations for the character:

// Higher the Z float, the LESS of a rotation when moving
Vector3 v3 = new Vector3 (Input.GetAxis ("Horizontal"), 0.0f, 1.5f);

// A Quaternion variable named "quaternion" that's equal to LookRotation class that takes
// the "v3" variable
Quaternion quaternion = Quaternion.LookRotation (v3);

// The actual rotation is done using the Slerp class
transform.rotation = Quaternion.Slerp (
  transform.rotation,
  quaternion,
  Rotspeed * Time.deltaTime);

// When Countdown timer is done, then the animator is enabled
adventureAnimator.enabled = true;

When I put "357" on the X-Axis tab of Rotation, why does it go back to 0 whenever the game starts? After some debugging I know it is because of my logic contained in my "transform.rotation = Quaternion.Slerp" line of code. What do I need to change?

If you need more information or need me to elaborate, please let me know.


texts: What is a trainer from a coder prospective?

texts:
What steps usually takes or modify a trainer?

How a trainer can change the way a game behaves?

Edit:
with the word trainer I mean the applications, usually a single executable, that can unlock and give extra points and features during a gameplay, kind of a series of cheats that you can activate with this executable.


texts:
I need help finding a method to save some variables to a string that can be repeated in a text file, which will be stored in my C: drive. It will be storing data for multiple players.  For example:

int one = 0; //(will be set from a different file)
int two = 0; //(will be set from a different file)
int three = 0; //(will be set from a different file)
String PlayerName;(set from a different file)

Saves like:

(1, 2, 3, player 1);
(1, 2, 3, player 2);
(1, 2, 3, player 3);
etc.

Whenever it's called from a player's action it will save that string to a text file.

My save and load methods so far:

public class Offers {

    public static List<Offer> offers = new ArrayList<Offer>(2000);

    public Offers() {
    }

    public static void saveOffers() {
        for (Offer offer : offers) {
            if (offer == null) {
                continue;
            }
            int id = offer.id;
            int item = offer.item;
            int amount = offer.amount;
            int price = offer.price;
            int currentAmount = offer.currentAmount;
            int removedAmount = offer.removedAmount;
            int type = offer.type;
            int completed = offer.completed ? 1 : 0;
            int aborted = offer.aborted ? 1 : 0;
            int currentPrice = offer.currentPrice;
            int slot = offer.slot;
            String owner = offer.owner;
            String VALUES(""+ id + "" + item + "" + amount + "" + price + "" + currentAmount + "" + removedAmount + "" + type + "" + completed + "" + aborted + "" + currentPrice + "" + slot + "" + owner + "");
        }
    }

    public static void load() {
        int id = stream.readShort();
        int item = stream.read();
        int amount = stream.read();
        int price = stream.read();
        int currentAmount = stream.read();
        int removedAmount = stream.read();
        int type = stream.readShort();
        boolean completed = stream.readShort() == 1;
        boolean aborted = stream.readShort() == 1;
        int currentPrice = stream.read();
        int slot = stream.readShort();
        String owner = stream.readString();
        if (id != -1)
            offers.add(new Offer(id, item, amount, currentAmount, removedAmount, price, type, owner, completed, slot));
            for (Offer l : offers) {
                if (l == null) {
                    continue;
                }
                if (l.id == id && l.item == item && l.amount == amount && l.currentAmount == currentAmount && l.price == price && l.type == type && l.owner.equals(owner) && l.slot == slot) {
                    l.currentPrice = currentPrice;
                    l.aborted = aborted;
                    break;
                }
            }
        }
    }
}


texts: I've started working on my first game in Unity; It's very simple, there's a spinning block in the middle, and there are spinning blocks coming from all sides. When they hit the middle block, you lose a life. You have 3 lives. I've hit a bit of a brick wall, here, though; I can't seem to find anywhere how to use a sprite atlas as a font, or at least be able to sprite my own font. Does anyone know how to do this?


texts: Performance Optimization for 2D game developed using Unity 3D game engine

texts:
I have a game with almost 160 sprites in my resources folder.  I need 15 randomly selected sprites on each level (there are 7 levels).

I load those sprites which are required e.g. my random generator scripts generate 15 random numbers (completely unique from previously generated 15 numbers) and based on those number I load the sprites (sprites are numbered from 1-158 so I can easily load them).

My levels take some significant time to load, I think that pre-loading the sprites at the start of each level is taking time.   There are actually two folders, one for the questions and another for the answers.  Each question has 5 possible answers so I actually load 15 * 5 sprites on each level and save them in an array.

Should I load all the sprites once the game is loaded? Or Should I pre-load all the Sprites in advance?

Thanks in advance I am really looking forward for answers.

NOTE: There are almost thousands of tiles(100px by 100px in size) on each level, I know this also has some impact on performance.


texts: Techniques for creating sound effects in a browser based game?

texts:
The <audio> tag and the <object> tag are (somewhat hard to use) ways to embed audio on a page... ...but what about creating sound effects in a browser-based game?  E.g. if the game becomes aware you died, I plan to have some music play on the "you're dead" page.  But what about some kind of fighting sound when people click an "attack" link, or the sound of flowing water when they click to "heal".

Do I essentially have to look into embedding an invisible flash widget like facebook does for some of it's sounds in order to make this work, or are there other approaches?


texts: How to determine what animation to render in a component-based system without breaking encapsulation?

texts:
In a component based system, how should change the rendering/visual state of an entity such that I know what animation to use, without breaking encapsulation?

My guess is that it would have to be message-based system, not a query-based one, because having a few ifs checked every frame to determine the right animation based on the values of the attributes of the other components doesn't sound very efficient.


texts: Publishing an XNA project on Windows Store

texts:
I have made an application in XNA that I want to sell on Windows Store. When it comes to uploading in the Windows Store dashboard it says files need to be in the format xap, .appx, .appxbundle or .appxupload but I can't figure out how to create these files.
The best information I could find is https://msdn.microsoft.com/en-us/library/hh454036.aspx but I don't have "Store" in my Project menu. I am using Visual Studio 2015 and XNA 4.0.5


texts: What causes polygonal twitching in older games?

texts:
I'd like this answer large part to curiosity and I'd like to recreate it with our modern computers somehow.

By old games I'm referring to ps1 games. My specific example would be Megaman Legends I've not really noticed it in any other games maybe Final Fantasy 8. There probably are others.

When your looking around, vertices "lock" into different locations very twitchily. The Textures follow too. Sometimes vertices supposedly connecting to each other are in two different locations looking like one is jutting out of place.

Heres a video of the game. You have to look at about mid range to see changes is location.

https://www.youtube.com/watch?feature=player_detailpage&v=ojGrAcZw3pA#t=961s

Its probably not something uncommon to old polygonal graphics.

My only theory is its rounding floating points to the closest integer but that doesn't seem plausible to me.

[edit] PSX doesn't have floating points there goes my theory XD.

I'd like to hear anyone's theory even if they don't know. Take a stab. I'll investigate any of them myself.


texts: How can I generate spheres equal between the waypoints?

texts:
public void duplicateObject(UnityEngine.GameObject original, int howmany)
    {
        howmany++;
        for (int i = 0; i < waypoints.Count - 1; i++)
        {
            for (int j = 1; j < howmany; j++)
            {
                Vector3 position = waypoints[i].transform.position + j * (waypoints[i + 1].transform.position - waypoints[i].transform.position) / howmany;
                UnityEngine.GameObject go = Instantiate(original, new Vector3(position.x, 0, position.z), Quaternion.identity);
                go.transform.localScale = lightsScale;
                objects.Add(go);
            }
        }
    }

For example howmany value is 21.
If I have two waypoints it's fine it will create 21 spheres between the two waypoints.

But if I have 3 waypoints it's creating 42 spheres but it should create 21 since howmany is still 21. And it also position the spheres between waypoint 1 and 2 and then from waypoint 2 to 3.

But I want that it will create 7 spheres between waypoints 1 and 2 and 7 spheres between waypoints 2 and 3 and last 7 spheres between waypoints 3 and 1.


texts: graphics.IsFullScreen resetting to false after game constructor and graphics.ApplyChanges()

texts:
This is a MonoGame 3.2 Windows (DirectX) Project.

I've tried setting graphics.IsFullScreen to true in the game's constructor and in the game's initialize function, both times running graphics.ApplyChanges(), but when stepping through the code, I see that it gets set back to false when it leaves the constructor or graphics.ApplyChanges() is called. Here is the code I've tried:

public class Sandbox : Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;

    public Sandbox()
        : base()
    {
        graphics = new GraphicsDeviceManager(this);

        Content.RootDirectory = "Content";

        IsFixedTimeStep = false;
        IsMouseVisible = true;

        graphics.PreferredBackBufferWidth = Config.Screen.Width;
        graphics.PreferredBackBufferHeight = Config.Screen.Height;

        graphics.IsFullScreen = Config.Screen.IsFullScreen; // IsFullScreen reads true
        graphics.ApplyChanges(); // IsFullScreen reads true
    } // IsFullScreen reads FALSE when leaving the constructor

    protected override void Initialize()
    {
        graphics.IsFullScreen = true; // IsFullScreen reads true
        graphics.ApplyChanges(); // IsFullScreen reads FALSE after applying changes

        graphics.ToggleFullScreen(); // this did not do anything

        base.Initialize();
    }
}


texts: Why doesn't the y Axis work with SuperBible frame reference or GluLookAt

texts:
I'm currently trying to understand how to use the GLFrame Class in the superbible book, and acording to the 4th edition of the book, the camera matrix derived from the Frame of reference class should work the same as GluLookAt

When I add these lines

cameraFrame.SetForwardVector(-0.5f, 0.0f,-0.5f);
cameraFrame.Normalize();

The camera looks in the correct direction, yaw at 45 Degrees (Am I doing that right!)

However when I add this

cameraFrame.SetForwardVector(0.0f, 0.5f,-0.5f);

The camera just looks as if it was set to (0.0f, 0.0f, 1.0f)

Why is this! It's been driving me mad for three days. Maybe I'm not passing in the vectors correctly, but I'm not sure how to pass in x,y 360 degrees for the look at (forward) location/vector. Do the vectors have to be normalized before passing them in?

Eventually I hope to do full mouse look (FPS style) , but for now just understanding why I can't make the camera simply pitch up would be a good start.

Thansk!

Here is the code in situ.

// Called to draw scene
void RenderScene(void)
{
// Color values
static GLfloat vFloorColor[] = { 0.0f, 1.0f, 0.0f, 1.0f};
static GLfloat vTorusColor[] = { 1.0f, 0.0f, 0.0f, 1.0f };
static GLfloat vSphereColor[] = { 0.0f, 0.0f, 1.0f, 1.0f };

// Time Based animation
static CStopWatch   rotTimer;
float yRot = rotTimer.GetElapsedSeconds() * 60.0f;

// Clear the color and depth buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Save the current modelview matrix (the identity matrix)
modelViewMatrix.PushMatrix();

M3DMatrix44f mCamera;

/////////
///////// My Code

cameraFrame.SetForwardVector(-0.5f,-0.5f,-0.5f);
cameraFrame.Normalize();

///////// End of my code
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.PushMatrix(mCamera);

// Transform the light position into eye coordinates
M3DVector4f vLightPos = { 0.0f, 10.0f, 5.0f, 1.0f };
M3DVector4f vLightEyePos;
m3dTransformVector4(vLightEyePos, vLightPos, mCamera);

// Draw the ground
shaderManager.UseStockShader(GLT_SHADER_FLAT,
                             transformPipeline.GetModelViewProjectionMatrix(),
                             vFloorColor);
floorBatch.Draw();

for(int i = 0; i < NUM_SPHERES; i++) {
    modelViewMatrix.PushMatrix();
    modelViewMatrix.MultMatrix(spheres[i]);
    shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF,     transformPipeline.GetModelViewMatrix(),
                            transformPipeline.GetProjectionMatrix(), vLightEyePos, vSphereColor);
    sphereBatch.Draw();
    modelViewMatrix.PopMatrix();
    }

// Draw the spinning Torus
modelViewMatrix.Translate(0.0f, 0.0f, -2.5f);

// Save the Translation
modelViewMatrix.PushMatrix();

    // Apply a rotation and draw the torus
    modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f);
    shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, transformPipeline.GetModelViewMatrix(),
                                 transformPipeline.GetProjectionMatrix(), vLightEyePos, vTorusColor);
    torusBatch.Draw();
modelViewMatrix.PopMatrix(); // "Erase" the Rotation from before

// Apply another rotation, followed by a translation, then draw the sphere
modelViewMatrix.Rotate(yRot * -2.0f, 0.0f, 1.0f, 0.0f);
modelViewMatrix.Translate(0.8f, 0.0f, 0.0f);
shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, transformPipeline.GetModelViewMatrix(),
                            transformPipeline.GetProjectionMatrix(), vLightEyePos, vSphereColor);
sphereBatch.Draw();

// Restore the previous modleview matrix (the identity matrix)
modelViewMatrix.PopMatrix();
modelViewMatrix.PopMatrix();
// Do the buffer Swap
glutSwapBuffers();

// Tell GLUT to do it again
glutPostRedisplay();

}


texts: Which files of addressable assets should be committed to Git?

texts:
I would like to keep my Git repository as small as possible and exclude any automatically generated files. The developers can re-build their Unity Addressable Assets themselves. Any developer should be able to build the final project and the final result should contain the same assets packed in the same way.

I noticed that Unity generates the following files and folders:

Which of these files are important settings that should be included and which files are safe to exclude from a Git repository?


texts: Binary operation for fast 3D game engine

texts:
I had a thought while ago. I read about bitBoard and I was curious, could be the concept be applied in 3D?

What I mean is to use a 3D matrix of boolean value, which correspond to the voxels. So that one could use the and, or, not, ecc bit operations to calculate if a position for example is occupied or not.

for example let's consider the two objects (represented by 1's):

 object1              object2            result: no collison
 0000000000           0000000000         0000000000
 0001110000           0000000000         0000000000
 0001110000     &     0000000000    =    0000000000
 0001110000           0000000011         0000000000
 0000000000           0000000011         0000000000
 0000000000           0000000000         0000000000

would it be useful? Are there already games that uses this trick?


texts: Design pattern for creating multiple enemies

texts:
I'm currently attempting to implement a factory method pattern for creating multiple different enemies after loading data from a file. But I'm having second thoughts on what would be the best design pattern to implement or if in fact I am even using it correctly, below is how I intended to use it:

The Enemyfactory determines which enemy to create according to enemy type specified in the xml level file. For example:

<enemy>
    <type>
    NORMAL
    </type>
   ...
</enemy>

<enemy>
    <type>
    BRAWLER
    </type>
   ...
</enemy>

This data is read in the LevelLoader and then can be used to construct enemies. In the LevelLoader class I could easily have somehting like this instead:

if(node.equal("NORMAL")){
 return new NormalEnemy(//parameters from file to construct enemies);
  }else if (node.equal("BRAWLER")) {
  return new BrawlerEnemy();
}

With this information, what would be the best way/best design pattern to use to create multiple enemies.


texts: Having troubles with LibNoise.XNA and generating tileable maps

texts:
Following up on my previous post, I found a wonderful port of LibNoise for XNA. I've been working with it for about 8 hours straight and I'm tearing my hair out - I just can not get maps to tile, I can't figure out how to do this.

Here's my attempt:

            Perlin perlin = new Perlin(1.2, 1.95, 0.56, 12, 2353, QualityMode.Medium);
        RiggedMultifractal rigged = new RiggedMultifractal();

        Add add = new Add(perlin, rigged);

        // Initialize the noise map
        int mapSize = 64;
        this.m_noiseMap = new Noise2D(mapSize, perlin);
        //this.m_noiseMap.GeneratePlanar(0, 1, -1, 1);

        // Generate the textures

        this.m_noiseMap.GeneratePlanar(-1,1,-1,1);
        this.m_textures[0] = this.m_noiseMap.GetTexture(this.graphics.GraphicsDevice, Gradient.Grayscale);

        this.m_noiseMap.GeneratePlanar(mapSize, mapSize * 2, mapSize, mapSize * 2);
        this.m_textures[1] = this.m_noiseMap.GetTexture(this.graphics.GraphicsDevice, Gradient.Grayscale);

        this.m_noiseMap.GeneratePlanar(-1, 1, -1, 1);
        this.m_textures[2] = this.m_noiseMap.GetTexture(this.graphics.GraphicsDevice, Gradient.Grayscale);

The first and third ones generate fine, they create a perlin noise map - however the middle one, which I wanted to be a continuation of the first (As per my original post), is just a bunch of static.

How exactly do I get this to generate maps that connect to each other, by entering in the mapsize * tile, using the same seed, settings, etc.?


texts: Preserving Cocos2D context between UIKit screens

texts:
My app is designed to use Cocos2D in the "main game screen" but the rest of the screens are in UIKit. While I feel that this isn't ideal, I really don't have time to port the rest of the screens into Cocos2D for the time being.

One of the problems I face is that I am required to load all the textures each time I enter the main game screen, and discard them once I leave Cocos2D-land (and repeat the process all over again)... or am I?

I am actually wondering if I could preload all the textures needed in a CCTextureCache during startup, even when the EAGLView and context hasn't yet been set up until I visit the main screen (and in doing so preserve the texture cache contents). But whenever I try this the app crashes.

Any way in which I can do this?


texts:
I'm writing a little Android game in OpenGL ES. My game graphics are not appearing in the right orientation. In fact everything is drawn in reverse vertically. Can someone please comment on my understanding of how OpenGL works below please?

My understanding is that OpenGL works in a right handed coordinate system, e.g.

        y(+)
        |
        |
        o-----x(+)
       /
      /
     z(+)

So, I set my orthographic projection matrix using

Matrix.orthoM(..., -2, 2, -2, 2, 1, 15)

for example, so if I were to draw a line from (-2, 2, 0) to (2, -2, 0) I should be drawing a line in the X/Y plane from (-2, 2) top (2, -2). Near and far planes are 1 and 15 respectively.

In addition I am setting up my view matrix using

Matrix.setLookAtM(mViewMatrix, 0, 0, 0, 10, 0, 0, 0, 0, 1, 0)

so I'm standing on the positive Z axis at 10 units, looking towards the origin with the Y axis as the upwards vector.

But when I come to draw stuff, everything is flipped in the X axis. So a point at (1, 1) would appear at (1, -1).

Does anyone see what might be wrong here?


texts: GUIText size on 4:3 and 16:9 is different

texts:
I have a text (guiText) on the screen.

It shows correctly when viewed on 16:9 resolution.

But it scales up when viewed on 4:3 (e.g iPhone4).

I am using following ObjectLabel script to place it on the same position regardless of screen resolution. Which is working fine for 16:9 and 16:10.

Object Label


texts:
I am trying to write a match-three puzzle game like 'call of Atlantis' myself. The most important algorithm is to find out all possible match-three possibilities. Is there any open source projects that can be referenced? Or any keywords to the algorithm? I am trying to look for a faster algorithm to calculate all possibilities.

Rules:

Diagonals don't count.
The size is 8x8

Thanks.


texts: How do I make TextMesh Pro go invisible when at a distance from the camera?

texts:
I'm building a 4x game. I've rendered the galaxy, and I want the text below each star to disappear when I'm zoomed out, so it looks nicer.

My stars are Prefabs with a star sprite and a 'UI' gameobject with TextMeshPro underneath the 'UI' gameobject.

I've put this as the script on the TextMeshPro object, but it says there is no renderer for TextMeshPro:

    Vector3 viewPos = Camera.main.WorldToViewportPoint(transform.position);
    if (viewPos.z > 100F)
    {
        this.gameObject.GetComponent<Renderer>().enabled = false;
    }


texts: Getting Center and Radius of Irregural Object

texts:
I have drawn an asteroid object manually , and would like to get its center/radius by a specific equation. I think I can get them by calculated and hard-coded values.

The code to draw the asteroid:

float ratio = (float)app::getWindowWidth()/app::getWindowHeight();
gl::pushMatrices();

gl::translate(m_Pos*ratio);

gl::scale(m_size*ratio,m_size*ratio);
gl::color(ci::Color(1,1,1));

    gl::drawLine(Vec2f(20,0),Vec2f(80,0));
    gl::drawLine(Vec2f(80,0),Vec2f(100,20));
    gl::drawLine(Vec2f(100,20),Vec2f(100,50));
    gl::drawLine(Vec2f(100,50),Vec2f(60,100));
    gl::drawLine(Vec2f(60,100),Vec2f(40,100));
    gl::drawLine(Vec2f(40,100),Vec2f(50,70));
    gl::drawLine(Vec2f(50,70),Vec2f(25,90));
    gl::drawLine(Vec2f(25,90),Vec2f(0,70));
    gl::drawLine(Vec2f(0,70),Vec2f(20,40));
    gl::drawLine(Vec2f(20,40),Vec2f(0,20));
    gl::drawLine(Vec2f(0,20),Vec2f(20,0));

gl::popMatrices();

gl::pushMatrices();

float radius = getRadius();

Vec2f center = Vec2f(m_Pos.x+50, m_Pos.y+50);

gl::drawStrokedCircle(center*ratio, 10);
gl::popMatrices();

}

According to the answer I have written that code to calculate the radius, is it correct or not ?

cinder::Vec2f Asteroid::getCenter()
{
    return ci::Vec2f(m_Pos.x, m_Pos.y);
}

double Asteroid::getRadius()
{
    ci::Vec2f  _vec = (getCenter()- Vec2f(15,5));
    return _vec.length()*0.3f;
}


texts: How to check if a game object is inside another gameobject

texts:
My idea is that there is a plane which is more of a border at top of the screen and if a game object has no more space to fall and it collides with something while it is in that border, the game ends. How can I check if a gameobject is inside that plane?

Example:


texts: Can you move items made in the Skyrim Creation Kit on PC to the Xbox version?

texts:
I'm a pretty technically illiterate gamer but after several annoying glitches I finally went out and got the PC version of Skyrim. After a little bit of practice I got the hang of transferring my Xbox 360 saves to the PC and vice versa. I've really been enjoying using the console commands and lately after fixing the crashes associated with the DLC have begun to explore the Creation Kit.

I've created several items with custom weight, value, armor rating and multiple custom enchantments. I'd really like to use them on the Xbox, and I know some people will just say to play it on the PC but I just don't enjoy using the keyboard compared to my controller and flat screen TV.

I haven't changed the mesh, design or texture of any of the items just their names and enchantments. Considering Bethesda said they used the Creation Kit to make the game I don't think my custom items are anything the Xbox can't handle. To me it seems like just a matter of getting them over there... Can I do that?

If you know of a video that will show how, that would be awesome. It should be mentioned I'm not willing to do anything to void my Xbox's warranty.


texts: Creating a Player object in a physics engine

texts:
I have a working physics environment using Farseer - but how do I create a player object that can walk around?

My current attempt involves applying forces to a rectangular body whenever keys are pressed.

This... works... to some degree. The player box moves around and such, after significant angle damping doesn't flip over much either. But I want a smooth moving simple player that can walk around and climb slopes but not walls and stuff like that. As it currently stands, the player object can climb any slope no matter how steep due to continue sideways force being applied. The player also does not stop quickly, but rather slides heavily due to low friction - and raising the player body's friction value doesn't help all that much.

I just don't know how to do a standard player object without making it move around in ridiculous ways due to the physics engine being a full physics engine.


texts: Behavior trees - Can sequences and selectors contain conditions?

texts: I can't wrap my head around this. Is it legal for parent nodes to contain additional logic ?


texts: Shed some light on this Nvidia Pascal slide?

texts: What are the meanings of all the terms in this slide? Why is the correct operator to roughly compute (guesstimate) the improvement in performance multiplictive and not instead bottle necked by the new weakest link?


texts: LookAt different object smoothly in unity3d

texts:
As picture depicted my camera moving on path i want to lookAt bath different object smoothly. Currently have tried

trasnform.LooAt(activePath.gameObject.transform);

but it producing jerky result. object suddenly lookAt to next object how to avoid it. I searched and found this sloution but it also not working

var targetRotation = Quaternion.LookRotation(activePath.gameObject.transform.position - transform.position);
        transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime);


texts: What is the transformation order when using the Transform Class?

texts:
I am currently using Unity 5.5 for the first time in a project and I've got some problems regarding transformations.

I've got a background in more general 3D graphics meaning that I'm used to manually manage scene graphs and matrix transformation orders.

My greatest problem when moving to Unity, and using their built in Transform Class, is that I can't find any information regarding the transformation order of rotation, localrotation, scaling, localscaling, position and localposition.

I can't find any good information of this and It's driving me slightly mad.

TL;DR: What's the transformation order of the Transform class?


texts:
I am not sure if I will be able to provide enough information for someone to answer this question, but any ideas might help.

I am creating a tower defense game in Flash and I eventually want to make it run on Android. Just for testing purposes, I have been running it on Android's browser and different Android .swf player apps.

Recently, the game stopped working correctly. When it gets to the second wave of enemies, they get about four tiles in and stop moving. I can get them to start moving again by constantly clicking on parts of the screen. It's almost like the game loop has quit updating.

Trying to solve the problem, I have updated the gameloop from Flash's standard events to a NativeSignal event (didn't solve the problem but the game runs much faster overall).

The game works fine on my PC, I can't figure out the Android problem though. Any ideas or help would be appreciated. I didn't want to supply code since I wouldn't know where to start that would be helpful.


texts: Executing Components in an Entity Component System

texts:
Ok so I am just starting to grasp the whole ECS paradigm right now and I need clarification on a few things. For the record, I am trying to develop a game using C++ and OpenGL and I'm relatively new to game programming. First of all, lets say I have an Entity class which may have several components such as a MeshRenderer,Collider etc. From what I have read, I understand that each "system" carries out a specific task such as calculating physics and rendering and may use more that one component if needed. So for example, I would have a MeshRendererSystem act on all entities with a MeshRenderer component. Looking at Unity, I see that each Gameobject has, by default, got components such as a renderer, camera, collider and rigidbody etc. From what I understand, an entity should start out as an empty "container" and should be filled with components to create a certain type of game object. So what I dont understand is how the "system" works in an entity component system.

http://docs.unity3d.com/ScriptReference/GameObject.html

So I have a GameObject(The Entity) class like

class GameObject
{
public:
    GameObject(std::string objectName);
    ~GameObject(void);
    Component AddComponent(std::string name);
    Component AddComponent(Component componentType);
};

So if I had a GameObject to model a warship and I wanted to add a MeshRenderer component, I would do the following:

warship->AddComponent(new MeshRenderer());

In the MeshRenderers constructor, should I call on the MeshRendererSystem and "subscribe" the warship object to this system? In that case, the MeshRendererSystem should probably be a Singleton("shudder").  From looking at unity's GameObject, if each object potentially has a renderer or any of the components in the default GameObject class, then Unity would iterate over all objects available. To me, this seems kind of unnecessary since some objects might not need to be rendered for example. How, in practice, should these systems be implemented?


texts: Unifying Texture-, Bump- and Lightmapping

texts:
I would like to implement a rendering component that makes use of texture-, bump- and light mapping. Unfortunately, I am a little bit stuck on some implementation details. In particular,

Does each different map require individual texture coordinates? (I assume at least a   light map would)
Is there a simple file format that stores all the information needed? ( I guess .obj's are missing support for light maps)

I would be grateful for advice on this.


texts: Computing pixel's screen position in a vertex shader: right or wrong?

texts:
I am building a deferred rendering engine and I have a question. The article I took the sample code from suggested computing screen position of the pixel as follows:

VertexShaderFunction()
{
    ...
    output.Position = mul(worldViewProj, input.Position);
    output.ScreenPosition = output.Position;
}

PixelShaderFunction()
{
    input.ScreenPosition.xy /= input.ScreenPosition.w;
    float2 TexCoord = 0.5f * (float2(input.ScreenPosition.x,-input.ScreenPosition.y) + 1);
    ...
}

The question is what if I compute the position in the vertex shader (which should optimize the performance as VSF is launched significantly less number of times than PSF) would I get the per-vertex lighting insted. Here is how I want to do this:

VertexShaderFunction()
{
    ...
    output.Position = mul(worldViewProj, input.Position);
    output.ScreenPosition.xy = output.Position / output.Position.w;
}

PixelShaderFunction()
{
    float2 TexCoord = 0.5f * (float2(input.ScreenPosition.x,-input.ScreenPosition.y) + 1);
    ...
}

What exactly happens with the data I pass from VS to PS? How exactly is it interpolated? Will it give me the right per-pixel result in this case? I tried launching the game both ways and saw no visual difference. Is my assumption right?

Thanks.

P.S. I am optimizing the point light shader, so I actually pass a sphere geometry into the VS.

Solution:

struct PSInput
{
    float2 vPos : VPOS;
};

PixelShaderFunction(PSInput input)
{
    float2 ScrPos = input.vPos*halfPixel*2;

        //The correct Screen Space Texture Coordinates.
    float2 TexCoord = ScrPos + halfPixel;

    //Bonus: getting the world position.
    ScrPos = ScrPos*2 - 1;
    ScrPos = float2(ScrPos.x, -ScrPos.y);

    float4 position;
    position.xy = ScrPos;
    position.z = depthVal; // Read from the depth map.
    position.w = 1.0f;

    position = mul(position, InvertViewProjection);
    position /= position.w;
}


texts: How to use GLM Simd using GLM version 0.9.8.2?

texts:
I am new user for GLM, can somebody guide me how to use GLM SIMD using its version 0.9.8.2.

According to its Manual using #define GLM_FORCE_SSE2

For example, if I write:

#define GLM_FORCE_SSE2

#ifdef GLM_FORCE_SSE2

glm::vec3 v(1.0f);

#endif

I am unable to notice any difference if I write this now:

glm::vec3 v(1.0f);

unlike older version of GLM where I can use different function like

#include <GLM\GTX\simd_mat4.hpp>
glm::detail::fvec4SIMD v(1.0f); //for simd
glm::vec3 v(1.0f); //for non simd

but with version 0.9.8.2 I am confused.


texts: Creation of block mesh for minecraft like chunk

texts:
Problem:

I'm trying to build a naive mesh for a "chunk" of 2x2x2 blocks. But the "mesh" i create is 3x3x3 blocks (i don't understand why?) and the "extra cubes" are not like i intendet them to be (image at the end).

My code for creation of the mesh:

/**
 * Creates vertices and indices for a mesh
 * @return
 */
public FloatBuffer createVerticesAsBuffer(){
    vertexPositionData = BufferUtils.createFloatBuffer((24*3)*worldSize*worldSize*worldSize);
    indicesData = BufferUtils.createIntBuffer(worldSize*worldSize*worldSize*36);
    int i = 0;
    for (int x = 0; x < worldSize; x++) {
        for (int y = 0; y < worldSize; y++) {
            for (int z = 0; z < worldSize; z++) {
                if(world[x][y][z] == BlockType.Grass)
                {
                    i += putVertices(x*cubeSize, y*cubeSize, -z*cubeSize, i);
                }
            }
        }
    }

/**
 * Creates cube data and puts it into buffers for one mesh
 * @param tx
 * @param ty
 * @param tz
 * @param offset number of indices
 * @return number of vertices added
 */
public int putVertices(float tx, float ty, float tz, int offset) {
    vertexPositionData.put(new float[]{
            // Back face
            -cubeSize + tx,cubeSize + ty,-cubeSize + tz,    //0
            -cubeSize + tx,-cubeSize + ty,-cubeSize + tz,   //1
            cubeSize  + tx,-cubeSize + ty,-cubeSize + tz,   //2
            cubeSize + tx,cubeSize + ty,-cubeSize + tz,     //3

            // Front face
            -cubeSize + tx,cubeSize + ty,cubeSize + tz,     //4
            -cubeSize + tx,-cubeSize + ty,cubeSize + tz,    //5
            cubeSize + tx,-cubeSize + ty,cubeSize + tz,     //6
            cubeSize + tx,cubeSize + ty,cubeSize + tz,      //7

            // Right face
            cubeSize + tx,cubeSize + ty,-cubeSize + tz,     //8
            cubeSize + tx,-cubeSize + ty,-cubeSize + tz,    //9
            cubeSize + tx,-cubeSize + ty,cubeSize + tz,     //10
            cubeSize + tx,cubeSize + ty,cubeSize + tz,      //11

            // Left face
            -cubeSize + tx,cubeSize + ty,-cubeSize + tz,    //12
            -cubeSize + tx,-cubeSize + ty,-cubeSize + tz,   //13
            -cubeSize + tx,-cubeSize + ty,cubeSize + tz,    //14
            -cubeSize + tx,cubeSize + ty,cubeSize + tz,     //15

            // Top face
            -cubeSize + tx,cubeSize + ty,cubeSize + tz,     //16
            -cubeSize + tx,cubeSize + ty,-cubeSize + tz,    //17
            cubeSize + tx,cubeSize + ty,-cubeSize + tz,     //18
            cubeSize + tx,cubeSize + ty,cubeSize + tz,      //19

            // Bottom face
            -cubeSize + tx,-cubeSize + ty,cubeSize + tz,    //20
            -cubeSize + tx,-cubeSize + ty,-cubeSize + tz,   //21
            cubeSize + tx,-cubeSize + ty,-cubeSize + tz,    //22
            cubeSize + tx,-cubeSize + ty,cubeSize + tz      //23
    });
    indicesData.put(new int[]{
            0+offset,1+offset,3+offset, // Back face
            3+offset,1+offset,2+offset, // Back face

            4+offset,5+offset,7+offset, // Front face
            7+offset,5+offset,6+offset, // Front face

            8+offset,9+offset,11+offset, // Right face
            11+offset,9+offset,10+offset, // Right face

            12+offset,13+offset,15+offset, // Left face
            15+offset,13+offset,14+offset, // Left face

            16+offset,17+offset,19+offset, // Top face
            19+offset,17+offset,18+offset, // Top face

            20+offset,21+offset,23+offset, // Bottom face
            23+offset,21+offset,22+offset // Bottom face
    });
    return 24;
}

Full code on github: https://github.com/karoc123/ba_tobias_zink/tree/master/LWJGLTest

My actual output:


texts:
I'm working on GUI system and I want to implement tooltips and dialogs.

Base components hierarchy looks like this:

So every panel extend ComponentContainer class, and other controls like button extend Component class

This is my current component hierarchy:

My main idea to add layers. For example first for components, second for tooltips, third for different dialogs, but I can't realize where they should be in this structure... and if dialog will contain some fields with tooltips, how should it work?

Any ideas?

UPD:
The question about layers and class structure with layers.
How they should be organized considering the fact that they will be used to hold dialogs and tooltips.

Event handling already implemented and it will not be so complicated to add it for layers.


texts:
Searching about VAOs and VBOs I read here and here that I can optionally unbind them to avoid accidental modification so I gave it a try. The problem is that unbinding the VBO causes an access violation when calling glDrawElements and I don't understand why am I getting this behavior.

int main(int argc, char *argv[]) {
    if (!glfwInit()) {
        return -1;
    }

    GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL", nullptr, nullptr);
    glfwMakeContextCurrent(window);
    glewExperimental = GL_TRUE;

    if (glewInit() != GLEW_OK) {
        return -1;
    }

    GLfloat vertices[] = {
        -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, // Top-left
        0.5f, 0.5f, 0.0f, 1.0f, 0.0f, // Top-right
        0.5f, -0.5f, 0.0f, 0.0f, 1.0f, // Bottom-right
        -0.5f, -0.5f, 1.0f, 1.0f, 1.0f  // Bottom-left
    };

    // Create Vertex Array Object
    GLuint vao;
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);

    //Vertex Buffer Object
    GLuint vbo;
    glGenBuffers(1, &vbo);
    glBindBuffer(GL_ARRAY_BUFFER, vbo);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    // Index Buffer Object
    GLuint elements[] = {
        0, 1, 2,
        2, 3, 0
    };

    GLuint ibo;
    glGenBuffers(1, &ibo);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements), elements, GL_STATIC_DRAW);

    (...) // Shader-related stuff

    // Specify the layout of the vertex data
    GLint posAttrib = glGetAttribLocation(shaderProgram, "position");
    glEnableVertexAttribArray(posAttrib);
    glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), 0);

    GLint colAttrib = glGetAttribLocation(shaderProgram, "color");
    glEnableVertexAttribArray(colAttrib);
    glVertexAttribPointer(colAttrib, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (void*)(2 * sizeof(GLfloat)));

    glBindVertexArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    glBindVertexArray(vao);
    while (!glfwWindowShouldClose(window)) {
        glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

        if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
            glfwSetWindowShouldClose(window, GL_TRUE);

        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    // Prepare to close the application
    glDeleteProgram(shaderProgram);
    glDeleteShader(fragmentShader);
    glDeleteShader(vertexShader);
    glDeleteBuffers(1, &vbo);
    glDeleteBuffers(1, &vao);
    glDeleteBuffers(1, &eab);

    return 0;
}

I'm getting the following error and it happens only when I unbind the VBO. Unbinding the VAO and the IBO doesn't throw any exception.

  Unhandled exception at 0x0282D434 (ig4icd32.dll) in main.exe: 0xC0000005: Access violation reading location 0x00000000.

Is there a problem with the way I did the unbinding?


texts: How to change between camera angles in Unity

texts:
I need to change camera angles in Unity by hitting a key.

For example,

I want to look down on the battle, so I hit 1.
Then I want to see it from the side, so I hit 2, etc.

How do I write a script to do this change of perspective?

I have 3 cameras set up, each of them outputting to a different display. I want to switch between those cameras/displays to get a different viewing angle for the players. As an example, in the Unity editor, in the upper left corner, you have a tab that says Display 1. Clicking that will show you other displays.

Also, when setting up a camera, you have to connect it to a display. (I know you already know this, I just wanted to make sure you guys knew what I was talking about)


texts: Does the NetworkTransport compress and decompress the data sent through the network?


texts:
I have three image files, one is Techs.png, one is Techs.gif and one is Techs.bmp. I have used SDL_image 2.0.5 and SDL 2. When I load the image of Techs.gif and Techs.bmp, there is no error, but when I load the image of Techs.png.
SDL_Surface*Surface=IMG_Load("Techs.png"), an error occurs, I cannot load this image and Surface always returns NULL, I am using Visual Studio 2019.
Can someone help me, thanks.


texts: How to control an Animator without having all the animations on a Controller?

texts:
I am building a sims-like game where there are a lot of objects for my autonomous characters to interact with.
Because of this, as much of the unique interaction code as possible is controlled by the objects, rather than the characters. This prevents unnecessary script bloat.
However, many of these objects also have unique animations used to interact with them. Like the actual behaviour, I'd prefer to store these animations on the object rather than the characters.
Though all my characters possess an Animator, I see no way to trigger animations that aren't on the associated Animation Controller.
What options does this leave me with? Can I somehow drastically alter the controller at runtime? Is that the smart approach?


texts: Paper-based prototyping: simulating real time

texts:
I was messing around with this game idea where players race along a dangerous road in trucks to deliver their cargo. As they travel along the road (especially if they decide to go at speed) they will run into dangers: landslides where they must dodge/clear terrain, fog so they can't see the cliff sides etc.

I'd love to try this out 'on paper' first with some friends. However I'm not sure how to simulate a real time experience of driving the trucks at various speeds. The most simple solution I have come up with is rolling dice to move however many grid squares; wherever you land you roll again to see if a randomised disaster occurs. To measure speed I could add a modifier, such as if they're going an 'above average speed' they get a +1 to the amount of grid squares they cover but also a +1 to the chance of a disaster happening.

However, in a video game I'd be simulating acceleration (by holding down a key for example) and changing gear for speed. It also would not be turn based and they would have free control of the truck's movement and could accidentally plummet off the edge.

I guess the game can track when a player leaves and enter a new square in the grid and, after so many, roll to see if a disaster occurs. However, I don't think my current idea would really reflect the real time game experience/dynamics I'm trying to create in the video game. Am I looking at this the wrong way?

Many thanks


texts:
When I export my Mudbox mesh (level 1), with its skeleton selected, to a .fbx and import it into unity, I don't get the bones/joints/skeleton/whatever under my mesh in the hierarchy.

Am I missing something?


texts: Converting copyrighted song to 8 bit. Is it legal?

texts: I would like to get a copyrighted song, convert into a 8 bit song and use it in my game. Is that legal?


texts: Unity Pixel Perfect Camera - Adjusting the Viewport Rect?

texts:
I am trying to make a pixel perfect Tetris style game.
I have the pixel perfect component attached and have tried playing with settings such as Crop Frame and Stretch Fill. It seems to override any setting made to the 'Viewport Rect'.
The problem here is I want to control where the play-area is shown on the screen. For example I want the single player game to be somewhere near centre (although preferrably slightly off to the left). But when they play 2-Player mode I want the P1 playarea to be near left, and P2 area at the right.
The screens below shows some of the settings I tried. The 3rd screen shot shows the play area approaching what I want, but I am unable to move it left to right for example (Im unable to move it at all).
(Also note, if I try leaving CropFrame and StretchFill unchecked my Camera Size value is also overridden).
I even tried to 'extend' the Pixel Perfect Camera class but haven't been able to do that, I'm starting to wonder if this is just a limitation of using this component and perhaps I would need to write my own implementation of the pixel perfect camera to achieve the full control I need.
UPDATE: Actually I am able to extend the Pixel Perfect Camera class by 'using UnityEngine.U2D'. So far this is what I am trying whilst I wait in hope of further help (It seems like a lost cause extending the class, because I am not sure I can override much from it and cannot see the code. I can't find a way to set the Viewport X or similar). All the best everyone!
Thanks for any help.


texts: CenterContainer makes my button too small

texts:
I get the perfect width for my buttons, but CenterContainer overrides that value of theirs to make the button as wide as the biggest text length of the buttons when I put the buttons inside of the container

godot 3.1


texts:
I'm starting a project using Haxe and OpenFL. I defined a big level in Flash, when I try to scroll the level in the game I have a really bad performance.

I think that moving all the objects is really expensive in terms of processing, how can I improve this?


texts: LibGDX - Image width is not set to resetting to zero when full width

texts:
I am making a progress bar for showing the players current experience. However I have come around to a bug, which appears when the player is maxing out his experience and then is getting a new level. In the ideal world my code should reset the progress bar image width (which is a Scene2D image btw), but for some reason it is not setting the image width to zero, but is setting it to its full width instead, which I can't seem to understand why. I hope anyone can help me.

I have provided my code below, and also uploaded a video on youtube with my bug - Video of the bug

The method below is the one I use to change the experience progress bar width as well as the experience.

public void changeLevelExperience(int gainedExperience) {
    float maxExpDividedInPixels = 131f / this.GAME.gameScreen.getGameManager().maxExperience;

    this.GAME.gameScreen.getGameManager().currentExperience += gainedExperience;

    if (this.GAME.gameScreen.getGameManager().currentExperience >= this.GAME.gameScreen.getGameManager().maxExperience) {
        this.GAME.gameScreen.getGameManager().currentLevel++;
        this.currentLevelLabel.setText(this.GAME.gameScreen.getGameManager().currentLevel + "");
        //TODO: Another arrangement for the experience needs to be made.
        this.GAME.gameScreen.getGameManager().maxExperience += 35;
        this.GAME.gameScreen.getGameManager().currentExperience = 0;
        Gdx.app.debug(TAG, this.GAME.gameScreen.getGameManager().currentExperience + "");
    }

    this.levelProgressBar.setWidth((int) (maxExpDividedInPixels * this.GAME.gameScreen.getGameManager().currentExperience * this.scaleFactor));
}


texts: How to implement turn-based game engine?

texts:
Let's imagine game like Heroes of Might and Magic, or Master of Orion, or your turn-based game of choice. What is the game logic behind making next turn? Are there any materials or books to read about the topic? To be specific, let's imagine game loop:

void eventsHandler(); //something that responds to input
void gameLogic(); //something that decides whats going to be output on the screen
void render(); //this function outputs stuff on screen

All those are getting called say 60 times a second. But how turn-based enters here? I might imagine that in gameLogic() there is a function like endTurn() that happens when a player clicks that button, but how do I handle it all? Need insights.


texts: How do I correctly use GetComponent to get the rigidbodies of each element in an array of colliders?

texts:
I was trying to implement an AddExplosionForce-script that was shown in a Unity live training session a few years back. It has out of date calls to rigidbodies because it uses the old gameobject.rigidbody way of accessing them. I tried doing the standard process of

declare a rigidbody,
link it to a GetComponent<>, and
act on the rigidbody through the resulting variable.

However, as shown below, the rigidbodies I need to interact with are used in a foreach loop that goes through an array of colliders. How do I access the rigidbody of each collider in the array as it is used? (and if that is the wrong approach, please let me know). Will using GetComponent in that way harm performance?

Here is the original script from the video, w/ minor comments. I have left out my botched attempt at fixing it for the sake of brevity.

public class MassExplosionScriptOriginal : MonoBehaviour
{
    public float force;
    public float radius;

    void Update()
    {
        if(Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100))
            {
                Collider[] colliders = Physics.OverlapSphere(hit.point, radius);
                // overlap sphere collects all the colliders that it overlaps
                // with/touches. From  the point you click (hit.point), create a sphere of the
                // given radius (radius),collect all the colliders from the objects overlapped,
                // and then return them with the array colliders.

                foreach (Collider c in colliders) // declare a variable to hold a //collider
                {
                    if (c.rigidbody == null) continue;
                    // the if statement clause says that, if the collider touched //has no rigidbody, then skip it and continue on.

                    c.rigidbody.AddExplosionForce(force, hit.point, radius, 1, ForceMode.Impulse);
                    // Whenever you click, this script will collect all the
                    // colliders and then apply the explosive force to them. It works on everything
                }
            }
        }
    }
}


texts: Optimal way to select a random item from a list based on its chance to appear in Unity

texts: I am creating a random object spawning script in Unity with c#, and am wondering what the ideal way to do this task would be. So I have a list of 31 objects or so, of my special class type. Each one has an arbitrary number assigned as it's weight. This number is divided by the sum of all their weights and multiplied by 100 to make their percent chance for appearing. It's at this stage where I'm stumped. How should I go about selecting them with a random number between 0 and 100? My first idea was to give each one a range and if the random number falls within it, I select that one, but that method does not sound like it would be the most elegant and would involve like 31 IF statements. What is the standard way to do this sort of random selection?


texts:
This is sort of a multidisciplinary question, so I'm asking it here rather than on one of the other Stack Exchange sites.

I've been toying with the idea of making a game that's a mix between Minecraft and Kerbal Space Program, where the world is actually a planet and can be traveled around (either on the ground or in orbit) seamlessly, yet still consisting entirely or mostly of cubes à la Minecraft.  It turns out this is actually incredibly difficult to wrap my head around!

There are a few requirements and concessions.

Requirements

Must be able to travel and build on all parts of the planet seamlessly (poles included)
Every tile must be able to be mapped exactly or roughly to a spherical coordinate.

Concessions

Planet's perceived 'radius' at varying depths can be uniform.
Depth of buildable area can (and should) be limited, meaning you don't need to be able to tunnel into the center of the planet and you don't need to be able to make an absurdly large tower.

Those are the main points, and the problem is open to interpretation and more concessions are able to be made so long as the illusion of being on a planet is maintained.

Initial Idea

Here is an I've had that may have some merit but I'm not sure if it'd actually work.

Tesselated Platonic Solid

The idea here is to create a 'virtual' sphere made of a patchwork of faces of a platonic solid (e.g. cube, icosahedron, octahedron).  The faces represent a plot of flat land, with each edge being the 'portal' to another faces and so on.  In this way the world is always 'flat' and you are basically traveling over a 2D unwrap of the original shape.

One of the problems with this method is that with some tesselated platonic solids (such as the cube above), the tesselated faces are warped and the surface area of each face is not uniform.  A little bit of this is acceptable, but not too much.

The Question

The real question here is ultimately "is this possible?" and if so, what would be the best method to achieve all of the requirements.  If not, what kind of concessions would I need to make to make a believable world?


texts: River to nowhere - how do I make a pathfinder move to a destination that doesn't exist yet?

texts:
Let me start with the basics. Here's what I have:

A height map built on a few different combinations of noise functions
Rivers that are generated after the height map and flow from pseudorandom points to water following an A* algorithm

What I'm trying to do:

Create a "zoomed in" portion of this map without generating the whole map

Why?

The map is very large, and storing all the points in the height map in its zoomed-out form already takes 100+ Mb.
I decided the best way to store maps is just store the seeds used to generate them, which takes a couple of kilobytes.
This allows me to generate identical maps every time
However, when it comes to rendering such a map, the size does matter, since a bigger map means a bigger array/map/list holding it and a bigger chunk of memory dedicated to it.
So instead of rendering the whole map at once, I want to be able to render small, manageable sections and stitch them together into a full map with a higher resolution.

I figure that I can just sample the noise function more frequently, and this will fill in points in between points to increase resolution. This works. The problem is when I get to edge cases.

In the full map, I make the edge believe that everything beyond it is a copy of the edge tile in question.

When I get to the smaller section of the map, I'm not quite sure how to deal with the edge case, especially when it comes to rivers:

Say a river in the large map starts outside of the smaller section, but flows through the smaller section. How do I make sure that river is created?

Or say a river starts in my small section but ends at an ocean that isn't located in that section - an ocean that isn't generated at all but theoretically exists as a result of the noise function at those coordinates. Now what do I do?

I have an idea of a possible solution, but I don't know how to execute it. I generate sets of river tiles in my world generation code, and I could just generate a full map at low resolution and copy the river tiles to the smaller map. However, this would leave gaps in the river, realistically in every other tile if I zoomed in to 2x scale. Is there some way I can fill in surrounding tiles to ensure that my river won't change scale?

If you would like code or pictures, please comment and I'll post them. I'm just not sure what I need to include that would actually be helpful and not just clutter.

Edit: I'm adding some pictures that might help explain the situation, everyone likes pictures right? The first one is an "unzoomed" map. The second one has twice the resolution of the first - the equivalent of zooming in on the map but still generating the whole thing. You can see that some of the rivers are now flowing in different directions (I made sure they start in the same place) because the terrain is now more detailed and they have found better paths. I'm not as concerned about that as I am about the questions in bold above. I don't need multiple maps at different resolutions, I just need one big map at high resolution.


texts:
I am creating a maze type puzzle game where there is a grid and the user can create their own maze but I need help in writing an algorithm which finds the following things:

How many dead ends are there. (It should return 4 tunnels which are marked red)
How many of those dead ends don't lead to the exit. (It should return 3 tunnels as only 1 dead end leads to the END point)
Which dead ends lead to the end. (*3rd dead end only)

I am new to writing algorithms so I haven't written code for this yet. How can I identify dead ends, and which ones don't lead to the exit?


texts:
So my game is done for now but every time it flashes on the screen and my game loop is awful. So crowded with logic.

I need to learn more about games and how they are running. My idea now is that at the heart of the game you have a while loop. Inside that you are checking for events to happen. Each time an event happens, you spawn a thread that accomplishes a task.

You then have a layer that draws on the screen the "map". Also a layer that says where objects collide. And finally the logic of how objects interact.

I am using C++ and SDL and I need a complete tutorial that takes me through a complex example to get started. I am a good programmer but have no experience with games. Any suggested tutorials would help.

All tutorials I have found so far are too easy and don't do anything worth while.


texts: Switching songs - MediaPlayer lags the game

texts:
When the player encounters a boss in the game I'm working on, I want to have the music change. It seems simple enough with the MediaPlayer class to fade out the current song, switch to another, and then fade the new song in. However, at the point where the second song starts, the game freezes for a split second. The songs in question aren't particularly large either - the first song is 1.7mb and the second song is 3.1mb, both mp3 format. This is the code I'm using to do it:

protected void switchSong(GameTime gameTime)
{
   if (!bossSongPlaying)
   {
      MediaPlayer.Volume -= ((float)gameTime.ElapsedGameTime.TotalSeconds/10);
      if (MediaPlayer.Volume < 0.05f)
      {
         MediaPlayer.Play(bossSong);
         MediaPlayer.Volume = 1.0f;
         bossSongPlaying = true;
      }
   }
}

What can I do to eliminate that momentary hang?


texts: Ideas wich design patterns apply in my school assignment

texts:
For a assignment for school i've to develop a game in Microsoft XNA 4. Let me first clear out that my intention of this post is NOT to give me codes. I want to figure out things by my self. The intention of this post is to help me and give me advice wich design patterns may be better to apply in wich situation.

This game should use the following design patterns:

strategy
factory
decorator
singleton
observer
template

The assignment is as follow:

In this game the player should avoid the attack from his enemies who want to attack his spaceship. The enemies have their own way of attack and movement.

When the game starts the player has one cannon who can shoot bullets each 0.2 seconds. The spaceship can move horizantally with the keyboard. With the spacebar the player kan shoots bullets.

There are 3 kind of enemies who have their own attack and the way they move.

Chure : Moves horizantally from left to right, each time when the chure hits the edge
he moves down and again he move horizontally but this time in the opposite direction    (thus from right to left). Each chure drops at any time (random) a bomb. Each level the speed of the drop will increase.
Thege: Moves from the corner of the stage diagonal to the player. When the Thege hits the player, the player loose one life and starts the level again. When the Thege don't hit the player and reach the bottom of the stage he will remove from the stage and won't come back again in that level.
Sinode : Moves from top to bottom of the stage, when the Sinode reach the bottom of the stage hi moves the opposite direction (from bottom to top). The Sinode stays on the stage as long as the player didn't shoot him. When the player shoots the Sinode he will be remove from the stage.

Each enemie can carry an upgrade wich will be released when he will be shot by the player. either the enemie has a upgrade or not has been choosen randomly. There are three kinds of upgrades. The player can use his spaceship but once expand with each type of upgrade. If the player already has a upgrade the upgrade will remove from the stage.

The three type of upgrades are:

Lasers (Specs aren't important)
Rockets (Specs aren't important)
Guided missile (Specs aren't important)

some conditions to the game:
 - The game consists of 3 levels
 - Each player starts with 3 life
 - The level will be ended when all of the enemies are destroyed or not visible on the stage.

Now i've some ideas wich design pattern will be good by wich scenario but i would be gratefull if u guys can help me out how i can implement the factory and the observer pattern in this case and maybe help me out and give advice how i can implement the rest of the patterns.

Thank u


texts: Is it possible to store diffuse and normal maps in the same texture area and preserve SRGB/linear space?

texts: Usually, one would want to upload texture data to OpenGL with GL_SRGB* for the internalformat of a texture, and GL_RGB* (or some other linear format) for normal data or specular highlight maps. We can minimize context switches by using a texture array, but that forces all textures to have the same internalformat. Is there a way to store all needed textures in a single texture array, but preserve colour spaces? Or should I convert from SRGB to linear space when uploading texture data?


texts: How can I change the value of a matrix uniform in an OpenGL vertex shader?

texts:
I'm new at OpenGL. I have a uniform transform matrix in a vertex shader file. I want to modify the matrix by individually assigning each values in the matrix. How can I do that in C++?

I learned that we have to get location variable by using glGetUniformLocation but I am not sure how to access and modify index n with it with glUniform.


texts: How to connect nodes in a star pathfinding for platformer games?

texts:
In this thread, it tells that in 2d platformer games, I should pre-define and connect node to find the correct path.

But I don't understand how to find the node's children. In my program, I define map as following, 0=free space, 1=solid terrain, 2=node

the original map definition is:

numpy.array([ [0,0,0,0,0,0,0,0,0,0,0],
              [0,0,0,0,0,0,0,0,0,0,0],
              [0,0,0,0,0,0,0,0,0,0,0],
              [0,0,0,0,0,0,0,0,0,1,1],
              [1,1,1,1,1,1,1,0,0,0,0],
              [0,0,0,0,0,0,0,0,0,0,0],
              [0,0,0,0,0,0,0,0,0,0,0],
              [1,1,1,1,1,1,1,1,1,1,1], ])

the map after adding nodes

numpy.array([ [0,0,0,0,0,0,0,0,0,0,0],
              [0,0,0,0,0,0,0,0,0,0,0],
              [0,0,0,0,0,0,0,0,0,2,2],
              [2,2,2,2,2,2,2,0,0,1,1],
              [1,1,1,1,1,1,1,0,0,0,0],
              [0,0,0,0,0,0,0,0,0,0,0],
              [2,2,2,2,2,2,2,2,2,2,2],
              [1,1,1,1,1,1,1,1,1,1,1], ])

so the map should be so

In the original A* (A star) algorithm, it searches 8 directions and every direction  checks only one node if available.

But in a platfomer, I don't know how to deal with this, there are too many possibilities. For example, assuming the character's jump value is 3, then we go to left now I can:

jump to left using 200% power, (keep pressing left while jumping and falling, move 6 steps actually)
jump to left using 166% power
jump to left using 133% power
jump to left using 100% power
jump to left using 66% power
jump to left using 33% power
just walk (the paths 1-7 in the pic)

8 directions and bigger jump value lead to more possibilities.  What's more, there are countless  possibilities when falling  from a high solid terrain.

For every possibility, in order to connect the nodes, I need to check the corresponding coordinate in the map (array) if existing node.

So I am confused. Am I over-complicating / misunderstanding A* or did I miss something because it requires a huge calculation for every node in a big map like 500*500?


texts: Updating RigidBody rotation and velocity only updates it's rotation

texts:
I'm currently making spaceship controller script. Control is simple, W/S to move forward/backward, A/D/ to rotate ship by Y Axis(yaw).

Spaceship is RigidBody node and has CollisionShape as children.

Here's the code for move forward/backward:

export var speed = 1
export var max_speed = 10
var current_speed = 0

export var key_acceleration = KEY_W
export var key_deceleration = KEY_S

func process_movement(delta):
    if Input.is_key_pressed(key_acceleration):
        current_speed -= speed * delta
    elif Input.is_key_pressed(key_deceleration):
        current_speed += speed * delta

    current_speed = clamp(current_speed, -max_speed, max_speed)

    linear_velocity = Vector3(0, 0, current_speed)

I need to limit it's maximum speed, so I updated velocity directly, not using something like add_force.

Next is rotating code:

export var yawing_speed = 0.01
export var max_yawing_speed = 0.02
export var yaw_stop_threshold = 0.001
var current_yaw = 0

func process_yaw(delta):
    if Input.is_key_pressed(key_yaw_left):
        current_yaw += yawing_speed * delta
    elif Input.is_key_pressed(key_yaw_right):
        current_yaw += -yawing_speed * delta
    else:
        if current_yaw > 0:
            current_yaw -= yawing_speed * delta

            if current_yaw < yaw_stop_threshold:
                current_yaw = 0
        elif current_yaw < 0:
            current_yaw += yawing_speed * delta

            if current_yaw > yaw_stop_threshold:
                current_yaw = 0

    current_yaw = clamp(current_yaw, -max_yawing_speed, max_yawing_speed)
    rotation.y += current_yaw

In this code, I updated rotation.y directly. Each of this function works if run separately, however run these together, it only changed rotation, not velocity.

func _physics_process(delta):
    process_movement(delta)
    process_yaw(delta)

Change order of process_movement and process_yaw doesn't change anything. If I just run one of process_movement and process_yaw, it works perfectly.

Why my rigidbody ignored velocity and only rotated? Any advice will very appreciate it.


texts: How can I ungrab the grabbed Object in Unity?

texts:
I modified a grab Script to my purpose, I can grab the Object and make it a parent to the character with the Key "G" but I want to let it go and detach the parent of the picked Object with "H" with the Code: "hit.transform.parent = null;" but i cant get it to work, I dont know where to put it.

Code:

[SerializeField]
private Transform RayCastGrab;
[SerializeField]
private float raySize;
private Transform pickUpObj;
private Vector3 lastPos;

public LayerMask GrabLayer;

void Update ()
{
    PickRayLayer();
}

void PickRayLayer()
{
    Ray rayF = new Ray (RayCastGrab.position, transform.forward);
    Debug.DrawRay(rayF.origin, rayF.direction * raySize, Color.black);

    RaycastHit hit;

    if(Input.GetKey (KeyCode.G))
    {

        if (Physics.Raycast(rayF, out hit, 2f, GrabLayer))
        {
            //Picking up the Object and make it a parent of Player
            pickUpObj = hit.transform;
            hit.transform.parent = this.transform;
        }
    }

    if(Input.GetKey (KeyCode.H))
    {
        //Should let the grabbed Object go and detach it from parent of Player
        if(pickUpObj)
            pickUpObj = null;
        transform.parent = null;
    }

    if(pickUpObj)
    {
        pickUpObj.transform.position += transform.position - lastPos;
    }


texts: Add buttons into List when mouse is HoldDown?

texts:
I have three buttons in my menu. What I need to do is when I click on first button it becomes the first element in my list. Now, when I keep mouse button down and move it to the second button it becomes the second second element in my list. The same with the third button.
public List<GameObject> UI_Button_List = new List<GameObject>(3);

void Update()
{

    if (Input.GetMouseButtonDown(0))
    {

    if (UI_Button_List[0] == null)
    {
        UI_Button_List[0] = EventSystem.current.currentSelectedGameObject.gameObject;
    }

    if (UI_Button_List[0] != null && UI_Button_List[1] == null)
    {
        UI_Button_List[1] = EventSystem.current.currentSelectedGameObject.gameObject;
    }

    if (UI_Button_List[0] != null && UI_Button_List[1] != null && UI_Button_List[2] == null)
    {
        UI_Button_List[2] = EventSystem.current.currentSelectedGameObject.gameObject;
    }

    } // end if

}


texts: Multithreading: Each system on a different thread or a thread pool?

texts:
I'm building a fairly involved game using OpenGL and C++. I've been thinking about how to implement multithreading, and the two options are:

1) Each system (Graphics, Audio, Physics, et cetera) gets their own dedicated thread that they run off of.

2) Implement a thread pool, that picks up a jobs from a queue (priority queue), executes it and gets re-inserted into the pool to wait for new available job.

I was wondering which one is generally considered better: in terms of performance, maintenance, scalability, code smell, et cetera.


texts: Performance issues with different types of uniform buffer

texts:
I've tested different buffer layouts, because I'm confused about some performance issues. That are my test buffer (OpenGL 4.1, GLSL 410, GT 750M, MacBook Pro):

Test #1: Using fixed struct buffer with unused variables inside

struct SPerFrameUniformBufferVS
{
    vec4 m_UnusedButPlaned1;
    vec4 m_SometimesInUse2;
    vec4 m_UnusedButPlaned3;
    vec4 m_Used4;
    mat4 m_Used5;
    mat4 m_Used6;
};

layout(row_major, std140) uniform UPerFrameUniformBufferVS
{
    SPerFrameUniformBufferVS m_PerFrameUniformBufferVS;
};

Test #2: Same buffer without unused variables

struct SPerFrameUniformBufferVS
{
    vec4 m_Used4;
    mat4 m_Used5;
    mat4 m_Used6;
};

layout(row_major, std140) uniform UPerFrameUniformBufferVS
{
    SPerFrameUniformBufferVS m_PerFrameUniformBufferVS;
};

Test #3: Using fixed buffer with unused variables inside

layout(row_major, std140) uniform UPerFrameUniformBufferVS
{
    vec4 m_UnusedButPlaned1VS;
    vec4 m_SometimesInUse2VS;
    vec4 m_UnusedButPlaned3VS;
    vec4 m_Used4VS;
    mat4 m_Used5VS;
    mat4 m_Used6VS;
};

Test #4: Same buffer without unused variables

layout(row_major, std140) uniform UPerFrameUniformBufferVS
{
    vec4 m_Used4VS;
    mat4 m_Used5VS;
    mat4 m_Used6VS;
};

In my case i've the following performance results:

Test #1: 40 FPS
Test #2: 55 FPS
Test #3: 46 FPS
Test #4: >60 FPS

My application do 1558 draw and 2341 glGetUniformBlockIndex calls. glGetUniformBlockIndex seems to be the bottle neck, because it is much higher in Test #1 and Test #3.


texts: Which is better, one big level model or multiple smaller level models?

texts: I am writing a game in XNA 4 and I want to have something like a corridor. Do you think that is better to use one big and solid model, or to use multiple small parts (window, stairs, door...)?


texts: Determining the X, Y co-ordinates in sprite sheets

texts:
I am new to Android COCOS2D and developing a simple game to start with. I am developing a game for kids in which the kids shall spell out the names of the fruits they select. I have developed the sprite sheet consisting of pictures of several fruits. Kindly tell me how will the fruit on which the kid taps will get selected. How are the x and y co-ordinates in the sprite sheet determined??

I shall be thankful in case anyone can help me out with this. Thanks in advance


texts: In which software do the professional game developers create 3D Model?

texts: I am just thinking about beginning game development in xna c#. However, I don't know (and no tutorial teaches) how do professional game developers create a 3D Model/Scene. How can we create a realistic looking model and what is the hardware configuration needed in machine for using such a software?


texts: Applying prerecorded animations to models with the same skeleton

texts:
well my question sounds a bit like, how do I apply mo-cap animations to my model, but thats not really it I guess. Animations and model share the same skeleton, but the models vary in size and proportion, but I still want to be able to apply any animation to any model. I think this should be possible since the models got the same skeleton bone structure and the bones are always in the same area only their position varies from model to model.

In particular Im trying to apply this to 2D characters that got 2arm, 2legs, a head and a body, but if you got anything related to that topic even if its 3D related or keywords, articles, books whatever Im gratefull for everything cause Im a bit stuck at the moment.

cheers

Jery


texts:
Im trying to switch from the glTranslate etc to my own Matrices, but for some reason it does not work. Here are my 2 functions to create the view- and projection matrix:

public Matrix4f getViewMatrix() {
    Matrix4f viewMatrix = new Matrix4f();
    viewMatrix.setIdentity();
    viewMatrix.translate(game.player.position);
    viewMatrix.rotate(game.player.rotation.x, new Vector3f(1.0f, 0.0f, 0.0f));
    viewMatrix.rotate(game.player.rotation.y, new Vector3f(0.0f, 1.0f, 0.0f));
    viewMatrix.rotate(game.player.rotation.z, new Vector3f(0.0f, 0.0f, 1.0f));
    //System.out.println(viewMatrix);
    return viewMatrix;
}

public Matrix4f getProjectionMatrix() {
    FloatBuffer projectionBuffer = BufferUtils.createFloatBuffer(16);
    GL11.glGetFloat(GL_MODELVIEW_MATRIX, projectionBuffer);
    Matrix4f projectionMatrix = new Matrix4f();
    projectionMatrix.load(projectionBuffer);
    return projectionMatrix;
}

I send those 2 matrices to the Vertex shader with a uniform, and use:

gl_Position = view_matrix * proj_matrix * vec4(in_position, 1.0);

Where in_position is the coordinate of the vertex.

I do see some things on the screen, but it's very, very buggy, and nothing is right about it.
If I use the build-in gl_ModelViewProjectionMatrix in the shader and use glTranslate and glRotate in OpenGL, it works perfectly fine.

What am I doing wrong here?

Here is the output of me view projection together with the camera position:

0.5095141 0.0 -0.8604623 1.1625774
0.7321221 0.52541286 0.43351877 16.980185
0.45209795 -0.8508474 0.26770526 0.8665553
0.0 0.0 0.0 1.0

Vector3f[1.1625774, 16.980185, 0.8665553]


texts: Moving gameobject with animation according to my script Unity3D

texts:
I am developing a game with Unity3D with an horizontal list of elements which you can move with arrows. Here you can see an example:

I have created animations in order to modify the alpha value of the elements and to move them according to my script:

void Update () {
    if (managePositionInUpdate) {
        transform.position = Camera.main.ScreenToWorldPoint (new Vector3 (Screen.width * positionX, Screen.height * positionY, 10));
    }
}

In my animation, the alpha value of the centered element is initially 1 and after the animation the alpha value is 0.5, this works correctly; however, in this animation I have also put positionX of my script initially with a value A, and after the animation with a value B, and this doesn't work correctly.

I have tested the code and it works correctly without animation, but I can't get it works according to my animation. What can I do? I have read about apply root motion but It also doesn't work for me.


texts: Is Patreon a viable way to implement a subscription-based monetization strategy?

texts:
I am looking for an alternative to premium currency and microtransactions as a monetization strategy for a persistent browser game. Subscriptions seem the straightforward solution, though I don't want to set up my own payment system.

Can I use Patreon (or similar membership platforms) as a way to limit access to a premium server, or access to the game itself, for patrons only?

I couldn't find it in their guidelines if this sort of implementation is allowed.


texts:
I'm writing a 2d space game, and I want the players to be able to 'orbit' objects and other players (if they're fast enough, of course), but I'm having trouble coming up with the right way to think about this physically (I never took physics, so this part is hard for me).

Note that this is not a 'realistic' space sim -- more like boats, really, so I don't want to do this by having the objects actually have enough gravity to force the orbit normally, because that'll make players that didn't press the 'orbit' button get sucked in and not be fun.

Also, do note that the objects players are trying to orbit may themselves be trying to orbit another object or even be mutual orbits.

I'm using the RK4 integrator right now, though if that needs to change, I'm totally up for it.


texts: OpenGL - Drawing quad with 4 position coordinates

texts:
Im developing a graphically very simple program (Does not require any 3D) in opengl. The main issue is that the default float positions for vertices are based on percentages of the screen.

Basicly what I want is to be able to pass 4 coordinates: x1, y1, x2, y2 and draw a quad based on those coordinates. For example if it was (0, 0, 10, 10) It would draw a 10px by 10px box in the top left.

So far shaders for transformations like pos and scale have been implemented. But they do not provide enough fine control on the quad and access to window width, height and other variables.

I don't need actual code, pseudo code is more than enough. But if you are curious im using lwjgl 3 with java in the programmable pipeline.

Is there any way of doing this with shaders? Or should I be using a completely different method?


texts:
I have been banging my head against the wall with this for few days now with no improvement..
The problem is that after build my project keeps using over 30% of the GPU. Even in the editor it takes 20%+
I ended up making a new empty scene with few cubes with rigidbodies, but the performance was still going over 30%. It starts with 3-5 % and within the next 5-10 seconds starts climbing up.
I am using Unity 2019.1.12f1, but the problem is still there even on the newest Unity 2020 version.
The project is using LWRP.
I have played around with the quality settings but they seem to have absolutely no effect on the issue, besides turning the V-Sync on, which capped the framerate at acceptable levels.
I am using Windows 10 , my video card is Geforce GTX 1080 Ti.
Here are some screenshots + the project build
Project: https://easyupload.io/foqq5x