texts: Creating Seamless Perlin Noise Across Faces of Cube

texts:
I am writing a planet renderer and have stumbled into a problem that I cannot solve. I am generating heightmaps in a glsl pixel shader. These heightmaps are generated for every quad in the quadtree that the planetary sphere is built on. The sphere is a cube transformed by the equations found here. The way I am generating a point to be inputted into the noise function in the shader is shown here:

vec2 coords = vec2((gl_FragCoord.x - 0.5) * m_Scale , (gl_FragCoord.y - 0.5) * m_Scale)+m_Offset;
vec2 position = vec2(coords.x,coords.y);
vec3 noiseInput;

 if(m_t == 1){

 noiseInput = vec3(spherize(vec3(position.x, 0.0, position.y) + m_faceOffset))/m_worldSize;
}else if(m_t == 2){

noiseInput = vec3(spherize(vec3(position.x, position.y, 0.0) +  m_faceOffset))/m_worldSize;

}else if(m_t == 3){

noiseInput = vec3(spherize(vec3(0.0, position.x, position.y) +   m_faceOffset))/m_worldSize;

}

Here "m_Scale" is the length of the quad's edges divided by the lengths of one of the root node's sides. m_Offset is a variable which offsets the quad from the origin. m_worldSize represents the planet's radius. m_faceOffset is the variable which translates the quad to it's correct face of the cube (faceIndex = faceOffset):

if(c.face.equals(faces.TOP)){
                    c.faceIndex = new Vector3f(nhsize, hsize, nhsize);
                }else if(c.face.equals(faces.BOTTOM)){
                    c.faceIndex = new Vector3f(nhsize, nhsize, nhsize);
                }else if(c.face.equals(faces.FRONT)){
                    c.faceIndex = new Vector3f(nhsize, nhsize, hsize);
                }else if(c.face.equals(faces.BACK)){
                    c.faceIndex = new Vector3f(nhsize, nhsize, nhsize);
                }else if(c.face.equals(faces.RIGHT)){
                    c.faceIndex = new Vector3f(hsize, nhsize, nhsize);
                }else{
                    c.faceIndex = new Vector3f(nhsize, nhsize, nhsize);
                }

where hsize is the radius of the planet and nhsize is the radius negated.
Finally, m_t describes which face of the cube the quad is supposed to be on:

if(q.face.equals(QuadMesh.faces.TOP.toString()) || q.face.equals(QuadMesh.faces.BOTTOM.toString())){
                    t = 1;
                    }
                if(q.face.equals(QuadMesh.faces.FRONT.toString()) || q.face.equals(QuadMesh.faces.BACK.toString())){
                    t = 2;
                    }
                if(q.face.equals(QuadMesh.faces.RIGHT.toString()) || q.face.equals(QuadMesh.faces.LEFT.toString())){
                    t = 3;
                    }

"spherize" is the function which transforms a point on the cube to a point on the sphere:

     denom1 = hWorldSize * hWorldSize * 2f;
 denom2 = hWorldSize * hWorldSize * hWorldSize *hWorldSize * 3f;

     vec3 spherize(vec3 v){
float x = (v.x * (sqrt(1.0-((v.y*v.y)/m_denom1)-((v.z*v.z)/m_denom1)+(((v.y*v.y)*(v.z*v.z))/m_denom2))));
float y = (v.y * (sqrt(1.0-((v.x*v.x)/m_denom1)-((v.z*v.z)/m_denom1)+(((v.x*v.x)*(v.z*v.z))/m_denom2))));
float z = (v.z * (sqrt(1.0-((v.y*v.y)/m_denom1)-((v.x*v.x)/m_denom1)+(((v.y*v.y)*(v.x*v.x))/m_denom2))));
return vec3(x,y,z);
 }

This all leads to the following problem:

As one can see the faces of the "cube" do not match up.
I am at a loss here; I use the exact same methods described above to transform the vertices of the cube to those of a sphere.

Any and all help is highly appreciated. If one needs more code to form an accurate opinion please let me know.


texts: How to stop diagonally in an event driven input system?

texts:
Example scenario:

Assume 2 dimensional top down movement system.

Given that I have 4 directional keys ( UP / DOWN / LEFT / RIGHT ), I am able to move in 8 different directions 4 perpendicular and 4 diagonal.

As long as a directional key is pressed there exists an assumed movement, if all directional keys are released then movement is assumed to have stopped.

If I have an event driven input system in place (instead of polling for key states every frame there is an observer which receives and acts upon events based on which keys are pressed and released) is it possible to stop movement in a diagonal direction given that the events received will be sequential?

In a polling driven input system, as long as I would be able to release both keys fast enough for them both to register as released at the same time on the next frame there would be no need to change the direction and the movement would conclude in a diagonal state.


texts: How to loop section from a song correctly?

texts:
I'm programming a little Music Engine for my game in C# and XNA, and one aspect from it is the possibility to loop a section from a song. For example, my song has an intropart, and when the song reached the end ( or any other specific point ), it jumps back where the intropart is just over. ( A - B - B - B ... )

Now I'm using IrrKlank, which is working perfectly, without any gaps, but I have a problem:

The point where to jump back is a bit inaccurate.
Here's some example code:

public bool Passed(float time)
    {
        if ( PlayPosition >= time )
            return true;
        return false;
    }
//somewhere else
if( song.Passed( 10.0f ) )
   song.JumpTo( 5.0f );

Now the problem is, the song passes the 10 seconds, but play a few milliseconds until 10.1f or so, and then jumps to 5 seconds. It's not that dramatic, but very incorrect for my needs. I tried to fix it like that:

public bool Passed( float time )
{
      if( PlayPosition + 3 * dt >= time && PlayPosition <= time )
             return true;
      return false;
}

( dt is the delta time, the elapsed time since the last frame )

But I don't think, that's a good solution for that.

I hope, you can understand my problem ( and my english, yay /o/ ) and help me :)


texts: How can I make several 2D objects move in complex pre-defined patterns?

texts:
I will be making my mobile 2D game in Unity and the objects in the game will have complicated movement. For example, there will be lots of squares (around 10-15 tiny squares) in the middle of the screen which will move in pre-defined patterns like in the shape of an X or an M or O. The tiny squares forming the pattern M will be constantly moving within that X symbol and will be constantly instantiated at one end and destroyed at the other to achieve the effect (or just allowed to move within a pattern if the patterns shape permits).

Unity tutorials explain the basics on how to work with the transform component, etc but I have been looking for a resource that tells you how to achieve the above. How can I implement it?


texts: Sprite with transparency: Create box collider (ignoring transparent area)

texts:
I have a sprite which has a transparent area in it. The non-transparent area is a free-form graphic (red). I would like to create a box collider around it (yellow), but ignoring the transparent area.

Some notes to the image above:

Left: This is what happens, if I apply a PolygonCollider2D. The yellow line represents the area covered by the PolygonCollider2D. This is not what I want.
Middle: This is what happens, if I apply a BoxCollider2D. The yellow line represents the area covered by the BoxCollider2D. This is also not what I want, as it includes the transparent area of the sprite.
Right: This is what I want: Have a BoxCollider2D outside my free-form graphic.

Here's how I currently load my sprite data into the game during runtime:

My sprites are located in the /Assets/Resources/SceneData/... folder structure of my project. The graphics are stored as .png files.
When loading a level, I load the required graphics as sprites like this:

    var sprite = Resources.Load<Sprite>("SceneData/AfternoonAtTheBeach/DragAndDrop/Graphics/Level1/ElephantWithIceCream");

"ElephantWithIceCream" is the .png file (Resource.Load wants me to refer to this file without file extension)

After that, I create a new game object and attach a SpriteRenderer component to it. The sprite is assigned to the
SpriteRenderer by setting the sprite attribute of the SpriteRenderer component.

My first thought on how to solve my problem was to do something like this:

Create a PolygonCollider2D and try to convert it into a BoxCollider2D. But I was not able to find code examples on how to do this.

After that, I thought of trying it to do like this:

Create a PolygonCollider2D and try to extract some useful information out of it (such as bounds, center, extents, etc...).
Delete the PolygonCollider2D and create a BoxCollider2D. Use the previously extracted info to create the BoxCollider2D.

But I fail doing so. I am also a bit confused as sometimes they refer to world space or local space. Does anyone have a working recipe for doing something like this? I do not really understand how to work with center, bounds and extents. If there is any better way of doing this, I am highly interested. Thanks a lot for your help!


texts:
I get the following errors on the LibGDX tutorial "Simple App"

  Exception in thread "main" java.lang.UnsatisfiedLinkError: no gdx64 in
  java.library.path     at java.lang.ClassLoader.loadLibrary(Unknown
  Source)   at java.lang.Runtime.loadLibrary0(Unknown Source)   at
  java.lang.System.loadLibrary(Unknown Source)  at
  com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:118)
    at
  com.badlogic.gdx.backends.lwjgl.LwjglNativesLoader.load(LwjglNativesLoader.java:41)
    at
  com.badlogic.gdx.backends.lwjgl.LwjglApplication.(LwjglApplication.java:52)
    at com.badlogic.drop.DesktopGame.main(DesktopGame.java:7)

I copied and pasted the final code onto the project, but I don't know why it wont run.

Whats the problem?  Is it the project set-up?


texts: Is it better to use an image component or to draw on a canvas?

texts:
I am developping a small 2D RPG with JavaFX, although my question might apply to any toolkit or even any language for the matter.

I have two choices to display the characters, the scenery, the items and other displays such as a life bar or an inventory:

Put them in imageView printed on top of a background.
Draw them directly on the canvas (graphicsContext) of the background.

Which is the best practice? Is there a significant difference in term of speed, for example?


texts: I've made 2 scenes where a room is another scene and the other is the outside of it. But whenever I do something in either scenes, and enter the other, it resets everything I did in the first one. I'm thinking of making the scene running in the background the whole time but how can I do that?


texts: OpenGL gradient banding on Samsung Galaxy S2 Android phone

texts:
I've got a live wallpaper out on the market which uses OpenGL to render some basic shapes and a flat plane.  The simple lighting creates a gradient effect across the plane, which looks fine on most devices.  The Samsung Galaxy S2 series seems to have some trouble rendering the gradient, though, as you can see in this screen shot:

The color banding looks awful, especially compared to this screen shot from an Incredible:

I'm using a 565 EGL config in both cases, so I believe this is just a display issue with the GS2 devices.  Can anyone confirm this suspicion?

Is there any solution to the banding?


texts:
I'm in the process of learning DirectX and in the examples supplied with the book I get the following error:

Error   29  error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1800' in d3dApp.obj

Google didn't really come up with anything, or rather I was struggling to understand how to fix it from what I read, could someone explain what it means/how to fix it?

The line of code that is causing it is:

ID3D10Blob* compiledShader = 0;

