texts: What is the benefit of triple buffering?

texts:
I read everything written in a previous question. From what I understand in double buffering the program must wait until the finished drawing is copied or swapped before starting the next drawing. In triple buffering the program has two back buffers and can immediately start drawing in the one that is not involved in such copying.

But with triple buffering if you're in a situation where you can take advantage of the third buffer doesn't that suggest that you are drawing frames faster than the monitor can refresh. So then you don't actually get a higher frame rate. So what is the benefit of triple buffering then?


texts: What is wrong with my specular phong shading

texts:
I'm sorry if this should be placed on stackoverflow instead however seeing as this is graphics related I was hoping you guys could help me:
I'm attempting to write a phong shader and currently working on the specular. I came acros the following formula: base*pow(dot(V,R),shininess) and attempted to implement it (V is the posion of the viewer and R the reflective vector). This gave the following result and code:

Vec3Df phongSpecular(const Vec3Df & vertexPos, Vec3Df & normal, const Vec3Df & lightPos, const Vec3Df & cameraPos, unsigned int index)
{
    Vec3Df relativeLightPos=(lightPos-vertexPos);
    relativeLightPos.normalize();
    Vec3Df relativeCameraPos= (cameraPos-vertexPos);
    relativeCameraPos.normalize();
    int DotOfNormalAndLight = Vec3Df::dotProduct(normal,relativeLightPos);
    Vec3Df reflective =(relativeLightPos-(2*DotOfNormalAndLight*normal))*-1;
    reflective.normalize();
    float phongyness= Vec3Df::dotProduct(reflective,relativeCameraPos);
    if (phongyness<0){
        phongyness=0;
    }
    float shininess= Shininess[index];
    float speculair = powf(phongyness,shininess);
    return Ks[index]*speculair;
}

I'm looking for something more like this:


texts: Do developers watch player match recordings for their online games?

texts: When developers plan and decide on new buffs and nerfs, do they gather information from online game matches, recorded secretly from their servers' data feeds and reconstructed / analyzed offline - for such data as player movement trajectories and popular paths, weapon preferences and gamestyle behaviour?


texts: How can one add a level to an already published ios/android unity3D game on a daily basis?

texts:
How can one add a level to an already published iOS/Android Unity3D game on a daily/weekly basis?

I know this probably isn't feasible but it won't harm if I just made sure of it. Our game requires to allow access to just one level a day/week. You may access levels that were released on previous days and play to your heart's content but all players will get access to a new level every day/week. I know this may sound crazy but the concept requires it so just roll with me.

Is there anyway to achieve this for iOS/Android games built with Unity? Of course, we could package a whole game with 10 levels and allow access to each level after a set time, but the game will need to talk to a back-end CMS all the time to allow login and verification of users, make sure they aren't cheating, etc, etc, over proper security and https (proper anti-cheat solutions are a must and that's why maybe HTML5 route is better).

We are now moving towards doing all this in HTML5 and completely bypass Unity, but was hoping to find a solution with Unity because 3D is better than 2D depending on the situation, and some levels could be 3D while others 2D. Patching/updating everyday to upload new levels won't go down well with anyone, the app stores or the users.


texts:
I have a function for a timer using waitforseconds but instead of waiting for how long I want to, it just skips it.

A ui text should become "foo" then 5 seconds later become "bar" but it turns to bar as soon as it starts.

Code:

void Update () {
     text1.text = "foo";
     wait (5);
     text1.text = "bar";
 }

 IEnumerator wait(int time)
 {
     yield return new WaitForSeconds(time);
 }


texts: Blender 2.6: Move Mesh to X Coordinate of Another Mesh

texts:
An example:

There are two planes A and B with the following median points:

    ( X | Y | Z )

M_A ( 3 | 2 | 2 )
M_B ( 6 | 1 | 1 )

Now I want to move the plane A on the X-axis to the X coordinate of the plane B (the Y and the Z coordinate of plane A should stay the same). That's the desired result:

M_A ( 6 | 2 | 2 )

My Question:

How can I move a mesh to the X position of another mesh (or to the X postition of the 3D cursor) without touching the Y and Z coordinates. - It's a bit like the Blender function called Snap, but what I want is just about X coordinate.

Thanks for your ideas (please comment if anything is unclear!).


texts: Pixel-perfect rendering to a rendertarget with a fullscreen quad

texts:
I have some trouble rendering a bunch of values to a rendertarget. The values never end up in the exact range I want them to. Basically I use a fullscreen quad and a pixel shader to render to my rendertarget texture and then intend to use the texture coordinates as basis for some calculations in the shader. The texture coordinates of the quad range from (0,0) in the top left to (1,1) in the bottom right corner... the problem is, after interpolation, these values don't arrive at the pixel shader as such.

An example:
I render to a 4x4 texture and the shader in this case simply outputs the texture coordinates (u,v) in the red and green channels:

return float4(texCoord.rg, 0, 1);

What I want to get out of it is a texture where the pixel in the top left is RGB (0,0,0) and thus black, the pixel in the top right is RGB (255,0,0) and thus a bright red and the pixel in the bottom left is RGB (0,255,0) - a bright green.

However, instead I get this here on the right:

(straight quad rendering, no correction)

The top left pixel is black, but I only get a relatively dark red and dark green in the other corners. Their RGB values are (191,0,0) and (0,191,0). I strongly suspect it has to do with the sampling locations of the quad: the top left pixel correctly samples the top left corner of the quad and gets (0,0) as UV coordinates, but the the other corner pixels don't sample from the other corners of the quad. I have illustrated this in the left image with the blue box representing the quad and the white dots the upper sampling coordinates.

Now I know about the half pixel offset you should apply to your coordinates when rendering screen-aligned quads in Direct3D9. Let's see what kind of result I get from this:

