texts:
I'm a C++ newbie working on adding gamepad support to Moai as a learning exercise and because I'd like to be able to use a gamepad with it. I'm starting by implementing the Xbox 360 gamepad via XInput and that's going pretty well. Eventually I'd also like to support the PS3 gamepad.

This has got me thinking: the 360 and PS3 pads are mostly similar. They have the same number of buttons in more or less the same places that do more or less the same things (e.g., the right trigger on the 360 pad is an analog trigger, so is the R2 trigger on the PS3 pad). From the standpoint of creating an API to support both pads the main difference is the labeling applied to each button.

The PS3 square button is in the same place as the 360 X button, triangle matches Y, circle matches B, and X matches A. Some comparison images:

When creating the API to work with gamepads I see a couple ways to approach it:

Use the 360 naming conventions exclusively.
Use the PS3 naming conventions exclusively.
Come up with something in between.

I'd like to go with option #3 and could devise my own solution easy enough but don't want to reinvent the wheel unnecessarily.

Is there some standard naming convention used for a gamepad API that supports both 360 and PS3 (and possibly other, similar) gamepads? Is this even really an issue -- should I just create an API, document it and call it good?


texts:
I am developing a solar system animation in Unity3D. Planets rotates around sun. But ı have an issue simulating satellites like Moon. Moon should be rotating around world normally and moon should be rotating around World. Since World is rotating around Sun , i am having trouble about calculating  true rotation for moon. I don't want to use rotateAround() since it is deprecated. I need to make this done using Rotate().

this is my planetScript

public class planetScript : MonoBehaviour {

    public GameObject target;//target is Sun for World, World for Moon etc

    public float rotateRatioCenter;//1 degree for World
    private float rotateSpeedTarget;

    public float rotateRatioAround;//365 for World
    private float rotateSpeedAround;

    public float counter = 0;
    void Start () {
    }

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

     rotateSpeedTarget = rotateRatioCenter * gameMasterScript.rotateAroundCenterRatio;//  rotateRatioCenter * 1 ,
     rotateSpeedAround = rotateSpeedTarget * rotateRatioAround;
     float yRotate = transform.eulerAngles.y;

     transform.Rotate(Vector3.up, rotateSpeedAround);

     rotateAroundTarget();
    }

    void rotateAroundTarget()//this is the method should be optimized
    {
        Quaternion quaRot = Quaternion.Euler(0, rotateSpeedTarget, 0);
        transform.position = quaRot * (transform.position - target.transform.position) + target.transform.position;
    }
}

gameView


texts: Unity how do I play an intro only the first time the player starts the game?

texts: I have an intro animation scene in my game that I want to play the first time the player hits play from the main menu. How do I do this?


texts: Input.GetAxisRaw not returning zero after releasing the key

texts:
In my WebGL Project here is the way for camera navigation (Movement/Rotation) on Update event:

void UpdateMovement()
    {

        bool accelerate = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
        moveDirection   =
            new
            Vector3(
                Input.GetAxisRaw("Horizontal") * moveSpeed,
            0,
            Input.GetAxisRaw("Vertical") * moveSpeed);
        //moveDirection = new Vector3(Input.GetAxis("Horizontal") * moveSpeed, 0, Input.GetAxis("Vertical") * moveSpeed);
        moveDirection   = transform.TransformDirection(moveDirection);

        if (Input.GetButton("Up"))
        {
            moveDirection.y += moveSpeed;
        }
        else if (Input.GetButton("Down"))
        {
            moveDirection.y -= moveSpeed;
        }

        if (Input.GetAxisRaw("Mouse ScrollWheel") > 0)
        {
            moveDirection.y = moveDirection.y + scrollSpeed;
        }
        else if (Input.GetAxisRaw("Mouse ScrollWheel") < 0)
        {
            moveDirection.y = moveDirection.y - scrollSpeed;
        }

       moveDirection *= (accelerate ? speed : moveSpeed);
        controller.Move(moveDirection * Time.deltaTime);

    }
    void UpdateRotation()
    {
        if (!Input.GetMouseButton(1))
            return;

        rotationX += Input.GetAxis("Mouse X") * lookSpeed;
        rotationY += Input.GetAxis("Mouse Y") * lookSpeed;
        rotationY = Mathf.Clamp(rotationY, -90, 90);
        rotationZ = Input.GetAxis("Mouse ScrollWheel");

        transform.localRotation = Quaternion.AngleAxis(rotationZ, Vector3.forward);
        transform.localRotation = Quaternion.AngleAxis(rotationX, Vector3.up);
        transform.localRotation *= Quaternion.AngleAxis(rotationY, Vector3.left);
    }

All working fine but the problem on WebGL canvas when I rotate the camera using mouse and comes out of the bound of WebGl canvas meanwhile, I also continuously press horizontal or vertical key, then release input key doesn't work. Remember I logged the key[Input.GetAxisRaw("Horizontal"),Input.GetAxisRaw("Vertical")] input and found that it is not reset to zero on release.

 Debug.Log("Hr GetAxisRaw : " + Input.GetAxisRaw("Horizontal"));
 Debug.Log("Vertical : "     + Input.GetAxisRaw("Vertical"));

Normally when I don't use camera rotation using mouse and during this time, when i release the horizontal/vertical key, it works fine.


texts:
I have a project whose subject is "Sound Synthesis from object collision in Virtual Reality Environment" First of all, I have to define some objects with certain attributes (like shape, mass, material) and then I have to create sound from the collision of these objects in C++ according to their attributes, area of collision etc. I think I have to use some sort of Physics Engine like Bullet or ODE but I'm not sure how to start this project. Is there any Physics Engine specialized in Sound Synthesis?

I've come up with PhyA but I don't know how to download it and implement it. http://www.tech.dmu.ac.uk/~dylan/z/phya/

P.S. I intend to use CHAI3d or H3dApi because I have to use the Falcon device.


texts: Play animation when click on each player with in maincamera unity3d

texts:
I have 3 gameobjects (player1, player2, player3). I attached a script "playerscript" to these game objects.  In the main camera, I have added another script called "testscript". Clicking on a player should play the animation.  For that, I need to call the update() of "testscript.cs" in maincamera to the onMouseDown() of "playerscript.cs".

testscript.cs:

public class testscript : MonoBehaviour {
public bool selected;
public GameObject player1;
public GameObject player2;
public GameObject player3;

void Update () {
    //animation PickRightAndLeft
    player1.animation.Play("PickRightAndLeft");
}

playersscript.cs:

public class Playersscript : MonoBehaviour {
     void OnMouseDown () {
         Debug.Log (gameObject.name);
      }
}


texts: OpenGL Learning Material (that's up to date)

texts:
Possible Duplicate:
  What are some good learning resources for OpenGL?
  Good resources for learning modern OpenGL (3.0 or later)?

So im sure there are topics on this, but alot of them list older material. And the last book:
http://www.amazon.com/OpenGL-SuperBible-Comprehensive-Tutorial-Reference/dp/0321712617/ref=sr_1_1?ie=UTF8&qid=1346116133&sr=8-1&keywords=opengl

REALLY REALLY disappointed me. I DO NOT want to use someone else's library to learn this stuff, that bothers me SOOO much.

So I was hoping there was a newer book that goes into detail, and doesn't use some sort of library "Hiding" everything from you.

Or should I just look at older material? If so....anything thats not "too" out of date. Terrain tutorials are a plus (that's kinda my "goal").

Thanks


texts:
I'm currently creating a 3d game where I need to rotate shapes. To do se, I created a rotation matrix for each axis, X, Y and Z. X and Y are giving me expected results, but not Z who kind of "inverts the shape". I need it to rotate like it would rotate a 2d shape.

Here is the Z matrix :

zRotation.matrix[0][0] = cosf(rotationAngles.z);
zRotation.matrix[1][0] = -sinf(rotationAngles.z);
zRotation.matrix[0][1] = sinf(rotationAngles.z);
zRotation.matrix[1][1] = cosf(rotationAngles.z);
zRotation.matrix[2][2] = 1;

Here is what it looks like : https://imgur.com/a/3YR4Nlc

PS : The game have an isometric perspective.

EDIT : Here is how I do matrix * vector

vec3 operator *(vec3 operand){
    //multiply vector by matrix

    vec3 result = vec3((operand.x * matrix[0][0]) + (operand.x * matrix[1][0]) + (operand.x * matrix[2][0]) + (operand.x * matrix[3][0]), (operand.y * matrix[0][1]) + (operand.y * matrix[1][1]) + (operand.y * matrix[2][1]) + (operand.y * matrix[3][1]), (operand.z * matrix[0][2]) + (operand.z * matrix[1][2]) + (operand.z * matrix[2][2]) + (operand.z * matrix[3][2]));
    return result;
}

(Fourth element is always 0)


texts:
Before anyone say that this questions already has a answer, I will list all the questions I read and tried:

AABB collision resolution issues
Trouble with AABB collision response and physics
https://gamedev.stackexchange.com/questions/98323/hard-time-implementing-aabb-collision-into-a-platformer
2D Platformer AABB collision problems
2D Platformer Collision Handling
Collisions not working as intended
Checking Collisions In 2D Platformer With Tiles
And a lot more...

So, whats my problem? I am tring to implement a solid collision handling/response, but every time I try I fail. After fail with a lot of tile based solutions, like this one:

player.Y = tile.Y - player.height;

I am using the XNA Platformer Example as base, it is solid, but not completly. Some of the bugs is this:

This happens very often when the character is even wider than from the example. I solved it changing this line:

if (absDepthY < absDepthX || collision == GameMap.TileCollision.Platform)

To this:

if (absDepthY < absDepthX || collision == GameMap.TileCollision.Platform || _velocity.X == 0)

So, if the player isn't moving in the X axis, don't resolve it (resolve the Y axis instead). It worked very well, but it only hides the problem. After some gameplay the error is evident when you fall down and is pushed some tiles to the right. See this example from my game, I slowed down the X velocity:

I can't walk to the left and if I fall on the middle of the tiles, I'm pushed to the right. In the game the velocity isn't too slow, but as I said, it still happens. This is the real problem.

Update

The problem above was solved using David's solution, now I need implement the one-way platforms. The code I have so far is this, I commented the most important parts:

private void HandleCollisions(Direction direction)
{
    Rectangle playerBounds = BoundingRectangle;
    int leftTile = playerBounds.Left / (int)GameMap.Instance.TileSize.X;
    int topTile = playerBounds.Top / (int)GameMap.Instance.TileSize.Y;
    int rightTile = (int)Math.Ceiling((float)playerBounds.Right / GameMap.Instance.TileSize.X) - 1;
    int bottomTile = (int)Math.Ceiling(((float)playerBounds.Bottom / GameMap.Instance.TileSize.Y)) - 1;

    _isOnGround = false;

    for (int y = topTile; y <= bottomTile; ++y)
    {
        for (int x = leftTile; x <= rightTile; ++x)
        {
            Vector2 depth;
            Rectangle tileBounds = GameMap.Instance.GetTileBounds(x, y);
            GameMap.TileCollision collision = GameMap.Instance.GetCollision(x, y);

            if (collision != GameMap.TileCollision.Passable && GameMap.Instance.TileIntersectsPlayer(playerBounds, GameMap.Instance.GetTileBounds(x, y), direction, out depth))
            {
                if (collision == GameMap.TileCollision.Platform && direction == Direction.Vertical && previousBottom < tileBounds.Top)
                {
                    // This is reachable if I fall on a platform tile only from the top!
                    _isOnGround = true;
                }

                if (collision == GameMap.TileCollision.Block || (direction == Direction.Vertical && _isOnGround))
                {
                    // The position is increased
                    Position += depth;
                    playerBounds = BoundingRectangle;
                    // But the player falls through the platform block.
                }
            }
        }
    }

    previousBottom = playerBounds.Bottom;
}

If I jump from bellow of the platform, when I reach the top of the tile the _isOnGround is set to true, so the condition bellow is executed and the player is supposed to be pushed to top, but he falls through the platform. I debugged and the Position is really increased, but it only happens one time. What am I doing wrong?


texts: Batch/Combine multiple Graphics.DrawProcedural-Calls in Unity

texts:
I have multiple calls to Graphics.DrawProcedural in my Unity-project.
E.g. I'm drawing 1000 procedural geometries that share the same material and get their positions/meshes from a ComputeBuffer.

At some place in my code I'm doing something like this

foreach(ProceduralGeometry pG in proceduralGeometries)
{
    pG.Draw();
}

Where draw sets the Materials buffer accordingly and calls Graphics.DrawProcedural.

Is there anything I can do to batch all these geometries together? Currently I perform over 1000 DrawCalls (seen in the frame inspector) which happen to be very expensive performancewise.

Thanks in advance!


texts: How do I make a 2D game resolution independent?

texts:
I'm working on a simple 2D game. I've finished the mobile phone version.

However, my boss wants the game to works on his RT.
I'm doing the "conversion" but my buttons are in the wrong places, because I hard-coded the screen size, like this:

 texture = game.Content.Load<Texture2D>("StartScreen");
 mainFrame = new Rectangle(0, 0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height);

 // button definitions
 startbrect = new Rectangle(300, 258, 88, 88);
 startbtext = game.Content.Load<Texture2D>("bplay");

In this example, mainframe is fine, but startbrect isn't, because I defined the size to match a Windows phone's screen.
How can I handle responsive design when all Windows 8 phones' screens are different? Is there a formula or macro to calculate each time the good size?


texts: cocos2d looks like it is well supported and widely used, are there other good choices?

texts:
I've been googling a bit and looking for ios game frameworks. It looks like cocos2d has the mindshare, and it looks like it has an active community. It also fits my budget ($0.00), as this is really more for fun than anything else.

Are there other open source alternatives worth looking at?

To be a bit more specific on criteria, I'm interested in the following.

ios
open source
well used (i.e. used on more than a few games)
active community
should provide benefits over just doing it 'on your own'


texts: Creating an alphabet with numbers in 3d using opengl-es

texts: How should I create an alphabet with numbers in 3d in opengl-es? I'm trying to create them with the existing primitives, but it's not looking good. Do we have any alternate way to get these things done? If so, please let me know! Thanks in advance.


texts: Is there an out-of-the-box way to create a custom non-convex polygon in three.js?

texts: Does Three.js offer an out-of-the-box way to create custom non-convex polygon, or do I have to use THREE.Geometry and set faces manually? I'm guessing that ShapeGeometry has something to do with this, but I can't find either documentation or examples.


texts: How to have RTS units move along un-even terrain?

texts:
My current world is a flat 2D plane.
I want to make the terrain 3D, like hills, bumps, etc. If I tell a unit to go to a position (x, y) in 2D, how do I make sure the unit is always at ground level?
For example, if x, y is above the current position in 3D?
I am defining terrain height using a height map, and generating a simple mesh from it. Path-finding will remain flat 2-d, and can project to 3-d.


texts: Maya depth buffer plus OpenGL depth buffer

texts:
I am trying to write an plugin for Maya, using -among other things- OpenGL. Everything works fine so far, but the final Maya scenario is not taking into account the OpenGL depth buffer (or OpenGL is not taking into account the Maya depth). Hence, OpenGL things always appear "over" the Maya native objects.

I looked at the Maya's documentation and I found out that you can get Maya's depth may through MStatus M3dView::readDepthMap function, which basically returns a float array with Maya's depth.

I am now in a situation where I have two float arrays, one with OpenGL depth's and another with Maya's depth, and I believe I should combine them both somehow to get a final render in Maya that would respect both depth maps.

So, the question is, is there anyway to "add" depth information into OpenGL's renderbuffer / depthbuffer? Or... I am trying a completely wrong approach and there's a much nicer and better way to do this?

Thanks a lot!


texts: My Canvas has an image which I am using for my background but it is blocking my Camera from seeing my Game Scene

texts:
So I am not entirely sure how to explain this as I have not had any luck searching online and I'm sure this is a simple problem but I'm being stupid and can't see it.
I have a Canvas which is for my UI obviously and I have added an Image as a Background to the Canvas. The problem I am having is that due to the Image on the Canvas it is blocking my Camera from seeing the Scene with my game object you can see in the background.
On the Canvas, I have tried playing around with Sort Order, Render Mode, and see if I could edit the Z-Position but I can't seem to do that. I'm not too sure what I have missed but I must have missed something.
Any assistance would be great.


texts: How can I run two CCActions in parallel and another one afterwards with Cocos2D?

texts:
With Cocos2D I can run two actions in parallel by simply using runAction and I can use a CCSequence two run several actions after each other.
However what I could not find is:

Run two actions simultaneously
When both actions are done, trigger a third CCAction

It must be really easy but I seem to use the wrong search keywords on Google. :-)

The only possible solution I have found so far is to use a delayed action as the first element of a CCSequence and then start the third action. But it "feels" wrong.


texts: Unity - Duck volume of audio source inside a boxed area

texts:
I'm trying to lower the volume of an outside ambient wind sound while the player is inside a building or room. Is there any way in Unity to do this without scripting? Or would I have to script this to check whether the player is in a certain collider to duck (or lowpass filter) the sound?

The room is seamlessly in the scene's outside environment.

Any ideas on this?


texts: What is the order of postprocessing effects?

texts:
I am newbie in game development. I have read how many shader effects are implemented usually, and I have implemented msot of them by myself. However, now, I have the situation when I have to program my post process pipelines and so is the question: in what order should I do post process effects? Mostly I ask about: SSAO, blur, motion blur, chromatic abberation, fog, shadows... Actually, I am curios about all of them. So, the basic idea of my engine is:

Always draw everything to the texture.
Apply (so called by me - "prePostProcess") effects (lighting, for example).
Apply post process fx (blur and so on).

I understand that as I change the texture sequentially then the result will be different if I change the order in which programs are used to change the texture. Like: chromatic aberration and then blur is different between blur and then chromatic aberration.

I code my game with opengl 4.4 at this moment, so I tagged it so.


texts: How do I create modular/replaceable game/engine code interfaces with C++?

texts:
I've spent some time when I can spare it experimenting with c++ and at the same time learning a bit about game programming. I like most thought I'd start with creating a simple game engine but with some experimenting and plenty of advice along the lines of create a game, not an engine I forgot about the engine and just experimented with building a game.

Suffice to say in the process of doing that I hacked together rendering code (ogre3d) and physics (bullet) and input/output (OIS) and a couple of times over experimented with basic game ideas to the point of loading a map and being able to walk around it. Nothing special I know but it's an achievement for me.

Moving on from that now I would like to learn more about creating reusable code that falls more under engine programming than just a game. I'm sure the skills will be transferable to more than just games.

Basically I'd like to move from having everything intertwined to being able to separate and replace the individual parts. For example, build a 3d renderer dll/so in OpenGL and another with DirectX (as a dll). Or the same for other aspects such as Physics, sound, input, networking.

I'm learning about general dll programming and shared libraries on Linux but would like some more information with regards to game specific interfaces. I am also aware that Ogre3d which I previously mentioned is already cross platform and capable of both opengl and direct-x... I'm not saying I want to replace a library like that, more make it able to be unplugged and have something else plugged in instead.

So you are aware. My programming experience has been C with some more recent exposure to C++. Mostly recently I have been doing web development with both PHP and C#.NET (mostly php). I've also got average experience with c#, python, perl, etc. I'm a bit of a jack of all trades and I pick up things pretty quickly. What I'm hoping for is not to be spoon fed the code but rather some good places to research the concepts etc. (Although I won't turn down code if you're offering) ;)


texts: How can I iterate over the vertices of a mesh without an IndexOutOfRangeException?

texts:
I'm trying to draw a gizmo sphere at the location of each vertex in my mesh with the following code:

private void OnDrawGizmos()
    {
        MeshFilter selectedMeshFilter = (MeshFilter)objecttodraw.GetComponent("MeshFilter");
        Mesh mesh = selectedMeshFilter.sharedMesh;
        Vector3[] vertices = mesh.vertices;
        Color[] colors = new Color[vertices.Length];
        for (var i = 0; i <= vertices.Length; i++)
        {
            Gizmos.DrawSphere(vertices[i], vertices.Length);
        }
    }

I'm getting an exception, "Array index is out of range" on this line:

Gizmos.DrawSphere(vertices[i], vertices.Length);

  IndexOutOfRangeException: Array index is out of range.

  GetBounds.OnDrawGizmos () (at Assets/Scripts/GetBounds.cs:32)

  UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)


texts: Cube bounces back with rigidbody and script in Unity

texts:
I have Unity 4.6.1 and I added a cube with a moving script and a rigidbody. The script is:

#pragma strict

var speed : float = 10.0;

function Update () {

    // Is the user pressing left or right (or "A" & "D") on the keyboard
    var horMovement = Input.GetAxis("Horizontal");
    // Is the user Pressing up or down (or "W" & "S") on te keyboard
    var forwardMovement = Input.GetAxis("Vertical");

    if (horMovement) {
        transform.Translate(transform.right * horMovement * Time.deltaTime * speed);
    }

    if (forwardMovement) {
        transform.Translate(transform.forward * forwardMovement * Time.deltaTime * speed);
    }
}

And the rigidbody freezes position Y and freezes rotation X, Y, and Z. How do I stop it from bouncing back?


texts: Unreal Engine: Object Reference is not compatible with pawn Object Reference

texts:
Hello I am a beginner Unreal Engine developer learning with Blueprint and I am trying to take an imported FBX model and put a pawn control on it. Below is what I am trying to do. By the way, FbxScene_Test_Character is an actor.

What can I do to get around this error? Do I need to add extra information?


texts: I have downloaded completely different samples with water effects (in XNA) and I've noticed that they all exhibit a common problem: when the camera direction (only the direction, not the position)  moves, a noticable and annoying flicker occurs where the water meets terrain. I'm curios to find out more about this. Why does it happen? Does it have a name? And what can I do about it?


texts: Interpolate Entitiypositions received from Server

texts:
I want to Inter, or perhaps, extrapolate the positions of gameentities on the client. Those positions are received from the Server. The vague updaterate of the server makes it difficult to implement.

The Game is a html5 mmo tbs(turnbased strategy) game. That means you have a huge map with lots of players with their bases and tanks and so on. Units move on a grid

Here is how the Server works:

Node.js Server, so no true multithreading
Authoritative Server (Physics are calculated here)
Physics Loop 15ms / Update Loop 45ms
Physics loop calculates new position every 200ms*
Updates Client only when something changes (so no heartbeat or whatsoever)
Update contains the path and the current position
TCP is used to update Clients

(*roughly, because some units are faster, and if driving diagonally, the pythagoras theorem is used -> ~283ms)

This means that the server provides updates roughly every 200ms. But due to     phase shift of the physic and update loop, as well as lags the real update times are like these:

3314, 239, 206, 177, 186, 2136, 218, 210, 204, 189, 221, 194
Note the bigger numbers 3314, 2136 are caused when the unit did not receive an update for a longer time. As far as I understand, the aberration of the numbers are caused by the 45ms of the updateloop. So the worst-case would be 200 +/- 45 ms (No lag taken into account)

What have I tried so far

I am currently using Interpolation but the movement is very choppy. I guess it is because of the uncertain updatetimes and perhaps because the current position of the unit is overwritten which messes with my interpolation. I am calculating the interpolation for each unit respectively. The clientside renderloop takes place roughly every 50ms

Following Code is all on the client.

This is the Code when updates happen:

updatePosition : function(unit,x,y){
    unit.position.x = x;
    unit.position.y = y;
    unit.lastPosUpdate = Date.now();
}

This is the interpolation calculation:

interpolateSingle : function(unit){

    if (unit.lastAnimationTime){
        unit.drawingInterpolationFactor =
                (unit.lastAnimationTime-unit.lastPosUpdate)/(200) *(-1)
        if (unit.drawingInterpolationFactor>0){
            unit.drawingInterpolationFactor = 0;
        }
        if (unit.drawingInterpolationFactor<-1){
            unit.drawingInterpolationFactor = -1;
        }
    } else {
        unit.drawingInterpolationFactor = 0;
    }
    unit.lastAnimationTime = Date.now();

    if(unit.lastPosUpdate){
        //map.grid is 64 Pixels, unit.position is the worldposition in the grid
        //unit.sprite.position is the worldposition in pixels
        var dX = unit.position.x - (unit.sprite.position.x / map.grid);
        var dY = unit.position.y - (unit.sprite.position.y / map.grid) ;

        unit.sprite.position.x = unit.sprite.position.x - dX * map.grid * unit.drawingInterpolationFactor
        unit.sprite.position.y = unit.sprite.position.y - dY * map.grid * unit.drawingInterpolationFactor
    }
}

I guess my approach is pretty miserable. So what did I do wrong, what more
do I have to take into account? I do have information about the Path, tho, So I could theoreticaly extrapolate?


texts:
I want to write custom inspector for one of my scripts. All I want to change is input method for one of the strings to popup (so instead of writing whole string everytime I choose it from premade list of strings, like enums, the list is different for every dialogue). But the thing is it's VERY long inspector with a lot of variables and rewriting everything just for this one input doesn't click for me. Other problem is that this string is nested deep in the serializable object arrays, it look like so

I'm very happy with how default inspector shows all the fields, expect this one string I want to change. I tried playing around with SerializedProperty but no luck.

If it comes to available options I populate public string array with the names in the inspector (every dialogue has different list of participants) so the options should vary between different dialogues. What's the best way to set options?

Is there a way to do it without rewriting whole inpector on your own?


texts: how to design and develop game level(stages)

texts:
I need some expert opinion about game level design. I've been developing android game(2D) using LibGDX framework inspired from below sample game.

LibGDX sample Drop game

I've customized this game and made several changes as I am novice in gaming industry. Now, I need some help related to level(stages) design. I've just implemented level-1. As level increases , complexity increases. Should I'll have to implement new screen for each and every level and write separate code related to that screen. Or, there is some better approach? I want there should be single game play screen(except splash, menu and help screen etc) that should override sprite as level changes. I've searched a lot but didn't find useful article.
Looking for useful links, article or online tool anything.

what should be the best design approach as performance is really matters. Should file reading is good approach or use sqllite ? What should be the best practices while designing these things as I am the one man army. Is there any level editor that will help.


texts:
I've heard about data driven design and have been researching about it for a while. So, I've read several articles to get the concepts.

One of the article is Data Driven Design written by Kyle Wilson. As he described, it seems to me that the application code (i.e. the code for controlling resources such as memory, network...) and the game logic code should be separated, and the game logic code should be driven by external data sources. At this point, I can imagine that the developer would write some sort of game editor which accepts external data about in-game objects (such as character information, weapon information, map information...). The scenario design will be scripted by custom language/tool written by programmer to let the game designer create interaction between in game objects. The game designer will either use an existing/custom scripting language to write script for the game, or drag and drop tool to create game world. Example of tool approach I can think of is World Editor, which usually packaged along with Bliizard's games.

However, another article is against the use of Data Driven Design, The Case Against Data Driven Design. The author suggests to not let the game design driven by data, because it would take more time to develop a game, since the game designer has the burden of programming. Instead, there will be a game programmer to program the game freely from the sketch design, and is verified by the game designer after the game programming is finished. He calls this is programmer driven. What I think of this method is similar to the way I used to do: The game logic is the application itself, as apposed to the above idea, the application is the game editor, and the actual game is designed based on the tool.

To me, the first method seems to be more reasonable, since game components can be reused for many projects. With the second method which opposes data driven design, the game code belongs to that game only. This is why I think Warcraft has so many game genres in it, such as the original Warcraft and various custom maps, and one of the most famous: DOTA which actually defines a new genre. For this reason, I heard people call the World Editor is the game engine. Is this true how a game engine should be?

So, after all of this, I just want to verify that is there any flaw in my understanding about these ideas (data driven, programmer drive, scripting etc...)?


texts:
I made the game space shooter. In my game the boss take too much time to fire and the enemy not even come in the screen. So how to manage the fire speed and make the level tough.Click the link on 2 and 3 also for image view.

shootscript. cs

using UnityEngine;
using System.Collections;

public class ShootScript : MonoBehaviour {