HR(D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(),
    0, md3dDevice, &mFX));


texts:
I have a 2D square. It has an initial position translation T0. It rotates about the Z axis, about an arbitrary point, say 45 degrees, then moves (translates) along the +X axis some distance.

I'm trying to put together the 4x4 homogeneous transform (this example is only 2D but the problem is really in 3D) to move the square but I seem to be missing something, and I get odd results.

T0 := initial translation to some point
T1 := center of rotation point
Rz := rotation Matrix about Z and about point located at T1
T2 := additional translation
TF := final transform
p := a vertex of the square to rotate
If I use the following sequence -

TF = T2 * T1 * Rz * T1^-1 * T0

I can rotate about T1 as long as T2 is (0,0).

If I use only T0  - by combining T0 and T2 - it rotates correctly but it moves along the rotated X axis rather than the original X axis.

So, it seems I can

Transform first and get the rotation correct but not the translation
OR
Transform last and get the translation correct but not the rotation.

example:

move to 10,10
rotate about 9.5, 9.5
move -5,0

It seems there should be a way to get my desired result, but I seem to be missing something.

Thanks

Rick


texts: Where should I handle player movements in a Java Game?

texts:
I had an old pure Java 2D top-down game that I'm trying to reformat a bit. Before, I had a bit of a messy game loop that didn't use delta timing for any movements or animations. Now, I'm trying to implement this delta timing.
I implemented delta timing into the game loop with two framerates (60FPS and 30FPS) to test it, but I noticed that the movement created with the 30FPS was half of what was obtained using the 60FPS.
When I moved the player, I did something like:
posX += Game.deltaTime * SPEED;

and this didn't work well because the delta time was the same for both the 30FPS and 60FPS.
So, I did some calculations... I run into some problems if I use change the player's position from the update() method, because it runs at a constant 60UPS.
Here are my calculations

int deltaXPerSecond = Game.deltaTime() * SPEED * 60;

// To get the delta X over a second, I multiplied deltaX by 60 (UPS)
// with 30FPS, it was 9.9, with 200FPS it was 1.5

// Game Loop

private static final double UPDATES_PER_SECOND = 1.0 / 60.0;

