texts: Slick2D shader crashes, but only after a while

texts:
I'm using Slick2D's ShaderProgram for shader-based drawing in my game. Some players report that after 3-10 minutes, the game inevitably crashes hard during what appears to be a setUniform4f operation that's happened thousands of times before:

[error occurred during error reporting (printing native stack), id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J  org.lwjgl.opengl.ARBShaderObjects.nglUniform4fARB(IFFFFJ)V
J  com.zarkonnen.airships.Appearance.draw(Lcom/zarkonnen/catengine/Draw;DDDDILcom/zarkonnen/catengine/util/Clr;Z)V

Full Log

Why might this happen? Is it a transient problem, or maybe a driver issue? I'm confused that this happens not when the shader is bound, or when textures are set, but at the point of this utterly mundane operation of setting a 4f value. I'm in fact pretty lost here, as I can't even repro this on any of my own machines.

This is the culprit function in its entirety:

public void draw(Draw d, double x, double y, double w, double h, int ms, Clr tint, boolean flipped) {
    if (shaderLoadFailed) {
        drawFallback(d, x, y, w, h, ms, tint, flipped);
        return;
    }

    if (tex == null) {
        tex = loadTex(SPRITESHEET);
        if (tex == null) {
            shaderLoadFailed = true;
        }
    }
    if (sp == null) {
        try {
            sp = ShaderProgram.loadProgram(
                    AGame.getGameDirectoryPath("data/passthrough.vert"),
                    AGame.getGameDirectoryPath("data/frag.frag"));
        } catch (Exception e) {
            e.printStackTrace();
            shaderLoadFailed = true;
        }
    }

    if (shaderLoadFailed) { return; }

    sp.bind();
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
    sp.setUniform1i("tex", 0);
    if (tint == null) {
        sp.setUniform4f("tint", 1.0f, 1.0f, 1.0f, 1.0f);
    } else {
        sp.setUniform4f("tint", tint.r / 255.0f, tint.g / 255.0f, tint.b / 255.0f, 1.0f);
    }

    Img img = frames.get((ms / interval) % frames.size());

    glBegin(GL_QUADS);
    if (flipped ^ isFlipped) {
        glTexCoord2d(img.srcX, img.srcY);
        glVertex2d(x + w, y);
        glTexCoord2d(img.srcX, img.srcY + img.srcHeight);
        glVertex2d(x + w, y + h);
        glTexCoord2d(img.srcX + img.srcWidth, img.srcY + img.srcHeight);
        glVertex2d(x, y + h);
        glTexCoord2d(img.srcX + img.srcWidth, img.srcY);
        glVertex2d(x, y);
    } else {
        glTexCoord2d(img.srcX, img.srcY);
        glVertex2d(x, y);
        glTexCoord2d(img.srcX, img.srcY + img.srcHeight);
        glVertex2d(x, y + h);
        glTexCoord2d(img.srcX + img.srcWidth, img.srcY + img.srcHeight);
        glVertex2d(x + w, y + h);
        glTexCoord2d(img.srcX + img.srcWidth, img.srcY);
        glVertex2d(x + w, y);
    }
    glEnd();
    sp.unbind();
    TextureImpl.bindNone();
}

And the shaders FWIW:

passthrough.vert

void main() {
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

frag.frag

uniform sampler2D tex;
uniform vec4 tint;

void main(void) {
    gl_FragColor = texture2D(tex, floor(gl_TexCoord[0].st) / 1024.0) * tint;
}

As you can see, there's very little to them.


texts: How can I disable the red X button in unity?

texts:
I just want to know how to disable the red X button in the game window using unity, to prevent the player for example from closing the game.

So if anyone knows how to do it, any help would be greatly appreciated.


texts:
I'm developing a 2d survival shooter using Box2d extension and I've got some questions:

I have two AnalogOnScreenControls. Their listeners modify both
sprites and bodies. I receive TouchEventPool was exhausted and as
their number grows the game crashes accidently. I've tried to put
the modification of the bodies and sprites on the UpdateThread but
that does not solve the problem. What could be the cause?
I have a class that at the beginnig of the game loads all the
textures. After I relaunch the game activity several times I receive
Unable to find Phys Addr for and "green color" interface. But that
doesn't happen if I clear the memory manually through the Task
Manager before relaunch What could be the cause? I unload my atlas
at the end of the game.
The game sometimes crashes at start with NullPointerException in
onResumeGame. The solution suggested is to set
android:configChanges="orientation|screenSize" but my device is API
10 so it doesn't have screenSize property and orientation only does
not seem to help, because the game starts in portrait mode at times
(though landscape is set in the code)


texts:
I have a 2D map of 500 x 500 tiles, split into chunks of 256 x 256.

I'm saving each chunk as a separate file, and I have them loading in as the player moves around. This means however there's over 1024 chunk files currently- and more to come when I increase the map.

Is this normal practice? I have no stutters when the game streams map loads or anything.


texts: Spritebuilder and CCScrollView, page indicators not showing up?

texts:
I'm using Spritebuilder to make my game, and CCScrollView usually saves me quite a bit of time. I'm trying to implement the scroll view much in the same way as the home screen on an iphone uses the UIScrollView. I want the page indicators to be visible and change as you scroll through the pages (the little white dots for iOS 7).

In Spritebuilder I set up the CCScrollView as a child of a CCNode. Then I set the content node to another one of my ccbi files, EasyPackpage1. When I run my project, everything works pretty well. I currently have a content node that is large enough so that it has three different pages, so if I scroll to the right it locks onto the next page, scroll to the right again, it locks onto the next page. The only problem is that the page indicators are non-existent. How can I get these page indicators?

If someone knows the solution for doing this using purely code, that would also be greatly appreciated. Cocos2d v3 still has very little documentation and I haven't been able to find much on how to use CCScrollView, since it looks like CCScrollLayer is deprecated in v3.

Thanks for the help!


texts:
Given the XYZ rotation of an object, e.g. (90,0,0), how can I find the object's normal assuming the object is pointing along it's local Z axis?

In the above example the desired result is (0,1,0).

I'm using blender, but this seemed like more of a general math question so I decided to ask here..


texts: Scene Graph for Deferred Rendering Engine

texts:
As a learning exercise I've written a deferred rendering engine. Now I'd like to add a scene graph to this engine but I'm a bit puzzled how to do this.

On a normal (forward rendering engine) I would just add all items (All implementing IDrawable and IUpdateAble) to my scene graph, than travel the scene-graph breadth first and call Draw() everywhere.

However in a deferred rendering engine I have to separate draw calls. First I have to draw the geometry, then the shadow casters and then the lights (all to different render targets), before I combine them all. So in this case I can't just travel over the scene graph and just call draw. The way I see it I either have to travel over the entire scene graph 3 times, checking what kind of object it is that has to be drawn, or I have to create 3 separate scene graphs that are somehow connected to each other. Both of these seem poor solutions, I'd like to handle scene objects more transparent.

One other solution I've thought of was traveling trough the scene graph as normal and adding items to 3 separate lists, separating geometry, shadow casters and lights, and then iterating these lists to draw the correct stuff, is this better, and is it wise to repopulate 3 lists every frame?


texts:
I would like to add log4net library as a logging tool to visual studio project which created by Unity, Is this possible?

I dragged the log4net DLL to assembly references in Visual Studio. so the DLL added to the project, but when I want to import it in code with using log4net, it doesn't find the library!


texts: Can we implement google play game services Multiplayer games with Facebook and not just Google+?

texts:
Basically, I want to make Multiplayer games but found Google Play Game Services only works with Google+ Login:
https://developers.google.com/games/services/android/turnbasedMultiplayer

How does one implement this with Facebook login so people can play with their facebook friends, etc.


texts: What does "ShapeRenderer.ShapeType.Filled", "ShapeRenderer.ShapeType.Line" and "ShapeRenderer.ShapeType.Point" do in libGdx

texts:
I am creating a game and I wanted to include collision detection when I came across this:
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);

What is this and what does ShapeRenderer.ShapeType.Filled, ShapeRenderer.ShapeType.Line and ShapeRenderer.ShapeType.Point do?
The official documentation has no information about this


texts: How to make my installer install XNA framework and .NET 4.0

texts:
I have made a simple Monogame game. Right now I am using this installation-package maker: http://installforge.net/

Currently my installer only installs my "game". (All the output files generated by the build)

However I also want it to install the XNA framework 4.0

https://www.microsoft.com/en-us/download/details.aspx?id=20914

and the .NET Framework 4.0

http://www.microsoft.com/en-us/download/details.aspx?id=17718

How would I do that?


texts:
I'm loading a number of characters (using SDL2_ttf) into a texture atlas to improve performance.

The glyphs can be separately rendered correctly, however, how can you find the kerning distance between two characters that will sit next to each other?

As a follow up, are there any other variables that impact font rendering?


texts: I understand that I can learn XNA as a hobbyist, but for top games like Fifa for example how are they witten?


texts: How can I send different contoller input to the different player avatars?

texts:
My apologies in advance for the vague question, since I don't understand the problem well enough to ask in finer detail.

I want to create a multi-player Unity application using the Oculus SDK. Let's say there are two players in the scene, A and B. The problem is this: When player A presses a button using his index finger, the hand avatar for player B also displays a moving index finger. In short, hand movements for one player are also observed for the other. Controller inputs are also read without any ability to distinguish whether they originate from player A or B.

What are the possible approaches for eliminating this problem, if it is mandatory that I continue using Oculus SDK?


texts: Pre-render 3D object from multiple angles, save as PNG

texts:
I'm looking for a tool or script that takes a 3D object (any format) and makes multiple renders of it automatically (using a raytracer or other high-quality offline renderer). It would then save the output as a series of PNG files.

Example: let me render a car from angles 0,90,180,270 and save the images to car0.png, car1.png, car2.png and car3.png with a single command.

Is there such a tool?


texts: Translate click on screen to point on plane in 3D space

texts:
I am creating a 2.5D game with the camera at a slight angle, like so:

The grid is the "playing field," and the positive x, y, and z directions are labelled.

I already know all the details about where the camera is, where the point on the grid that corresponds to the center of the screen is, and what the angle between the positive z axis and the direction the camera is pointing is.

What I want to do is be able to click on the screen, and figure out where on the grid I clicked. There are two ways that I have considered approaching this problem:

I could create a vector or ray of some sort that starts at the camera and goes in the direction the mouse is pointing. I could then solve the equation for the ray for x and y at z = 0. The problem with this is I don't know how computationally expensive it would be.
I could figure out the transformation matrix for something (I'm not sure exactly what it would have to be), then apply it to the [x y] position of the mouse. The problem with this is I have no idea where to start when finding the necessary transformation matrix.

Is one of these likely to be better than the other? Is there a different way that might be better? If I should use the transformation matrix option, how do I find that matrix?


texts:
I'm learning LibGdx and I need some help with the camera.

Let's see, I'm making a Chu Chu Rocket! clon to start. I've loaded a TiledMap (10x10), and I've created an OrthographicCamera to show the map.
This is my camera code, written in the Map class constructor, which is invoked in the create() method:

map = new TmxMapLoader().load("data/maps/" + filename);
renderer = new OrthogonalTiledMapRenderer(map, 1.0f/24.0f);
camera = new OrthographicCamera();
camera.setToOrtho(false, 10, 10);

And this is the result, when I compile

The problem is that the tiles I used in Tiled were squares. When I load, as you can see, they're rectangles. That's a problem for me.

I've read some things about resizing, changing aspect ratio, etc, but everithing was about doing it to fit various devices resolutions / screen sizes. So, my questions are:

How to define correctly the aspect ratio for a tiled map using a ortographic camera?
When I do that, the ratio will be correct for every device?
The elements which aren't the map (like the mice) would need to be also adjusted? How?

Thanks for your answers.


texts: How do I go about making a text box that allows for highlight-able and copyable text in the new UI?

texts:
I'm trying to make a simple chat system for our games lobby, however I am having issues making a text box that allows for text-highlighting. The Text component does not have interactible text, and the Inputfield allows for interaction, but I don't want the text to be editable in any way.

How would I go about doing this?


texts:
In Unity, does anyone know exactly what is behind the scenes of Application.genuine?

More specifically, I would like to understand its exact process so I can understand:

If I can use it safely without "false negatives".
If it considers text (or other) assets stored in a Resources folder (e.g. my level config files).

Just for context, I want to say that my target platform is iOS.


texts: How can I extract the RGB color data from a TGA image?

texts:
I am working in OpenGL, and I am trying to create terrains using height maps.

I am using my own functions to load a TGA image, and in order to pass data to heightmap vertex shader I need to retrieve RGB components from the TGA image.

I am not quite sure how to do that, I saw in one tutorial that SDL library can be used to retrieve RGB component from a TGA image, but I do not want to use any such libraries because I am already able to load a TGA.

So, how do I recover RGB information per pixel from a TGA that we loaded?


texts:
I am raytracing on the CPU and I need to display my renders to the screen in realtime. I chose SDL 2 as it seems to be made for low level stuff.

I made this basic test which fills the screen from left to right, one column of pixel per frame. It works as expected, but runs very slowly (~10 fps):

int resolutionX = 1920, resolutionY = 1080;

if (SDL_Init(SDL_INIT_VIDEO) != 0)
    return EXIT_FAILURE;

SDL_Window *window = SDL_CreateWindow("Hello World!", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, resolutionX, resolutionY, SDL_WINDOW_SHOWN);
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
PixelBuffer *framebuffer = createPixelBuffer(resolutionX, resolutionY);
SDL_Texture *framebufferTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, framebuffer->width, framebuffer->height);

for (int x = 0; x < resolutionX; x++)
{
    for (int y = 0; y < resolutionY; y++)
        setPixel(framebuffer, x, y, 0x123456FF);

    SDL_UpdateTexture(framebufferTexture, NULL, framebuffer->pixels, framebuffer->pitch);
    SDL_RenderCopy(renderer, framebufferTexture, NULL, NULL);
    SDL_RenderPresent(renderer);
}

SDL_DestroyTexture(framebufferTexture);
destroyPixelBuffer(framebuffer);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();

I found SDL_UpdateTexture to be the slowdown.

I heard of SDL_LockTexture but I don't think I should be using it for write-only operations.
EDIT : SDL_LockTexture is in fact exactly made for write-only operations.

Am I using this function in a wrong way ? Is there any other way to display my renders in real time ?


texts:
I'm making a very basic online RPG (2d, and instead of sprites I use characters, like a roguelike) and I still haven't figured out how to store and retrieve maps. Until now I used a text file that are stored on the server.
Should I store the map in the database and retrieve it as the player moves around?
For example, if the player is in the position [x, y], load all the tiles within a 15 tile radius.

Or maybe dividing the map in "sections" and then, depending on the player's location load a given section?
Which is the best option?

Also, if I was to save the map in the database, which is the best data type to store it as a bi-dimensional array? BLOB maybe?


texts: Tips for communication between JS browser game and node.js server?

texts:
I am tinkering around with some simple Canvas based cave flyer game and I would like to make it multiplayer eventually. The plan is to use Node.js on the server side.

The data sent over would consists of position of each player, direction, velocity and such. The player movements are simple force physics, so I should be able to extrapolate movements before next update from server.

Any tips or best practices on the communications side? I guess web sockets are the way to go. Should I send information in every pass of the game loop or with specified intervals? Also, I don't mind if it doesn't work with older browsers.


texts:
I'm trying to split a tileset (from here) into individual tiles.

For debugging purposes I wrote some code to split the tileset into individual tiles and display them on screen, but some aren't being split correctly.

There are some small icons after the mob in the 3rd line from the bottom that got mixed up because they seemed to be smaller than 32x32.
Here is my code for splitting them:

public class TilesetEngine : Game
{
    Dictionary<int, Texture2D> individualTiles = new Dictionary<int, Texture2D>();

    public void LoadTiles(string szFileName, ContentManager content, GraphicsDevice graphicsDevice)
    {
        var foo = content.Load<Texture2D>(szFileName);

        Color[] imageData = new Color[foo.Width * foo.Height];
        foo.GetData<Color>(imageData);

        var horizontalElements = foo.Width / 32;
        var verticalLines = foo.Height / 32;

        var i = 0;

        for (int y = 0; y < verticalLines; y++)
        {

            for (int x = 0; x < horizontalElements; x++)
            {
                var startRect = new Rectangle(x * 32, y * 32, 32, 32);

                var colorPiece = getImageData(imageData, foo.Width, startRect);
                var subTexture = new Texture2D(graphicsDevice, 32, 32);
                subTexture.SetData<Color>(colorPiece);
                individualTiles.Add(i, subTexture);

                i++;
            }
        }
    }

    public IEnumerable<Texture2D> GetTiles()
    {
        return individualTiles.Values.AsEnumerable<Texture2D>();
    }

    Color[] getImageData(Color[] colorData, int width, Rectangle rectangle)
    {
        var color = new Color[rectangle.Width * rectangle.Height];
        for (int x = 0; x < rectangle.Width; x++)
            for (int y = 0; y < rectangle.Height; y++)
                color[x + y * rectangle.Width] = colorData[x + rectangle.X + (y + rectangle.Y) * width];
        return color;
    }
}

Usage

        tileEngine = new TilesetEngine();
        tileEngine.LoadTiles("fantasy-tileset", Content,GraphicsDevice);

Drawing code

        spriteBatch.Begin();

        int i = 0;
        int padding = 10;
        var tiles = tileEngine.GetTiles();

        var maxPerLine = 10;
        var count = 0;
        var vertLine = 0;

        foreach (var p in tiles)
        {
            spriteBatch.Draw(p, new Rectangle(count * 32 + padding * count, vertLine * 32 + padding * vertLine, p.Width, p.Height), Color.White);
            count++;

            if (count == maxPerLine)
            {
                count = 0;
                vertLine++;
            }
        }

        spriteBatch.End();

I don't believe this is the best way, since I always found tilesets with pictures with variable size, what would be the best way to detect an individual tile from a tileset and split it?


texts: How can I make the gun rotate and shoot like lost control and shooting all around?

texts:
The shooting part I will make later. Now I'm trying to make the rotations part.

The first thing I did is to rotate the gun barrel and this is working fine.
The next thing I want to do is to rotate the gun body 360 degrees randomly so when the gun will shoot it will shoot randomly all around like lost control.

This is a screenshot of the gun barrel :

And the gun body :

By rotating the gun body 360 degrees randomly I want to create a lost control effect so it will shoot all around hitting randomly.

The script is attached to the top parent Drone :

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

public class Rotate : MonoBehaviour
{
    public Transform[] wings;
    public Transform[] propellers;
    public Transform gunBarrel;
    public Transform gunBody;
    public float propellersSpinSpeed = 50;
    public float wingsSpinSpeed = 50;
    public float gunBarrelSpeed = 50;

    private float angle = 360.0f;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < propellers.Length; i++)
        {
            propellers[i].Rotate(0, propellersSpinSpeed * Time.deltaTime, 0);
        }

        for (int i = 0; i < wings.Length; i++)
        {
            wings[i].Rotate(0, wingsSpinSpeed * Time.deltaTime, 0);
        }

        gunBarrel.Rotate(0, 30 * gunBarrelSpeed * Time.deltaTime, 0);

        gunBody.Rotate(Vector3.zero, angle * Time.deltaTime / 1.0f);
    }
}