    public int dammage = 1;
    public bool isEnemyShot = false;
    public Sprite lightDestroy;
    public float laserTime;
    private float increament;

    void Update()
    {
        laserTime -= Time.deltaTime;
        if (laserTime <= 0) {
            Destroy(gameObject);
        }
    }

    void FixedUpdate()
    {
        if (!isEnemyShot) {
            this.transform.Translate (Vector2.up * 6 * Time.deltaTime);
        } else {
            this.transform.Translate (Vector2.up * -6 * Time.deltaTime);
        }
    }

    void OnCollisionEnter2D( Collision2D coll)
    {
        if (coll.gameObject.tag == "Player" || coll.gameObject.tag == "Enemy")
        {
            gameObject.transform.localScale = new Vector2 (1, 1);
            gameObject.GetComponent<SpriteRenderer> ().sprite = lightDestroy;
            gameObject.GetComponent<BoxCollider2D> ().isTrigger = true;
            Destroy (gameObject, 0.05f);
        } else {
            Destroy(gameObject);
        }
    }
}

Weapon.cs

using UnityEngine;
using System.Collections;

public class Weapon : MonoBehaviour {

    public Transform laserPrefab ;
    public bool isEnemyWeapon = false;
    public float shootDelay = 1.0f;
    private float waitToShoot;

    public bool firingContinously = true;
    float nextFire = 0;
    float fireDelay = 400; // 100 milliseconds between each bullet

    void Start () {
        waitToShoot = 0f;
        firingContinously = true;
    }

    void Update () {
        if(Input.GetKeyDown(KeyCode.G)){
            firingContinously = !firingContinously;
        }

        if(firingContinously && !isEnemyWeapon)
        {
            if(Time.time * 1000 > nextFire){
                nextFire = (Time.time * 1000) + fireDelay;
                Fire();
            }
        }

        if (waitToShoot > 0) {
            waitToShoot = Time.deltaTime;

        }

        if (Input.GetKeyDown (KeyCode.Space) && isEnemyWeapon == false) {
            Fire ();
        }

        if (isEnemyWeapon == true && EnemyAttack == true) {
            waitToShoot = shootDelay;
            var shootLaser = Instantiate (laserPrefab) as Transform;
            Vector2 pos = shootLaser.transform.position;
            pos.x = transform.position.x ;
            pos.y = transform.position.y - 0.1f;
            shootLaser.transform.position = pos;
//          SoundHelper.instanceSound.EnemyLaserSound();

        }
    }

    public void Fire()
    {
        var shootLaser = Instantiate(laserPrefab) as Transform;
        Vector2 pos = shootLaser.transform.position;
        pos.x = transform.position.x;
        pos.y = transform.position.y + 0.5f;
        shootLaser.transform.position = pos;
        //SoundHelper.instanceSound.PlayerLaserSound();
        Debug.Log("Fire Method");

    }