@Override
        public void run() {

            /*
             * Note: This game loop uses Majoolwip's game loop.
             * https://www.youtube.com/watch?v=4iPEjFUZNsw&list=PL7dwpoQd3a8j6C9p5LqHzYFSkii6iWPZF
             */

            double firstTime = 0;
            // converts to seconds because System.nanoTime is extremely accurate.
            double lastTime = System.nanoTime() / 1000000000.0;
            double passedTime = 0;
            double unprocessedTime = 0;

            double frameTime = 0;
            int frames = 0;
            int fps = 0;

            boolean render = false;

            // Continuously repeats this loop until the game is stopped.
            while (running) {
                render = false;
                firstTime = System.nanoTime() / 1000000000.0; // converts to seconds.

                // Gets how many milliseconds have passed between now and the last time.
                passedTime = firstTime - lastTime;
                deltaTime = (float) passedTime;
                lastTime = firstTime;
                unprocessedTime += passedTime;
                frameTime += passedTime;

                while (unprocessedTime >= UPDATES_PER_SECOND) {
                    unprocessedTime -= UPDATES_PER_SECOND;
                    // Sets render to true. This makes the game render only when it updates
                    render = true;

                    // Updates the game
                    if (frameTime >= 1.0) {
                        frameTime = 0;
                        fps = frames;
                        frames = 0;
                        System.out.println("FPS: " + fps);
                    }
                    update();
                }

                if (render) {
                    frames++;
                    render();
                }
                else {

                    /*
                     * If the game doesn't need to render or update,
                     * the GameLoop thread sleeps for 1 millisecond,
                     * causing a decrease in CPU usage.
                     */

                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }

What am I doing wrong? Shouldn't these numbers be approximately the same regardless of the frame rate? Do I need to change the game loop? Please let me know what I am missing.


texts: Can I randomly generate an endless road?

texts:
So suppose we stand on a position(x0, y0) of a map. We can only move on the horizontal plane(no jump and stuff) but we can move forward, left, or right (in a discrete math way, i.e. integer movement).

As soon as we move to the next position(x1, y1), everything around us is generated randomly by a program. We could be surrounded by one of mountain, lake, and road. We can only move on the road. The road is always 2D as the map itself.

My question is, are we able to play this game endlessly? "End" means that we come across a dead end and the only way out is to go backward.


texts: Artificial Intelligence - when to update pathfind?

texts:
Right now I have a pathfind algorithm A* so I'm already using it to move the player around.
My problem comes to the NPC'S. They find the path to the player but if the player change the position they have to find a new path all the time? or there's something I can do to avoid so many calculations?

Example
I have an enemy 5 units of distance from the player.
He moves to 4 units of distance based in the path he already found and then search the path again? or does he make half of the path until he search for a new path?

I imagine making that for 5 or more enemies may make the game slow? (I never tested it before)
Any toughs?


texts: Correct way of modelling for a multiplayer FPS game

texts:
I was wondering what was the best way to model characters for an first person shooter game?

Assuming I have 2 modes to show, first person view (the player's view) and 3rd person view (viewing other players) - Here is a sample of what I mean

I guess the simplest way to do it would be managing only the 3rd person view, and try and make the camera on the player "look through the eyes" of the 3rd person model, but I failed to achieve any decent results using this method, due to the model's animation not working well in first person view.

Thanks


texts: How to leave trails that are equidistant apart from each other

texts:
I want bunch of circles to follow the player while keeping a distance apart.
So far I have this:
local p = {
  x=0,
  y=0,
  life={
    {x=0,y=0},
    {x=0,y=0},
    {x=0,y=0},
    {x=0,y=0}
  }
}

local last={x=p.x,y=p.y}
for l in all(p.life) do
  l.x = lerp(last.x,l.x,0.5)
  l.y = lerp(last.y,l.y,0.5)
  circfill(l.x,l.y,2,7)
  last={x=l.x,y=l.y}
end

But this makes it so the circles collapse into each other and the player. I want the circles to have a distance between themselves and the player.

I've also tried this:
  l.x = lerp(last.x*0.8,l.x,0.5)

This leaves a distance as I want but the trail is always on the upper left, barely following player.
I want the trail to stay always behind the player.
Probably I can achieve this by stop following if the distance is less than threshold.


texts:
Myself and two colleagues are working on making our first indie game for PC and, we decided to use Cocos2D + PyBox2D.  We decided this based on what we've seen of Cocos2D-iPhone games, but I'm not sure if Cocos2D-iPhone is just a port of the Python version with a few more features, or if it's far more advanced than the Python version.

I just want to be sure that I'm on the right track. (We also want to port our game to Android and iPhone if it is successful on the PC.)

Note: For the maps we will use Tiled , which is compatible with Cocos2D (both iPhone and Python versions, I think.)


texts:
I am having some trouble to receive and interpret mouse movement data from RawInput. Generally mouse input seems to work, I can query mouse buttons and receive updates of mouse movement.

The problem is that data.mouse.lLastX and data.mouse.lLastX are both 0 if the data is relative. However when the data is absolute there is no problem. Does anybody know how this can happen?

Let me know if you need some code in order to help.


texts:
The open source game Glest has models that feel detached from the ground that they sit on because of the hard edges.  In real life, grass is not flat!

What are the options and recommendations for breaking up the hard edges where the meshes of the models meet the terrain?  How do other games do it?  What are the options on a sliding scale of rendering performance and widespread GPU support?


texts: In Unity, how do I make separate mute buttons for sound-effects and music?

texts: I'd like to have a button to mute game sounds and another to stop the game music. How can I do this?


texts: How (if possible) would I change the BasicEffect Matrix mid draw

texts:
Say, for example, I have a list of enemies.  Each enemy is a textured quad which is the stored in a singular shared VertexBuffer and IndexBuffer with the buffer usage set to BufferUsage.WriteOnly (static buffers essentially).  Then only one call to DrawIndexedPrimitives would be needed to draw all enemies.  The problem is enemies have to move around at some point.  It is quite easy to change the BasicEffect Matrixes to get the desired result of enemy movement.

My question is how can I change the BasicEffect Matrixes after each Quad using only one static VertexBuffer and IndexBuffer?

Changing the Matrixes for movement is normal, right?

I thought about using a DynamicVertexBuffer instead, is this more effcient for my case?

What about 4.0 streaming?  Would a call to GraphicsDevice.SetVertexBuffers(array);  (where array is whatever you send it that frame) be a better idea?

I know this question may seem silly for quads considering SpriteBatch is pretty good at doing this already for sprites.  But, I am going to add in my own dazzling effects and want to draw textured quads this way. Plus, I'm also OCD and want this to be organized and efficient.

Any help on the matter is appreciated.


texts: Get a body from TiledMap via MapBodyBuilder and draw a sprite on it in LibGDX?

texts:
I use a various of MapBodyBuilder in my Libgdx project. I created a body from map.tmx via my MapBodyBuilder and in my SpriteBuilder buildSprite method i created its sprite:

sprite = new Sprite(atlas.findRegion("elementWood0532"));
sprite.setSize(sprite.getWidth() / B2D.PPM, sprite.getHeight() / B2D.PPM);
sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);

and in SpriteBuilder render method I draw it like this:

Vector2 pos = body.getPosition();
sprite.setPosition(pos.x - sprite.getWidth() / 2, pos.y - sprite.getHeight() / 2);
sprite.setRotation((float) Math.toDegrees(body.getAngle()));

//sprites drawing on bodys
game.batcher.enableBlending();
game.batcher.begin();
game.batcher.draw(sprite,
sprite.getX(), sprite.getY(),
sprite.getOriginX(), sprite.getOriginY(),
sprite.getWidth(), sprite.getHeight(),
sprite.getScaleX(), sprite.getScaleY(),
sprite.getRotation());
game.batcher.end();

but it didn't draw on the body.
please help.


texts: How can I scroll/animate up lines reading from a string to ui text?

texts:
This is the reading lines code :
if (primaryTarget != null)
            {
                var lines = primaryTarget.description.Split('\n');
                text.text = "Item found: " + primaryTarget.description;
            }
            else
            {
                text.text = "";
            }

And this is the script of the description :
The script is attached to each interactable target(item) :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class InteractableItem : MonoBehaviour
{
    public enum InteractableMode // your custom enumeration
    {
        Description,
        Action
    };

    public InteractableMode interactableMode = InteractableMode.Description;

    public float distance;

    private bool action = true;

    [TextArea(1, 10)]
    public string description = "";

    public void ActionOnItem()
    {
        if(interactableMode == InteractableMode.Action && distance <= 5f && action == true)
        {

            action = false;
        }
    }
}

Depending on the amount of text in the string I want to show it in the ui Text.
If there is one line then just show the text or even if there are two lines.
but if there is a lot of text then split the lines and scroll the lines smooth up so the first line will be disappear or pushed up and bottom lines will come up.
In the screenshot you can see on the left the text that show in the ui text on the right the text of the description. The ui text can't show all the text and I don't want the text to overlap other ui's or objects so the idea is to make the text slowly smooth scrolling up.


texts: Unable to launch Unity due to license glitch

texts:
A few hours ago, Unity crashed on me.  When I went to re-launch it from Unity Hub, that's when the nightmare started.

Any time I try to launch a project from the Unity Hub, the Unity Hub disappears, the Unity splash screen opens, and then about 3 seconds later the Unity Hub reappears, followed shortly by the Unity splash screen disappearing.  I can't get the editor to actually load!

I looked in the Unity Editor log and found this:

[LicensingClient] ERROR Failed to connect to local IPC
[Licensing::Module] Failed to connect to channel: LicenseClient-Mason
[Licensing::Module] Successfully launched the LicensingClient
[Licensing::Module] Successfully connected to LicensingClient on channel: LicenseClient-Mason
[Licensing::Module] Successfully launched and connected to LicensingClient
Entitlement-based licensing initiated
[LicensingClient] Licenses Updated successfully in LicensingClient

LICENSE SYSTEM [202059 16:58:48] Next license update check is after 2020-05-10T19:18:29

Built from '2019.3/staging' branch; Version is '2019.3.10f1 (5968d7f82152) revision 5859543'; Using compiler version '191627012'
OS: 'Windows 10  (10.0.0) 64bit' Language: 'en' Physical Memory: 16332 MB
[Licensing::Module] License is not active (com.unity.editor.ui). HasEntitlements will fail.
BatchMode: 0, IsHumanControllingUs: 1, StartBugReporterOnCrash: 1, Is64bit: 1, IsPro: 0
No valid Unity Editor license found. Please activate your license.

I do, in fact, have a valid Unity Editor license.  It was working just fine this morning, and it doesn't expire for several months yet.  Looking at the "Manage license" function in Unity Hub confirms this.  A bit of Googling suggests doing some of the following things, all of which I have tried, to no avail:

Reboot the computer.
Delete the Unity license file in C:\ProgramData\Unity and recreate it in Unity Hub.
Uninstall and reinstall Unity.
Update to the latest Unity version.

There was no Windows Update, driver update, or hardware change that could have provoked this.  It happens no matter which version of Unity I attempt to open, and no matter which project I attempt to open, and nothing I do to attempt to fix it actually works!

The one thing that does work, for whatever reason, is creating a new Unity project.  This creates a new project as expected, but the Unity theme is reverted to a light gray background, rather than the dark mode I'm accustomed to with my license, and once that project is closed, attempting to reopen it is just the same as attempting to open any other Unity project.

I tried opening Unity on my old, broken computer that has the same license, and it opens just fine... but that computer is old and broken, and will take several times longer to do anything on.  Apparently there's some serious issue, specific to my dev machine, that came out of nowhere this morning and is causing license verification to fail.

Anyone have any idea how I can fix this or, failing that, how I can reach someone at Unity Technologies to get their help fixing it?  Try as I may I can't find any option anywhere on their web site to reach a human being for customer service, at a time when I urgently need a live human being, rather than a "open a ticket and we'll try to respond to it within 3 days if you're lucky".  I'm just finishing up something that I was hoping to have ready today, and this has disrupted everything!


texts: Convert linear velocity to angular velocity for a ball / sphere (Rolling Ball Maths)

texts:
I have a ball moving on a flat plane. I cannot use RigidBody physics, so my object in Kinematic and I am manually handling speed/acceleration. The linear movement of the ball is fine, however as the ball does not rotate, it looks odd.

Given a speed Vector3, where I am moving on the X & Z, I need to figure out how to make the ball "roll".

I think I a running into Euler / Gimbal lock issues by trying this:

transform.Rotate(
  180.0f *  speed.z / (Mathf.PI * radius) * dt,
  0,
  -180.0f * speed.x / (Mathf.PI * radius) * dt
);

This formula is loosely based on the angular velocity formula and converting to degree's per second, with dt (deltaTime).

My gut instinct says that the solution may lie in Quaternions somewehere...?!


texts: Noticeable quality loss on texture captured using Graphics.Blit vs Shader output directly to a mesh

texts:
I'm currently using a GPU shader to generate a texture. I want to be able to capture the output of this out I'm using Graphics.Blit to output the shaders result to a RenderTexture(GPU Memory) and then using Texture2D.ReadPixels(System Memory) to grab the data from the RenderTexture.

So far I've got it almost perfect, unfortunately, I'm noticing a significant difference in quality between a plane that uses the shader output directly and a plane that uses the Texture2D returned from my method and applied to the shared material.

The process of my static method is as follows:

Check if the static material variable is set. If not, create a new
instance using the shader and assign it to, the static material
variable, otherwise reuse the existing one.
Create a RenderTexture that uses the same width and height scale as
the plane (128x128) using RenderTexture.GetTemporary() which uses
ARGB32, Linear colorspace and 0 depth buffer.
Set the material keywords and properties based on method input. Call
Graphics.Blit() with null, RenderTexture(from 2) and material (from
1). Create a new Texture2D with the same dimensions as the render texture, ARGB32 and using linear colour space.
Called GetPixels() on the above Texture2D with parameters, of a new
Rect of (0,0) and render texture dimensions and 0 for offsets.
Call Apply() on the Texture2D and return it. I then use a simple
editor script for the class that adds a button to call the above
static function and then apply the output to the material of the
object the script is on.

I don't know what's causing the quality loss, I've added a screenshot of what I'm currently getting below. The left plane is steps detailed above and the right plane is with the shader applied directly to a plane. Both use the same shader properties and keywords.

I don't normally post questions but I've tried everything I can think of to get the quality of texture to match the shader output. I'm wondering if I'm misunderstanding something about how the shader works or if it's a formatting issue. Any ideas are appreciated, thanks.


texts: How do you map a texture to a sphere in Unity using script?

texts:
I am looking to map a texture to a sphere inside of Unity using c# (not in the visual editor)?

dragging a jpg or other image resource onto the sphere is the effect I am looking for -- but I would like to do it at runtime.


texts: What should I keep in mind while developing a game for Steam?

texts:
I recently did the programming on a game that was just released and i've decided that for my next project I want to do something a little bigger scale.  I plan to develop a game to be sold on Steam, it will be 3D.  I've done large-scale games in Flash and a small game in C++ written with OpenGL.  I realize that flash-based games can be submitted to Steam but I'd like for it to be written in some variation of C.  I'm looking for information on a couple things.

What engine should I use? Ideally I'd like it to work on both Mac and PC. Seeing as it would be released on Steam, I'd like to use the Source Engine but I'm worried about having to pay licensing fees when I don't plan to make loads of money on it - it's mainly for the experience and as a resume builder.
What sorts of things should I keep in mind when developing so that when, and if, it gets accepted, the process of adding the Steam-specific functionality will be less painful.


texts: OpenGL texture2d/image sampling issue. Strange artifacts in texture

texts:
I have an issue when using textures in OpenGL, strange artifacts occur where geometry overlaps, but not always.
Video Reference. I am using a GL_TEXTURE_2D with GL_ARB_image_load_store to make a custom depth test shader that stores material data for opaque and transparent geometry. The video given shows the artifacts occur where the support structure for a table is occluded behind the top of the table, but strangely, not occurring where the base of the table is occluded by the support.
#version 450 core

in VS_OUT {
    vec3 Position;
    vec3 Normal;
    vec2 TexCoords;

    mat3 TanBitanNorm;
} fs_in;

// Material data
uniform sampler2D uAlbedoMap;
uniform sampler2D uNormalMap;
uniform sampler2D uMetallicMap;

// Material info out
layout(rgba16f) coherent uniform image2D uAlbedoDepthOpaque;
layout(rgba16f) coherent uniform image2D uNormalMetallicOpaque;
layout(rgba16f) coherent uniform image2D uAlbedoDepthTransparent;
layout(rgba16f) coherent uniform image2D uNormalAlphaTransparent;

// Depth info in/out
layout(r8) uniform image2D uDepthBufferOpaque;
layout(r8) uniform image2D uDepthBufferTransparent;

void main() {
    vec3 n_tex = texture(uNormalMap, fs_in.TexCoords).xyz;
    n_tex = n_tex * 2.0f - 1.0f;

    ivec2 tx_loc = ivec2(gl_FragCoord.xy);
    const float opaque_depth = imageLoad(uDepthBufferOpaque, tx_loc).r; // Stored depth of opaque
    const float trans_depth = imageLoad(uDepthBufferTransparent, tx_loc).r; // Stored depth of transparent

    // Depth processing
    if (gl_FragCoord.z > opaque_depth) {
        bool tran = false;
        if (trans_depth > opaque_depth)
            tran = trans_depth > gl_FragCoord.z;
        else
            tran = true;

        // Transparent
        if (texture(uAlbedoMap, fs_in.TexCoords).a < 1.0f && tran) {
            imageStore(uDepthBufferTransparent, tx_loc,
                vec4(gl_FragCoord.z));

            imageStore(uAlbedoDepthTransparent, tx_loc,
                vec4(texture(uAlbedoMap, fs_in.TexCoords).rgb, gl_FragCoord.z));
            imageStore(uNormalAlphaTransparent, tx_loc,
                vec4(abs(length(n_tex) - 1.0f) > 0.1f ? fs_in.Normal : normalize(fs_in.TanBitanNorm * n_tex), texture(uAlbedoMap, fs_in.TexCoords).a));
        }

        // Opaque
        else {
            imageStore(uDepthBufferOpaque, tx_loc,
                vec4(gl_FragCoord.z));

            imageStore(uAlbedoDepthOpaque, tx_loc,
                vec4(texture(uAlbedoMap, fs_in.TexCoords).rgb, gl_FragCoord.z));
            imageStore(uNormalMetallicOpaque, tx_loc,
                vec4(abs(length(n_tex) - 1.0f) > 0.1f ? fs_in.Normal : normalize(fs_in.TanBitanNorm * n_tex), texture(uMetallicMap, fs_in.TexCoords).r));
        }
    }

    if (opaque_depth == 0.0f) {
        imageStore(uDepthBufferOpaque, tx_loc,
            vec4(0.125f));
    }

    else {
        imageStore(uDepthBufferOpaque, tx_loc,
            vec4(0.125f + opaque_depth));
    }
}

Render with overlapping geometry shows that artifacts still occur outside of reading from the texture. Also in the video, I move the camera back and forth (with orthographic projection) and the artifacts become brighter and darker. Render with overlapping geometry w/out depth processing shows that the brighter/darker values were from the depth test.
Any ideas on why this occurs, and how can I fix it?


texts: btRigidBody world transform and scale issue

texts:
When I create a collision shape for rigid body (in this case box) I use vertices positions and scale from the opengl matrix, the code looks this way:

glm::vec3 boxDim = getBoxDim(verticesPositions, scale);
collisionShape_.reset(new btBoxShape(btVector3(boxDim.x, boxDim.y, boxDim.z)));

When a simulation step is done I need to update opengl matrix for the object. I calculate a new model matrix this way:

btTransform transform = rigidBody->getWorldTransform();
float openglMatrix[16];
transform.getOpenGLMatrix(openglMatrix);

glm::mat4 newModelMatrix = glm::make_mat4(openglMatrix);
newModelMatrix = glm::scale(newModelMatrix, glTransform.getScale());

My code works but I wonder if there is any possibility to have already scale in the transform returned by getWorldTransform. Then I can ommit this line of the code:

newModelMatrix = glm::scale(newModelMatrix, glTransform.getScale());


texts:
I am new to Game Development and Unity. I have written a component for Jumping and Running, CharacterJumpAbility.cs and CharacterRunAbility.cs.

I would like the Character to be able to Jump only if the Character is not moving. I came across a State Pattern but I can't understand how to apply it. For example if I want to Jump, first I must check if the Character is Running, but I have to do this in the CharacterJumpAbility.cs or in the CharacterController.cs (the component who handles inputs)?

If I define a state for example:

public enum CharacterState {
    Run,
    Jump
}

For example if the player is pressing the space bar, I have to set the Jump state, the code that sets state = CharacterState.Jump should be written in the CharacterJumpAbility.cs or in the component that handles inputs?

And if I want to set a new state for example Jump, while I am running, this is clearly not possible, how to handle situations like these?


texts: Erase save file when the game gets force closed Unity C#

texts: Im making an old school arcade for android where you have to get the highest score between levels. At each level you can save the progress. If you die and have 0 lives left your save file gets deleted. However to prevent cheating I want the game to erase the save file when the player quits the game mid level instead of going back to the last save. What is the code for checking if the player force closed the game?


texts: Do google game services require the users to have a g+ account to enter lobby?

texts:
I've been reading Google Game Services (GGS) API about multiplayer lobby/rooms and the documentation doesn't make it very clear if the users are required to sign in with a Google+ account (which I don't want).

The web GGS SDK mentions this:

  The simplest way to add a sign-in button to your page is to implement
  the HTML-based sign-in button. For implementation details, see Adding
  the HTML sign-in button to your page on the Google+ Sign-In
  documentation.

What I am looking for is a simple way (service or library) to connect anonymous users together (matchmaking).
My application being in Java, a Java compatible API is also needed.

Can Google Game Services fit the bill or should I keep looking?


texts: How can I draw a line rotated some number of degrees away from an original line?

texts:
I have a line ahead of my moving object to serve as a raycast and its aligned with the object's movement direction. But I want also some extra lines according to an angle related to the 'head' of the moving object.

This position is always changing; I also have a velocity vector to see the direction of the object as well, I use that to trace the front line ray of my object but not sure how to use to calculate this new line.

In this picture, my object is moving to the right and up. I want to trace a new line but 30 degrees from this one. How do I do that?


texts:
PHPhotoLibrary.shared().performChanges({
            PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: videoURL as URL)
        }) { success, error in
            if !success {
                print("Error saving video: \(String(describing: error))")
            }
        }

Results in:
Error saving video: Optional(Error Domain=PHPhotosErrorDomain Code=-1 "(null)")
I found this similar problem solution on github for images and I think objC(?):

the code below will cause error on iOS 13 devices when import uri is
https://xxxxx.png assetRequest = [PHAssetChangeRequest
creationRequestForAssetFromImageAtFileURL:inputURI];
this way works well
NSData *data = [NSData dataWithContentsOfURL:inputURI];
UIImage *image = [UIImage imageWithData:data];
assetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];