(quad rendered with DX9's half pixel offset)

Red and green have gotten brighter but still aren't correct: 223 is the maximum I get on the red or green color channel. But now, I don't even have pure black anymore, but instead a dark, yellowish gray with RGB(32,32,0)!

What I actually need would be this kind of rendering:

(target render, reduced quad size)

It looks like I have to move the right and the bottom border of my quad exactly one pixel up and to the left, compared to the first figure. Then the right column and the bottom row of pixels all should correctly get the UV coordinates right from the border of the quad:

VertexPositionTexture[] quad = new VertexPositionTexture[]
{
    new VertexPositionTexture(new Vector3(-1.0f,  1.0f, 1f), new Vector2(0,0)),
    new VertexPositionTexture(new Vector3(1.0f - pixelSize.X,  1.0f, 1f), new Vector2(1,0)),
    new VertexPositionTexture(new Vector3(-1.0f, -1.0f + pixelSize.Y, 1f), new Vector2(0,1)),
    new VertexPositionTexture(new Vector3(1.0f - pixelSize.X, -1.0f + pixelSize.Y, 1f), new Vector2(1,1)),
};

However this didn't quite work out and caused the bottom and right pixels to not render at all. I suppose these pixels' centers aren't covered by the quad anymore and thus won't get processed by the shader. If I change the pixelSize calculation by some tiny amount to make the quad a tiny amount bigger it kinda works... at least on a 4x4 texture. It doesn't work on smaller textures and I fear it subtly distorts the even distribution of uv values on bigger textures as well:

Vector2 pixelSize = new Vector2((2f / textureWidth) - 0.001f, (2f / textureHeight) - 0.001f);

(I modified the pixelSize calculation by 0.001f - for smaller textures, e.g. 1D lookup tables, this doesn't work and I have to increase it to 0.01f or something bigger)

Of course this is a trivial example and I could do this calculation much more easily on the CPU without having to worry about mapping UVs to pixel centers... still, there has to be a way to actually render a full, complete [0,1] range to pixels on a rendertarget!?


texts: Is WaitForSecondsRealtime() dependent on machine lag?

texts:
I was reading the documentation and I'm trying to get some timing down for a few animations.
My question is, is the WaitForSecondsRealtime dependent on machine lag or anything? A friend of mine said that WaitForSecondsRealtime was invoked at the kernel level and thus it would be as accurate as possible.
Like I said I've read the documentation, but they don't really go into the specifics about how that works. Anyone have any insight?


texts: Visual artifacts on long distance on plane

texts:
I'm making a voxel game in XNA, and have filthy visual artifacts on long distances.

I use 2048*2048 atlases.

I'm already using mipmaps and 16x anisotropic filtering.

I've read this blog post, but I'm not quite sure that this is the problem.

This is how it looks like:

UPD:

The atlas I'm using looks like this:

The topmost left square is used on the screenshots. I'm using XNA Content Processor mipmap compiler to generate mipmaps.

Every cube on the screen is separate, there is no gigantic cubes.

Does anybody have a clue what might it be?


texts: How to remove a scene after the another one has loaded

texts: ]2[]3I'm having this problem in Unity where I load a new scene, but the original is still overlapping it. How would you remove the original scene?


texts: How calculate camera target position, if I have front/back planes, camera transformation matrix and camera lens length?


texts: How do I get bullets to move in the direction of the mouse's position?

texts:
Possible Duplicate:
  Shoot a bullet towards cursor - top down 2d

I'm creating a 2D top down shooter, and I want to get the bullets to go in the direction of the mouse. Not sure of the logic that goes into it.


texts: XML, how to have two variables under the same node?

texts:
I have XML sheet that I use in my game. In my unity(C#) game, a game's monster can spawn at predetermined position or random position.

<monster delay="0.2" isRed = "true" position ="random"/>
<monster delay="0.3" isRed = "true" position ="10 20"/>

Right now I read value of position and if it is "random" then I assign random position for the monster.

If it is not "random" then I parse the value, separate them by a space bar then use the two numbers I obtain from the "position" as position of my monster.

I get this gut feeling what I am doing is probably really ugly and inefficient that there is probably better way to do this, but I am not sure.


texts: 2d very large tile based game, zoom and pan considerations

texts:
what's a sensible way of implementing zoom and panning for my game?

each tile is very large, 100,000 x 100,000 pixels, with some objects possibly being only a single pixel at maximum zoom (small objects in a vast vast space).

I want to be able to zoom out so the view encompasses the entire chunk/tile, possibly two chunks if objects are near the border, I also want to replace the image used for the objects with an icon past a certain level of zoom.

I'd like to have this drawn on a jpanel in an applet with a swing based ui. graphically I was aiming to keep it simple and just use graphics2d functions. should I be looking at using LWJGL or is this overkill.

I realise these sorts of questions get asked a lot, but I'm concerned there are special considerations for having such large tiles.

Thanks


texts:
can someone please guide me how to restore purchases in android using prime 31.

What my basic understating is to get the list skus which player has purchased after he logs in with his account and restore them accordingly.

What I am not getting is how to get that list.


texts: Why is my model's scale changing after rotating it?

texts:
I have just started a simple flight simulator and have implemented Roll and pitch. In the beginning, testing went very well; however, after about 15-20 seconds of constantly moving the thumbsticks in a random or circular motion, my model's scale begins to grow. At first I thought the model was moving closer to the camera, but i set break points when it was happening and can confirm the translation of my orientation matrix remains 0,0,0. Is this a result of Gimbal Lock?

Does anyone see an obvious error in my code below?

    public override void Draw( Matrix view, Matrix projection )
        {
            Matrix[] transforms = new Matrix[Model.Bones.Count];
            Model.CopyAbsoluteBoneTransformsTo( transforms );

            Matrix translateMatrix = Matrix.Identity
                * Matrix.CreateFromAxisAngle( _orientation.Right, MathHelper.ToRadians( pitch ) )
                * Matrix.CreateFromAxisAngle( _orientation.Down, MathHelper.ToRadians( roll ) );

            _orientation *= translateMatrix;

            foreach ( ModelMesh mesh in Model.Meshes )
            {
                foreach ( BasicEffect effect in mesh.Effects )
                {
                    effect.World = _orientation * transforms[mesh.ParentBone.Index];
                    effect.View = view;
                    effect.Projection = projection;
                    effect.EnableDefaultLighting();
                }
                mesh.Draw();
            }
        }

        public void Update( GamePadState gpState )
        {
            roll = 5 * gpState.ThumbSticks.Left.X;
            pitch = 5 * gpState.ThumbSticks.Left.Y;
        }


texts: Is it possible to map mouse coordinates to isometric tiles with this coordinate system?

texts:
I'm trying to implement mouse interaction in a 2D isometric game, but I'm not sure if it's possible given the coordinate system used for tile maps in the game.

I've read some helpful things like this. However, this game's coordinate system is "jagged" (for lack of a better word), and looks like this:

Is it even possible to map mouse coordinates to this successfully, since the y-axis can't be drawn on this tile-map as a straight line?

I've thought about doing odd-y-value translations and even-y-value translations with two different matrices, but that only makes sense going from tile to screen.


texts: How to create simple acceleration in a 2D sprite?

texts:
So here's what I thought might work but half the time I press the 'Right' key, it results in a crash and the rest of the time seems to produce no acceleration at all.

if (KeyboardState.IsKeyDown(Keys.Right))

            while (motion.X < 1)
                motion.X += 0.001f + motion.X;

I want to know why exactly it won't work, and any possible alternate algorithms.


texts: Smoothly switch between 2 pairs of oscillating colors

texts:
I have a simple script that changes the emission color based on a bool.

The first color is its idle color, which transitions between orange and light purple using a lerp weighted with a sine wave.

The second color is its "isinDanger" state, and this lerps between orange and red.

Is there any way to make the transition between both of these color variants smooth? When the bool is set to true the colors switch instantly with no transition. I've tried numerous things to try to get them to be smooth but ultimately it just breaks the lerping.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GemGlowOrange : MonoBehaviour
{
    public Material Mat;

    Color Red;
    Color lightpurple;
    Color orange;

    public bool isInDanger = false;

    Color CurrentColor;
    float startTime;

    public float speed = 1.0f;

    void Start() {
        startTime = Time.time; // time since game started

        orange =  new Color(1.320755f, 0.5346785f,0.2928088f,1f); // making my colours RGBA

        Red = new Color(0.858f, 0f,0f,1f);

        lightpurple = new Color(1.320755f,0.2973427f,0.8263685f,1f);

        var Mat = GetComponent<Renderer>().sharedMaterial;
        // making a reference to the material so we can enable the emission keyword if you do not want this to affect every object using this
        //material then use "Getcomponent<Renderer>().material" the same goes with setting the color as you can see further down.

        Mat.EnableKeyword("_EMISSION"); // this is making sure this shader has the emission keyword enabled.
    }

    void Update() {

        float frac = (Mathf.Sin(Time.time - startTime) * speed);

        CurrentColor = Mat.GetColor("_EmissiveColor");

        if (!isInDanger) {
            Mat.SetColor("_EmissiveColor", Color.Lerp(lightpurple, orange, frac));
            // getting the same material over and over again each frame and updating its
            // emission colour
        } else if (isInDanger) {
            Mat.SetColor("_EmissiveColor", Color.Lerp(Red, orange, frac)); // if it is in danger then it will alternate between red and orange.
        }
    }
}


texts: What's involved in resetting the graphics device?

texts:
I'm playing with XNA 4.0, VS2010. I've created a window (not maximized) and drawn some sprites. All is good until I resize the window, after which the sprites stop displaying or only partially display. I'm pretty sure it has something to do with needing to reset the device or something, but can't find any clear instructions or sample code. It's not just a case of needing to increase the preferredbackbuffer size, because even if I shrink the window I get this symptom. I've looked at the source code that I was able to get from Microsoft before they shut down XNA, but it doesn't actually explain anything.

Any help or advice?

If it makes any difference I'm creating DrawableGameComponents and doing my updates and drawing in their Draw/Update routines.


texts: Should I change velocity or apply force to implement a jump in Unity?

texts:
I have started making a basic platformer game just for fun. Its going to be the style of the original Super Mario Bros game, but with 3d assets.

My problem is that I'm using a rigidbody and using code I have always used to make my player object jump. It seems really slow. I am using a capsule object, the standard size (which is 2 units height). I have played about with the mass, ive tried 1 and 40. And other than having to increase the 'jumpForce' value accordingly, it seems to have not changed the jump speed at all.

So I'm hoping there is a way to tweak the flight of the jump whilst still using the Rigidbody component, and if so how please?

If not, I think I'm able to write my own code to make the gravity etc, but this seems stupid since Unity is a well established game framework I expect other people have also needed to change it and I'm sure there is a way I just don't know about.

Hope someone can help me.

Many thanks!

PS (Here is the basic code I have to make the character jump):
PPS: It's not super-slow , like being in space. (I've had that problem in LibGDX where my objects scales were all wrong. But this time I have just the standard sized Capsule (1x2 units) and the platform is about 4 units above the ground. He jumps ok, but I'd like to make him jump really-fast like mario can

 public class PlayerController : MonoBehaviour {
     Rigidbody rb;
     Vector3 faceRight = new Vector3(0, 90, 0);
     Vector3 faceLeft = new Vector3(0, -90, 0);
     float halfHeight;

     float speed = Constants.speed;
     float jumpForce = Constants.jumpForce;

     private bool IsGrounded()
     {
         return Physics.Raycast(transform.position, Vector3.down, halfHeight + 0.1f);
     }

     void Start () {
         halfHeight = GetComponent<Collider>().bounds.extents.y;
         rb = GetComponent<Rigidbody>();
         rb.transform.Rotate(0, 90, 0); // make the capsule face right at start.
     }

     void Update () {
         HandleKeys();
     }

     void HandleKeys()
     {
         if (Input.GetKey(KeyCode.A))
         {
             if (rb.transform.eulerAngles != faceLeft)
                 rb.transform.eulerAngles = faceLeft;

             rb.transform.Translate(Vector3.forward * speed * Time.deltaTime);
         }
         if (Input.GetKey(KeyCode.D))
         {
             if (rb.transform.eulerAngles != faceRight)
                 rb.transform.eulerAngles = faceRight;

             rb.transform.Translate(Vector3.forward * speed * Time.deltaTime);
         }
         if (Input.GetKeyDown(KeyCode.Space) && IsGrounded())
         {
             rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
         }
     }
 }


texts: Entity component system - where did attributes and behaviors come from?

texts:
I recently spent quite some time understanding and building a component-based system. I got stuck on  a few problems and after searching for quite some time ran across this answer which is talking about behaviours and attributes.

From what I understand, attributes are an entity's data; I thought that's what the component is? And what are behaviours? Is it another term for Entity Processing System?


texts:
I have Visual Studio 2019 installed, with all of the tools mentioned in the Unreal documentation installed, and when I try to create a C++ project in Unreal Engine, I get "No compiler was found. In order to use a C++ template, you must first install Visual Studio 2017.".

I don't have VS 2017 and would prefer not to get it because I'm using a metered connection. According to the Unreal documentation, VS 2019 is indeed supported but that doesn't seem to be the case here.

Any idea what's wrong?


texts:
I am creating a 3d game. In this game I have a 3d model for a tile which I render in different locations using instancing.

I want to create a number of these tiles arranged so as to approximate a circle, similar to this:

I need to create an array of 3d vectors representing the position of the tiles in order to create this circle pattern with a given radius.

Here is the code I use to generate a square platform.

ENG_U is a constant representing a "Unit" in the game.

t is the array of positions passed to the renderer.

int rad = 16;

  t = new glm::vec3[(rad+rad+1)*(rad+rad+1)];
  int c = 0;
  for (int i =0;i < (rad+rad)+1;i++)
  {
    for (int j =0;j < (rad+rad)+1;j++)
    {
    t[c] = glm::vec3(i*ENG_U*1.7*2,0,j*ENG_U*1.7*2) - glm::vec3(ENG_U*1.7*2*rad,0,ENG_U*1.7*2*rad);
    c++;
    }
  }


texts: Convert GPS coordinates into Unity world space?

texts:
I am developing an AR application where a number of historical buildings are spawned around the player depending on his position when a target / QR Code is recognized.
I know the Lat/Lon of these buildings and I have the Lat/Lon of the player. I have already implemented the Harvesine algorithm and can calculate the relative bearing of the buildings:
public static double Harvesine(double lat1, double lon1, double lat2, double lon2)
{
    double R = 6371000; // metres
    double omega1 = ((lat1 / 180) * Mathf.PI);
    double omega2 = ((lat2 / 180) * Mathf.PI);
    double variacionomega1 = (((lat2 - lat1) / 180) * Mathf.PI);
    double variacionomega2 = (((lon2 - lon1) / 180) * Mathf.PI);
    double a = Math.Sin(variacionomega1 / 2) * Math.Sin(variacionomega1 / 2) +
                Math.Cos(omega1) * Math.Cos(omega2) *
                Math.Sin(variacionomega2 / 2) * Math.Sin(variacionomega2 / 2);
    double c = 2 * Math.Asin(Math.Sqrt(a));

    double d = R * c;

    return d;
}

public static double Bearing(double lat1, double lon1, double lat2, double lon2)
{
    double radians;
    double x = Math.Cos(lat2*Mathf.Deg2Rad) * Math.Sin((lon2 - lon1) * Mathf.Deg2Rad);
    double y = Math.Cos(lat1 * Math.PI / 180) * Math.Sin(lat2 * Math.PI / 180) - Math.Sin(lat1 * Math.PI / 180) * Math.Cos(lat2 * Math.PI / 180) * Math.Cos((lon2 - lon1) * Math.PI / 180);

    radians = Math.Atan2(x, y) * 180 / Math.PI;

    return radians;
}

From here, how can I spawn the building relative to the player position? I have the distance (Harvesine) and the angle (Bearing), how can I get the Vector3 location?


texts: How can I make animations "snap" between transitions in Unity?

texts:
I have an animator with a few animations in it.  These are very basic animations, just changing a transform to slide a sprite around in a cutscene.  The issue that I'm running into is that when I transition from one animation to the next it will try to smooth out the animation differences.  So if I have something move off the right of the screen, then with the next animation come falling from the top of the screen, it will first quickly slide to the new position.

I've tried to change the last frame of the first animation to Right Tangent -> Constant, and the first frame of the second animation to Left Tangent -> Constant.  It didn't make any noticeable difference.

I also set up two functions (one for X, one for Y) to set the position at the beginning of the second animation, but only one of them were called, and it didn't seem to do anything.

So, how do I get an animation to snap to the starting values of the new animation after a transition?


texts:
I am trying to make 3D drawing software. I wanted to have the drag feature so I am using object picking using the OBB algorithm. I am facing problems in understanding the algorithm, and my implementation thus is having bugs.

How do I implement object picking, using OBB in OpenGL? As I am new to OpenGL (free-glut library), a step by step explanation would be helpful.


texts:
http://www.gamasutra.com/blogs/AdamWinkels/20140220/211306/DevLog_7_Learning_How_to_Walk.php

Following the link above I have been able to get my character to move and rotate very smoothly over angled surfaces up-to 80 degrees.  Anything over that and it begins to clip and wobble when traveling down the surface. The spiders rotation only reaches half of the desired angle.  So at 85 degrees it only rotates to 42.5.  Going up is a mess, but I have not implemented the fix for that from the link above, so I am less worried about that.  Any suggestions?

private float RayDuration = 0;
private float RayAngle = 5f;
private float RayLength;
Vector2 MovementDirection;
float OffSetY  = 5;
float OffSetX = .5f;
int GroundMask = 1 << 8;

 void Start()
{
    SpiderRect = GetComponent<RectTransform>();
    RayLength = SpiderRect.rect.height;
}

private void TouchHeld(CustomEvent customEvent)
{

    if (Input.mousePosition.x > 400)
    {
        MovementDirection = transform.right;
    }
    else
    {
        MovementDirection = -transform.right;
    }

    Vector2 transformUp = transform.up;
    Vector2 position = transform.position;

    Vector2 rightRayPosition = new Vector2(transform.position.x + OffSetX, transform.position.y + OffSetY);
    Quaternion rightOffSetAngle = Quaternion.AngleAxis(-RayAngle, new Vector3(0, 0, 1));
    Vector2 rightRayAngle = rightOffSetAngle * Vector2.down ;

    Vector2 leftRayPosition = new Vector2(transform.position.x - OffSetX, transform.position.y + OffSetY);
    Quaternion leftOffSetAngle = Quaternion.AngleAxis(RayAngle, new Vector3(0, 0, 1));
    Vector2 leftRayAngle = leftOffSetAngle * Vector2.down;

    RaycastHit2D rightHit = Physics2D.Raycast(rightRayPosition, rightRayAngle, RayLength, GroundMask);
    RaycastHit2D leftHit = Physics2D.Raycast(leftRayPosition, leftRayAngle, RayLength, GroundMask);

    #region move
    if (rightHit && leftHit)
    {

        Debug.DrawRay(rightRayPosition, rightRayAngle, Color.red, RayDuration);
        Debug.DrawRay(rightRayPosition, rightHit.normal, Color.green, RayDuration);

        Debug.DrawRay(leftRayPosition, leftRayAngle, Color.yellow, RayDuration);
        Debug.DrawRay(leftRayPosition, leftHit.normal, Color.magenta, RayDuration);

        Vector2 averagePoint = (leftHit.point + rightHit.point) / 2;
        Debug.DrawRay(averagePoint, -transform.up, Color.cyan, RayDuration);

        Vector2 averageNormal = (leftHit.normal + rightHit.normal) / 2;
        Debug.DrawRay(averagePoint, averageNormal, Color.cyan, RayDuration);

        Quaternion targetRotation = Quaternion.FromToRotation(Vector3.up, averageNormal);
        Quaternion finalRotation = Quaternion.RotateTowards(transform.rotation, targetRotation, 10);
        transform.rotation = Quaternion.Euler(0, 0, finalRotation.eulerAngles.z);

        transform.position = Vector2.MoveTowards(transform.position, averagePoint + MovementDirection, .15f);
    }
    else
    {
        Debug.Log("What");
    }


texts: set zfar/znear in openGL using shaders (QT env)

texts:
I have a QT canvas and I'm using shaders to build my scence.
I've set the camera image plane at some position, and would like to view object from the image plane to infinity. How do I set the zfar and znear values?


texts: Unity - Syncing/Downloading/overwriting files to a local folder accessed by the game when offline?

texts:
I currently have a game/application (PC/Standalone only) made in Unity which features a multitude of buttons which all link to external webpages which open up in the user's browser window.
Recently my client expressed an interest in having an offline version, where all the online content is available locally offline, as their users regularly go offsite to areas without an internet connection and the buttons are then useless.
I have done a new version which has all the webpages, PDFs and videos saved off as local files and placed in a folder within the build folder, the buttons now use the following script to read the files from there instead -

public class URLOpener_OFFLINE : MonoBehaviour {

    public void relativeURL(string url)
    {
        Application.OpenURL(url);
    }
}

This works perfectly on a basic level.
However my client has expressed an interest in being able to update the offline content without having to make a new build each time or manually go and update the folder content.

So basically what I need is to be able to store all the offline files somewhere online, which can be overwritten as and when is needed.
Then I need some way of syncing the game with this online location (when the user is online), to pull down the latest files into the offline folder and overwrite the files in there, so the latest offline files are included when they go offsite to an area without internet.

Is this possible at all?  I am more than happy to pay for a plugin or service that would provide this sort of feature.

I already have a plugin for translated languages which essentially does this (https://www.assetstore.unity3d.com/en/#!/content/14884) - changes to the online spreadsheet containing all the text is pulled down when the game syncs.  But this is obviously a bit different to downloading actual files and placing them in a specific folder.

Any help or advice would be appreciated.

Many thanks in advance


texts: What are the parameters for a smooth wall jump

texts:
I want to make a platformer like Celeste and trying to implement wall jump.
When the player is on the air and near a wall, and presses jump, the player gains x velocity opposite the wall direction, and some y velocity. So the player jumps against the wall, but it shouldn't climb the wall thru wall jumping.
Game runs 60 frames per second. resolution is 320x180. Tile size is 16.
Here's some constants for calculating velocity and gravity:
export const vMax = 4; // maximum velocity in pixels
export const tMax = 20; // time to reach maximum velocity in frames

export const hMax = 16 * 3; // maximum jump height
export const xSubH = 16 * 3; // x distance that is reached in one jump

export const xFriction = 5 / tMax;  // friction to apply to x velocity
export const hAccel = vMax * xFriction; // accelaration for x

export const v0Jump = (2 * hMax) * vMax / xSubH; // initial jump velocity
export const gJump = - (2 * hMax * vMax * vMax) /
      (xSubH * xSubH); // gravity applied to y velocity on jump

Here's how I do wall jump:
 // player object
 let p = {
   x: 0, // position
   y: 0,
   dx: 0, // velocity
   dy: 0,
   ax: 0, // acceleration
   ay: 0
 };

 // let inputX = -1 for left input 1 for right input

 // x movement
 let _hAccel = inputX * hAccel;
 p.dx += _hAccel;
 p.dx += - p.dx * xFriction;

 // let isGrounded = ...
 // let wallDir = ... // -1 for left wall 1 for right wall

 // fall
 if (!isGrounded) {
   p.ay = -gJump;
 }

 // jump
 p.ay = -gJump;
 p.dy = -v0Jump;

 // wall jump
 p.dy = -v0Jump;
 p.dx = - wallDir * hAccel;

 p.dy += p.ay;

 // position
 p.x += p.dy;
 p.y += p.dx;

What are the parameters of the wall jump I need to control and tweak so it looks smooth and doesn't allow player to climb up the wall. But player can climb two walls side by side jumping one off another vs.
As you can see I have parameters like vMax and tMax that I can tweak to control the jump and movement. I tried setting arbitrary fractions of current values to give more x velocity or y velocity for wall jumping, but I can't quite get a wall jump that feels good to climb against two walls.
If you look at the Celeste Pico 8 source code:
  if (E.abs(spd.X) > maxrun)
        spd.X = G.appr(spd.X, E.sign(spd.X) * maxrun, deccel);
    else
        spd.X = G.appr(spd.X, input * maxrun, accel);

When the x velocity is greater than maxrun, it is decelarated towards maxrun, otherwise it is decelarated towards input. So this basically disables input when given a big x velocity, thus disallowing to approach the wall thru input.


texts: How do I determine the rotation of a Tile using Tilemap in Unity 2d?

texts:
I want to know the rotation of the tile in C# in order to do some logic on another object that is sitting on the tile. The rotation matters for the logic. I don't see anything except GetTileData in the doc, but that doesn't actually seem to "Get" the tile data. I could cast to Tile but not all tiles are Tile. Alternatively, I think I can get the rotation if I can get the GameObject for the tile but I have no idea how to do that either from a BaseTile.

Anyone have any suggestions? Maybe I'm trying to do this wrong and I should make different tiles for each orientation or extend BaseTile or some other solution instead of trying to determine rotation. Any help or ideas would be greatly appreciated!

Additional info: When I inspect around in the Unity editor I see that the rotation is stored in Z in something called "Grid Selection" but I can't find a programmatic way of accessing that.


texts: How to calculate turn heading to a missile?

texts:
I have a missile that is shot from a ship at an angle, the missile then turns towards the target in an arc with a given turn radius. How do I determine the point on the arc when I need to start turning so the missile is heading straight for the target?

EDIT

What I need to do before I launch the missiles is calculate and draw the flight paths. So in the attached example the launch vehicle has a heading of 90 deg and the targets are behind it. Both missiles are launched at a relative heading of -45deg or + 45 deg to the launch vehicle's heading. The missiles initially turn towards the target with a known turn radius. I have to calculate the point at which the turn takes the missile to heading at which it will turn to directly attack the target. Obviously if the target is at or near 45 degrees then there is no initial turn the missile just goes straight for the target.

After the missile is launched the map will also show the missile tracking on this line as indication of its flight path.

What I am doing is working on a simulator which mimics operational software. So I need to draw the calculated flight path before I allow the missile to be launched.

In this example the targets are behind the launch vehicle but the precalculated paths are drawn.


texts: AS3 Starling in Fullscreen Mode cuts off most of the screen

texts:
I have a mixed mode (classic Flash Renderer + Starling) AIR AS3 project that I'm switching to fullscreen with

 stage.align=StageAlign.TOP_LEFT;
 stage.scaleMode=StageScaleMode.SHOW_ALL;
 // Swtich to Fullscreen with
 stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

When I do this, I have a callback on the Event.RESIZE event to resize my Starling instance to fullscreen:

private function resizeStarling(e:Event):void
{
            var size:Point = new Point();
            if(this.stage.displayState == StageDisplayState.FULL_SCREEN_INTERACTIVE)
            {
                size.x = Capabilities.screenResolutionX;
                size.y = Capabilities.screenResolutionY;

            }
            else
            {
                size.x = WIDTH;
                size.y = HEIGHT;
            }

            RectangleUtil.fit(
                new Rectangle(0, 0, stage.stageWidth, stage.stageHeight),
                new Rectangle(0, 0, size.x, size.y),
                ScaleMode.SHOW_ALL, false,
                Starling.current.viewPort);
}

The set to FULL_SCREEN_INTERACTIVE turns all my normal flash Stage object based UI and visuals to full-screen mode.  However, while the Starling graphics are correctly upscaled, they only occupy the upper left corner of the screen, and the remaining three quadrants are cut off.  I haven't validated yet, but I suspect that the segment being displayed is the same dimensions as the original windowed stage size.  Any ideas on what I'm forgetting to do to achieve fullscreen Starling displays that are actually fullscreen?  This is on OSX.


texts: How to do Digital Painting type of graphics art like in Braid?

texts:
I'm wanting to create the digital painting type of effect that you see in Braid for a game I'm creating. I was wondering if someone can point me in the right direction? I'm most familiar with OpenGL ES 2.0.

I'm wanting to have the background move like Braid does as well.

If anyone can get me started I would really appreciate it.


texts: Android multitouch: How to detect movement on non-primary pointer / finger?

texts:
How does one go about detecting a secondary/non-primary finger moving?

There is:

ACTION_DOWN and ACTION_UP  to detect a primary finger pressing the screen / leaving the screen

ACTION_POINTER_DOWN  and ACTION_POINTER_UP for subsequent fingers pressing / leaving the screen

But there is no ACTION_POINTER_MOVE for monitoring and responding to subsequent fingers moving.

Also, if I log event.getActionIndex(); it always returns '0' regardless of how many fingers are touching the screen (I'm guessing because *ACTION_MOVE* is only interested in the primary finger).  So how is it possible test the subsequent fingers?

Code

case MotionEvent.ACTION_MOVE:{
         int pointerId = event.getPointerId(pointerIndex);

        //Finger slid to left button so set sprite left
            if (event.getY(pointerIndex)>=renderer.leftButton("top") && event.getX(pointerIndex)<=renderer.leftButton("right")){
                renderer.setSpriteState('l', true);
                renderer.setSpriteState('r', false);

        }

            //Finger slide to the right button so set sprite right
            else
                if (event.getY(pointerIndex)>=renderer.rightButton("top") && event.getX(pointerIndex)>renderer.rightButton("left") && event.getX(pointerIndex)<=renderer.rightButton("right")){
                    renderer.setSpriteState('l', false);
                    renderer.setSpriteState('r', true);

            }
            break;


texts:
I want to use lambda funcitons in gdscript. I have seen that this feature has been merged with master on GitHub. But I cannot make them work with 3.3.1 release:
func _ready() -> void:
    var l = func foo() -> void:
        pass

simply throws: Error parsing: misplaced; func


texts: How do I implement following behavior with a state-based AI?

texts:
I'm making a 2D game with two spaceships flying around shooting each other. One spaceship is controlled by the user, the by an AI. I want to use a simple Finite State Machine (FSM) for the AI.

I'm trying to make the AI ship follow the player's ship and stop at a given radius from it.

I've got a GetInsidePlayersRadius state, and a StopMoving state. But so far I got a weird bug involving the AI ship moving a few pixels, then stopping for a moment, than moving again, creating very fragmented movement.

The AI can move up, down, left, right, up-left, up-right, down-left, or down-right, just like the player.

What could create this fragmented movement behavior, generally when an AI agent is constantly trying to get inside a certain radius from an object, and stop when it's inside it?

How would you implement a following behavior of an AI as part of a Finite State Machine?


texts: How can I render "two-sided" clouds like in Minecraft?

texts:
The clouds in Minecraft are semi-transparent and are rendered on both sides.  If you fly into the cloud you can see inside of the cloud.
If I render clouds the inside faces would be visible on the outside.
How can I prevent that?
Z-Ordering the faces and render near to far with depth test on?
There must be a better, easier way.
Could the accum or stencil buffers be used somehow?

UPDATE : I think the crucial point everyone is forgetting is that these clouds and semi-transparent and "blended" into the scene as each face is rendered.  If two faces are rendered on top of each other the "white" texture will double up which is undesired.  The faces also seem to have slight lighting variations which would rule out using a stencil.

UPDATE2: Just another note.  Each cloud is 12x12x4 blocks (roughly).  Larger clouds are just a group of the base clouds stuck together.

Here's showing clouds from above. They are translucent and the chunks below can be seen.

And here's the view from inside them.


texts:
Is there a way to do it? I can get only polygon_shape's vertices, but i want circle, box, etc too.

How to do it?


texts: Create a touchpad-joystick using texturepacker2

texts:
I am adding a touchpad control to my game, using TexturePacker for loading images into the image-atlas. I have followed this tutorial to add the joystick. Everything is the same apart from the loading assets part. This is how I am adding the control:

//in create
ta = new TextureAtlas(Gdx.files.internal("image-atlases/pages-info.atlas"));

        camera = new OrthographicCamera();
        camera.setToOrtho(false, 800, 480);

        batch = new SpriteBatch();

        blockSpeed = 5;

        InitTouchPad();

        //create a stage and add touchpad
        stage = new Stage(800, 480,true, batch);
        stage.addActor(touchpad);
        Gdx.input.setInputProcessor(stage);

        //create block sprite
        blockTextureRegion = ta.findRegion("block");

        blockSprite = new Sprite(blockTextureRegion);
        //set position to the left bottom of screen
        blockSprite.setPosition(800-blockSprite.getWidth()/2, 480-blockSprite.getHeight()/2);

//end create

private void InitTouchPad(){
        //adding touchpad controls
        //create a touchpad skin
        touchpadSkin = new Skin();
        //set background image
        touchBackgroundRegion = ta.findRegion("touchBackground");
        touchpadSkin.add("touchBackground", touchBackgroundRegion.getTexture());
        //set knob image
        touchKnobRegion = ta.findRegion("touchKnob");
        touchpadSkin.add("touchKnob", touchKnobRegion.getTexture());
        touchpadStyle = new TouchpadStyle();
        //create drawable's from touchpad skin
        //touchBackground = touchpadSkin.getDrawable("touchKnob");
        //touchKnob = touchpadSkin.getDrawable("touchBackground");
        //apply the drawables to the touchpad style
        touchpadStyle.background = touchpadSkin.getDrawable("touchBackground");
        touchpadStyle.knob = touchpadSkin.getDrawable("touchKnob");
        //create new touchpad with the created style
        touchpad = new Touchpad(10, touchpadStyle);
        //setbound(x,y,width,height)
        touchpad.setBounds(0, 480 - 150, 150, 150);

    }

@Override
    public void render() {
        // TODO Auto-generated method stub
        Gdx.gl.glClearColor(0, 0, 0.2f, 1);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

        camera.update();

        //add touchpad controls
        blockSprite.setX(blockSprite.getX() + touchpad.getKnobPercentX()*blockSpeed);
        blockSprite.setY(blockSprite.getY() + touchpad.getKnobPercentY()*blockSpeed);

        batch.begin();
        blockSprite.draw(batch);
        batch.end();

        stage.act(Gdx.graphics.getDeltaTime());
        stage.draw();

    }

And for the output, all my assets are preloaded on the screen, the touchpad is nowhere looking like a joystick control. The images are jumbled over each other the movement of the sprite is in opposite direction..


texts: How to create a "retro" pixel shader for transformed 2D sprites that maintains pixel fidelity?

texts:
The image below shows two sprites rendered with point sampling on top of a background:

The left skull has no rotation/scaling applied to it, so every pixel matches perfectly with the background.
The right skull is rotated/scaled, and this results in larger pixels that are no longer axis aligned.

How could I develop a pixel shader that would render the transformed sprite on the right with axis aligned pixels of the same size as the rest of the scene?

This might be related to how sprite scaling was implemented in old games such as Monkey Island, because that's the effect I'm trying to achieve, but with rotation added.

Edit

As per kaoD's suggestions, I tried to address the problem as a post-process. The easiest approach was to render to a separate render target first (downsampled to match the desired pixel size) and then upscale it when rendering a second time. It did address my requirements above.

First I tried doing it Linear -> Point and the result was this:

There's no distortion but the result looks blurred and it loses most of the highlights colors. In my opinion it breaks the retro look I needed.

The second time I tried Point -> Point and the result was this:

Despite the distortion, I think that might be good enough for my needs, although it does look better as a still image than in motion.

To demonstrate, here's a video of the effect, although YouTube filtered the pixels out of it:

http://youtu.be/hqokk58KFmI

However, I'll leave the question open for a few more days in case someone comes up with a better sampling solution that maintains the crisp look while decreasing the amount of distortion when moving.


texts: How should I structure my Tetris clone's code?

texts:
I programmed my first game (a Tetris clone in XNA) and all my code is in a Game1.cs file with 730+ SLOC. It's fairly well-commented, and each piece of functionality has its own subroutine, but I have a feeling that I'll have to move toward a more organized approach as my games increase in complexity.

To offer some background, my current approach separates the "view" (the tetrimino sprites visible on the board) from the underlying "data" (represented by an 18x10 bool array), which determines if there is a block at some point on the grid. In other words, my "data" determines my "view." Also, here's a list of all my subroutines:

Game1()
Initialize()
LoadContent()
UnloadContent()
GetBlockType()
IsFreeBlock()
IsPossibleMovement()
GetXInBlocks()
GetYInBlocks()
StorePiece()
DeleteLine()
DeletePossibleLines()
IsGameOver()
ResetBoard()
Update()
Draw()

I hear a lot about game components in XNA, which sounds like something that could make my code more organized and extensible. Are there any organizing features of XNA that I could incorporate into my future games?


texts: I'm using FreeImage and Squish library. I think there is no matter what row order is passed to squish::CompressImage (it's simply like inversed image). FreeImage stores rows from bottom to top, the pixel(0, 0) is placed in bottom-left corner. When I put RGBA or DXTn data to glTexImage the data at index 0 should be at top-left corner or at bottom-left corner?


texts: How can I reduce aliasing in my outline glow effect?

texts:
I'm trying to replicate the glowing outline effect in the Left 4 Dead game. The effect causes an objects outline to glow, even when the object is occluded. Here is a screenshot of the effect:

I'm somewhat able to replicate this effect in my OpenGL based program. This is what I'm currently doing:

Create a color and depth texture that is half the screen size for rendering the glowing objects
Clear the glow color/depth textures. Color is cleared to black.
For each glowing object, render it to the glow texture as a solid color
Perform a separable gaussian blur on the glow texture
Render the full resolution scene as normal
Additively blend the glow texture with the normal scene, but use the glow depth texture to mask out the object, leaving just the blurred outline.

Here is a screenshot of my approach:

Here is the fragment shader that combines the glow texture with the scene:

uniform sampler2D glowColorTex;
uniform sampler2D glowDepthTex;
uniform sampler2D sceneColorTex;
void main()
{
    vec2 uv = gl_TexCoord[0].st;

    vec4 color = texture2D( sceneColorTex, uv);

    float depth = texture2D( glowDepthTex, uv).r;
    if(depth == 1.0) {
        color += 2.0 * texture2D( glowColorTex, uv);
    }

    gl_FragColor = color;
}

As you can see, it seems to work for the most part, but the aliasing on the outline is really bad.

Does anybody have any suggestions for smoothing the inner edge of the outline?

Should I be sampling the neighboring depth values of each pixel and scale the glow based on the number of depth values that equal 1.0?

Or is there a better approach that will produce smoother results?


texts: Is there a way to create a cellular automaton mod for Minecraft?

texts:
I basically want to create a mod for Minecraft that does the following:

if(a sand block is next to lava block) {
   change the sand block to a glass block
}

Is it possible to create a mod like this without editing multiple Java classes?


texts:
In Unity is there a way to add a menu button during gameplay that allows the player to export the current scene as an fbx file?
My googling and research shows that its possible to do this while developing the game but wondering if there is a way to add this functionality for the gameplay itself.
Any suggestions on how/if this can be done?


texts: Character can't jump in other angle with fixed angle off

texts:
I turn off fixed angle so my character can rotate, but it can only jump in 1 angle but I want it to jump in every angle.

How do I do that?

Code:

using UnityEngine;
using System.Collections;

public class Player: MonoBehaviour {

  public float maxspeed = 10f;
  bool facingRight = true;

  Animator anim;

  bool grounded = false;
  public Transform groundCheck;
  float groundRadius = 0.2f;
  public LayerMask whatIsGround;
  public Vector2 jumpDirection = new Vector2(0f, 0f);
  public float jumpFocre = 500f;
  bool doubleJump = false;

  void Start ()
  {
    anim = GetComponent<Animator> ();
  }

  void FixedUpdate () {
    grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
    anim.SetBool ("Ground", grounded);

    if (grounded)
      doubleJump = false;

    float move = Input.GetAxis ("Horizontal");
    anim.SetFloat ("Speed", Mathf.Abs (move));

    GetComponent<Rigidbody2D>().velocity = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);
  }

  void Update()
  {
    if((!doubleJump) && Input.GetKeyDown ("up"))
    {
      anim.SetBool("Ground", false);
      float move = Input.GetAxis ("Horizontal");
      jumpDirection.x = move;
      GetComponent<Rigidbody2D>().AddForce(jumpDirection.normalized * jumpFocre);

      if(!doubleJump && !grounded)
        doubleJump = true;
    }
  }

  void Flip()
  {
    facingRight = !facingRight;
    Vector3 theScale = transform.localScale;
    theScale.x *= -1;
    transform.localScale = theScale;
  }
}


texts: How do I draw these tiles without them overlapping?

texts:
I want to make a map that is tiled, and I want to start the map with all grass.

I use this tile:

When I display this tile and place another next to it I get the following result:

How do I get it to be "flat?"


texts:
Here I am not talking about how to render fog of war, but how to model exploring of terrain in a more sophisticated way.

In a straight-forward approach, terrain explored by a game unit is simply represented by a circle whose radius is how far this unit can see. And visible area is just union of isometric circles. But I can tell that it is not the case in popular games.

Please take a look at the following screenshot from League of Legends, for example.

The sight of view is anisotropic. The shape of surrounding terrain is also taken in to account.

Any idea how this can be done?


texts: If I save some information with PlayerPrefs, they will remain saved even if the game is online?

texts: If I make a game in unity and I use the PlayerPrefs function to save the progress and load it in another play, that information will be stored even if the game is loaded on an online platform? I mean: I save a number: 4. Then i close the web page, and enter again and hit load. That number will be saved and loaded properly for every user that plays the game?


texts: How can I create a patch of ocean that blends seamlessly into the horizon?

texts:
The tagline pretty much says it, but here's a picture to show the problem:

The darker gradient of blue on the horizon comes from the Godot WorldEnvironment, while the lighter shade results from a half-transparent plane that will later be animated with waves.
How can I make the ocean plane blend into the horizon?


texts: Game AI move towards player while avoiding an obstacle

texts:
I'm trying to move enemy towards player, while enemy also tries to avoid an obstacle if it's in its path. Here's a simple illustration of what I want to do:

What I've tried:

Making circular collision around the obstacle. It works but that
makes the enemy impossible to hit.
I think going with an A* pathfinding algorithm might be a bit overkill
especially since it's designed for multiple obstacles, where in my
case there is only the mouse and wall collision concerned.
Moving the enemy towards the player, while also moving away from the
obstacle at a slower speed. This works better because you can
actually hit the enemy, but also slows down enemy if obstacle if it's
in its path.

My questions:

Is there a better way to go about doing this?
Anything you would've done differently with my code to either improve or optimize?

Here's the code I have currently in my game logic and a fully-working example on jsFiddle.

// Calculate vector between player and target
var toPlayerX = playerPosX - enemyPosX;
var toPlayerY = playerPosY - enemyPosY;

// Calculate vector between mouse and target
var toMouseX = mousePosX - enemyPosX;
var toMouseY = mousePosY - enemyPosY;

// Calculate distance between player and enemy, mouse and enemy
var toPlayerLength = Math.sqrt(toPlayerX * toPlayerX + toPlayerY * toPlayerY);
var toMouseLength = Math.sqrt(toMouseX * toMouseX + toMouseY * toMouseY);

// Normalize vector player
toPlayerX = toPlayerX / toPlayerLength;
toPlayerY = toPlayerY / toPlayerLength;

// Normalize vector mouse
toMouseX = toMouseX / toMouseLength;
toMouseY = toMouseY / toMouseLength;

// Move enemy torwards player
enemyPosX += toPlayerX * speed;
enemyPosY += toPlayerY * speed;

// Move enemy away from obstacle (a bit slower than towards player)
enemyPosX -= toMouseX * (speed * 0.4);
enemyPosY -= toMouseY * (speed * 0.4);


texts: Is it possible to create native application for Google Chrome Store?

texts:
I'm developing small game using c++ and OpenGL. I would like to post it also in Chrome Web Store.

I've seen that a lot of apps are just redirection to specific url. I can use Java Applet and JNI to launch it in chrome, but that would be only waste of memory.


texts: Isometric Map with different Z-axis values

texts:
I want to create a isometric tile map editor just like the one shown in the images ( pictures are from the game Zoo Tycoon ).
I know how to render the tiles when there is only one Z value ( zero ), but I have no clue how I could archieve something like in the pictures where you can raise certain tiles in 1/2 unit steps, either creating a sharp edge/cliff or a smooth transition.

Can anyone give me some good reference materials or help me out here? Thanks in advance :)

Oh yea and you can also rotate the view by 90 in any direction like this:

EDIT :

I am using SFML with C++ for this project. There I am creating an array of vertices, 4 of which represent an quad/tile in the map. In SFML each vertex has two main properties, a position in space and a position in the texture mapped to it. I adjust the first one based on the simple projection formula. The textures are represented in a simple tileset. I simply calculate the corresponding 4 edges of a tile in the texture based on a level data array that contains the number of the tile in the texture, starting from 0.

Here's a very very simple tileset that I made myself

Here's how this looks so far:

Oh yea and this is how far I come with rendering different z values. The 4 tiles on the top right are raised 1 unit. But as you can see the faces of the blocks are incomplete. I don't know how I draw them yet.

UPDATE :
I managed to display sharp edges correctly now, even though it's really unoptimised (I am drawing every front-facing face of the blocks, even the ones that are covered by others. Any tips on how I can prevent this?)


texts: How does Unity3D lower an imported .obj vertex count?

texts:
I have a question regarding how Unity3D handles importing of .obj files.
I'm importing this teapot: http://groups.csail.mit.edu/graphics/classes/6.837/F03/models/teapot.obj

The number of vertices this teapot has is 3644. I know that Unity's Mesh class needs to replicate these vertices for each face shared by the same vertex. I tried this with a Cube imported from a .obj, and using Debug.Log() to print the number of vertexes I found out that there were 24 vertices in the mesh's vertex array.

However, with the teapot the original file had 3644 vertices, so in Unity the vertex count should be 18960. Instead, when I print the length of the mesh's vertex array, it prints 3260 (even less than the original file).

The final objective for this is that I'm trying to modify an OBJ Importer script from Unity's Wiki, so that the number of vertices resulting from this script are the same as Unity's native importer. Reference: http://wiki.unity3d.com/index.php?title=ObjImporter
Note: I printed the vertex count using this importer and the result was 18960.

Does anyone have an idea of how this vertex reduction might be achieved?


texts: What algorithm to use for predictive collision detection in multivariate systems?

texts:
In the collision system for my game I basically have two kinds of things, boxes, defined thusly:

struct Box2I
{
    uint32_t x, y, width, height;
};

and quads, which are used for terrain:

struct Quad
{
     const uint32_t left, right;
     const float slope_top, intercept_top;
     const float slope_bottom, intercept_bottom;
     bool solid;
};

The boxes can collide with the quads, but the boxes can't collide with each other, and colliding quads has no meaning.

Anyway, I'm having trouble with the collision, the collision function should return a number between 0.0 and 1.0, where 0.0 is the time of the last frame, 1.0 is the time of the next frame--and -1 for no collision.  But I can't find a way to do this.

Mostly I can find algorithms for systems such as colliding circles, where they move but the scale doesn't change, or points, etc. But I'm having trouble finding anything beyond the general scheme of:

broad phase checks
?????
binary/interpolation search for collision time

And I'm just not sure what goes in 2, because I frequently find things on the  separating axis theorem, but that can't be #2 because objects would sometimes tunnel.  The other general idea I've come across is casting rays from each of the corners of the box, but again, I can see that sometimes allowing tunneling.

What's the general technique that's typically used here?


texts: How can I set my application to run on the High performance GPU by default?

texts:
Nowadays a good deal of laptops come with 2 GPUs - a high-performance one and a power-saving one (less powerful). Most of the application, which I use on my laptop run with my integrated(power-saving) GPU, but still some of them are set to open with the high-performance card. I am trying to config the app which I am building to run on the high performance GPU by default, but I can't find any information about the topic anywhere. I hope that someone can shed a bit of light onto this. I will distribute my application with an NSIS installer and I guess that I'll have to add the path of my application to a list of applications for NVidia/ATI cards. The application is programmed in C#. Also, does anyone know how things stand with desktop PCs? What happens if a PC has 2 GPUs and I have to choose the more powerful one?

Milcho


texts: Mixamo Models not Importing Correctly in Unity

texts:
Mixamo (now Adobe Mixamo) allows us to choose character and then animations from its website from free samples. I have done one simple animation and added the model to Unity. The animation works fine but the model is very changed once being imported, have a look here.

I am using following import settings,

Format: Fbx for Unity

Skin: With Skin

FPS: 30

Keyframe Reduction: Uniform

I tried "Fbx" format only too, but no luck.I also applied "humanoid" in rigging, but I think it is not relevant here. Since I am not good with modeling that is why I am using this service, and I have no idea how to tackle this. Once it did worked well, but unfortunately I could not remember how, so I am stuck again.


texts:
I have monogame 3.0.1 (latest stable) installed on a Windows 8 Pro machine. I can create a new Windows Phone 8 project (Monogame template) and deploy to the emulator and an actual device with no problems.

However after successfully getting a screen of cornflour blue I wanted to display a simple image. I know the content pipeline is something that doesnt work but I wanted to display a simple PNG.

For this, I tried:

Adding a Content folder. Adding a simple PNG (test.png) to the content folder. Set the build to "Content" and ensure it was set to "Copy if newer". Then added the following code.

texture = Content.Load<Texture2D>("test");

And in the draw, draw it out. However , I get a NotImplementedException when I try to deploy this.

Out of the box, how do I draw a simple texture/sprite to the screen?


texts: UNET start game with friend by finding their name, Android

texts:
There is a game at the google play store called Fun Run 2- Multiplayer Race. I loved its feature to find friends by writing their names, and then to play with them. Is it possible to achieve that with UNET? How?

Another one is called Virtual Table Tennis. There I have a lobby full of people from whom I can choose. Can I achieve that with UNET? How?


texts: Determining the end location for AI movement in groups in a 2D RTS

texts:
I have written an RTS game (a demo for a game engine of sorts, actually) in which the user's basic interaction with the game is to select a bunch of soldiers and then right-click on the map to move them to the specified location. This is in JavaScript and you can play with it here (code).

Ignoring the problem of how the soldiers move from their current location to their destination, my question is about determining what their actual destination is. Here is what I've tried so far:

Attempt 1: Tell all selected soldiers to move to the coordinates the mouse clicked. This has the odd behavior that all the soldiers will then go cluster around the target unnaturally.
Attempt 2: Find the average coordinates of all selected soldiers, then find the offset from that center point for each soldier, and finally translate that offset around the mouse coordinates. This works fine except that if your selected soldiers are far apart they will not get close to the target.
Attempt 3: Build a grid around the mouse coordinates and place each selected soldier into a cell of the grid. If each soldier makes it to their assigned cell, this works great. However, soldiers are assigned to grid cells in the order the soldiers were spawned, so sometimes they collide (i.e. all the soldiers on the right side will try to go to the left side) which looks unnatural.
Attempt 4: Use a grid like before, but first sort the soldiers by location so that they line up sensibly, i.e. if you clicked below the group then the soldiers at the bottom of the group will end up on the bottom of the grid when they reach their destination. This works pretty well but there are glitches sometimes and I'm not sure why.

Here is the function that determines the destination coordinates:

function moveSelectedSoldiersToMouse() {
  var w = 0, h = 0, selected = [];
  // Get information about the selected soldiers.
  myTeam.soldiers.forEach(function(soldier) {
    if (soldier.selected) {
      selected.push(soldier);
      w += soldier.width;
      h += soldier.height;
    }
  });
  var numSelected = selected.length, k = -1;
  if (!numSelected) return;
  // Build a grid of evenly spaced soldiers.
  var sqrt = Math.sqrt(numSelected),
      rows = Math.ceil(sqrt),
      cols = Math.ceil(sqrt),
      x = Mouse.Coords.worldX(),
      y = Mouse.Coords.worldY(),
      iw = Math.ceil(w / numSelected), // grid cell width
      ih = Math.ceil(h / numSelected), // grid cell height
      wg = iw*1.2, // width of gap between cells
      hg = ih*1.2; // height of gap between cells
  if ((rows-1)*cols >= numSelected) rows--;
  w = iw * cols + wg * (cols-1); // total width of group
  h = ih * rows + hg * (rows-1); // total height of group
  // Sort by location to avoid soldiers getting in each others' way.
  selected.sort(function(a, b) {
    // Round to 10's digit; specific locations can be off by a pixel or so
    var ax = a.x.round(-1), ay = a.y.round(-1), bx = b.x.round(-1), by = b.y.round(-1);
    return ay - by || ax - bx;
  });
  // Place the grid over the mouse and send soldiers there.
  for (var i = 0; i < rows; i++) {
    for (var j = 0; j < cols; j++) {
      var s = selected[++k];
      if (s) {
        var mx = x + j * (iw+wg) - w * 0.5 + s.width * 0.5,
            my = y + i * (ih+hg) - h * 0.5 + s.height * 0.5;
        // Finally, move to the end destination coordinates
        s.moveTo(mx, my);
      }
    }
  }
}

You can paste this function into your browser's JavaScript console when viewing the demo and mess around with it to change the soldiers' behavior.

My question is: is there a better way to determine the target location for each soldier to move to?


texts: How to snap a 2D Quad to the mouse cursor using OpenGL 3.0?

texts:
I've been having issues trying to snap a 2D Quad to the mouse cursor position I'm able :

1.) To get values into posX, posY, posZ

2.) Translate with the values from those 3 variables

But the quad positioning I'm not able to do correctly in such a way that the 2D Quad is near the mouse cursor using those values from those 3 variables eg."posX, posY, posZ"

I need the mouse cursor in the center of the 2D Quad.

I'm hoping someone can help me achieve this.

I've tried searching around with no avail.

Heres the function that is ment to do the snapping but instead creates weird flicker or shows nothing at all only the 3d models show up :

void display()
{
  glClearColor(0.0,0.0,0.0,1.0);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

  for(std::vector<GLuint>::iterator I = cube.begin(); I != cube.end(); ++I)
  {
      glCallList(*I);

       }

     if(DrawArea == true)
     {

    glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);

cerr << winZ << endl;

glGetDoublev(GL_MODELVIEW_MATRIX, modelview);

glGetDoublev(GL_PROJECTION_MATRIX, projection);

glGetIntegerv(GL_VIEWPORT, viewport);

gluUnProject(winX, winY, winZ , modelview, projection, viewport, &posX, &posY, & posZ);

    glBindTexture(GL_TEXTURE_2D, DrawAreaTexture);

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, DrawAreaSurface->w, DrawAreaSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, DrawAreaSurface->pixels);

    glEnable(GL_TEXTURE_2D);

    glBindTexture(GL_TEXTURE_2D, DrawAreaTexture);

glTranslatef(posX , posY, posZ);

     glBegin(GL_QUADS);

     glTexCoord2f (0.0, 0.0);
     glVertex3f(0.5, 0.5, 0);

     glTexCoord2f (1.0, 0.0);
     glVertex3f(0, 0.5, 0);

     glTexCoord2f (1.0, 1.0);
     glVertex3f(0, 0, 0);

     glTexCoord2f (0.0, 1.0);
     glVertex3f(0.5, 0, 0);

     glEnd();

        }

      SwapBuffers(hDC);
}

