texts:
I've been building a game center game for iOS and it works great so far. I finally started testing the game and theres (obviously) some latency, which is causing the game to be out of sync.

Basically I have 2 players, each controlling a game character. The game character can shoot fireballs and iceballs etc. These attacks do damage, and they have effects. For example. the ice ball effect will freeze the opponent for 3 seconds if it makes contact. the fireball will do extended fire damage for 3 seconds.

so the problem is, when I was playing against my brother, because of the latency, my game said I had 40 health left and he was down to 0, while on his device, the game said I had 0 and he had 20.

This means that attacks were registering/colliding on one device (based on the positions of the characters/fireballs) and not on the other. and vice versa.

I'm currently using the default peer-to-peer game-center architecture. Would using a client-server architecture (one person becomes the server) solve this out-of-sync problem?

if not, what other options do I have with the game kit API?


texts: Making a DX9 game resolution independent

texts:
How can I change the resolution and stretch my entire game to the new resolution? I want my game to have a base resolution, and when I change it to stretch to that new resolution. I saw a few similar questions but all the answers suggested that i should change the presentation parameters. If i do that, my screen resolution changes, but all my other objects remain the same size and draw in the wrong position.

I use a LPD3DXSPRITE object to draw the textures to the screen, some DirectX text, and vertices defined as this:

#define D3DFVF_VERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)

I tried to put D3DXSPRITE_OBJECTSPACE at sprite->Begin() and play with the projection, view and world matrices but without success.

Can someone tell me if this method is possible and how should I do it? I also read about another method that suggested rendering to a surface, and then stretching the surface, but i don't know how to implement that. I am a beginner in DirectX. I googled the second method, but I couldn't find someone explaining it, and I don't think I can draw from a sprite to a surface.


texts: Unity allows me to add multiple labels to my assets in the editor (the little blue luggage tag in the corner of the inspector). I can use the Asset Database to find all assets with a certain tag from the editor, but can I do the same thing at runtime? Maybe if the assets are in the resources folder?


texts: Unity 2020.1.8f1 cannot build xcode project for iOS

texts:
We recently updated a project to Unity 2020.1.8f1
But it will not build the xcode project for iOS because of missing plist key value pairs.
This is really weird cus, before, I would build the xcode project, then fix the plist stuff, then build to iOS.
Here are the errors Im getting when I try to build.

WebCamTexture class is used but Camera Usage Description is empty. App will not work on iOS 10+.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean &)(at / Users / bokken / buildslave / unity / build / Modules / IMGUI / GUIUtility.cs:189)

Microphone class is used but Microphone Usage Description is empty. App will not work on iOS 10+.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

I tried adding this script to Editor folder in assets
    using UnityEngine;
    using UnityEditor;
    using UnityEditor.Callbacks;
    using System.Collections;
    using UnityEditor.iOS.Xcode;
    using System.IO;

    public class AddStuffToplist {

        [PostProcessBuild]
        public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
        {

            if (buildTarget == BuildTarget.iOS) {

                Debug.Log("adding plist stuff");
                // Get plist
                string plistPath = pathToBuiltProject + "/Info.plist";
                PlistDocument plist = new PlistDocument();
                plist.ReadFromString(File.ReadAllText(plistPath));

                // Get root
                PlistElementDict rootDict = plist.root;

                rootDict.SetString("NSCameraUsageDescription","Natcorder unity asset uses this");
                rootDict.SetString("NSMicrophoneUsageDescription","Natcorder unity asset uses this");
                rootDict.SetString("NSPhotoLibraryUsageDescription","Natcorder unity asset uses this");

                //rootDict.SetString("Privacy - Photo Library Usage Description", "Natcorder unity asset uses this");
                //rootDict.SetString("Privacy - Microphone Usage Description", "Natcorder unity asset uses this");

                // Write to file
                File.WriteAllText(plistPath, plist.WriteToString());
            }
        }
    }

I get exactly the same errors if I use Privacy - Microphone Usage Description or NSMicrophoneUsageDescription as the key for example.
Also the debug line I added "adding plist stuff" never shows up in the console, so maybe this script is not working?


texts: Java - how to reduce iteration loops for enemies

texts:
I have many places in my code where I'm iterating through the enemies array and it seems to me it could be optimised somehow, but I can't see how it can be done. For example these two loop checks:
private void arc1() {
    for (Enemy e : gs.getEnemies())
        if (e.distanceFromPlayer() < 32 && !e.seen) {
            arc1.setActive(true);
            return;
        }
    arc1.setActive(false);
}

private void arc2() {
    for (Enemy e : gs.getEnemies())
        if (e.distanceFromPlayer() < 24) {
            arc2.setActive(true);
            return;
        }
    arc2.setActive(false);
}

They're both just checking the distance from the player with one having an extra condition and a different distance. Is there a way to combine them into one? I tried doing it but it didn't work correctly.
Will it actually give any benefit performance wise to combine into one in any case? It does look like duplicate code but not sure if there would actually be any performance benefit.


texts: Is there a quick way to determine if a vector is in a quadrant?

texts:
I am wondering if there is a quick easy way to determine if a given vector is in a specified quadrant.

In the below image, I've define the ranges of the blue quadrants.

For example, if I am given a sample vector of -9.4,13.3 is there an easy way to figure out which of the four quadrants it is in (Q2)?

I'm looking to know if there is some vector math that can determine this relatively simply instead of doing a bunch of less than / greater than operators on a fixed range.

Considering that I could have more or less than 4 quadrants and they might not be at this nice 45 degree angle.


texts:
Having noticed that UDK (Unreal) and Unity 3 include similar pre-computed visibility solutions that unlike Quake are not dependent on level geometry, I've been trying to figure out how the calculation is done.

The original Quake system is well documented: You divide the world into convex volumes that limit both the camera and the geometry. Each volume has a list of all the other volumes that are visible from it.

Visibility would be computed by firing rays at some random distribution of points in the target volume and see if any hit. And because the position of the camera in the source volume could have an effect, those thousands of rays would have to be fired from multiple places in the source cell.

So what I'm wondering is if there's any been fundamental change to this basic scheme in the intervening 15 or so years? I can see how to adapt it to a UDK/Unity scheme that has regular source volumes and deals mostly with arbitrary meshes as the targets, but is there a better way than stochastic ray testing?


texts: how to move the camera behind a model with the same angle? in XNA

texts:
I'm having difficulty moving my camera behind an object in a 3D world. I'd like to have two view modes:

for fps (first person).
external view behind the character (third person).

I've searched the net for examples but they don't work in my project.