https://github.com/react-native-community/react-native-cameraroll/issues/159
So I am thinking I might need to find a wrapper class for video? I'm finding if very difficult to find good resources for working with swift.


texts: How can I create "events" that are called in scripts without requiring subscriptions?

texts:
I am creating an editor extension that includes an API for developers to use. It also includes events like (for example) "OnHealthChanged."

The problem is that events I have stumbled upon would require a user to subscribe to them, which is not what I actually want. I want developers simply type in the event handler in their script, and it would just work.

For example, I want a programmer to write a function "OnHealthChanged" in their own script. When the health changes, their code runs.

void OnHealthChanged()
{
    //code that is going to run when health changes
}

Any idea where can I look?

I want to create something like "OnCollisionEnter()" event in Unity, which runs code every time a game object collides with another game object.

Hope it makes sense.


texts: Unity use image to load prefabs along a line

texts:
Say I have an image of PNG or a bitmap with a line zigzagging through it. I have done quite a bit of research in the answer still eludes me to how to use an image in unity and have it generate Primitives IE cubes along a black line in the bitmap. If anyone could just point me in the right direction as far as the tutorial or information that will get me started that will be great.

Ok so take the image below. What I am attempting to do is where the black line is instantiate a cube. I pretty much have the code written but the 4 issues I am having is
1. Identifying if black is found in my Color[] variable
2. Getting the blocks to render on the black lines without overlapping
3. Not freeze when generating the blocks.

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

using UnityEngine;

public class MazeGeneratorV1 : MonoBehaviour {
public Texture2D img;
public GameObject wall;
public int unitWidth = 10;
public int unitHeight = 10;

// Use this for initialization
void Start () {
    Pixelreader();
}

private void Pixelreader()
{
    //img = (Texture2D)Resources.Load("test2.png");
    for(int w=0; w < img.width; w++)
    {
        for(int h=0; h < img.height; h++)
        {
            Color[] colors = img.GetPixels(w, h, 10, 10);
            print(colors);
            if (colors == Color.black)
            {
                print("wall");
                Instantiate(wall, new Vector3(w,0,h), Quaternion.Euler(0, 0, 0));

            }
        }
    }
  }
}


texts:
Hi currently i am working on modelling an object within view port, but i have issues here. On my right panel view port, when i try to alter an vertex of an cube i'm getting an 3d effect similar like this:

But instead i should see effect similar like this:

Where am i wrong here? Thanks


texts: Selectively applying overlay shadows in a 2D tile based game

texts: I'm currently building a top down 2D tile based game using OpenGL. There are three tile layers, the background layer, player/sprite layer & foreground layer. The foreground layer is pretty much used to place translucent tiles that give the impression of a shadow when blended over the two underlying layers. The problem is that many textures for tiles in the background layer already have a shadow applied in their source images. I would like to exclude these background tiles from having the shadow overlaid whilst still applying it to sprites that may be above these tiles. Any ideas as to how I could go about accomplishing this? In the accompanying image notice how I only want the forground shadow applied to the character in the sprite layer to get the result.


texts: Drawing multiple triangles at once isn't working

texts:
I'm trying to draw multiple triangles at once to make up a "shape". I have a class that has an array of VertexPositionColor, an array of Indexes (rendered by this Triangulation class):

http://www.xnawiki.com/index.php/Polygon_Triangulation

So, my "shape" has multiple points of VertexPositionColor but I can't render each triangle in the shape to "fill" the shape. It only draws the first triangle.

struct ShapeColor
{
     // Properties (not all properties)
     VertexPositionColor[] Points;
     int[] Indexes;
}

First method that I've tried, this should work since I iterate through the index array that always are of "3s", so they always contain at least one triangle.

//render = ShapeColor

for (int i = 0; i < render.Indexes.Length; i += 3)
{
    device.DrawUserIndexedPrimitives<VertexPositionColor>
    (
         PrimitiveType.TriangleList,
         new VertexPositionColor[] { render.Points[render.Indexes[i]], render.Points[render.Indexes[i+1]], render.Points[render.Indexes[i+2]] },
         0,
         3,
         new int[] { 0, 1, 2 },
         0,
         1
    );
}

or the method that should work:

device.DrawUserIndexedPrimitives<VertexPositionColor>
(
    PrimitiveType.TriangleList,
    render.Points,
    0,
    render.Points.Length,
    render.Indexes,
    0,
    render.Indexes.Length / 3,
    VertexPositionColor.VertexDeclaration
);

No matter what method I use this is the  "typical" result from my Editor (in Windows Forms with XNA)