I'm using :

OpenGL 3.0
WIN32 API
C++
GLSL

if you really want the full source here it is -> http://pastebin.com/1Ncm9HNf , Its pretty messy.


texts: How can I process extra mouse buttons using Monogame?

texts:
I use Monogame for game development. For processing mouse input, I can use the Mouse class to query basic information like left click state, right click state, and screen position. That works fine for a generic three-button mouse (left, right, and scroll wheel), but falls short for more complex gaming mice with side buttons. My question is, how can I query those extra side buttons?

Since Mouse doesn't include that functionality, are there additional C# libraries I can use? How do I account for the fact that mice can have any number of extra buttons and wheels? Is there some standard for representing those additional buttons programatically?

Edit: This question originally also asked about complex keyboards with extra buttons or wheels. Now, I'm asking only about processing extra mouse buttons (ideally any number of extra buttons).


texts: Could use some help figuring out bouncy physics material in this PhotonEngine game

texts:
So I'm trying to prototype a primitive 1v1 fighting game where the goal is to push the opponent off of the platform rather than actually fight. This is working great in a local multiplayer setup using a physics material on the "belly" of the Rigidbody2d players (the circle collider gameobject nested inside of the square gameobject has the bouncy material).

But I'm toying with the idea of making it a network game and it seems the physics material doesn't get communicated too well over the Photon Realtime connections?