Here is my code used to change the view when F2 is pressed:

 //Camera
        double X1 = this.camera.PositionX;
        double X2 = this.player.Position.X;
        double Z1 = this.camera.PositionZ;
        double Z2 = this.player.Position.Z;

        //Verify that the user must not let the press F2
        if (!this.camera.IsF2TurnedInBoucle)
        {
            // If the view mode is the second person
            if (this.camera.ViewCamera_type == CameraSimples.ChangeView.SecondPerson)
            {
                this.camera.ViewCamera_type = CameraSimples.ChangeView.firstPerson;

                //Calcul position - ?? Here my problem
                double direction = Math.Atan2(X2 - X1, Z2 - Z1) * 180.0 / 3.14159265;
                //Calcul angle - ?? Here my problem

                this.camera.position = ..
                this.camera.rotation = ..

                this.camera.MouseRadian_LeftrightRot = (float)direction;
            }
            //IF mode view is first person
            else
            {
                    //....


texts: What technology is best for building my first game

texts:
I have started a few game projects in the past, but have never finished anything.  I decided that it was probably because I was writing everything thing from scratch, and just ended up dropping the project once development started taking too long.

I've decided that I want to finish my first game now, and needed some opinions on what sort of middleware would be good to use.  I was hoping that with an engine provided for me, I'd be able to finish the game.

I am most familiar with C++, but do know quite a few other languages as well.


texts: Can i tell if a Vertex Tree is a solid shape?

texts:
if a Vertex looks like this:

struct vertex {
    vec3 point;
    vertex [] connected;
};

Can I tell if this makes a solid shape with no holes? (e.g a sphere or a cube, NOT a sphere with a side missing for example)

(if i can see the back of a face from outside of the shape then it is not solid)


texts: How do I create a player movement system in Farseer?

texts:
My group of students is helping produce a a 2D platformer. We tried making a pixel-based collision system which fell through. Now I am trying this physics engine on for size and see new ways to create and control my player. Like the obvious circle body player:

I was using a different type of player movement system like this XNA video example.

What system would work for a player that needs to be able to jump and move in mid-air (as in the above link), and can run up slopes like the circular body example?

I guess that the circular body can be made to do anything, but would like community input.


texts:
I am planning on making a 2D mobile game for iOS and Android. It will have animations (including some simple flash/light and particle effects, like in Candy Crush), but the only physics the game will need is hit-detection between 2 circles, and dragging a sprite across the screen. And the game isn't very complicated. Since these would be easy to implement on my own, I'm considering using the native iOS/Android SDKs for this (on Xamarin), with no game engine.

Is this a good or bad idea? Would avoiding using game engines, and using the native SDKs (on Xamarin) improve the performance of my game? Wouldn't fixing bugs become easier (in some odd cases) since both platforms are separated into different builds/code? Looking at games like Candy Crush, I don't see any physics involved and so believe that a game engine isn't even needed for a game like that. Any advice/suggestions would be appreciated.


texts: Why does Facebook share callback return "success" if the user cancels? - Unity

texts:
Here is the code piece I used to debug:

public void Share (FacebookPost post)
{
    FacebookDelegate<IShareResult> innerCallback = (result) =>
    {
        foreach (var item in result.ResultDictionary)
        {
            Debug.Log(item.Key + " " + item.Value);
        }
    }

    FB.ShareLink (post.linkURL, post.linkTitle, post.linkDescription, post.imageURL, innerCallback);
}

The callback is expected to return a "cancelled" key if user closes the share dialog without sharing, but instead it returns "posted" key with "true" value, which is exactly the same result as when user literally "posts".

And it returns no other data that can help me to decide if user actually shared or not.

So, how can i decide if user shared or cancelled?


texts: Point Light shows black box & rect (PointLight not working) - libgdx 3D

texts:
I am creating a 3d scene currently a box and rect, and trying to enable lighting.

  When i create a PointLight and add it to Environment everything turns to  black color?

all i want to do is create a 3d scene and enable point light, like a sun or rays coming from a point and shading the objects.

Code:

environment = new Environment();
environment.add(new PointLight().set(1f, 1f, 1f, 0, 0, 20f, 100f));

modelBatch=new ModelBatch();

..

square=new ModelBuilder().createBox(300,300,300,new Material(ColorAttribute.createDiffuse(Color.GREEN)),
                VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
squareinst=new ModelInstance(square);
squareinst.transform.setTranslation(-500,0,0);

--

sprites.get(0).setRotationY(sprites.get(0).getRotationY() + 1f);
sprites.get(1).setRotationY(sprites.get(1).getRotationY() - 1f);
squareinst.transform.rotate(1,0,0,1);

modelBatch.begin(camera);
for(Sprite3D sp:sprites)// has 3d rect models
     sp.draw(modelBatch,environment);
modelBatch.render(squareinst,environment);
modelBatch.end();

PointLight turning everything black

Without using environment or lights

as per my investigation, here if pointlight is not working then everything should be black as currently, because the environment needs light, it works fine with Directional light (only the backface of rect is black even after rotations, i don't know why)

libgdx version 1.6.1 - android studio
i checked it on both android device and desktop

please i really need to get this PointLight working, i don't know if it will take a custom shader, if so please guide me to some links because i am not experienced in shaders. I also read about PointLight not working on some device or not working in opengl 2.0 enabled, but i am not sure.


texts: What is the advantage of using "pixel coordinates" in a 2D engine?

texts:
From the Godot feature list:

  Work in pixels as your units, but scale to any screen size and ratio.

Reading the documentation they also use pixel coordinates to update the position of objects

move( Vector2(0,1) ) #move down 1 pixel per physics frame

What is the advantage of using pixel coordinates? The limitation seems to be that an object can't easily move less than one pixel per frame. For example move object 1.5 pixels per frame.


texts: How efficiently use SDL_RenderFillRects?

texts:
For the sake of learning C++, I would like to optimize a "Game of life" project I made.
In my first attempt, I used a bunch of SDL_RenderFillRect to draw the board squares.
In my second attempt, I used a single SDL_RenderFillRects to avoid the cost of calling the GPU a lot of times.

However, I am probably wrong in my second implementation because it is not faster than the first one (or barely 5%). Moreover, my implementation is all but elegant.

In the two cases, I only draw the living cells.

The SDL_RenderFillRect solution:

SDL_Rect fillRect;
for (int column=0; column<array_width; ++column)
{
    for (int row=0; row<array_height; ++row)
    {
        if (board[column][row]) // // Checks if the cell is alive
        {
            fillRect = {column*CELL_SPACE,row*CELL_SPACE,CELL_SIZE,CELL_SIZE};
            SDL_RenderFillRect(gRenderer, &fillRect);
        }
    }
}

The SDL_RenderFillRects solution:

SDL_Rect fillRect;
static SDL_Rect rect_list[120000]; // The list of squares to be drawn
int array_index_count = 0;
for (int column=0; column<array_width; ++column)
{
    for (int row=0; row<array_height; ++row)
    {
        if (board[column][row]) // Checks if the cell is alive
        {
            fillRect = {column*CELL_SPACE,row*CELL_SPACE,CELL_SIZE,CELL_SIZE};
            rect_list[array_index_count] = fillRect; // Adds the cell to the array
            ++array_index_count;
        }
    }
}
SDL_RenderFillRects(gRenderer, rect_list, array_index_count);

I am not happy with the way I use SDL_RenderFillRects.
First, I don't know in advance how many living cells there will be, forcing me to declare an oversized array.
Second, I indeed avoided a lot of SDL_RenderFillRect calls, but at the price of long iteratings over the rect_list array.

How to use the SDL_RenderFillRects function properly?


texts: How to implement own UI widget in libGDX?

texts:
I want to implement my own widget, here is an image:

what I want to get. Instead of numbers there will be some names, but I think it doesn't matter. I'm pretty new in libGDX, so could you please briefly describe me plan, how can I do something like this (if there will be some code, it would be awesome)? I tried to google it, but didn't find something relevant.

Thanks in advance!


texts: Making sure my users don't fake that they've completed a task I can not verify electronically?

texts:
I hope this is worded alright, I didn't know how else to describe it. I'm developing a game that has the user set their own "missions" that take place in real life. A simple example would be "Smile at a stranger". Then they can mark it complete and win coins with which they can use to buy real prizes.

However, because these tasks cannot be verified to see if the user has really completed them, I'm worried that people will just mark things as complete to win coins and get prizes without working for them. I used a fitness iphone game years ago where this was the case.

How do you suggest I prevent this from happening?

Edit: My first thought was to add a max amount of missions a user could do a day. Something like two. And let users that subscribe (so the more serious users) have limitless missions a day.

Thank you for the suggestions so far!


texts: My triangle disappears when multiplaying by my perspective projection matrix

texts:
Whenever I multiply my transformation matrix, which is passed to the shader via constant buffer, my triangle disappears. Here is the code for the passed matrix:

fast_matrix mat = transpose_matrix(
        rotation_z_matrix(0) *
        scale_matrix(1.0)*
        translation_matrix(vec3(0.0f, 0.0f, 0.f))*
        perspecitve_projection_matrix(800, 600, 0.5, 10)
        );

And here is the implementation of my perspective_projection_matrix:

fast_matrix perspecitve_projection_matrix(const uint32_t width, const uint32_t height,
        const float_t near_z, const float_t far_z)
    {
        fast_matrix proj;

        float_t d_near_z = 2 * near_z;

        proj.elements[0][0] = d_near_z / width;
        proj.elements[0][1] = 0;
        proj.elements[0][2] = 0;
        proj.elements[0][3] = 0;

        proj.elements[1][0] = 0;
        proj.elements[1][1] = d_near_z / height;
        proj.elements[1][2] = 0;
        proj.elements[1][3] = 0;

        proj.elements[2][0] = 0;
        proj.elements[2][1] = 0;
        proj.elements[2][2] = far_z / (far_z - near_z);
        proj.elements[2][3] = 1;

        proj.elements[3][0] = 0;
        proj.elements[3][1] = 0;
        proj.elements[3][2] = (-1 * near_z * far_z) / (far_z - near_z);
        proj.elements[3][3] = 0;

        return proj;
    }

All other functions like transpose_matrix work correctly and have been tested.

Here is my vertex shader:

struct VS_Out
{
    float4 cl : COLOR;
    float4 pos : SV_POSITION;
};

cbuffer CBuf
{
    matrix transform;
};

VS_Out main(float4 pos : POSITION, float4 col : COLOR)
{
    VS_Out vso;
    vso.pos = mul(transform, pos);
    vso.cl = float4(col.x, col.y, col.z, 1);
    return vso;
}

Vertex and index buffer:

{0, 0.5, 1, 1.f}
{0.5, -0.5, 1, 1.f}
{-0.5, -0.5, 1, 1.f}

{0, 1, 2}

Does anyone have an idea what may be wrong and how I can get my triangle to be rendered with perspective?


texts: I am almost complete developing a small indie-style multiplayer game. While I intend to allow people to cheat in single-player, this is obviously not acceptable in multi-player. Does anyone know of any ways to help stop the average Joe from using something like Cheat-Engine to modify parts of the game? I currently plan to have the client upload a MD5 hash of each setting file the game uses (stored as an XML) to the game server for verification every few seconds, but is there anything I can do to stop things like memory-editors, etc?


texts: My rhythm game runs choppy even with high frame rate

texts:
EDIT: [SOLUTION] I posted a possibly explanation for my issue below to anyone who has a similar problem. Hope it helps.

I'm coding a rhythm game and the game runs smoothly with uncapped fps. But when I try to cap it around 60 the game updates in little chunks, like hiccups, as if it was skipping frames or at a very low frame rate. The reason I need to cap frame rate is because in some computers I tested, the fps varies a lot (from ~80 - ~250 fps) and those drops are noticeable and degrade response time. Since this is a rhythm game this is very important.

This issue is driving me crazy. I've spent a few weeks already on it and still can't figure out the problem. I hope someone more experienced than me could shed some light on it. I'll try to put here all the hints I've tried along with two pseudo codes for game loops I tried, so I apologize if this post gets too lengthy.

1st GameLoop:

const uint UPDATE_SKIP = 1000 / 60;
uint nextGameTick = SDL_GetTicks();

while(isNotDone)
{

    // only false when a QUIT event is generated!
    if (processEvents())
    {
        if (SDL_GetTicks() > nextGameTick)
        {
            update(UPDATE_SKIP);
            render();
            nextGameTick += UPDATE_SKIP;
        }
    }
}

2nd Game Loop:

    const uint UPDATE_SKIP = 1000 / 60;
    while (isNotDone)
    {
    LARGE_INTEGER startTime;
    QueryPerformanceCounter(&startTime);

    // process events will return false in case of a QUIT event processed
    if (processEvents())
    {
        update(frameTime);
        render();
    }

    LARGE_INTEGER endTime;
    do {
        QueryPerformanceCounter(&endTime);
        frameTime = static_cast<uint>((endTime.QuadPart - startTime.QuadPart) * 1000.0 / frequency.QuadPart);
    } while (frameTime < UPDATE_SKIP);
    }

[1] At first I thought it was a timer resolution problem. I was using SDL_GetTicks, but even when I switched to QueryPerformanceCounter, supposedly less granular, I saw no difference.

[2] Then I thought it could be due to a rounding error in my position computation and since game updates are smaller in high FPS that would be less noticeable. Indeed there is an small error, but from my tests I realized that it is not enough to produce the position jumps I'm getting. Also, another intriguing factor is that if I enable vsync I'll get smooth updates @60fps regardless frame cap code. So why not rely on vsync? Because some computers can force a disable on gfx card config.

[3] I started printing the maximum and minimum frame time measured in 1sec span, in the hope that every a few frames one would take a long time but still not enough to drop my fps computation. It turns out that, with frame cap code I always get frame times in the range of [16, 18]ms, and still, the game "does not moves like jagger".

[4] My process' priority is set to HIGH (Windows doesn't allow me to set REALTIME for some reason). As far as I know there is only one thread running along with the game (a sound callback, which I really don't have access to it). I'm using AudiereLib. I then disabled Audiere by removing it from the project and still got the issue. Maybe there are some others threads running and one of them is taking too long to come back right in between when I measured frame times, I don't know. Is there a way to know which threads are attached to my process?

[5] There are some dynamic data being created during game run. But It is a little bit hard to remove it to test. Maybe I'll have to try harder this one.

Well, as I told you I really don't know what to try next. Anything, I mean, anything would be of great help. What bugs me more is why at 60fps & vsync enabled I get an smooth update and at 60fps & no vsync I don't. Is there a way to implement software vsync? I mean, query display sync info?

Thanks in advance. I appreciate the ones that got this far and yet again I apologize for the long post.

Best Regards from a fellow coder.


texts: Controlling player and camera movement in a 3rd person game with keyboard and mouse

texts:
In many action games with a third person view, joystick controls typically map the left joystick for player movement and the right joystick for camera movement (or more precisely camera's direction towards the character). With first-person games, mapping to mouse/keyboard is easy because the camera is directly influenced by the player's movement.  The player has to be able to look at any direction to point where he should go. Here is where the mouse comes in to provide this movement.

But the challenge I see is having separate camera and player controls with this setup. With a mouse/keyboard setup, it seems like I have to settle with a compromise, because the mouse is usually the only source for analog-like movement, whereas modern game pads have two sources, as separate joysticks.

One control scheme I had in mind is using A and D to change the player's heading as he travels through the world, leaving W and S to move forward/backward and the mouse free to move the camera. This still has a disadvantage, because you lack some degree to control how fast to change heading with the keyboard, unless you momentarily punch at the keys instead of holding them.

Is it possible to map the mouse and keyboard controls more intuitively for independent third person player and camera control?


texts:
I'm doing a 2D platformer but I don't know how they are usually built.

The approach I'm looking at is making it tilebased, with ground tiles on bottom row, then platforms on some places in "mid-air" within the array.

Then some physics to add gravity to pull the player down if airborn, and just scroll the map horizontally and check for collisions.

Am I on the right track? Thank you.


texts: Using collectable items to change a gameobject Unity

texts:
I’ve been working on a 2D platform side scroller. I’m rather new to Unity and C#.
Basically what I’ve achieved so far is a character which can collect Logs throughout the game and those logs are stored in an inventory (a simple count variable). Those logs can then be used to increase the values of Campfires. This is where the problem starts, I’m trying to figure out how to check the currentValue of the campfire and show a different sprite animation of the fire. (As shown below)

In short:

  Player gathers log (count += 1) -> if ( count > 0 && Player collides
  with (or in range of) Campfire && presses E -> Player is able to use
  log  { call throw_log_animation; count -= 1; currentValue +=25%; call
  new fireAnimation; }

  if Fire = 100% -> Player CANNOT use log. If Fire = 0% -> Game Over.

Collectable items code:

using UnityEngine;
using System.Collections;

public class CollectableItems : MonoBehaviour {

    private int count;
    public GUIText countText;

    // Use this for initialization
    void Start () {
        count = 0;
        setCountText ();
    }

    // OnTriggerEnter 2D
    void OnTriggerEnter2D(Collider2D other) {
        // If gameObject comes in contact with player
        if (other.gameObject.tag == "WoodStumps") {
            other.gameObject.SetActive (false);
            count += 1;
            setCountText ();
        }

        // If player comes in contact with gameObject
        if (other.gameObject.tag == "CampFire") {
            if (count > 0) count -= 1;
            else gameObject.SendMessage("No logs");

            setCountText ();
        }

    }

    void setCountText() {
        countText.text = "Count: " + count.ToString();
    }
}

If anything is unclear, don’t hesitate to ask. I’m looking forward to your solutions and idea’s!


texts: Which is better for mobile games, PNG or SVG?

texts:
I want to make several 2D games for mobile platforms, mainly using Qt for iOS, Android, Symbian, MeeGo and whatever supported by Qt.

I've made one game already using PNGs. Now I'm thinking of making a game similar to Battle Heart. What do you think is the best option, PNG files or SVG files or other formats?


texts:
I'm from a background of using OpenAL with other languages; and I'm on a project that benefits very much from Python. I remember PyAL, but it hasn't been updated since 2013 and my computer can't even find a copy of the package to download. I'm also aware of such relative-fringe packages as alpy and python-openal; but I'm hesitant to pick them up if they are also unmaintained. (Can't be sure yet.)

Is there a library that provides a Python binding to OpenAL? Or do I simply need to either write my own or make due with one of the other, non-3D-sound, packages? If getting it is more complicated than pip, how would I go about doing so?

Thanks.


texts:
I'm using the Unity as a physic simulation and I want to gather the data of object position from it. So I put my code about random the force and apply to that object. Also the part that Write the data into .csv format file. The sampling rate that I need is about 360Hz then i decided to set the FixedUpdate to 1/360 ~= 0.002777778. But once i use the DateTime to measure the sampling rate, The unity give the number of points(In my understanding is the number of time date FixedUpdate() have been run because file writing is also in FixedUpdate(). The sampling rate kinda jump between 210 to 410. Please correct me if i'm wrong using this way.
[#Note : I don't care about the low framerate because i just need the position from unity's Physx]
Here's my Time settings.

Here's my code to get the current time.
void Start()
{
...
DateTime startTime = DateTime.UtcNow;
DateTime currentTime = DateTime.UtcNow;
...
}

void FixedUpdate(){
...
WriteData()
PhysicsUpdate()
...
currentTime = DateTime.Utc.Now
print("#N Data : " + t + ", Elapsed time : " + (currentTime - startTime));

Here's my results that show the jumping of sampling rate :
The sampling rate each passing second periods are 223, 395, 392, 362 (This should close to 360 Data points)

Thank you.


texts: How to handle a Block World like Minecraft

texts:
I want to write a simple game with a block world like in Minecraft. My theoretical question is what is the best way to handle this block informations during playing. My first Idea was a huge array but this will cause running out of memory I think. Maybe I have to only load the blocks near the player.

How can I handle the loading of needed block informations from a file and the holding only of needed ones in memory?


texts: Reversing plane projection texture mapping algorithm

texts:
I found this algorithm in some old codebase, it takes two triangles from a mesh ABC and PMN, where ABC is the triangle that will be rendered and PMN is an extra triangle that is only used to generate the UV coordinate for ABC and is not rendered.
I am trying to create a reverse algorithm to calculate the PMN triangle positions based on UV coordinates of a triangle and ABC positions of the same triangle.
Vector3f A = /* stored in mesh data */;
Vector3f B = /* stored in mesh data */;
Vector3f C = /* stored in mesh data */;

Vector3f P = /* stored in mesh data */;
Vector3f M = /* stored in mesh data */;
Vector3f N = /* stored in mesh data */;

Vector3f PM = M.sub(P, new Vector3f());
Vector3f PN = N.sub(P, new Vector3f());
Vector3f PA = A.sub(P, new Vector3f());
Vector3f PB = B.sub(P, new Vector3f());
Vector3f PC = C.sub(P, new Vector3f());

Vector3f PMxPN = PM.cross(PN, new Vector3f());

// Calculate the U coordinates
Vector3f U = PN.cross(PMxPN, new Vector3f());
float Mu = 1.0F / U.dot(PM);
float Ua = U.dot(PA) * Mu; /* 1st U coordinate (for vertex A) */
float Ub = U.dot(PB) * Mu; /* 2nd U coordinate (for vertex B) */
float Uc = U.dot(PC) * Mu; /* 3rd U coordinate (for vertex C) */

// Calculate the V coordinates
Vector3f V = PM.cross(PMxPN, new Vector3f());
float Mv = 1 / V.dot(PN);
float Va = V.dot(PA) * Mv; /* 1st V coordinate (for vertex A) */
float Vb = V.dot(PB) * Mv; /* 2nd V coordinate (for vertex B) */
float Vc = V.dot(PC) * Mv; /* 3rd V coordinate (for vertex C) */

Formatted LaTex represention of the same algorithm:
$$
\vec{PM} = \vec{M} - \vec{P} \\
\vec{PN} = \vec{N} - \vec{P} \\
\vec{PA} = \vec{A} - \vec{P} \\
\vec{PB} = \vec{B} - \vec{P} \\
\vec{PC} = \vec{C} - \vec{P} \\
\vec{PMPN} = \vec{PM} \times \vec{PN} \\
$$
$$
\vec{U} = \vec{PN} \times\vec{PMPN} \\
Mu = \frac{1} {\vec{U} \cdot \vec{PM}} \\
Ua = \vec{U} \cdot \vec{PA} \times Mu \\
Ub = \vec{U} \cdot \vec{PB} \times Mu \\
Uc = \vec{U} \cdot \vec{PC} \times Mu \\
$$
$$
\vec{V} = \vec{PM} \times\vec{PMPN} \\
Mv = \frac{1} {\vec{V} \cdot \vec{PN}} \\
Va = \vec{V} \cdot \vec{PA} \times Mv \\
Vb = \vec{V} \cdot \vec{PB} \times Mv \\
Vc = \vec{V} \cdot \vec{PC} \times Mv \\
$$


texts: Creating a DPI and Resolution Independant GUI

texts:
How would one best go about it? Assuming I'm using OpenGL to do all the drawing.

It seems like the best approach is to have the GUI elements maintain the same physical size regardless of the screen it is displayed on.It seems that Windows will act as if you had a screen with 72 DPI regardless of its actual size unless you specifically request tell it that you handle high DPI cases. Which would greatly simplify things, does this hold for Linux as well?

Does things change between running things in Windowed mode versus fullscreen? It seems like it should, as the Window changes size depending on resultion while in fullscreen the image is always the same size, just with less or more density!


texts: How do you assign a value of different roles in a game design project?

texts:
A friend and I are building a game together and having a great time with it, and we hope to sell the product at some point. The prospects for actual earnings maybe be practically nil (and we aren't getting our expectations up), but regardless, we wanted to get some of the hard "profit splitting" questions out of the way.

Originally, my feeling was that we are both putting a full time effort into the game and would split the profits evenly. I am a programming and his role would be art and music/sound. Game design and concept generation is something we are both doing together. This has become complicated, as we are now looking at "hiring" a few other interested parties and we want to split any profit up fairly. We were looking at perhaps hiring another artist, and perhaps a sound person. We are not sure at this point what level of commitment our hired hands will be willing or able to commit.

So:

Our idea was to make a very large list of all tasks that need to be done across all categories (programming, marketing, art, sound, research, design, etc) and assign weighted values to each task based on the time requirement, difficulty/value of skill set required, and importance to the project.

Then, we can assign tasks to our hired hands and as they complete them, they would earn that percent of any profits that came in. My hope is that my original partner and I would divy up the "remaining" profit (the money our hired hands don't earn) equally when all is said and done. There's still a lot of details to work out, but our feelings were to divy things first into broad categories as follows:

14.81% - Marketing (PR, promotional campaigns, website)
 3.70% - Post-release support
18.52% - R&D (programming, tool development, engine development)
 7.41% - HR (hiring, dealing with any legal stuff, registering for digital distribution, etc)
18.52% - Art (all graphics and animations in the game)
11.11% - Sound (music + SFX)
18.52% - Game Design
 7.41% - Production (timesheet management, organizing meetings and project planning)

(The numbers are weird just because the calculated weights worked out that way)

I'm particularly interested in what others who has walked the same path as us feel. For the record, the game is a spin on the real-time strategic genre with a classic 16-bit look and feel.

Is this a sensible approach?
Are the numbers weighted reasonably in your mind? (I'm pushing for more value on game design and a little less on sound, myself)
How should be deal with changing requirements? We are estimating things as best we can currently, but we're all very new at this process, so there are sure to be areas we've over and underestimated.
Any generic advice appreciated!

Thanks everyone!


texts: How can I select an enemy to act next, biased toward smaller enemies?

texts:
Suppose there are X number of enemies in the game. They all have to attack one by one. Each enemy is picked randomly, and can be of Y size.

How can we attain biased randomness in such a way that small enemies are attacking more often than big ones?

My current algorithm is "pick any random enemy" no matter the size, and I'd like to improve on this.


texts: How to render a curved horizon when rendering terrain far away

texts:
For games with long view distance, it might look at bit weird when you fly high above the ground and the horizon is all flat.

So, how can I make a crumb/bend effect, when I fly high above the surface? Can this be done in the shaders?

If you're not sure what I mean, heres a picture:

A more clear example, though it might be captured with fish eye.

What would this best way to do this? I believe you could rotate and move (using transformationMatrix) all vertices a tiny little bit according to how far they are from the camera. But would this even create the desired effect, and would it be too resource extensive? Or maybe you know a whole another way to do it.


texts: How to find and manipulate a line on a mesh?

texts:
In Unity I currently have a script that allows me to "grab" a vertex, move it, and then update the mesh accordingly. How would I grab a line (which is basically grabbing two vertices I think) and move it?

I have read the manual (the scripting reference on Unity's site) but I can't really seem to figure out how to go about doing it. I got a lot of help with the initial script that lets me grab and move a vertex but I, unfortunately, am in need of guidance on how to extend its functionality to do what I described above.

For reference here are how things currently are working. Linked it because it says my gif is too big. Below is the functionality I'd like to add (hover over for text for further explanation).

So how would I go about doing this? Also for the sake of keeping my project stable, I'm using Unity 5.3.2f1 but converting new to old code shouldn't be that big of a deal (or so I hope). Also I'mn doing this all at runtime.


texts: How can I minimise memory thrashing when doing vector math in JavaScript or ActionScript?

texts:
Please note that a similar question has been asked before in the context of C#.

Say I'm building a 3D game in Javascript or Actionscript, and doing a lot of 3D vector math. In current libraries, every operation causes a new object to be created and returned as the result value. What is a simple way to optimize this?

For example in this snippet, 2 new Vector3D objects are created, one at the divide and one at the multiply operator.

// JS
result = v.divideBy(len1).multiplyBy(len2);

A better approach would be creating a single object and reusing it.

// JS
var _temp = {x:0, y:0, z:0};  // create a single object once
....
v.divideBy(len1, _temp);       // re-use it
_temp.multiplyBy(len2, _temp); // re-use it

In C# you could just use structs, but in languages like JS and AS3 there are no such things. What does one do to minimise object creation in such  languages?

Edit: For example currently I'm doing BSP partitioning in the browser, and its very slow during the BSP operation. (I have profiled to confirm this) I have discovered that the major cause is vector math, and the GC that occurs often that also causes stutters.

Edit: Please note that my question can apply to any type of object in general, not just vector math. So when I'm creating millions of objects as a return value of any function, performance would be affected. Therefore, I am looking for better design patterns to solve the very common issue of returning multiple values.


texts: How do I separate model positions from view positions in MVC?

texts:
Using MVC in games (as opposed to web apps) always confuses me when it comes to the view.  How am I supposed to keep the model agnostic of how the view is presenting things?

I always end up giving the Model a position that holds x and y but invariably, these values end up being in units of pixels and that feels wrong.  I can see the advantage* of avoiding that but how am I supposed to?

This idea was suggested:

  Don't think of it in units of pixels, think of them in arbitrary distance units that just happen map to pixels at a 1:1 ratio. Oh, the resolution is half of what it was? We are now taking the x/y coordinates at 50% value for screen display, and your spells casting range is still 300 units long, which now is 150 pixels.

But those numbers conveniently work out.  What do I do if the numbers divide in such a way that I get decimal places?  Floating points are unsafe.  I think allowing decimal places would eventually cause really weird bugs in my game.

*It'd let me write the model once and write different views depending on the device.


texts:
Some days ago, I've felt a need to add a camera to my game, it's a puzzle. That would let me move the board, zoom in and etc. This gave me control to do boards muuuch larger, soon, more complex puzzles.

But today when i was implementing such a toolbar, I've found which problems the camera gave me too.

In logic, it is simple. I want the toolbar to be fixed, and the board be free. That is, when I zoom in, the board zoom, but the toolbar stays.

My camera code look as follows:

    public void Camera::draw(GL10 gl) {
    gl.glMatrixMode(GL10.GL_PROJECTION); // Select the projection matrix
    gl.glLoadIdentity(); // Reset the projection matrix
    gl.glOrthof(0.0f, width * zoom, 0.0f, height * zoom, 0.0f, 1.0f);

    // Translating
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glTranslatef(-position.X, -position.Y, 0);
}

Very simple, but stills functional.

To draw a scene I do the following:

public void Game::draw(GL10 gl) {
    camera.draw(gl);
    currentLevel.board.draw(gl);
}

I've came with the problem to add the toolbar.

public void draw(GL10 gl) {
    toolbar.draw(gl);
    camera.draw(gl);
    currentLevel.board.draw(gl);
}

I've thought about letting it came first than the camera draw, so it would be fixed. I was wrong.

Nice images examples for you:

A normal board

The effect expected for zoom in, just the board zooms

The effect that i got when i zoom in everything zooms, even the draw that came before the camera.

You can think of this as a camera that supports HUD. I saw people solving this by using a scale factor instead of using glOrthof. But this would mess all my coordinate system. Are there any other alternative for me? If so, how can I implement it?


texts:
I'm trying to integrate Farseer into my XNA game.
Since I'm using an EntityComponentSystem approach, I've added the Body inside a component and added it to the players' components.

One thing I'm struggling with is that I don't know how to control "collision rules".

For example,

I want Players to colide with other Players/Walls, but not move them on contact, which is what happens when I set BodyType = BodyType.Dynamic.

I want players to be able to block other players, but I what happens now is that if a player remains still, if another player runs into them, they move, physically, which is not the kind of behavior I want.

I move them by giving them a LinearVelocity, and then when I Step the World, I set the players' position to their Body's position. I tried changing BodyType = BodyType.Static, but that removed the collision between the players.

I know that if it was Unity, I'd give the object a BoxCollision2D and a RigidBody2D and it'd behave like I want. I guess that what I'm missing is the RigidBody part of the collision, but how can I implement it in Farseer?


texts: Can someone provide a practical example of decoupling game world updates from frame redraws in iOS?

texts:
Please bear with me as I've been spending some time lately trying to get a better grasp of some game dev fundamentals. My specific issue is a direct result of trying to apply what I've read about here: When should I use a fixed or variable time step?

I understand that a common option is to write your game framerate-dependent and be done with it. However, once you mix in SKAction's or physics bodies, this seems like a good way for things to get out of sync. For example, one scenario I can think of is something like an endless runner where the earth is moving beneath you at a steady rate (.position.x -= someDistance) mixed with other objects whose positions are updated with a [SKAction moveTo: duration:], or physics bodies whose positions are updated by applying a force/impulse.

So it makes sense to me that the solution to this problem is to decouple game world updates from frame redraws. This means not using [SKScene update:] for world updates and instead coming up with your own game loop.

So I guess my question is twofold. Am I on the right track or am I off-base with any of my assumptions? Does Sprite Kit have a game loop set up outside of [SKScene update:] that is redraw independent, and whose resolution I can specify, that I can leverage? NSTimer has turned out to be way too inaccurate in my tests. Specifically a practical example would be great.


texts: Entity to tile collision detection (C++, SDL)

texts:
I'm currently trying to handle collisions between entities and a tilemap, but I've hit a problem. My tiles are stored simply as integer tile IDs in a multidimensional array, and I wanted to perform a quick collision check by working out which tile the player is on (or will be on if the new position is valid), by simply dividing the player's position by the tile size to get the x,y of the tile in question. After this, I'd perform a simple SDL_Rect collision check between the tile's rect and the entity's.

The problem of course is that depending on which direction I'm moving in, I may want to add the entity's width/height to the x,y position of the entity when working out which tile I'm on, otherwise the collision would only apply to the top left corner of the entity. I tried to do this myself, but couldn't produce consistent results. I didn't think it would be difficult, but I'm obviously missing something.

In my situation, my entity sprites are 32x32, while tiles are 16x16. Is it possible that using tiles that are smaller than my entity is making it more of a problem than it might otherwise be?

Thanks in advance for any help you can offer in suggesting a working solution.


texts: How can I determine the extreme color values in a texture?

texts:
I am looking for a way to determine the most extreme color values for all of the texels in a texture. So for a texture consisting only of black and white texels, the extreme values should be (0,0,0) and (1,1,1) expressed in RGB format. For a color gradient from red to green I should get the values (1,0,0) and (0,1,0).

Now obviously I could do this on the CPU by iterating over all the pixels/texels of the texture and keeping track of the color values found to be most apart from each other, but this is probably relatively slow, so I am looking for a way to do this using the GPU/shaders.

Is this possible using shaders? I am not experienced with GPGPU, so a solution in HLSL/GLSL would be preferred. Or maybe there is a fast algorithm I could use on the CPU?


texts: I have a simple sun flare that I would like to appear on my directional light (sun). However I cannot see the flare, I have tried setting the ignore layers to everything and checked and double checked that there is a flare layer on my camera. The light is also rotating constantly as I have a day/night cycle too if that means anything for the flare... Anyway, could someone show me how to fix this?


texts: HaxeFlixel, Font gets fuzzy android upscale

texts: I made a simple game for android with a small native resolution (320x480). When text gets upscaled it loses its sharpness. Tried having anti aliasing on and off and both results were fuzzy. The size of the text is 16 (read that with some fonts the size should be dividable by 8). Also tried different fonts, but had the same result. Any solutions to that?


texts: Collision Resolution of Axis-Aligned Bounding Boxes that Change Size

texts:
I am developing an action platformer in Python, with Pygame. That said, my question is a general one about collision resolution strategies.

I use an axis-aligned bounding box for the purposes of collision detection. The bounding box changes sizes depending on the sprite's action and the frame of the action's animation.

When I update my sprite's position, I first update the y-coordinate, check for and resolve collision in the y-direction, then do the same for the x-coordinate. When I resolve collision, I simply move the bounding rect's sides to align flush with the appropriate walls.

Because the bounding rect changes sizes throughout my animations, I am noticing buggy behavior in certain situations when the frame moves from a smaller one to a larger one. The change of frame results in the sprite intersecting a wall and his position is resolved such that he falls off the map.

Here is a diagram illustrating the problem:

It doesn't matter whether I resolve in the x-direction or the y-direction first. They result in reciprocal buggy behavior when the next frame is wider or taller, respectively.

My question concerns general collision resolution strategies for axis-aligned bounding boxes that change size and shape. What are the best algorithms for collision resolution that avoid this issue?

Here are some of the functions and values I have access to:

colliderect -- tests if two rectangles collide
collidepoint -- boolean that tests if a point collides with a rectangle
rect.topleft, rect.topright, rect.bottomleft, rect.bottomright, rect.center,
rect.centerx, rect.centery -- various points on the rectangles
rect.left, rect.right, rect.top, rect.bottom -- values for the sides
of the rects
various vectors
in short, the usual stuff

Apologies if this question is a dupe. I imagine it is a pretty common one, though I couldn't find anything that helped me specifically.


texts: THREE.ShaderMaterial cannot perform antialiasing

texts:
I created a ShaderMaterial to draw a box in three.js using the following key code:

//magnetic orientation
let magnetMaterial = new THREE.ShaderMaterial({
    uniforms: { orientation: { value: new THREE.Vector3(1) } },
    vertexShader: `varying vec3 vPos;
void main() {
    vPos = position;
    gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
}`,
    //https://stackoverflow.com/questions/15688232/check-which-side-of-a-plane-points-are-on
    fragmentShader: `#extension GL_OES_standard_derivatives : enable
varying vec3 vPos;
uniform vec3 orientation;
void main() {
    float a = dot(orientation, vPos);
    gl_FragColor = vec4(step(a, 0.), 0, step(0., a), 1.0);
}`});

See also online Demo. Even if I set WebGLRenderer.antialias to true, there's a heavy aliasing if the box is not axis-aligned.

I found Point Sampled AA  and How do I implement anti-aliasing in OpenGL?, but I didn't how to do?

In addition, the custom shader cannot work with the light if any. In order to make custom color work with the built-in effect (light). I want to try post-processing via EffectComposer.

Can anyone help me out?

Related:

Add scene lights to custom vertex/fragment shaders and shader materials?
the last shader I added point lights
threejs Adding lighting to ShaderMaterial
How do you “combine”a ShaderMaterial and LambertMaterial?


texts: How to create bullet hole decals in Godot engine?

texts:
How can you create decals such as bullet holes in Godot?
Godot doesn't seem to have any native method of creating decals.
I am trying to create decals so that bullet holes will be displayed properly on curved and angled surfaces and corners.
I have tried a few plugins, but none of them worked, they all either had a texture stretching issue or they didn't work at all.
For example, when I tried using the Screen Space Decals plugin (https://godotengine.org/asset-library/asset/241), it did draw decals when a texture wasn't provided (a simple black rectangle by default), but when I assigned the bullet hole texture to the decal property the bullet holes became invisible.
What would be an ideal method of creating decals in Godot?


texts:
I am making a simple browser rpg game, similar to battleknight. To keep the game simple, I have just Strength, Constitution, and Luck. But as luck is random based, I'm struggling with fight calculations. I need some kind of formula to calculate attacks.

Preview from battleknight

UPDATE
I was thinking about this model:

Strength - base dmg.

speed - chance of attack avoidance

toughness - increase HP

luck - crit. hit chance

defence - chance of attack blocking.

As I expect, there will be fight between high and lower ranked players so I want to calculate attack differently. My idea is sum of stronger player stats(this will be cap). So random based attributes will be divided by this sum. Example:

cap = sumOfStrongerPlayerAttributes
player1Luck = player1.luck / cap
player2Luck = player2.luck / cap
// also luck can be devided for ensure that crit hits will not be so often

Also crit. hit dmg. will be calculated from based dmg. like:

critHitDmg = player.strength * someKindOfConst

This model will prevent from too often crits. And player who will spend all his resources to level up luck, will have low stamina, defence or base dmg (which is also important for crit. hit dmg)


texts:
I need to make a feature in WebGL, where I have horizontal list of meshes (example 20) and I want to show only 3 and 2 at edge are fade in/fade out. And it slowly animates from one side no another (sliding to left or right).

Here is a sample code, how it is done using CSS. (https://jsfiddle.net/jqsLh4vg/91/)
What would be possible options to have this kind of effect?

My current approach, what I am trying (could be not the most perfomant solution):

Calculate visible area
Calculate how much visible area (in percentage) each mesh is visible in visible area on each render

Draw gradient using frag shader at the edges (here it is were I stucked and can't figure out the solution)

But maybe there is easier approach for this kind of effect? (Image if I have 100 elements and I need to manually calculate their visible area on each render time).


texts:
My code keeps crashing at runtime, I have done some creative debugging and determined that it was the glGenVertexArrays that was causing the crash, I've looked around and come across some answers that told me to enable experimental mode in GLEW but that didn't work, as far as I can tell my graphics card supports it, my opengl version is 3.1. I'm using freeGLUT and GLEW

here's the code, the line in question is 45
http://hastebin.com/rekizejuza.cpp

std::cout << "made it here\r\n";
glGenVertexArrays(1, &meshID);
std::cout << "not here here\r\n";
glBindVertexArray(meshID);


texts: PyBullet & OpenGL - Rotations are reversed in OpenGL

texts:
Project description: I am writing a basic game engine to help with my PhD topic on multi-agent learning. I am using PyBullet as the backend physics engine and OpenGL for visual display. I have OpenGL buffers set up to hold the object information such as position(vec3) and rotation(matrix4x4) with rotations being done using Quaternions, but are stored using Euler angles for convenience.
My problem is that when I rotate an object in the OpenGL game world (around any axis), the pyBullet rotation (as seen from the pyBullet GUI) is in the opposite direction and sometime completely off. I must be missing something quiet basic and I apologies if this is a simple fix. I have also provided a video to show the issue that I am having - link to video of error (Link to video):
When I extract the rotation from PyBullet using getBasePositionAndOrientation() and convert the quaternion to Euler angles using pybullet.getEulerFromQuaternion(), the result is the correct vec3, but upon conversion to the rotation matrix pybullet.getMatrixFromQuaternion(), it seems to reverse the rotation direction.
Please see my code below:
'obj = Class BaseSceneObject'
'action = Euler rotation angle in degrees to apply vec3(x, y, z) e.g.(1., 0., 0.) apply +1 degree rotation to x-axis'

'Collect current position and rotation of object and update PyBullet'
# get the rotation - euler angles in degrees vec3(x,y,z)
rot = obj.get_rotation()
# add rotation action (e.g. +1 degree to x = vec3(1., 0., 0.)) and convert to radians
rot = math.radians(rot[0] + action[0]), math.radians(rot[1] + action[1]), math.radians(rot[2] + action[2])
# convert rotation from euler to quaternion
quat = pybullet.getQuaternionFromEuler(rot)
# update position and orientation
pybullet.resetBasePositionAndOrientation(bodyUniqueId=obj.get_rigid_body_id(),
                                         posObj=obj.get_position(),
                                         ornObj=quat)

'Collect PyBullet results and update OpenGL'
# get position and rotation from PyBullet
position, rotation = pybullet.getBasePositionAndOrientation(bodyUniqueId=obj.get_rigid_body_id())
# update object position
obj.set_position(position=position)
# convert rotation quaternion to euler angles
rot_r = pybullet.getEulerFromQuaternion(rotation)
# convert radians to degrees
rot_d = math.degrees(rot_r[0]), math.degrees(rot_r[1]), math.degrees(rot_r[2])
# construct OpenGL object rotation matrix
rot_m_final = numpy.identity(4)
rot_mr = numpy.array(pybullet.getMatrixFromQuaternion(rotation)).reshape(3, 3)
rot_m_final[:3, :3] = rot_mr
# update OpenGL rotation matrix
obj.set_rotation(rotation=rot_d,
                 rotation_matrix=rot_m_final)

Thank you for reading this and I hope that you can help me.


texts:
I have the following four gameObjects, they have, respectively, the rotations: -90, 0, 90, 180. I want them to move as denoted in the image below

This is what I got so far:

public class Projecttile : MonoBehaviour
{
    public float speed;

    private void Update()
    {
        transform.Translate(transform.up * speed * Time.deltaTime);
    }
}

The result of my code is the following:

Why does my code result in this outcome, and how can I make each gameObject move in the direction it's facing?


texts: Movement on tile map when player is the size of 4 tiles, moving in 1 tile increment

texts:
I understand how to move a square around a tile map: you have a coordinate of the square (say the center), and if they player press the "up" arrow, just increment the y-coordinate by 1.

Question: How should I think about tile based movement when the player is the size of 4 squares, and still moves in 1 square increment? E.g. if the player get into a tank, and the tank is now a 2 by 2 block. Would it be significantly different?

I suppose I would have to keep track of the 4 tiles my player's tank is in. And when he presses "up", I would have to check if the forward 2 tiles are empty, then increment all 4 tiles' y-coords by 1.


texts: Is multipass rendering possible with SpriteBatch?

texts:
I'm trying to implement a bloom effect. This requires three shader passes: a brightness threshold, a horizontal blur, and a vertical blur. It also requires resizes, but these are irrelevant to the question. I've also omitted the threshold, as the problem lies in the blurs.

Now, I've read that HLSL passes are just syntactic sugar for different shaders, and that switching between them is about as expensive as setting a new effect to the GraphicsDevice. Still, I prefer to keep them in one .fx file.

The passes:

    pass Pass0
    {
        PixelShader = compile ps_2_0 PS_Threshold();
    }
    pass Pass1
    {
        PixelShader = compile ps_2_0 PS_BlurHorizontal();
    }
    pass Pass2
    {
        PixelShader = compile ps_2_0 PS_BlurVertical();
    }

The blurring code:

        private void Blur(SpriteBatch SpriteBatch, RenderTarget2D Source, RenderTarget2D Rendertarget1, RenderTarget2D Destination)
        {
            // Blur pass 1
            Contents.BloomEffect.CurrentTechnique.Passes["Pass1"].Apply();
            SpriteBatch.GraphicsDevice.SetRenderTarget(Rendertarget1);
            SpriteBatch.GraphicsDevice.Clear(Color.Black);
            SpriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, Contents.BloomEffect);
            SpriteBatch.Draw(Source, Rendertarget1.Bounds, Color.White);
            SpriteBatch.End();

            // Blur pass 2
            Contents.BloomEffect.CurrentTechnique.Passes["Pass2"].Apply();
            SpriteBatch.GraphicsDevice.SetRenderTarget(Destination);
            SpriteBatch.GraphicsDevice.Clear(Color.Black);
            SpriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, Contents.BloomEffect);
            SpriteBatch.Draw(Rendertarget1, Destination.Bounds, Color.White);
            SpriteBatch.End();
        }

Finally, the Draw loop:

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.SetRenderTarget(RT1);
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, bloom);
            spriteBatch.Draw(android,
                             new Rectangle(0, 0, 258, 294),
                             Color.White);
            spriteBatch.End();

            Blur(spriteBatch, RT1, RT11, RT1);

            GraphicsDevice.SetRenderTarget(null);
            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, null, null, null);
            spriteBatch.Draw(RT1,
                RT1.Bounds,
                Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }

The output, however, is as follows:

It's obvious what happens: the last pass is applied twice. I've tested the passes individually by snipping them out of the shader, and they work fine. Is EffectPass.Apply() simply not meant to be used with SpriteBatch, or is there another way to change what passes are applied (without putting the passes in different .fx files)?

This has all been in XNA. To make this even weirder, when I do the same thing in Monogame the opposite occurs: the shader will only use Pass0. However, I'm converting the shader to OpenGL there, so that might be a conversion quirk.

EDIT: I fixed this by putting the different passes in different techniques, and switching techniques instead of passes. That doesn't answer the original question though, so I'll leave it open.


texts: Creating metadata/pack files for an existing sprite sheet

texts:
I've just bought Oryx's Roguelike Tileset pack and I use LibGDX (flixel-gdx to be precise).

My question is, given this pre-made sprite sheet format, what's the best way to integrate the sprites into the game I'm making?

LibGDX uses TexturePacker, but that needs a special .pack file with metadata like where the sprites are located. I can't see a way to generate these from an existing spritesheet.

Is there any other recommended technique?


texts:
I'm trying to regenerate stamina at a rate of 1 per second using Time.deltaTime, however this doesn't do anything (My 'current stamina' doesn't change at all). I've done some looking around and I have tried Time.fixedDeltaTime. Also tried Time.time, but that just regenerated all my stamina in under a second.

Here is my code:

var max_stamina : int = 100;
var cur_stamina : int;
var staminaRegenRate : int = 1;

function Update(){
    //regen
    if(cur_stamina < max_stamina){
        cur_stamina += staminaRegenRate * Time.deltaTime;
        Debug.Log("Second has passed");
    }
}

What am I doing wrong?


texts: Why do built versions of my multiplayer game act different than the version I run in the editor? (Unity / Mirror)

texts: When loading saved data from a client's PC, it act's different to how my game, running in the editor works. Saved data is only being loaded on the version being played in the editor. Without any specifics, could anyone explain some differences between the editor version of a game and the built version because I was under the impression that they were the exact same.


texts: How to attach a framebuffer to a whole cube map from a GL_TEXTURE_CUBE_MAP_ARRAY?

texts:
I'm trying to make shadow cube maps in an array.  I want to draw each shadow map with a single pass using a geometry shader, which I read about here: https://stackoverflow.com/questions/462721/rendering-to-cube-map.  But in that example, the cube map is not in an array, and I can't find any code examples of how to get a cube map from an array attached to a frame buffer.

Just to make sure my array is legit, here's how I made it:

glGenTextures(1, &shadowMapArray);
glActiveTexture(GL_TEXTURE0 + TEXTURE_UNIT_SHADOW_MAPS_POINT);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, shadowMapArray);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_DEPTH_COMPONENT, POINT_LIGHT_SOURCE_SHADOW_MAP_RESOLUTION, POINT_LIGHT_SOURCE_SHADOW_MAP_RESOLUTION, (POINT_LIGHT_SOURCE_MAX_SHADOW_MAPS * 6), 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);

And this is how I tried to make the frame buffer:

    //Create the shadowMapFrameBuffer
    glGenFramebuffers(1, &shadowMapFrameBuffer);
    glBindFramebuffer(GL_FRAMEBUFFER, shadowMapFrameBuffer);
    glDrawBuffer(GL_NONE);

    //Attach the shadow map to the shadowMapFrameBuffer
    glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowMapArray, 0, shadowMapIndex);

    GraphicsResources::checkGLFramebufferStatus();
    glBindFramebuffer(GL_FRAMEBUFFER, 0);

But it looks like glFramebufferTextureLayer is only going for a layer-face, not a layer (a whole cube map), so only the first face (positive X) of the first shadow map is working, (and, for some unknown reason, only half of that face).

I also tried this:

    glFramebufferTexture3D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, shadowMapArray, 0, ((shadowMapIndex * 6) + 0));
    glFramebufferTexture3D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, shadowMapArray, 0, ((shadowMapIndex * 6) + 1));
    glFramebufferTexture3D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, shadowMapArray, 0, ((shadowMapIndex * 6) + 2));
    glFramebufferTexture3D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, shadowMapArray, 0, ((shadowMapIndex * 6) + 3));
    glFramebufferTexture3D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, shadowMapArray, 0, ((shadowMapIndex * 6) + 4));
    glFramebufferTexture3D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, shadowMapArray, 0, ((shadowMapIndex * 6) + 5));

But I don't know if a frame buffer is meant to be set up with multiple calls like that, and anyway, this produces 'GL_INVALID_ENUM'.

Anyone know the proper way to do this?


texts: Windows Class Library vs XNA Class Library

texts: I'm going to start a library in C# for Navigational Meshes. I would like to use it in both WPF/Winforms and in XNA. Can I create a windows class library and still use it in XNA?


texts: Get type of the object where attribute was declared - Hide In Derived Inspector Attribute

texts:
I want to implement a custom Unity inspector attribute, like usual ones [HideInInspector] or [Range(0, 100f)].

This attribute should hide a field from the inspector if it's inherited from a base type, rather being defined directly in the type of the object we're inspecting.

So, for example, if I have these classes...

public class Enemy : MonoBehaviour {
    [SuperField]
    public int EnemyHealth;
}

public class GiantMonster : Enemy {
    [SuperField]
    public int Armor;
}

then the inspector for a base Enemy should show a control for the EnemyHealth variable, but when inspecting a GiantMonster we should not see a control for this variable.

So far I have my attribute:

public class SuperFieldAttribute : PropertyAttribute {}

which has its own PropertyDrawer:

[CustomPropertyDrawer(typeof(SuperFieldAttribute))]
public class SuperFieldDrawer : PropertyDrawer {

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
        // ...
    }
}

Inside OnGUI I need to access/find the type where the field we're drawing was declared with the [SuperFieldAttribute].

So if SuperFieldDrawer.OnGUI() is called for the SerializedProperty corresponding to GiantMonster.EnemyHealth, I should be able to determine that the type where EnemyHealth was declared is Enemy and not GiantMonster. (I'll use this to hide the field so it's not drawn)

And if SuperFieldDrawer.OnGUI() is called for the SerializedProperty corresponding to GiantMonster.Armor, I should be able to determine that the type where Armor was declared is GiantMonster itself. (Meaning I should proceed and draw the field)

So far I've found ways to access the type of the component we're inspecting, but not the type where the field was first declared, so that's the missing piece I need to fill in.

It's OK if I use reflection and so on; any method is good, performance isn't a concern.


texts: Why is my performance so poor when accessing elements in an unordered_map?

texts:
I'm trying to implement a component based architecture on a game engine project. Each GameObject has an unordered_map that holds a pointer to Component base class. At this point, I only have one component derived class, which is the Transform class. I wanted to implement this component based architecture similar to the Unity's convention: I want to get a component of game object by calling the member template function like GetComponent<Transform>().

Here are the headers:

Component.h

enum type{
    TRANSFORM   // more will be added later
};

class Component // base class
{
public:
    Component() : _owner(NULL) {}
    virtual ~Component(){}
    static type Type;

protected:
    GameObject* _owner;
};

Transform.h

class Transform : public Component
{
public:
    Transform();
    ~Transform();
    static type Type;

    void Rotate(float deg);

    // to be encapsulated later on
    Vector2D _position;
    float _rotation;
    Vector2D _scale;
};

GameObject.h

class GameObject
{
public:
    GameObject();
    ~GameObject();

    void Update();
    //and more member functions

    template<class T>
    T* GetComponent();
private:
    // some more private members
    unordered_map<type, Component*> _componentList; // only 1 component of each type
};

template<class T>
T* GameObject::GetComponent()
{
    return static_cast<T*>(_componentList[T::Type]);
}

My initial implementation used std::vector for keeping Component* and the application ran at 60 fps (I also have a frame rate controller, which just limits the FPS to 60). When I changed to the unordered_map for accessing those component pointers, the performance went downhill to 15 FPS.

I only draw two quads and I call GetComponent<Transform>() only 6 times per frame at this point, so there is not much going on in the scene.

What I tried?

I tried to use const char*, std::string, type_info and finally enum type as key values for the unordered_map but nothing really helps: all implementations got me 15-16 FPS.

What causes this performance issue? How can I isolate the issue?

 I hope I provided enough detail, feel free to ask for more code if necessary


texts: Getting error when I Send a message to the RaycastHit object

texts:
I have created a shooting game, here when I am shooting I have a c# script for damage for enemies.I have Used Raycast to Shoot enemies.if the RaycastHit becomes an enemy, it will be deducted it's health.It works properly.But the thing is, If I shoot objects except enemies it causes an error.
I have provided some details about that.this is the script,

public class DamageSMG : MonoBehaviour
{
    public int DamageAmount = 5;
    public float TargetDistance;
    public float AllowedRange = 50;
    public RaycastHit Shot;
    public int Firing;
    void Update()
    {
        if(Input.GetButton("Fire1")){
            if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward),out Shot))
            {
                TargetDistance = Shot.distance;
                if (TargetDistance < AllowedRange)
                {
                    if (Firing == 0)
                    {
                        Deduct();
                    }
                }
            }
        }
    }
    public void Deduct()
    {
        Firing = 1;
        Shot.transform.SendMessage("DeductPoints", DamageAmount);
        StartCoroutine(Wait());

    }
    IEnumerator Wait()
    {
        yield return new WaitForSeconds(0.1f);
        Firing = 0;
    }
}