It should show a filled shape, because the indexes are right (I've checked a dozen of times)

I simply click the screen (gets the world coordinates, adds a point from a color, when there are 3 points or more it should start filling out the shape, it only draws the lines (different method) and only 1 triangle). The Grid isn't rendered with "this" shape.

Any ideas?


texts: Why I get different size for equal attributes types?

texts:
I trying to implement flexible shader attributes, but when I try to get them I got strange info.
This is my vertex shader:

    GLchar* vertexShader =
    "in vec4 position; \n"
    "in vec4 loc;\n"
    "\n"
    "void main()\n"
    "{\n"
    "gl_Position = position + loc;\n"
    "}";

This is my code with the help of which I get attributes info:

GLint i;
GLint count;

GLint size; // size of the variable
GLenum type; // type of the variable (float, vec3 or mat4, etc)

const GLsizei bufSize = 16; // maximum name length
GLchar name[bufSize]; // variable name in GLSL
GLsizei length; // name length

glGetProgramiv(shader->GetProgram(), GL_ACTIVE_ATTRIBUTES, &count);
printf("Active Attributes: %d\n", count);

for (i = 0; i < count; i++)
{
    glGetActiveAttrib(shader->GetProgram(), (GLuint)i, bufSize, &length, &size, &type, name);

    printf("Attribute #%d Type: %u Lenght: %d\n", i, type, length);
}

And what I get:

Why I got such strange info and how I can get size of each attribute?


texts: How to create a Pixmap from an OrthographicCamera in LibGDX

texts: I am trying to create a picture based on what one of my OrthographicCamera can see. LibGDX has a ScreenUtils class that has a getFrameBufferPixels method, but it does not what I want as I want to get only what one camera sees, not the whole screen.


texts: How do I use trigger colliders in Unity?

texts:
I am trying to create a "Fruit Ninja" style game in Unity in VR. I have a BoxCollider on my sword set to "Trigger" and I have some "fruit" objects coming towards it. I then have this function:

void OnTriggerEnter(Collider other)
{
    Destroy(gameObject);
    Destroy(other.gameObject);
}

I've tried applying this script to the sword and to the objects, but nothing is destroyed.

In the documentation, there is also a note of "Trigger events are only sent if one of the Colliders also has a Rigidbody attached", but I've attached a Rigidbody to the objects.


texts: How to get asset folder path in android native activity?

texts:
I am trying to create a small game with android native activity. I wish to load textures using stb image. I don't know how to get the path to assets folder.
Is there any API to get path to apk directory so that I can use that to get textures? Thanks.


texts: Counting point for a recursive domino-like game: Carcassone

texts:
I have to build a 2D version of this game:

http://en.wikipedia.org/wiki/Carcassonne_(board_game)

counting scores for Towns and Roads seems easy enough (but I'm not sure), but for Lands I feel I don't have a clue.

I'm guessing I can define 3 "plugs" for each side, 12 for each tile, and then using pairs to create links between them inside a tile...

I remembered seeing that there is some book about graphes with boost, but I'm sure I don't need that...


texts: LibGDX Change mouse cursor to custom image......and keep it there

texts:
I'm able to create a custom cursor no problem using the following code running in my GameScreen's Show method:
Pixmap pixmap = new Pixmap(Gdx.files.internal("ui/cursor.png"));
Cursor cursor = Gdx.graphics.newCursor(pixmap, pixmap.getWidth() / 2, pixmap.getHeight() / 2);
Gdx.graphics.setCursor(cursor);
pixmap.dispose();

The problem is...if I deselect the game window and return back...the cursor has returned back to the default one. At least that happens for me on Mac desktop. If I move the cursor out of the screen (without deselecting) and then back again I get the custom cursor image back but I don't think people would know to do that.
But after searching I couldn't find any way for LibGDX to detect when the game window is deselected? I thought I would be able to find that since it would seem useful for something like automatically pausing when deselecting the game window and such.
That would seem to be the way to reset the cursor every time returning to the game window, unless there's some other way to make it more permanent?
EDIT: The cursor in fact just seems to randomly disappear for no reason during gameplay and then sometimes reappear briefly....seems like it's a bug.


texts: Why add a transparent border to a texture?

texts:
I've seen game developers give advice to add a transparent border around sprites, for example around 3:00 minutes into this tutorial.

Why should we leave a transparent border around a texture before using it in these cases?

And how broad should this border be?

Also I found one of my friends saying to me that when he rendered multiple copies of same texture by u v coordinates, he got some white lines at texture to texture intersections.

Adding borders fixed that as per the answer he got from his question at this site.


texts: How to make plane thick with shader in Unity?

texts: I use plane as wall, door,... using Double Sided Shaders. I just want to make my wall, door,... thicker so it doesn't look like paper, I don't need to make it look super realistic. I wonder if I can do that with shader.


texts:
I'm having problems drawing a simple sprite. When I draw:

void CSprite2D::render()
    {
        CHECKGL(glLoadIdentity());
        CHECKGL(glEnable(GL_TEXTURE_2D));
        CHECKGL(glEnable(GL_BLEND));

        CHECKGL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));

        m_texture->bind();

        //CHECKGL(glPushMatrix());

        CHECKGL(glBegin(GL_TRIANGLE_STRIP));
            CHECKGL(glNormal3i(0,0,1));
            CHECKGL(glTexCoord2f(m_textureAreaStart.s,m_textureAreaStart.t)); // 0,0 by default
            CHECKGL(glVertex3i(m_position.x,m_position.y,0));

            CHECKGL(glNormal3i(0,0,1));
            CHECKGL(glTexCoord2f(m_textureAreaEnd.s,m_textureAreaStart.t)); // 1,0 by default
            CHECKGL(glVertex3i( m_position.x + m_dimensions.x, m_position.y, 0));

            CHECKGL(glNormal3i(0,0,1));
            CHECKGL(glTexCoord2f(m_textureAreaEnd.s, m_textureAreaEnd.t)); // 1,1 by default
            CHECKGL(glVertex3i( m_position.x + m_dimensions.x, m_position.y + m_dimensions.y, 0));

            CHECKGL(glNormal3i(0,0,1));
            CHECKGL(glTexCoord2f(m_textureAreaStart.s, m_textureAreaEnd.t));  // 0,1 by default
            CHECKGL(glVertex3i( m_position.x, m_position.y + m_dimensions.y,0));
        CHECKGL(glEnd());

        //CHECKGL(glPopMatrix());

        CHECKGL(glDisable(GL_BLEND));
    }

I'm always get an GL_INVALID_OPERATION in glEnd(). I suspect that error is not here, but I can't detect where may be.
Actually, the output render seems ok. But I want to solve this situation before to catch a subtle bug tomorrow.

Any idea of what could be


texts: How to diagnose the problem when the input assembler and the vertex shader look correrct, but the Output Merger is wrong?

texts:
I'm porting some OpenGL code to Direct X 11.  I ended up with nothing being drawn on the screen. I reverted to a simple program, which I am writing about here.

I'm now trying to use the Graphics Tools in Visual Studio to diagnose a very simple "Hello Triangle" program.  In my program, I am drawing simple geometry and using a basic shader.  The shader just outputs a constant color.

float4 ps_main(VS_OUTPUT Input) : SV_TARGET
{
    return float4(0.2f, 0.2f, 0.2f, 1.0f);
}

However, the Output Merger shows nothing.

(LOOK CLOSELY)

When I click on the output merger, I see a green alpha checkerboard.

What I would like to know ultimately, is what I'm doing wrong. (Why is the output merger basically blank?)  Additionally, I'd like to learn some skill in reading outputs like this:

This is the contents of basic.hlsl

cbuffer cbTransform : register( b0 )
{
    matrix matWorldViewProj;
};

struct VS_INPUT
{
    float3 Position     : POSITION0;
    float2 TexCoord     : TEXCOORD0;
    float3 Normal       : NORMAL;
    float4 Color        : TEXCOORD1;
};

struct VS_OUTPUT
{
    float4 Position     : SV_POSITION;
    float2 TexCoord     : TEXCOORD0;
    float3 Normal       : NORMAL;
    float4 Color        : COLOR0;
};

VS_OUTPUT vs_main( VS_INPUT Input )
{
    VS_OUTPUT Output;
    Output.Position = mul(float4(Input.Position,1), matWorldViewProj);
    Output.TexCoord = Input.TexCoord;
    Output.Normal = mul(Input.Normal, (float3x3)matWorldViewProj);
    Output.Color = Input.Color;
    return( Output );
}

float4 ps_main(VS_OUTPUT Input) : SV_TARGET
{
    return float4(0.2f, 0.2f, 0.2f, 1.0f);
}

Here's what matWorldViewProj looks like:


texts:
I believe I read somewhere that there is a technique which will make games appear more smooth than they are. I believe it is some visual trick, but I don't remember which one. (It is be something like "You percieve game to be more fluid if there is good shadows").

I may be wrong and there is no such thing.


texts: I am trying to learn OpenGL, and I just found out that GLUT is obsolete. I already know SDL, and it seems it is a good alternative. Should I use SDL to develop games with OpenGL, or are there any better alternatives. I am new to game development, so I don't know much about the state of the art.


texts: Validating building "completion/enclosure" in infinite 2D tile map

texts:
I have a 2D infinite tile map game in which the player can place floors and walls to construct "buildings".

I'm trying to think of an efficient way to determine whether the player is inside a "complete" building, meaning it's fully enclosed by walls and a door.

Normally, the logic isn't difficult since it's easy to tell if the walls fully encircle an area - but in the case of an infinite map, the "building" may extend into unloaded areas of the game.

For example, if a player makes a complete rectangular building, 10x100 tiles long, only some of the chunks it covers will be loaded at once.

I have a few ideas:

If a player is near candidate walls, follow them and load all necessary chunks to check completeness. This would work, but could load a moderate number of unused chunks.
Cache a list of "complete" buildings as they're completed. So option #1 is applied only as the player builds the building. This would have to saved/loaded, and updated when integral walls/doors are removed, so it trades efficiency for a little overhead, which might be OK.
Using a different metric to determine "indoors". I can't think of one though.

Anyone have any other ideas? Has this ever been implemented somewhere else, something I can at least use as an example?


texts: Is there any way to make xTile work with MonoGame?

texts:
I am currently in the process of planning and developing a game. I use MonoGame as my framework, and I also planned to use xTile with tIDE to manage my tiles, but it only works with XNA 4.0, but my project (of course) only references the MonoGame.Framework and not the Microsoft.Xna.Framework, which means that some classes are defined in assemblies which are not referenced.
I know MonoGame is a continuation of Xna, but as the Assembly has a different name/ID, xTile of course doesn't recognise it.
Is there any way to support xTile when using MonoGame? If there isn't, is there any alternative to xTile?


texts:
I'm working on an open source game for 2 years but I'm very bad at math. The game permits moving a character on an octagonal basis. When the character reaches the border coordinate (colored in yellow), I permit him to travel to another octagon:

The map is a simple 2d array of x, y coordinates. The goal is to know if an x, y tile coordinate is on a "yellow" tile, and which direction it represents (north, northeast, east etc.) depending on map width and height.

I wrote this algorithm many times and in two different language, example with Rust:

pub fn get_corner(width: i16, height: i16, new_row_i: i16, new_col_i: i16) -> Option<CornerEnum> {
    let left_col_i_end = width / 3;
    let right_col_i_start = (width / 3) * 2;
    let top_row_i_end = height / 3;
    let bottom_row_i_start = (height / 3) * 2;
    let mut more = if new_row_i >= 0 { new_row_i } else { 0 };
    #[allow(unused_assignments)]
    let mut right_col_i = 0;
    #[allow(unused_assignments)]
    let mut left_col_i = 0;

    if new_row_i < top_row_i_end {
        right_col_i = right_col_i_start + more;
        left_col_i = left_col_i_end - more;
    } else {
        if new_row_i >= bottom_row_i_start {
            more = (height / 3) - (new_row_i - bottom_row_i_start + 1);
            more = if more >= 0 { more } else { 0 };
            right_col_i = right_col_i_start + more;
            left_col_i = left_col_i_end - more;
        } else {
            left_col_i = left_col_i_end;
            right_col_i = right_col_i_start;
        }
    }

    if new_col_i < left_col_i && new_row_i < top_row_i_end {
        return Some(CornerEnum::TopLeft);
    }
    if new_row_i < 0 && left_col_i <= new_col_i {
        return Some(CornerEnum::Top);
    }
    if new_col_i >= right_col_i && new_row_i < top_row_i_end {
        return Some(CornerEnum::TopRight);
    }
    if new_col_i > width - 1 && top_row_i_end <= new_row_i {
        return Some(CornerEnum::Right);
    }
    if new_col_i >= right_col_i && new_row_i >= bottom_row_i_start {
        return Some(CornerEnum::BottomRight);
    }
    if new_row_i > height - 1 && left_col_i_end <= new_col_i {
        return Some(CornerEnum::Bottom);
    }
    if new_col_i < left_col_i && new_row_i >= bottom_row_i_start {
        return Some(CornerEnum::BottomLeft);
    }
    if new_col_i < 0 && top_row_i_end <= new_row_i {
        return Some(CornerEnum::Left);
    }

    None
}

But it is not working too well: it works only for some borders, but not for others, apparently depending on width/height odd/even... I curse my math. I'm sure it's not that complicated but I've failed for two years. So, I'm here to ask for a solution... which would be greatly appreciated!