Here is a video showing how it seems like sometimes the position is updated but sometimes a player runs into another player and its like a brick wall:

https://imgur.com/QYWH178

Any ideas of what to try or if this is even possible?

A bit about how things are currently setup:
Each player object has the nested collider with a high bounciness material on it. Each player moves via the Rigidbody2D component via

.AddForce(direction * Speed);

I have a Photon View component on the player prefab and a Photon Rigibody 2D View component that is checked to Synchronize Velocity and Angular Velocity, as well as a Photon Transform View component synchronizing Position. Both the transform view and Rigidbody2dView are Observed Components in the Photon View.

I also found a script someone posted where they were manually sending the position/velocity data via OnPhotonSerializeView() I've tried adding that script and making that observable as well, but no luck, but it looks something like this:

 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
        {
            if (stream.IsWriting)
            {
                //We own this player: send the others our data
                stream.SendNext(transform.position);
                stream.SendNext(transform.rotation);
                stream.SendNext(r.velocity);
                stream.SendNext(r.angularVelocity);
            }
            else
            {
                //Network player, receive data
                latestPos = (Vector3)stream.ReceiveNext();
                latestRot = (Quaternion)stream.ReceiveNext();
                velocity = (Vector2)stream.ReceiveNext();
                angularVelocity = (float)stream.ReceiveNext();

                valuesReceived = true;
            }
        }

        // Update is called once per frame
        void Update()
        {
            if (!photonView.IsMine && valuesReceived)
            {
                //Update Object position and Rigidbody parameters
                transform.position = Vector3.Lerp(transform.position, latestPos, Time.deltaTime * 5);
                transform.rotation = Quaternion.Lerp(transform.rotation, latestRot, Time.deltaTime * 5);
                r.velocity = velocity;
                r.angularVelocity = angularVelocity;
            }
        }