    public bool EnemyAttack
    {
        get
        {
            return waitToShoot <= 0f;
        }
    }
}

[][1[Boss Laser[]2]3


texts: Implementing Skyrim's save system in Unity

texts: Unity has it's own way of saving in which you can add values and any type of information to the registry and it will be saved for future use. However what happens when you try to create a more complex save system such as the one featured in Skyrim. In this case it even get's a screenshot of the moment you pause the game to save and uses it to identify the save file. Also all the current actions the user and the npcs where doing at the moment gets save. How can I implement this complex save system into unity using it's current way of handling save data?


texts:
I have an entity's following details:

x, y
vx, vy
angle to x axis
its target

I want to reach the target by a parabolic path, how to implement an ai that follow a particular path from any given point to another like parabolic or sine wave.


texts: how to check previous scene in scene manager in unity 3d

texts: I'm trying to make my first game using unity 3d and I'm trying to make a game over the scene that when you press the try again? button it should take you back to the previous scene, I was thinking of just making it with the code SceneManager.GetActiveScene().buildIndex - 1)); then just place one after every level on the build index so that it takes to the previous level that the player was in, but I think this would just increase the file size (Idk if it actually does), so I was wondering if there is a more efficient manner on how to do this so that I could only have one Game Over Scene in the Build Index?


texts: Want event to occur when button is held but not when clicked

texts:
I'm wondering if there is a way to have an event occur when the left mouse button is held down, but not to occur when it is initially clicked. I think you can do something like...

if (Input.GetMouseButtonDown(0))
{
    // do stuff
}
else if (Input.GetMouseButton(0))
{
    // do other stuff
}

It looks at first like this would work because when left click is clicked it would execute the first if statement and not test for the second. And if left click is held it would fail the first if condition. But, does this in fact work? Do you actually enter the second if statement when attempting to click because you actually hold it down for slightly longer than a true click since this is happening in Update?

Now, I want to do this in one condition. Something like...

if (!Input.GetMouseButtonDown(0) && Input.GetMouseButton(0))
{
    // do the stuff that should happen when mouse is held but not clicked
}

but I don't think this works either. Any pointers?

For Context, I want to have something happen in every case when mouse button is held down, and only happen in some cases when mouse button is clicked.