I am using an machine gun.therefore I have created Script to fire coutinously with 0.1sec break.When I press Fire1 button, The RayCastHit Object is received a message where the method called DeductPoints with the DamageAmount.As this Script my enemies are deduct point 5 by 5 every hit.Then Destroy the object.The Enemy script is this.

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

public class EnemyScript : MonoBehaviour
{
    public int EnemyHealth = 20;
    void DeductPoints(int DamageAmount)
    {
        EnemyHealth -= DamageAmount;
    }

    // Update is called once per frame
    void Update()
    {
        if (EnemyHealth <= 0)
        {
            Destroy(gameObject);
            GlobalScore.GlobalScorecount += 1;
        }

    }

}

But my problem is when I shoot objects except Enemies(Ex: walls),The console gives an error.The error is like this
SendMessage DeductPoints has no receiver
How can I solve this error or is there any other way of Deducting enemy health with raycast?
I can play the game with this error in UnityEngine.but it is not possible to Build the game.Please help me to Solve this..


texts: 2D Physics library for multiplayer in c++

texts:
Im trying to create a top down shooter with multiplayer functionality.
So far im using Box2D for my physics Simulation.

The last few days I played around with syncing movement between Clients and Server without box2d. I now feel like Box2d might be too complex for my rather simple needs(players are the only moving bodys, the Rest of the scene consists of static polygons) and after reading online it seems like Box2D isnt the best pick to sync physics over a network.