texts: How to deal with procedural terrain, pre-load or real-time calculation?

texts:
I have developed an algorithm that generates 2D terrain coordinates for my iOS 2D game. This may be a possible visual output:

The coordinates are stored in a 2D array.

mVertices[i][0] = ccp(sx, sy);
mVertices[i][1] = ccp(sx, 0);

E.g. sx is increased in steps of 30px while i is the number of steps. For each step a sy is generated. To get the line straight down I need a second point which is the second line of code.

Imagine in the game there will be a character on that terrain. The terrain scrolls to the left while you have to move your character. Now I want to figure out what would be the best way for me to draw the terrain.

One way is to pre-load the terrain. So I would generate the points for say 5000px along the x-axis when the user starts the game while a loading spash is displayed.

Another way is to generate the terrain in real-time. I think this is the best solution here. What do you think?

When I take the real-time way, how I do the array stuff? I mean the part that goes out of screen has to be removed from the array and there is a new step that is added.

Maybe a classic array is not good as data structure for that prupose. I introduced it in my project because I can pass it to the ccDrawPoly function that takes a CGPoint array.

Please share your ideas.


texts: If you compare integration between WPF with XNA vs Winforms with XNA, what is the most suitable framework to integrate XNA framework with.


texts: Is Angry Birds Made Purely Using Bitmaps/Raster graphics?