I tried to do :

gunBody.Rotate(Vector3.zero, angle * Time.deltaTime / 1.0f);

But it does nothing not rotating it 360 degrees and I didn't use yet the Random.
The gun barrel keep rotating but the lost control shooting all around is not working yet not sure how to do it.

Update :

This is the current code :

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

public class Rotate : MonoBehaviour
{
    public Transform[] wings;
    public Transform[] propellers;
    public Transform gunBarrel;
    public Transform gunBody;
    public float propellersSpinSpeed = 50;
    public float wingsSpinSpeed = 50;
    public float gunBarrelSpeed = 50;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < propellers.Length; i++)
        {
            propellers[i].Rotate(0, propellersSpinSpeed * Time.deltaTime, 0);
        }

        for (int i = 0; i < wings.Length; i++)
        {
            wings[i].Rotate(0, wingsSpinSpeed * Time.deltaTime, 0);
        }

        gunBarrel.Rotate(0, 30 * gunBarrelSpeed * Time.deltaTime, 0);

        gunBody.localEulerAngles = new Vector3(Mathf.Clamp(gunBody.localEulerAngles.x, 0f, 90f), 0, 0);
    }
}

The gunBody is now facing down.

This is a screenshot of what I want the gunBody to do :
I changed the gunBody on X and Z rotations a bit and this is the behaviour I want it to do randomly rotating on X and Z but not to pass too much up/down and left/right degrees.

The Z to be in range more or less 150, 205 and the X range of 55,100
And make it moving smooth randomly on this ranges. I'm not sure to the float point if those are the ranges but more or less this is what I mean by randomly moving in circles 360 degrees shooting all around like lost control.

Same behaviour of a turret trying to shoot on target and rotate 360 degrees in any direction the same thing here but only looking forward not backward. This is the logic I mean moving in circles and shooting around to the front.