Especially when thinking about implementing client side prediction and entity interpolation where I have to manually correct values and interpolate between others I feel like box2d might be more of a Problem then a help.

As I noted my physics Simulation isnt too complex(just polygon-polygon intersection and raycasting) and so im currently thinking about implementing the physics myself so I have complete controll over it.

Maybe somebody here has already used box2d and networking or can point me to another library? Maybe im wrong and box2d is the best solution for networked 2d physics? :D

What about my idea of implementing the physics myself?


texts: I need advice on creating animal 3D walk cycles in XNA

texts:
I want to purchase a number of 3D models from TurboSquid and animate them in an XNA game.

I wrote a lot of games from 1985-1999 and have recently become involved with XNA. Now I would like to port one of my old games to the XBOX. I do have a background in 3D animation; but that was years ago.

What is the current method for animating a walk cycle with a 3D model and using it inside XNA?

Is there a book, software or a tutorial that you can recommend?

Thanks in advance and sorry for such a broad and currently naive question.


texts: I am new to game design and i am creating a MMORPG that allows players to create 2d avatars that can be customized. If i had lets say a male character model (no equipment no armor). How would i handle body variation for this male model? If this has been answered please provide link. I know layering customizing for equipment and armor has but not morphing the character sprite itself.


texts: How to tap a square and draw "Cross (X)" on tic-tac-toe for iibGdx

texts:
I am having much difficulty trying to figure out how to draw the cross in the square of where the person just touched.

I have made a class called 'CellPositions', by making 9 invisible squares around my board Texture; Example of CellOne...

public CellOne cellOne;

public CellPositions(Board board) {
    load(board);
}

public void load (Board board) {
    cellOne = new CellOne(board);

}

public class CellOne {
    public Rectangle square = new Rectangle();

    public CellOne (Board board) {

        square.x = board.boardRect.x;
        square.y = (board.boardRect.y + board.boardRect.height) - (board.boardRect.height / 3);
        square.width = board.boardRect.width / 3;
        square.height = board.boardRect.height / 3;
    }
}

I have made a 'Controller' class to handle my input and a 'Renderer' class to handle rendering images to the game.

What I want to do is draw the "Cross" on the square the person touched. For eg. if he/she touches the first square - cellOne - how would i render my "cross" to that specific square.

I've tried making a class called "Cross" and made the x and y coordinates Gdx.input.getX() and Gdx.input.getY(), but the 'cross' was not in the square, but intersecting the lines.

Please help! I am trying to get used to libGdx by making a simple game like tic-tac-toe, but it's really not so simple when trying to draw your cross on a certain square.

Here is my board class for further info

private TextureRegion reg;
public Rectangle boardRect;

public Board () {
    init();
}

private void init () {
    reg = Assets.instance.board.boardRegion;
    boardRect = new Rectangle();
    boardRect.set((Constants.SCREEN_WIDTH / 2) - (340 / 2), 15,
            340, 340);

}

public void render (SpriteBatch batch) {
    batch.draw(reg, boardRect.x, boardRect.y,
            boardRect.width, boardRect.height);
}

I have made my screen width and height be 480x480.


texts: Is implementing your own scripting language viable?

texts:
I am coding a beat 'em up game in C++ and the time has come to implement scripting for events, triggers, cutscenes etc.
I have read around on the internet and gotten a fair bit of information. My first choice solution would be to implement my own scripting language like the one in Cave Story.
I have seen this suggested but most poeple suggest lua but that does not seem to fit my type of programming.

Have you made your own scripting language? Why did you chose to roll your own instead of using an existing one? What resources did you consult during the development?


texts: How to know the adresses an editor modifies while saving a file

texts:
I hope this question belongs here.

Suppose an editor for a specific file extension. It usually has a user friendly interface so you don't see raw data. Once you edit anything and save the editor modifies some data. Is there any way to keep track of these changes and see which specific data is modified?
This is motivated by the fact that an editor is a program that has its limitations and sometimes it does not allow some changes. This protects the original file from fatal damage. As an example suppose a .nes file that can be edited through the HEX editor or a "level" editor. I might not know the ROM address where some level information is stored but (i guess) the "level" editor knows. So I can edit, save and search the region of the ROM, with the HEX editor, that was modified. That would give me information on where this level data is stored and be able to understand it.

My system is Windows so I wonder if there is any "save register" that keeps track of this save operations. Or is it an editor specific thing and each one has its own way of saving data, meaning i should look into the editor's code more than a general Windows place?

Thanks,

PD: I'm sorry if I misunderstood something essential but I'm not experienced with how this precesses work.


texts: Creating an Array of 1s and 0s (with all 1s touching)

texts:
I am a novice programmer trying to add an unnecessary and complicated element to a text adventure!  ...and I've run into a question I am not sure how to research further (I suspect due to lack knowledge of the proper terminology).

I am working on a small text adventure that uses an 11x11 array. Player is capable of moving into spaces with a 1 and incapable of moving to a 0. I need to a) retain the outer boundary 0s, b) randomize the content inside the border, and c) ensure that there is a linked path of 1s that will eventually connect to a 2 (the exit):

0 0 0 0 0 0 0 0 0 0 0
0 1 1 0 0 0 0 1 0 0 0
0 0 1 1 1 1 1 1 1 1 0
0 0 1 0 0 0 0 0 0 1 0
0 0 1 1 1 1 1 1 1 1 0
0 1 1 0 1 0 1 0 0 0 0
0 1 0 0 1 0 1 0 0 0 0
0 1 1 1 1 0 1 1 1 2 0
0 0 0 1 0 0 1 0 0 0 0
0 0 0 0 0 0 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0

I'd appreciate any pointers here - not sure what direction I should be looking in. Thinking of scrapping this feature so if it's not viable I don't mind hearing that :) Thanks for reading.


texts: Create vector based on length, angle and origin vector

texts:
I have been trying to come up with a function that allows me to take in an origin vector, angle, and a length I want to be between the old and new vector, but I can't wrap my head around it.

The function requires the angle input to be a 3D vector that is normalized and needs to look something like this.

glm::vec3 CreateAngledVector(glm::vec3 origin, glm::vec3 angle, float length)
{
    angle = glm::normalize(angle);

    ...
}

If anyone has any suggestions on how I can achieve this, I'd be happy to hear them.

Edit
I've managed to make it so I can create angles on a 2D plane on all 3 dimension but I can't figure out how to rotate it on two planes at the same time.

glm::vec3 CreateAngledVector(glm::vec3 start, glm::vec3 axis, float angle, float length)
{
    axis = glm::normalize(axis);

    glm::vec3 output = axis;
    output = glm::rotate(output, (angle*DEG2RAD) * axis.z, glm::vec3(1.0f, 0.0f, 0.0f));
    output = glm::rotate(output, (angle*DEG2RAD) * axis.x, glm::vec3(0.0f, 1.0f, 0.0f));
    output = glm::rotate(output, (angle*DEG2RAD) * axis.y, glm::vec3(0.0f, 0.0f, 1.0f));

    output *= length;
    output += start;
    return output;
}

Using this function I can create circles using the following.

int loops = 180;
float angle_part = 360.0f / loops;
glm::vec3 axis = glm::vec3(1.0f, 0.0f, 0.0f);
for (int i = 0; i < loops; i++)
{
    glm::vec3 new_vector = CreateAngledVector(l1.position, axis, angle_part*i, 1.0f) ;
    ...
}

The state before the function works fine creating angled vectors on a 2d plane (end goal is to make circles) but when I attempt to turn the axis of the function to go into 3D such as glm::vec3 axis = glm::vec3(1.0f, 1.0f, 0.0f); It breaks the function (see example)

axis = glm::vec3(0.0f, 1.0f, 0.0f)

axis = glm::vec3(0.0f, 0.0f, 1.0f)

"Broken one" axis = glm::vec3(1.0f, 1.0f, 0.0f)


texts: Problems with texture orientation in space

texts:
I am currently drawing texture in 3D space and have some problems with it's orientation.

I'd like me textures always to be oriented with front face to user.

My desirable result looks like

Note, that text size stay without changes when we rotating world and stay oriented with front face to user.

Now I can draw text in 3D space, but it is not oriented  with front but rotating with world.

Such results I got with following shaders:

Vertex Shader

uniform vec3 Position;

void main()
{
    gl_Position = vec4(Position, 1.0);
}

Geometry Shader

layout(points) in;
layout(triangle_strip, max_vertices = 4) out;

out vec2 fsTextureCoordinates;

uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;
uniform sampler2D og_texture0;
uniform float og_highResolutionSnapScale;
uniform vec2 u_originScale;

void main()
{
    vec2 halfSize = vec2(textureSize(og_texture0, 0)) * 0.5 * og_highResolutionSnapScale;
    vec4 center = gl_in[0].gl_Position;
    center.xy += (u_originScale * halfSize);

    vec4 v0 = vec4(center.xy - halfSize, center.z, 1.0);
    vec4 v1 = vec4(center.xy + vec2(halfSize.x, -halfSize.y), center.z, 1.0);
    vec4 v2 = vec4(center.xy + vec2(-halfSize.x, halfSize.y), center.z, 1.0);
    vec4 v3 = vec4(center.xy + halfSize, center.z, 1.0);

    gl_Position =  projectionMatrix * modelViewMatrix   * v0;
    fsTextureCoordinates = vec2(0.0, 0.0);
    EmitVertex();

    gl_Position =  projectionMatrix * modelViewMatrix   * v1;
    fsTextureCoordinates = vec2(1.0, 0.0);
    EmitVertex();

    gl_Position =  projectionMatrix * modelViewMatrix   * v2;
    fsTextureCoordinates = vec2(0.0, 1.0);
    EmitVertex();

    gl_Position =  projectionMatrix * modelViewMatrix  * v3;
    fsTextureCoordinates = vec2(1.0, 1.0);
    EmitVertex();
}