texts:
Being a beginner game developer I would like to start creating my own engine and graphics so I am concerned about how successful games accomplish the graphics portion.
My question is, are all the graphics (background, birds, slingshot etc) in Angry Birds made with raster images only and using something like a sprite sheet for character animations?


texts: What's the recommended bitrate for Background Music in iPhone Games?

texts: What is the recommended bitrate for Background Music in iPhone Games?


texts:
I'm learning C++, and I'm writing my first OpenGL program. Unfortunately, it seems to be defaulting to Software Rendering (CPU uses bounces, GPU uses stays at 1%). I'm using SDL as the Windowing system. I've got no idea why, but when there is significant scaling, the program grinds to a halt. My PC should be able to handle it - I'm using an 8800GTX. My texture is 1024x1024, 32 bit RGBA and loaded with DevIL,  and glGetString(GL_VENDOR) is returning "NVidia Corporation". Any ideas?

I'm sorry to be dumping all the code, but I've got absolutely no idea at all what is doing it. I'm very new to OpenGL.

#pragma once
#include "SDL.h"
#include "SDL_opengl.h"7
#include "IL/il.h"
#include "IL/ilut.h"
#include <math.h>

const int SCREEN_WIDTH = 1024;
const int SCREEN_HEIGHT = 768;
const int SCREEN_BPP = 32;
const int FPS = 60;
const int XSIZE = 1024;
const int YSIZE = 768;