texts: How to convert relative position of child to parent into an absolute position?

texts:
I am modifying a game that stores object positions with a 3d vector { x, y, z } and rotation as a 3d vector with degree angles { x, y, z }.
I want to place an object in relation to a parent object accounting for its rotation. I do not have access to the game code, so I have to provide a position of the child as an absolute position.
For example, I would like to place a child object at a relative position { 50, 0, 100 }: 50 units along the x axis and 100 units up the z axis from the parent's position.
Assuming the parent object is currently at position { 0, 0, 0 } with rotation { 0, 0, 0 } the resulting absolute position for the child object would be simply { 50, 0, 100 }.
But, if the parent has a position of { 0, 0, 0 } and a rotation of { 0, 0, 90° }, the child's absolute position would be { 0, 50, 100 }.
What would be the transformation function that, given the absolute parent position, parent rotation, and relative child position, outputs the absolute position of the child (taking into account all three axes of rotation)?


texts: Level Design: Char Traveling to and from a Site

texts:
I'm developing a 2d platformer game where your character can travel to and from sites as he pleases. To travel to and from these sites the character must travel along a path between his current location and his destination (see illustration below).

And of course the idea is that you can travel through the level backwards if you wish to return to Site One. But as you probably realize, doing this may provoke some serious problems, and will put limitations on the level design (no cliffs or long drops because then your character wouldn't be able to overcome them on the way back). I've come up with multiple ways to overcome this (such as designing two levels for the same path etc), but I was wondering if anyone else has any creative work-arounds for this problem. Any help and advice is appreciated.


texts: Accessing uniform variables from a Cg shader in OpenGL

texts:
I am trying to implement a simple PC program with OpenGL, using mandatorily Cg shaders (no Unity whatsoever).

I have found some tips on this page http://bobobobo.wordpress.com/2008/10/05/cg-1/ and kept the Cgprogram, Cgcontext and Cgprofile types in my own project.

Problem is: How can you access uniform variables in the C++ code?
I have tried the glGetUniformLocation way, but that won't work because the first parameter must be the program's ID of GLuint type and I have CGprogram type.

I have already searched by myself (including the Nvidia Cg 'tutorial') but I can't seem to find both Cg and OpenGL discussed on a page without having to deal with Unity.

edit: I can now access the variables, but in my case I'm trying to change a texture, and it doesn't bind.


texts: Should I amortize scripting cost via bytecode analysis or multithreading?

texts:
I'm working on a game sort of thing where users can write arbitrary code for individual agents, and I'm trying to decide the best way to divide up computation time.

The simplest option would be to give each agent a set amount of time and skip their turn if it elapses without an action being decided upon, but I would like people to be able to write their agents decision functions without having to think too much about how long its taking unless they really want to.

The two approaches I'm considering are giving each agent a set number of bytecode instructions (taking cost into account) each timestep, and making players deal with the consequences of the game state changing between blocks of computation (as with Battlecode) or giving each agent it's own thread and giving each thread equal time on the processor.

I'm about equally knowledgeable on both concurrency and bytecode stuff, which is to say not very, so I'm wondering which approach would be best. I have a clearer idea of how I'd structure things if I used bytecode, but less certainty about how to actually implement the analysis. I'm pretty sure I can work up a concurrency based system without much trouble, but I worry it will be messier with more overhead and will add unnecessary complexity to the project.


texts: Handling incoming packets immediately or queuing them

texts:
I'm using Golang to write a game server. I was wondering what the advantages of queuing the incoming packets for processing over processing them immediately.

For example (processing immediately) each new connection/client a new goroutine/coroutine is created and within that goroutine a loop that reads from the network socket and has a switch statement that routes and handles each packet.

Or (queuing) each new connection/client a new goroutine is created and within that goroutine a loop that reads from the network socket and passes it to a queue. A second dedicated goroutine for this connection/client has a loop that process the packets in the queue.

Is this a pre-optimization? How are MMORPG's (server side) packet recv/handling handled in principle?

I'm using TCP.


texts: trouble getting the lighting and material set up right

texts:
I am having some trouble getting the lighting and material set up. Below I have setup lighting and material, however, when ever I turn on spectular reflection for material the sphere that I am rendering turns white with only a little of its colour in the corners. But if I don't turn it on I get approximately the right colour. I understand that specular reflection property of material is suppose to reflect light and make the object look shiny. But with a specular reflection value of {0.1,0.1,0.1,1} the difference seems to be really great. I don't think the picture below is what I want. Could anyone tell me what I am doing wrong here?

      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
      GLfloat ambientLight[] = {1.0, 1.0, 1.0};
      GLfloat diffuseLight[] =  {1.0, 1.0, 1.0};
      GLfloat specularLight[] = {1.0, 1.0, 1.0};
      GLfloat position[] = { 10.0f, 10.0f, 10.0f, 1.0f };

      glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
      glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
      glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
      glLightfv(GL_LIGHT0, GL_POSITION, position);

      GLfloat materialColor[] = {1, 0, 0, 1.0};
      GLfloat materialSpecular[] = {0.1, 0.1, 0.1, 1.0};

      //The color emitted by the material
      glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, materialColor);
      glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, materialSpecular);
      glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 10);
      // Perform OpenGL calls necessary to set up this material.


texts: Apply Vertex Colors to XNA Spritebatch sprites

texts: I know that you can use custom vertex and pixel shaders using SpriteBatch but I can't figure out how to apply colors to individual vertex points on a sprite generated by spritebatch. All I can do is apply a blanket color to the entire sprite rather than being able to blend between the 4 points that should be available in a quad. Can anyone give me a hand with this?


texts: How to implement translation, scale, rotation gizmos for manipulating 3D object's transforms?

texts:
I am in the process of developing a basic 3D editor. It uses OpenGL for rendering a 3D world. Right now my scene is just a few boxes of different sizes and I am at the stage where I want to be able to select each box and then move/scale/rotate it to achieve any transform I want.

How can I solve the problem of implementing both the rendering of these tool's gizmos(or handles, or how people usually call them), and also picking them on each axis to perform the change in the transform with my mouse? For clarity:

My research so far suggested the cleanest approach is to have an axis aligned bounding box per arrow in the gizmo and another one per square (the ones that move the object in a plane rather than a single axis) and then cast a ray from the mouse position and see what it collides with. But this is still a bit too abstract for me, I would appreciate further guidance in how this algorithm would go (pseudocode is more than enough)


texts: Camera Rolling when Implementing Pitch and Yaw

texts:
I am implementing a camera in opengl for an android game and am having problems getting the pitch/yaw/roll of the camera correct. I have read many tutorials on quaternions and have implemented a basic camera based on this link.

Everything works well except for when I pitch and yaw I get unwanted roll. I have read things that say I need to apply the pitch/yaw rotation together to prevent this, and other things that said not to track individual changes to angles, but I'm not sure what they mean or how to extend this implementation to mine. I am new to this type of math so any help would be appreciated.

My goal is to have a camera that can rotate similar to how a space ship would rotate - I want the camera to be able to rotate 360 degrees in all directions and turn upside-down - which is why I was rotating the upVector too.

Any suggestions on what I can do to not have the camera roll when rotating around the y and y axes?

Thanks!

Here is the code that translates user input into two angles, and rotates the lookVector, upVector, and rightVector of the camera. My problem is the camera is also rolling when I just pitch and yaw.

// Java
// Camera uses a position vector, lookAt vector, and upVector
// eventually calls Matrix.setLookAtM()

Camera c = mRenderer.theCamera;

// PVector is a class that implements a 3 dimensional vector

float thetaX = getTouchChange(...); // set by the user touching the screen
float thetaY = getTouchChange(...); // set by the user touching the screen

// I keep 3 vectors in the camera class, one points up, one points right,
// and the 3rd is the point I am looking at

///////////////////////////////////////////////
// Pitch - rotate the up and look around right
///////////////////////////////////////////////
// get up and look vectors
PVector lookVector = PVector.sub(c.getLookAtPoint(), c.getLocation());
PVector otherVector = c.getUpDirection();
// get axis
PVector rAxis = c.getRightDirection();
rAxis.normalize();
// rotate look
PVector rotated = Quaternion.rotateVector(lookVector, rAxis, thetaY);
// Add back camera location to convert vector to actual look points
rotated.add(mRenderer.theCamera.getLocation());
c.setLookAtPoint(rotated);
// rotate up
rotated = Quaternion.rotateVector(otherVector, rAxis, thetaY);
rotated.normalize();
c.setUpDirection(rotated);

///////////////////////////////////////////////
// Yaw - rotate the look and right around up
///////////////////////////////////////////////
// get up and look vectors
lookVector = PVector.sub(c.getLookAtPoint(), c.getLocation());
otherVector = c.getRightDirection();
// get axis
rAxis = c.getUpDirection();
rAxis.normalize();
// rotate look
rotated = Quaternion.rotateVector(lookVector, rAxis, thetaX);
// Add back camera location to convert vector to actual look points
rotated.add(mRenderer.theCamera.getLocation());
c.setLookAtPoint(rotated);
// rotate right
rotated = Quaternion.rotateVector(otherVector, rAxis, thetaX);
rotated.normalize();
c.setRightDirection(rotated);

In my rendering code I update the camera orientation by calling the following

// called in onSurfaceChanged
Matrix.frustumM(m3DProjectionMatrix, 0, -screenRatio, screenRatio, -1, 1, 1, 70);

// called in onDrawFrame
Matrix.setLookAtM(m3DViewMatrix, 0,
    theCamera.getLocation().x, theCamera.getLocation().y, theCamera.getLocation().z,
    theCamera.getLookAtPoint().x, theCamera.getLookAtPoint().y, theCamera.getLookAtPoint().z,
    theCamera.getUpDirection().x, theCamera.getUpDirection().y, theCamera.getUpDirection().z);

Matrix.multiplyMM(m3DMVPMatrix, 0, m3DProjectionMatrix, 0, m3DViewMatrix, 0);

// m3DMVPMatrix is eventually passed to the shader along with the shape data


texts: Unity - Inaccurate rotation if object is rotated on two axis at once

texts:
I have an object which i want to rotate relative to world space. I have three variables (one for every axis) which store the rotation. By pressing buttons on my controller I add or subtract 90 to these variables (rotX, rotY, rotZ). Then I rotate my Object like this:

transform.Rotate (rotX * delta, rotY * delta, rotZ * delta, Space.World);

As this is called every frame the object would spin forever so i subtract the ammount I've allready rotated afterwards:

rotX -= rotX * delta;
rotY -= rotY * delta;
rotZ -= rotZ * delta;