texts: Should independent game developers outsource?

texts:
Simple question: What are the pros and cons, as well as overall opinions, of outsourcing work as an independent game developer? (For example: paying an artist to draw characters, or a composer to write music, etc.)

In particular I'm interested in the case where the developer (be it an individual or a team) can still complete their game to an acceptable standard without hiring somebody. (For example: maybe they're "ok" artists, or can use music from a free library.)

(Ideally I'm looking for answers from people with experience in this area.)


texts:
I am writing my own CCD IK solver. The version I have currently works perfectly fine, however, I need a way to make it use a pole target constraint.

What I want is for the elbow of my characters arm to point towards a pole target, similar to how Blender allows you to add a pole target.

I would love if someone could point me in the right direction of how this can be implemented.


texts:
Basically Danny Varod seems to know as he posted it as an answer to this question:

Display a Message Box over a Full Screen DirectX application

I think, theoretically this might work, but I have no idea how to actually do it. Since I'm also not allowed to post a comment under his comment nor am I allwoed to ask on meta about how to contact another user, I ask this as a normal question here:

How do I render my own DirectX Stuff to a full screen WPF's DirectX surface?

For starters, I have no idea how to get the DirectX surface from a WPF window. If I had it, what do I have to take care of that the WPF rendering doesn't screw up my own rending or vice-versa?


texts: Finding collision point of moving projectile/bullet with a cube

texts:
I am programming a game in the spirit of Wolfenstein 3D (2D grid map, 1 cell = 1 cube) and I wanted to implement shootings. I didn't want the shootings to happen in one frame so, I wanted to see the beams flying everywhere.

So this gets a bit complicated for me to test for impacts. To be fair, I'm not really sure how I'm supposed

This is how I used to do it : I took the position of the beam and checked on the map to see if there is a wall at said position. It works great when the beam is moving very slowly. But when they go extremely fast, naturally, as you would expect, they clip through walls.

Here you can have an idea of what I'm looking for. 2D grid with white cells being air and grey cells being walls. Player is green, beam is red and dotted lines represent the beam on next frames. And orange is the collision

So I'm not exactly sure when and what to test for collisions here, as well as how to find the impact's position. What would be the most optimised way to test for collisions ?


texts: Determining and Re-Considering Trapped Targets when Path-finding

texts:
I have a game that has multiple path-finding agents (A*) with a grid based map. The player can change the map by constructing walls, floors etc. and the agents will move to construct what the player has requested. I call the tasks that an agent will move to complete build tasks.

I have implemented a simple distance heuristic for when the agent is deciding which build task to pursue. Since there can be 100's of build tasks in the game at any one time, it's not really possible, as far as I can discern, to do a flood-fill to check if the task is reachable for a particular agent before doing a path-finding exercise.

At the moment, if an agent struggles to find a path to a task (for example, imagine the player has surrounded the agent with walls so it cannot escape a room), the task is stored as something that cannot be reached and a new item is looked for. I also flood-fill from the task and maintain a region which contains the task so that any other tasks in this area are not considered.

My problem is, how can I determine when an item can be released from the cannot-be-reached store or when the locked region can be cleared from consideration?

I though about doing some sort of timed expiration so that an item that cannot be reached will eventually be re-considered but this solution has several problems. Another idea I had was to path-find from the target to the agent every so often and if a new path is possible, clear the item and let it be re-considered. Neither of these solutions seem optimal and I feel I am missing something obvious...

Here is a rather lacking diagram of the problem I am trying to convey.


texts: Are difficult code tests when applying for jobs the norm?

texts:
I just did the online tech test for Lionhead and found it a bit defeating. There were questions that required you to work out the answers to recursive algorithms that accepted arrays as arguments and made multiple calls each run through, thus splitting off into exponentially more versions. This all had to be done on paper or in your head.

There were also questions that asked you to evaluate the efficiency of theoretical algorithms and say what Big O notation you think would best describe their scaling, something that I have never been taught or learned.

There were 27 such questions. Is this usual? Is this the standard of entry level games programming? I mean, I've written 3D games, but I found this really hard.

EDIT - I have actually done another tech test for another company now which was considerably easier. I had to write various different linked list algorithms and write a routine in sudo code for how I would mathematically calculate a bot's sight given a world up vector and a forward vector.


texts: Why am I getting this "Android SDK does not include any platforms!" error?

texts:
This question has been asked several times on the Unity answers website, but there's no solid answer to it!
Problem: While trying to build a game for android in Unity, I receive this error:

Android SDK does not include any platforms!

Yet I have all Android platform APIs downloaded.I've tried all of the suggested solutions:

Running Unity as Admin
Manually modifying the AndroidSdkRoot registry value
Deleting the old android platform folders
Reinstalling Android SDK into a folder other than Program Files
Reinstalling Unity
Recreating the project
Renaming "android-sdk" folder to "android-sdk-windows" since that was the default folder name value in the Unity's Browse dialog window.

Some Notes:

The Android SDK Home in Preferences value gets reset every time I try to build the project!
I'm also not using the Eclipse bundle, I installed Android SDK using the .exe installer.
Using Windows 8 Pro x64 (if it makes a difference)

I'm absolutely clueless, but I feel like this is a bug on Unity's side which needs to get fixed. If not, please let me know what I'm doing wrong.


texts: android game - how to store game elements so gc wont fire

texts:
I'm developing a android game and I have a question about storing the game elements without firing garbage collector.

My game needs a collection where the game elements are stored according to x,y positions (all game elements have x,y,width and height). The collection is then called every frame to retrieve the elements according to cameraX, cameraY, camera width and height (user can scroll around the game).

Example:

 function draw() {
   tmp = collection.getElements(tmp,cameraX,cameraY,cameraWidth,cameraHeight);
     for(int i = 0; i < tmp.size(); i++) {
        tmp.get(i).draw();
     }
  }

I'm currently using the Vector class to represent the collection elements, but the gc keeps firing every couple of minutes. I do all my allocations up front. I've also modified the getElements function to accept 1 more parameter - a temp vector(allocated upfront) which is filled with elements and then returned.

How should I store the game elements so the gc wont fire (I prefer never if possible)?

I also add elements to the collection during runtime, do I have to allocate them upfront also?


texts: How do I take 2D ballistic trajectory planning and apply it to 3D?

texts:
I am currently using this formula

speed = sqrt((gravity.y*target.x^2)/(2*cos^2(angle)*(target.y - target.x*tan(angle)))

provided by DMGregory as an answer for my question here to determine the speed of a trajectory given an angle and start/end points. So now I need to be able to apply this to a 3D scenario. How would I go about doing that?


texts: How to make WASD equivalent input on mobile in Unity?

texts:
I'm familiar with Unity 3d, but I haven't made phone games before.

I have already looked into the input manager to no evail. The problem is that I don't know how to make a WASD-like input on a phone with a touch screen.

How could I do it?


texts: LineRenderer doesn't apply material in 2D Unity5

texts:
I'm making something that draw lines with mouse on top of everything (in 2D), but the color of the line is always purple even though I assign a material to the line renderer. I could change the color by using shader, but after that the line doesn't appear on the screen anymore.

DrawLine.cs

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

public class DrawLine : MonoBehaviour
{
    private bool isMousePressed;
    private List<Vector3> pointsList;
    private Vector3 mousePos;
    private GameObject lineDrawPrefab;
    private LineRenderer lineRenderer;
    public GameObject lineDrawPrefabs;

    struct myLine
    {
        public Vector3 StartPoint;
        public Vector3 EndPoint;
    };

    void Awake()
    {
        isMousePressed = false;
        pointsList = new List<Vector3>();
    }

    void Update ()
    {
        if(Input.GetMouseButtonDown(0))
        {
            isMousePressed = true;
            lineDrawPrefab = GameObject.Instantiate(lineDrawPrefabs) as GameObject;
            lineRenderer = lineDrawPrefab.GetComponent<LineRenderer>();
        }
        else if(Input.GetMouseButtonUp(0))
        {
            isMousePressed = false;
            pointsList.Clear();
        }
        if(isMousePressed)
        {
            mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            mousePos.z=-5;
            if (!pointsList.Contains (mousePos))
            {
                pointsList.Add (mousePos);
                lineRenderer.SetVertexCount (pointsList.Count);
                lineRenderer.SetPosition (pointsList.Count - 1, (Vector3)pointsList [pointsList.Count - 1]);
            }
        }
    }

    private bool checkPoints (Vector3 pointA, Vector3 pointB)
    {
        return (pointA.x == pointB.x && pointA.y == pointB.y);
    }
}

LineMaterial.cs

using UnityEngine;
using System.Collections;

public class LineMaterial : MonoBehaviour {

    private LineRenderer line;

    void Awake()
    {
        line = gameObject.GetComponent<LineRenderer>();
        //line.material =  new Material(Shader.Find("Particles/Additive"));
        //line.SetColors(Color.green, Color.green);
        line.SetWidth(0.15f,0.15f);
        line.useWorldSpace = true;
    }
}


texts: Reasonable texture Formats for VertexTextureFetch in GL

texts:
Wich is a reasonable GL version that have support for vertex textures fetchs(VTF) in OpenGL ? (for example GL 3.0, 3.1, 3.3) What textures formats should I expect to be supported in average video cards when doing such vertex fetch.

Is that possible with GL ES 2?


texts: How do I find out which functions are deprecated for specific OpenGL profiles?

texts: I would like to get the list of functions that are part of a certain OpenGL profile and the list of the ones that are deprecated so that I can avoid those.


texts:
I've for loop which work well on Windows

double speed = 35;

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

        speed += 0.3;
        Sleep (1000); // sleep 1000 mili seonds

     }

But it responds an error on cocos2d-x.what should i do in cocos2d-x.
In my code i want to increase my speed to N unit every X second.

auto Action = MoveBy::create(3  *   visibleSize.width,Point(-visibleSize.width * speed, 0));

My way is right or should I do something else


texts: Keyboard input vs character movement encapsulation

texts: In our game created with c++ and sdl we are having difficulty delegating how the main character should be controlled.  We have a keyboard class and a sprite class for the main character, but are unsure if the main character should have an instance of the keyboard class or if keyboard input should be done through the game loop.  If you need anymore information I would be happy to provide it, thanks in advance for any help.


texts: Player jitters when Jumping at object edges

texts:
So I have a bit of an issue with my Player controller script. Everything works fine except with very specific jump cases. If I jump at an object and I don't reach the top edge I will just fall normally with no issue. However, when the object is short enough for me to possible jump on top of it, if I collide with its side when jumping my player will halt in that spot, jitter for a second and then fall normally.
Here is my code:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ThirdPersonPlayerController : MonoBehaviour
{
    public CharacterController controller;
    public Transform camera;
    public Transform groundCheck;

    Vector3 direction;
    Vector3 velocity;

    public float moveSpeed = 10f;
    public float turnSmoothTime = 0.1f;
    private float turnSmoothVelocity;
    public float gravity = -39.24f;
    public float groundDistance = 0.4f;
    public float jumpHeight = 3f;

    public LayerMask groundMask;
    private bool isGrounded;

    // Update is called once per frame
    // Unity is currently working on a new input system***
    private void Update()
    {
        IsPlayerGrounded();

        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");
        direction = new Vector3(horizontal, 0f, vertical).normalized; // direction player is moving

        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            Jump();
        }

        MoveAndRotate();
        Gravity();
    }

    private void MoveAndRotate()
    {
        if (direction.magnitude >= 0.1f)
        {
            float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + camera.eulerAngles.y;
            float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
            transform.rotation = Quaternion.Euler(0f, angle, 0f);

            Vector3 moveDirection = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
            controller.Move(moveDirection.normalized * moveSpeed * Time.deltaTime);
        }
    }

    // Implemented proper gravity from /_\ y = 1/2g * t^2
    private void Gravity()
    {
        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);
    }

    // Check if player is grounded and reset velocity
    private void IsPlayerGrounded()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }
    }

    private void Jump()
    {
        velocity.y = Mathf.Sqrt(jumpHeight * -2 * gravity);
    }

    // Current issue (Not yet fixed): When jumping against a wall the player will stick/jitter (starts to jitter at the top edge).
}