int main( int argc, char *argv[] )
{
    bool quit = false;

    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);

    SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_HWSURFACE |  SDL_OPENGL);

    glEnable(GL_TEXTURE_2D);

    const GLubyte * Vendor = glGetString(GL_VENDOR);

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear the background of our window to red
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    glOrtho(0, XSIZE, YSIZE, 0, 0, 1);
    glMatrixMode (GL_MODELVIEW);

    glDisable(GL_DEPTH_TEST);

    GLuint image;

    ilInit();
    ilutRenderer(ILUT_OPENGL);

    ILuint texid;
    ILboolean success;
    ilGenImages(1, &texid);
    ilBindImage(texid);

    success = ilLoadImage("Textures.png");
    if (success)
    {
        success = ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
        if (!success)
        {
            SDL_Quit();
            return -1;
        }
        glGenTextures(1, &image);
        glBindTexture(GL_TEXTURE_2D, image);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
        GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
        GL_NEAREST);
        glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
          ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
          ilGetData());
        ilDeleteImages(1, &texid);
    }
    else
    {
        SDL_Quit();
        return -2;
    }

    SDL_Event event;

    float x = 0.0f;

    while (!quit)
    {
        while ( SDL_PollEvent(&event) )
        {
            switch (event.type)
            {
                case SDL_QUIT:
                    quit = true;
                    break;
            }
        }

        glClear(GL_COLOR_BUFFER_BIT);

        glLoadIdentity();
        glTranslatef(200.0f, 200.0f, 0.0f);
        glRotatef(x,0.0f,0.0f, 1.0f);
        glScalef(1.0f+x, 1.0f+x, 1.0f+x);
        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f);
        glVertex2f(-100, -100);
        glTexCoord2f(0.0f, 0.119140f);
        glVertex2f(-100, 100);
        glTexCoord2f(0.091797f, 0.119140f);
        glVertex2f(100, 100);
        glTexCoord2f(0.091797f, 0.0f);
        glVertex2f(100, -100);
        glEnd();

        x += 0.1f;

        SDL_GL_SwapBuffers();
        glFlush;
    }

    return 0;
}

Edit : (24/04/2011 9.22 PM AEST)
When run on an ancient card, on an ancient computer, it maintains ~60FPS.


texts: What distinguishes a free to play game from one worth paying for?

texts: There's a heck of a lot of free games available out there, some of which are as good as games that you have to pay for. My question is, what makes the difference between a game that people will be willing to pay for, and one which is best left as a free to download/play online game subsidised with advertising?


texts: Why are shadows not snapping to the objects?

texts:
I'm using a directional light in Unity to cast shadows. However, the shadows don't appear to be "snapped" to the objects creating them. The object appears to be floating in mid air while it actually isn't.

How do I "snap" the shadow to the objects so it looks like it's actually on the ground?


texts: Deep Cloning C++ class that inherits CCNode in Cocos2dx

texts:
I'm stuck with something in Cocos2dx ...

When i copy my class that inherits CCNode, i get a shallow copy of my class but the base type seem to still point to the original node address. We dont seem to get a deep clone of any object that inherits CCNode, any ideas anyone?

Basically i have....

GameItem* pTemp = new GameItem(*_actualItem);

// loops through all the blocks in gameitem and updates their position
pTemp->moveDown();

    // if in boundary or collision etc...
if (_gameBoard->isValidMove(pTemp))
{
    _actualItem = pTemp;

    // display the position
    CCLog("pos (1) --- (X : %d,Y : %d)",  _actualItem->getGridX(),_actualItem->getGridY());
}

Then doesn't work, because the gameitem inherits CCNode and has the collection of another class that also inherits CCNode with is a pointer.

its just creating a shallow copy and when you look at children of the gameitem node in the copy, it still just points to the original base type?

class GameItem : public CCNode {

// maps to the actual grid position of the shape
CCPoint* _rawPosition;
// tracks the current grid position
int _gridX, _gridY;
// tracks the change if the item has moved
CCPoint _offset;

public:
//constructors
GameItem& operator=(const GameItem& item);
GameItem(Shape shape);

}

then in the implementation....

GameItem& GameItem::operator=(const GameItem& item)
{
_gridX = item.getGridX();
_gridY = item.getGridY();
_offset = item.getOffSet();
_rawPosition = item.getRawPosition();

// how do i copy the node?

return *this;
}

Any ideas are welcome at this point!!

thanks


texts: Animation package from Assert Store not working probably with Unity Model/Custom Model?

texts:
I downloaded the animation pack from here:
https://www.assetstore.unity3d.com/en/#!/content/25794
The assert contains a fbx file, which contains a bunch of animations.

Then in Animator window I added a State and transitions between states and have set the Motion in the inspector of the state.
Then I look at the preview in Animator's inspector with it original Model, the animation works properly:

If I apply Unity Model or my custom Model in the preview, its became:

Why is that?  How can I fix it?
Or did I use it incorrectly?


texts:
I'm working in java with LWJGL and trying to double all my pixels. I'm trying to draw in an area of 800x450 and then stretch all the frame image to the complete 1600x900 pixels without them getting blured. I can't figure out how to do that in java, everything I find is in c++... A hint would be great!

Thanks a lot.

EDIT : I've tried drawing to a texture created in opengl by setting it to the framebuffer, but I can't find a way to use glGenTextures() in java... so this is not working... also I though about using a shader but I would not be able to draw only in the smaller region...


texts: LibGDX trying to create a matrix of circles

texts:
I am trying to create a circular stage like so:

But I can only make a square:


texts:
I have a really simple question I cannot be sure about the answer.

What is the space of tangent (T), and bitangent (B) vectors when we calculate them using vertex positions, and texture coordinates?


texts: Understanding marching cubes and voxel data relationships

texts:
in case it matters i'm doing all this in unity with C# ...

I think I missed something or maybe don't understand the logic correctly.
I have an existing voxel engine that looks very "minecrafty" at the moment, and I want to step it up a bit so it actually looks reasonably good!

So lets say I have a "chunk", and common sense says that a chunk can either be on or off in a voxel world so its basically a "point cloud" (you either render it or you dont).
This means my game engine has something like this ...

public class Chunk
{
    public Block[,,] Blocks;
    ... other stuff
}

public class Block
{
    public bool Active;
    ... other stuff
}

So bring in the marching cubes and part 1 of Paul Bourke's guide (http://paulbourke.net/geometry/polygonise/) says ....

  The first part of the algorithm uses a table (edgeTable) which maps
  the vertices under the isosurface to the intersecting edges. An 8 bit
  index is formed where each bit corresponds to a vertex.

   cubeindex = 0;
   if (grid.val[0] < isolevel) cubeindex |= 1;
   if (grid.val[1] < isolevel) cubeindex |= 2;
   if (grid.val[2] < isolevel) cubeindex |= 4;
   if (grid.val[3] < isolevel) cubeindex |= 8;
   if (grid.val[4] < isolevel) cubeindex |= 16;
   if (grid.val[5] < isolevel) cubeindex |= 32;
   if (grid.val[6] < isolevel) cubeindex |= 64;
   if (grid.val[7] < isolevel) cubeindex |= 128;

Now here's what throws me ...
I'm comparing my "grid data" (so basically my block data) to some "isolevel" value.
Every implementation i've seen (the easiest being here: http://nucleardevs.wordpress.com/2011/11/17/marching-cubes-sourcecode/) does exactly that but it creates a load of float values using something like simplex or perlin noise and runs through this logic.

floats? not bools?

So ...

Given a Block[,,] if i check each blocks state (Active property) and return a simple true or false ... why do i need a float / double value or should I say ... what is the purpose of the float value that requires it to be a float and not a simple boolean?

I gather they are referred to as "densities" which implies that I missed something because i've been thinking of them as the point cloud data to be evaluated and a voxel (to my knowledge) isn't a "density" value its more like a switch (on off).


texts: How can I implement simple object orbits in Game Maker?

texts:
I've seen a lot of tutorials for things like "fixed circular orbit" and "elliptical orbits" which end up never been what I actually want.

I have two objects: oPlayer, and oPlanet.

I am trying to allow the player to move around freely, but be able to be caught by the gravity of oPlanet, causing the player to go around in circles/elliptical orbit. I also need the player to be able to escape thate orbit, and end up on a trajectory. In fact, I want it to work for any oPlanet.

What I am looking for is something similar to the orbital gravity in Kerbal Space Program.

Is there any way I should go about this? If anyone can be of help, I would rather answers be in GML rather than the Drag and Drop, but any help is great!


texts: Find out remaining distance before utilizing SetPath()