if (Input.GetMouseButtonDown(0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()
|| !Input.GetMouseButton(0) && Input.GetMouseButton(0))

This doesn't work though


texts: How to tell if a glut window has focus from c#

texts:
How can I tell if a glut window has focus? Im using c#/tao, Ill use p/invokes if necessary.

Basically I want to ignore input if it doesn't have focus.


texts:
I'm creating a top down 2D RTS game for educational purposes.  Currently, I'm really just copying Starcraft's design/ideas.  I've decided I should probably implement Fog Of War too.

My expectations:

Areas currently explored (units are there) should be lit up.
Areas previsouly explored (units were there) should be darker but show what things were there when your unit was there.
Areas not explored (areas your units have never been to) should be completely black.
There should be a gradient change from each type (e.g. explored to previously explored) See picture below.

Just the rough details: How would I do this?


texts: Should I consider a cloud-based networking solution?

texts:
In my spare time for the past few years, I have been working on both the front-end and back-end for a space-based online game. This game is initially designed for the PC, and is hopefully able to host thousands of players in a massively playable universe.

Along with the development of the game, I have been building the networking solution almost entirely from scratch. The architectural design of the networking solution is based on a fairly traditional master-server > sub-server model. I recently was able to run some fairly decent-scale tests on this model and was pleased to see that both my expectations and goals were met. Which leads me to my current fear.

The basic idea behind the current solution is that the master server acts as a router. It knows about all of the currently active sub-servers, including their load (cpu, memory, bandwidth etc) and what the sub server is assigned to handle. The master server has literally no other purpose.

Each sub server is designed to handle one (or more) solar systems. The idea being: as a player, you connect to the master server and tell it which solar system you want to go to. The master server looks to see if there is a sub server already assigned to this solar system and sends you there, otherwise it finds the sub server with the least load and assigns that sub server to the solar system before sending you there.

The part that I am worried about is that this is pretty much as much as I can get out of this model. Once you have been sent to a solar system, you (and everyone else in that solar system) are on that sub server until you leave that solar system. Although I am happy with my testing so far, and that it looks to be able to handle around 300 fairly active peers, fairly comfortable on a well-fitted server, I am worried if I ever end up in the situation where this isn't enough.

I discussed this recently with a few acquaintances of mine. The discussion lead to a cloud-based network maybe being a better solution than single server machines acting as sub servers. Atmittedly, cloud commputing is fairly unknown territory for me. With that being said I've spent some time looking into this and I am fairly confident with the basics, but I have the following questions:

I assume that if I were to re-design the networking solution to work within a cloud-based network, I would no longer need the master-server > sub-server model, since I could build a single application that would handle all solar systems and peers, and that the cloud would scale based on the number of solar systems and peers?

Any and all advice is welcome!


texts: Transforming a primitive tetrahedron into a primitive icosahedron?

texts:
I've created a tetrahedron by creating a BoundingBox and building the faces of the tetrahedron within the bounding box as follows (see image as well):

VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[12];
BoundingBox box = new BoundingBox(new Vector3(-1f, 1f, 1f), new Vector3(1f, -1f, -1f));

vertices[0].Position = box.GetCorners()[0];
vertices[1].Position = box.GetCorners()[2];
vertices[2].Position = box.GetCorners()[7];

vertices[3].Position = box.GetCorners()[0];
vertices[4].Position = box.GetCorners()[5];
vertices[5].Position = box.GetCorners()[2];

vertices[6].Position = box.GetCorners()[5];
vertices[7].Position = box.GetCorners()[7];
vertices[8].Position = box.GetCorners()[2];

vertices[9].Position = box.GetCorners()[5];
vertices[10].Position = box.GetCorners()[0];
vertices[11].Position = box.GetCorners()[7];

What would I then have to do to transform this tetrahedron into an icosahedron? Similar to this image:

I understand the concept but applying it is another thing entirely for me.

And to clarify, I'm not wanting an animation, I simply want to create an icosahedron from the vertices of a tetrahedron.

EDIT: So I now have an alternative way to create an icosahedron using golden rectangles. That's fine for the purposes of my particular project. However, I'd like to leave the question open for solutions to the original problem, i.e. mathematically converting a tetrahedron in Cartesian co-ords into an icosahedron (not vice-versa).


texts:
using visual studio 2015 and SFML .
relevant code:

sf::Font font;
font.loadFromFile("Arial.ttf");
sf::Text text;
text.setFont(font);
text.setString("hello ");
_mainWindow.draw(text);

It doesn't display the text.
I put a breakpoint, the font gets the correct value.
but the text's string stays empty.
for the main window I get:
+       _mainWindow     sf::RenderWindow

Can anybody help?

thanks


texts: Unity3D - JsonUtility returns empty string

texts:
i have the problem that when I convert an instance of highscores through JsonUtility.ToJson the value of my value of it is always {"highscoreEntryList":[{},{},{},{},{},{},{},{},{},{},{}]}...

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

public class HighScoreTable : MonoBehaviour
{
    private Transform entryContainer;
    private Transform entryTemplate;
    private List<HighScoreEntry> highScoreEntries;
    private List<Transform> highScoreEntryTransformList;
    private void Awake()
    {
        entryContainer = transform.Find("HighScoreEntryContainer");
        entryTemplate = entryContainer.Find("HighScoreEntryTemp");

        entryTemplate.gameObject.SetActive(false);

        highScoreEntries = new List<HighScoreEntry>()
        {
            new HighScoreEntry { Score = 9999, Name = "T1"} ,
            new HighScoreEntry { Score = 9282, Name = "T2"} ,
            new HighScoreEntry { Score = 9942, Name = "T3"} ,
            new HighScoreEntry { Score = 2419, Name = "t4"} ,
            new HighScoreEntry { Score = 2390, Name = "t5"} ,
            new HighScoreEntry { Score = 9282, Name = "t7"} ,
            new HighScoreEntry { Score = 2918, Name = "t6"} ,
            new HighScoreEntry { Score = 4921, Name = "t8"} ,
            new HighScoreEntry { Score = 1318, Name = "t9"} ,
            new HighScoreEntry { Score = 8818, Name = "t10"} ,
            new HighScoreEntry { Score = 9231, Name = "t11"} ,
        };

        highScoreEntryTransformList = new List<Transform>();
        highScoreEntries.Sort((first, second) => second.Score.CompareTo(first.Score));

        foreach (var highScoreEntry in highScoreEntries)
            CreateHighScoreEntry(highScoreEntry, entryContainer, highScoreEntryTransformList);

        Highscores highscores = new Highscores {highscoreEntryList = highScoreEntries };
        string json = JsonUtility.ToJson(highscores);
        PlayerPrefs.SetString("highscoreTable", json);
        PlayerPrefs.Save();
        Debug.Log(PlayerPrefs.GetString("highscoreTable"));
    }

    private void CreateHighScoreEntry(HighScoreEntry highScoreEntry, Transform container, List<Transform> transformlist)
    {
        float tempHeight = 40f;
        Transform entryTransform = Instantiate(entryTemplate, container);
        RectTransform entryRectTransform = entryTransform.GetComponent<RectTransform>();
        entryRectTransform.anchoredPosition = new Vector2(0, -tempHeight * transformlist.Count);
        entryTransform.gameObject.SetActive(true);

        entryTransform.Find("posText").GetComponent<Text>().text = "" + (transformlist.Count + 1);
        entryTransform.Find("scoreText").GetComponent<Text>().text = "" + highScoreEntry.Score;
        entryTransform.Find("nameText").GetComponent<Text>().text = "" + highScoreEntry.Name;

        transformlist.Add(entryTransform);

    }

    private class Highscores
    {
        public List<HighScoreEntry> highscoreEntryList;
    }

    [Serializable]
    private class HighScoreEntry
    {
        public int Score { get; set; }
        public string Name { get; set; }
    }
}

My List property is public and i also tried to write [SerializeField] over it.


texts: I want to render some surfaces in GLSL with normal maps, and some without

texts:
I have normal mapping working in my game, but I want to only use normal mapping for some surfaces, and not others.

Right now, as far as I can tell, my shader is applying an incorrect normal of (0, 0, 0) in tangent space to my non normal mapped surfaces, since no textures are bound to the sampler.

Is there a suitable way of detecting that nothing is bound to a sampler in GLSL and then using a flat normal instead? I've also found old posts around the web recommending the following:

Using a dummy 1x1 texture with the color (128, 128, 255) - this will lose Phong interpolation.
Switching shader programs for normal mapped and non-normal mapped surfaces - I get the feeling that I'd end up duplicating a lot of code this way, especially when I start implementing specular maps, parallax displacement maps, etc.

Are either of these still recommended or is there a new feature to query the sampler that I could make use of? Should I be doing it one way over another for performance reasons?

Here is my fragment shader:

#version 330 core

in vec2 UV;
in vec3 tangentSpaceLightDir;
out vec4 outColor;
uniform sampler2D diffuseMap, normalMap;

void main (void)
{
    vec4 texel = texture(diffuseMap, UV);
    vec4 ntexel = texture(normalMap, UV);

    // I want to use vertex normal here, if nothing is bound.
    vec3 N = normalize(ntexel.xyz * 2.0 - 1.0);

    vec3 L = normalize(tangentSpaceLightDir);

    float lambertTerm = dot(N, -L);

    vec4 finalColor = vec4(0.0);
    if (lambertTerm > 0.0)
    {
         finalColor += vec4(lambertTerm, 1.0);
    }

    outColor = finalColor * texel;
}


texts: Breaking up a map so countries can be colored separately in Spritekit

texts:
I'm currently trying to build a little strategy game where players take control of countries on an world. Each player's countries are represented by having a different color background but as each country is a different irregular shape I'm wondering how best to build this. To be clear I know how to change the color of a sprite or texture, but I'm wondering if there's a better approach to building the map then I outline below

My initial thought is that I export each individual country sprite and then use a shader etc. to change the background color when required. To do this I would obviously need to piece together each scene manually and make sure my countries line up correctly against each other to form the whole world.

This means I can't really create any 'dynamic' worlds. i.e. each map has to be hand curated.

Is there a better way to approach this without having uniform shaped countries? Bearing in mind this is a 2D game and there isn't really physics, could I use a physics body or something similar to get the actual shape of a country, and perhaps make sure each sprite has a white/transparent background then just change that particular color? Leaving the border black or whatever color I choose.

My fallback option is just having a building on each country that has a flag representing the faction color as this would be a lot easier to do.


texts:
I've been looking at the example at: http://create.msdn.com/en-US/education/catalog/tutorial/collision_2d_perpixel and am trying to figure out how to adjust the sprite once a collision has been detected. As David suggested at Sidescroller variable terrain heightmap for walking/collision, I made a few sensor points (feet, sides, bottom center, etc.) and can easily detect when these points actually collide with non-transparent portions of a second texture (simple slope). I'm having trouble with the algorithm of how I would actually adjust the sprite position based on a collision.

Say I detect a collision with the slope at the sprite's right foot. How can I scan the slope texture data to find the Y position to place the sprite's foot so it is no longer inside the slope? The way it is stored as a 1D array in the example is a bit confusing, should I try to store the data as a 2D array instead? For test purposes, I'm thinking of just using the slope texture alpha itself as a primitive and easy collision mask (no grass bits or anything besides a simple non-linear slope). Then, as in the example, I find the coordinates of any collisions between the slope texture and the sprite's sensors and mark these special sensor collisions as having occurred. Finally, in the case of moving up a slope, I would scan for the first transparent pixel above (in the texture's Ys at that X) the right foot collision point and set that as the new height of the sprite.

I'm a little unclear also on when I should make these adjustments. Collisions are checked on every game.update() so would I quickly change the position of the sprite before the next update is called?

I also noticed several people mention that it's best to separate collision checks horizontally and vertically, why is that exactly?

Open to any suggestions if this is an inefficient or inaccurate way of handling this.

I wish MSDN had provided an example of something like this, I didn't know it would be so much more complex than NES Mario style pure box platforming!


texts: Multiple bodies or multiple fixtures for a wall in Box2D?

texts: I am making a game with a sort of "playfield" where the game takes place, acting as boundaries on a top-down shooter. I am using Box2D for physics, and I am questioning which of the following would be the most efficient. One option would be to have the playfield represented by a single static body, with four fixtures attached to it (top, bottom, left, and right walls). The other option would be to have four static bodies, one for each border fixture. Which is the fastest for Box2D to process?


texts: Why does every texture drawn cause a new draw call?

texts:
I'm currently working on a 2d sandbox tile game in LibGDX and I noticed I had 700+ draw calls. So checked my code and I could not find anything that would cause a new draw call. All the tiles are drawn between a single batch.begin() and a batch.end(). I commented out the code for rendering the tiles and I had around 2-3 draw calls. I can't figure out whats wrong so I am posting this here.

Here is the call chain of the render method:

In my world class:

public void render(SpriteBatch batch, ShapeRenderer shapeBatch) {

    batch.begin();
    chunkManager.render(batch);
    if (selectedBlock != null) batch.draw(gameScreen.app.assetManager.get("misc/block_selection_texture.png",Texture.class), selectedPosition.x * 32, selectedPosition.y * 32);
    batch.end();

}

World is calling chunkManager.render(..):

public void render(SpriteBatch batch) {
    //Render all the chunks
    for (Chunk c : activeChunks) {
        if (c != currentChunk) {
            c.render(batch);
        }
    }

    //Render Current Chunk the player is in in front of every other chunk
    currentChunk.render(batch);
}

ChunkManager is calling c.render(..):

public void render(SpriteBatch batch){
    //Render all Blocks inside the Chunk
    for(Block b:blocks.values()){
        b.render(batch); // <- this is the line I commented out
    }

    //Render all Entities inside the Chunk
    for(Entity e:entities){
        e.render(batch);
    }
}

Chunk is calling b.render(..):

public void render(SpriteBatch batch){

    float hp = hardness/maxHardness;

    //tint the blocks based on their health
    batch.setColor(1*hp,1*hp,1*hp,1);
    batch.draw(texture, x*32, y*32);
    batch.setColor(Color.WHITE);

}

and e.render(..):

public void render(SpriteBatch batch){
   if(isAnimated) {
       renderAnimation(batch); // -> just batch.draw(..) for animations
   } else {
       batch.draw(texture, x, y);
   }
}


texts:
I once read (I actually don't remember where, I'm looking for it) that using this.GameObject to call the script owner is a very bad practice.

I believe it has to do with some sort of information hiding, but I couldn't figure out why. What are the disadvantages with this? Is there a best-practice to achieve the result?


texts: Should I use different input layout for meshes (vertices) with and without normal maps?

texts:
I'm writing an DirectX11 game.

About 60% of my game models (or "of my vertices") have:

Position
Texture coordinate

Some of them use:

Position
Texture coordinate
Normals

And few of them:

Position
Texture coordinate
Normals
Tangents
BiTangents

And I have about 10 shaders:

3 of them assume that vertices have just position and texture coordinates
5 that they also have normals
2 make use of tangent/bi-tangent info

The question is: should I create 3 vertex structures and 3 D3D11_INPUT_ELEMENT_DESC arrays for them (option 1)? Or create only one, universal vertex structure (the last one, 5 members) and 1 D3D11_INPUT_ELEMENT_DESC for it (option 2)?

What I see:

Option 1:

No unused data will be transfered to shader - e.g. 60% of models will be rendered with simple shader that don't calculate normal maps and we will send to him just position/texture coordinate.

Option 2:

Only one input structure, no need to switch vertices types - simpler code, maybe faster (no switching)?, no need to bother if new shader needs 1st, second or third structure (we can just pass everything to it and it will decide which members to use).


texts:
Say this ball for example :

These three models have been created, to then use a simple morph transition to make the ball switch from 0 to 1 then to 2, and make it look like it's melting.

But is it possible to make a material that can be melted programatically? without need of having to make models for every object I want to be interacted with? And is it possible to make it as realistically looking as the first one shown in the pictures?


texts: Are models on 3D warehouse free of copyright?

texts: Are models on sketchup's 3D warehouse free to use for personal or commercial work? I haven't been able to find copyright information on the site.


texts:
I'm playing around with 3D graphics programming and it's only a few weeks I'm into OpenGL and able to render meshes with textures with few basic transformations.

I've a hobby project where I want to apply a picture of human face on a 3D mesh head. I'm not very clear about the best programmatic approach to do that.

I read about how textures are created using a UV map which is created using some sort of projection of vertices in 3D onto a 2D image plane. This UV map is taken as reference to create the texture so that the texture appears correctly when it folds around the 3d mesh object.

So for my application let's say I've 3D mesh head with a UV map. I'd like my application to map the picture of my face onto this UV-map and create a texture which folds as seamlessly as possible on the 3D mesh head.

Please suggest some approaches I can explore. Also what kind of image processing algorithm I should refer and what libraries would best suit my needs?

Edit 1:
Please check a similar app which is in market. https://play.google.com/store/apps/details?id=itseez3d.game.avatar&hl=en  They are taking only one selfie image and superimposing it with a UV-map template to create it. I'd like to do something on similar lines.


texts: Parent object is too far from children how can I fix it ? Parent is at 0,0,0 but the children in other position/s

texts:
When I make double click on the empty GameObject as it should be it's zooming to the children group :

I grouped all the npcs under emprt GameObject name Npcs but first I was reseting Npcs to 0,0,0 Now the arrows of the axis to drag and change the Npcs positions are far away. The idea was to easy move the npcs all the same time.

When I zoom out in the scene window this is where the Npcs is so if I will drag it and change it's positions I will not see where the npcs are moving to they are too far.


texts: Offset on camera following object that accelerates

texts:
I have camera a that is actively following an object (a plane) from behind. This object can accelerate or decelerate.

I would like to have a camera offset when I move the plane, so it doesn't look so static.

I have done this with the following code:

float cameraOffset = 0.05 * elapsed_time * 100;

Vector3 previousEye = camera->eye;
Vector3 newEye = ship->model * Vector3(0, 10, -5);
Vector3 eye = previousEye * (1 - cameraOffset) + newEye * cameraOffset;

Vector3 previousCenter = camera->center;
Vector3 newCenter = ship->model * Vector3(0, 0, 10);
Vector3 center = previousCenter * (1 - cameraOffset) + newCenter * cameraOffset;

Vector3 up = ship->model.rotateVector(Vector3(0, 1, 0));

camera->lookAt(eye, center, up);
previousModel = ship->model;

It works fine, except that when I increase the object's speed, the camera barely follows it. This is of course logical; my code is supposed to make it difficult for the camera to follow the plane.

However, I would like to have a lateral camera offset and also to keep following the plane from a relatively short distance.

Any hint on how to achieve this is appreciated.


texts: In Unity, how can I check if an input was made x seconds/frames ago?

texts:
I'm using the Rewired input plugin, and it comes with an input buffer. I enabled the buffer for my directional keys and airdash button so that the player doesn't have to hit both keys on the same frame in order to dash.

However, this means that if you press both keys and hold them down for more than a frame, the airdash code gets run again. I tried to stop this by comparing Time.time at the beginning of Update() to Time.time at the beginning of the coroutine, but this seems inconsistent and it doesn't feel like the right way to do it.

How would you check for the player's input time and compare it to the time since some previous input?

Here's a sample of the dash code within FixedUpdate()

        //Dash

        if (grounded)
        {
            dashCount = 0;
            dashTime = 0;
        }

        if (dashCount < 2)
        {
            //print(currentTime - dashTime);
            if (currentTime - dashTime < 0.1 || dashCount == 0)
            {
                //Double Tap Dash
                if (player.GetButtonDoublePressDown("Left"))
                {
                    StartCoroutine(Dash("left"));
                }

                //Button Dash
                if (player.GetButtonDown("Dash") && player.GetButtonDown("Left"))
                {
                    StartCoroutine(Dash("left"));
                }
            }

        }

        print(dashCount);

and here's a sample of the coroutine:

    //Dash
    IEnumerator Dash(string axis) {

        dashCount++;

        dashTime = Time.time;

        if (axis == "left")
        {
            if (inDash == true)
            {
                anim.SetBool("dashUp", false);
                anim.SetBool("dashDown", false);
                anim.SetBool("Hover", false);
            }
            canControl = false;
            inDash = true;
            anim.SetBool("dashHorizontal", true);
            anim.SetBool("inDash", true);
            rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, 0);
            rigidbody2D.AddForce(-dashForceHorizontal, ForceMode2D.Impulse);
            rigidbody2D.velocity = Vector2.ClampMagnitude(rigidbody2D.velocity, maxVelocity);
            rigidbody2D.gravityScale = 0;

            yield return new WaitForSeconds(0.2f);

            rigidbody2D.gravityScale = 2;
            rigidbody2D.drag = 25f;
            yield return new WaitForSeconds(0.2f);

            if (grounded == true)
            {
                yield return new WaitForSeconds(0.1f);
            }

            rigidbody2D.drag = 0f;
            canControl = true;
            anim.SetBool("dashHorizontal", false);
            anim.SetBool("inDash", false);

            inDash = false;

            yield break;
        }
  }


texts:
Sorry, I searched it but couldn't figure how to apply it to my code reading the other answers to similar questions. I what to rotate a quad, my code is the following:

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, player_texture);
glBegin(GL_QUADS);
    glColor4ub(255, 255, 255, 255);
    glTexCoord2d(0,0); glVertex2f(hero.xValue(), hero.yValue());
    glTexCoord2d(1,0); glVertex2f(hero.xValue()+hero.lValue(), hero.yValue());
    glTexCoord2d(1,1); glVertex2f(hero.xValue()+hero.lValue(), hero.yValue()+hero.hValue());
    glTexCoord2d(0,1); glVertex2f(hero.xValue(), hero.yValue()+hero.hValue());