This works fine as long as I don't rotate two axis at once. Then the object rotates rotates only partially to the desired position (e.g. 83 if I want to rotate to 90).

I can't see what I've done wrong. It actually seems like the moment I start an rotation around an axis all other axis get canceled. But if I monitor the variables they look exactly as they should.

Thank you in advance and have a amazing day!


texts: Calculate Position on Tile Map by single Index

texts:
I stumble about a Math Problem for calculating a Position on a dynamic tile-map.

So i got a List of Tile Entities. Every Tile got his one unique Index Value and i have to set the parameters for Map Height and Width.

Example A
Map X = 3 Y = 4

Example B
Map X = 4 Y = 3

To get the X Position Value of Tile E6 i know i have to use Map.X % 6.
But i'm not sure how to get the Y Position of the Tile by his Index. % in this case stands for the modulo operation (c#).

Is there a name for such an calculation? Does somebody already know the answer?


texts:
I am currently working on a game in Game Maker Studio 2 where the player character is capable of increasing their maximum health beyond a starting value of 30, by increments of 10. I want to represent this graphically by adding a different-colored overlay to the character's health bar for each additional 10 points added, with the last layer added diminishing before the ones behind it, proportional to how much of the last "extra" 10 points remains.

If you are familiar with the Mega Man Zero games, and how some bosses in that game had extra health represented in "layered" health bars that decremented independently of and sequentially to each other, I am basically trying to make that, just using a different health increment for all layers beyond the first.

So far I can get the first layer to work out just fine:

draw_sprite_ext(sprite931, -1,0,0,(min(30, hp_current)/30),1,0,c_white,1);

but I am having some difficulty calculating the xscale argument for the layers representing hp_current values 31-40, 41-50, 51-60, etc. without causing visual glitches.

To summarize, I need the gauge to remain full if the player's current HP is equal or greater than its respective range's maximum, be empty if it is less than its increment range's minimum, and scale between empty and full proportional to where hp_current lies between said layer's maximum and minimum values. I am having trouble figuring out how to make each layer do this independently of each other. Does anyone else have experience with making something similar to this work?


texts:
I'm trying to figure out an approach to creating a cocos2d scene that would help kiddos learn to draw letters of the alphabet. Right now I am just using Apple’s PaintView demo code and applying an outline mask for each letter such that the child only sees their tracings within the unmasked parts of each letter. But I want to take it a step further.

Here is how I have defined the challenge:

I have used Cocos2d before and was thinking it should be used for this problem as well.
I need to build 26 of these and was wonder if sprite builder would be a good tool to layout each letter. If so do you have any hints on how to define the stroke paths?


texts:
In the update, I have set up a counter so that after 140 frames, Unity will quit the game. But this quit command doesn't quit and it just continues to play the game. What am I doing wrong? I am using and testing in Unity 2D. There are no errors and all the prints are visible.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Normal_Car : MonoBehaviour
{
    private int counter = 0;

    public Vector3 finalPos = new Vector3(0.00f,0.00f,0.00f);

    public Transform t;

    // Start is called before the first frame update
    void Start()
    {
        t.GetComponent<Transform>();
    }

    // Update is called once per frame
    void Update()
    {
        print("Frame: " + counter.ToString());
        counter += 1;
        t.position += finalPos;
        if(counter >= 140)
        {
            Application.Quit();
            print("Quit!");
        }
    }
}


texts: ECS - Lantern implementation / How does the RenderSystem determine which one to choose? Entity-Datastructure

texts:
I want to implement ECS in my game. The more I read the more insecure I get.

The current available Components for a Entity processed by the RenderSystem are:

RenderComponent (mesh, texture, normalmap, etc.)
TransformationComponent (position, scale, rotation)
LightComponent (light color, brightness)
CameraComponent (view Matrix)

Let's assume that my EntityManager has a methode: getEntitiesByComponents(Class[] components): List and is a singleton.

Here is my pseudocode with the issues I have:

cclass RenderSystem {

    EntityManager em = EntityManager.getInstance();
    Renderer renderer = new Renderer();

    update(float dt) {

        //This one contained only  RenderSystem related components
        RenderSystemComponents rsc = em.getRenderSystemComponents();

        // Try to get the Camera
        [CameraComponent,TransformationComponent][] cameraArray = rsc.getComponentByType(TRANSFORMATION,CAMERA);
        // Check if Camera is avaible
        if(cameraArray.length != 1) {
            // Do some error Stuff here
            // Not sure if I should allow more then one Camera
            // e.g. MiniMap
        }

        // lights
        [TransformationComponent,LightComponent][] lightArray = em.getComponentByType(TRANSFORMATION, LIGHT);

        // 'default' entities
        [TransformationComponent,LightComponent][] entityArray = em.getComponentByType(TRANSFORMATION, RENDER);

        renderer.render(cameraArray,lightArray,entityArray);
    }

    public enum ComponentType {
        RENDER, TRANSFORMATION, LIGHT, CAMERA
    }
}

This implementation could work if my method getEntitesByComponents is fast enough. But the floor is literally the floor. The Terrain has seen from the component's point of view no difference but the RenderEngine should know that it is processing an Entity ( box, tree, player, mob, ... ) or a terrain (different shaders). This isn't a only RenderSystem problem even the Collision detection has to know if it's a terrain or an entity.

This is my first problem understanding how I detect differences. The second problem is the method getEntitesByComponents. Current this peace of code doesn't exists in a way I would use it. The basic concept I current use is the one here. The Structure is a Map<String, Map<Id, Component>>. The String is the Component class, which maps to a Map with the EntityId as key and the actual component as value.