texts:
I am currently trying to find out the remaining distance of an object to the target point where I click at. However, CalculatePath() will only have a remaining distance of 0, if I do not use SetPath() beforehand. Is there an easy way to get the remaining distance without actually setting an object on their path/in motion?

 public void CreatePathing()
{
    ActiveToken = true;

    Ray ray = cam.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit;

    if (Physics.Raycast(ray, out hit) && ActiveToken == true)
    {
        NavMeshPath path = new NavMeshPath();
        NavMesh.CalculatePath(this.gameObject.transform.position, hit.point, NavMesh.AllAreas, path);

        if (path.status == NavMeshPathStatus.PathComplete && ActiveToken == true )
        {

            if (agent.remainingDistance > this.gameObject.GetComponent<Stats>().speed)
            {

                agent.ResetPath();
            }
            else
            {
                agent.SetPath(path);
                FalsePath = false;
            }

        }

        ActiveToken = false;
    }
}


texts: How to set ortho projection / model view matrix without a camera?

texts:
I'm trying to create the correct projection and model view matrix for rendering without a camera.

_orthoCamera is a camera I set up in the scene view. Using the _orthoCamera projection matrix and modelView matrix works but I don't know exactly how to recreate these. My attempt is the commented code.

    //not correct
    //var projection = Matrix4x4.Ortho(-512, 512, -512, 512, 0.3f, 1000);
    //var modelView = Matrix4x4.LookAt(new Vector3(512, 512, -5), new Vector3(512, 512, 0), Vector3.up); //inverse?

    //correct result
    var projection = _orthoCamera.projectionMatrix;
    var modelView = _orthoCamera.worldToCameraMatrix;

    GL.LoadProjectionMatrix(projection);
    GL.modelview = (modelView);

This is how I set the camera up in the scene.


texts: Algorithms for calculating vertex normals in 2D polygon

texts:
I have the points of a 2D polygon in the order in which they are connected, and I need to calculate the vertex normals and move them along it. An example is shown.

I would like to know how to calculate them efficiently and which structures I could use. I don't know if I have to find the orientation of the polygon, and what to do in general. As I said the only thing I have to start with is the list of points in the order in which they are connected. Say 5 vertices, I have a list that goes: x1, y1, x2, y2, x3, y3, x4, y4, x5, y5.

Where should I start?

It doesn't matter if the polygon becomes complex or self crossing, nothing matters just that to calculate the normals at the vertices and move them along these normals in the correct direction, all outwards or all inwards the polygon.


texts: Keeping instantiated grid in the centre of the screen?

texts:
everyone, I'm making a mobile game and I need help.
In the game, I instantiate a grid of dots as seen in the first attached file below.
My problem is the grid is not in the centre of the screen
I could just position my main camera so the grid is in the centre the only problem with this approach being that the grid changes in size depending on your level as shown in attachment 2

here's my spawn code

  for (int x = 0; x < gridX; x++)
         {
          for (int y = 0; y < gridY; y++)
             {
                 SpawnDelay = Random.Range(0.2f, 0.5f);
                 yield return new WaitForSeconds(SpawnDelay);
                 Instantiate(Dot, transform.position, transform.rotation);

                 NumberOfdots++;
        transform.position = new Vector2(transform.position.x + distanceBetween, transform.position.y);
                 if (y % MutpleNum == ByMutpleNum)
                 {
                     transform.position = new Vector2(GridoffsetX/2, transform.position.y + GridoffsetY);
                 }
             }

         }

Is there anyway I can have the grid centre regardless of its size

Thanks,

David


texts: Unity Physics Material - Character Slides Too Much

texts:
I am currently working on a 2D platformer in Unity. I am using a prefab from the AssetStore for my character (The last paragraph contains a link to the prefab). The character has a circle collider for his feet so that he can walk up slopes.

The problem I'm having is that because it is a circle collider, he also slides down any slope. I realize that I can add a Physics Material to the collider with a friction variable to stop (or at least resist) the sliding, but if I add any friction above ~0.1 the character can collide with a wall to stop himself from falling and yet 0.1 isn't even enough to stop him from sliding down slopes.

So my question is, how can I stop the character from sliding down slopes in a way that doesn't allow the player to stop himself from falling by colliding with walls?

The prefab that I'm using specifically is an asset found here, it's disk location is Sample Assets/2D/Prefabs/2D Character


texts: How to disable depth buffer in Directx11

texts:
For now i know what i must use OMSetDepthStencilState. In the beginning i must create two states and change them every time i need another. For now i have this and it doesn't work, i.e. objects rendered in order i draw them:

D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
depthStencilDesc.DepthEnable = TRUE;
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;
depthStencilDesc.StencilEnable = FALSE;
depthStencilDesc.StencilReadMask = 0xFF;
depthStencilDesc.StencilWriteMask = 0xFF;

// Stencil operations if pixel is front-facing
depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;

// Stencil operations if pixel is back-facing
depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;

ID3D11DepthStencilState *m_DepthStencilState;
HR(m_Device->CreateDepthStencilState(&depthStencilDesc, &m_DepthStencilState));
m_ImmediateContext->OMSetDepthStencilState(m_DepthStencilState, 0);


texts: Access vertex data stored in VBO in the shader

texts:
If I wanted to store extra data in a VBO for skinning (indices for indexing into an array of matrices of bones and floats for applying weights to those bones) How would I go about accessing that data in GLSL? I already know how to put the data in the buffer, interleaved with the rest of the data.

For example I want each vertex for a model to contain:

Vec3 position;
Vec3 normal;
Vec4 color;
Vec2 texCoords;
int boneCount;
int[3] boneIndex;
float[3] boneWeight;

Then drawing like:

bind(vertexBufferID);
glVertexPointer(3, GL11.GL_FLOAT, stridePlus, 0 * 4);
glNormalPointer(GL11.GL_FLOAT, stridePlus, 3 * 4);
glColorPointer(4, GL11.GL_FLOAT, stridePlus, (3 + 3) * 4);
glTexCoordPointer(2, GL11.GL_FLOAT, stridePlus, (3 + 3 + 4) * 4);
glVertexPointer(7, GL11.GL_FLOAT, stridePlus, (3 + 3 + 4 + 2) * 4);
glDrawArrays(GL11.GL_TRIANGLES, 0, VPNCTEnd);

Then in my vertex shader I want:

 //Get indices of bones
 //Get weights of bones
 //Get bone transforms
 //for each bone transform, apply it to gl_Position at the specified weight

What is the GLSL required for the last part of the process? It seems like I need to set a attribute pointer to the data somehow, but I'm not sure where to do that when the data is stored in the VBO.


texts: Opinions on using AE and/or Flash for 2D animation?

texts: I am each day making the art in illustrator more complete and now comes the time where I decide to invest in an animation program/route. I hear at times for people to use Toon Boom but the problem is I don't see a ton of tutorials and it seems like it's more for hand drawn animation. So, I'd use AE for example to draw out 15 or so frames for my robot rolling animation, adjusting the lines in different areas and then use a script to export that to a spritesheet I suppose. The main thing I want to avoid is the stiff puppet animation I see in many flash animations. So, do you guys have any thoughts on starting on either of these two programs for 2D animation or tips in general in relation to this process?


texts:
I would like to ask for game engine recommendations for turn based wargame development. I would like my engine to support;

hex maps
agents on hex
rule based ai for the agents
terrain on hex
cultural features on hex
los analysis
abstract agent templetes


texts:
i am currently having a struggle thinking about syncing bullets.
I am using node js and phaser.io and I am creating top-down shooter.

I would do it like this:
Player shoots a bullet.
Player sends information where that bullet is
Player2 gets information and updates their bullet.

But the problem is, when client window is out of focus. Physics are paused and so are bullet movement, which is horrible for multiplayer game.

How can I achieve synced bullet across two or more clients .

I tried searching for information about server sided physics for node,  but I really couldn't find any.

Thanks


texts: Normal mapping soft question: What could this be?

texts:
So I'm trying to implement tangent space normal mapping. I bind the uniforms, load the attributes, set the shaders, and out comes this:

This happens on the sides only, and not when in direct light. I'm pretty sure it's matrix related, but could it be I'm mapping the tangent values incorrectly? Has anyone seen something like this before? Or have a hunch what it could be?

UV screenshot, it's a cube, turned into a sphere, and each side is separated. The final object shows no seams on the top or bottom, but rather on each side.

Update: When I order the tangents according to UVs, I get a much cleaner result, but some areas/sides still get an inverted normal. I'm not sure why this is, or how to fix it. It happens on each side, so it is as if the sides get inverted normals.


texts: Click event doesn't trigger when clicking

texts:
I've made some buttons on my screen to navigate to other scenes of my Unity project but the Click(string command) method doesn't trigger. I've placed a breakpoint on the bold line in code below, but the pointer never hits that point.

public class GameNavigation : MonoBehaviour
{
    public void Click(string command)
    {
        switch (command)
        {
            case "again":
                Application.LoadLevel(Application.loadedLevel);
                break;

            case "go_to_menu":
                Application.LoadLevel("Navigation");
                break;

            default:
                break;
        }
    }
}

Here are also some screenshots form my Unity project.

What did I wrong?

Note one: I've made also this code that is called after the scene ends. the parameter command is always an empty string.

public void RestartLevel(string command)
{
    switch (command)
    {
        case "again":
            Application.LoadLevel(Application.loadedLevel);
            break;

        case "go_to_menu":
            Application.LoadLevel("Navigation");
            break;

        default:
            break;
    }
}

If I place it in a comment, I get this error:

  'Player' AnimationEvent 'RestartLevel' has no receiver! Are you missing a component?

Note two: I also use a mouse down event for when the player must shoot.

Update one: by a comment below I've made this code:

public Button btnAgain;
public Button btnMenu;

public void Start()
{
    btnAgain.onClick.AddListener(() => {
        Application.LoadLevel(Application.loadedLevel);
    });

    btnMenu.onClick.AddListener(() => {
        Application.LoadLevel("Navigation");
    });
}

The Start() method is always called, no problems with it. But the Application.LoadLevel(...) code never executes when I click on the methods. However btnMenu and btnAgain aren't null.

Update two: I've upload a zip file on my SharePoint that you can access. Start a game and choose level 01. You navigating to a new scene. On that scene you have on the right below side you have two buttons, these are the buttons that doesn't work. If you can find the problem, please give me the solving of the problem. Other bug fixes are also welcome. 😉


texts: Animations won't transfer states until entire animation is completed

texts:
I am following the survival shooter tutorial and am using Unity 5.

I just completed this video (linked) and I tested played it to see my animations worked but it seems like it will only transition from idle to walking after the entirety of the idle animation completes. The idle animation is quite long so my character will move around when it looks like its idling since the movement responds right away.

Did I mess up something in my transitions? I followed the directions exactly and didn't change anything in the inspector that I wasn't told to do.