texts: Is it possible to use absolute input device like a pointer or VR headset for peeking(looking) in non VR FPS or 3rd person games?

texts:
Assume I have a VR headset, which has absolute orientation as output and this orientation is input to a game.
In VR Games, your character looks wherever you look by using your headset's absolute orientation(right?) Everything is OK for VR games
Coming to the point for non VR games;
Normally, when you tilt a joystick to a direction and hold it at that position, your character always turns relative to the direction until you released your finger. For example if you tilt the joystick to rightest and hold it at there, your character starts rotationg around itself to the right until you release joystick.
Can I do the VR rotating thing with a standart game controller joystick? Do games (or game engines) allow this type of control? I mean when I tilt my stick to rightest position, my character peeks to rightest, but when I release the stick, character peeks to default(front).  If it is possible, could you give name of games that suppport this control type? What is the technical name for this control type and maybe some resources or keywords for my research?


texts: How to write an adjacency algorithm that compares position data?

texts:
I have a list of indexed triangles for which I need to generate adjacency data. I've already written a brute force algorithm that creates 3 edge data structures for each triangle and then compares the edge structures with those of other triangles like so:

public struct AdjEdge
        {
            public Vector3 _ref0;
            public Vector3 _ref1;
            public int _edge;
            public int _face;
            public bool _parsed;

            public AdjEdge(Vector3 ref0, Vector3 ref1, int edge, int face)
            {
                _ref0 = ref0;
                _ref1 = ref1;
                _edge = edge;
                _face = face;
                _parsed = false;
            }
        }

private static int[] GenerateAdjacency(Vector3[] positions,
            List<int> positionIndices)
        {
            int ncFaces = positionIndices.Count / 3;
            int ncVertices = positions.Length;

            // inst. adjacency array and set all values to -1
            int[] adjacency = Enumerable.Repeat(-1, 3 * ncFaces).ToArray();
            if (adjacency == null)
                throw new OutOfMemoryException("Failed to allocate memory for adjacency data");

            List<AdjEdge> edges = new List<AdjEdge>();

            for (int i = 0; i < positionIndices.Count; i+=3)
            {
                int iFace = i / 3;
                edges.Add(new AdjEdge(positions[positionIndices[i + 0]], positions[positionIndices[i + 1]], 0, iFace));
                edges.Add(new AdjEdge(positions[positionIndices[i + 1]], positions[positionIndices[i + 2]], 1, iFace));
                edges.Add(new AdjEdge(positions[positionIndices[i + 2]], positions[positionIndices[i + 0]], 2, iFace));
            }

            for (int i = 0; i < edges.Count - 1; ++i)
            {
                AdjEdge edgeA = edges[i];
                if (edgeA._parsed)
                    continue;

                for (int j = 3 - (i % 3) + i; j < edges.Count; ++j)
                {
                    AdjEdge edgeB = edges[j];
                    if (edgeB._parsed)
                        continue;
                    // CompareVectors() returns true if the vectors are separated by a distance less than 1e-6f
                    if (CompareVectors(edgeA._ref0, edgeB._ref1)
                        && CompareVectors(edgeA._ref1, edgeB._ref0))
                    {
                        adjacency[3 * edgeA._face + edgeA._edge] = edgeB._face;
                        adjacency[3 * edgeB._face + edgeB._edge] = edgeA._face;
                        edgeA._parsed = true;
                        edgeB._parsed = true;
                        break;
                    }
                }
            }

            return adjacency;
        }

Needless to say, time complexity is an issue here. What is the most efficient method for generating adjacency when comparing position data using an epsilon?


texts: How to update off screen bitmap in a surfaceview thread

texts:
I have a Surfaceview thread and an off canvas texture bitmap that is being generated (changed), first row (line), every frame and then copied one position (line) down on regular surfaceview bitmap to make a scrolling effect, and I then continue to draw other things on top of that. Well that is what I really want, however I can't get it to work even though I am creating a separate canvas for off screen bitmap. It is just not scrolling at all.

I other words I have a memory bitmap, same size as Surfaceview canvas, which I need to scroll (shift) down one line every frame, and then replace top line with new random texture, and then draw that on regular Surfaceview canvas.

Here is what I thought would work;

My surfaceChanged where I specify bitmap and canvasses and start thread:

@Override
    public void surfaceCreated(SurfaceHolder holder) {
    intSurfaceWidth = mSurfaceView.getWidth();
    intSurfaceHeight = mSurfaceView.getHeight();

    memBitmap = Bitmap.createBitmap(intSurfaceWidth, intSurfaceHeight,
            Bitmap.Config.ARGB_8888);
    memCanvas = new Canvas(memCanvas);

    myThread = new MyThread(holder, this);
    myThread.setRunning(true);
    blnPause = false;
    myThread.start();
}

My thread, only showing essential middle running part:

@Override
public void run() {
  while (running) {
    c = null;
try {
    // Lock canvas for drawing
    c = myHolder.lockCanvas(null);

    synchronized (mSurfaceHolder) {
        // First draw off screen bitmap to off screen canvas one line down
        memCanvas.drawBitmap(memBitmap, 0, 1, null);

        // Create random one line(row) texture bitmap
        memTexture = Bitmap.createBitmap(imgTexture, 0, rnd.nextInt(intTextureImageHeight), intSurfaceWidth, 1);

        // Now add this texture bitmap to top of off screen canvas and hopefully bitmap
        memCanvas.drawBitmap(textureBitmap,
                    intSurfaceWidth, 0, null);

        // Draw above updated off screen bitmap to regular canvas, at least I thought it would update (save changes) shifting down and add the texture line to off screen bitmap the off screen canvas was pointing to.
        c.drawBitmap(memBitmap, 0, 0, null);

        // Other drawing to canvas comes here

    } finally {
        // do this in a finally so that if an exception is thrown
        // during the above, we don't leave the Surface in an
        // inconsistent state
        if (c != null) {
            myHolder.unlockCanvasAndPost(c);
        }
    }
}
}

For my game Tunnel Run.
Right now I have a working solution where I instead have an array of bitmaps, size of surface height, that I populate with my random texture and then shift down in a loop for each frame. I get 50 frames per second, but I think I can do better by instead scrolling bitmap.


texts:
I'm trying to create the most basic application that will draw a cube using indices and textures for starters, but nothing about it makes any sense whatsoever.

I ran it on my machine with an nVidia card and the display driver (latest, not that it matters) crashes (null ref), along with the program on the glDrawElements(...) command (Renderer.cpp). Fine. Then I sent it to a friend of mine who has an AMD card to try to debug it because I was unable to find the bug in the code, and the program worked (didn't crash) on his machine.

That surprised me since I only did the most basic openGL stuff, no way it was vendor specific. To get to the bottom of this, I downloaded APItrace (http://apitrace.github.io/) to try to see what's going on under the hood of my machine and why does my driver crash.

Once I dumped the trace after I ran the program, it said that the shader program linker failed because I didn't write to gl_Position (which I have).

The problem is that the program links just fine in VS debugger and no error is returned there. So it just keeps getting weirder.

If you want to mess with this, you can get the code (commit with issue linked) at https://github.com/Karlovsky120/7DaysWorldEditor/commit/e86b8be40c81511c4416dc5e253b90e42a5a8ec0

I don't think you'd see the bug if I just pasted the code here, there must be a mistake with the setup somewhere.

I really made an effort to make this as hassle free as possible, it's just one click install: clone it, build it, and you're good to go, no additional setup required. You will need to open it with VS2017 though.

There's a lot of classes in the code, but all of the relevant code is in Scene.cpp and any of the classes it references.

Thank you for any help you give, even if it's just a guess at what might be wrong because I'm at my wits end here.


texts: How can determine the number of instances of an object in Game Maker?

texts:
I am making a small puzzle based game.  I want the number of instances of an object to be equal to the ammo count plus 2.

Each time a new room is loaded, the main object's creation method with run this script:

var ammo = instance_count(jellyfish)+2;

Then each time a bullet is fired, I subtract one. When there is no ammo left, the player goes to the 'failure' room.

However, I get the error: Unknown function or script: instance_count.

I have see this script on Google, but am not sure if it has deprecated or not. Is there a way I can do this?


texts: Does pixels per unit property affect performance of the game in Unity?

texts:
The Sprite import inspector has a Pixels Per Unit setting that controls the size of the sprite objects when they're added to the scene:

Will Unity resize the sprite at run time or will it be resized after me changing the property and saved for the future?


texts: Examples of wall avoidance algorithm dealing with rectangles instead of lines?

texts:
I have a tile based engine and in the middle of translating out the example wall avoidance alogrithm in the book AI programming by example.  I was wondering if the method below can be modified so that it takes a rectangle instead of vector C and D and still produce the same output ?

/-------------------- LineIntersection2D-------------------------
//
//  Given 2 lines in 2D space AB, CD this returns true if an
//  intersection occurs and sets dist to the distance the intersection
//  occurs along AB. Also sets the 2d vector point to the point of
//  intersection
//-----------------------------------------------------------------
inline bool LineIntersection2D(Vector2D   A,
                               Vector2D   B,
                               Vector2D   C,
                               Vector2D   D,
                               double&     dist,
                               Vector2D&  point)
{

  double rTop = (A.y-C.y)*(D.x-C.x)-(A.x-C.x)*(D.y-C.y);
    double rBot = (B.x-A.x)*(D.y-C.y)-(B.y-A.y)*(D.x-C.x);

    double sTop = (A.y-C.y)*(B.x-A.x)-(A.x-C.x)*(B.y-A.y);
    double sBot = (B.x-A.x)*(D.y-C.y)-(B.y-A.y)*(D.x-C.x);

    if ( (rBot == 0) || (sBot == 0))
    {
        //lines are parallel
        return false;
    }

    double r = rTop/rBot;
    double s = sTop/sBot;

    if( (r > 0) && (r < 1) && (s > 0) && (s < 1) )
  {
    dist = Vec2DDistance(A,B) * r;

    point = A + r * (B - A);

    return true;
  }

    else
  {
        dist = 0;

    return false;
  }
}


texts: Start an animation exported from 3ds Max in UDK

texts:
I made a shape in 3ds Max with one bone and I gave it an animation. I exported it and imported to UDK. When I shoot to that shape, I want my animation to start playing.

How can I do this?


texts: Unity JS to C# conversion - Incomplete list of public variables in Inspector

texts:
I'm trying to convert a javascript file to a C# script for Unity, mostly because the rest of my workflow is in C#, and I'm much more comfortable with C#.  In this case, it's an audio controller script.

The .js looks like this:

var audioClips              : AudioClips[];                     // Array of single use audio clips
var audioLoops              : AudioClips[];                     // Array of loops

class AudioClips{
    var name            : String;
    var audioClips      : AudioClip[];
    var volume          : float             = 1.0;
    var volumeBySpeed   : boolean           = false;
    var minVolume       : float             = 0.2;
    var pitchBySpeed    : boolean           = false;
    var minPitch        : float             = 1.0;
    var maxPitch        : float             = 1.0;
}

and the editor looks like this:

My C# script looks like this:

public class AudioClips : MonoBehaviour
{
    public string       _name;
    public AudioClip[]  audioClips;
    public float        volume          = 1.0f;
    public bool         volumeBySpeed   = false;
    public float        minVolume       = 0.2f;
    public bool         pitchBySpeed    = false;
    public float        minPitch        = 1.0f;
    public float        maxPitch        = 1.0f;
}

public class AudioController_SFB_C : MonoBehaviour {

    public AudioClips[] audioClipsArray;                        // Array of single use audio clips
    public AudioClips[] audioLoopsArray;                        // Array of loops

and the editor looks like this:

The C# code doesn't reflect all of the public variables.  Interestingly, even if I comment out the public AudioClip[] section and the code that relies on it, my inspector looks the same.  I'm thinking maybe there a scoping issue or a strong-typing issue that I'm missing, but I can't seem to see it.


texts: What fluid simulation system is used in iPhone games?

texts: Does anybody know what kind of system developers are using for fluid simulation in iPhone games? It doesn't seem like they're using a Navier-Strokes simulation to me.


texts: Handling User Input with Simple Hit Test

texts:
Currently in my project, the way I handle user input events is through the OS Framework, then create a generic object - basically combines all types of input: keyboard, mouse, touch, trackball, etc. all together - this object gets queued and then on update gets processed. The queuing of objects is done on the UI thread - created by the OS - and the processing of the queue on another thread - one that I have generated. I handle the threads by using turn-based concurrency.

My problem is I worry about lag of the input events when there are fast moving objects, and I am curious to see if there are better ways of handling the input events then currently?

My current idea, of handling the simple hit test of fast moving objects with user input, is that I try and use the timestamp generated by the event to work out where everything was at that time, but it seem like a lot of work - probably because the way I have implemented everything on the update side - so is there a better way?

I did think about adding a bulk of data on the generic object creation, but there might be a lag between the creation and the actual event - on Java, I have to go through JNI and the generic object is always created on the native side. So I feel that the timestamp is my best solution. If anyone has any better ideas, it would be great to hear them.


texts: What is the most efficient way to render water?

texts:
Would I create the water surface mesh in C++, and control the movement/animation in the CPU, and afterward apply any shaders (reflect/refraction/caustics/etc..).
Or should I only create the mesh in C++ and afterward control movement in the vertex shader?

It seems with the second approach, it would be more difficult to simulate more complex water models.

What is the most common approach in modern video games?


texts: Identify whether object is off screen or not

texts: I have placed three game object in the scene.How to know whether the object is visible on the screen.Print a message if the object is not visible on the screen.


texts: What do I need to learn so I can make games on XBox Kinect?

texts:
I am interested to learn more about game development especially on XBox Kinect. What do I need to learn and what books I should read so I can make games on XBox Kinect?

Thanks


texts: iPhone GLSL shader dynamic branching issue

texts:
I am trying to pass an array of vec3 as uniform and then iterate through them on each pixel. The size of array varies on situations so I can't make the loop with constant number of iterations.

Here is the code:

precision highp float;
precision highp int;

varying vec4 v_fragmentColor;

varying vec4 v_pos;

uniform int u_numberOfParticles;

const int numberOfAccumsToCapture = 3;
const float threshold = 0.15;
const float gooCoeff = 1.19;

uniform mat4 u_MVPMatrix;
uniform vec3 u_waterVertices[100];

void main()
{
    vec4 finalColor = vec4(0.0, 0.0, 0.0, 0.0);

    vec2 currPos = v_pos.xy;

    float accum = 0.0;
    vec3 normal = vec3(0, 0, 0);

    for ( int i = 0; i < u_numberOfParticles; ++i )
    {
        vec2 dir2 = u_waterVertices[i].xy - currPos.xy;
        vec3 dir3 = vec3(dir2, 0.1);
        float q = dot(dir2, dir2);

        accum += u_waterVertices[i].z / q;
    }

    float normalizeToEdge = 1.0 - (accum - threshold) / 2.0;

    if (normalizeToEdge < 0.4)
        finalColor = vec4( 0.1, normalizeToEdge + 0.5, 0.9-normalizeToEdge*0.4, 1.0);

    if ( normalizeToEdge < 0.2 )
    {
        finalColor = vec4( 120.0/255.0, 245.0/255.0, 245.0/255.0, 1.0);
        float shade = mix( 0.7, 1.0, normal.x);
        finalColor *= shade;
    }

    gl_FragColor = vec4(finalColor);
}

The problem is here:

for ( int i = 0; i < u_numberOfParticles; ++i )
{
    vec2 dir2 = u_waterVertices[i].xy - currPos.xy;
    vec3 dir3 = vec3(dir2, 0.1);
    float q = dot(dir2, dir2);

    accum += u_waterVertices[i].z / q;
}

When I make the for-loop like this

for ( int i = 0; i < 2; ++i )
{
    //...
}

I get double the framerate even though u_numberOfParticles is also 2

Making it like this

for ( int i = 0; i < 100; ++i )
{
    if (i == u_numberOfParticles)
        break;
    //...
}

gives no improvement.

The only way I know to cope with this situation is to create multiple shaders. But The size of array may vary from 1 to 40 and making 40 different shaders just because of the for-loop is stupid. Any help or ideas how to deal with this situation ?


texts: My game is mostly complete, how do I find a publisher?

texts:
I've been working for quite a while on a game.

I'm mostly done with it.

Simply finishing the project, adding banners and just publishing it on google play / appstore probably won't bring in any money, at least without firstly investing some in promotion...

How do I go about finding companies that might be interested in either promoting or maybe even fully buying out such a product?


texts:
First: I am using C# and C++ on windows 7.

I have created a basic rendering engine in c++ with directx 10. It works good as a stand alone application. But, when I sending the Form.Handle of a WinForm I want to render inside to the engine it crashes during D3D10CreateDeviceAndSwapChain with the following error:

HRESULT: 0x887a0001 (2289696769)
Name: DXGI_ERROR_INVALID_CALL

I get the handle from the winform during loading of the form.

unsafe {
  void *ptr=m_view.Handle.ToPointer();
  uint v = (uint)ptr;
  lhandle = v.ToString();
};


texts: Is it okay to copy a game's formula? (damage, etc)

texts:
Is it okay to copy a game's formula? Formulas like damage formulas, taking the stats STR, DEX, INT, critical rate, etc. into account. Specifically I want to copy Ragnarok Online's damage calculation. But I will probably remove some stuff from the formula to reduce the scope of my game.

  Your question has been identified as a possible duplicate of another question.

I think game formulas and the like are different from game mechanics. Game mechanics is how the game is played.


texts: How do I tell the difference between tapping and holding the touchscreen?

texts:
I have a problem with the Unity game engine. I am making an Android game. I want to move an object by a small distance every time the user taps the screen, but not when the user holds the screen.

This is my current code. When the user holds the screen, the object keeps moving. I want to only move the object once the user touches the screen and not move it again until they released it:

void Update () {
        if (Input.touchCount > 0) {
            transform.position = new Vector2(transform.position.x, transform.position.y+0.1f);
        }


texts:
I am implementing a skeleton system for my latest game. I am using my own linear algebra classes which already have some optimisations, such as separate transformPoint and transformVector functions which avoid some multiplications by 0 or 1. It is working well so my question is not HOW to implement skeletal animation.

My question is how to optimise the matrix multiplications. At the moment there are several full 4x4 multiplications and 1 inverse per bone. I need the inverse because this is not just for skinning but also physics and stuff. But there are many 0s and 1s in the homogeneous matrices which can be optimised out. Also, I want to be able to specify the degrees of freedom for each joint, and in which order they are calculated, so for example, a shoulder joint could rotate yaw then pitch, or pitch then yaw. The result would be different. Should I have a separate matrix constructor for each permutation, which I believe is 15?

I assume this is a common issue with skeletal systems, so is there a standard method for this? How do engines normally optimise forward kinematic calculations?

I calculate all the matrices for the bones, starting at the root and working outwards. Note: my bones are in an array that is sorted by heirarchy depth so a bone's parent's matrices will already have been computed.

Please note: this is not a questions about skinning, I have no problem with that.


texts:
Summary:
I want vertical lines to be drawn as vertical lines regardless of their position relative to the camera (distance/offset). I want the projection to be perspective so the furthest objects from camera look smaller while keeping their respective proportions.
What am I trying to achieve: A two (vanishing) point perspective like this one http://insidetheoutline.com/wp-content/uploads/2019/07/2_Point_Perspective_Cityscape.jpg
Why am I at it: I'm really bad at 3D (obviously) therefore I'm trying to replace character models with 2D sprites like in Populous 3, or "The Game" quest in Fable 3. I also want to have a top-downish view like in isometric games. Alas, perspective distortion totally kills the effect, making sprites look skewed whenever they are off-center.
What am I doing right now:
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity;
  gluPerspective(FOV, wndWidth / wndHeight, zNear, zFar);
  // Googling lead me to this MV matrix, alas it's not working for me
  // {
  //  1, 0, 0, 0,
  //  0, 1, 0, 0,
  //  0, -camY/camZ, -camZ, 0,
  //  0, 0, 0, 1
  // }
  glMatrixMode(GL_MODELVIEW);
  glLoadMatrixf(@cam);
  // camX = camY = camZ = 50
  gluLookAt(
    camX, camY, camZ,
    0, 0, 0,
    0, 0, 1
  );
  // then I draw a uniform grid -5..5 by -5..5
  // and slightly off-center wireframe box to test if they are drawn correctly

Does it work? No, it doesn't. Provided matrix produce no result at all, so I had to change it to { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -camY/camZ, -camZ, 1}. Just like any text on a two-point perspective says: "Set one of the values in the last column to zero". I tried zero in any position, except the last one, to no avail. Generally, I get something like this:

The rightmost vertical line--the one that aligns with screen center--is vertical, just as I want all of them to be, but the others are skewed away.
What else I managed to google: Not much, really. I found an example that kinda looks like something I want to achieve, but they place the camera at ground level with zero Z delta, effectively eliminating the third vanishing point. In some other example, they just narrowed FOV to some absurdly low value, making it look like a two-point perspective to some extent.
I'm afraid I'm missing or misunderstanding something. I also not sure if the desired output will, in fact, look like I want, and I won't discard it if it's not.


texts: Unity: Set LightProbes to "Off" on Static objects

texts:
Since I use Light Probes for Indoor Scenes only I only need them to work on Dynamic Objects. Objects in Indoor Scenes are all Lightmap Static and baked, objects in outdoor scenes rely on real time lighting.

Most objects are not within range but sometimes the Lightprobes from inside interfere with Static objects outside and add light to them that should not be. It's really time consuming to disable LightProbes in every individual Mesh Renderer

I sort all Prefabs & Game Objects by Static, LightmapStatic and Dynamic. Turning Lightmapping on and off can be easily done in the hiearchy but turning off LightProbes needs to be done in every individual Mesh Renderer. Is that so, or am I overlooking something? If not this is really something that should get fixed.

My Version is 2017.3.1f1


texts: How can I come up with a simple diminishing return equation?

texts: There are formulas out there for a diminishing return equation; however, those usually involve exponential. What other ways are there for coming up with such an equation? Take, for example, the following test case -- One farm produces 10 food, for every 10 farms produced, the production rate drops by 5%.


texts: What are the correct angles in the Top-down perspective?

texts:
In the following picture it says that in the Top-down perspective the angles are 90°, but if it would be 90° then you shouldn't see the front of the building and the roof at the same time...

So what are the correct angles to get such an perspective?


texts:
Just a bit curious - where do you perform mesh manipulations, on the CPU or in the shader?
I've been doing everything on the CPU and a friend suggested moving things on to the GPU side.

If you're doing things like bone animations... on the GPU, how do you get back the mesh? (since I'm doing collision detection...)


texts: How do I make a message based communication system between objects?

texts:
Just as I was told here, I need to make some kind of communication between objects in my game. Mainly, for achievements. How do I do this? My idea was to make every object have an array attached to itself called "messages", and then, when something happens, a message gets pushed there. At the end, I would have a big loop, where I would check messages that each object got, remove them, and act accordingly. I could also have a global array called "messages", and then I would iterate through it, and fire off events in different objects that the messages were sent to (in this case, a message would contain both a message, and some kind of an object ID), and then remove them. Is there a better way? Keep in mind that I'm working in Javascript.

I forgot to mention, we're talking about serverside Javascript running on Node.js, not in a browser.


texts: How to create custom inspector to display generic Stack class

texts:
I have a member that I would like to expose:

[Serializable]
private sealed class InputGameObjectStack: Stack<GameObject> {
    public InputGameObjectStack(): base(_InputGameObjectStackSize) {
    }
}

Inside the MonoBehaviour, I have:

[SerializeField]
private InputGameObjectStack _inputGameObjectStack;

Inside the editor script, I'm able to fetch the property from the MonoBehaviour object (as SerializedProperty), but there is nothing usable that allows me to traverse through the elements.

Is there any way of showing the constents of the stack in the inspector as immutable (no functionality to push/pop)?


texts: How to draw a plane equivalent to a given btStaticPlaneShape using OpenGL

texts: With all other shapes in bullet, you can easily get the transform from the MotionState which holds the origin, the scale, and the rotation. There seems to be no way to get the same information about a btStaticPlaneShape. How can I get this information, so that I can build a rectangle with 4 vertices that will act as a representation in OpenGL?


texts: How to texture procedurally generated custom terrain mesh

texts:
I am making an infinite procedural terrain for my game and currently trying to apply textures to it.
The generated terrain has different biomes, so I want to texturize the terrain based on biome and have different textures applied based on the steepness and height of the terrain. I also have different areas generated, such as settlements and also roads so I want to apply specific textures to specific places like those as well.
Unity terrain only supports I think 8 layers, but generally, it should be around 4 for 4 channels? In my case I generate a custom mesh, so I don't really need to worry about this, however, I am trying to figure out how to generate some sort of texture map (splatmap), and have lots of textures in it. I want to use (albedo, normal, height) for each 'layer'. Considering that the biomes are generated based on the noise map and each chunk can have many different biomes in it, I need to have more than 4 layers available. For example, steep areas like cliffs will need to have a rocky texture applied and each biome will have a different rocky texture. So if a chunk has two biomes in it, there are lots of different textures that need to be used, including various misc textures for paths and settlement grounds, etc.
Something like this, where a single chunk mesh has for example two biomes. Also, the terrain has a settlement that has a dirt texture applied to the terrain, which extends to both biomes. So essentially, lots of textures in just one mesh.

The other chunk(s) can have similar biomes or even completely other types of biomes. Also, would like to perhaps add the ability to apply different textures to a specific position on terrain chunk at runtime, for example, if the player would want to create a path or if a specific object is placed that would spread some specific texture around the object on the terrain. Something like this for example, where a placed tree has spread some leaf ground texture around:

So, I am looking for a flexible way in applying various different textures to generated terrain mesh. I would like to do that in the script when I am generating a chunk, so I would know which biomes is it at the position and as well as things like steepness and etc.
I am using Shader Graph to create the terrain shader. I'm not really experienced with shaders, so would like to ask for some help on what would be the correct way to achieve something like this?


texts: Correct architecture for weapon class in RPG

texts:
So, I'm a little stuck on what the best way to implement weapons is. The problem I'm running into is, what exactly is a weapon.

I have a Player Class that has an attack method.

public class Character
{
    public int MaxDamage;

    public bool IsAlive = true;

    public Character Attack(Character target)
    {
        Random attackRange = new Random();
        int damageValue = attackRange.Next(0, MaxDamage);

        target.TakeDamage(damageValue);

        Random critCheck = new Random();
        int critCheckValue = critCheck.Next(0, 100);
        //hitChance = dex - target.dex;

         if (critCheckValue <= CritChance)
         {
          //dmg min = dmg min + (dmg min*crit damage);
          MaxDamage = MaxDamage + (MaxDamage * CritDamage);
         }
     }
}

So this works. But once I implement a weapon, it gets a little confusing.

Does the player still have the attack method and the weapon just modifies the values?
Does the weapon really have the attack method and the player just calls it?
How would you handle something like a power swing that may hit 3 characters?
Does the weapon contain the range or the player?


texts:
I'm developing 2.5D space shooter (3D objects, 2D gameplay). I'm searching for a way to pick targets for homing missiles.

There are two types of missiles: active-radar-guided and heatseekers. The first ones are relatively simple to implement: I search for a target once and then store it in the missile's navigation code. If object is destroyed or escapes missile's triangle of view, I seek for another target. Searching for target is costly, because I have to iterate through all game objects and eliminate ones behind the rocket or out of its "radar range". However, that happens rarely - only after launch and when missile loses the target from sight, so I guess it will be acceptable.

Now imagine heatseeker missile. Situation is different here - I have to make decision about flight direction on every frame - gather information about nearby heat sources, create some kind of heatmap, find hottest direction and navigate rocket towards it. This may degrade performance - especially if I have multiple missiles on scene and this is very likely scenario.

I thought of using collider as first-degree sieve to keep track of potential targets. This collider would have to be quite big but it would narrow down count of potential targets to 10-20 and I guess that should be acceptable for processing. However, I'm falling into problem of multiple colliders: I use one for regular collisions and I wouldn't want the other one to interfere. Also, I'm not sure what is the performance penalty for having a couple of big colliders on scene.

How can I solve the problem of picking target for missile every frame such that it won't have big impact on overall performance? Are the colliders correct path to follow? Or should I rely more on coding than on built-in features?


texts: Dynamic length increment of of an object-LibGdx

texts:
I want to implement something in my LibGdx game, where a small stick is positioned vertically.On tap,I have to increase the length of the stick with tap frequency.Later I want to rotate,perform collision and do all those things that a sprite can do.It is an advanced form of fly Swatter game.
I am wondering how can I do it.I found some ways.But I am not sure it will work nicely.

1.Creating an array of small sticks and adding it to the base stick to increase the length.(Rotating array of object at a time is difficult,I know.)

2.Scale the image to increase the size of the stick.

Important thing is that this stick and rotation is an super important event in my game.

I only have experience of a simple running in LibGdx.
It would be very helpful if experienced persons give some ideas to implement this game in LibGdx.


texts:
Bots in games can bad and usefull depending on the genre.

A lot of small games use bots to create a fake player base and illude the player that he is playing with real people.

The scariest thing is, that in most of these games you can't actually tell if you are playing with/against real people or bots and sometimes in shooter games bots can be way better than real people, not because they have more HP or more damage, they are not rpgs but shooter games.

And in chatting simulator games, where you actually speak to bots... Some are trashy but a few can get creative , these bots get to the point where they feel like real people... Or at least it means in my life I have encountered people that act like robots.

But there's only one genre of games where bots are not only useful but might be essential.

Rpg's

Why? Immersion.
What's the point of playing a game with an epic giant world twice the size of the real earth if the player base is a few millions (at best) ? You are gonna feel extremely lonely when exploring or you are not in a raid/battleground/dungeon.

most mmos I've explored tend to have really beautiful empy and soulless landscapes and cities... Entire cities with maybe only 30 npcs inside...

And npcs don't do anything, they are different from bots.

Bots try to replicate human behavior, they can talk with you help or try to kill you.

In some games as I have already said bots are created to make the illusion of multi-player but in mmorpgs you already know there are npcs and not every character you encounter is a person but limiting npcs to being statues that stand still in a city to sell you endless items is a waste of pure potential.

So why don't mmos use bots when lesser games can do it perfectly and make their bots seem real? What's the drawback?


texts: How can I make space recognizable and easy to orient in?

texts:
I'm thinking about making a game set in space, that would feature very large, procedurally-generated game world (many stars, planets and what have you). However, I foresee a big problem: cosmic space is mostly featureless. It's almost the same everywhere - the same black emptiness with stars. This is obviously bad. A large game world must be different in different places, so that the player can understand where she is, and how to get where she needs. What can I do to make different, recognizable places in space?

The game I'm envisioning is 2D (a bit like Space Rangers), with space pictures used only in background. However, I'm interested in any techniques, 2D or 3D.

Clarification
What I need here is not just ability to orient in game space, but rather having different places so that the game feels more interesting. Here's an example: imagine any space-trading game (like Elite or X or whatever). You visit different star systems, but they're all generally alike: a dock to repair/refuel, a shop to trade, a bar to take missions/contracts... Some Tau Ceti III differs from KZ'ish VI mostly by name.

I believe that every place, or at least most places that player visits should be different from each other, and immediately recognizable, so that player has a sense of wonder and discovery as she explores the universe.  Of course, making every star system a full-fledged 3D level with its own visual style would work, but that's prohibitively expensive even for a big-budget game. Are there any other ways to achieve this wonder and discovery?


texts: Unity Editor Scene View does not match built executable

texts:
I'm trying to make my game resolution independent. I'm using Unity's 4.6 UI, and I've got custom resolutions defined at 1280 x 720, 1600 x 900, and 1920 x 1080. In-editor, if I swap between any of these resolutions, the observed scene doesn't change. It looks like this:

I then build an executable (set to only allow 16x9 resolutions), and run this scene. On 1280 x 720 (as selected from the resolution dialog), I get this:

While on 1920 x 1080 (as selected from the resolution dialog), I get this:

Which matches the editor view. (Ignore the character sprites; those are in worldspace on a separate camera and aren't relevant to this question).

What is it about the executable that causes lower resolutions to be "zoomed in" like this, even if that lower resolution is the Reference Resolution for the Canvas Scaler?


texts: How long does one have to pay the $125 per month subscription fee for Unity pro?

texts:
I'm a bit confused by how the subscription for Unity Pro works. If I were to get Unity Pro, do I have to keep paying $125 per month for as long as I'm using Unity pro? Or do I have to keep paying $125 per month until certain period, after which I am no longer required to pay anything?

Furthermore, if I developed a game with the personal version of Unity and the game made over $100K, would that result in an immediate penalty or will Unity give me a deadline before which I must get Unity Plus/Pro?


texts:
I am having a slight problem with my Bump Mapping project. Although everything works OK (at least from what I know) there is a slight mistake somewhere and I get incorrect shading on the brick wall when the light goes to the one side or the other as seen in the picture below:

The light is on the right side so the shading on the wall should be the other way. I have provided the shaders to help find the issue (I do not have much experience with shaders).

Shaders:

varying vec3 viewVec;
varying vec3 position;
varying vec3 lightvec;
attribute vec3 tangent;
attribute vec3 binormal;
uniform vec3 lightpos;
uniform mat4 cameraMat;

void main()
{

    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_Position = ftransform();

    position = vec3(gl_ModelViewMatrix * gl_Vertex);
    lightvec = vec3(cameraMat * vec4(lightpos,1.0)) - position ;

    vec3 eyeVec = vec3(gl_ModelViewMatrix * gl_Vertex);
    viewVec = normalize(-eyeVec);

}

uniform sampler2D colormap;
uniform sampler2D normalmap;

varying vec3 viewVec;
varying vec3 position;
varying vec3 lightvec;

vec3 vv;

uniform float diffuset;
uniform float specularterm;
uniform float ambientterm;

void main() {

    vv=viewVec;

    vec3 normals = normalize(texture2D(normalmap,gl_TexCoord[0].st).rgb * 2.0 - 1.0);

    normals.y = -normals.y;

    //normals = (normals * gl_NormalMatrix).xyz ;

    vec3  distance = lightvec;
    float dist_number =length(distance);
    float final_dist_number = 2.0/pow(dist_number,diffuset);
    vec3  light_dir=normalize(lightvec);
    vec3  Halfvector = normalize(light_dir+vv);
    float angle=max(dot(Halfvector,normals),0.0);
          angle= pow(angle,specularterm);
    vec3 specular=vec3(angle,angle,angle);
    float diffuseterm=max(dot(light_dir,normals),0.0);
    vec3 diffuse = diffuseterm * texture2D(colormap,gl_TexCoord[0].st).rgb;
    vec3 ambient = ambientterm *texture2D(colormap,gl_TexCoord[0].st).rgb;
    vec3 diffusefinal = diffuse * final_dist_number;
    vec3 finalcolor=diffusefinal+specular+ambient;

    gl_FragColor = vec4(finalcolor, 1.0);

}


texts: I downloaded an animated spider that comes with its own animations. I put the idle and walk animations in the controller. The default idle works fine but it won't transition to walk. I have other characters in my scene that transition with no problem. The only difference is that the other characters animations are separate from the character and the spider's animations are attached to the spider. I have been looking for any tutorial on the attached animations but can't find anything. Any help would be appreciated.


texts: Game Architecture: Class leaking into almost all files

texts:
We currently have the problem that our main class GameController is being pulled into every backend file in our game. We're wondering what are common solutions to this problem.
Here's a bit more about the game architecture. The game is a board game, so since ~90-95% of the time there isn't anything happening, the game is set up more like a rest API. It waits for a user prompt, when received, the msg is distributed to the respective components of the game and the proper logic is executed. No large update loops, just executes logic when prompted.
The problem is that as this msg cascades through the system, GameController acts more like a relay point between the systems. It's how the nodes communicate to each other so that all game components are updated properly. The problem is that it's created this system where all new/old classes contain a pointer to parentGame, so GameController is everywhere.
Are there any simple architectural solutions to avoid having every class contain a pointer to parentGame? Is this necessarily a bad thing?
Some example code:
class GameController {
    bank: Bank
    action: Action
    ...
}
class Bank {
    parentGame: GameController

    constructor(game: GameController) {
        this.parentGame = game
    }
}
class Action {
    parentGame: GameController

    constructor(game: GameController) {
        this.parentGame = game
    }
}
```


texts: I'm making a mobile game, and I want have secondary camera that shows another part of the scene within a box. I'm able to do this easily enough by setting the camera's viewport settings, but the issue I'm having is when you change the screen size, the camera size changes with the screen no longer looking like it shows in the box (The box doesn't expand/contract with the device's screen size). Is there a way to set the camera's size an position relative to a game object? This is what I'm trying to do:


texts: Action Script 3.0 datatype to match C++ iterator? (Code convertion)

texts:
I am developing a game with Action Script 3.0 using Starling Framework, converting it from C++

C++ Code :

for (std::vector<MyObject*>::iterator i = m_listEnemy->begin();i!= m_listEnemy->end();)
{

    (*i)->update(dt);
    if ( (*i)->m_Hp <=0 )
    {
            (*i)->release();
            i = m_listEnemy->erase(i);
            continue;
    }
    i++;
}

MyObject is the class.

What Action Script 3.0 data type matches the C++ iterator?
Also , how can I convert this C++ code to Action Script 3.0 code?
Thanks in advance!


texts: Pre-render bump mapped/normal mapped textures?

texts:
I saw Direct3D supports rendering bump map textures. But why is this necessary? Can't I just pre-render the already "bumped" textures and use the exported file?

The resulting image is still simple 2D, so why not go this way and avoid rendering the bump map through the game itself?

It's not just about Direct3D, just an example.

I'm very confused and would be glad if you could explain that.


texts: How can I rumble/vibrate my controller with libGDX?

texts:
The com.badlogic.gdx.controllers.Controllers API only supports getting the input data (which works fine).

Is there a way to make my controller rumble/vibrate, possibly using some other classes?

I tried using the org.lwjgl.input.Controllers class, which supports this, but the controllers don't get indexed there and I can not access them.


texts: Good system for experimenting with shaders in different languages

texts:
I'm trying to experiment a bit with shaders and they have been programmed in several different languages (GLSL,  Cg and HLSL). Now most systems (dirrectX, openGL) have only support for one of them. Does anybody know of such a system that easily allows all 3?

Thank you


texts:
I have frequently tried to make some sort of a platformer, but when I actually code it, I run into a bit of a snag. How would I be able to make platforms in the air stop objects if they hit the sides or bottom, but allow them to sit on top of them?

I have tried many different methods, and some work slightly, but have many bugs, or some don't even work at all. Like this one I tried made it so that if you hit the side of the platform at the right angle, it forced you up on top of it.


texts:
I want to add fog in my scene which contain transparent textures made by Blend ,

when i enable the fog the transparent textures appear white From a distance but when i  disable it the textures appear well.

What is the solution to the problem of whiteness?

Fog Code:

GLfloat fogColor[4]= {0.5f, 0.5f, 0.5f, 1.0f};
glClearColor(0.5f,0.5f,0.5f,1.0f);
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogfv(GL_FOG_COLOR, fogColor);
glFogf(GL_FOG_DENSITY, 0.35f);
glHint(GL_FOG_HINT, GL_DONT_CARE);
glFogf(GL_FOG_START, 1.0f);
glFogf(GL_FOG_END, 1000.0f);
glEnable(GL_FOG);

Screenshot


texts: How to create customizable character mesh?

texts:
Imagine a character that can equip different game items like helmets, gloves, shoes, etc. Each different item have its own mesh, bone rig and animations.
What is the best way to create such a system using Unity3d?


texts: Can't consistently add to TimeSpan for Unity Game

texts:
I'm making a game that has a timer showing how long the player has survived from being crushed by pessimism. (Long story) I'm trying to use TimeSpan in Unity to accomplish this but it seems that I'm having trouble finding a way to add time consistently. My output is always 00:00:01. Here is the code I've been working on. Any help would be appreciated.

using UnityEngine;
using System.Collections;
using System;

public class TestScript : MonoBehaviour {

static float timer;
TimeSpan t = TimeSpan.FromSeconds(timer);
TimeSpan add = TimeSpan.FromSeconds(1);

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

    TimeSpan span3 = t.Add(add);

    Debug.Log(span3);
}
}

UPDATE

Thanks for your help Jason, here's the code I made in case anybody else wants to know how to do this. The only beef I have is that the milliseconds show 3 characters instead of two, but I'm personally very satisfied with it. Plus, I'm sure that it is something that could be easily fixed.

using System.Collections;
using System;

public class TestScript : MonoBehaviour {

static float timer;

// Update is called once per frame
void Update () {
    timer += Time.deltaTime;
    TimeSpan timeSpan = TimeSpan.FromSeconds(timer);
    string output = String.Format("{0}:{1}:{2}",timeSpan.Minutes,timeSpan.Seconds, timeSpan.Milliseconds);
    Debug.Log(output);
}
}


texts: Most efficient way to optimize based on gpu type?

texts: So, I'm writing an optimization button that should optimize a game based on the type of hardware the user has. I know I can use d3dadapter_identifier9 to achieve this, but what would be the most efficient way of actually implementing it? Not sure whether i should check based on deviceid, name, etc. was hoping someone could give me a couple tips for that. Thanks in advance.


texts: variable number of lights in a glsl shader?

texts:
I want to render an arbitrary number of lights in my fragment shader. I do not understand how you can properly pass them into the shader though. For example, I want something like this:

uniform int numberOfLights;

struct PerLight
{
    vec4 position;
    vec4 intensity;
}

uniform Lights
{
    vec4 ambientIntensity;
    float lightAttenuation;
    PerLight lights[numberOfLights];
} Lgt;

I've only seen documentation and examples use 'numberOfLights' as a constant and I cant get above to work so I am guessing you cant have a dynamicly sized struct in glsl.

So, how are you supposed to pass any given number of lights to the shader?


texts: Attributes and Behaviours in game object design

texts:
Recently I have read interesting slides about game object design written by Marcin Chady Theory and Practice of the Game Object Component Architecture. I have prototyped quick sample that utilize all Attributes\Behaviour idea with some sample data.

Now I have faced a little problem when I added a RenderingSystem to my prototype application. I have created an object with RenderBehaviour which listens for messages (OnMessage function) like MovedObject in order to mark them as invalid and in OnUpdate pass I am inserting a new renderable object to rederer queue. I have noticed that rendering updates should be the last thing made in single frame and this causes RenderBehaviour to depend on any other Behaviour that changes object position (i.ex. PhysicsSystem and PhysicsBehaviour).

I am not even sure if I am doing this the way it should be. Do you have any clues that might put me on the right track?


texts: Javascript - How and where to put game initialization data

texts:
I'm new to JS game programming. In the past, when coding games (in Java), I tend to make separate files for configuration and game data (maps, character stats, etc). This is for separation of code and data. How can I effectively implement this on JS?

EDIT: This is for browsers only.


texts:
In my current project I'm using the Emotiv Unity plugin found here.  I'm still very early on as I can not figure out what is going on when Unity asks for authorization to access Cortex.
When I run my game I can't even get past the first step because I get a message in the log that my credentials are invalid.  I have my Cortex client ID and secret in an app config script and I've even traced references to each and hardcoded my info attempting to find the issue.  I was having the same issue with the example found here.
I've spent a lot of time tracing references in the C# script and now I'm wondering if a Cortex update maybe broke the plugin or (far more likely) I'm missing something glaringly obvious.  I'd really appreciate some insight into this and/or a link to docs as I haven't been able to find any.  Thanks in advance!


texts: Unity - Logic for saving and loading objects with both static and dynamic data

texts:
I need help to get some structure for my save and load.

I am making a city builder, so I have Buildings thats need to be saved.

Each building has a lot of static Data, for example name, description, etc.

However it also has a lot of dynamic Data, for example worldPosition, id, etc.

My current structure looks like this:

On each Building GameObject I keep a reference to a ScriptableObject that stores all the static data.
I also store a reference to an Object that stores all the dynamic data.

This means I need 2 classes for storing Building data, which I already don't like (BuildingStaticData & BuildingDynamicData)

When I Save/Load my game I only need to store the Dynamic data, so for saving I just save the DynamicData.

For Loading I load the DynamicData, and instantiate a Building GameObject that is associated with it, then the GameObject has the reference to the StaticData.

While this works, I would prefer to have a structure where I only have a single class for BuildingData, but I also don't want to lose the power of a ScriptableObject where I can reference other Prefabs etc.

I need some help with this logic.


texts: How can I keep track of which "rooms" characters and NPCs are in?

texts:
I have a Unity 2D project which has a player character and numerous NPCs all potentially moving (top-down) at the same time during play. The number of NPCs is not to exceed 100 (and will be, probably, more like 40-50) but I'd still like to be performant.

The "rooms" are really just rectangles that correspond to sections of my tilemap. All the "rooms" are contiguous, and hence all characters will always be in exactly 1 "room". Like if you picture the floorplan of a house, you're in the "Hallway" or the "Living Room" or the "Front Porch" or the "Driveway", and so on.

My tilemap is not complete, so it would be nice to be able to easily move the rooms around in the Scene editor as I refine it.

I was thinking I could...

Create Rect objects (or maybe an AABE, although I just read very briefly about what this even is) for each room inside a "RoomsController" GameObject, and then on each Update() iterate through each and see who is within the bounds of each room. But that seems majorly wasteful, and pretty brute-force even if done every few frames.
Create a GameObject for each room with an appropriately-sized BoxCollider 2D, and look for collisions with NPCs, and have a script that handles changing the active room on the NPC when he "collides" with a new room. But this requires a RigidBody 2D for each room, and it feels like overkill.

Is there an existing "right way" to solve this problem?


texts:
Okay, this is may be very simple.
I embedded my XNA project in WinForms through "this tutorial" and it works fine even with XNA 4. Now I have a 3D CoilSpring object and the number of loops for this coil needs to be determined by the user. I'm using a txtBox for this. However when I run the project it only gets the default value of txtBox and I want to update it when the user changes its value.


texts: Is it worth it to use Bullet for 2D physics instead of Box2D for the sake of learning Bullet?

texts:
There isn't much more to the question. I'm not concerned about overhead, as I'm sure they are both fine for my purposes. Basically, I am familiar with Box2D concepts because of the Farseer Physics Engine, but I want to use Bullet when I make the jump to 3D stuff. Perhaps Bullet has some educational value for me even in the 2D realm?

The generalized version of the question is: should I use a 3D physics engine for a 2D game if I plan to utilize a 3D physics engine in the future? Or is this a waste of time which would not provide educational value?


texts: Unity animation - Cull completely vs Cull transform with hundreds of objects

texts:
I am making a game with a lot of animated AI, somewhere around 500 active AI at a time. This works great so far.
My one issue is how much performance animating uses up. My issue is with culling, take the scenario below:
I have 20 units off screen that chop wood, if I cull comletely I cannot use animation events because they will not get triggered while culled, so I use cull transforms. I always prefer using animation events instead of using some timer in the code that calls ChopWood() at a set interval, I find it produces a lot of messy code.
I tried comparing performance between cull completely and cull transform and didnt notice any huge difference when using 200 agents.
So I am wondering if anyone has experience with this scenario and can warn me of any pitfalls I might encounter using animation events for this many agents. Will it end up killing my performance? Is it unreliable? If so, how did you solve it?


texts: Per pixel normal mapping resulting in static on normals starting on Z axis

texts:
For the past week I've been trying to implement bump mapping in DirectX 11 using the Frank Luna's '3D Game Programming with DirectX 11' book. I got it working until I tried to add a flat 2D plane facing in the -Z axis and the texture appeared distorted. After a while I found out it was the bumped normals that were causing it.

I've used Terathon to calculate tangents after generating a mesh.

My code is as follows:

void AddTangentToVertexArray(const UINT vertexCount, const UINT indexCount, PackedVertex* vertices, const WORD* indices)
    {
        const UINT triangleCount = indexCount/ 3;

        XMVECTOR* tan1 = new XMVECTOR[indexCount* 2];
        XMVECTOR* tan2 = tan1 + indexCount;
        ZeroMemory(tan1, indexCount* sizeof(XMVECTOR) * 2);

        for (UINT a = 0; a < indexCount; a++)
        {
            WORD i1 = indices[(a * 3)];
            WORD i2 = indices[(a * 3)+1];
            WORD i3 = indices[(a * 3)+2];

            const XMFLOAT3& v1 = vertices[i1].vertex;
            const XMFLOAT3& v2 = vertices[i2].vertex;
            const XMFLOAT3& v3 = vertices[i3].vertex;

            const XMFLOAT2& w1 = vertices[i1].uv;
            const XMFLOAT2& w2 = vertices[i2].uv;
            const XMFLOAT2& w3 = vertices[i3].uv;

            FLOAT x1 = v2.x - v1.x;
            FLOAT x2 = v3.x - v1.x;
            FLOAT y1 = v2.y - v1.y;
            FLOAT y2 = v3.y - v1.y;
            FLOAT z1 = v2.z - v1.z;
            FLOAT z2 = v3.z - v1.z;

            FLOAT s1 = w2.x - w1.x;
            FLOAT s2 = w3.x - w1.x;
            FLOAT t1 = w2.y - w1.y;
            FLOAT t2 = w3.y - w1.y;

            FLOAT r = 1.0f / (s1 * t2 - s2 * t1);
            XMVECTOR sdir{ (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r,
                (t2 * z1 - t1 * z2) * r };
            XMVECTOR tdir{ (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) *r,
                (s1 * z2 - s2 * z1) * r };

            tan1[i1] += sdir;
            tan1[i2] += sdir;
            tan1[i3] += sdir;

            tan2[i1] += tdir;
            tan2[i2] += tdir;
            tan2[i3] += tdir;
        }

        for (UINT a = 0; a < vertexCount; a++)
        {
            const XMVECTOR& n = XMLoadFloat3(&vertices[a].normal);
            const XMVECTOR& t = tan1[a];

            XMStoreFloat4(&vertices[a].tangent, XMVector3Normalize((t - n * XMVector3Dot(n, t))));

            vertices[a].tangent.w = (XMVector3Less(XMVector3Dot(XMVector3Cross(n, t), tan2[a]), XMVECTOR{ 0.0f, 0.0f, 0.0f, 0.0f })) ? -1.0f : 1.0f;
        }

        delete[] tan1;
    }

And I used Frank Luna's implementation to use those tangents to calculate the bitangent but in the the newer version of directX 11

float3 NormalSampleToWorldSpace(float3 normalMapSample, float3 NormalW, float4 TangentW)
{
    float3 NormalT = 2.0f*normalMapSample - 1.0f;
    float3 N = normalize(NormalW);
    float3 T = normalize(TangentW - dot(TangentW, N)*N);
    float3 B = cross(N, T) *TangentW.w;

    float3x3 TBN = float3x3(T, B, N);

    float3 bumpedNormalW = mul(NormalT, TBN);

    return normalize(bumpedNormalW);
}

EDIT: After a couple hours of debugging I've found that changing the T calculation to float3 T = normalize(TangentW - dot(TangentW, N));// *N); seems to have stopped any distortions. If someone can confirm that this isn't going to cause later issues I'm willing to say it's solved.

All surfaces are using the same normal map in the following gifs.

A visual example of what happens to normals facing down and up the Z axis

Here is the same plane but rotated 90 degrees

A visual example of a sphere that isn't affected by the distortion due to what i can only assume is having no normals along the Z axis

My guess is that something is wrong within the tangent calculator as the error persists when the plane is rotated, but I cannot seem to find anything different to the version on Terathon.

If there's anything else that you need to tackle the problem just let me know and I can supply it.


texts: What are the pros and cons of GameSalad versus Cocos2D?

texts:
I am currently using the Cocos2D framework for creating my game but I just happened to come across GameSalad and was amazed by this video.

GameSalad claims to allow you to create games without writing a single line of code. So I ask myself, what is the catch? What makes Cocos2D better than GameSalad? What are the pros and cons of GameSalad?


texts: Unity Initializing class of a script not working

texts:
I have been trying to find a solution for the last couple of hours so please hear me out. At first I got a NullReferenceException, which I resolved(?) by initializing the class first (This is my problem! I can't seem to initialize my class sucessfully). However, here are my next errors. I tried using the new keyword, which resulted in You are trying to create a MonoBehaviour using the 'new' keyword. Next I tried GetComponent<>(), which resulted in a CS0120, that I didn't know how to fix. The AddComponent<>(), resulted in a CS0103 The name AddComponent does not exist in the current context. What I tried next was GameObject.AddComponent<>(), which threw a CS0120, and gameObject.Addcomponent<>() which threw a CS0236.

Here is my code for the class I am trying to initialize if it should be needed:

public class Dialogue : MonoBehaviour {
public TextMeshProUGUI textDisplay;
public string[] sentences;
private int index;
public float typingSpeed;

public GameObject continueButton;

void Update() {
    if (textDisplay.text == sentences[index]) {
        continueButton.SetActive(true);
    }
}

public IEnumerator Type() {
    foreach (char letter in sentences[index].ToCharArray()) {
      textDisplay.text += letter;
      yield return new WaitForSeconds(0.01f);
    }
}

public void NextSentence() {
    continueButton.SetActive(false);

    if (index < sentences.Length - 1) {
        index++;
        textDisplay.text = "";
        StartCoroutine(Type());
    } else {
        textDisplay.text = "";
        continueButton.SetActive(false);
    }
  }
}

Here is from where I tried to initialize:

public class Mace : MonoBehaviour {
//Dialogue dialogue = gameObject.AddComponent<Dialogue>();

private void OnTriggerEnter2D(Collider2D otherCollider) {
    if (otherCollider.CompareTag("Player")) {
        StartCoroutine(dialogue.Type());
    }
}

}


texts: Blend different biomes using linear interpolation

texts:
I've been scouring the internet for hours looking for a solution to blending biomes that have different amplitudes and frequencies together to create a seamless world. A recurring theme I'm seeing is that they have solved it by using linear or bilinear interpolation. I'm having trouble finding an implementation that would work for me.

Currently each biome is the same noise function but with adjusted frequencies and amplitudes to create variation. The problem is that it would result in "seams" between biomes, for example the plains and a mountains biome.

I think I understand how linear interpolation works. I have functions for it as well, but I'm confused as how to implement it. The game is essentially a 2D Minecraft type game. Would I have to determine the neighboring biomes by doing additional calculations across the x axis for every single block? I'm worried about performance if I somehow do this method.

I'm not sure if this would help but biomes are just determined using three instances of 1D noise, depth, temperature and rainfall. Depth is really just for oceans, but rainfall and temperature determine the biome. I have this basic setup (probably not the best code)

if(biome === 'desert') {
    frequency = 0.09;
    amplitude = 8;
    elevation = 65;
  } else if(biome === 'mountain') {
    frequency = 0.1;
    amplitude = 20;
    elevation = 65;
  } else if(biome === 'tundra') {
    frequency = 0.08;
    amplitude = 7;
    elevation = 65;
  } else if(biome === 'spruce') {
    frequency = 0.01;
    amplitude = 4;
    elevation = 65;
  } else if(biome === 'plains') {
    frequency = 0.08;
    amplitude = 8;
    elevation = 65;
  } else if(biome === 'forest') {
    frequency = 0.008;
    amplitude = 7;
    elevation = 65;
  } else if(biome === 'ocean') {
    frequency = 0.2;
    amplitude = 9;
    elevation = 30;
  } else if(biome === 'icy ocean') {
    frequency = 0.2;
    amplitude = 9;
    elevation = 30;
  }

  var height =
  (this.biome.noise.terrain.value(xt * frequency) * amplitude) + elevation;


texts: Unity 5 - Texture/Material rendering issue

texts:
I am working on a Minesweeper clone that started as a Unity 4.6 project and ended up as a Unity 5 project. I have cube objects that use Legacy Shaders/Diffuse. I am new to Unity 5, so I am not fully aware of the changes to the shaders.

The following texture on cube objects does not render as it is (I think it used to).

I want the flag appear on the cube as it is. What causes this output and how do I fix it?


texts: Is topology of procedural meshes important?

texts:
I've been working on a project which involves generating 3d game models, mostly
hard surface ones, procedurally. Do I have to worry about keeping the topology clean? Will topology affect texturing, or have any other consequences on the model that I haven't thought of?


texts: mesh gets twisted wildly when trying to use Unreal's mannequin's skeleton

texts:
I have modelled a simple mannequine and made a skeleton for it in Blender. As far as I can judge, this skeleton copies the Unreal's standard mannequine's skeleton perfectly...
All the hierarchy and bone names are the same, and Unreal also does not complain when I import this mesh and use Unreal's skeleton asset for it.
However, when I try to play a preview animation on my mesh, it gets twisted wildly.
This is a normal state:

... and this happens when I play an animation on this asset:

I thought it was due to different joint initial transforms, so I tried exporting from Blender with varying bone axes (x-axis along the bone, z-axis along the bone etc.) but it did not help. There is neither imporevement nor mere difference when I change that. Can you tell me possible reasons?
Please find the .fbx here:
https://drive.google.com/file/d/1v1X8t7l-6lwQragO8E0mtC1chdT2p1m4/view?usp=sharing


texts: How can I use a bounding sphere for intersection?

texts: How can I use a bounding sphere for intersection, like on a statue? Would I use the radius to detect intersection?


texts: Storing game objects in multiple containers

texts:
In the light of DRY, it seems desirable to store a collection of related game objects in one container only.
However, one might need sub-collections of these objects in various contexts. It might be sensible store these specific sub-sets in specific more suitable containers.
This increases the effort to track objects across containers, for instance when objects are removed from the game world.

What are possibilities to simplify such a design and what are the typical trade-offs?

To illustrate:

In a multiplayer role playing game, the server might hold a collection of game characters in a map suitable for lookup by id.

world
    map<id, Character> allCharacters

A character may also reside in a certain game level. In order to identify all characters being present in a level it may seem suitable to introduce a container for each level which holds the characters currently present on it. This way you can execute common logic for all characters in that level.

world
    map<id, Character> allCharacters

    [levels]
        level1
           vector<Character> charactersOnPlayfield
        level2
           vector<Character> charactersOnPlayfield
        ...

Going even further, when a character interacts with the world messages should only be routed to characters in range. This interest management could be achieved by dividing the each level into a grid of cells each of which in turn store the characters currently standing on it.

world
    map<id, Character> allCharacters

    [levels]
        level1
           vector<Character> charactersOnPlayfield
           [cells]
               cell1
                   vector<Character> charactersOnCell
               cell2
                   vector<Character> charactersOnCell
               ...
        level2
           vector<Character> charactersOnPlayfield
           [cells]
               cell1
                   vector<Character> charactersOnCell
               cell2
                   vector<Character> charactersOnCell
               ...
        ...

The Character objects at different levels of abstraction introduce the need to think carefully about object ownership and life-time.

Note that the Character objects stored in the containers would naturally be references, not copies.
Also, I am assuming that no garbage collection is in place.


texts:
I am out of options. I have tried everything I could and no matter what I do, the Transforms don't sync up. I have had multiple solutions that worked in my test, non AR project, but once I put on the HoloLens, it doesn't work.
Here is what I did:

//PlayerObject that is spawned by the NetworkManager
//(obviously has Network Identity component)
public class ClientObject : NetworkBehaviour {
    public static ClientObject CurrentClient;

    private void Start() {
        if(isLocalClient) CurrentClient = this;
    }

    public void MoveObject(GameObject obj, Vector3 position) {
        Cmd_MoveObject(obj, position);
    }

    [Command]
    public void Cmd_MoveObject(GameObject obj, Vector3 position) {
        obj.transform.localPosition = position;
    }
}

And now the object that wants to get synced. It has a Network Transform with standard settings, a network identity and (obviously) no-one has authority since it doesn't get spawned:

public class AnObject : MonoBehaviour {
    public void IWasMoved() {
        /*
         * Someone Moved this object, either by dragging it or
         * clicking on one of it's arrows through the hololons.
         */

        Vector3 newPosition = (the new position i want this object to have);
        ClientObject.CurrentClient.MoveObject(gameObject, newPosition);
    }
}

That's what I have. The only thing different from the version that works on my PC without the HoloLens is that I don't set localPosition = position, but instead use Translate(position) (which is obviously the non local version);

I am tired of writing new code, building the project, having Visual Studio translate the code to C++, start my HoloLenses and test if it works, which takes over an hour every time I do so.

So: is there anything fundamentally wrong with my code? Again: it works on my test project just fine. I refuse to believe that it's the HoloLens's fault...


texts: Is there a way to manipulate a pixel Array on the GPU?

texts:
I'm currently working on a 2D-Game and i want to draw and calculate the whole screen myself through a pixel array. I'm programming in C++, using SDL 2 and OpenGL specifically a OpenGL Texture which is generated through my manipulated pixel array. My rendering System basically works like this:

Pixelvalues from a spritesheet are getting put into the pixel array (those are all the tiles that should be rendered).
The RGB values of every pixel are getting multiplied by a certain value to get the effect of     lighting.
The manipulated pixel array is being passed to OpenGL to generate a Texture which is then drawn to the screen.

And the problem is that especially the lighting calculations cost a lot of time since its all being calculated on the CPU and even though all i'm doing is drawing the very basic things my FPS is maxed out at like 160 (on a quite good computer).
And after profiling my code i also got to the conclusion that mostly the lighting function takes up a lot of time.

Lighting function:

    void PixelRenderer::applyLight(Uint32& color, Uint32 factor){
    Uint32 red = (((color >> 16) & 0xff)* factor) >> 8;
    Uint32 green = (((color >> 8) & 0xff)* factor) >> 8;
    Uint32 blue = (((color) & 0xff)* factor) >> 8;

    if (red > 255) red = 255;
    if (green > 255) green = 255;
    if (blue > 255) blue = 255;

    color = (color & 0xFF000000) | red << 16 | green << 8 | blue;
}

and this is done for every single pixel on the screen (1024*576 resolution and 32x32 tileSize)

So my question basically is if theres any way i can do those calculations on the GPU to improve my performance.


texts: My .FBX model is not picking the .TGA texture file

texts:
I'm at a complete loss.

An artist has sent me a 3D model so I can test it in Unity. This is exactly what I got:

 - Guy.fbx
 - Guy_DIF_512.tga

Alright. So I move the folder into the Unity inspector. Suddenly, a Materials folder is created within such folder. The Materials folder has one material.

Anyway, now I put the Guy prefab into the scene. It doesn't have textures applied.

No problem. A simple Google search yields this response:

  The textures for your model have to be in your Unity project for Unity
  to apply them automatically when you import.

  There are 3 different ways to make sure this happens

  1 Use Textures for your 3D model from a \textures directory already in
  your Unity project

  2 Embed them in the FBX

  3 Copy the textures into your project before you import your model

I will avoid the second option for now to avoid troubling the artist. Let's see the third option...

  3 If you are using 3D software packages that might not have newer FBX
  plugins or are importing native files you generally do not have the
  option to embed media, so you will need to copy the textures into a
  directory inside your project called textures - nested next to the
  model before you import it e.g.

  \Projectx\Assets\Models\Textures\ModelTexture.tga

  \Projectx\Assets\Models\Model.fbx

Ok, so I created Assets/Models/Textures and imported the Guy_DIF_512.tga file into it. Then in Assets/Models folder I import the Guy.fbx file.

Doesn't work. The model still doesn't have textures applied.

Alright, so let's look at the first option then.

... Let's look at the first option...

  1 If you create your textures in your Unity project to start with and
  source them from a \textures directory nested under Models for
  example, Unity should always create materials and pick up the textures
  correctly at import

  **\Assets\Models\Textures**

  **\Assets\Models**

Uh, isn't this the same as the third option?

How do I import my 3D model?

I am using Unity 5.


texts: do i need a deterministic game engine for ball physics multiplayer game?

texts:
I want to create a simple soccer game but where the ball physics is accurately rendered across the network. I looked at Photon's Quantum engine and it is too expensive for indie devs at 1k/month for only 500 CCU.
Is there an alternative approach? Basically I need the ball physics to be as accurate as possible.


texts:
I have problem with simple box2d physics: I have two bodies : 1 - static box , 2 - dynamic box. I only want to this dynamic box fall on this static, and lay. But now it looks like that at end , starting from  . This is code, which bases on box2d HelloWorld:

#include <SFML/Graphics.hpp>
#include <Box2D/Box2D.h>
#include <cstdio>

int main(int argc, char* argv[])
{
    B2_NOT_USED(argc);
 B2_NOT_USED(argv);

 b2Vec2 gravity(0.0f, -10.0f);
 bool doSleep = true;
 b2World world(gravity, doSleep);

 b2BodyDef groundBodyDef;
 groundBodyDef.position.Set(0.0f, -10.0f);
 b2Body* groundBody = world.CreateBody(&groundBodyDef);
 b2PolygonShape groundBox;
 groundBox.SetAsBox(50.0f, 10.0f);
 groundBody->CreateFixture(&groundBox, 0.0f);

 b2BodyDef bodyDef;
 bodyDef.type = b2_dynamicBody;
 bodyDef.position.Set(0.0f, 300.0f);
 bodyDef.active = true;
 b2Body* body = world.CreateBody(&bodyDef);
 b2PolygonShape dynamicBox;
 dynamicBox.SetAsBox(3.5f, 3.5f);

 body->SetTransform(b2Vec2(0,100),30);

 b2FixtureDef fixtureDef;
 fixtureDef.shape = &dynamicBox;
 fixtureDef.density = 1.0f;
 fixtureDef.friction = 0.3;

 body->CreateFixture(&fixtureDef);

 float32 timeStep = 1.0f / 60.0f;
 int32 velocityIterations = 6;
 int32 positionIterations = 2;

    sf::RenderWindow app(sf::VideoMode(800, 600), "BOX/SFML");
 app.UseVerticalSync(true);
 sf::Shape shape = sf::Shape::Rectangle(-3.5f,-3.5f,3.5f,3.5f,sf::Color::Green);
 sf::Shape groundShape = sf::Shape::Rectangle(-50,-10,50,10,sf::Color(100,40,120));

    while (app.IsOpened())
    {

        sf::Event event_;
        while (app.GetEvent(event_))
        {

            if (event_.Type == sf::Event::Closed)
                app.Close();
        }

  world.Step(timeStep, velocityIterations, positionIterations);
        world.ClearForces();

  b2Vec2 position = body->GetPosition();
  float32 angle = body->GetAngle();
  b2MassData m;

  body->GetMassData(&m);
  printf("m %f\n",m);
  printf("%4.2f %4.2f %4.2f\n", position.x, position.y, angle);

  app.Clear();
  shape.SetPosition(position.x+400,-position.y+300);
  shape.SetRotation(angle);
  app.Draw(shape);
  groundShape.SetPosition(0+400,10+300);
  app.Draw(groundShape);

        app.Display();
    }
 world.DestroyBody(groundBody);
 world.DestroyBody(body);
    return EXIT_SUCCESS;
}

I looking for any advice for solve this problem. And another problem, why mass of dynamic shape is 0 ?


texts: How do I make my Unity application quit programmatically?

texts:
I made a script and I want to make my game quit, but this does not work. How should I go to make the app quit?

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class LevelManager : MonoBehaviour {
  public int Index;

  public void SceneLoad()
  {
    SceneManager.LoadScene(Index);
  }

  public void Quit()
  {
    Application.Quit;
  }
}


texts: I'm trying to add in-app purchases into my Android game and it having some trouble figuring my around the Google Play Billing. Can anyone refer me to a good open source reference for how to do that?


texts: How do I set the opacity of a Button to 0? (Unity)

texts:
I'm trying to hide a button when you click that button (I meant setting the opacity to 0, not disabling the game object of the button). What the button does is it loads a scene async. If I disable the game object I won't be able to load the scene async. Any way to set the opacity of the button?
Sorry if the question is already asked as I wasn't able to find any questions related to this.


texts: What is the purpose of the canonical view volume?

texts:
I'm currently learning OpenGL and haven't been able to find an answer to this question.

After the projection matrix is applied to the view space, the view space is "normalized" so that all the points lie within the range [-1, 1]. This is generally referred to as the "canonical view volume" or "normalized device coordinates".

While I've found plenty of resources telling me about how this happens, I haven't seen anything about why it happens.

What is the purpose of this step?


texts: Performance problem when multiple enemies are grouped up

texts:
I have enemy with simple behavior: Reach the player's current position. In game are increasing waves, which are increasing the number of enemies. But when are more enemies (like 14), and they got too close to each other, there is big physics spike in profiler.

There are significant drop of performance... And as Profiler says, it's because of Physics...

Now I am little lost, I tried turn of the ignore collision on layer (which was turned on), so they don't overlap, but there is still little touch of course, when they group up, so still so much to process...
What is the best solution here?
I build it around rigidbodies for the use of Velocity, and detection of collisions with walls (edge collider), so when the object reaches there, it is easily stopped... But for this cases it seems now like not the best solution.


texts: My frustum culling is culling from the wrong point

texts:
I'm having problems with my frustum being in the wrong origin.
It follows the rotation of my camera but not the position.

In my camera class I'm generating a view-matrix:

void Camera::Update()
{
    UpdateViewMatrix();

    glMatrixMode(GL_MODELVIEW);
    //glLoadIdentity();
    glLoadMatrixf(GetViewMatrix().m);
}

Then extracting the planes using the projection matrix and modelview matrix:

void UpdateFrustum()
{
    Matrix4x4 projection, model, clip;

    glGetFloatv(GL_PROJECTION_MATRIX, projection.m);
    glGetFloatv(GL_MODELVIEW_MATRIX, model.m);

    clip = model * projection;

    m_Planes[RIGHT][0] = clip.m[ 3] - clip.m[ 0];
    m_Planes[RIGHT][1] = clip.m[ 7] - clip.m[ 4];
    m_Planes[RIGHT][2] = clip.m[11] - clip.m[ 8];
    m_Planes[RIGHT][3] = clip.m[15] - clip.m[12];
    NormalizePlane(RIGHT);

    m_Planes[LEFT][0] = clip.m[ 3] + clip.m[ 0];
    m_Planes[LEFT][1] = clip.m[ 7] + clip.m[ 4];
    m_Planes[LEFT][2] = clip.m[11] + clip.m[ 8];
    m_Planes[LEFT][3] = clip.m[15] + clip.m[12];
    NormalizePlane(LEFT);

    m_Planes[BOTTOM][0] = clip.m[ 3] + clip.m[ 1];
    m_Planes[BOTTOM][1] = clip.m[ 7] + clip.m[ 5];
    m_Planes[BOTTOM][2] = clip.m[11] + clip.m[ 9];
    m_Planes[BOTTOM][3] = clip.m[15] + clip.m[13];
    NormalizePlane(BOTTOM);

    m_Planes[TOP][0] = clip.m[ 3] - clip.m[ 1];
    m_Planes[TOP][1] = clip.m[ 7] - clip.m[ 5];
    m_Planes[TOP][2] = clip.m[11] - clip.m[ 9];
    m_Planes[TOP][3] = clip.m[15] - clip.m[13];
    NormalizePlane(TOP);

    m_Planes[NEAR][0] = clip.m[ 3] + clip.m[ 2];
    m_Planes[NEAR][1] = clip.m[ 7] + clip.m[ 6];
    m_Planes[NEAR][2] = clip.m[11] + clip.m[10];
    m_Planes[NEAR][3] = clip.m[15] + clip.m[14];
    NormalizePlane(NEAR);

    m_Planes[FAR][0] = clip.m[ 3] - clip.m[ 2];
    m_Planes[FAR][1] = clip.m[ 7] - clip.m[ 6];
    m_Planes[FAR][2] = clip.m[11] - clip.m[10];
    m_Planes[FAR][3] = clip.m[15] - clip.m[14];
    NormalizePlane(FAR);
}

void NormalizePlane(int side)
{
    float length =  1.0/(float)sqrt(m_Planes[side][0] * m_Planes[side][0] +
                                m_Planes[side][1] * m_Planes[side][1] +
                                m_Planes[side][2] * m_Planes[side][2]);

    m_Planes[side][0] *= length;
    m_Planes[side][1] *= length;
    m_Planes[side][2] *= length;
    m_Planes[side][3] *= length;
}

And check against it with:

bool PointInFrustum(float x, float y, float z)
{
    for(int i = 0; i < 6; i++)
    {
        if( m_Planes[i][0] * x + m_Planes[i][1] * y + m_Planes[i][2] * z + m_Planes[i][3] <= 0 )
        return false;
    }
    return true;
}

Then i render using:

camera->Update();
UpdateFrustum();

int numCulled = 0;

for(int i = 0; i < (int)meshes.size(); i++)
{
    if(!PointInFrustum(meshCenter.x, meshCenter.y, meshCenter.z))
    {
        meshes[i]->SetDraw(false);
        numCulled++;
    }
    else
        meshes[i]->SetDraw(true);
}

Matrices look like (Camera is at (5, 0, 0)):

ModelView
[0,0,0.99,0] [0,1,0,0] [-0.99,0,0,0] [0,0,-5,1]

Projection
[0.814,0,0,0] [0,1.303,0,0] [0,0,-1,0] [0,0,-0.02,0]

Clip
[0,0,-1,-0.999] [0,1.30,0,0] [-0.814,0,0,0] [0,0,4.98,4.99]

What am I doing wrong?


texts:
In my 2D game project, as well as in LibGDX in general, are a lot of different entities that need to be rendered(static images, sprites, animations, etc...), as well as have certain effects applied (shaders). Most, if not all, tutorials show a simple hardcoded way of rendering each sprite instance, or at the most, a loop iterating over one type of renderable entity and rendering it.

I have a need to render a decent number of entities (~1000 static(background/tilesets) and dynamic(characters) per screen) where certain entities might have one or even multiple shaders applied to them. I'll also probably have to deal with rendering to FBO's to be able to apply multiple shaders on entities, though I haven't yet reached that point so I'm not sure yet (so far my entities have either 0 or 1 shader, but I'm planning on placing multiple shaders per entity soon so I need to take that into account).

I don't know what rendering techniques would allow me to accomplish this task however I've got some ideas I'm stuck with.

For more context I'm also using an ECS but I'm not coupling rendering to it.

My current idea is to have a RenderingEngine of sorts, decoupled from ECS. It would basically contain a queue of... something, some message POJO describing what and where to render. This queue would then, each render cycle, be sorted according to layer, type, shader and then be distributed to their own appropriate renderer.

The gist is that other game systems send a message to the RenderingEngine describing what they want rendered and then the engine works out what to do with it the next rendering cycle.

Current issues I've got with this idea:

Messages might prove to be a performance overhead as they are plain objects created for the sole purpose of sending a message over. This could probably be alleviated via pooling.
Shaders. Without shaders rendering logic is fairly simple [sort by layer -> for each layer sort by type -> render]. Shaders however are applied per batch and that confuses me. I am not sure where in the above rendering logic would shaders fit in...

Am I reinventing the wheel? Is there a standard technique of accomplishing this kind of "flexible" rendering?

Is the queueing idea I've described above a part of some well known technique I could investigate for clues?(My searches have given me no anwsers so far)


texts: What is causing this error in rpg maker mv "Animated Sideview Enemies plugin"

texts:
I am having trouble with this plugin because when I use it to attack It gives an error. You can clearly see using magic works fine, it only seems to cause the error when attacking and only when using the "" notetags aka side-view mode.

Using Attack

Using Magic

Here is some reference links to what I am talking about.
The plugin: http://yanfly.moe/2015/12/13/yep-44-animated-sideview-enemies/
rpg maker mv: https://store.steampowered.com/app/363890/RPG_Maker_MV/


texts: Texture coordinates do not map correctly in Direct3D11 game engine

texts:
I beg your pardon if this question has been already answered elsewhere or if this is the wrong site, but I have a serious issue with rendering textures with Direct3D 11.

Using Cinema 4D R17, I created a simple cube, triangulated all polygons, and UV mapped a texture, as you can see here:

and it renders correctly.

Next, I exported the file to .x because I created a simpler mesh format and .x is ideal for getting vertices, indices, normals, texture coordinates, etc. This conversion is perfect as all data from the source file is successfully transferred to my file (I checked and double checked it).

However, when I upload the file in my game engine, I get the following result:
The cube is being rendered incorrectly where that strange pattern forms.

This is the original .x file (I included only relevant parts):

Mesh CINEMA4D_Mesh {
  8;
  // Cube. These are vertices.
  -0.01;-0.01;-0.01;,
  -0.01;0.01;-0.01;,
  0.01;-0.01;-0.01;,
  0.01;0.01;-0.01;,
  0.01;-0.01;0.01;,
  0.01;0.01;0.01;,
  -0.01;-0.01;0.01;,
  -0.01;0.01;0.01;;

  12;
  // Cube. These are indices.
  3;0,1,3;, // '3;' means that this face contains 3 vertices.
  3;2,3,5;,
  3;4,5,7;,
  3;6,7,1;,
  3;1,7,5;,
  3;6,0,2;,
  3;0,3,2;,
  3;2,5,4;,
  3;4,7,6;,
  3;6,1,0;,
  3;1,5,3;,
  3;6,2,4;;

  MeshNormals {
    8;
    // Cube
    -0.408;-0.408;-0.816;,
    -0.667;0.667;-0.333;,
    0.667;-0.667;-0.333;,
    0.408;0.408;-0.816;,
    0.408;-0.408;0.816;,
    0.667;0.667;0.333;,
    -0.667;-0.667;0.333;,
    -0.408;0.408;0.816;;

    12;
    // Cube
    3;0,1,3;,
    3;2,3,5;,
    3;4,5,7;,
    3;6,7,1;,
    3;1,7,5;,
    3;6,0,2;,
    3;0,3,2;,
    3;2,5,4;,
    3;4,7,6;,
    3;6,1,0;,
    3;1,5,3;,
    3;6,2,4;;

  }
  MeshTextureCoords {
    8;
    // Cube
    1.0;1.0;,
    0.0;1.0;,
    1.0;0.0;,
    1.0;1.0;,
    1.0;1.0;,
    1.0;0.0;,
    0.0;1.0;,
    1.0;0.0;;
  }
  MeshMaterialList {
    2;
    12;
    1,
    1,
    1,
    1,
    1,
    1,
    1,
    1,
    1,
    1,
    1,
    1;

    Material C4DMAT_NONE {
      1.0;1.0;1.0;1.0;;
      1.0;
      0.0;0.0;0.0;;
      0.0;0.0;0.0;;
    }
    Material C4DMAT_Mat {
      1.0;1.0;1.0;1.0;;
      1.0;
      0.0;0.0;0.0;;
      0.0;0.0;0.0;;
      TextureFilename {
        "tex.bmp";
      }
    }

    {C4DMAT_Mat}
  }
}

I also invert the vtexture coordinate (v = 1 -v). This is the vertex data I extract:

8 // Number of vertices.
-0.01 -0.01 -0.01 -0.01 0.01 -0.01 0.01 -0.01 -0.01 0.01 0.01 -0.01 0.01 -0.01 0.01 0.01 0.01 0.01 -0.01 -0.01 0.01 -0.01 0.01 0.01 // Vertices stored in X, Y, Z.
1 0 0 0 1 1 1 0 1 0 1 1 0 0 1 1  // Texture coordinates stored in U, V.
36 // Indices count.
0 1 3 2 3 5 4 5 7 6 7 1 1 7 5 6 0 2 0 3 2 2 5 4 4 7 6 6 1 0 1 5 3 6 2 4 // Indices.
tex.bmp // Texture file name.

I read that there might be a conflict between texture coordinates of vertices that are shared among different faces and that resolving this would imply not using index buffers.

EDIT: I did what @wondra said (replaced texture coordinates with 0 0 0 1 1 0 1 1 0 1 0 0 1 1 1 0 and it looks better indeed:

I am not sure what is wrong here. Could anybody help me? Thank you.

UPDATE: The Cinema 4D .obj is broken. Use Blender or anything else.


texts: How can I compute which chunk a coordinate is in?

texts:
I am working on a video game. Everything (terrain, entities, particles) is stored in 100 by 100 chunks. Here is the array structure for the chunks:

public static final int chunkSize = 100;
public static Chunk [][][] chunks;

The world is 20,000 by 20,000.

Given a random coordinate (such as (-1244, 1353)), how can I quickly and efficiently determine what chunk the coordinate is in?

Once I know what chunk a coordinate is in, I can determine which chunks to load around a player.


texts:
i am creating a game using a "Low Poly Art Style".   Meaning there is an effect of polygons on the model.  Whilst modelling a tree, a portion somehow became smooth and i continued to model not knowing this.  What i am wondering is,  is there a way to unsmooth these polygons to look similar to the rest of the model.  EDIT... The smoothed are is on the tree trunk in the middle.

Below is an image of the model in question.

Thanks is advance guys...


texts:
I'm 21 years old and I suck at math, I mean really bad. I don't have the necessary logic to apply it towards programming. I would like to learn the math and logic of applying it. I found Game Institute (http://www.gameinstitute.com) awhile back and heard a lot of praise about them. Are there Math courses any good?

Thank you.

Edit: My high school was terrible and did not prepare me for any math. I am fairly decent at programming, I just don't have the logic to apply any mathematics to programming, as an example I don't understand the algorithm of finding the size of a user's screen.

Yes I have heard of KhanAcademy (http://www.khanacademy.org/) and I have completed a lot of maths on his website but I still don't have the logic to apply any of it to programming.


texts:
This has been discussed a couple of times, but I didn't find any solution:

I want to set the position of an UI.Button to my mouse position.
I can get the mouse position like this:

Vector3 cameraVector = Camera.main.ScreenToWorldPoint(Input.mousePosition);

Problem: The UI elements are using another "coordination system". How can I handle that problem?


texts: Is "entity component system" a principle or a pattern?

texts:
Since the ECS follows the principle Composition over Inheritance, and it  makes the behavior of game objects can be changed in the runtime.

If ECS is a principle, from my memory of design patterns of GoF, the following patterns can accomplish the principle well:

Decorator pattern
Composite + Visitor

But I'm not sure about that ECS is a pattern like the above or a principle like Open Closed Principle, I've tried to find a video which explains ECS well but found nothing clear.

Current resources I found:

gamedev.net ECS


texts: Why am I seeing unbounded memory usage in my WP8 game?

texts:
I recently upgraded to VS2012 and tried my game out on the new WP8 emulators. I was dismayed to find out the emulator now crashes and throws an out of memory exception during my sprite loading procedure (it still works in WP7 emulators and on my WP7).

Regardless of whether the problem is the emulator or not, I want to get a clear understanding of how I should be managing memory in the game.

My game consists of a character that has 4+ different animations. Each animation consists of about 4 to 7 frames. On top of that, the character has up to 8 stackable visualization modifications (eye type, nose type, hair type, clothes type, et cetera). Prior to my memory issue, I preloaded all textures for each animation frame and customization  and created animate action out of them. The game then plays animations using the customizations applied to that current character.

I revisited this implementation when I received the out of memory exceptions and have started playing with RenderTexture instead, so instead of pre-loading all possible textures, it on loads textures needed for the character, renders them onto a single texture, from which the animation is built. This means the animations use 1/8th of the sprites they were before. I thought this would solve my issue, but it hasn't.

Here's a snippet of my code:

var characterTexture = CCRenderTexture.Create((int)width, (int)height);

characterTexture.BeginWithClear(0, 0, 0, 0);
// stamp a body onto my texture
var bodySprite = MethodToCreateSpecificSprite();
bodySprite.Position = centerPoint;
bodySprite.Visit();
bodySprite.Cleanup();
bodySprite = null;
// stamp eyes, nose, mouth, clothes, etc...

characterTexture.End();

As you can see, I'm calling CleanUp and setting the sprite to null in the hope of releasing the memory, though I don't believe this is the right way, nor does it seem to work.

I also tried using SharedTextureCache to load textures before stamping my texture out, and then clearing the SharedTextureCache with:

CCTextureCache.SharedTextureCache.RemoveAllTextures();

But this didn't have an effect either.

I used VS to do a memory profile of the emulation causing the crash. Both WP7.1 and WP8 emulators peak at about 150mb of usage. WP8 crashes and throws an out of memory exception.

Each customisation/frame is 15kb at the most. Lets say there are 8 layers of customization (120kb) but I render then onto one texture which I would assume is only 15kb again. Each animation is 8 frames at the most. That's 15kb for 1 texture, or 960kb for 8 textures of customization. There are 4 animation sets. That's 60Kb for 4 sets of 1 texture, or 3.75MB for 4 sets of 8 textures of customisation.

So even if its storing every layer, its 3.75MB. That's nowhere near the 150mb breaking point my profiler seems to suggest.

WP 7.1 Memory Profile (max 150MB)

WP8 Memory Profile (max 150MB and crashes)

Why might I be seeing this behavior?