if you want to get the components from an entity you ask map.get(Component.class).get(Entity#getId()) but you can't direct ask this structure to get all entities who refer to certain components without looping throw the map. So I need a proper management for the objects.

My first idea is to modify the entity class with a new attribute map and give each Component a unique static Id. So you can easily loop throw the entities and check with something like map.keySet().conatains(x) and y without checking one entity multiple times. But this seems not to be a common implantation. I often see a 'ComponentManager' but unfortunately the article I read doesn't describe the inner datastructure.


texts: How can I get the width and height of a picture?

texts:
I'm trying to make a script on RPG Maker XP that needs the width and height of an image to do some calculations. I tried @picture.bitmap.widthand @picture.bitmap.height but it returned the width and height of the image that is being shown in the screen.

For instance, if the image is 800 pixels height, and the image takes 400 pixels in the screen, @picture.bitmap.height will only return 400.
This is the code I'm using:

@picture = Sprite.new
@picture.bitmap = RPG::Cache.picture("picture")
@pictureWidth = @picture.bitmap.width
@pictureHeight = @picture.bitmap.height


texts: How to know when user has stopped dragging

texts: How can we know when user has stopped dragging fingers over screen if user has not removed finger from screen but stopped dragging ?


texts: Is ID@Xbox restricted to established studios?

texts:
I read through the ID@Xbox site but don't totally understand the program. I am a software developer who has made a few Flash games on my own and would like to try to port or recreate one of them for Xbox One.

Is this program only for established game studios?


texts: What verb describes when you hold a joystick to the right or left?

texts:
I'm trying to describe a the scenario where you use a joystick to turn the camera. However, I'm struggling to find the word for this. Saying the joystick is "pressed" could mean the joystick is pressed in (as in when you press a playstation controller's joystick and it clicks).

What word describes when a joystick is held in a cardinal direction?


texts:
I have a basic 20x20 array that stores the map for my game. It either has a 1 or 0 to say a path and a non path. When I draw it on the screen, It seems to take to long to draw one at a time and looks like a snake is being loaded on the screen. I need them drawing faster.

Set up the screen array

for(int i=0; i<sizeOfArray; i++)
    {
        for(int j=0; j<sizeOfArray; j++)
        {
            if (LevelOne[i][j]==0)//Path
            {
                screenChunks[i][j].Set(i*40,j*40,"Path.bmp", screen);
            }
            if (LevelOne[i][j]==1)//Wall
            {
                screenChunks[i][j].Set(i*40,j*40,"Wall.bmp", screen);
            }
            if (LevelOne[i][j]==2) //Hero
            {
                screenChunks[i][j].Set(i*40,j*40,"Hero.bmp", screen);
            }
        }
    }

Draw the sprites

for(int i=0; i<sizeOfArray; i++)
    {
        for(int j=0; j<sizeOfArray; j++)
        {
            screenChunks[i][j].Draw();
        }
    }

    //Dynamically drawn each time
    SDL_FillRect(screen,0,0);

    //Hero Start Position
    hero.Draw();

    SDL_Delay(60);

Sprite.cpp Draw Method

void Sprite::Draw()
{
SDL_Rect offset;

//Give the offsets to the rectangle
offset.x = PosX;
offset.y = PosY;

//Blit the surface
SDL_BlitSurface( sprite, NULL, Screen, &offset );

Height = offset.h;
Width = offset.w;

SDL_UpdateRect(Screen, 0,0,0,0);

}

Sprite Setter

void Sprite::Set(int posX, int posY, string imagePath, SDL_Surface *screen)
{
PosX = posX;
PosY = posY;
ImagePath = imagePath;
Screen = screen;

if(ImagePath == "")
    return;

char * writable = new char [ImagePath.size()+1];
strcpy (writable, ImagePath.c_str());

temp = SDL_LoadBMP(writable);
sprite = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
// free the string after using it
delete[] writable;
}


texts: Play videos via 3rd party library or as animation in libGDX?

texts:
I want to add an animated splash screen to my desktop game, which I develop using libGDX. Now I see there is no native support for videos in libGDX, so I guess I have two options:

Include a 3rd party framework for video playback (like the Java
media framework); or
Save the video as a series of PNG images and
play them as a libGDX animation.

Since the splash screen video is not very long, maybe 5 seconds or so, I tend to the libGDX animation option. However, the video would be full screen, so rather large images, and I am not sure whether an animation would really be the best option in that case.

Does anyone of you guys have some experience with (full screen) video playback under libGDX on the desktop?


texts: How do you turn off all scene lighting in the game view like you would with the scene view button?

texts: In the scene view, there's a control bar with a 'lighting' button that lets you toggle scene view lighting. This turns off all shadows and all light sources, i.e. makes it so that all objects are seen as fully bright on all sides.  How do I do the same for the game view?


texts: OpenGL ES 2.0 Without The Use of Shaders

texts:
While refreshing my mind on OpenGL ES, I decided to read a few of the books I brought a while back and search for some tutorials online.

Whilst doing so, I came across many beginner's tutorials that show how to draw a triangle using simply the followings:

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
....
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);

or using simply:

glDrawElements

along with an index buffer.

However to my understanding, is that since OpenGL ES 2.0, one must supply both a vertex and a fragment shader and the modern rendering pipeline is:

Primitive Processing - Vertex Shader - Primitive Assembly - Rasterizer -
Fragment Shader - Depth Stencil - Color Buffer Blend - Frame Buffer

So my question is, how is it possible for those tutorials to draw without having any vertex nor fragment shaders using just glDrawElements or glDrawArrays? Or, does the program supply them automatically when no shaders are in use and when it detects that either or both glDrawElements and glDrawArrays are in use?

In addition, does the aforementioned flow of pipeline withhold when no shaders are in use?

Thank you.


texts: How do I accomplish fading texture trails in UDK?

texts:
I would like to know how to leave a fading texture/material trail in udk.

For example (I'm not sure if there is a special name for this effect):

A character may leave footprints that fade after x number of seconds
Or, a tank may leave a tracks trail as in Civilization IV.

Here is another example of this type of effect. Skip to 1:00 and watch the green slime texture.

  http://www.youtube.com/watch?v=KdJIauWjE8s

How do I accomplish this effect in UDK? Any good tutorials?

Thank you.


texts: Bones are rotated wrong direction on play mode

texts:
I made animations from Blender and exported as FBX.

However in Unity, default pose seems fine in edit mode.

But in play mode, spine bones are rotated wrong direction:

It's Humanoid type and each bones are set correctly without any error. There's nothing make change to those bones but why it has wrong rotation in play mode?

What am I missing? What should I check about this?

Any advice will very appreciate it.


texts: How to tune the collision handling to respond differently depending on the collided objects?

texts:
I'm making a collision handler for a Java game engine. I made an interface called Collidable. I have a method called onCollision which takes the parameter of my Engine Game Object.

public void onCollision(engine.objects.Object obj) {

}

I want to know how I can redo this so that I can give individual instructions for each Collidable object's onCollision method for how to collide with a Wall object or an Enemy object without having to write another method that has the parameters Wall and Enemy so that my engine is flexible.

How can I do this?


texts: Way to check overlaps of a collider2d that's not set to "is trigger" in Unity

texts:
I have a system where physics2d objects are spawned and I need to know when they spawn outside of a region defined by a box collider set to "is Trigger".
Using onTriggerEnter and onTriggerExit to know if an object exits / re-enters the bounds (with some other conditions determining whether to kill the object when it exits the bounds). That stuff works fine.
However I can't detect when an object spawns outside of the collider (which I want to allow, but just know when it happens).
I tried the following in the Start method of the spawned object:
List<Collider2D> results = new List<Collider2D>();
_boundsCollider.OverlapCollider(new ContactFilter2D(), results);
bool spawned_outside = !results.Contains(_thisCollider);

However at the time that method runs, the booundsCollider doesn't register it. Subsequent frames it will, but that's too late.
OverlapCollder can't be run on the collider for the spawned object since it isn't set as a trigger.
Is there any way I can query the spawned object's own collider to determine if it is in contact with the bounds collider?
Thanks!
PS I can't trivially just reference the coords of the object and check if they're out of bounds because the bounds collider will move, and I want to know with precision wether just a corner is overlapping or whatever so I'd need something that amounts to my own simple collision system


texts: How to calculate the viewing cone radius at a distance in raymarching?

texts:
I'm "raymarching distance fields" (proper lingo: sphere-tracing) in GLSL. To implement cone-marching atop of it (and also to minimize the number of raymarching steps regardless of whether cone-marching is added or not), I need to estimate the radius of the ray cone at any given distance.

Recall with raymarching distance fields, a "hit" is recorded when the distance to an object is smaller than a threshold value, often in code named nearLimit or epsilon. This threshold can be seen as equivalent to the ray-cone radius if we increase it exponentially with distance traveled -- this way, we don't shoot straight thin ray lines into space but cones expanding in accordance with perspective projection. This more accurately covers catching the "right" distant objects (at this point let's ignore the issue of blending materials and filtering normals of all intersected objects in the viewing cone at distance t for now...).

At step 0, this radius can be approximated by something such as

float fInitialRadius = 1 / min(screenwidth, screenheight);

This can then be increased at each step exponentially by applying the starting radius to the distance:

fNearLimit = fTotalDist * fInitialRadius;  // after each raymarching step

This works OK but still has artifacts. If I use fInitialRadius*fInitialRadius (resulting in a smaller number since initial radius for a 640px framebuffer and a unit-width view-plane is 1/640) I get less artifacts and a more accurate result. But both approaches are inaccurate, the first is too eager (increases radius too much too early), the latter too lazy (increases radius too little too late).

The most accurate factor to increase fNearLimit / the cone radius at a given distance must most likely take into account my current field of view and will vary depending on whether field-of-view is 45° or 60° or 90° or...

TL;DR: I want to know what's the proper calculation or most acceptable approximation of the cone radius at a given distance given the initial pixel radius at step 0 and the field of view angle?


texts: I have a game that I made in Unity and I have a windows build for it. It works fine on windows no problems there but I want to make a mac version of it. To make a mac version will it work if I just build it for mac or will I have to reprogram it for mac? I don't have a mac to test this and obviously I dont want to release a broken game. Note that the game uses the command Input.GetMouseButtonDown(0) a lot, not sure if you need a different command for a mac mouse.


texts: XNA Spritebatch sorting by texture vs depth

texts:
I am refining my 2D game engine, and I want to look in to sorting sprite batches by texture (because I'm quite often using the same textures repeatedly).

However, I also want to retain a few 'layers' of depth (i.e. ground < buildings < units < GUI etc).

My question is, which of the following is the best approach (in terms of performance)?

Create multiple SpriteBatches and Begin() and End() them in order; or...
Create a single SpriteBatch and call Begin() and End() multiple times, once for each layer (in order)?


texts: XNA: Perform Collision Detection Against 3D Scene Geometry

texts:
How would one perform collision detection between a simple scene like the one below and a simple object like a sphere?

I assume the best solution would involve convex hulls in some way but I have no idea how that works (still learning :)


texts: Unity - Exporting and Importing Terrains

texts:
To provide modding support via Unity editor, I need to export terrains in editor and load the exported terrain in runtime.

Is this possible by any manner?


texts: Why does my terrain turn white when I get close to it?

texts:
When I zoom in on my terrain it goes white:

The further in I zoom, the greater the whiteness becomes. Is this normal? Is this to speed up rendering or something? Can I turn it off?

I'm also getting these error messages in the console over and over again:

  rc.right != m_GfxWindow->GetWidth() || rc.bottom != m_GfxWindow->GetHeight()

and

  GUI Window tries to begin rendering while something else has not finished rendering! Either you have a recursive OnGUI rendering, or previous OnGUI did not clean up properly.

Does this bear any correlation on the issue?

Update I create virtual desktops to flit between using the program Deskpot. Turning this program off and restarting has stopped the above errors appearing in the console. However, I still get white terrain when I zoom in. Not a single error message.

I've restarted my computer to no avail.

I have an Asus NVidia GeForce GTX 760 2GB DDR5 Direct CU II OC Edition Graphics Card. Any known issues?

Update I don't think it's fog...


texts:
I'll be likely writing one this year. It will end up having unique design so things turn out on its own anyway.

Though, what an experienced level designer would want from a level editor? Requirements? Key features? Things that could be worth the time spent into implementing them?


texts: OpenGL Fragment Shader Interpolation Vs Inverse Calculation

texts:
I have found openGL fragment shader tutorials on the web, some that use use inverse calculations to revert the fragment coordinate back to the world space and others that interpolate the position.  With that said...

Is there a difference between interpolated world-space position and the actual world space position calculated using inverse matrices and the fragment window space coordinates?
Does anyone know of any resources that would help me understand the mathematical differences between these two things, if they are different?
If they aren't different, then why would anyone use inverse matrices instead of interpolating, which seems less expensive?

I wrote a shader to test 1, but I cannot tell if rounding errors are to blame for the differences or not.

Thanks!


texts: how to check mouse is not over any object in unity

texts:
Im working on a way to check mouse is not over any object on scene to put my object in there. i know i can use OnMouseOver function but i have to add it on all objects script. Is there any other way to check my mouse position is not on any object collider?
Its a 2d project.
thank you for helping


texts: rendering an image within c# & sharpdx dirext3d9 [game overlay]

texts:
I'm following this guide and the related blog post to implement a basic game overlay for DirectX 9 games using SharpDX.

So the tutorial already have an example for text rendering but I need to be also able to render a provided image to the overlay.

Any ideas, guides?


texts:
I have been trying to create a smooth movement technique that would allow me to move in all directions, not just the 8 cardinal directions.
I have tried to use this doing trig, and while the coordinates are being calculated correctly, drawing anything onto graphics requires me to use integers. Because of the rounding, the movement is reduced to the 8 cardinal directions again. How can I get around the draw methods only using integers?

I calculate the movement by taking the current x position, and adding the product of the speed and sin/cos of the angle of movement

public void moveForward(Block b) {

        b.x += speed * Math.sin(angle);

        b.y += speed * Math.cos(angle);
}

Here is the Block class:

import java.awt.Graphics;

public class Block {
int x, y;
public Map() {
    x=0;
    y=0;
}

public void Draw(Graphics g) {
    g.drawRect(x,y,100,100);
}

And this is the panel class that draws the movement:

import java.awt.Graphics;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JPanel;
import javax.swing.KeyStroke;

public class Panel extends JPanel{
Block block;
Movement movement = new Movement(0);
boolean mforward,mback,rright,rleft;

public Panel() {
    block = new Block();
    setKeyBinds();
    game.start();
}

Thread game = new Thread(){
    public void run(){
        while(true){
        if(mforward)
            movement.moveForward(block);
        if(mback)
            movement.moveBack(block);
        if(rright)
            movement.addangle(1);
        if(rleft)
            movement.addangle(-1);
        repaint();
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {}
        }
    }
};

public void paintComponent(Graphics g){
    super.paintComponent(g);
    block.Draw(g);
    movement.Draw(g);
}

//Following code is for setting up keymapping

private void setKeyBinds() {
    getInputMap().put(KeyStroke.getKeyStroke("UP"), "MOVEUP");
    getInputMap().put(KeyStroke.getKeyStroke("DOWN"), "MOVEDOWN");
    getInputMap().put(KeyStroke.getKeyStroke("LEFT"), "MOVELEFT");
    getInputMap().put(KeyStroke.getKeyStroke("RIGHT"), "MOVERIGHT");
    getInputMap().put(KeyStroke.getKeyStroke("released UP"), "STOPUP");
    getInputMap().put(KeyStroke.getKeyStroke("released DOWN"), "STOPDOWN");
    getInputMap().put(KeyStroke.getKeyStroke("released LEFT"), "STOPLEFT");
    getInputMap().put(KeyStroke.getKeyStroke("released RIGHT"), "STOPRIGHT");
    getActionMap().put("MOVEUP", moveforward);
    getActionMap().put("MOVEDOWN", moveback);
    getActionMap().put("MOVELEFT", rotateleft);
    getActionMap().put("MOVERIGHT", rotateright);
    getActionMap().put("STOPUP", stopup);
    getActionMap().put("STOPDOWN", stopdown);
    getActionMap().put("STOPLEFT", stopleft);
    getActionMap().put("STOPRIGHT", stopright);
}
AbstractAction moveforward = new AbstractAction() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        mforward=true;
    }

};
AbstractAction moveback = new AbstractAction() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        mback=true;
    }

};
AbstractAction rotateleft  = new AbstractAction() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        rleft=true;
    }

};
AbstractAction rotateright = new AbstractAction() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
    rright=true;
    }

};
AbstractAction stopup = new AbstractAction() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
mforward=false;
    }

};
AbstractAction stopdown = new AbstractAction() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        mback=false;
    }

};
AbstractAction stopleft = new AbstractAction() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        rleft=false;
    }

};
AbstractAction stopright = new AbstractAction() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        rright=false;
    }

};

}