glEnd();
glDisable(GL_TEXTURE_2D);

I'm not sure about how to use the glTranslatef function, I tell it what is the center of my object?

In that case it would be:
hero.xValue()+hero.lValue()/2 (x) and hero.yValue()+hero.hValue()/2  (y)

I know I have to use both glTranslatef and glRotate, by the way. When I try, setting glTranslatef with the values I mentioned above, I get a texture floating far from where the hero actually is.

Any help on this matter will be appreciated, thank you.

Obs: hValue = height, lValue = lenght

Edit: New information to show the changes I made after @user55564's comment:

I call init() once, on there I set basic openGL and SDL stuff, among them:

glViewport(0, 0, WIDTH, HEIGHT);
glMatrixMode(GL_MODELVIEW);

then I call my draw function, it has in it:

while (running) {
    glLoadIdentity();

.
. stuff non-related to drawing
.

glClear(GL_COLOR_BUFFER_BIT);
    glClearColor(0, 0, 0, 0);
    glPushMatrix();
    glOrtho(0, WIDTH, HEIGHT, 0, -1, 1);

    // draws the player
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, player_texture);
    glTranslatef(hero.xValue(), hero.yValue(), 0);
    glRotatef(0, 0, 0, 1);
    glTranslatef(-(hero.xValue()+hero.lValue()/2), -(hero.yValue()+hero.hValue()/2), 0);
    glBegin(GL_QUADS);
        glColor4ub(255, 255, 255, 255);
        glTexCoord2d(0,0); glVertex2f(hero.xValue(), hero.yValue());
        glTexCoord2d(1,0); glVertex2f(hero.xValue()+hero.lValue(), hero.yValue());
        glTexCoord2d(1,1); glVertex2f(hero.xValue()+hero.lValue(), hero.yValue()+hero.hValue());
        glTexCoord2d(0,1); glVertex2f(hero.xValue(), hero.yValue()+hero.hValue());
    glEnd();
    glDisable(GL_TEXTURE_2D);
    glPopMatrix();

// then I use pushmatrix again to draw the enemies and the health bars of both enemies and player (these don't need rotation);
glPushMatrix();
    glOrtho(0, WIDTH, HEIGHT, 0, -1, 1);
.
.
.


texts: How to create an obstacle that sends the player in the air?

texts:
I'm making a game in UE4.25 and I have several obstacles in there. I want them to send the player in the air if the player walks or stumbles into them. (Kind of like a Fall Guys effect, like if you get hit by a nearby falling ball, you fall into the void or something.)
Is there a possible way to do this?


texts:
I have written some jumping code for my player in a platformer game. At the moment it has some basic logic which says that the player can jump if he is on the ground. The pseudocode looks something like this:

### Input Handling ###
if(jumpButtonPressed){
    if(onGround){
        jump
    }
}

### Player Update Loop ###
onGround = false
movePlayer
resolveCollisions
if(player collided with ground){
      onGround = true
}

This works fine for basic static tile levels, but when the player is standing on a descending platform, or moving down a downward slope for instance, it becomes very difficult to jump. The reason for this (in the case of the descending platform) is that the platform has moved from underneath him in that frame, so for that moment he is not actually colliding with the ground, and therefore the condition to be able to jump is not fulfilled.

Is there a general way to add some leniency into the jump mechanic so that the player can jump even if they are not technically on the ground for that exact frame? This seems like it should be quite a common problem but I cannot seem to find any similar questions on stackexchange or google.


texts: Rotating objects in an random rotation around center point

texts:
I almost have what I'm looking for. Still trying to understand rotation and spawning of objects.

I have a ground field with a number of spawn points (and they are placed randomly in a circle). It's working quite well.

I have the issue tho, that I'm spawning them in an angle I'm not intending to and I have troubles finding the issue and understanding the math to it.

This is what it looks like:

I want the rocks to be spawned around the circle on the ground, not 90° to it.

I have the following code:

Vector3 RandomCircle(Vector3 center, float diameter) {
    float r = diameter / 2;
    float ang = Random.value * 360;
    Vector3 pos;
    pos.y = center.y + r * Mathf.Sin(ang * Mathf.Deg2Rad);
    pos.x = center.x + r * Mathf.Cos(ang * Mathf.Deg2Rad);
    pos.z = center.z;
    return pos;
}


texts: Getting Parser Error: The identifier "delta" isn't declared in the current scope. in godot

texts:
this is the whole code

extends KinematicBody

signal health_updated(health)
signal killed()

var speed = 10
var acceleration = 10
var gravity = 0.2
var jump = 5

var mouse_sensitivity = 0.3

var direction = Vector3()
var velocity = Vector3()
var fall = Vector3()
export (float) var max_health = 100

onready var health = max_health setget _set_health
onready var head = $Head

func _ready():
    Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _input(event):

    if event is InputEventMouseMotion:
        rotate_y(deg2rad(-event.relative.x * mouse_sensitivity))
        head.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))
        head.rotation.x = clamp(head.rotation.x, deg2rad(-90), deg2rad(90))

func _physics_process(delta):

    direction = Vector3()

    move_and_slide(fall, Vector3.UP)

    if not is_on_floor():
        fall.y -= gravity
onready var invulnerability_timer = $invulnerabilitytimer
func damage(amount):
    if invulnerability_timer.is_stopped():
        invulnerability_timer.start()
        _set_health(health - amount)
func kill():
    pass
func _set_health(value):
    var prev_health = health
    health = clamp(value, 0, max_health)
    if health != prev_health:
        emit_signal ("health_updated", health)
        if health == 0:
            kill()
            emit_signal("killed")

    if Input.is_action_just_pressed("jump") and is_on_floor():
        fall.y = jump

    if Input.is_action_pressed("move_forward"):

        direction -= transform.basis.z

    elif Input.is_action_pressed("move_backward"):

        direction += transform.basis.z

    if Input.is_action_pressed("move_left"):

        direction -= transform.basis.x

    elif Input.is_action_pressed("move_right"):

        direction += transform.basis.x

    direction = direction.normalized()
    velocity = velocity.linear_interpolate(direction * speed, acceleration * delta)
    velocity = move_and_slide(velocity, Vector3.UP)


texts: How to stop my particle systems from being frustum culled

texts:
Please could somebody advise on whether it is possible to control the culling of particle systems in Unity? I am referring to the entire system, not individual particles.
In my use-case, I am modifying the vertex transformation to get the "distant object effect".
When the camera thinks it is not viewing something it will cull it (frustum culling).
For most game objects you can get around this by inflating the size of the bounds to make the camera think it is within its frustum and therefore not get culled. However, particle systems are not a single object, they are many particles and I can’t see a way of manipulating the total bounds of the system.
Any ideas?


texts: How can I plug a Unity application into native Android and native iOS?

texts:
There are a lot of questions about running native Android and iOS code in Unity.  I am trying to run Unity inside of native Android and native iOS apps.

My problem is that I have two native apps, and I don't want to write code twice when I add a feature.

I currently have two native apps - one in Android and one in iOS.  I am trying to write code once, and add it to both.  Can I write a Unity program, and put that into my native apps?

I am thinking something along the lines of writing a Unity Android app, building it as an Activity instead of an APK, and launching that Activity from the native android app.  Then also the equivalent in iOS, whatever that may be.

Does anyone know a solution to this problem?


texts: How to achieve single animation for different charcters?

texts:
I've been playing a game called Marvel Contesnt of Champions for android. In that game two opponent fights with each other in most 2D view but the game is developed in 3D. Each character has their own special move which dynamically interacts with opponent. So how does they achieve single animation for different characters?

By single animation I mean, for example, I'm playing with X character and he uses his special move on Y character and in that animation X character grabs character Y's neck and smashes him on the ground. Now, I'm fighting Z character with X character and in the special move he smashes Z character same way he smashed Y character. Is it like a common skeletal movements that are just changing their clothes(textures) ?