Fragment Shader

in vec2 fsTextureCoordinates;

out vec4 fragmentColor;

uniform sampler2D og_texture0;
uniform vec3 u_color;

void main()
{
    vec4 color = texture(og_texture0, fsTextureCoordinates);

    if (color.a == 0.0)
    {
        discard;
    }
    fragmentColor = vec4(color.rgb * u_color.rgb, color.a);
}

Any ideas how to get my desirable result?

EDIT 1:

I make edit in my geometry shader and got part of lable drawn on screen at corner. But it is not rotating.

..........

    vec4 centerProjected = projectionMatrix * modelViewMatrix * center;
    centerProjected /= centerProjected.w;

    vec4 v0 = vec4(centerProjected.xy - halfSize, 0.0, 1.0);
    vec4 v1 = vec4(centerProjected.xy + vec2(halfSize.x, -halfSize.y), 0.0, 1.0);
    vec4 v2 = vec4(centerProjected.xy + vec2(-halfSize.x, halfSize.y), 0.0, 1.0);
    vec4 v3 = vec4(centerProjected.xy + halfSize, 0.0, 1.0);

    gl_Position =  og_viewportOrthographicMatrix * v0;

..........


texts: Calculate gravity between two intersecting bodies

texts:
I've been working on a 2D gravity simulator for some time and I'd like to add some surrealism to it by creating planets that can't collide with other planets (passing right through them).

The problem is, as distance between two bodies approaches zero, gravity goes to infinity - causing planets to slingshot when they're intersecting. Stopping gravity from being applied for a pair of bodies as soon as they touch looks odd as their velocity will suddenly go from accelerating to constant until they get to the other side.

Is there a function that gives me the best of both worlds or should I just leave the planets not being affected by gravity while intersecting other bodies?


texts:
I am trying to add ssao effect to a visualization application but there are errors in resulting image. I am using code from https://github.com/nvpro-samples/gl_ssao .
Errors occur in rapidly changing lighting near the edges of screen.

Only change to code was to remove basic shading and passing only white from scene.frag shader so the error could be seen more pronounced. I also added obj input to import sponza scene but the error is visible with the included sample scene as well if camera is moved close to object.
As is this implementation only enables viewing objects in relative distance. Moving closer to objects brings up this errors.

What causes this error and is there fix.


texts: Should players be required to find story clues to advance in the current playthrough (if they have already played the game)?

texts:
I am making a fairly simple game. I would like to know if players should be required to find story clues to advance in the current playthrough (if they have already played the game).

For example, let's say someone needs to find a password late in the game to unlock a door that has been visible since the beginning of the game, allowing them entry into one of the final areas of the game. If someone has already played the game and already knows the password, should they be able to skip the majority of the game by quickly entering the password in the beginning, or should they be required to work their way through the game and find the password before the door can be accessed?

For major games, which approach is more common?

Also, I would like this game to be able to be speedrun-able. Would a speedrun be boring if the fame used the first approach of being able to skip most of it by using the password?


texts: Should I sync animations from the server to the client or let the client play its own animations?

texts: For example, if the user presses the "Fire" button which leads to the player character doing some kind of animation, should the client evaluate itself if it can play the animation or wait for a response from the server telling it that it's ok to play the animation?


texts: Cuda API to render using Physically Based Rendering (PBR) in OpenGL-ES based project

texts:
I need to develop a OpenGL-ES based application to render a model using Physically based Rendering (PBR).
Do I need to use Cuda API to render the computation intense PBR rendering?
Is there any performance advantage of using CUDA in the OpenGL-ES project for PBR?


texts: How can the player open this door and have its collision physics stay in sync?

texts:
I just finished modeling a scene in Blender like this:

Now I'm animating and creating interactions between the player and the objects inside the house. When I reached the doors, I started having doubts.
Originally, I created the doors animations using Blend Shapes to easly control the transition between the open/close states and to allow the door being half opened or closed. (That's because my interaction system allows to interact partially with object, like for example the door system at Amnesia The Dark  descent / outlast)

The trouble is, that the collider of the doors doesn't update when the Blendshapes values changes.
How can the player open this door and have its collision physics stay in sync


texts: Set rotation on single axis with provided angle using Quaternion

texts:
I am using a Quaternion to represent the rotation of some object, and I would like to allow the user to rotate it about a single axis at a time using textbox, so he would write the angle that the object is rotated by (ex. at X-axis), then the object rotation is set to that rotation.
I know that, this operation q1 * q will rotate q by q1, but I don't know how to set the rotation at a single axis, Could any one help me to complete this function?

public void SetRotationX(float Angle)
{

}


texts: Automating repetitive game development tasks

texts:
Disclaimer: this is an open-ended and kinda "far out" question

Over the last few years I've made a few iPhone games.  I use very common programs like Xcode and Illustrator to make the games.

Lately I've become tired of repeating certain tasks over and over again.  Here are some examples:

in Xcode: "clean target, build, run" over and over again
in Xcode: delete image resources and then import updated image resources (identical names)

I'd like to automate these tasks in Xcode.  Any ideas?  I've done some automation in Photoshop using the "button mode" thing where you record a macro... that's been very useful.

Here's the kinda wacky or "far out" part of the question:  how can this automation be done via voice commands?  (perhaps using a Nuance product or something)

Here's an example of what I'd love to do via a few voice commands:

Save artwork from illustrator at a user-specified size (@2x versions as well)
Delete "someArt.png" and "someArt@2x.png" from Xcode
Add the updated versions of someArt.png to Xcode
In Xcode:  clean target, build, and run

I know this question probably seems bizarre...  but something like this could make certain things substantially easier for game developers.

Edit: wonder if a combination of AppleScript and Nuance might work?


texts: Bad FPS for smaller size (OpenGL ES with SDL)

texts:
If you saw my other question, well, there is still a little problem:

Click here to watch on youtube

Basically, the frame rate is very bad on the actual device, where for some reason the animation is scaled (it looks like the left side on the video). It is quite fast on the simulator where it is not scaled (right side).

For a test, I submitted this new changeset that simply hard-codes the smaller size (in SDL_CreateWindow() and in glViewport()), and as you see in the video, now it is slow even in the simulator (left side shows the small size, right side shows the original size -- otherwise the code is the same).

I'm clueless why it's soooo slow with a smaller galaxy, in fact it should be FASTER.

The question is not about general speed optimization like reducing screen resolution or joining glBegin(GL_POINTS)/glEnd() blocks.

Update: For a test, I simply reduced the screen size to 320x480 and compiled it to OS X desktop -- got the same speed as with 800x800, so this size-specific slow-down is on iOS only. Will post this on the SDL mailing list now.


texts: Implementing Online Leaderboards for indie windows PC Game

texts:
I've just finished my game and I'd like to add some ranking functionality to it. I have a mySQL database running on my website and want to be able to insert and retrieve data from it. My knowledge in server side programming is basic to none and I'm wondering if you could provide me some tips on how to approach this. My game was developed in C++.

1) Should I look for I library written in C/C++ that handles this client/server communication directly?

OR

2) Should I implement it through a script (say python) and somehow interface it through my C++ code. By interfacing I imagine I'd call .py passing in a string as argument, and somehow receiving a string as return. (table entries, error messages, etc). Also I don't want anyone messing up with the database. I don't know, the source code would be there with connection authentication and I assume anyone knowing python could adjust it to inject any value in the database. Well, If that is a good approach what libraries could I use to interface C and Python (or any other say Java).


texts:
No matter what frameworks we use -- Core Graphics, Cocos2D, OpenGL ES -- to write games, should a timer be used (for games that has animation even when a user doesn't do any input, such as after firing a missile and waiting to see if the UFO is hit)?

I read that NSTimer might not get fired until after scheduled time (interval), and CADisplayLink can delay and get fired at a later time as well, only that it tells you how late it is so you can move the object more, so it can make the object look like it skipped frame.  Must we use a Timer?  And if so, what is the best one to use?


texts: What would be the best way to find an open space in a level?

texts:
I'm working on a 2D game where you use paint to add tiles to a level and right now I'm working to add warp tiles. I have it set up so certain direction-oriented paints use two points (a start and end) to determine which direction the tiles will point (left, right, up, down.) The warp tiles have these points, but they'll be added to two other lists (warp start and end). The way the warps work is: if the player hits one tile they'll be teleported to the corresponding warp tile. Now, if I'm going to get this to work properly, I need to make it so the player can't be teleported into a wall or off the map. So I need to move the point to an open tile exactly one space away from any walls.

What would be the best way to do this?


texts:
First of all this is not a discussion for the best place to put credits, but rather where it's allowed.

So for instance is it fine if I just include a credits.txt file in the install directory, or will I have to make an in-game place where you can read them.

And is there any general rules, or is it up to the individual which need credit?


texts:
I am developing an iphone app.
It has following page structure,
1.List of game levels in a UITableView
2.Game page

I use "UIViewAnimationTransitionFlipFromRight" between pages

Game page has 3 views, One is a scrollView in that my game grid is drawn.
Game grid is a sub class of UIView ,that added to Scrollview.
To support zooming i use CATiledLayer to draw the grid(20*20).

MY problem is GameGrid shows white or last played puzzles grid contents for a few seconds and then refresh(flashing) to the new content.

My GameGrid class as follows

`

 @implementation GameGrid

+(Class)layerClass
{
 return [CATiledLayer class];
}

 - (id)initWithFrame:(CGRect)frame {
        if ((self = [super initWithFrame:frame])) {
           CATiledLayer *tempTiledLayer = (CATiledLayer*)self.layer;
           tempTiledLayer.levelsOfDetail = 5;
           tempTiledLayer.levelsOfDetailBias = 2;
              self.opaque=YES;
           }
             return self;
}

-(void)drawRect:(CGRect)r
{
 //empty
}

-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context
{
 // here i am drawing grid
// filling rect
 // lines
// string etc..
}


texts: Story dialogues: user controlled or script driven?

texts:
I'm currently working on the animations that present the story.

Right now my animations are scripted. They allow me to dictate the pace of the scene. My dialogue bubbles expire on a simple "time per char" system or scripted time where needed.

I was wondering that maybe i should let the user control the flow with a click for each major frame. This gives him the time he needs to read and process the dialogue.

But that breaks the flow.
For example: when i want to create agitation, dialogues are really fast, barely readable etc.. Important stuff on the other hand is slow.

So my question is, what would your approach and why? Generally speaking. What do users prefer in these cases?

Platform is phones, scenes are presented in the same env as game engine, with characters only walking and talking.