texts:
There are many systems where attack statistics are opposed by defense statistics:

Strict: HP -= (damage - defense)
Threshold: HP -= (damage>defense? damage : 0)
Reciprocal: HP -= (damage / defense)

Just to name a few, and there are variations on those as well:

Reciprocal threshold: HP -= damage>defense ? (damage/defense) : 0

Note that this is by no means an exhaustive list, since many games use multiple stats to arrive at a final "defensive" result (agility, current speed, movement relative to attacker, flanking) that's applied to any potential damage.

What drives the selection of one relationship over another?


texts: Are there 3D projections other than orthographic and perspective?

texts:
The question is pretty much in the title. Are there notable 3D projections other than orthographic and perspective that could be used in a 3D system such as OpenGL?

In particular, are there any that have a particular use in game design?


texts: Making unity inspector accept classes that inherit from a base class

texts:
I have a base class that has a lot of classes inheriting from it, I want to make a script that you can drop one of these derived classes into. How do i do that?

abstract class thingy : UnityEngine.ScriptableObject
{
    // methods, variables, etc
}

class awsomeThing : thingy
{
    // Imagine there are more of these classes with different names...
}

I've managed to get the thingy class to show up but (as you can guess) you can only drag in that script in there, is there a way to get the inspector to accept the multiple awsomeThing classes?


texts: Increase the speed of my grid/render system?

texts:
I currently have a simple Minecraft-like grid system setup.
The game has a world -> a world has multiple chunks -> a chunk has blocks.

The world asks the chunks to render (if needed), but the render function in the chunk class takes up 97.4% of the application!
72.8% of that method is checking whether a block is at a specific location. This is needed, because I want to check if the block is surrounded by other blocks. If so the block is not visible, so it doesn't need to be rendered.

World.cpp

//97.4% of the application
void World::render()
{
    m_Renderer.prepare();
    for (int i = 0; i < CHUNKS_AMOUNT; i++) {
        m_Chunks[i]->render();
    }
}

//33.8% of the application
bool World::hasBlockAtLocation(const int& x, const int& y, const int& z)
{
    int chunkX = x / CHUNK_WIDTH;
    int chunkZ = z / CHUNK_WIDTH;

    Chunk* const& chunk = getChunk(chunkX, chunkZ);

    if (chunk) {

        int blockX = x - chunkX*CHUNK_WIDTH;
        int blockZ = z - chunkZ*CHUNK_WIDTH;

        if (chunk->hasBlockAtLocation(blockX, y, blockZ))
            return 1;
    }
    return 0;
}

Chunk.cpp

//97.4% of the application
void Chunk::render()
{
    int xMin = xLoc * CHUNK_WIDTH;
    int xMax = xLoc * CHUNK_WIDTH + CHUNK_WIDTH;

    int zMin = zLoc * CHUNK_WIDTH;
    int zMax = zLoc * CHUNK_WIDTH + CHUNK_WIDTH;

    if (xMax < m_Camera->getXMin()) return;
    if (xMin > m_Camera->getXMax()) return;

    if (zMax < m_Camera->getZMin()) return;
    if (zMin > m_Camera->getZMax()) return;

    for (int i = 0; i < CHUNK_SIZE; i++) {
        if (m_Blocks[i] != nullptr) {
            glm::vec3& pos = *m_Blocks[i]->getPosition();

            //If statement takes 72.6% of the application!
            if (!m_World->hasBlockAtLocation(pos.x - 1, pos.y, pos.z) ||
                !m_World->hasBlockAtLocation(pos.x + 1, pos.y, pos.z) ||
                !m_World->hasBlockAtLocation(pos.x, pos.y - 1, pos.z) ||
                !m_World->hasBlockAtLocation(pos.x, pos.y + 1, pos.z) ||
                !m_World->hasBlockAtLocation(pos.x, pos.y, pos.z - 1) ||
                !m_World->hasBlockAtLocation(pos.x, pos.y, pos.z + 1))

            {
                m_Renderer->addToRenderQueue(m_Blocks[i]);
            }
        }
    }
    m_Renderer->render();
}

//13.3% of the application
bool Chunk::hasBlockAtLocation(const int& x, const int& y, const int& z)
{
    if (x < 0 || y < 0 || z < 0) return 0;
    if (x >= CHUNK_WIDTH || y >= CHUNK_HEIGHT || z >= CHUNK_WIDTH) return 0;

    if (m_Blocks[CHUNK_WIDTH * CHUNK_WIDTH * y + CHUNK_WIDTH * z + x])
        return 1;
    return 0;
}

So how can I increase this speed? Because it's a real bottleneck and I ran out of ideas...

Any help would be appreciated!
If any additional information is required please ask.


texts:
So, I'm trying to develop a 3d table tennis game, and I'm having problems when it comes to colliding the ball with the table. I have a bounding sphere for the ball and bounding box for the table, but the intersection isn't that accurate, and I'm guessing that the bounding box is incorrect since colliding the ball with the racket is good.

I'm trying to display the bounding box so that it would be easier to see where the error is, but I cant seem to implement the tutorials I've found with my code, or just don't know how. And, I'm I right in creating an AABB since my table isn't moving? If anyone could help, it would be greatly appreciated, or if anyone could suggest a better way to collide a ball with a box (if there is) thanks. I've pasted my bounding box detection, and the collision between the sphere and box. If more code is needed I'll post it. Thanks

http://pastebin.com/NDYmhXCh

http://pastebin.com/47vwJWSc


texts: Varying spritefont quality depending on string

texts:
I'm using Kleymissky font size 26 made via Nuclex font renderer (Hinting Method: AutoHinter) - download

Why the thickness of the font drawn on screen depends on the string itself? What can I do to ensure it'll always be drawn one way or another (but not both)?

I'm using MonoGame, dll v3.1.2


texts:
I'm wondering how I can get the final position of a vertex. I use glTranslate in my render code, and I'm not getting the world-coordinates correct. My world is devided in chunks and my position get's screwed up.

I have tried multiplying the position with the 3 built-in matrices, but no success.


texts:
This is a question that may have an answer that differs for vanilla desktop GL and GL ES 2.0 (and wishful thinking is that ES 3.0 would have the same answer as vanilla GL).

What I'm doing is rendering a cubemap with a FS quad and I'd like to know if there's a way to specify a constant depth value for an entire render call rather than to get involved at the fragment shader level, in hopes of chasing a little bit of performance as well as flexibility in that I can use the same shader for drawing to different const depth values.

As for why it might benefit performance, the note at the bottom here offers some ideas, such as early-z testing... I suppose realistically if I emit a constant distant fragment depth, then early-z can still happen while maintaining the flexibility of pixel-programmable depth in general (necessary for proper impostors as shown). In this case I may be splitting hairs unnecessarily at this point. However that note does mention that if I can avoid specifying gl_FragDepth, I should, but it'd be up to the driver whether it will do something smart if I e.g. set gl_FragDepth to a constant.

As an example I could render my 3D scene, then set depth draw value to maximum, keep depth test on, and then render a fullscreen quad for my cubemap skybox, and it would just do the right thing.

Otherwise, choices include:

render skybox first with depth testing switched off, then render scene
use a fragment shader for the skybox that specifies the requisite depth value (this may very well just be the answer)


texts: How to add a nice looking muzzle flash to the tip of my guns

texts:
I am making a top down shooter and would like to add a muzzle flash to the tips of my guns. So I have an idea of what I want to do which would be just a circle that would fade from yellow to white or from white to yellow, don't really know yet. I actually have know clue how to fade in and fade out colors in libgdx so don't know how to do that. I guess I could also pass in a texture that I can color yellow and append that to the tip of the gun but still would like to add a color fade. Of course, these are just my crappy little ideas. Anyone else have a better idea that would look better graphically and if so could you try to describe it in some detail that would be great.

Thanks!


texts: Unity get more than 2 lines of log height

texts:
Unity does only display 2 lines in height for each log, at least with the default settings. I couldn't find a menu, where I could change this.

I want to display a matrix, and I need to see the log live, so it's no option for me to click on each log separately. Has unity no option to increase the height of a log line? And additionally is there no option to hide the "source" of the log like the line "UnityEngine.Debug:Log(Object)" I mean I can hide it if I click "collapse" but I don't want to collapse the entries, since it stacks the same entries which is not what I want....

Edit: I just saw, that there exist some plugins, which would do the job I guess. But I wonder if there is a way to solve this with the Unity console, since I don't want to pack my project full of utility stuff for developing...


texts:
I have following idea about processing keyboard input. We capture input in "main" Game class like this:

protected override void Update(GameTime gameTime)
{
    this.CurrentKeyboardState = Keyboard.GetState();

    // main :Game class logic here

    base.Update(gameTime);

    this.PreviousKeyboardState = this.CurrentKeyboardState;
}

then, reuse keyboard states (which have internal scope) in all other game components. The reasons behind this are 1) minimize keyboard processing load, and 2) reduce "pollution" of all other classes with similar keyboard state variables.

Since I'm quite a noob in both game and XNA development, I would like to know if all of this sounds reasonable.

UPDATE: If someone is interested, actual utility class, as suggested by David Gouveia, I've created can be found here.


texts: How can I avoid duplication of jBox2D physics attributes?

texts:
I'm using jBox2D for physics and collision detection in a game engine with an entity-component system. It works, but I'm unsure how to structure my code with respect to the values represented in the Physics World and in my Pixel world.

Initially, I had these vectors on my Entity class:

public Vector position;
public Vector acceleration;
public Vector velocity;

public Body body; //this is jBox2D's physics body object.

Duplication is bad. How can I reduce the duplication of entity values in jBox2d's physics body?


texts: How to overlay texture materials on top of each other in Unity 2D tiled game

texts:
I'm learning how to do a 2D tile-based game. So far, I have followed this tutorial which seems like a good starting point.

With his method of building the raw triangles and then applying the uvs, I do not understand how I would go about layering other materials on top.

The code he's using to generate the tilebased grid:

  float x = transform.position.x;
  float y = transform.position.y;
  float z = transform.position.z;

  newVertices.Add( new Vector3 (x  , y  , z ));
  newVertices.Add( new Vector3 (x + 1 , y  , z ));
  newVertices.Add( new Vector3 (x + 1 , y-1 , z ));
  newVertices.Add( new Vector3 (x  , y-1 , z ));

  newTriangles.Add(0);
  newTriangles.Add(1);
  newTriangles.Add(3);
  newTriangles.Add(1);
  newTriangles.Add(2);
  newTriangles.Add(3);

  newUV.Add(new Vector2 (tUnit * tStone.x, tUnit * tStone.y + tUnit));
  newUV.Add(new Vector2 (tUnit * tStone.x + tUnit, tUnit * tStone.y + tUnit));
  newUV.Add(new Vector2 (tUnit * tStone.x + tUnit, tUnit * tStone.y));
  newUV.Add(new Vector2 (tUnit * tStone.x, tUnit * tStone.y));

  mesh.Clear ();
  mesh.vertices = newVertices.ToArray();
  mesh.triangles = newTriangles.ToArray();
  mesh.uv = newUV.ToArray(); // add this line to the code here
  mesh.Optimize ();
  mesh.RecalculateNormals ();

This is his texture import (Notice he isn't using Sprites):

I want many items on the grid: terrain, enemies, trees, clouds, cursor.

These would have to be layered on top of each other somehow. An ordering could be:

Layer 0: Base Terrain
Layer 1: Trees
Layer 2: Enemies
Layer 3: Clouds
Layer 4: Mouse Cursor

I know that the SpriteRenderer has a Sorting Layer that does the layering for you. However, the author in the tutorial does not use Sprites, so using the Sorting Layer doesn't seem to be an option? He is using Texture Type: Advanced when importing the texture and then chooses some options.

The only other way I can think of is to logically represent different layers by using a different z-index for each logical layer. But I've read that this will cause clipping/artifact issues when rendering, and so using the Sorting Layer is preferred.

If using Sprites is the way to go, could I still use the author's way to generating tiles? The way he's doing it seems pretty efficient since he's building the triangles together to form one tile instead of using a plane/gameobject. I imagine that reassigning the uvs to the triangles is also pretty efficient. I don't quite understand how Sprites can be used on top of what the author has done or how overlaying should be done if using sprites is not possible.

I'm using Unity 4.5.5.


texts: Help with concrete examples of Perlin Noise variables for terrain generation

texts:
I believe this question can help beginner game developers. I've looked through a dozen or so answers on perlin noise here and on Stackoverflow, and found only 1 concrete implementation of perlin noise that I have listed below. There's a lot of advice, but it's hard to translate into what I have to do with X and Y values, and if I have to do this at all times, or only when I want specific features to appear.

Here's what I got from Stackoverflow: I believe this was advised as mixing various noise octaves. It seems to generate a fairly interesting terrain, although it rarely generates mountains for me.

  float perlinNoiseValue =
    +1/15.0* fabsf([generator perlinNoiseX: perlinX y: localYIndex z: 0 t: 0])
    +2/15.0* fabsf([generator perlinNoiseX: 2*perlinX y: 2*localYIndex z: 0 t: 0])
    +4/15.0* fabsf([generator perlinNoiseX: 4*perlinX y: 4*localYIndex z: 0 t: 0])
    +8/15.0* fabsf([generator perlinNoiseX: 8*perlinX y: 8*localYIndex z: 0 t: 0]);

I'm looking at this answer on Perlin Noise by Byte56, and it's hard for me to translate verbal descriptions into what I have to do with X/Y inputs. Can someone provide concrete examples, along with descriptions of what terrain features such noise generates?

For example, does mixing noise by picking the max value equates to something along the lines of

float perlinNoiseValue1 =  fabsf([generator perlinNoiseX: perlinX y: localYIndex + 300 z: 0 t: 0]);
float perlinNoiseValue2 =  fabsf([generator perlinNoiseX: perlinX y: localYIndex z: 0 t: 0]);

float finalValue = fmax(perlinNoiseValue1,perlinNoiseValue2);

Do I always pick the max value in the case above, or only in some cases when I want a certain feature to manifest?

Does flatter terrain look like ?

float flatterTerrain =  fabsf([generator perlinNoiseX: perlinX y: 0.2*localYIndex z: 0 t: 0]);

Does wider valleys and hills look like?

float widerValleys =  fabsf([generator perlinNoiseX: perlinX*3.0 y: localYIndex z: 0 t: 0]);


texts: Binary space partitioning with floor as an object

texts: I have a conceptual problem. The problems comes with the floor I'm rendering and the count of objects. The idea was to reduce rendering with BSP implementation, but the problem that I hit was that the floor has huge object (triangles that range through the entire scene). Should I put those objects into the parent nodes of the BSP or try to split them into smaller triangles.


texts: RTS Lockstep: How to deal with high latency and packet drops?

texts:
In the lockstep RTS model, I understand how games can be made deterministic by sending across commands to run at designated frames in the future. Then, to keep everyone in sync, confirmations are sent back to confirm that the commands were properly received. If the confirmations wasn't received, the command wouldn't run and the game would pause.

My question is how do I keep the confirmation frames in sync? Given at least 2 players i.e. Player_A and Player_B:

It's entirely possible that Player_A might receive confirmation from Player_B but Player_B wouldn't from Player_A, so Player_A would run the command while Player_B would pause and be out of sync. How can this be dealt with? Confirmation for the confirmations?


texts: Easy way to do gravity in a simple game?

texts:
I'm looking for an easy, beginner friendly way to do gravity in a platformer.
I've looked into Box2D tutorials, but they all seem very complicated.

All I want is a class that takes into account if my player is grounded, or airborn, and a nice little curve as he jumps. I know this shouldn't be more than a few lines of code, and learning a library seems excessive.

Anyone mind helping me out?


texts:
i'm drawing text above monster head and it's fine. But when there is to many monsters and their name gets render every second cause fps go down. When i disable the font drawing, then the fps is fine. Any idéa how to tackle this perfomence issue?

Thanks.


texts:
i just did the tutorial on Hardware Instancing from this source: http://www.float4x4.net/index.php/2011/07/hardware-instancing-for-pc-in-xna-4-with-textures/. Somewhere between 900.000 and 1.000.000 draw calls for the cube i get this error "XNA Framework HiDef profile supports a maximum VertexBuffer size of 67108863." while still running smoothly on 900k. That is slightly less then 100x100x100 which are a exactly a million.

Now i have seen voxel engines with very "tiny" voxels, you easily get to 1.000.000 cubes in view with rough terrain and a decent far plane. Obviously i can optimize a lot in the geometry buffer method, like rendering only visible faces of a cube or using larger faces covering multiple cubes if the area is flat. But is a vertex buffer of roughly 67mb the max i can work with or can i create multiple?


texts: What kind of gaming platforms for Linux are available?

texts: Which libraries/platforms are available on Linux to start game development?


texts: unity: input event consumed by image raycast target that is "under" a sprite with a 2D collider

texts:
I am having a hard time getting my UI to work.

Basically I have a canvas with a UI image A that is the size of the screen. This image has raycast enabled and if effectively receiving inputs.

Not in the canvas I have a sprite B that have a 2D collider attached to it. No matter what I try, the UI image is always consuming the input event when I click on the sprite.

When I disable the image A , the sprite B gets the events, so the setup looks right (camera with Physic2D raycaster for the sprite B, layerMask set to the layer of the sprite B, canvas with Graphic raycaster for the image A, no blocking object, no mask).

What do I need to do so that the sprite B gets the input event BEFORE the image A and consume it?

EDIT:
Those two elements are part of the UI and must be interactable at all time. I use a sprite for the second element as it is dragged from the UI inside the game and I don't want to make it an image.

The image A is a big cancel button with opacity 0 on the whole screen that must be active at all time.

I just want to know if the Collider of sprite B can intercept the input before the image A. If it isn't possible, I'll create an Image B instead of the sprite B and destroy it to create a Sprite with the same texture when the  is interacted with.


texts:
I want to implement a 360-degree viewer for Augmented-Reality in Unity. Augmented-Reality means in this case, that I want to place an image like an interface mockup in my viewer which has transparency. The transparency is getting filled with the real world. So the real world part is working without problems, but that is also the reason, why a sky box is not possible since the sky box would block that.

So I already had 2 approaches:

A sphere with a shader which rendered only the inside (turned the
normals), worked on my MAC, but didn't render anything on my vr/ar
device (Samsung GearVR)... Here a picture how it should look like and does look like in the Unity Editor. But nothing of this "crosshair" is showing up on the GearVR

A sphere or cylinder where I turned the normals beforehand in
Blender, didn't apply the texture correctly and didn't show anything
in Unity and on Device except a blank color.


texts: How much memory does a texture take up on the GPU?

texts: A large png on disk may only take up a couple megabytes but I imagine that on the gpu the same png is stored in an uncompressed format which takes up much more space. Is this true? If it is true, how much space?


texts: Bounding box collision handling makes player glitch to the other side of the wall

texts:
The way I handle simple collision detection causes a really frequent and easy to reproduce glitch, which affects gameplay severely. Here's my code (Python 3.5):

 def move(self, _map):
    self.col = False
    for y in _map.actors:
        for actor in y:
            if actor[1]:
                if not (((self.y + self.h) < (actor[1].y - self.cam.y)) or (self.y > ((actor[1].y - self.cam.y) + actor[1].h)) or (self.x > ((actor[1].x - self.cam.x) + actor[1].w)) or ((self.x + self.w) < (actor[1].x - self.cam.x))):
                    print(self.col)
                    self.col = True
    if not self.col:
        if self.directions[0]:
            self.cam.y -= self.speed
        if self.directions[1]:
            self.cam.y += self.speed
        if self.directions[2]:
            self.cam.x -= self.speed
        if self.directions[3]:
            self.cam.x += self.speed
    else:
        if self.directions[0]:
            self.cam.y += self.speed
        if self.directions[1]:
            self.cam.y -= self.speed
        if self.directions[2]:
            self.cam.x += self.speed
        if self.directions[3]:
            self.cam.x -= self.speed
    if self.running:
        self.speed = system.RUNNING_PLAYER_SPEED
    else:
        self.speed = system.NORMAL_PLAYER_SPEED
    self.x = ((self.cam.w / 2) - (self.w / 2))
    self.y = ((self.cam.h / 2) - (self.h / 2))

As you can see, I'm detecting collision against walls and whatever (Any actor in the map) in the player's "move" method. The logic is pretty straightforward, a basic bounding box collision test (I consider the position of the player relative to the camera, since the player is always in the center (It's the camera that moves)).
If I just stop the player if there's a collision, the player gets stuck inside the wall, thus creating the necessity of "teleporting" the player to its former position, as you can see in this other question.
The problem with that solution is that it leads to this glitch, which I need to illustrate in order to make myself clear.

In this first example, I'm going up (pressing W) towards the wall.

The collision works fine just pressing W, it gets teleported in the opposite direction at each collision. The problem is when I start pressing S (Down) at the same time. The player goes to the opposite direction, glitching up towards the other side of the wall, since the collision test always returns true when the player is "inside" the wall, just like this:

This would severely compromise the gameplay, since players would be able to play outside the boundaries of the map in multiplayer. How can I avoid this using bounding box collision or other method?


texts:
Let's say I'm making a 2D game and I want to implement a zoom in/out feature. Normally this is as simple as modifying the projection matrix to get more or less of the world to show. However, this results in quite blurry resizing, and I suspect the culprit is the GL_LINEAR parameter you supply to glTexParameteri as explained here.

I've done my fair share of video resizing and I know much better algorithms exist such as bicubic filtering, lanczos, spline, etc, however the only one OpenGL offers is (tri?)linear. What would be the best way of improving 2d scaling? I suppose this would involve shaders but I'm not familiar with the approach. Any reference to working code would be a nice plus.


texts: Getting "System.Int32 is not defined or imported" in Visual Studio 2017 with Unity

texts:
I have been working well with Unity 2018.2 & VS2015, the only issue was the constant VS2015 reloading but I was putting up with it. When I upgraded to Unity 2018.3 an issue came up when trying to start debugging on VS2015:

I searched online and the only discussion I found recommended upgrading to VS2017, but when I switched to it I got a billion errors in the solution regarding basic types such as int or object not being defined:

These errors are only in VS2017, the Unity editor reports everything being fine. Can anyone help me fix either version? Thank you.


texts: How can I set only the players X rotation to 0 in Quaternion.Slerp in Unity?

texts:
I want to set the players X axis to zero while he is turning to the target Object but I dont get it to work.

Code:

public float rotationSpeed;

void OnMouseDown()
{
        //PLAYER ROTATION TO ORE OBJECT
        var rotation = Quaternion.LookRotation(transform.position - player.transform.position);
        player.transform.rotation = Quaternion.Slerp (player.transform.rotation, rotation, rotationSpeed * Time.deltaTime);
    }


texts: How can I determine when colliders of two gameobjects touch one another?

texts: I stop gameobjects from colliding with one another by having box colliders around the gameobjects with dimensions bigger than the gameobjects. It works fine, but I want that when the gameobjects collide with one another, they stop moving. I cannot use OnTriggerEnter as I have turned IsTrigger off. Is there a thing which can determine when two gameobjects' collider touch each other?


texts:
I'm stuck in this situation:

I have a GameObject with a script, that persist trough Level loads.

Inside this script, when a condition is meet, i Load a Level, and also call a function. That function is a C# Messenger Broadcast() function.

The level that I am loading contain the script with the Listener for that Messenger Broadcast.

The problem is that the Broadcast occurs before the level has been loaded, and so there is no Messenger Listener that can receive the event.

  BroadcastException: Broadcasting message OnConnectionError but no listener
  found.

I need to do the Broadcast only after the level has been loaded, but I don't know how, or maybe there is a better solution.

For a simple example here is the code:

public class NetworkingManager : MonoBehaviour {

    void Start(){
        DontDestroyOnLoad (this);
    }

    void OnConnectionLost(BaseEvent _event ){
        if(Application.loadedLevelName != "LoginScreen"){
            Application.LoadLevel ("LoginScreen");
        }
        Debug.Log ("Disconnected. Reason: " + _event.Params["reason"]);
        Messenger<string>.Broadcast ("OnConnectionError", "Disconnected");
    }
}


texts: Unity2D Best way to determine degrees between two colliding entities?

texts:
I'm trying to determine the collision-direction between two objects. I'll be using this for various things such as creating blood-entities in a specific direction proportional to where the other entity is hitting an entity. What's the best/most efficient way to do this? I've been doing this but it seems unstable/not to be working.

Assuming both entities are center-pivoted, I use trigonometry to find the angle like; atan(b/a).
For some reason the output angle seems to be pretty random.

Here's the method I made:

protected void checkCollisionDirection(Collision2D target)
    {
        Vector3 positionDifference = target.gameObject.transform.position - gameObject.transform.position;
        int quadrant = 0;
        float x = positionDifference.x;
        float y = positionDifference.y;
        float degrees = Mathf.Atan (y / x) * Mathf.Rad2Deg;

        if (positionDifference.x > 0 && positionDifference.y > 0)
        {
            quadrant = 1;
        }
        else if (positionDifference.x < 0 && positionDifference.y > 0)
        {
            quadrant = 2;
            degrees += 180;
        }
        else if (positionDifference.x < 0 && positionDifference.y < 0)
        {
            quadrant = 3;
            degrees += 180;
        }
        else if (positionDifference.x > 0 && positionDifference.y < 0)
        {
            quadrant = 4;
            degrees += 360;
        }
        hitDirectionDegrees = degrees;
    }

I'm open to any suggestions that can find an angle between two entities.


texts: SDL2 - Isometric map: Draw visible tiles or draw pre-rendered slice of the whole map?

texts:
I started a small project which is basically an isometric map with tiles. Right now I render only the visible tiles - at each rendering cycle.

Because I don't have experience with actual SDL2 projects I'm asking myself if I can store a large map (e.g. 10000 x 10000 tiles with 32px each) completely into an SDL_Texture. In my rendering routine I could slice out everything that's visible and draw a few things on top of it, e.g. units.


texts:
I want to know is with XNA 4.0 (and C#) How do I exactly make a top down shooter? I have been looking for ages, but have been unable to find out how.

If someone could tell me how to get started with it or possibly link me to a good easy to understand tutorial that would be fantastic!


texts: libGDX - Why do I have to use camera.setToOrtho what does it do?

texts:
I am very confused about camera matrices and I don't know where to start my studying. Maybe I have to study OpenGL, but I don't know C++ ...

Ok so I have a camera, Box2d world and a Box2d body.

private World world;
private Box2DDebugRenderer b2dr;
private OrthographicCamera cam;
private Body player;

@Override
public void create () {
    //Create the world without gravity
    world = new World(new Vector2(0, 0), false);
    b2dr = new Box2DDebugRenderer();
    //I create my camera
    cam = new OrthographicCamera();

    //Create the player
    BodyDef bdef = new BodyDef();
    bdef.type = BodyDef.BodyType.DynamicBody;

    //Sets the body position to the center of the screen
    bdef.position.set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);

    player = world.createBody(bdef);
    CircleShape shape = new CircleShape();
    shape.setRadius(2f);
    player.createFixture(shape, 1f);
}

@Override
public void render () {
    world.step(1f/60f, 6, 2);

    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    b2dr.render(world, cam.combined);
}

I am not seeing the player on the center of the screen, just a black void.

But if I add cam.setToOrtho(false); I see the player!
Why is that?

setToOrtho sets the camera to Orthographic projection WHY?

The camera is Orthographic what oder projection can it have?? Isn't the orthographic projection obvious?


texts: Component/Entity-based design + Behavior Trees => how to integrate?

texts:
For my current project I implemented a component/entity-based system, basically following most of the best-practice there is in this rather undefined area.

So I got (slightly extended) Entities, which are basically an int ID, a human-readable Name, a std::map of components and a long "type indicator" which is used to show what components are present (I have an power of two enum for all the components types and whenever a component is added to the Entity, I automatically alter that long via bitwise operations, compare this answer).

Then there are the Components, also rather simple: int ID, enum as component type, parent Entity pointer and a std::map of all properties this component holds.

Lastly some Systems/Managers that handle the actual logic processing. They first check if the currently processed Entity has a matching long "type indicator" = all necessary components for that system are present. It then accesses some properties if needed and either directly calls some functions in the respective component or send some messages (via a message dispatcher).

Bottom-line: Until here, a rather standard event-driven component/entity-based system combined with a data-driven approach (compare, components do not have hard-coded data variables, but instead a generic map, as (some) components/archetypes of components will later be read from files with the option to add additional data, that is not part of the actual component code.

Now I would like to also introduce Behavior Trees (based on AiGameDev BTSK) into that project, but I am not sure if and how they should be linked to the already existing components or how to integrate those design in general.

Several related ideas/points/questions come to mind:

My BTs will be read from files (again). I currently have a hard time seeing how I would however best make the connection between an BT Action in that tree and the actual coding in my application. Should I build up some sort of map between the action names used in the BT files and a function pointer to the actual logic implementation? What is the usual approach to solve that?
I assume that I will have to create BTs for all my different Entity types (so for each game-logic/AI-relevant combination of components as indicated by my multiple times mentioned long "type indicator"). As a result it doesn't make sense to put the BT Action implementations in the components as most likely many components will be involved per action, does it?
So should the BT Action logic sit in a/multiple separate systems (to whose methods the map from idea #1 points to)? The system would then check per my long "type indicator" whether the Entity for which the BT is currently checked and that was told to execute a certain action (= method in the system) is actually allowed to do so (= has the necessary components). But then, if not (because for example the BT creator did overlook a specific situation, where a necessary component might not be attached to the Entity at runtime anymore), nothing would happen.

Questions:

Are there proven concepts for that kind of integration?
What is your take on my 3 points above?
Any other things that come to mind, also regarding my component/entity-based design in general?


texts:
I'd like to use Lua to write some scripts which should allow me, given the state of certain variables of a specific instance, to determine a number to be assigned to a variable of that instance.

Let me explain: I have a class, which is called Monster. This class contains a boolean variable which is called "Slowed". My script should return a different number depending on Slowed's value.

To do this, I have to push a lot of functions in Lua, for example getSlowed(), and this functions also depend on the kind of instance.

So, I'd like to write a "LuaManager" class which can push the functions in Lua's context... the problem is that I don't know where to start.
Anyone has any ideas, or a guide to suggest which I can read?

Thanks.