I'm pretty sure it's not pre-animated thing cause there are like more than 50 characters. I'm currently working in Blender and getting my character design right but this question was bugging me for a while and I thought there could be no better place other than here to clarify my confusion.


texts: How do I get and install the Android SDK on my Ubuntu OS?

texts:
I heard that it would be a lot easier to do java type games and then move on to Android gaming?
I AM a total beginning but with motive and I have been reading about it from several sources, including similar questions on this site alone.
But I need to know specific things from experienced users.

As for getting the SDK and Eclipse on the computer, I'm having trouble with it, I am running Ubuntu btw so exe files are useless. But I have tired terminal use but I kind of failed because I don't think the SDK and Eclipse are installed, just downloaded.
Ubuntu users especially, I can use help from you seeing how complicated Ubuntu can be compared to windows "click install" setups.

Also if you guys really suggest me learning Java first (which is still a big question cause I don't want to waste time with something I don't want to really use, but getting the feel of gaming is pretty important I know) I am looking at this tutorial:

http://zetcode.com/tutorials/javaswingtutorial/

And it talks about using swing toolkit, but idk how to get that exactly, I tried searching. Sorry for the noobness, but gotta start somewhere and I'm new to this site so I'm really hoping you guys can really help me. I want to make simple games to put on the android market, and then advance.

So going to the tutorial above, it just kind of starts with giving me coding and whatnot which is fine, just copy it but idk where exactly to do all this on (Swing toolkit?) so I can't even start with that.

But really I want help getting this SDK and Eclipse/plugins on my computer and then I can continue with this guide:

www.rbgrn.net/content/54-getting-started-android-game-development

Which is the main guide that I probably should follow, and would be great if some expert skims it a little at least to see if I should start with that guide and skip the java.
But again, I'm stuck on the SDK stuff.

Sorry for the long questions, I am new and I really want to get out of this beginner stage, it's the worst part. Tank you to all and if you want my facebook or AIM to help me through with IM to at least get this SDK and stuff installed fine with Ubuntu OS, ask please (:


texts: Need help with making number system for idle game

texts:
So, I want to create a new game. I have problems with how to store large numbers in the game and how to output them. I have written a small pseudo code that contains everything I need to play the game (Did I forget anything?).

# represent  our number
struct BigNumber {
    double base; # (or mantissa)
    double exponent;
}

# create new number
function NewBigNumber(double b, double exp) {
    return BigNumber{
        base = b;
        exponent = exp;
    }
}

# now if we have to BigNumbers we want add operation (+)
# and other operations (-), (*), (/)
# +
function adding(BigNumber n, BigNumber m){
    # if numbers have same exponent part
    if (n.exponent = m.exponent) {
        # adding base here
        double new_base = n.base + m.base;

        #create new BigNumber with new base
        return NewBigNumber(new_base, n.exponent);

    } else {
        #?????????
    }
}

# -
function subtraction(BigNumber n, BigNumber m){

}

# *
function multiplication(BigNumber n, BigNumber m){

}

# /
function division(BigNumber n, BigNumber m){

}

As you can see, I will use Scientific notation

I have a problem with the addition operation (and other), what if the exponent part of numbers are different?

Next I have this code.

# If we have achievement systems
# we need function equals of two numbers
function equals(BigNumber n, BigNumber m){
    if (n.base = m.base && n.exponent = m.exponent){
        return True;
    } else {
         return false;
    }
}

And finally, I need the function to output numbers nicely.

suffices = [
    'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'Dc', 'Ud',
    'Dd', 'Td', 'Qad', 'Qid', 'Sxd', 'Spd', 'Od', 'Nd', 'V', 'Uv', 'Dv',
    'Tv', 'Qav', 'Qiv', 'Sxv', 'Spv', 'Ov', 'Nv', 'Tt'
];
# now we need "good view numbers" function
# for exapmle
# 1000 - 1000
# 1000000 - 1Million
function(BigNumber n) {
    #????????
}


texts: Best way to gain C++ working experience for a job in games (coming from C#)

texts:
I am a software developer, experienced with C# (5 years experience) alongside a few other languages.

My "dream job" is working in video games as a developer.

Most jobs require knowledge of C++, which i currently don't have (except for some of the basics).

I've looked around, and most big game companies require something along 3-5 years of previous experience with C++.

My question is -- what would be a good route to get myself up to this required experience level, coming from C# ?

I've thought of some possible ways to do it:

Get more knowledge about C++ from books.
Participate in open-source projects that are written in C++.
What would be the best way to learn C++ and have working-level experience with it, in particular for the game industry?


texts: Render Texture shows opposite view of camera when rendered?

texts:
I am using render texture (cube) to render what camera sees into it. However, the render texture shows me opposite side of cameras view (flipped) instead of what camera sees. Any solution for this?

    void Update()
    {
         renderTexture.isPowerOfTwo = true;
         //Graphics.SetRenderTarget(renderTexture, 0, CubemapFace.PositiveZ);
         renderTexture.dimension = TextureDimension.Cube;
         camera.RenderToCubemap(renderTexture, 63);
    }

What camera sees:

What Render Texture shows:

What happens when I rotate Render Texture manually by hand 180 degrees:

So, instead of rotating per hand, what I want is for the render texture to be rotated via code so that what is in camera view is shown exactly the same in render texture view.


texts:
I'm not sure which way is the best way to do this for my purposes.
My purposes being having a textured (with an image) cube.

Also, I've been following a blend of tutorials, so I'm not sure which way is the most right and what I'm doing wrong (currently I haven't had the texture fit right).

Do I use glDrawArrays or glDrawElements?
For pointers, do I say gl.glVertexPointer(3, GL.GL_FLOAT, 0, vertices); and gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, textureData);
or
gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0); and gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0);
When do I bind/unbind the buffers? (gl.glBindBuffer(GL.GL_ARRAY_BUFFER, VBOVertices); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboTextureCoordHandle);) Before I establish the pointers or not in my drawing method at all?
Do I need to specify the UV coordinates/Texture Coordinates in the shader? If I'm getting a weirdly stretched texture, does that mean my fragment shader and setting the uniforms is working correctly?

Thank you!
I can supply more code, but I think I just need more information on the basics.


texts: Can I make a Cue in XACT to play two sounds?

texts:
I have my gun shot and reload sounds with their own cues, can I create a cue that points to both of them so they are played one after the other when playing the cue?

I would have tried the documentation but: Where is the XACT documentation?

UPDATE:

The documentation now found says:

  A cue allows a game programmer to play sounds. It is composed of one or more sounds, and is referenced through a sound bank.

and:

  ...XACT enables audio designers ... to create transitions between cues

So my hunch was correct! But still cannot find how to do it. Why why doesnt the tool come with a comprehensive manual? whats the point in creating it if you dont tell people how to use it!!??


texts: How can I get a list of sprites which are being drawn in the current viewport using XNA?

texts:
Just starting out using XNA to draw 3D scenes and have a question about determining which objects are currently visible.

If I load many thousands of sprites and shapes in a scene, then render the current view from a camera, is it possible to actually find (e.g. list to a text file) the IDs of those visible objects?

I guess another way to ask this is to say: how can I get a list of objects (e.g. sprites) which are being drawn in the current viewport?


texts: Directx Ray Tracing Dxr Support Application Issue

texts: I have a question, I have source code that is old that was built in visual studio 2003 and It does not allow me to compile DirectX12 code in visual studio 2003 so my Attentions was to take my old game I built and update it to support dxr ray-tracing but my question is, Is it better to code my dxr support in a "dll" and just use run-time linking to call each function upon execution of the game process "executable" or just code it to the application itself and execute it. Cause, I really don't want to rewrite all my code in visual studio 2017 to be honest there is several lines of code "over 10,000" so yeah any advice Much Appreciated.


texts: Correctly transforming normals for G-Buffer in Deferred Rendering

texts:
I have a deferred rendering system: first there is the G buffer generation, then there is the lighting or shading calculation on that gbuffer data.

However there seems to be an issue with various rendering algorithms and I can’t determine why that is. I think it’s because my normal’s Gbuffer texture or other G buffer texture does not have the proper format or space in terms of world space, tangent  space etc.

The algorithms that rely on normal information such as normal oriented ambient occlusion and parallax occlusion mapping don’t work they just look wrong And not what they’re supposed to be by a long shot.

In the G buffer generation stage, my vertex shader simply passes along world space vertex positions and world space normals to the Gbuffer's fragment shader. I do this by multiplying the world matrix or model matrix by the normal and by the position. In the fragment shader I then write these out as is to the G buffer.

Is this correct? Should I be passing along the Raw position & normals to the fragment shader and then multiplying the matrices in the fragment shader instead?

Edit 1:

Ok, So using the "normalMatrix" didn't change anything.  Here is a screen shot of my ambient-occlusion pass demonstrating the issue.  There is a screen space split that basically inverts the colors. and some other oddities.

The SSAO Shader is As Follows.

void main()
{

vec3 WorldPosition = texture(GPositionsTexture, In_TexCoords).xyz;
vec3 WorldNormal = normalize(UnScaleNormal( texture( GNormalsTexture, In_TexCoords ).xyz ));

vec3 Random = texture(KernalNoiseTexture, In_TexCoords * KernelNoiseScale).xyz;
vec3 Tangent = normalize(Random - WorldNormal * dot(Random, WorldNormal));
vec3 BiTangent = cross(WorldNormal, Tangent);
mat3 TBN = mat3(Tangent, BiTangent, WorldNormal);

float Occlusion = 0.0;
for (int i = 0; i < KERNEL_SIZE; ++i)
{
    // get sample position:
    vec3 Sample = TBN * Kernel[i];
    Sample = Sample * Radius + WorldPosition;

    // project sample position:
    vec4 Offset = vec4(Sample, 1.0);
    Offset = CamData.Projection * CamData.View * Offset;
    Offset.xy /= Offset.w;
    Offset.xy = Offset.xy * 0.5 + 0.5;

    // get sample depth:
    float SampleDepth = texture(GPositionsTexture, Offset.xy).z;

    // range check & accumulate:
    float RangeCheck= abs(WorldPosition.z - SampleDepth) < Radius ? 1.0 : 0.0;
    Occlusion += (SampleDepth <= Sample.z ? 1.0 : 0.0) * RangeCheck;
}

Occlusion = 1 - (Occlusion / KERNEL_SIZE);

Out_Diffuse = pow(Occlusion, Power);
}


texts: Collision Detection Game Design and Architecture

texts:
I've reading some articles about collision detection. My question here is about ideas on the design for it.

Baically I have a C++ game that has a main loop with entities with an update method. Based on keyboard input, these characters updates their positions.