Here is a visual representation of what I mean by colliding near its top edge

Any help at all is greatly appreciated. Note: I thought it had something to do with objects having the Ground layer attached to them, but the bug is still present if they don't have a layer.


texts:
How to calculate the distance between a Vector3 and a (3D polygon triangle)?

for example : " float DistanceToTrianale( Vector3 pos, Vector3 Edges1, Vector3 Edges2, Vector3 Edges3)

thanks in advance


texts: VS2012 C++: Unable to ID3D11Device::CreateVertexShader when loading compiled CSO file

texts:
I have been trying to get a tutorial Direct X 11 application running for some time now. I'm being stymied when I try to create the vertex shader. Setting the Direct X Debug setting reveals that I am getting this error.

D3D11 ERROR: ID3D11Device::CreateVertexShader: Encoded Vertex Shader size doesn't match specified size. [ STATE_CREATION ERROR #166: CREATEVERTEXSHADER_INVALIDSHADERBYTECODE]

I have compiled the hlsl shader code using Visual Studio 2012 Express into "shaders.cso" and that appears to load okay. According to the HRESULT return from D3DReadFileToBlob. However, the CreateVertexShader call returns "E_INVALIDARG One or more arguments are invalid."

After this the program fails on a Draw attempt.

I have checked the size of the blob buffer and it is the same size as the shaders.cso file.

I have included the code which sets this up below.

void InitPipeline()
{
    HRESULT hr;

    // load and compile the two shaders
    ID3DBlob *VS = nullptr, *PS = nullptr;
    ID3DBlob *errorBlob = nullptr;

    const D3D_SHADER_MACRO defines[] = {"EXAMPLE_DEFINE", "1", NULL, NULL};
    UINT flags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
    flags |= D3DCOMPILE_DEBUG;
#endif
    hr = D3DReadFileToBlob(L"shaders.cso", &VS);

    // encapsulate both shaders into shader objects
    auto vbs = VS->GetBufferSize();
    auto vbp = VS->GetBufferPointer();

    hr = dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), nullptr, &pVS); // This function returns "E_INVALIDARG One or more arguments are invalid." and pVS is returned as NULL

    // set the shader objects
    devcon->VSSetShader(pVS, 0, 0);

    // create the input layout object
    D3D11_INPUT_ELEMENT_DESC ied[] =
    {
        {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
        {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
    };

    dev->CreateInputLayout(ied, 2, VS->GetBufferPointer(), VS->GetBufferSize(), &pLayout);
    devcon->IASetInputLayout(pLayout);
}

For reference this is the shader code.

cbuffer ConstantBuffer
{
    float4x4 matFinal;
}

struct VOut
{
    float4 position : SV_POSITION;
    float4 color : COLOR;
};

VOut main(float4 position : POSITION, float4 color : COLOR)
{
    VOut output;

    output.position = mul(matFinal, position);
    output.color = color;

    return output;
}

I'll admit to not knowing much about shader code. Honestly, I'd prefer to do without it at this stage of re-learning D3D, but it appears to be required to use DX11.

Can anyone shed any light on this?


texts: Convert a direction vector (normalized) to rotation?

texts:
Say i have something like this:

pos += glm::normalize(target - pos) //PLEASE NOTE: pos is a glm::vec3 and so is target

This makes "pos" translate towards "target", but what if i want to make my object to face "target"?


texts:
If you look through fog that continues to horizon it should obscure the horizon. But in Unity (so far) it seems that the horizon shows clearly through the fog. This ruins my underwater effects, etc.

Is there a way to get the horizon to obscure behind the fog?

It is worth noting that I am speaking of fog in conjunction with a procedural skybox.

EDIT, per request:

See this image -- this fog settings at .1 (extreme, for this example, official "thick-as-pea-soup" fog. This is using the lighting-settings fog. Frustratingly enough, the global fog camera effect only destroy/bugs my scene, so I'm stuck using this.

I'm using default procedural skybox (I intend to do day/night effects with it)

It fades out the railing nicely, but the horizon is shown as though there is no fog. The horizon should be fog color.


texts: Online Tower Defense : Problem in protecting user's data

texts:
Sorry about the question heading

I am creating an online tower defense game with SQL Server 2008 as my database.

SQL user used to send data to server is restricted to only execute existing storeprocedures which means to do anything like building or destroying a tower a storeprocedure has to be used. Now in the case of destroying of towers a storeprocedure named "sp_remove_tower" is fired with just 1 parameter "UserId" which will tell the database from which account the tower has to be removed.

Problem

is that if a person has SQL Server 2008 management studio installed and gets the SQL Server Name, SQL User ID, SQL User Password from lets say through inspect element in google chrome or by hacking the game itself. Then he can randomly pass any UserId in the storeprocedure which will cause to delete towers from other innocent players account.

How do i stop such a thing from happening?

Thanks in advance


texts: Perspective correct interpolation of normal values

texts:
I'm currently writing a software rasterizer and I'm at the point where I can draw arbitrary triangles with vertex colors and perspective correct texture mapping.
I do point and directional lighting by linearly interpolating the vertex normals and it works fine, only on big triangles you can notice that the lighting is somehow distorted when viewed from a very flat angle.
However, this is only visible when you're particularly looking for it but I was wondering if there is a way to have perspective correction on the normals too.

For the texture coordinates and other stuff this is being done by dividing the value by W or Z. But if you divide a vector by a single number you only change its magnitude, which is useless, as I'm normalizing the vector in the end for the lighting computation.
So, is there a way to do it?


texts:
I have a custom hlsl directx shader,
it takes vertex normals for rim light calculation.
and vertex tangent(it stores unified normals) for edge render(enlarge model & cull front).

I can export one fbx with auto smooth normals, and one fbx with unify normals, combine them in unity, it works but the process is slow. I just wonder if I can do it directly in 3ds max, so 3d artist can preview the result directly in their tools.

I tried storing unify normals data in texture coordinate or vertex color, but the data will be wrong once bone animation is running. So I believe normal + tangent is the only way to go if I want to have rim lighting & edge render together for a animated character model use in Unity3D.

I guess FBX SDK will help, but I have no experience in using it.

I wish someone could tell me a way to store vertex normals data into tangent.
or tell me is it not possible so that I should consider another solution.

thanks you.


texts: What name (if any) applies to this particular 3D rendering technique?

texts: Is there a name for this technique where when instead of rendering certain polygons, you just calculate a few key points and do the drawings in 2d? For instance, instead of rendering a sphere, you just calculate its central vector and draw a 2d circle? And what are the situations one can benefit from it?


texts: Yet another libGDX resolution independance question

texts:
I am developping a Android smartphone game in LibGDX, and I am encountering issues about resolution managing. Most notably, I have no clue how to handle that in LibGDX.  For now, I am developping based on my Nexus 5 screen, but it will certainly not (down)scale well to devices with lower density screens.

On the web, most data are about LibGDX < 1.0.0 and is totally irrelevant. The few things I have found talks about the Viewport classes, but it is poorly explained ; the game is either horribly stretch or way too small on high-definition devices.

At this point, I have understood that I need to define a "virtual screen" of some unit (lets say meters) and then place my elements based on this unit. But there is no fragment of clue on how to do that the right way in LibGDX ; when using Scene2D, for example, buttons are totally misshaped, with letters out of the box, buttons clearly overstretched and such, or ultra small based on the Viewport class used.

In the same way, using multiple asset size is not clear ; how to load them based on pixel density, how to force them to be there at the good size ? Etc... This stuff can make anyone crazy at start.

What I want to know is : is there somewhere some good, updated to recent libGDX, demos, examples or tutorial to the proper way to handle resolution, screen ratio and such in recent libGDX ? The libGDX viewport example, while a good start, are still unclear to me, and don't show the multiple asset size thing.

Thanks for any help, it is highly needed.


texts: Difference between _process(delta) and _physics_process(delta)?

texts:
The documentation is pointing one main difference, this is the concept of being synced or not with the physics engine, so the delta parameter has more chance to be constant in _physics_process(delta) than in _process(delta).
But I am pretty sure that no one counts on that. And that everybody checks the value of delta in _physics_process(delta).
So what are the different use cases of those two functions?


texts: How can I plot a radius of all reachable points with pathfinding for a Mob?

texts:
I am designing a tactical turn based game.  The maps are 2d, but do have varying level-layers and blocking objects/terrain.  I'm looking for an algorithm for pathfinding which will allow me to show an opaque shape representing all of the possible max-distance pixels that a mob can move to, knowing the mob's max pixel distance.

Any thoughts on this, or do I just need to write a good pathfinding algorithm and use it to find the cutoff points for any direction in which an obstacle exists?


texts: LibGDX - Camera and viewport initialization in show()?

texts:
I'm reading the book LibGDX game development by example and the author tends to follow a pattern like

 public class MyGame extends Game {
      @Override
      public void create() {
          setScreen(new GameScreen(this));
      }
      ...
 }

 public class GameScreen extends ScreenAdapter {
     private Viewport viewport;
     private Camera camera;
     private final MyGame myGame;

     // code omitted for brevity

     public GameScreen(MyGame myGame) {
         this.myGame = myGame;
     }

     @Override
     public void show() {
         camera = new OrthographicCamera();
         camera.position.set(WORLD_WIDTH / 2, WORLD_HEIGHT / 2, 0);
         camera.update();
         viewport = new FitViewport(WORLD_WIDTH, WORLD_HEIGHT, camera);
         ...
     }

It seems to me that creating a new camera and viewport in the show() method is not correct, as it would create new objects every time the screen becomes active (eg when the game has multiple screen and the user can switch between them). So my questions:

Am I correct in my reasoning? Should the camera and the viewport be created in the GameScreen class constructor?
Would it be possible/advisable to have just a single camera and viewport shared by all screens?


texts: GL_INVALID_OPERATION on glBindVertexArray Despite glGenVertexArrays()

texts:
so I've been trying to create a simpler way to draw polygons and and have come across the following issue:

When I call glBindVertexArray(m_VAO); it throws a GL_INVALID_OPERATION even though I have previously called these functions:

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

Why does this happen? The only description for this error officially is that I failed to call the lines above.

Here is the source with any relevant parts. Please note that I have the error pop up the line after this one, but it might be because of this current error.

Polygon::Polygon(const std::vector<GLfloat>& vertexArray,
         const char* vertShaderPath,
         const char* fragShaderPath)
    :m_vertexArray(vertexArray)
{
    // Created and linked shaders here...
    // ...
    // ...

    // Generate and bind vertex array object.
    glGenVertexArrays(1, &m_VAO);
    glBindVertexArray(m_VAO);

    // Generate and bind vertex buffer object.
    glGenBuffers(1, &m_VBO);
    glBindBuffer(GL_ARRAY_BUFFER, m_VBO);

    //Send verticies to buffer's memory.
    glBufferData(GL_ARRAY_BUFFER,
         m_vertexArray.size() * sizeof(GLfloat),
         &m_vertexArray[0],
         GL_STATIC_DRAW);

    // Set up vertex attributes.
    glVertexAttribPointer(0,
              3,
              GL_FLOAT,
              GL_FALSE,
              3 * sizeof(GLfloat),
              (GLvoid*)0);

    // Enable the attributes at layout position 0.
    glEnableVertexAttribArray(0);

    //Unbind VBO and VAO.
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);
};

// Destructor
Polygon::~Polygon()
{
    // De-allocated resources
    glDeleteVertexArrays(1, &m_VAO);
    glDeleteBuffers(1, &m_VBO);
}

void Polygon::draw()
{
    glUseProgram(m_shaderProgram);
    check_gl_error();
    glBindVertexArray(m_VAO); // GL_INVALID_OPERATION here
    check_gl_error();
    glDrawArrays(GL_TRIANGLES, 0, m_vertexArray.size()); // GL_INVALID_OPERATION here
    check_gl_error();
    glBindVertexArray(0);
    check_gl_error();
}

Let me know if you need any more info. Thanks!


texts: Bilinear filter in repeating texture, HLSL

texts:
I have a repeating texture that I'm using as a scroll surface.  The idea is that as I pan the surface I adjust the texture coordinates, filling in what gets wrapped on the right as it disappears from the left.  This is all working quite well.

When bilinear filtering is switched on (D3DTEXF_LINEAR) I think the repeat filters the edge of the texture with the corresponding pixels on the other side given the wrap.  This is wrong of course.

I've had a look around for bilinear filtering shaders that ignore edge texels but can't seem to find anything.  Does anyone have an ideas about how to do this?  Is there a way of configuring a sampler to ignore edge texels when filtering?  Is there a bilinear filtering shader knocking around I can use as a reference?


texts: What are the best 3rd party DRM solutions available from a user experience, development integration, and security perspective?


texts: How can I cast a std::shared_ptr to the correct derived class?

texts:
I'm trying to implement a component based design for a game I'm making. I decided to write it in C++, but I'm not very good at it. Coming from a Java background I encountered a problem when trying to manage the std::vector for the components. Right now each entity has a vector of components that can be of different derived classes such as "Transform Component" which has an x and y field that I will access later. From what I've read I have to use a std::shared_ptr for each component, and that has worked fine except when I retrieve a component and try to cast it I start getting errors.

The code looks like this:

Component.hpp

class Component
{
public:
    virtual ComponentType getType() = 0;

    virtual ~Component() { }
};

Transfrom.hpp

class Transform : public Component
{
public:
    float x, y;

    virtual ComponentType getType() { return ComponentType::TRANSFORM; }
};

Entity.hpp

class Entity
{
public:
    Entity() : m_components() { }

    Component& getComponent(ComponentType type);
    void addComponent(std::shared_ptr<Component> comp);
    bool hasComponent(ComponentType type);

private:
    std::vector<std::shared_ptr<Component>> m_components;
};

And when I try to use it:

// This gives an error!
Transform comp = std::dynamic_pointer_cast<Transform>(entity.getComponent(ComponentType::TRANSFORM));

How can I fix this?


texts: Find if one player is visible to the other

texts: Two players (p1 and p2) are standing in a 3D space, represented by points (x1, y1, z1) and (x2, y2, z2). Player 2 is holding a light source, pointing in the direction given by a normalised vector (xn, yn, zn). Given an angle cone (between 0 and 360) and a limiting distance max to which p2 can see with the light source, how can I determine if p1 is visible to p2.


texts:
Will Games developed on XNA work under a Windows 8 environment?

I know the XNA project was killed off, and you can't develop it on Windows 8 (apparently), but will they still work under windows 8? I don't care about metro integration or whatever, even if they run in desktop mode that's fine.

I've been looking around and finding a bunch of contradictory answers - so maybe I can get a clear one from here.


texts:
I am making a game in GameMaker: Studio, but I've run into a problem. Originally, the game would create three possible save files:

save1
save2
save3

The issue is that I have replaced the "save" value with "Save 0" so the files are generated as:

Save 01
Save 02
Save 03

The game can generate my save files, but not read them. I determined it is the namespace, as removing it resolves the error. Why does this happen after adding a namespace?


texts: Record voice and Comparison prefab audio in unity

texts:
I am android programmer that i Comparison Entrance voice with ready voice(prefab voice) for example when you say hello >>>>>to analyze>>>>>if your voice == prefab voice >>>>>you listen hello(play hello sound)
i want create game example tom that you can speak by somebody by speak.

i want scan Entrance words and i know about characters.

I want simulate artificial intelligence Robot speaks to you in android
how i can know about entrance words in android.


texts: Why does the location of my vehicle spawner change when I open a matinee?

texts:
I'm doing work with InterActors and vehicle spawners in Unreal Tournament 3's editor, and have it set up like so:

(The Walkway its on is the InterActor)

However if I go in Kemsit and open the matinee that handles the InterActor, this happens:

It does look to me like the editor is moving it out of the way so I can see the InterActor (which would be very clever) because only the image of the vehicle moves, not the gizmo, nor does the vehicle spawn in that location in game.

Is this the case?


texts: create terrain with some vertical cliffs, natural arcades, caves using octree

texts:
I am about to start creating the first terrain. I would like to create a terrain with vertical cliffs, natural arcades and caves.

For instance in one point the terrain might look like this.

I want to discuss about how to store this information about the terrain.

I think quadtree will not do the trick. From my understainding with quadtree perfectly vertical terrain is bound to be low quality in the vertical part, as you cannot subdivide it.

So I thounght that octree should be the right tool. But I have a conceptual problem with octree. I cannot understand how to store the triangle data in a octree structure.

Understanding how to store data in a quadtree is easy: you subdivide the region in a lot of squares and you give a coordinate value to each vertex of the squares, then you just connect all the verticies with triangles.

But what can you do when it comes to octtree? Which information should you store conceptually in the octree tree?

I cannot guess the logic and the algorithm that lays behind a octtree terrain.

Thank you


texts: What is the best way to handle MouseEvents in AS3?

texts:
What is the best way to handle MouseEvents?

Should I add an event on each MovieClip I want to work with, or a general Event at a holder MovieClip (or even at the stage) with internal control from the function?

I generaly see people here at work using one Event for each MovieClip, but all linked to the same funcion that handles them in general, is that a good thing? "target" and "currentTarget" seem a bit weird to me at first, but I think I'm starting to get it.


texts: How can I adjust the UVs of my quad so my texture isn't flipped?

texts:
My sprite geometry is reversed using matrix so that it is in the XZ plane. This results in the image used for the sprite to also be reversed, which I don't want:

(source : http://www.badlogicgames.com/wordpress/?p=2032 )

The image is then upside-down (note the 2 and 4):

Would you know how to switch the UVs, or apply a matrix on the image only?

Here is my code to draw the new image (the broken one):

curPix.drawPixmap(modelPix, newX, newY, modelX, modelY, tileResolution, tileResolution);

This is how the plane is modified in "render:"

batch.setProjectionMatrix(cam.combined);
batch.setTransformMatrix(matrix);
batch.begin();
getMap(0).draw(batch);
batch.end();


texts: Character states in component based entity system

texts:
I'm working on a Zelda-like game (github), and I made a component-based entity system.

I've a Scene class which holds a std::vector of SceneObject.
SceneObject is a collection of components
Scene uses systems, like MovementSystem, DrawingSystem, CollisionSystem to perform actions using components, or directly on components themselves. For example, this isMovementSystem:

#include "CollisionComponent.hpp"
#include "MovementComponent.hpp"
#include "MovementSystem.hpp"
#include "PositionComponent.hpp"

void MovementSystem::process(SceneObject &object) {
    if(object.has<PositionComponent>() && object.has<MovementComponent>()) {
        auto &positionComponent = object.get<PositionComponent>();
        auto &movementComponent = object.get<MovementComponent>();

        movementComponent.movement->process(object);

        movementComponent.isBlocked = false;

        if(object.has<CollisionComponent>()) {
            object.get<CollisionComponent>().checkCollisions(object);
        }

        movementComponent.isMoving = (movementComponent.vx || movementComponent.vy) ? true : false;

        positionComponent.move(movementComponent.vx * movementComponent.speed,
                               movementComponent.vy * movementComponent.speed);

        movementComponent.vx = 0;
        movementComponent.vy = 0;
    }
}

My problem is that I don't know how to handle states for characters.

For example, let's say Link has three states: Standing, Moving and Pushing.

In each state, a different animation is played, so DrawingSystem have to know about this, but I can't put it in a StateComponent because all the objects which need a state don't always need an information on animation.

In each state, I must check for conditions to change the current state and process an action. For example, if Link's current state is Standing, I must check if he's moving or not, to change his state to Moving.

Which components/system do I need to implement this?


texts:
I currently can rotate around a pivot point by first translating to the pivot point then performing the rotation and finally translating back to the origin. I do that easily enough for the shoulder in my example. However I cannot figure out how to also add in a rotation around the elbow for the forearm.

I've tried the following for the forearm rotation around the elbow:

translate to shoulder, rotate, translate to origin, translate to forearm, rotate, translate to origin
translate to shoulder, rotate, translate to forearm, rotate, translate to shoulder, translate to origin

Neither work for me. Any suggestions? I'm really stuck on this one.