texts: Rotate a UI Image exactly 360 degrees over the course of 1 second?

texts:
I have a UI Image that I want the user to click and have it rotate 360 degrees once on the z axis.  I can get it to rotate through a coroutine but I'm having trouble making it stop once it is started.

public void getInputClick()  // OnClick method for UI object
{
    foreach (Transform child in EventSystem.current.currentSelectedGameObject.GetComponentsInChildren<Transform>())
    {
        if (child.gameObject.name == "Lock")  //Making sure this is an object that should rotate becasue it has a child named "Lock"
        {
            if (rotating == false) //enable coRoutine if not already rotating
            {
                runRotationRoutine = true;
            }
            break;
        }
    }

}

void Update()
{
    if (runRotationRoutine == true)  //Listening for coRoutine execution directive during update.
    {
        StartCoroutine(rotationRoutine());
    }
}

IEnumerator rotationRoutine()
{
    runRotationRoutine = false;  // make sure update doesnt try to run the coroutine more than once!
    rotating = true;  // bool signifying that rotation is currently happening.

    while(rotating == true)
    {
        imageObject.transform.Rotate(rotationVector);
        yield return null;

        //  This works but rotates forever because the coroutine is never terminated.

        //  How do I make this stop after the object has rotated 360 degrees????

        //  Something like (when current rotation == starting rotation --->  set rotation = false
        // But how would I determine this?
    }

}

It needs to be a coroutine because there are a lot of other things executing simultaneously.  I feel like it should be pretty simple to just tell it to only rotate around once, what am I missing here?


texts:
In Unity, can I load a local (/Resources folder) website to safari on an ipad?
This works fine on a Mac, opening up a wepage from my Resources folder.

string path = "file://"+(Application.dataPath)+"/Resources/testsite.html";
    void OnGUI(){
        if(GUI.Button(new Rect(20, 20, 100, 100), "site")){
           Application.OpenURL(path);
        }
    }

but when I try to load this on an iPhone or iPad, it doesn't seem to work.
Am I accessing the address incorrectly for iOS using "file://"?
If this is not possible, is there an alternative way I can load a locally stored website on an iOS device?


texts: How to perform collision detection in 3D space?

texts:
I've got to write, what can be summed up as, a complete 3D game from scratch this semester. Up until now I have only programmed 2D games in my spare time, the transition doesn't seem tough, the game's simple. The only issue I have is collision detection. The only thing I could find was AABB, bounding spheres or recommendations of various physics engines. I have to program a submarine that's going to be moving freely inside of a cave system, AFAIK I can't use physics libraries, so none of the above solves my problem.

Up until now I was using SAT for my collision detection. Are there any similar, great algorithms, but crafted for 3D collision? I'm not talking about octrees, or other optimizations, I'm talking about direct collision detection of one set of 3D polygons with another set of 3D polygons. I thought about using SAT twice, project the mesh from the top and the side, but then it seems so hard to even divide 3D space into convex shapes. Also that seems like far too much computation even with octrees.

How do professionals do it? Could somebody shed some light.


texts: (love2d)How would I go about drawing the same image multiple times?

texts: Obviously I could just copy and paste a love.image.draw() function multiple times for how many times I want the item to be drawn, but lets say I wanted to draw an image wherever the mouse is clicked at. How would I go about making it so it draw said item every time I clicked. If I only clicked twice it would draw two objects, and if I clicked it 500 times it would draw 500 items, without having to have 500 different draw functions?


texts: What is the mesh generation technique shown in Chrome Music Lab?

texts:
The Google toy of the day, https://musiclab.chromeexperiments.com/Spectrogram, features a continuously scrolling 3D render of a shape with cross sections that seem to equal the spectrograph of sound at a single instant.

Assuming the frequency information is available as input, how does that information become a mesh that updates continuously?


texts: Is it possible to find the child body involved in a collision of a compound shape?

texts:
I am noob at using bullet physics. I am using it for collison detection and I want to create a compound body to represent a ship. However, in my game I need to know which part of the ship was hit.

The contact manifolds only have the collision objects in other words the compound body. The contact manifold does not have the child body that collided.

Thank you


texts: GML: check ds_queue or ds_stack for equality (identical contents)

texts:
Is there a nondestructive way to check whether two queues or stacks contain identical values? For example:

foo=ds_queue_create();
ds_queue_enqueue(foo, 1);
ds_queue_enqueue(foo, 2);

bar=ds_queue_create();
ds_queue_enqueue(bar, 3);
ds_queue_enqueue(bar, 1);
ds_queue_enqueue(bar, 2);
ds_queue_dequeue(bar);

return(equality_test(foo, bar));

should return true

Options I know of:

foo == bar returns false, presumably because it's checking whether they point to the same queue as opposed to having the same values.
ds_queue_write(foo) == ds_queue_write(bar) seems to be sensitive to the queues' histories. If I just enqueue [1,2] on each queue, it gives true. But because I added and then dequeued an irrelevant value on bar, the serialized strings differ even though the current values are identical.
Iterating through the items one at a time and checking equality works for arrays, but doing this using ds_queue_dequeue destroys the queues. Is there a nondestructive way to read elements of a queue, other than the head and tail?
Per liggiorgio's comment below, I could duplicate the queues with ds_queue_copy and destructively iterate over the duplicates -- is this the best way?

As far as I know the same issues apply to stacks.


texts: XNA graphics.PreferredBackBufferWidth's new value doesn't immediately change window size

texts:
I set the width and height of the window in my game constructor, and then pass the graphics manager to a class to check the value. In the game's initialize function, it doesn't seem to recognize the new width and height values, so it uses the default.

Here's relevant code:

Game1.cs Constructor:

graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 1600;
graphics.PreferredBackBufferHeight = 900;
Content.RootDirectory = "Content";
World = new TestWorld(Content, graphics);

Game1.cs Initialize

World.Initialize();

TestWorld Initialize

Debug.WriteLine(Graphics.GraphicsDevice.Viewport.Width);

The TestWorld Initialize outputs the default (800).

I have tried graphics.ApplyChanges(), but it does not resolve the issue.


texts: Unity - Adding a sphere volume to this shader

texts:
I'm trying to create a spherical effect around my player that when they walk into range of hidden object, it gradually renders the object.

I found a shader that would work pretty well for this. When applied to an object, that object doesn't render, but when the object is brought into range of a cube shaped volume (by default it's located at the world origin) it renders.

Shader "Custom/ClipVolume" {
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0

        // Expose parameters for the minimum x, minimum z,
        // maximum x, and maximum z of the rendered volume.
        _Corners ("Min XZ / Max XZ", Vector) = (-1, -1, 1, 1)
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200

        // Allow back sides of the object to render.
        Cull Off

        CGPROGRAM

        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input {
            float2 uv_MainTex;
            float3 worldPos;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;

        // Read the min xz/ max xz material properties.
        float4 _Corners;

        void surf (Input IN, inout SurfaceOutputStandard o) {

            // Calculate a signed distance from the clipping volume.
            float2 offset;
            offset = IN.worldPos.xz - _Corners.zw;
            float outOfBounds = max(offset.x, offset.y);
            offset = _Corners.xy - IN.worldPos.xz;
            outOfBounds = max(outOfBounds, max(offset.x, offset.y));
            // Reject fragments that are outside the clipping volume.
            clip(-outOfBounds);

            // Default surface shading.
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = c.a;
        }
        ENDCG
    }
    // Note that the non-clipped Diffuse material will be used for shadows.
    // If you need correct shadowing with clipped material, add a shadow pass
    // that includes the same clipping logic as above.
    FallBack "Diffuse"
}

Issue 1: I want this effect to be spherical so that it looks like it radiates from the player. I followed some signed distance and volumetric rendering tutorials to create the sphere, but I can't seem to hook that in with my existing shader (most likely because I'm very new to creating shaders).

Issue 2: I can't seem to figure out how to move the volume with my player. I can get the volume to shift in the inspector using the vector4 coordinates, but I can't get my player's position to translate in a way that uniformly moves the volume.

Can someone give me some tips or examples on how I can shape and move this volume?

Any help would be greatly appreciated!


texts: How to save boolean to player prefs in Unity?

texts:
I'm making a player settings thing where the user can turn off or turn on the game music by clicking buttons. I had this script below and everything was working fine.
 private GameObject music;

 public void Start()
 {
     music = GameObject.FindGameObjectWithTag("Music");
 }
 public void YesButton()
 {
     music.SetActive(true);
 }

 public void NoButton()
 {
     music.SetActive(false);
 }

I want to save it as player preferences so when they go out and back into the game, their settings would be saved. How would I do this? This is what I tried:
 private GameObject music;
 private bool musicOn = true;

 public void Start()
 {
     music = GameObject.FindGameObjectWithTag("Music");
 }

 public void YesButton()
 {
     musicOn = true;
     PlayerPrefs.GetInt("MusicOn", (musicOn ? 1 : 0));
 }

 public void NoButton()
 {
     musicOn = false;
     PlayerPrefs.GetInt("MusicOn", (musicOn ? 1 : 0));
 }

 void Update()
 {
     PlayerPrefs.SetInt("MusicOn", (musicOn ? 1 : 0));

     int value;

     value = musicOn ? 1 : 0;

     if (musicOn)
     {
         value = 1;
         music.SetActive(true);
     } else if (!musicOn)
     {
         value = 0;
         music.SetActive(false);
     }
 }

But it doesn't work. When I click the "no" button, the music turns off but it turns back on when I go back into the game. How would I fix this problem? Thanks for your help!
New code that mostly works:
public GameObject music;
public bool musicOn = true;

public void Start()
{
    music = GameObject.Find("Music");
    bool musicOn = PlayerPrefs.GetInt("MusicOn", 0) > 0;
    if (musicOn)
        YesButton();
    else
        NoButton();
}

public void YesButton()
{
    music.SetActive(true);
    PlayerPrefs.SetInt("MusicOn", 1);
}

public void NoButton()
{
    music.SetActive(false);
    PlayerPrefs.SetInt("MusicOn", 0);
}


texts: Android cocos2d removing a sprite after animation

texts:
I have an object going across the screen with an animation using the following code:

CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("ninjastar.plist");
CCSpriteSheet projectileSheet = CCSpriteSheet.spriteSheet("ninjastar.png");
addChild(projectileSheet);
ArrayList<CCSpriteFrame> projectileSprites = new ArrayList<CCSpriteFrame>();

for (int i = 1; i <= 4; i++) {
    projectileSprites.add(CCSpriteFrameCache.spriteFrameByName("ninjastar" + i + ".png"));
}

CCAnimation projectileAnimation = CCAnimation.animation("throw", 0.1f, projectileSprites);
CCSprite projectile = CCSprite.sprite(projectileSprites.get(0));
CCAction projectileAction = CCRepeatForever.action(CCAnimate.action(projectileAnimation, false));
projectile.setPosition(CGPoint.ccp(winSize.width + (projectile.getContentSize().width / 2.0f), actualY));
    actionMove = CCMoveTo.action(actualDuration, CGPoint.ccp(-projectile.getContentSize().width / 2.0f + 320, actualY));
projectileSheet.addChild(projectile);
projectile.setTag(1);
_projectiles.add(projectile);
CCCallFuncN actionMoveDone = CCCallFuncN.action(this, "spriteMoveFinished");
CCSequence actions = CCSequence.actions(actionMove, actionMoveDone);
projectile.runAction(actions);
projectile.runAction(projectileAction);

I'm using "spriteMoveFinished" to remove the sprite once it is done going across the screen:

public void spriteMoveFinished(Object sender) {
CCSprite sprite = (CCSprite)sender;
_projectiles.remove(sprite);
sprite.stopAllActions();
removeChild(sprite, true);
}

However, when the sprite gets to the end of the screen it just stays stuck there on the last frame. How do I remove it completely?


texts: Cross-platform, free (for commercial use) C/C++ 2d game library or rendering engine?

texts:
I need a C/C++ engine that should be really cross platform (or at least windows, android, and iphone).

The 2d engine should be written in C or (better) C++, should permit the rendering of animated sprites, permit transparency, collisions (but I can integrate box2d for that), rotations (eventually with opengl support to accelerate things), handle tile-based games. If it could be a game engine (with support for events/actions, scripting and generally have the features needed when developing a 2D game) it would be fantastic.

There are a lot of open source free 2d engine out there, but soon or later you find that:

the documentation is not so good and/or the tutorials are not so good (or there are no tutorial at all), the examples are missing (or are too few or are missing)
the community is too small and not so supportive
the engine doesn't abstract system things enough. That is bad, because you
soon find out that there is support for X and Y but not Z. With abstraction, you can use even Z adding system specific code
the engine is a game engine but does not have an associated editor. scripting is good, but an editor would save a lot of time I think
the engine writers have spent too much time to develop a complex (that will probably fails) compilation tools.

It would be useful to have something that:

#define WIN_PLATFORM
#define IOS_PLATFORM
#define ANDROID_PLATFORM
#define UNKNOWN_PLATFORM

In that way, using an empty implementation of the relevant interfaces, you
can simply code what you need

6 . You come to the conclusion that usually there is not a sufficient conceptual separation from what really needs to be abstracted and what can be supposed to be found on almost all systems (e.g. opengl).

Ok. The question is, regarding a free, open source 2D rendering engine or a 2D rendering engine+2D game engine for at least iOS and Android: in your experience, what would be a good/wise choice?


texts: How can I quickly determine whether objects are onscreen in 2D?

texts:
Currently, I have this in each object's renderer's update method:

        float a = transform.position.x * Main.scale;
        float b = transform.position.y * Main.scale;
        float c = Camera.main.transform.position.x * Main.scale;
        float d = Camera.main.transform.position.y * Main.scale;
        onscreen = a + width - c > 0 &&
                a - c < GameView.width &&
                b + height - d > 0 &&
                b - d < GameView.height;

transform.position is a 2D vector containing the game engine's definition of where the object is. This is then multiplied by Main.scale to translate that coordinate into actual screen space.

Similarly, Camera.main.transform.position is the in-engine representation of where the main camera is, and this is also multiplied by Main.scale.

The problem is, as my game is tile-based, thousands of these updates get called every frame, just to determine whether or not each object should be drawn. How can I do this more efficiently, please?


texts: Get VertexSize of Instance in VertexShader

texts:
I'm using Unitys DrawProceduralIndirect function to directly render the content of a ComputeShader.

I setup the argumentBuffer for this function as follows:

    int[] csArgs = new int[] { ptsOnLine, 2, 0, 0};
    argsBuffer = new ComputeBuffer(4, 4, ComputeBufferType.IndirectArguments);

So every instance consists of ptsOnLine (lets say 10) vertices.

My vertexShader then looks like this:

fsInput vert(uint id : SV_VertexID, uint instanceId : SV_InstanceId)
{
    fsInput fsIn;
    float3 worldPos = linePoints[id + (instanceId * 10)];
    fsIn.pos = mul(UNITY_MATRIX_VP, float4(worldPos, 1.0f));
    return fsIn;
}

The question is simple. My problem is: (instanceId * 10). Is there a built in variable telling me the length of one instance? I couldn't find anything. I mean, its in the argument buffer so it shouldn't be too much of a problem? I could forward this value from the compute buffer but thats ugly. :)

Help is much appreciated!


texts:
I have recently been trying to learn how to make Unity games through Lynda.com using the tutorials provided by Jesse Freeman. But I have one issue, he doesn't explain any of the coding. This bit has me confused.

Body2D.AddForce (new Vector2 (forceX, forceY));

1.) Why is Body2D (this is a variable) separated by AddForce with a .?

2.) Why does a new vector2 have to be created?

3.) My last question isn't quite in the code itself but why must we add a () to methods?

(Full Code)

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

public class Player : MonoBehaviour {

public float Speed = 2.5f;
public Vector2 MaxVelocity = new Vector2 (5, 10);

private Rigidbody2D Body2D;
private SpriteRenderer Renderer2D;

// Use this for initialization
void Start () {
    Body2D = GetComponent<Rigidbody2D> ();
    Renderer2D = GetComponent<SpriteRenderer> ();

}

// Update is called once per frame
void Update () {
    var absValX = Mathf.Abs (Body2D.velocity.x);

    var forceX = 0f;
    var forceY = 0f;

    if (Input.GetKey("right")){
        if (absValX < MaxVelocity.x) {
            forceX = Speed;
        }
    } else if (Input.GetKey("left")) {
        if (absValX < MaxVelocity.x){
            forceX = -Speed;
        }
    }
    Body2D.AddForce (new Vector2 (forceX, forceY));

}


texts:
I'm worried about this Caution box from the Box2d manual:

  Box2D is tuned for MKS units. Keep the size of moving objects roughly between 0.1 and 10 meters. You'll need to use some scaling system when you render your environment and actors. The Box2D testbed does this by using an OpenGL viewport transform. DO NOT USE PIXELS.

I don't want to use OpenGL since I know nothing about it. I'm using SFML to render my game.


texts: Collisions in other sides on pong in python

texts:
Im trying to create pong in python, so far Ive set up correct collisions on the right paddle but upon just trying to reverse the code to work with the other side it refuses to work, simply glitching and holding the ball in its axis somehow, anyone know how to help?`

from processing import *

ball = {
    'x': 50,
    'y': 50,
    'velocity_x': 3,
    'velocity_y': 3,
    'radius': 10
}
width = 550
height = 400

paddle1 = {
    'x': width - 20,
    'y': 160,
    'width': 15,
    'height': 100,
    'velocity': 5,
    'move': 0
}
paddle2 = {
    'x': width - 545 ,
    'y': 160,
    'width': 15,
    'height': 100,
    'velocity': 5,
    'move': 0
}
score = 0
def setup():
    # set the size of the canvas
    size(width, height)

def draw():
    # clear the previous frame by setting the background color of the canvas
    background(0, 0, 0)

def drawPaddle1():
    fill(0, 0, 255)
    rect(paddle1['x'], paddle1['y'], paddle1['width'], paddle1['height'])

def drawPaddle2():
    fill(0, 255, 255)
    rect(paddle2['x'], paddle2['y'], paddle2['width'], paddle2['height'])

def checkCollisions1():
    global score
    if ball['y'] >= paddle1['y'] and ball['y'] <= paddle1['y'] + paddle1['height']:
        if ball['x'] + ball['radius'] >= paddle1['x']:
            ball['velocity_x'] = -ball['velocity_x']
            ball['x'] = paddle1['x'] - ball['radius']

def checkCollisions2():
    global score
    if ball['x'] >= paddle2['x'] and ball['x'] <= paddle2['x'] + paddle2['width']:
        if ball['x'] + ball['radius'] >= paddle2['x']:
            ball['velocity_x'] = +ball['velocity_x']
            ball['x']
            ball['x'] = paddle2['x'] + ball['radius']

def drawBall():
    fill(255, 255, 255)
    ellipse(ball['x'], ball['y'], 2 * ball['radius'], 2 * ball['radius'])

def moveBall():
    ball['x'] = ball['x'] + ball['velocity_x']
    ball['y'] = ball['y'] + ball['velocity_y']
    if ball['y'] + ball['radius'] >= height or ball['y'] - ball['radius'] <= 0:
        ball['velocity_y'] = -ball['velocity_y']
    if ball['x'] + ball['radius'] >= width or ball['x'] - ball['radius'] <= 0:
        ball['velocity_x'] = -ball['velocity_x']

def draw():
    # clear the previous frame
    background(0, 0, 0)
    fill(255, 255, 255)

    drawBall()
    moveBall()
    drawPaddle1()
    drawPaddle2()
    checkCollisions1()
    checkCollisions2()

run()`


texts:
i'm currently trying to work out some 3d picking code that I started years ago, but then lost interested the assignment was completed (this part wasn't actually part of the assignment).

I am not using the mouse coords for picking, i'm just using the position in 3d space and a ray directly out from there.  A small hitch though is that I want to use a cone and not a ray.

Here are the variables i'm using:

float iReticleSlope = 95/3000; //inverse reticle slope
float baseReticle = 1; //radius of the reticle at z = 0
float maxRange = 3000; //max range to target
Quaternion orientation; //the cameras orientation
Vector3d position; //the cameras position

Then I loop through each object in the world:

Vector3d transformed; //object position after transformations
float d, r; //holder variables

for(i = 0; i < objects.length; i++) {

    transformed = position - objects[i].position; //transform the position relative to camera
    orientation.multiply(transformed); //orient the object relative to the camera

    if(transformed.z < 0) {

        d = sqrt(transformed[0] * transformed[0] + transformed[1] * transformed[1]);
        r = -transformed[2] * iReticleSlope + objects[i].radius;

        if(d < r && -transformed[2] - objects[i].radius <= maxRange) {

            //the object is under the reticle

        } else {

            //the object is not under the reticle

        }

    } else {
    //the object is not under the reticle
    }
}

Now this all works fine and dandy until the window ratio doesn't match the resolution ratio.  Is there any simple way to account for that


texts: Weird movement / rotation of Unity editor scene view camera

texts:
I am using the Unity 2017.3.0f3 Personal (64) bit editor for Pc, Mac and Linux Standalone (DX11 on DX10 GPU). I was editing my terrain when suddenly my camera for moving around in the editor went absolute wack.

The camera now rotates around any object I click on and pretty much doesn't work at all. I cannot move using the WASD keys anymore.

I have never had this problem before so I believe I just accidentally clicked the wrong button. Is there any way I can fix this?


texts: Sprite Animation of Tank Turning - how many items in sheet

texts:
I have a question about this tank you can see below. It's from a game called Command and Conquer from the 90s. My question is, how is something like this animated as the tank is turning? Did the game designers draw the tank at a basic position and then draw it again +1 degree and then draw again +2 degrees, etc. until they get all the way around?

http://cnc.wikia.com/wiki/Mammoth_tank_(Tiberian_Dawn)?file=CNCTD_Mammoth_Tank_Ingame.png


texts: How do I find an object by type and name, in Unity, using C#?

texts:
I know that in Unity you can find an object of a certain type, using myObject = Object.FindObjectsOfType<MyType>(), but that only returns the first object in the scene it finds of that type.

How do I make it find the object of a certain type and with a certain name?


texts: SDL2 Textures bleeding / 1px border around tile maps - SDL_RenderCopyEx taking integer arguments

texts:
https://forums.libsdl.org/viewtopic.php?t=9486 This post gives a good indication of my question.

Basically if you set SDL2 logicalScale or otherwise and render textures at native window resolution they appear fine. However, with tile maps if you resize the window in anyway, you get a bleed where an integer rounding issue creates a 1px border around certain tiles.

Is my only option to create a 1px border around all my images to stop this bleed / rounding error? Or a semi-transparent border with the main color. What are my options? Is this solved in any of the latest SDL2.X.Y ?

EDIT: A simpler method I have used is reducing my images from 64x64px to 62x62px in SDL2 (not the actual sprite) and using it's own sprite as a 1px border, and using Render Scaling to scale up that 1px, which stops bleed. It reduces the quality on background images ever so slightly, but it requires no tweaking of any code or sprites... but again wondering if there's a more elegant solution.


texts:
I recently read an article about light indexed deferred rendering from here:

http://code.google.com/p/lightindexed-deferredrender/

It explains its ideas in a clear way, but there was one point that I failed to understand. It in fact is one of the most interesting ones, as it explains how to implement transparency with this approach:

  Typically when rendering light volumes in deferred rendering, only
  surfaces that intersect the light volume are marked and lit. This is
  generally accomplished by a “shadow volume like” technique of
  rendering back faces – incrementing stencil where depth is greater
  than – then rendering front faces and only accepting when depth is
  less than and stencil is not zero. By only rendering front faces where
  depth is less than, all future lookups by fragments in the forward
  rendering pass will get all possible lights that could hit the
  fragment.

Can anyone explain how exactly you need to render only front faces? Another question is why do you need the front faces at all? Why can't we simply render all the lights and store the ones that overlap at this pixel in a texture? Does this approach serves as a cut-off plane to discard lights blocked by opaque geometry?


texts: Is there a library that will let me load a movie file and play it in an OpenGL application?  Or maybe just a code sample that someone has lying around?  I'm also using GLUT, if that makes a difference.  I guess file format doesn't matter, although currently my movie is in AVI format.


texts: Is there an application that converts a PC into a video game kiosk/arcade machine?

texts:
Sorry to make the question so vague.

What I ultimately want is software that allows people to play independent video games on a PC and not have to worry about maintaining it.

Imagine a game that was made in a few hours that does not have a restart button and crashes often. It should be able to handle these kinds of things and do more!

The software should:

allow the game to be restarted manually
handle game crashes (likely by restarting the game)
restrict the user from doing anything crazy

later...

offer a UI to select the game from a list
handle pre-configured key bindings
cross-platform (start with windows)

I just want to know if this exists already before I start creating one. As of now AutoHotKey is being used to do this sloppily.

If such software does not exist then perhaps someone could recommend a general open source Kiosk software? Open Kiosk? I'll take anything.

(I also could not find a related tag. Not even sure if this question should be here rather than stackoverflow)


texts: Good practices to hold terrain data in a 2D networked game

texts:
I am working on a client-server architecture game, its a 2D top view adventure.

My main focus for the map system right now is to have editable terrain, that will actually change in realtime to other players!

So, i've divided the map into equally sized chunks, that coupled together form the whole map.
As the client camera moves, the server will be sending updates for the neighbour chunk, allowing the client to show the map up to date, without having it locally, and seamless.

And this is what brings the problem, if a whole chunk is going through the network, the data for its terrain must be clever built.

Making this edition and storing like traditional Tilemaps would seem a little overhead for a online game.. I tought of representing terrain as shapes of a certain texture, with certain parameters. All textures would be in client, with a id associated to each one. The server would send something like "AddShape [dirttextureid] [point1] [point2]" and the client would convert that into a dirt road between point1 and point2, but that seems to take a lot of freedom of the map creation process as there would be no freehand painting at all, causing the person to overdraw with shapes.

The rendering itself should be painless anyway, as i intend to draw all terrain in a few textures, only rebuilding those textures when something changed in the terrain, allowing the onscreen terrain to render with 3-4 sprites, leaving the rest of the cpu to draw other objects.

So, any toughts on how i can allow map editing and storing in a clever way, giving a good freedom/performance tradeoff?


texts: What percentage of game content is normally free on a Free-to-Play game?

texts: If I wanted to launch a free-to-play game with different characters, weapons, items and clothes that can be either unlocked through gameplay or bought with real money, what percentage of items should only be available for real money? This isn't "subjective" - I'm interested in examples of real games and estimates of what percentage of their content is free.


texts: In Unity on Android, how can I rotate an object with the accelerometer?

texts:
I'm making a game where you control a platform with balls falling on it, and you have to balance the balls and prevent them from falling off. I'm currently using a mouse to control it with this code:

transform.rotation.eulerAngles.z += Input.GetAxisRaw("Mouse X");
transform.rotation.eulerAngles.x += Input.GetAxisRaw("Mouse Y");

I'm trying to make this an Android app, and want to use motion controls so I can tilt the device, as if it were the platform. I figured I would use the accelerometer for this.

Any ideas on how to do this in Unity?


texts: Why is my Simplex Noise appearing in four columns?

texts:
I'm trying to make a Texture out of Simplex noise, but it keeps appearing like this regardless of how big or small scale is:

The following code is used to produce the image's color date:

private Color[,] GetSimplex() {
    Color[,] colors = new Color[800, 600];

    float scale = colors.GetLength(0);

    for (int x = 0; x < 800; x++) {
        for (int y = 0; y < 600; y++) {
            byte noise = (byte)(Noise.Generate(x / scale, y / scale) * 255);
            colors[x, y] = new Color(noise, noise, noise);
        }
    }

    return colors;
}


texts: How does this data oriented design retain level data, while still offering cache-wise benefits?

texts:
I'm almost sold on the concept of a data oriented engine; however, one thing still eludes me. If we pack the data from a large level into huge arrays, and go over them, any visibility system that we have would basically render most of it as unprocessable.

Consider this exert:

void do_stuff_with_data(data* vdata, const const_data* cdata, int count)
{
    for ( int i = 0; i < count; ++i )
    {
        if ( vdata->active )
        {
            ... process data
        }
    }
}

Considering that most of the data is not visible, and due to stuff moving around, there is no sensible prediction for how to order it, and branch prediction is screwed. Doesn't that void the cache-wise benefits?

I have read up on article dealing with this specific problem, but most of the sources just show the "big picture", completely disregarding this important issue.


texts:
I have a 3d-models from old game.
They have the following structure:

Model {
    List<Vertex> Vertices;
    List<Bone> Bones;
}

Vertex {
    // point
    float x;
    float y;
    float z;
    // normal vector
    float nx;
    float ny;
    float nz;
    // texture
    float u;
    float v;
    // bones info
    byte boneIndex1;
    byte boneIndex2;
    float weight;
}

Bone {
    float[,] matrix = new float[4,4];
}

I want to convert models to any other format that is supported by 3D editors.
I learned how to convert a mesh (to obj, fbx). But I can't convert the bones.
As I understand it, a 4x4 matrix is enough to form a bone. The role of the bone index is performed by their index in the array. Unfortunately, as I understand it, there is no data on the hierarchy of bones.

I looked at various specifications of file formats, but I did not find one where the bones can be specified as a matrix.

Maybe there are some formats that support such a recording of bones in the form of matrices?
Maybe I just misunderstand something and I need to look for something completely different?


texts: OpenGL: Objects wont draw at certain angles while using lighting(shaders)

texts:
I was following this tutorial (http://www.lighthouse3d.com/tutorials/glsl-12-tutorial/point-light-per-pixel/) but when the camera is at a certain angle, if I had alpha test and blend enabled the cube i have in the scene wouldn't draw, otherwise they would be black(if alpha and blend was disabled) Any thoughts on what's going on?

here is some relevant code:

glClearColor(0.6, 0.6, 0.6, 1);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(80, (float)window.getSize().x / (float)window.getSize().y, 0.01f, 1000.0);
glMatrixMode(GL_MODELVIEW);

glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
//glEnable(GL_BLEND);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glEnable(GL_ALPHA_TEST);
//glAlphaFunc(GL_GREATER, 0.1f);

glEnable(GL_COLOR_MATERIAL);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
    .....

void Lighting(Camera cam, sf::Vector3f Pos) {
GLfloat amb[] = {0.2, 0.2, 0.2, 1};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, amb);

GLfloat diff[] = { 1, 1, 1, 1 };
GLfloat pos[] = { Pos.x, Pos.y, Pos.z, 1 };
glLightfv(GL_LIGHT0, GL_DIFFUSE, diff);
glLightfv(GL_LIGHT0, GL_POSITION, pos);
}
....
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
cam.up(delta, window);
Lighting(cam, Pos);
sf::Shader::bind(&shader);

cube.draw();
cube1.draw();
window.display();
sf::Shader::bind(NULL);

draw function for cubes:

glPushMatrix();
    glTranslatef(pos.x, pos.y, pos.z);
    glBegin(GL_QUADS);
        glColor3f(color.r / 255, color.g / 255, color.b / 255);

        glVertex3f(0, 0, 0);
        glVertex3f(width, 0, 0);
        glVertex3f(width, height, 0);
        glVertex3f(0, height, 0);

        glVertex3f(width, 0, 0);
        glVertex3f(width, 0, -length);
        glVertex3f(width, height, -length);
        glVertex3f(width, height, 0);

        glVertex3f(0, 0, -length);
        glVertex3f(0, 0, 0);
        glVertex3f(0, height, 0);
        glVertex3f(0, height, -length);

        glVertex3f(width, 0, -length);
        glVertex3f(0, 0, -length);
        glVertex3f(0, height, -length);
        glVertex3f(width, height, -length);

        glVertex3f(width, 0, 0);
        glVertex3f(0, 0, 0);
        glVertex3f(0, 0, -length);
        glVertex3f(width, 0, -length);

        glVertex3f(0, height, 0);
        glVertex3f(width, height, 0);
        glVertex3f(width, height, -length);
        glVertex3f(0, height, -length);
    glEnd();
glPopMatrix();


texts:
Why does XNA blurs the images which moves less than 1px in between two draws? It is quite annoying, because everything looks really blurry. Is there a way to disable it?
I have tried to set the SamplerState of the spritebatch's SamplerState to PointWrap in it's Begin function, but then it wraps the images to pixels, thus they move choppy. Any suggestions? Thanks!
My SpriteBatch's Begin function:

spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);

Edit:

public class Image:IDisplay
{
    public Texture2D texture;
    private BaseModel model;
    private Vector2 position;
    private Util.DISPLAY_LAYERS layer;
    public Image(String asset, BaseModel _model)
    {
        model = _model;
        texture = Main.current.Content.Load<Texture2D>(asset);
        DisplayManager.add(this, model.layer);
    }
}

This is how the Image class looks like (without additional functions), and this is it's draw function which is being called.

public void Draw(SpriteBatch batch)
    {
        if (model== null)
        {
            batch.Draw(texture, position, Color.White);
        }
        else {
            position.X = (int)Math.Round(model.Position.X, MidpointRounding.AwayFromZero);
            position.Y = (int)Math.Round(model.Position.Y, MidpointRounding.AwayFromZero);
            batch.Draw(texture, position, Color.White);
        }
    }


texts: Procedural mesh generation from raytracer

texts:
I'm interested in applying the following technique:

Define game objects using a object definition DSL similar to what you would use for a raytracer (e.g. POVRay)
Use a specialised raytracer to sample the shape of the object as a mesh and render a texture/normal map for the object
Subsequently use the generated mesh / textures in a 3D game engine as usual

It seems like this technique would be a good way of developing a lot of high quality meshes fairly efficiently, assuming a resoanably expressive object definition DSL.

Has this technique been effectively used anywhere?


texts: How to move the ball in straight line in gamesalad?

texts: I have an actor named ball  and I want to move it in a straight line which is created by actor ball's X and Y coordinate and cursor's X and Y coordinate. I have Move To behavior in gamesalad but I don't have exact idea how to move the ball with two Cartesian coordinates ball and cursor.


texts: Unity 5 Dynamic Button Creation with Event Parameters

texts:
According to the documentation, you cannot instantiate buttons except via prefab instantiate.

http://docs.unity3d.com/Manual/HOWTO-UICreateFromScripting.html

  You might wonder why we don’t have a API methods to create the various types of controls, including visuals and everything. The reason is that there are an infinite number of way e.g. a button could be setup. Does it use an image, text, or both? Maybe even multiple images? What is the text font, color, font size, and alignment? What sprite or sprites should the image use? By letting you make a prefab and instantiate that, you can set it up exactly the way you want. And if you later want to change the look and feel of your UI you can just change the prefab and then it will be reflected in your UI, including the dynamically created UI.

What I'm trying to do is dynamically create a table of buttons, each one going to a level in my game. The amount of button depends on how many levels the user has unlocked.

I can create a prefab for a button, that's fine, but how do I go about assigning an OnClick event to each of these buttons with an appropriate 'levelIndex' parameter?

I can not find any scripting method to do this, and I'd like to avoid hacky solutions like creating 50 buttons and only showing the first N children.


texts: How forward rendering done using OpenGL?

texts: Recently I come across the term forward rendering. I'm kind of curious how this could be done in OpenGL. I have done a lot of search on this, majority of the result I get are on theory but not code implementation. May I know is there any code implementation on OpenGL for this rendering technique?


texts: Is built-in checking Android/iOS permissions on runtime possible?

texts:
I have a game with some levels, coded to both Android and iOS.

One of the levels late in the game uses a Microphone, so the app asks the user at the start (at the start of the application) to accept the Microphone permission.

If he does accept, everything is fine.

If he doesn't, Microphone.Start() method doesn't really work and I can't do anything about it.

What I should do is that in level's start() I should check if he has the permission and handle it, but...

I can't find a built-in way to check that on both Android and iOS.

Is there any, or I should download two different libs (for both platforms) and check it natively?

This is what I've tried:

    audio.clip = Microphone.Start ("Built-in Microphone", true, 999, FREQUENCY);

    Debug.Log("CLIP: " + audio.clip); // not null

    if(audio.clip == null)
    {
        GameManager.Instance().ForceComplete();
        return;
    }

    try
    {
        audio.Play ();

    }catch(Exception ex) // no exception here
    {
        GameManager.Instance().ForceComplete();
        return;
    }

    //...


texts: Why are Monogame models tied to effects?

texts: When I load a model in Monogame using ContentManager, the model contains effects on each mesh (mesh.Effects). This is confusing to me since models seem to be directly tied to their rendering, rather than existing as standalone 3D models. Further, this makes applying custom effects more difficult in code, since I have loop through each ModelMeshPart and assign effects. The comparison to 2D would be a Texture2D containing its own SpriteBatch settings, which wouldn't make sense. Why are models tied to effects, and how can I separate them?


texts: How do I use Android's adaptive icons in Unity?

texts:
As of API 26, Android uses something called adaptive icons.

When targeting API 25 and lower, my app's icon looks fine:

But when targeting API 26+, it shows up in a white circle like so:

How can I target API 26+ while utilizing Android's adaptive icons?
What if I want to target API 26+, but not use Android's adaptive
icons?


texts: How do I avoid losing prediction responsiveness due to client interpolation?

texts:
In my online game, I am using client prediction and client interpolation to give the illusion of responsiveness over a networked connection.

The client prediction applies inputs that haven't yet been acknowledged by the server to incoming server states. When the input is acknowledged, the client's entity will already be in the final position.

The client interpolation works by buffering world snapshots and rendering the entities 100 ms in the past. While new snapshots arrive within the next 100 ms, there will always be valid data to interpolate between.

My problem is that the responsiveness gained from client prediction is lost due to client interpolation. The client's local inputs are applied to incoming server states. However, those incoming states aren't actually rendered on the client until 100 ms later, due to the client interpolation. The result is that there is always a 100 ms lag between pressing a key and rendering the change to the screen.

How can I get the best of both worlds, rendering entities in the past, but rendering the client's inputs instantly?


texts: Render sprites onto a virtual 640x480 "screen"

texts:
I'm making a game, and in part of it, the player uses a computer terminal. I want to draw to a virtual 640x480 screen with pixel precision, and then draw that "virtual screen" to the player's real screen. The end result will not be "pixel perfect" because 99% of people won't play the game at 640x480 -- and, in fact, I want to then go on and add further effects on top of this so it looks more like a CRT display -- but trying to figure out how to do pixel rendering in Unity has proven pretty difficult so far.

Basically I want to render something that looks like this:

onto the screen, where I draw all of the text characters myself (using Sprites? subsections of a Texture?), and then I want to render this "virtual screen" out onto the player's screen. I know RenderTextures are a thing, and maybe that's part of it? I've tried a lot of different things so far and got nowhere, hence why I'm posting here.

Sorry if this is too nooby of a question, I'm an experienced programmer who is relatively new to Unity.


texts: How can I fix this error about loading .wav assets in MonoGame 3.2?

texts:
I'm trying to add a music file to my project, but I get the error "Could not load EpicScores.wav asset!"

I load the music file like this:

Song sound1 = Content.Load<Song>(@"EpicScoreCreatorOfWorlds.wav");

I've tried both with and without the .wav ending.

My file is added to the Content folder, and I've made sure my file properties are set to the "Content" build action and to "copy always."

Why do I get this error and how can I fix it?


texts: Handwriting or handwritten text recognition in augmented reality

texts: Is there any way available to detect handwriting of a user using augmented reality within Unity. Or convert user hand written text into characters?


texts: Sprite is getting out of screen when changing resolution - Unity

texts:
Hello I am making this layout:

I used sprites for birds but used UI for the blue food thrower. I used UI for it so it will not get cut when screen resolution changes.
But I also need to add food itself which I need to make 2D to interact with birds.
Now It is not visible over UI, So I changes Canvas-Render Mode to world space. But I cannot adjust text in that mode. Its not visible.
Then I tried converting the food thrower to Sprite but it get cut. Any authentic and cleaner way to do it?


texts: Marketing a browser game with a specific audience

texts:
My issue is that I have extensively developed an online browser game, but mainly the marketing and independent developer guides tailor to action packed executable games. My game also tailors to a specific audience that is not typically on the indie gaming promotional websites. Namely those interested in Politics, Economy, Law, and/or Sociology.

(My first issue) I wanted to know if there are any suggestions, ideas, or references to any resources that may bring marketing value to my gaming community pre and post-launch? I have began development on my beta campaign already to include some crowd funding websites (mostly for promotion), a press kit, advertisements, and the like. However I would greatly appreciate more resources for the development and launch, namely for the target audience.

(My second issue) Many of the marketing strategies for games depend on a video, game photos, etc. While I can take photos of the screen, there are not too many things I can do for a video except add some stock footage and dress it up by explaining game mechanics and showing some photos of the game. Would that contribute to the game or is it just a waste of time? (Feel free to suggest any ideas for this as well if you are willing).

Thank you for your assistance!


texts: weird behaviour doing simple XMMATRIX multiplications

texts:
I have the following function:

void AnimatedModelShaderClass::PrepareToDraw(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* mesh) {

WVP = worldMatrix * viewMatrix * projectionMatrix;
cbPerObj.WVP = XMMatrixTranspose(WVP);
cbPerObj.World = XMMatrixTranspose(worldMatrix);
[...]

}

WVP is defined in the AnimatedModelShaderClass class as

XMMATRIX WVP;

The world, view and projection matrices are correctly received by the function, but as soon as the first line is executed, i can see that WVP contains some very weird values.

If i substitute the first line with the (supposedly) equivalent:

WVP = XMMatrixMultiply( XMMatrixMultiply(worldMatrix,viewMatrix), projectionMatrix);

then WVP is evaluated correctly and the numbers inside make sense.

Aren't the two ways equivalent?
What am i missing?

Thanks in advance.

UPDATE:

It doesn't seem to have anything to do with the multiplications order, it works correctly if i replace the faulty line with:

XMMATRIX temp1 = projectionMatrix;
XMMATRIX temp2 = viewMatrix;
XMMATRIX temp3 = worldMatrix;

WVP = temp3 * temp2 * temp1;

What's the difference? I don't get it...


texts: 3D open source physics engine suitable for mobile platforms (Android and iOS)

texts:
I have made some research and found that bullet, ode, newton and some others are open source physics engines that should be portable enough (but I have never tried to comile/use anyone of them on phones). I am writing my games for mobile platforms in C++, so the engine should be C or C++. I need a fast engine, since mobile platforms have limited resources. I need a free engine. A good design would be nice to have too.

What engine is best suited for my task?
What I really would like to hear from you is your direct experience.

Documentation and support (for example, forum or an IRC channel) is a really important aspect to take into consideration.


texts: Shading a 2D visibility mesh to act like a light?

texts:
I have a visibility mesh made by raycasting:

https://my.mixtape.moe/omjlgr.webm

Right now, I'm using a shader to color the mesh white and fall off with distance and radius (the texCoord in this case is the same as the current vertex position):

uniform vec2 lightPosition;
uniform vec4 lightColor;
uniform float lightRadius;

void main()
{
    float distance = gl_TexCoord[0].xy - lightPosition;

    float lightPower = 1 - length(distance) / lightRadius;

    gl_FragColor = lightColor * lightPower;
}

However, as you can see, this light is all white. What I want to happen, is to shade the sprites themselves fullbright. Right now, to apply an ambient light color, I set the color of every tile to the color.

So if I have an ambient color of (70, 70, 70), and a light of (255, 255, 255), I want the center of the light to have a fullbright sprite (as if you set the color if it to white), and the tiles at the very edge of the light and further to be the ambient color. To explain further, if my map is fullbright (e.g. ambient color pure white), white lights wouldn't be visible.

How would I change my shader / add another shader to accomplish this effect?


texts: OpenGL FBO, render off screen and texture

texts:
I need to do some offscreen render to use the rendered image in something different from OpenGL context (for instance I need to use the image in a QListWidgetItem inside a Qt application). After documenting a little bit I've found that Frame Buffer Object (FBO) is what I have to use in combination with glReadPixels for getting the raw image from OpenGL/GPU into my application. So, here I am against FBO.

I've found that I need to attach the FBO to a texture otherway it does not work and glCheckFramebufferStatus gives me: GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER. So when I try to init the FBO I need to add also glGenTextures and glBindTexture etc..

But.. why? I don't need a texture for now.. why do I have to declare/init/bind (don't know what is the best word here) a texture?

What is the "minimal" FBO setting for get the images? And what about if in my application I need also stencil or depth images? Are things different?

And using back buffer instead of FBO? Is it slower? Do I still need a texture?

I'm kind of afraid of using textures because of a lot of parameters () I don't understand for now..

Sorry for confusion..


texts: How can I add Y-axis/Pitch/Vertical to LineTraceByChannel Raycast with Unreal Blueprints?

texts:
I am using LineTraceByChannel to cast a ray and return the name of the object it hits in my game world. It works but I am having trouble working out how to add the Y-axis (Up/Down) value. At the moment the ray is only cast horizontal to the ground, regardless of whether the player is looking up or down.

I tried adding a Pitch variable and getting the y-axis value but haven't worked out how exactly to use this. I followed a tutorial to get this far so any further advice is much appreciated.

This is my blueprint currently

The 'Selection Beam' component is attached to the character mesh, facing forwards:

This is where I get the input from the Mouse Y axis, if that helps:


texts: setPosition of Sprite onUpdate in AndEngine

texts:
I am trying to get a "highlighter" circle to follow around a sprite, but I am having trouble, I thought I could use the onUpdate method that's available to me in SequenceEntityModifier but it's not working for me. Here is my code:

    // make sequence mod with move modifier
    SequenceEntityModifier modifier = new SequenceEntityModifier(myMovemod) {

        @Override
        protected void onModifierFinished(IEntity pItem) {
            // animation finished
            super.onModifierFinished(pItem);
        }

        public float onUpdate(float pSecondsElapsed, IEntity pItem) {

            highlighter.setPosition(player2.getX() - highlighterOffset, player2.getY() - highlighterOffset);
            return pSecondsElapsed;
        }

    };

When onUpdate is completely commented out, the sprite moves like I want it to, everything is ok. When I put the onUpdate in, the sprite doesn't move at all. I have a feeling that I am overriding the original onUpdate's actions?

Am I going about this the wrong way? I am new to Java, so please feel free to advise if this isn't going to work.

UPDATE: The player2 is the sprite that I'm trying to get the highlighter to follow.


texts: Convert 2d generated level to graph or analyze

texts:
Do you have any idea how to extract graph data from this type of procedurally generated level?

Well, actually we need to analyze only top level (gray). Background (black) does not matter. What I am looking for is a way to statistically analyze such type of generated maps. For example how much isolated areas I have (it's not hard, I know), how much branches in each area I have and which areas has exit.

Do you remember any algorithm or math instrument to do that? Memory does not matter, algorithm complexity does not matter too. It's not runtime task.

P.S. A desired result can look like this:


texts:
I've been trying to figure out how to implement something like the pathfinding in Starcraft 2. I'm not looking for all the sophisticated features like flocking, queueing, etc. In fact I like how in Starcraft 1 the units would interfere with each other. But I do want a path finder better than that used in Starcraft 1.

From the Google searches I've done the various answers have something to do with A* over a navigation mesh and/or dealing with some kind of "visibility graph". But I've gotten somewhat conflicting or unclear answers on what I should do.

One thing I read about has something to do with doing A* over the vertices of a triangle mesh (the navigation mesh). And then somehow "straightening out the path" which I don't know how to do. But that doesn't guarantee optimality right?

Another question I had is how does the starcraft 2 pathfinding deal with the fact that the units are discs with a finite radius and not points when dealing with corners? And how to deal with dynamic obstacles like idle units or even other moving units.

I'm looking for some gritty detailed explaination and not the generic super high level overviews that are typical in search results.

If it matters I've already looked at Amit’s Notes about Path-Finding. I've heard of but not read Computational Geometry: Algorithms and Applications. And a blog post about a AI navigation presentation at GDC 2011 mentioned that Starcraft 2 uses a constrained delaunay triangulation for a navmesh. Although the blog post mentions Boids steering and "horizon analysis", it doesn't mention exactly how the core pathfinding is done on the navmesh.


texts: Gdx.graphics.getWidth() vs cam.viewport width

texts: I'm facing difficulty understanding the difference between Gdx.graphics.getWidth() vs cam.viewportwidth, What is the difference?


texts: Why does this implementation of sweep and prune freeze, and how can I fix it?

texts:
When I try to implement sweep and prune the aabb and sphere collisions don't collide properly. I have debugged the code and traced the problem to these methods.

AABB and Sphere collisions(The code for both is slightly different)

@Override
public boolean collides(Sphere other) {
            //AABB
    float dist = sqDistance(other.getCenter(), this);

    return dist <= (other.getRadius() * other.getRadius());

}

    @Override
public boolean collides(AABB other) {
    float dist = sqDistance(center, other);

    return dist <= (radius * radius);
}

 public default float sqDistance(Vector3f point,AABB aabb) {
    float sqDist = 0.0f;
    for( int i = 0; i < 3; i++ ){
        // for each axis count any excess distance outside box extents
       sqDist += check(point,aabb,i);
    }
    return sqDist;
}

public default float check(Vector3f point,AABB aabb,float axis) {
        float sqDist = 0;
        if(axis == 0) {
            float v = point.x;

            if( v < aabb.getMin().x ) sqDist += (aabb.getMin().x - v) * (aabb.getMin().x - v);
            if( v > aabb.getMax().x ) sqDist += (v - aabb.getMax().x) * (v - aabb.getMax().x);
        }
        if(axis == 1) {
            float v = point.y;

            if( v < aabb.getMin().y ) sqDist += (aabb.getMin().y - v) * (aabb.getMin().y - v);
            if( v > aabb.getMax().y ) sqDist += (v - aabb.getMax().y) * (v - aabb.getMax().y);
        }
        if(axis == 2) {
            float v = point.z;

            if( v < aabb.getMin().z) sqDist += (aabb.getMin().z - v) * (aabb.getMin().z - v);
            if( v > aabb.getMax().z) sqDist += (v - aabb.getMax().z) * (v - aabb.getMax().z);
        }
        return sqDist;
}

Could anyone please try and tell me what is wrong with these methods.


texts: How to go orthographic instead of perspective view in XNA with CreateOrthographicOffCenter?

texts:
Using these view and projection values:

var eye = new Vector3(0, 0, 10f);
var view = Matrix.CreateLookAt(eye, Vector3.Zero, Vector3.Up);
var projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 1.0f, 1000f);

and then applying world rotation to the effects with this matrix:

var rotation = Matrix.CreateRotationX(-MathHelper.PiOver2)*Matrix.CreateRotationY(MathHelper.PiOver2);

I am able to render my animated model:

But simply changing projection matrix to something like this:

var projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1.0f, 1000.0f);

Renders pure CornBlue screen. I don’t see my model at all. What should I do to make it visible?


texts: How could I achieve an iOS high detailed level design for a platformer?

texts:
I'm seeing a lot of games that use a predefined and repeating set of tiles for their level (like FlappyBird or the Super Mario game series).

I'm a graphics designer so I would like to create levels with a much higher level of details for the game levels. I'm thinking about games such as Limbo (screenshot at the end of the post) or BadLand.

I thought about designing the whole level in one big  high detailed image which could reach to 30k pixels in width, but I'm not sure if that's the way to go.

How should I structure my game to achieve that level of detail?

I'm using sprite-kit.


texts: How to check strings from multiple lines in one input field?

texts:
I need help with input fields. I already set the line type to 'Multi_Line NewLine' in inspector, but I have problem with submitting the string. Here's the code:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class GameController : MonoBehaviour {
    public string code;
    public string code1;
    [SerializeField]
    public InputField input;

    public void Check(string guess)
    {
        if (string.Equals (guess,code)) {
            Debug.Log ("correct");
        } else
            Debug.Log ("wrong");
    }
    public void GetInput(string guess)
    {
        Check (guess);
        input.text = "";

    }
}

I want to have both 'code' and 'code1' strings to be inserted in different lines inside the same input field but I don't know how to check both 'code' and 'code1' string value inside the Check(). Any help would be appreciated.


texts: Texture coordinate discontinuity with mipmaps creates seams

texts:
I just started learning openGL and I am getting this artifact when texturing a sphere with mipmaps. Basically when the fragment samples the edge of my texture, it detects the discontinuity (say from 1 to 0) and picks the smallest mipmap, which creates this ugly seam:

ugly seam http://cdn.imghack.se/images/6bbe0ad0173cac003cd5dddc94bd43c7.png

So I tried to manually override the gradients using textureGrad:

//fragVert is the original vertex from the vertex shader
vec2 ll = vec2((atan(fragVert.y, fragVert.x) / 3.1415926 + 1.0) * 0.5, (asin(fragVert.z) / 3.1415926 + 0.5));
vec2 ll2 = ll;
if (ll.x < 0.01 || ll.x > 0.99)
    ll2.x = .5;
vec4 surfaceColor = textureGrad(material.tex, ll, dFdx(ll2), dFdy(ll2));

Now I get two seams instead of one. How can I get rid of them? And why does the code above generate 2 seams?

2 eams http://cdn.imghack.se/images/44a38ef13cc2cdd801967c9223fdd2d3.png

You can't tell from the two images but the 2 seams are on either side of the original seam.


texts: Get current window position with Monogame

texts:
I'm looking for some help figuring out the current position of the Monogame windowed form.  My ultimate goal is to figure out when the user is clicking inside of the game window and where they're clicking.
Getting the mouse position is easy:

var mouseState = OpenTK.Input.Mouse.GetState();
var mousePosition = new Point(mouseState.X, mouseState.Y);

That returns a Point relative to the computer's display.  I'm running my app as a windowed form, so I need to compute the mouse position inside of the window based off the forms current location on the monitor.
And in reading up on the subject, it looks like this should give me the point data I need:

System.Windows.Forms.Form form = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(this.Window.Handle);
var formPosition = new Point(form.Location.X, form.Location.Y);

Trouble is, that the object form is always coming back as a null object.  this.Window.Handle will return a valid (System.IntPtr) handle ID, but the form object is never created.

While I'm stopped at a break point, I can see the data I need inside the this.Window located at  ((OpenTK.NativeWindow)(((Microsoft.Xna.Framework.OpenTKGameWindow)(this.Window)).window)).Location - but that location is a non-public location so I can't get it out of there.

Any suggestions?


texts: How do I implement an AutoParallax Background in AndEngine GLES1?

texts: I'm using AndEngine GLES1. In my game, I use AnalogOnScreenControl to move a sprite and when it moves vertically, the background image also moves vertically. I want to do something like this: that is in this link.  I know that AutoParallax Background or BackgroundParallaxScrolling may be used. But how do I use it in my game?


texts:
I am trying to implement jumping in my game. I am casting a ray to know if the player is grounded, and using a Layermask to make it only react with the floor. The code:

groundLayer = LayerMask.NameToLayer("Ground");
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, 1.0f, groundLayer.value);
Debug.DrawRay(transform.position, Vector2.down * 1.0f, Color.green);
if (hit.collider != null)
    {
        print(collider.name);
        bounds = collider.bounds;

        if (distance < 0.2f)
        {
            grounded = true;
            return true;
        }
        else
        {
            print(collider.name);
            grounded = false;
            return false;
        }
    }
    else
    {
        print("Collider null");
        return false;
    }

I am receiving collider null always. What am I doing wrong?

EDIT:

In case it helps, this is a screenshot of my Unity editor:


texts: Unity - Determine direction vector3 from a point in space and an angle in eulers

texts:
I have a ball positioned as Vector3(x, x, x).

I was able to get the direction of the ball to the mouse clicked position with:

Code (csharp):

Vector3 direction = Direction (clickPos2 - startPos);

Where the method is:

Code (csharp):

public Vector3 Direction(Vector3 position) {
        return new Vector3(position.x / Length(position.x, position.y), position.y / Length(position.x, position.y), position.z);
    }

Now I have an angle in eulers and I want that the ball goes to the direction of the angle.

But how I calculate it?

The game is played in 2d so actually only x and y is needed, z stays the same.

Mirza


texts: Why aren't all public methods BlueprintCallable by default?

texts:
Considering the entire point of public/protected/private encapsulation is to abstract the class so it's easy to use, why does the programmer also have to decide if a method is callable from blueprints? Shouldn't all public methods/variables be visible in blueprints?

How should I determine if a member should be visible in blueprints? Should I only add the macro when they're strictly needed? Should I aim to make blueprint interfaces even more abstract than the corresponding C++ interface?


texts: Things to do to port game made for iOS in Unity to Android?

texts:
I have just made my first game for iOS and submitted it to app store. I was thinking of porting my game to Android also. I would like to know things one need to do/remember to port game made for iOS in Unity to Android. How to handle different screen resolutions and pixel densities, optimizations required, etc. Any other suggestions and important things you think I should know?

EDIT:
Also, should I handle builds according to device resolutions or by pixel density?


texts: Unity - moving an object around a radius

texts:
I'm trying to move a 2D object around the mouse position, However, i want to constrain the object from rotating unnaturally around itself, i want it to basically rotate around a radius, similar to how a boat moves. I've provided the boat example below of what i am trying to achieve, the game is called battleboats.io and their rotation around the mouse will not skid, it looks natural like propellers pushing from behind.

Here's my code for achieving this in unity:

public Camera camera;
public Rigidbody2D rigidbody;

private float rotationSpeed = 200f;
private float acceleration = 4.4f;

Vector3 GetMousePosition(Camera c)
{
    return c.ScreenToWorldPoint(Input.mousePosition);
}

void Update()
{
    Vector3 direction = GetMousePosition(camera) - transform.position;
    direction.Normalize();
    float rotationAngle = Vector3.Cross(direction, transform.up).z;

    //rotation
    rigidbody.angularVelocity = -rotationAngle * rotationSpeed;

    //forward momentum
    rigidbody.velocity = transform.up * acceleration;
}

Any help is appreciated.

What i currently have and the result of my code is illustrated in the below gif.


texts:
I'm searching how to manage game framerate on mobiles devices, here is my problem:

On a computer with got something like that:

void main()
{
    while(game.isRunning())
    {
        event.handle(eventInfos);
        game.update(dt);
        graphic.render();
    }
}

On a mobile device with got something like that:

void update()
{
    game.update(dt);
}

void render()
{
    game.render(dt);
}

void event()
{
    game.handle(eventInfos);
}

When I search on internet, I found something like that everytime:

-> GameLoop

-> Fix your time step

I'm using IOS (With GLKViewController) and Android (with the NDK), and I've that rendering method is call from another thread

Thanks for your help!


texts: What is the recommended way to output values to FBO targets? (OpenGL 3.3 + GLSL 330)

texts:
I'll begin by apologizing for any dumb assumptions you might find in the code below since I'm still pretty much green when it comes to OpenGL programming.

I'm currently trying to implement deferred shading by using FBO's and their associated targets (textures in my case).

I have a simple (I think :P) geometry+fragment shader program and I'd like to write its Fragment Shader stage output to three different render targets (previously bound by a call to glDrawBuffers()), like so:

#version 330

in vec3 WorldPos0;
in vec2 TexCoord0;
in vec3 Normal0;
in vec3 Tangent0;

layout(location = 0) out vec3 WorldPos;
layout(location = 1) out vec3 Diffuse;
layout(location = 2) out vec3 Normal;

uniform sampler2D gColorMap;
uniform sampler2D gNormalMap;

vec3 CalcBumpedNormal() {

    vec3 Normal = normalize(Normal0);
    vec3 Tangent = normalize(Tangent0);

    Tangent = normalize(Tangent - dot(Tangent, Normal) * Normal);
    vec3 Bitangent = cross(Tangent, Normal);
    vec3 BumpMapNormal = texture(gNormalMap, TexCoord0).xyz;

    BumpMapNormal = 2 * BumpMapNormal - vec3(1.0, 1.0, -1.0);

    vec3 NewNormal;
    mat3 TBN = mat3(Tangent, Bitangent, Normal);
    NewNormal = TBN * BumpMapNormal;
    NewNormal = normalize(NewNormal);

    return NewNormal;
}

void main() {
    WorldPos = WorldPos0;
    Diffuse = texture(gColorMap, TexCoord0).xyz;
    Normal = CalcBumpedNormal();
}

If my render target textures are configured as:

RT1:(GL_RGB32F, GL_RGB, GL_FLOAT, GL_TEXTURE0, GL_COLOR_ATTACHMENT0)
RT2:(GL_RGB32F, GL_RGB, GL_FLOAT, GL_TEXTURE1, GL_COLOR_ATTACHMENT1)
RT3:(GL_RGB32F, GL_RGB, GL_FLOAT, GL_TEXTURE2, GL_COLOR_ATTACHMENT2)

And assuming that each texture has an internal format capable of contaning the incoming data, will the fragment shader write the corresponding values to the expected texture targets?

On a related note, do the textures need to be bound to the OpenGL context when they are Multiple Render Targets?

From some Googling, I think there are two other ways to output to MRTs:

1: Output each component to gl_FragData[n]. Some forum posts say this method is deprecated. However, looking at the latest OpenGL 3.3 and 4.0 specifications at opengl.org, the core profiles still mention this approach.

2: Use a typed output array variable for the expected type. In this case, I think it would be something like this:

out vec3 [3] output;

void main() {
    output[0] = WorldPos0;
    output[1] = texture(gColorMap, TexCoord0).xyz;
    output[2] = CalcBumpedNormal();
}

So which is then the recommended approach? Is there a recommended approach at all if I plan to code on top of OpenGL 3.3?

Thanks for your time and help!


texts:
My aim is to allow my player to shoot 3 bullets at a time. Between shooting these 3 bullets the player should wait a very small interval (so that they don't all get fired at the same time) - call this gunLocalCooldown. After shooting these 3 bullets, the player should wait a much longer interval - call this gunGlobalCooldown. I also have a boolean canShoot that must be true for a bullet to fire (i.e. when the gun is off cooldown).

Here is  the code responsible for this in Update():

// If space is pressed, the gun is off local cooldown and the player can shoot
if (Input.GetKey (KeyCode.Space) && Time.time >= gunLocalCooldown && canShoot) {
    // Bullet prefab
    Rigidbody bPrefab = Instantiate (bulletPrefab, transform.Find ("Bullet").position, Quaternion.identity) as Rigidbody;
    bPrefab.AddForce (transform.up * bulletForce);
    gunLocalCooldown = Time.time + 0.12f;
    bulletCounter++;
    // If 3 bullets are shot, wait for gunGlobalCooldown then reset counter to 0 and allow him to shoot
    if(bulletCounter == 3) {
        gunGlobalCooldown = gunLocalCooldown + 0.8f;
        if(Time.time >= gunGlobalCooldown) {
            gunGlobalCooldown = Time.time + 0.8f;
            canShoot = true;
        } else {
            canShoot = false;
        }
    bulletCounter = 0;
    }
}

What happens right now: after player shoots 3 bullets he can no longer shoot. The problem is that after canShoot is set to false, it is never set to true again (it should be set to true if the player is able to fire 3 bullets again) - and after playing around with this code for a while I still can't figure out how to do this.

As well as this, I want the player to be able to fire 3 bullets again if he shoots even 1 or 2 bullets as long as the global cooldown is complete.

Any ideas?


texts: How can I calculate force and acceleration?

texts:
I have problem of calculating the movement of the object.

At the moment, I have a vectors calculated from the center of the screen minus the position of the object.

direction vector = centerScreen - positionObject

To calculate the new position of the object

position(new) = position(t) + directionVector * delta

The delta is the time frame rate.

Does anyone know how can I modify the above formula to calculate forces and acceleration? I want to have an object pulling other objects towards it.


texts:
I am trying to make a simple game that simulates ants inside a colony, in the Java language. They can move around the paths randomly, go outside to eat leaves, etc. The game is meant to be more of an exercise in programming logic, than an actual game, so I want to try to stay away from graphics, if at all possible. The idea I currently have is to use a 2D array, perhaps like:

public class Map {
    int mapArray[][] = new int[5][5];

    public static void main(String[] args) {
        Map m = new Map();
    }

    public map() {
        //Create the map
        for(int x = 0; x < 5; x++) {
            for(int y = 0; y < 5; y++) {
                mapArray[y][x] = 0;
            }
        }

        //Print the map
        for(int x = 0; x < 5; x++) {
            for(int y = 0; y < 5; y++) {
                System.out.print(mapArray[x][y]);
            }
            System.out.println();
        }
    }
}

I would then do my logic based on the values at different positions in the array.

Is this the best way, or is there a different method that would work better than this one?


texts: Texture loading: Everything at once OR un-/loading the needed assets?

texts:
Good evening. We've been developing quite a huge game for android on the basis of AndEngine. So we have a lot of assets to load, especially textures.

At the moment everything (sound, textures etc) for every screen (menu, shop, etc etc) is loaded when the app starts (while showing a progress bar). This way the user only has to wait once about 16 seconds at the start of the game. We think that this is a pretty pleasant solution from the users perspective but might it be bad in terms of battery usage / memory usage or any other reasons?

What arguments speak for a solution where we unload all the screen specific assets of the active screen and load the assets needed for the next screen? Thank you for your opinion!


texts:
I'd like to generate galaxy using seed , with shape changing a bit and positioning X number of stars.

I'd like to make it realistic (as possible). But i have absolutely no idea how i should do that.
I'm not talking about procedural content generation , i know a bit about and i can search for it if i need, i talking about formulas to use to generate galaxy and then placing dots (stars) so it can look real.

In my mind i see it this way:

1) place a center

2) generate tentacles (don't know the exact term) (i'd like to set the number of tentacles)

3) place dots randomly around those tentacles.

bonus question : i'd like to move the galaxy ingame (like it move in real) , and i don't get if a rotating would be enough and if the movement is more complex)


texts: Independent blending with DXGI_FORMAT_R16G16_SINT

texts:
I'm implementing direct volume rendering engine with volume bricking, but I'm stuck with this problem:

For each volume brick I render to color render target [CRT] (for visualization) and to data render target [DRT] (used for isosurface object picking). DRT is of the DXGI_FORMAT_R16G16_SINT format. All works fine and smooth except wrong handling of blending DRTs of multiple volume bricks together. Closer brick always occludes further brick DRT.

Here are the pictures to illustrate my point
(if the object has proper DRT data it's outlined - as you can se in the highlighted area, there are objects/parts with no data)

Could somebody please give me a tip, how to handle this?
Of course I could always render every brick to separate DRT and write own shader to merge them properly, but isn't there a way of only properly setting blending modes?

(now I'm rendering with blending disabled for DRTs)

Thanks


texts: Where can I find the DirectX SDK to work on D3D8?

texts:
I know this in unprofessional and probably doesn't follow the question asking conventions on this site, but I cannot find any other, more suitable (in my opinion) network on stackexchange to ask this question:

Where can I download the DirectX 8.0 SDK ? It seems all the download sources have vanished few years ago. Neither does Microsoft host 8.0 setup files anymore.

I have searched first 25 pages of google for "dx8sdk.exe" but not a single link is alive to download it.

Apologies..

EDIT:

I failed in finding the full SDK, but was able to get d3d8.h and d3dx8.h files for 8.0 version. So, if you download 8.1 SDK (easy), install it, and then replace the upper mentioned two files with ones from this thread: http://forum.ghbsys.net/index.php?/topic/2772-help-to-fixx/?pid=24384&mode=threaded you should have a hacky 8.0 SDK installed.

EDIT2: August 2007 SDK was the latest one to ship with pre-DX9 technology


texts: Unity Particle Systems from AssetBundle not rendered properly

texts:
Background

I'm developing a (mobile) game that makes use of particle systems to display blood splashing. The particles are - like most assets (characters and whatnot) - world based which means there are different looking and behaving assets.

I use Assetbundles in order to keep the app's download size low, but the one's this question is about come shipped with the app so they're on the system after download and install.

The Problem(s)

There are two problems

1. Shading

2. Render Order

When I build the Assetbundles and use them in production, there seems to be a problem with the shading. The particles are not in transparent/cutoff mode and are displayed darker than usual.

Regarding the rendering order, I know there's a render feature 'sorting order' which I make use of. I have set it to a somewhat high value (higher than all my other objects) and it's still not being rendered in front of them.

For reference I've included pictures of my setups and outcomes.

Reference Images

This is how the particle system's assigned material appears when testing without assetbundle:

This is how the material appears when being loaded from the assetbundle:

There are two materials, but except for the sprite they share the same settings

The Assetbundle includes all of the required materials and sprites as well as the particles themselves (just to make sure)

When testing the particles without assetbundles (plain prefab, test build) it looks like this:

But when built using an assetbundle, it looks like this (notice the difference in shade as well as the lack of transparency):

Also, the particles are not rendered in front of other objects despite the sorting order settings:


texts: Low resolution RenderTexture with gradients

texts:
I have a small RenderTexture that stretched on large object, so texels is near 0.3 of unit. Source for this texture has much more resolution and with gradients.

If source little bit changes its brightness, camera renders it much different.
On this video, first is source, second is texture. Also the rendered gradient is not constant.

How can I fix it?

Archive with minimal scene - If you hide source object in inspector and move it, you will see artifacts on result object.


texts: Better ways to parse text adventure commands?

texts:
Currently I have got a system set up where I split each sentence handed to me into it's baser parts and then compare each word against a list of known words. Once I have the verbs, adjectives and nouns contained in each sentence (ignoring all other words in the sentence) I go left to right in the list and try and create a recognisable command from it. However this doesn't allow for multiple commands in one line.

e.g. get the shiny sword and hit troll.

This would read get, shiny, sword, troll. It would ignore the hit part because currently I've only written the parser to handle one verb per line, but this would not be a recognisable command and would tell the player that it doesn't know what they're asking them.

I think my current system of tokenising the words and parsing them as arguments to an arbitrary action function is simple enough but not very elegant.

So I was just wondering what are some good ways to implement text adventure parsers? Are there any tried and true algorithms or ways to approach it?


texts: What popular real world XNA games are out there?

texts:
Possible Duplicate:
  Famous Games Written in .Net and XNA

Im learning XNA hoping to create a real world game out if one day, i.e. not just learning it to learn game programming.

But are there any successful real world XNA games out there?

(Maybe this question could be turned into a community wiki to a list can be maintained.)


texts: Are there any game engines for developing in C?

texts:
I cant find any game engines which use C, mostly just Java, Anyone know any good engines that support 2d Development in C?

ALso I have an additional question how hard is it to write your own game engine? How would one go about it I'm really curious about how they work.


texts: How can I create an array of GameObjects?

texts:
I need to add one assest multiple times in my scene similar to the blender array tool and I was wondering what is the best way to do this because adding each asset individually and setting there locations doesn't seem like the best way to do it. I need to:

Create multiple sprites quickly
Be able to set the distance between the sprites
Set the number of sprites

How can I do this in the editor preferably without any plugins?


texts:
I've got a simple shader to test multitextureing the problem is both samplers are using same image as their reference.

the shader code is basically just this :

vec4 mid = texture2D(u_texture,v_texCoord);
float g = texture2D(u_guide,v_guideCoord);
gl_FragColor = vec4(g , mid.g,0,1);

and this is how I'm calling draw function :

int last_State;
glGetIntegerv(GL_ACTIVE_TEXTURE, &last_State);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, getTexture()->getName());
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mGuideTexture->getName());

ccGLEnableVertexAttribs( kCCVertexAttribFlag_TexCoords |kCCVertexAttribFlag_Position);

glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, texCoord);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

glDisable(GL_TEXTURE_2D);

I've already check mGuideTexture->getName() and getTexture()->getName() are returning correct textures. but looking at the result I can tell, both samplers are reading from getTexture()->getName().

here are some screen shots showing what is happening :

The image rendered Using above codes

The image rendered when I change textures passed to samples

I'm expecting to see green objects from the first picture with red objects hanging from the top.

after testing lots of things I've figured out glUniform1i is not working as expected, Though I'm not sure what is wrong with it. Here is the code:

glUniform1i(textureLocation, GL_TEXTURE0);
glUniform1i(guideLocation, GL_TEXTURE1);


texts: Raycast to the movement direction after hit a collider?

texts:
I'm working on PingPong game style. My ball keep rotate on all direction. I want to use raycast to show me the direction ball will take after hit a wall or collider. Example
public GameObject Ball;
public Rigidbody rg;
public float StartSpeed;
public bool StartGame = false;

void Update()
{

    if (StartGame == true)
    {
        rg.AddForce(arrow.transform.right * StartSpeed);
        var vel = rg.velocity;
        currentSpeed = vel.magnitude;
        if (currentSpeed > StartSpeed)
        {
            StartGame = false;
        }
    }

        RaycastHit hitB;
        Ray fow = new Ray(Ball.transform.position, Vector3.forward);
        if (Physics.Raycast(fow, out hitB, 200))
        {
            print(hitB.collider.name);
            Debug.DrawLine(fow.origin, hitB.point, Color.yellow);
        }

}


texts:
Im trying to simulate shadows in a 2d RPG, So far I can make the shadows but i cant blit them properly, Im trying to rotate them according to where the "sun" is (just a position)

I have looked at other questions, they say to move the center of the image to the point rotate it then move it back so that what I'm trying to do

here is my code to rotate it:

def rotate(self, shadow, rect):
    copy = rect.copy() #get copy of rect
    angle = degrees(atan2(self.center[0]-self.sun[0], self.center[1]-self.sun[1]))-180 #get angle from "sun" to center of screen

    if angle < -180:
        angle += 360

    angle /= -5

    rect.center = copy.midbottom #move rect to rotation point
    shadow = rotate(shadow, -15) #rotate -15 as a test
    rect.center = copy.center # move it back

    return shadow, rect #return the image and rect to blit them

when the angle is negative it seem like its working and I get this result (which isnt really what I want):

but when I rotate it positively:

so I think I'm doing this totally wrong! I've been trying to figure it out for awhile now, I think I'm blitting it wrong, or not at the right state


texts: assigning script to dynamically created button

texts:
I have a script main.cs which creates a prefabricated button based on this SO post. I thought btnController.cs was providing the methods for the Button created in main.cs? Why would it have a casting issue?

Error

Assets/scripts/main.cs(21,51): error CS0030: Cannot convert type `UnityEngine.UI.Button' to `btnController'

main.cs

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class main : MonoBehaviour {

    public Button myButtonPrefab;

    // Use this for initialization
    void Start () {
        createButton ("minion");
    }

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

    }

    //this is giving a button prefab all the methods from the class btnController
    void createButton(string name){
        btnController b = ((btnController)Instantiate(myButtonPrefab));
        b.Setup(name,0);
    }
}

btnController.cs

using UnityEngine;
using System.Collections;

public class btnController : MonoBehaviour {
    string name="";
    int value=0;

    public void Setup(string n, int v){
        name = n;
        value = v;
    }

    void OnClick(){
        Debug.Log("btn clicked");
    }
}


texts:
Just curious what might be a good way to implement a decent collision system. As a class inherited by a base Entity class? Currently I'm stuck and could just use a couple better ideas than my own.

Any help is appreciated!

Edit:
Sorry, it's 2D Collisioning but honestly, I'm not looking for specific collision methods. I'm looking more about the lines of implementation. Just curious of some of the common methods of how to implement collision systems such as:

Should the entire collision system be it's own class?
What, if anything, should be inheritable?

These are some of my questions. Sorry for the confusion.


texts: Unity 5 - How to change Input Field 'Content Type' at runtime to toggle between asterisks and letters?

texts:
I have a password box set up in my project with the content type set to 'Password', so it shows asterisks when the user types in the box. However I would like a toggle switch so the user can click to show the password characters if they like, so effectively toggling between 'Password' and 'Standard' - is this possible? Any pointers would be appreciated.

Unity 5.3.5 - PC Standalone.

Thanks in advance.


texts: iOS: controlling size of assets designed in Cinema 4D when importing into Xcode?

texts:
A designer provided the attached two DAE files created in Cinema 4D. The characters in these DAE files are to be integrated into an iOS game.

Both assets are of comparable size inside of Cinema 4D. Both DAE files were produced with the same export process.

Importing the DAE files into a SceneKit scene, however, produces different results.

Chango.dae imports at a "normal" size with a bounding box of ~3x4x3.

Tiki.dae imports at a huge size with a bounding box of ~155x325x140. Its dimensions inside Cinema 4D is 122x283x142.

Questions:

1) How do you make sure assets "fit" into a SceneKit scene? Are you supposed to scale down assets with the "scale" property of the SCNNode, or are you supposed to ask the designer to make the asset of a certain size? In SpriteKit and UIKit, this is straightforward. The asset size correlates directly to its screen size (e.g., 20x20 icon takes about that much screen space depending on resolution). However, what's the analog for SceneKit? If you want an asset to fit into a 1x1x1 SCNNode, what size do you ask the designer to make the asset?

2) If your asset is too large for a scene, how do you scale it down? In UIKit, for instance, you can scale an image to fit a UIView with something like ScaleAspectFit. There doesn't seem to be an analog for a SCNNode. Using the SCNNode's scale property changes the appearance, but doesn't change the asset's bounding box. And even changing the appearance isn't precise. For instance, with Tiki.dae, the original height of the asset (as shown by the bounding box) is 324.36. If you set the Y-scale to 0.01, however, the height doesn't become ~3.24. It becomes smaller than 3, which you can prove by fitting it comfortably within a sphere of height 3 (radius of 1.5).


texts:
I'd like to draw a 2Dimensional coordinate system using C#. Unfortunately, in terms of a graphics rendering engine, XNA is out of the question since I'm running Linux. Thus, is this possible without XNA? How exactly would I go about doing this? My goal is to have something which allows the user to click on any specific area and have a dot appear in the spot where the mouse has clicked.

If I can't do this in C#, how would I go about coding it in C++?


texts: How wise is this multithreading architecture?

texts:
I'm rewriting a game engine I wrote in an attempt to parallelize as much as possible. I'm considering making properties which may be accessed from multiple threads all use accessors which use boost scoped_locks to avoid race conditions.

So then this way, say I have a character with base class CharacterBase. The X/Y/Z coords of the character are controlled through accessors with scoped locks. The main loop has 3 threads running, one to process physics, one to process rendering and one to process user input etc.

This will result in scoped_locks basically being everywhere and explicitly required by design when users are extending the engine. I am planning on making this open source so I'm wondering if there are any significant flaws or draw-backs in this design either from a technical perspective or end-user perspective (for those extending the engine). Thanks!


texts: Should I load scenes from files, or hard code them?

texts:
In a game engine I'm working on, I'm using scenes similar to what you would find in Unity. The entities, in my game, are composed of reusable components and custom data which is linked to those components. Entities have children, and one parent. This is shown, below:

class Entity {
    ...custom data here...
    let parent : Component
    var children : [Component] = []
    var components : [Component] = []

    ...methods...
}

If the entities did not have custom data, then creating a scene would be described by the following steps:

Loading a file into memory.
Creating a tree of entities.
Adding components to them, with parameters listed in the file.

However, this does not leave room for custom data. My other alternative is to create a scene by creating a scene object, then hard-coding the entities in. It would look something a bit like this:

var opening_scene = Scene()

opening_scene.addEntity(Player())
opening_scene.addEntity(Car())
opening_scene.addEntity(Terrain())
...

The downside to this is that everything is hard coded. What can I do to create scenes in a game more efficiently?


texts: Physics simulation methods for large delta times?

texts:
What physics simulation methods are most suitable for really big delta time (hours to weeks)?

In addition, would I face any problems combining different methods for big and small delta times?


texts:
What is the most common way modern games perform triple buffering ?
What does the SwapBuffers exactly do in terms of OpenGL states ?
Is it possible to perform double and triple buffering independently of window system (for example, by manipulating with glDrawBuffer or by using FBO/PBO) ? If so, any hints ?
Does 3. even make sense in terms of performance and flexibility ?


texts: Has anyone used WiiFlash for developing Flash games? Any pointers on how to begin developing games for the Opera channel for the Wii?


texts: AABB collision detection not detecting in some cases

texts:
I'm using simple AABBs in a tile based world, and for some reason the algorithm does not detect collisions when moving towards the left and then down. I actually upload a video to YouTube to demonstrate the problem because I can't figure out a good way to explain my problem. Here it is:
AABB collision detection problem

As you can see, the little wireframe tile that moves around is the player, and when I move to the left, and then try to move down on the tiles, the player just slips right through. Detection works when moving to the right. Here's my algorithm to detect collisions:

public static boolean isColliding(AABB a, AABB b) {
    if (Math.abs(a.pos.getX() - b.pos.getX()) < a.size + b.size) {
        if (Math.abs(a.pos.getY() - b.pos.getY()) < a.size + b.size) {
            return true;
        }
    }
    return false;
}

The pos variable in the AABB class is the center of the AABB in question, and the size is half the size. Here's how I move the player:

if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
        move(0, 1, 0, MOVESPEED);
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
        move(1, 0, MOVESPEED, 0);
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
        move(-1, 0, -MOVESPEED, 0);
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
        move(0, -1, 0, -MOVESPEED);
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_SPACE) && onGround) {
        onGround = false;
    }

Which references this method:

private void move(float x, float y, float sx, float sy) {
    if (getX() / 32 + x >= 0 && getX() / 32 + x <= world.mx && getY() / 32 + y >= 0 && getY() / 32 + y <= world.my) {
        if (world.tiles[(int) ((int) getX() / 32 + x)][(int) ((int) getY() / 32 + y)] != null) {

            Tile t = world.tiles[(int) ((int) getX() / 32 + x)][(int) ((int) getY() / 32 + y)];
            Vector2f tempPos = new Vector2f((pos.getX() + (pos.getX() + 32)) / 2, (pos.getY() + (pos.getY() + 32)) / 2);
            box.update(new Vector2f(tempPos.getX() + sx, tempPos.getY() + sy), 16);
            t.color = true;

            if (!Collision.isColliding(box, t.getBox())) {
                setPos(getX() + sx, getY() + sy);
            }
        } else {
            setPos(getX() + sx, getY() + sy);
        }
    } else {
        setPos(getX() + sx, getY() + sy);
    }
    glPushMatrix();
    glTranslatef(getX(), getY(), 0);
    glPopMatrix();
}

32 is the tile size and the player size, just for reference. The 'tempPos' vector is just a vector that holds the center of the player's position. AABB is a class that stores a vector and a size variable, and the update method just updates those variables.

I guess my question is either, why is it only working on one axis, or how can I change my move method to be "better"? I've been trying to figure out why this isn't working, and I just can't come up with any ideas because it happens constantly, so it's not that my entities are moving too fast and the algorithm isn't detecting the collisions.


texts: How can I compare two quaternions for logical equality?

texts:
I'm trying to write some unit tests and realize I don't know how to compare quaternions. I need to know if two quaternions represent the same orientation (the object would be facing the same way). With a vector like position I'd simply compare the parts and check they are close enough, but for quaternions the values can be very different.

How can I compare two quaternions?


texts: Backface culling without light leaking through

texts:
I want to be able to see through walls, so to do this I used planes for the walls, and enabled backface culling. However with shadow mapping I have a lot of light leaking through:

I read that using a thick wall solves this, so I did just that. This solved the leaking light:

but now I cannot see through the walls (camera is within the room in the above screen), all the backfaces are inward.

How could I prevent light leaking, as well as enable seeing through the walls?


texts: How do I pick tiles from an isometric map with slopes?

texts:
I'm looking for a way to convert mouse/screen coordinates to isometric map coordinates, with the addition that the world has slopes and cliffs, and I have to be able to tell which quadrant of the tile is being pointed at by the mouse. The textures are handled by OpenGL, so I can't (easily) pick directly based on the tile sprite.

I've found several similar solutions, (e.g. Isometric Tiles Math, XNA Resources & Mouse Maps for Isometric Height Maps with the latter looking most promising) but none of them seem to quite fit my requirements.

My tiles look like this:

What algorithm or technique could I use here?