My question is not about how to detect collisions, it's about getting ideas in which is the best way to implement this.
The game has a main character but also enemies that have to collide between them, so I'm not sure where to make all the iterations for checking collisions and if the right way is to check everything against everything.

Thanks in advance.


texts: I've got a sound looping from the start of the game, working exactly as I need it to. What I need is a second sound to alert the player that they have located the hidden object (the first sound is a locator sound to help them go in the right direction). My problem is that when I add the second sound to the object, there seems to be no change. Is there a way to add this second sound to go off when the player gets within the attenuation sphere? I don't want it to shut off the first sound though, just make the sound over it. That way if the player wanders away, they know where to go back to because the first sound will still be playing.


texts: First person camera world matrix issue (in THREE.js and webGL)

texts:
I'm trying to create a Portal-like effect in webGL using THREE.js.

I have two scenes connected by a pair of portals. The view of the 2nd scene in rendered inside the 1st portal using stencils and some matrix math

This is the code I use to determine the view in the portal:

function getPortalViewMatrix(cam, src, dst)
{
 var inverseCamToSrc = new THREE.Matrix4().getInverse(cam.matrixWorld).multiply(src.matrix);
 var rot = new THREE.Matrix4().makeRotationY(Math.PI);
 var portalViewMatrix = dst.matrix.clone().multiply(inverseCamToSrc).multiply(rot);

 return portalViewMatrix;
}

This setup worked as intended until I added first person camera controls, taken from this example.

Now, the view of the second scene is wrong whenever I rotate the camera (but remains correct if you only walk around), as you can see in here (only works in Chrome). The full source is also available there.

The PointerLockControls class I use places the Camera in a 'rig' to avoid gimbal lock:

yawObject -> pitchObject -> camera

The yawObject is rotated on the y axis.
The pitchObject is rotated on the x axis.
The camera itself remains fixed as a child of the pitchObject.

The PointerLockControls work very well, but because of this setup the matrixWorld property of the camera does not seem to represent the same values as with a free floating camera. And my understanding of matrix math is lacking to fix this problem.

I've tried different things like inverting the various matrices involved, using quaternions (decomposing camera.matrixWorld) but that has just been an exercise in random trial and error on my part.

Can anyone help me to understand this problem, and perhaps offer a solution?

Any help would be greatly appreciated.


texts: Mouse look rotation not rotating object axis in Unity

texts:
So, I made a simple First Person Camera script for my game, and the way it's supposed to work is the camera is rotated by localEulerAngles to rotate the camera around, and then just the Y-axis rotation is also applied to the character, so that he moves in the direction of the camera.

This isn't how its working now.

I've narrowed down the two most likely problems in the scripts, and this first one is from the camera controller:

player.transform.localEulerAngles = new Vector3(0, rotationX, 0);
cam.transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);

Note: the camera works just fine, and rotates perfectly in all directions.

Secondly, the player movement controller, which might not be actually be moving locally? I can't tell.

transform.Translate (new Vector3(0, 0, Input.GetAxis("Vertical") * walkSpeed));
transform.Translate (new Vector3(Input.GetAxis("Horizontal") * strafeSpeed, 0, 0));

There you go. Right now, even though the camera moves just fine with the mouse, and, incidentally, the whole script used to work, the player moves forward on the global Z-axis with W and backwards with S, all the while acting like a shooter on rails.

Thank you!


texts: Geometric clipping of triangles intersecting near plane

texts:
I was reading about how rasterization works but there is one topic I can't quite understand.
After perspective projection, our point is in clip space as I understand it.
Now we test all points in a triangle like so
rejected = true
for every point:
   if (abs(point.x) <= abs(point.w) &&
      abs(point.x) <= abs(point.w) &&
      abs(point.x) <= abs(point.w)
      point.w > 0) {
      rejected = false;
    }

So the triangle is only rejected if all points are behind the near clipping plane or fall out boundaries, but it can happen that one point is behind the near clipping plane and others are in front.
Now there is a part I don't understand.
To deal with this we somehow clip points in 3d space by constructing new triangles.
So how is this exactly works?
And why we can't just interpolate our z values to test if the point is behind or in front of the near plane?


texts: How do I export Daz3D characters into an XNA format?

texts: How do I export 3D animated characters created in Daz3D studio to a format suitable for inclusion in XNA video games?  I'm looking for instructions on how to make sure weight, bones, vertices and materials are properly translated over into an XNA useable format.


texts: What is an efficient way to deal with large, scrolling background images?

texts:
In my mobile game you basically you just fly up (infinite height) and collect stars.

I have many quite large background images, scaled down so that their width is the same as the device width. Then they are appended after each other during rendering.

Since I implemented these backgrounds, my game runs poorly. I've got about 20 background images with a size of 800x480 each; without backgrounds the game is quite smooth.

Does anyone have an idea how to implement this many backgrounds without making the game slow down?

The images are used as a 2DTexture.
If I leave the clouds out of the image and "just" display the blue part, the app still slows down. Showing some code is a bit difficult, because I got many many classes which will do the loading, rendering and display stuff. Basically its done as Google does it in there "spriteMethodTest" example here:
http://code.google.com/p/apps-for-android/source/browse/trunk/SpriteMethodTest

2 of these image set.

First: http://picbox.im/view/b7c8c86abb-01.png

Second: http ://picbox.im/view/3a8162314a-02.png


texts: How can be data oriented programming applied for GUI system?

texts:
I've just learned basics of Data oriented programming design, but I'm not very familiar with that yet. I've also read
Pitfalls of Object Oriented Programming GCAP 09. It seems that data oriented programming is much better idea for games, than OOP.

I'm just creating my own GUI system and it's completely OOP. I'm thinking if is data oriented programming design applicable for structured things like GUI.

The main problem I see is that every type widget has different data, so I can hardly group them into arrays. Also every type of widget renders differently so I still need to call virtual functions.


texts: OpenGL - Stack overflow if I do, Stack underflow if I don't!

texts:
I'm in a multimedia class in college, and we're "learning" OpenGL as part of the class. I'm trying to figure out how the OpenGL camera vs. modelview works, and so I found this example. I'm trying to port the example to Python using the OpenGL bindings - it starts up OpenGL much faster, so for testing purposes it's a lot nicer - but I keep running into a stack overflow error with the glPushMatrix in this code:

  def cube():
      for x in xrange(10):
          glPushMatrix()
          glTranslated(-positionx[x + 1] * 10, 0, -positionz[x + 1] * 10); #translate the cube
          glutSolidCube(2); #draw the cube
          glPopMatrix();

According to this reference, that happens when the matrix stack is full.

So I thought, "well, if it's full, let me just pop the matrix off the top of the stack, and there will be room". I modified the code to:

  def cube():
      glPopMatrix()
      for x in xrange(10):
          glPushMatrix()
          glTranslated(-positionx[x + 1] * 10, 0, -positionz[x + 1] * 10); #translate the cube
          glutSolidCube(2); #draw the cube
          glPopMatrix();

And now I get a buffer underflow error - which apparently happens when the stack has only one matrix.

So am I just waaay off base in my understanding? Or is there some way to increase the matrix stack size?

Also, if anyone has some good (online) references (examples, etc.) for understanding how the camera/model matrices work together, I would sincerely appreciate them!

Thanks!

EDIT:

Here is the pastebin of the full code: http://pastebin.com/QXxNisuA


texts: Algorithm for exploring/filling grid map

texts:
I'm working on a small game that takes place on a grid map. I'd like to write an AI that is able to explore the grid map by filling as much of its available space as possible.

From any given position there are four possible moves (north, south, east, west), but some of these may be blocked by walls. Also, once I visited a cell I don't want to visit it again. What's more, I want to avoid getting stuck: if moving in one direction means I'm going in a dead end, I'd rather not fill out that part of the grid.

Can you please help me with some pointers as to how I can do this?


texts: UNITY || How to access the "exit transitions" of the current played clip from the animator?

texts:
So, I have an animator , i can access it.
But from there I have no idea how to access the clips inside.
I need to access the transition of the clips.

I got as far as accessing the object of the "Animator" class.

EDIT:

It appears The TransitionInfo datatype doesnt provide conditions.
I need the conditions!


texts: What is the difference between a gameplay programmer and a game designer/developer?

texts: Gameplay programmers write game code, but so do game designers and developers. Where is the line drawn? What skills do gameplay programmers use that game designers or developers do not?


texts: Max Row and Col for Animating Sprite in Andengine

texts:
I want to animate a Sprite in Andengine , I have used the following

this.mSnapdragonTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mBitmapTextureAtlas, this,"arrow.png", 10, 10);

As show above in code its array is 10x10 that means I have 100 images to be animated, here is the image (I had individual image and joined it online so I created image below):

My issue is if I place this code and image it show black patch instead of animated image, i hv tried with 2x3, 4x2 animated sprite that is > working fine . Is my issue because of 10x10 ? what is the max row and col I can place to animate a Sprite in Above Code

Here is my output :


texts: Oscillating an object left and right based on it's current orientation

texts:
I'm currently implementing a fire animation in HTML5 Canvas using the phone's accelerometer.

Regardless of the phones orientation, the triangles for the fire move upward. So you can spin your phone around to what ever degree you wish, and the triangles will move towards the sky.

My issue is trying to implement an oscillation left and right for these triangles. Before I had the accelerometer hooked up, I just applied an oscillation to the x axis and everything worked fine. Now however because the triangles are moving in what ever direction up is, I need to somehow apply the oscillation to both axis depending on what the orientation of the phone is.

Could anyone help me out?

I'm using JS for this.

Thanks.


texts: Rendering artifacts on edges in Cardboard VR OpenGL ES 2

texts:
Unity beginner here. I've encountered this weird rendering artifacts in my Cardboard VR app on Android OpenGL ES 2: https://youtu.be/uJm4d3MwbRo
It doesn't occur in WebGL build: http://senovsky.wz.cz/virtualab/index.html
Does someone at least know how to call this artifact? Already tried searching for a solution, but I don't even know what keywords to use.

The app was build using the HelloVR scene from GVR SDK for Unity v1.130.1 https://github.com/googlevr/gvr-unity-sdk/releases and no default settings were changed. I tried changing the default overall quality settings to Ultra and Very High, didn't help.


texts: Sprite button not triggering "On Click()" event -Unity

texts:
Hi have created some buttons from sprite and I added image and button components on it.

I am just using sprites because In my game the camera can be moved on x and y. But I don't want my button to move and since UI buttons move with camera that is why I am not using them.

Here is the GIF to explain the scene: