texts: Cannot use my objects method when accessing from Stage LibGDX

texts:
I have a class Card with the method setOwner. I have set up my touch input to use a hitActor to identify touches by getting the Actor's name like so :

public boolean touchDown(int screenX, int screenY, int pointer, int button) {
   Vector2 hitCoord = stage.screenToStageCoordinates(new Vector2((float) screenX, (float) screenY));
   Actor hitActor = stage.hit(hitCoord.x, hitCoord.y, false);
    if (hitActor != null) {
            stage.getRoot().findActor(hitActor.getName()).setOwner();// here it doesnt identify the setOwner() method;
    }
    return false;
}

The problem is that it doesn't identify the method setOwner().
My Card actors are in a ListArray deck so I type casted them like so :

  for (Card c : deck) {
        c = (Card) stage.getRoot().findActor(c.getName() + c.getSuit());
    }

But still it doesn't identify the methods declared in the Card class. My goal is to call the methodsetOwner on the Actor that got touched.


texts: In Unity (2017) is there a way to set the buttons used by Input.GetAxis() programatically?

texts:
The buttons used for keyboard axis inputs can be set manually via Negative and Positive Button fields for the axis at Edit > Project Settings > Input Manager. However I'd like to make this a user configurable option which I think means needing to set the button values from a script.

I've been looking for a method along the lines of:

Input.SetAxis("Vertical").positveButton

But so far I'm striking out. Is there a way to do this?


texts: Directional light and finding relevant shadow casters

texts:
Right now when culling the models to render for the directional light shadow map pass I just do a view frustrum culling using the main camera. At some angles, the objects will be outside the view but still obviously should cast shadows.

My question is, how do you cull/gather all the relevant shadow casters for a directional light?


texts: Best way to create a level editor in java

texts:
I am creating an iPhone game using cocos2d + box2d that needs a lot of levels. My friends and I are creating the game and most of them have no programming experience and end up with nothing to do. I want to make a level creator / editor java applet that can create a level file and then I can parse that file into a box2d level with objective-c

The only problem is that I have never done game programming with java so I'm not sure where to start. I want to create something like this level editor video and let the user add predefined shapes like circles and boxes.

I can do all the objective-c side of things so I just need help with the java side

Any advice? Thanks


texts: What are Layout Qualifier in GLSL used for?

texts:
So I'm reading up on GLSL 4.0 standard and I see things like "layout (location = 0) in vec3...."

I understand they dictate where certain values are placed but...

Do particular locations hold special meaning (as in the index #s)?
Since I'm sending data by getting that attribute/uniform location by name, what advantage does it provide me?
What are some use cases / tricks done by using it?

On a side note: I see gl_FragColor is depricated, is gl_position deprecated too? Is there a particular name for the frag. shader output or is any vec4 output considered the final result?


texts: I am working on communicating unity application with an PC app. Since I doesn't know how socket programming can be implemented in unity.Can anybody please help me in creating a simple small application using TCP socket with unity


texts: I have a touchpad.  I tried touchpad.getKnobX> 0 and <0 (when swiping the knob left and right) the sprite still displayed but when I put touchpad.getKnobY> 0 and <0 (to swipe knob up and down) the sprite didn't show.  Why is that?


texts: Failing to move exponential depth term to depth shader in exponential shadow mapping

texts:
I'm playing around in my little toy project to see if I can understand how exponential shadow mapping works. To begin, I have the following two fragment shaders:

Light depth texture shader

layout(location = 0) out float fragmentdepth;

void main(){
  fragmentdepth = gl_FragCoord.z;
}

Main shader

...
vec3 shadowDiv = shadowCoords.xyz / shadowCoords.w;
float lightDepth = texture(depthMap, shadowDiv.xy);
float visibility = clamp(exp(-70 * shadowDiv.z) * exp(70 * lightDepth), 0, 1);
...

This works fine - I have shadows where I expect them, and I'm using the approximation to the boolean function by taking the product of exponentials, as shown in the ESM paper.

However, my understanding is that the whole point of this, is that I can move exp(70 * lightDepth) out of this shader, and into the shader when I generate the depth texture at the light. That is:

New light depth texture shader

layout(location = 0) out float fragmentdepth;

void main(){
  fragmentdepth = exp(70 * gl_FragCoord.z);
}

Main shader

...
vec3 shadowDiv = shadowCoords.xyz / shadowCoords.w;
float lightDepth = texture(depthMap, shadowDiv.xy);
float visibility = clamp(exp(-70 * shadowDiv.z) * lightDepth, 0, 1);
...

When I make this change, the entire scene becomes shadowed. I'm sure I'm misunderstanding something somewhere, but I'm not sure where. I have tried varying the constant term (70) between 1 and 70, though this doesn't appear to make a difference. I have no errors reported by KHR_debug

I am creating my light depth texture as:

genLightDepthMap :: IO GLTextureObject
genLightDepthMap =
  do lightDepthMap <- overPtr (glGenTextures 1)
     glBindTexture GL_TEXTURE_2D lightDepthMap
     glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER GL_LINEAR
     glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_LINEAR
     glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_S GL_CLAMP_TO_EDGE
     glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_T GL_CLAMP_TO_EDGE
     glTexImage2D GL_TEXTURE_2D
                  0
                  GL_DEPTH_COMPONENT24
                  shadowMapResolution
                  shadowMapResolution
                  0
                  GL_DEPTH_COMPONENT
                  GL_FLOAT
                  nullPtr


texts: How to include compiled GameMonkey script in final game release instead of script source?

texts:
I use GameMonkey to script the game play and use the script from my C\C++ host game.
I've got it working the script with my engine.
But I have a question. In these engines like Torque, Unreal, Unity, etc. when you finally build the game, all the scripts are also compiled and you don't need to ship all the script source.

How do I do that?
Right now my engine needs GameMonkey source script to process the game logic.

Thanks


texts: How can I increase the spawn rate and speed after some time?

texts:
I'm working on a Super Hexagon-like game and the goal is to survive as long as possible. The game is working fine but I want to add a new feature that increases the spawn rate of the obstacles and also beside that, I want to increase the player speed. For example, let's say I want to change the spawn rate to 2 if the player survives 1 minute or change the player speed to 610 after lasting 50 seconds. But the point is that the player should play that 1 minute (or 50 seconds) without dying in order for values to be changed and if he dies in that time, then the values won't change and the timer will be reset. I don't know how I can implement this but I guess I should use coroutines. Any help would be appreciated.
Player script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Player : MonoBehaviour
{
    public float moveSpeed = 600f;
    float movement = 0f;

    void Update()
    {
        movement = Input.GetAxisRaw("Horizontal");
    }

    void FixedUpdate()
    {
        transform.RotateAround(Vector3.zero, Vector3.forward, movement * Time.fixedDeltaTime * -moveSpeed);
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        SoundManager.playSound();
    }

}

Spawner script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawner : MonoBehaviour
{
    public float spawnRate = 1f;

    public GameObject hexagonPrefab;

    private float nextTimeToSpawn = 0f;

    // Update is called once per frame
    void Update()
    {
        if (Time.time >= nextTimeToSpawn)
        {
            Instantiate(hexagonPrefab, Vector3.zero, Quaternion.identity);
            nextTimeToSpawn = Time.time + 1f / spawnRate;
        }
    }
}

The game looks like this. When the spawn rate increases, the obstacles duplicate faster.


texts: When is the best time to consider performance?

texts:
I am coming from software development background. During the software
  development cycle, we usually focus on functionalities and the working
  product. At the end of development, we start optimizing the code and
  improving performance.

Now the question is, do we need to think about performance in every single line of code in game development?

Doing so I feel we miss the design patterns and clean code. I was wondering if there is any best practice approach in game development industry?


texts: Are javascript MVC model implementations too slow for games?

texts:
I wanted to implement a game in javascript with an MVC design pattern, with each entity's state stored in a model.
So for example,
In an update loop we iterate over all models and apply the velocity attribute to the position attribute of the model.
A view associated with each entity/model would then receive a position changed event,
and update the representation of the entity.
This would happen independently of the views render method being called in a requestAnimationFrame callback.
What I found though, through a possibly naive implementation, is that setting attributes of a model is simply too slow.
As much as I prefer the architecture of this code, the framerate was significantly lower.
Should I give up on using MVC for frequently updated attributes like position?
Below, I've included some code to test aspects of setting attributes of an object.
The most minimal model-like behaviour, in which an attribute is set only when the new value differs from the current,
and a "changed" update event is triggered, is about 10x slower than just setting attributes directly.
Output:

> test(1000, 100, 10)
object[key]: 163 ms
object[key] if changed: 172 ms
object[key] if changed & emit backbone event: 953 ms
Backbone.Model: 4043 ms
eventsBackboneCount: 100000

var test = function(creations, iterations, keyCount){
  var eventsBackbone = _.extend({}, Backbone.Events);
  var eventsBackboneCount = 0;
  eventsBackbone.on('all', function(){
    eventsBackboneCount = eventsBackboneCount + 1;
  });

  var looper = function(label, create, set){
    var start = (new Date()).getTime();

    var data = {};

    for(var i = 0; i < creations; i++){
      data[i] = create(i);
    }

    for(var j = 0; j < iterations; j++){
      for(var i = 0; i < creations; i++){
        var key = ''+(j % keyCount);
        set(data[i], key, Math.random());
      }
    }

    var end = (new Date()).getTime();

    console.log(''+label+': '+(end - start)+' ms');

    return data;
  };

  looper(
    'object[key]',
    function(id){
      return {};
    },
    function(datum, key, value){
      datum[key] = value;
    }
    );

  looper(
    'object[key] if changed',
    function(id){
      return {};
    },
    function(datum, key, value){
      if(datum[key] !== value){
        datum[key] = value;
     }
    }
    );

  looper(
    'object[key] if changed & emit backbone event',
    function(id){
      return {id:id};
    },
    function(datum, key, value){
      if(datum[key] !== value){
        datum[key] = value;
        eventsBackbone.trigger('changed:'+datum.id, datum, key);
     }
    }
    );

  looper(
    'Backbone.Model',
    function(id){
      return new Backbone.Model({});
    },
    function(datum, key, value){
      datum.set(key, value);
    }
    );

  console.log('eventsBackboneCount: '+eventsBackboneCount);
};


texts: Cocos2d CCSpriteFrameCache: couldn't load texture file

texts:
I am currently doing this Cocos2d tutorial: http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d

...and get the following error messages:

2011-12-30 16:36:28.536 AnimBear[11273:10a03] cocos2d: CCTexture2D. Can't create Texture. UIImage is nil
2011-12-30 16:36:28.537 AnimBear[11273:10a03] cocos2d: Couldn't add image:AnimBear_default.png.ccz in CCTextureCache
2011-12-30 16:36:28.537 AnimBear[11273:10a03] cocos2d: CCSpriteFrameCache: couldn't load texture file. File not found: AnimBear_default.png.ccz
2011-12-30 16:36:28.538 AnimBear[11273:10a03] cocos2d: CCTexture2D. Can't create Texture. UIImage is nil
2011-12-30 16:36:28.538 AnimBear[11273:10a03] cocos2d: Couldn't add image:AnimBear_default.png.ccz in CCTextureCache
2011-12-30 16:36:28.539 AnimBear[11273:10a03] cocos2d: CCSpriteFrameCache: couldn't load texture file. File not found: AnimBear_default.png.ccz
2011-12-30 16:36:28.540 AnimBear[11273:10a03] cocos2d: CCTexture2D. Can't create Texture. UIImage is nil
2011-12-30 16:36:28.540 AnimBear[11273:10a03] cocos2d: Couldn't add image:AnimBear_default.png.ccz in CCTextureCache
2011-12-30 16:36:28.541 AnimBear[11273:10a03] cocos2d: CCSpriteFrameCa[Switching to process 11273 thread 0x1410b]
[Switching to process 11273 thread 0x10a03]
che: Frame 'bear1.png' not found
2011-12-30 16:36:28.598 AnimBear[11273:10a03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x17e4052 0x1975d0a 0x17d136e 0x17d2220 0xc1997 0x3fcf1 0xc16dd 0xc0d7c 0x828b0e 0x8298a6 0x838743 0x8391f8 0x82caa9 0x2798fa9 0x17b81c5 0x171d022 0x171b90a 0x171adb4 0x171accb 0x8292a7 0x82aa9b 0xc085f 0x2135)
terminate called throwing an exceptionsharedlibrary apply-load-rules all

I have the following files in the Resource folder:

AnimBear_default.png.ccz
AnimBear_default.plist

The texture consists of eight(8) bears named Bear1.png - Bear8.png. I have bought and done the texture in Zwoptex, latest version.

The code looks like:

-(id) init {

if((self = [super init])) {

    [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"AnimBear_default.plist" textureFile:@"AnimBear_default.png.ccz"];
    CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"AnimBear_default.png.ccz"];
    [self addChild:spriteSheet];

    NSMutableArray *walkAnimFrames = [NSMutableArray array];
    for (int i = 1; i <= 8 ; ++i) {
        [walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"bear%d.png", i]]];
    }

    CCAnimation *walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.1f];

    CGSize winSize = [CCDirector sharedDirector].winSize;
    self.bear = [CCSprite spriteWithSpriteFrameName:@"bear1.png"];
    _bear.position = ccp(winSize.width/2, winSize.height/2);
    self.walkAction = [CCRepeatForever actionWithAction:
                       [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
    [_bear runAction:_walkAction];
    [spriteSheet addChild:_bear];

}
return self;

}

I am completely new to Cocos2d and have been trying to search the web and tried different things but with no success :-(


texts:
In this post Patrick Hughes suggested, and michael.bartnett was kind to explain a bit how to do that. While it seems rather clear how to implement and use it, I'm still a bit doubt if this useful enough. Does this kind of "testing" is used widely? I mean every change in a game usually change either how input is processed or a response to same input. This makes all recorded input obsolete. Or maybe I'm missing something?

I feel like implementing a unit testing for core parts (see also) of a game are much more useful, despite it also seems much harder to implement.

So the question is, does mocking input is really good at something in game testing?


texts:
Level Design Creep is what I've started to call what happens when you build a series of levels and notice that every level is a little bit better looking or designed than the last, or when working together with several people with different skill levels. Left alone, as the player goes through the game the level quality would go up and down according to the order the levels were built. It seems like we're spending more time on this than we should be.

Besides cutting out the really good and really bad levels, is there a way I can plan for or manage the production so that the detail doesn't "creep up," and we have to revisit the same work over and over?


texts: How to prevent object from moving when it's mesh/collider is being updated?

texts:
So I a made a script that lets the player grab a vertex, move it, and then update the mesh. To help prevent the player from trying to clip it through other objects I made it so the mesh/collider is constantly being updated. It works however there is an issue where it keeps falling into itself. So I tried updating the constraints to prevent this but it doesn't seem to help anything.

Visualization...

With the mesh being updated after the LMB is released: http://gifyu.com/images/withnocollisionprevetnion.gif (SE doesn't like non-imgur links apparently and they are too big for imgur).

With the mesh being updated in real time: http://gifyu.com/images/withcollisionprevetnion.gif

Also here is a gif showing how constraints on the RB don't solve the problem
 (I've tried freezing on different axes but those still cause issues too): http://gifyu.com/images/constprob.gif

So basically what can I do to prevent the object from moving when it's mesh/collider is being updated?


texts:
I am creating a game in LWJGL with Java that will feature growing animals that will be imported as OBJ files from Blender.

If I wanted these animals to grow, would I create a full sized 3D model and then shrink it via code and have it grow up, or would I have a small sized 3D model and have it expand in the game to full size?


texts: For loop not detecting Actors in draw method. (libGDX)

texts:
Question: In my code, I want to draw my actors through a For Loop. However the for loop doesn't seem to detect the addActor() call or even other libGDX calls.

Code:

package com.puzzlepieces.jjstudios;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.ui.Table;

import java.util.Random;

public class Box extends Table

{
    Texture box = new Texture(Gdx.files.internal("box.png"));
    Random rand = new Random();
    Texture test = new Texture("bomb.png");

    @Override
    public void draw(Batch batch, float parentAlpha)
    {
        super.draw(batch, parentAlpha);

        batch.draw(box, 400, 90, 900, 600);

        this.setBounds(400 , 90, 900, 600);
        this.addActor(new Bomb());

        this.setDebug(true);

        for (int i = 0; i>5; i++)
        {
            for (int a = 0; a > 9; a++)
            {
                int randomNo = rand.nextInt(2);  // Sets random value
                int est = 0;

                if (randomNo == 0)
                {
                    this.addActor(new Bomb());   //Spawns bomb if value 0
                }
                else if (randomNo == 1)
                {
                    this.addActor(new FireCracker());  //Spawns FireCracker if value 1
                }
                else if (randomNo == 2)
                {
                    this.addActor(new SteeringWheel());  //Spawns SteeringWheel if value is 2
                }
                else if (est == 1)
                {
                    batch.draw(test, 400, 90);
                }
            }
            this.row();
        }
    }
}

Please help me and sorry if I made some mistakes in my post as I'm a newbie


texts:
I am a second year, learning C/C++ and Java.

In our first year of university we did basic C++, no classes. This year we have been introduced to classes and inheritance. We have not yet done pointers, virtual functions, abstract classes, operator overloading, exception handling, linked lists, stacks, queues, binary trees, graphs, etc.

I am very curious, so I like to teach myself some things that we haven't yet done. I enjoy the technical side of things a lot, my friends think I am weird to want to learn more than I have to..

But heres my problem:

Our C++ lecturer has decided to take a different approach this term to learning. He said, form a group, think of a project you would like to do and implement it over the year.

Let me give you a break down of our group:

Theres five of us in the group. Myself and another member are much more experienced than the other three and we like the technical side of things, and are quite motivated to do something with an interesting challenge. Then we have a group member who has been extremely hard to motivate, and he was very unsure why he wanted to be a programmer. He did some thinking and decided he wanted to work towards becoming a game programmer. The next member of ours is not the most reliable and has let us down a few times. Finally we have a new member that is keen to learn, but his programming needs work, as do the previous two members.

We are all friends, of course -- which probably isn't the ideal solution to a good group.

The project idea:

Our lecturer gave us an initial idea for a project: a timetable scheduler. Of course this is no trivial task, but most of our members were not really interested in the project at all. So, then I thought -- one member wants to be a game programmer (the hardest member to motivate), most of us would probably enjoy the experience of doing a game, as it would be a big challenge, so why not give it a go?

So what is my question?
Do you think that we should take on the task of making a game, or aim for something else?

Initially we thought of a 2D, top-down, ARPG. Then it became a 3D ARPG.

Obviously 3D would be harder, but as we have time to learn, it wouldn't be such a bad idea would it?

Personally I think that the learning will be the most fun part of this project, even if we don't end up with a great game, we should have learned  a lot (including being forced to learn and implement new C++ topics).


texts:
Why are classes created by the game developer in Unity public (by default) when you could just as easily make them internal? For example: I go Assets->Create->C# Script. Via the default script template, I have just created a public class that derives from MonoBehaviour. But technically shouldn't this class only have to be internal? If so, I really want to delete that public keyword, because having the word public is a slight distraction to me.

Do outside DLLs call functions within the developer-created DLL? I don't think so, right? Because the classes in other DLLs wouldn't know what funcitons are in there beforehand anyway.

I don't know much about how these DLLs interact with each other, but I get the feeling outside DLLs don't particularly care about the one DLL assembly the game developer himself generates.

Take a look at my picture - it seems like Unity just jams all developer-created scripts in one assembly. Yes, the assembly does reference MonoBehaviour, (so I assume other classes in all the other dlls are public, not internal) but no classes outside of this one need be concerned with the details inside this assembly.

It doesn't matter that much. Yes, I could go on living my life peacefully and making my classes public within Unity. But is there any potential drawback, and isn't it considered better practice, to make them internal? If there's nothing wrong with making my classes internal, then I'm going to edit the default template.


texts: Raycast not working on touchscreen (Android tablet/phone)

texts:
I have a raycast that works in the unity editor but not when I build it for Android( tablet or phone, neither work). The code I'm using is as follows:

public class DirectionalTilePlacing : MonoBehaviour {

public LayerMask levelLayer;
private int tileType;
public int Tiletype
    {
        get { return tileType; }
    set
    {
        tileType = value;
    }
    }
RaycastHit hit;
Vector2I placePosition;
// Update is called once per frame
void Update()
{
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    if (Physics.Raycast(ray, out hit, Mathf.Infinity, levelLayer))
    {
        if (hit.collider.tag == "Replaceable")
        {

            transform.position = new Vector3(Mathf.Floor(hit.point.x) + 0.5f, Mathf.Floor(hit.point.y), Mathf.Floor(hit.point.z) + 0.5f);
            GetComponent<MeshRenderer>().enabled = true;
        }
    }
    if (Input.GetMouseButtonUp(0))
    {
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out hit, Mathf.Infinity, levelLayer))
            if (hit.collider.tag == "Replaceable")
            {
                placePosition = new Vector2I((int)transform.position.x, (int)transform.position.z);
                EditorManager.map.SetEmpty(placePosition);
                EditorManager.map.BrushTile(EditorManager.map.TypeToObject((Tile.tileType)tileType), placePosition, (Tile.tileType)tileType);
                GetComponent<MeshRenderer>().enabled = false;
                gameObject.SetActive(false);
            }
    }

}

}

Everything up until any Physics.Raycast line works. The idea is that there is a ray casted from the position your finger is at when touching the screen.


texts:
I'm currently getting a formal degree related to computation, in particular my current focus is numerical programming, scientific computing and machine learning. I'd love to apply that knowledge in game dev and expand it with statistics, probability theory, and graph theory (probably even linear algebra). The question is: which spheres of gamedev are filled with such math stuff, is it possible to advance in those without being a part of a group of people and how to get to it gradually?

P.S.: I've got experience with commercial java dev and am getting my hands on C/C++ at the moment, however, I'm opened to go ahead and try Unity3D and etc.


texts: How to prevent a circular dependency between an entity and its state?

texts:
I've read this question, and I think it has some good answers and discussion, but it appears to focus primarily on rendering.

I have a different problem in the management of a game entity's state. What I end up with is this:

Game -> Player -> FSM -> State -> Player

Upon entry into a state a pointer to Player must be passed through, but no matter what I do in C++ it has trouble resolving this relationship hierarchy.

A good deal of how I'm designing my FSM is like this article. However, that is a psuedo implementation, and does not use headers. Without moving completely over to behavior trees is there another design pattern that will eliminate this circular dependency?


texts: How do I determine a device's default orientation?

texts:
I am developing a game with accelerometer controls. This works well on all the mobile phones I've tested it on. However, when testing on a tablet, the y and x axes are reversed, presumably because the device's default orientation is landscape.

How can I identify the default orientation of the device, to set my axes accordingly?

(I'm using Android SDK 1.5 - 1.7.)


texts: How much matrices should I use for OpenGL transformation?

texts:
As I start to get some deeper(or at least a little bit better) understanding on how camera transformations works, I am curious about one thing: How much matrices should I use ?

I mean, until now I have been working with simple 2d ortho projection and I was using world positions (not in range -1.0 to 1.0 ) so I just created a matrix at the start of the program and that was it but when I wanted to get more to 3D(to get same effect of not using NDC) I noticed (in tutorials) that they use a lot of matrices(for example : they create matrix for every object ingame for translation and then send it to the GPU). This confuses me because I thought that I will use only 3 matrices (for every transform step). Can you explain me how is this done in professional games? Do I need to load new model matrix for every object(send it to vertex) ? Or change the whole MVP matrix in shader with every object being rendered? Is it still sufficient? Thanks

Edit
About efficiency : Is it efficient to change the shader variable that often ? I mean, I want use my batch system from my old code and it looks like this now:

1. Bind texture + VAO
2. Render object.1+object.n via glDrawArrays/Elements/Instanced

But what about now it would be :

1. Bind texture + VAO
2. Load model matrix of object.1(via glUniformMat4fv) and render it, then load another model matrix for object2 and same for every object in batch

Isn´t it inefficient to change shader variable that much ?


texts:
I'm currently working on a simple 2D tile based game. I want to let users (=players) to create really large maps without problems with performance. That is why I'm searching the way how to optimalize the code before I actually write it. I've read some articles about streaming tiles, but I don't think I've understood them at all.

Map is stored in simple INI file like this:

[MAP]
title = "Test"
tileset="test.png"
width = 5
height = 5

tile_widht = 32
tile_height = 32

[LAYER]
type="background"
data="0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4"

# ... items, NPCs and quests definitions

When loading a new map, I'm reading the file line by line and parse it. After that, I create array of Tiles (std::vector tiles).

Every tile knows it's own position, value (which is the number indicating the tile from tileset), passability (number which indicates how hard is it to pass this tile), inventory (list of items lying on this tile), NPC list (list of NPCs standing on this tile) etc...

Now comes my problem. How to stream the tiles? With this file format it seems to be inpossible to load data when needed, so I have to load them at once.

Only thing which comes to my mind is, to store map data in arrays and create Tile classes only when they are really needed (if the tile position is withing the screen) and unload them after leaving the screen...

My question is, how do you suppose to solve this problem? How do you do it in your games?

Thank for your help and sorry for my English.


texts:
I built a 3D model in Autodesk 123d design, then exported it as an stl. When I convert it into an obj, however, there were no UVs in it.

Is there a way I can add the UVs back into the model using a program like blender?

Cheers!


texts: making a box2d body move along a Bezier curve/ arc path

texts: I have been trying to make a box2d body move along a Bezier curve/ arc path. Most of the posts I've seen recommend an approach of manipulating SetLinearVelocity and SetTransform to arrive at an arc-like movement. I don't think testing linear velocity values on a try and error basis would help. I would appreciate any help solving this problem. Thanks.


texts:
I created a character in Adobe Fuse, sent it to Mixamo for rigging with blendshapes and downloaded the fbx for unity file.
Below is how the character eyelashes appear in Fuse..

However, when I imported the fbx file and pulled it in my scene, the eyelashes appear as a piece of block. How do I fix this?

EDIT: It seems like the eyelashes are messed up due to Mixamo, there is no issue with Unity import. It happens when the Fuse character is sent to Mixamo for rigging and downloaded from there. When I opened the downloaded fbx file in Windows 3dViewer, it appeared with messes up eyelashes as shown below.

EDIT: Added the texture/material option pane, material settings and import settings for albedo texture in Unity below:


texts: Why are there no dynamic shadows in UE4?

texts:
So my problem is that other than for static objects which have baked shadows from building lighting, there are no shadows for movable objects, like those cubes. Neither from the Light source actor, which is stationary, nor from Point lights that are either static or moveable.

I may be wrong but I think it used to have dynamic shadows (or I didn't notice the lack of them until recently). So any ideas how to get dynamic shadows?
Thank you


texts: Graphics Pipeline, how exactly it works and how graphics card interprets it?

texts:
I've looked at this Wikipedia's link, http://en.wikipedia.org/wiki/Graphics_pipeline, but the article lacks in-depth explanation.

The only thing, I suppose, I understand and can expand upon, is, Texture part:

Apply bump map
Apply specular map
Apply displacement map
Apply texture map
In between apply any other maps(?)

What interests me in the answer, is, what happens with the model on every frame rendered, like:

Application launched, requests a 3d model (OpenGL/D3D)
OpenGL/D3D calls hardware for help
Polygons get loaded into graphics card memory,
Something gets done, blah, blah
The Texture part comes in (the upper list), loading every texture in memory card memory texture that needs to be applied to the mesh.
Maybe something more?
Display to monitor or send out to operating systems display interface?

In short: OS -> Application -> OS -> Hardware -> OS -> Display device.

My examples are just what I understand/can make out of all this. But I'm looking for an answer that goes well in depth on graphics pipeline.

Would like to know how AAA tools like CryEngine, UDK does graphics rendering, where we have all the dynamic lightning and stuff like that.

I'd be more than thankful with answer that contains an example of, for instance, what does the character model (CryEngine/UDK) has to go through to get rendered in full fashion, with approximate included memory consumption/hardware instruction called, like:

Load polygons [OpenGL issues command, hardware instruction, memory used, possibly GPU usage?]
Next function [OGL, HW, Memory, GPU]

And, what are the best practices for graphics pipeline?

P.S. Please correct me if that's not Graphics Pipeline I'm referring to.

Thanks in advance!


texts: Why can I not map a dynamic texture in D3D?

texts:
I am trying to map a Texture2D resource in DirectX11 via SharpDX.

The resource is declared as a ShaderResource, with Dynamic usage and the 'Write' CPU flag specified.

My call however fails with a generic exception from SharpDX:

_Parent.Context.MapSubresource(
  _Resource,
  0,
  SharpDX.Direct3D11.MapMode.Write,
  SharpDX.Direct3D11.MapFlags.None,
  out stream
);

I see from this question that it is supported. The MSDN docs and this other question hint that instead of using Context.MapSubresource() I should be using Texture2D.Map(), however, the DirectX11 Texture2D class does not define Map() (though it does for the D3D 10 equivalent).

If I call the above with MapMode.WriteDiscard, the call succeeds but in this case the previous content of the texture is lost, which is no good when I only want to update a section of it.

Has the Map() method been removed in Direct3D 11 or am I looking in the wrong place?
Is the MapSubresource() method unsuitable or am I using it wrong?

EDIT:
I declared my resource as Dynamic with CPU Write Flags - not Default as I originaly wrote - sorry for the fairly huge 'typo' that changes the entire question!


texts:
In SDL, lets say I'm rendering text to a surface. Then I blit it with the scene's main surface to form a composite image to flip.

I get the text surface into a class-level member called 'messageSurface':

messageSurface = TTF_RenderText_Solid( ..... );

So, do I have to call

SDL_FreeSurface(messageSurface);

on every loop to prevent memory leaks? Or will SDL "reuse" the old surface the next time around?


texts: Unity: Set new Origin using empty GameObject

texts:
You used to be able to set a GameObject with your Mesh as a child of an Empty GameObject. By rotating the Empty the Mesh would rotate around the position of the Empty. Now after the update it seems it's auto calculating a Median Point.

Here's the problem: https://www.youtube.com/watch?v=gxB_6c75oP0

I should be able to keep the original Origin of the empty GameObject no matter what children it gets. What happened to Unity?

This is how it used to be: https://answers.unity.com/questions/609267/how-to-change-the-origin-of-a-gameobject.html


texts: LibGDX - Actors on top of each other, avoid multiple draw calls

texts:
I am writing a card game with multiple cards that will stack up on the unplayed deck, and also on player hands.

Currently I add all 100 card actors to the screen at the start to make it easier so i don't have to manage adding them when they are needed. They all start on top of each other and some get dealt out to players hands, which are also just piles of cards. So in theory with a 5 player game there are only 6 cards visible, the deck and the top off each player's hand.

I'm hoping someone can tell me off a clever method to mean that only 6 draw methods get run on the actors that are visible, or do i have to manage all this myself?

If i do, would you suggest adding the actors only when i need them, or adding them invisible and then setting them visible when i need to?

Or another method?


texts: Given a start and end point, how can I constrain the end point so the resulting line segment is horizontal, vertical, or 45 degrees?

texts:
I have a grid of letters. The player clicks on a letter and drags out a selection. Using Bresenham's Algorithm I can create a line of highlighted letters representing the player's selection.

However, what I really want is to have the line segment be constrained to 45 degree angles (as is common for crossword-style games).

So, given a start point and an end point, how can I find the line that passes through the start point and is closest to the end point?

Bonus: To make things super sweet I'd like to get a list of points in the grid that the line passes through, and for super MEGA bonus points, I'd like to get them in order of selection (i.e. from start point to end point).


texts:
Is there a function that according to the name of the object, its tag and the time taken since the beginning of the game(for example time+=Time.deltaTime), gives the position of this object?

if yes which one?

thanks

from a rectilinear trajectory unknown to a randomly translated object, I need to press a Q key to know its direction vector. For this, I get the position of the object to the object. Q support and if I get the position of the object in the lapse of time preceding the moment of this support, the difference of these 2 positions gives me the direction sought of the trajectory at this moment.

When I have perfectly resolved this script, I will create another very similar one that will give me the vector direction of the rectilinear trajectory of the object at each collision on another object

Here is my script:

  Blockquote

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class script5 : MonoBehaviour {

//public GameObject sphere;
public static float t;
//public float laps_time;
public static float temps;
//public float difftime;
//float temps_appui;

float x1,y1,j1;
float x2,y2,j2;
float x3,y3,j3;

// Vector3 cat = transform.position;
    struct vecteur {
    public float k1;
    public  float k2;
    public float k3;

};

// Use this for initialization
    void Start ()
    {
        temps+=Time.deltaTime;

}

//fonction retournant la position d'un objet à un instant précis
vecteur function_script6(float t)

{
    vecteur v;
    v.k1 = 0;
    v.k2 = 0;
    v.k3 = 0;

    Vector3 cat = transform.position;

    if (temps == t) {
        v.k1 = cat.x;
        v.k2 = cat.y;
        v.k3 = cat.z;

    }

    return v;
}

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

    float temps_appui;
    public float difftime;
    public float laps_time;
    //t += Time.time;

    //donner les coordonnées de la sphère au temps où la touche Q est appuyée
    if (Input.GetKeyDown (KeyCode.Q)) {

        //donner les coordonnées de la sphère au temps où la touche Q est appuyée
        temps_appui = temps;
        difftime=temps_appui-laps_time;

        function_script6 (temps_appui);

        //donner les coordonnées de la sphère au temps juste avant l'appui de la touche Q
        function_script6 (difftime);

        x1=function_script6(difftime).k1;
        x2=function_script6(difftime).k2;
        x3=function_script6(difftime).k3;

        j1=function_script6 (temps_appui).k1;
        j2=function_script6 (temps_appui).k2;
        j3=function_script6 (temps_appui).k3;

        //donne le vecteur de la trajectoire de la sphère à l'appui de la touche Q
        y1=function_script6 (temps_appui).k1-function_script6 (difftime).k1;
        y2=function_script6 (temps_appui).k2-function_script6 (difftime).k2;
        y3=function_script6 (temps_appui).k3-function_script6 (difftime).k3;

        print ("(position appui:" + j1 + "," +j2 + "," + j3 + ")");
        print ("(position difftime:" + x1 + "," + x2 + "," + x3 + ")");
        print ("(vecteur trajectoire:" + y1 + "," + y2 + "," + y3 + ")");
        print ("-----------------------------");

}

}
}

almost everything is good except for the position of difftime which is always null.
Why?


texts: Steering - Flocking with stopping without jittering

texts:
I have a simple steering system that integrates flow-field based path following and separation behavior that I use to control hordes of creatures.
These creatures follow the flow-field, but if a target enters their range, they stop and attack the target. The units behind them keep pushing forward, and the separation behavior kicks in, forcing some of them to circle around, but eventually when enough units have stopped to attack the target, those behind will have their desired direction cancelled out by the separation behavior.
At this point, they start jittering. Some frames they move forward a bit, and then when they get too close to the stopped units the separation force will be stronger and they will move back a bit, constantly turning around back and forth.
Any ideas how this is done in games with hordes of units pushing forward but those in the front have stopped?


texts: XNA 4.0 - Mixing 3D and 2D - SpriteBatch putting weird alpha texture over whole scene

texts:
I am working on a game in XNA 4.0 that has been entirely in 3D so far but now I want to incorporate a HUD.

I have tried doing a simple test using spriteBatch as such:

spriteBatch.Begin();
spriteBatch.Draw(Player.Texture, new Rectangle(0, GameConstants.GraphicsDevice.Viewport.Height - 50, 50, 50), Color.White);
spriteBatch.End();

This works fine and the test texture shows as a rectangle in the correct position but the 3d World behind seems to have a sort of "haze" over the top which looks like the drawn "Player.Texture" has been put all over the viewport but at an alpha of like 0.1f.

I googled around and have a reset() function to change some of the GraphicsDevice properties back after drawing the SpriteBatch but nothing has changed and I haven't seen anyone else with this problem.

I thought it would be that SpriteBatch changes the blendmode to additive but in my reset() function I set the blendmode to opaque so I have no idea where this strange effect is coming from, it looks like I've ran some post-processing on the whole scene.

If I change the Player.Texture that is drawn in the SpriteBatch then the "haze" changes to look like the new texture so it is definitely to do with that.

Are there any other GraphicsDevice propterties I should check to change back?

Edit

Okay, I have just realised the "haze" over the top is from the SkySphere texture, I am using the MSDN skysphere shader from this tutorial.

So when I comment out the SkySphere code, the spritebatch and 3d drawing looks completely fine, but this leaves me with the problem that I can't have a SkySphere anymore.

Is there some reason why the skysphere is sort of drawn over the scene translucently rather than behind the 3D after I use a SpriteBatch? As I said before, it kind of looks like additive blending.

Below are 2 screenshots, the top is with spritebatch and no skysphere, below is with spritebatch and skysphere where I am having problems. I have cropped the images down to save upload (my internet is pretty slow at the moment) and I've changed the area of the scene in the 2nd image to show more clearly what it looks like. As I move around the scene with the camera the "haze" overlay stays in the same place exactly as how the SkySphere works, as in not taking into account the world matrix.


texts: Is it possible exchange points between players using Game Center?

texts: I want to create a turn based two player game. In my game in a certain stage if player 1 loses he must give few points that he have to the opposite player. The game is implemented with game center. Is there any possibility that I can do this point exchange via game center. I am also thinking about creating a local DB can some one help me with the best possible way.


texts: Property replication vs RPC: Communication directions

texts:
I have an UParticleSystemComponent attached to ACharacter. Its activation is controlled by user input, so it receives several updates per second.

For replicating the activation state of the particle system, the user input triggers an update of the value of a replicated variable (UPROPERTY(Replicated)) on the ACharacter. This works fine for the direction

Listen server -> Clients,

however not for the directions

Client -> Listen Server
Client -> Client.

I assume this is the case b/c "Property updates only come from the server (i.e., the client will never send property updates to the server)".

So for Client -> Client replication I have to rely on RPCs and can't use property replication at all?


texts: How to Make Objects Fall Faster in a Physics Simulation

texts:
I used the collision physics (i.e. Box2d, Physics Body Editor) and implemented onto the java code. I'm trying to make the fall speed higher according to the examples:

It falls slower if light object (i.e. feather).
It falls faster depending on the object (i.e. pebble, rock, car).

I decided to double its falling speed for more excitement. I tried adding the mass but the speed of falling is constant instead of gaining more speed. check my code that something I put under input processor's touchUp() return method under same roof of the class that implements InputProcessor and Screen:

@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button)
{
    // TODO Touch Up Event

    if(is_Next_Fruit_Touched)
    {
        BodyEditorLoader Fruit_Loader = new BodyEditorLoader(Gdx.files.internal("Shape_Physics/Fruity Physics.json"));

        Fruit_BD.type = BodyType.DynamicBody;
        Fruit_BD.position.set(x, y);

        FixtureDef Fruit_FD = new FixtureDef(); // --> Allows you to make the object's physics.
        Fruit_FD.density = 1.0f;
        Fruit_FD.friction = 0.7f;
        Fruit_FD.restitution = 0.2f;

        MassData mass = new MassData();
        mass.mass = 5f;

        Fruit_Body[n] = world.createBody(Fruit_BD);
        Fruit_Body[n].setActive(true); // --> Let your dragon fall.
        Fruit_Body[n].setMassData(mass);
        Fruit_Body[n].setGravityScale(1.0f);

        System.out.println("Eggs... " + n);

        Fruit_Loader.attachFixture(Fruit_Body[n], Body, Fruit_FD, Fruit_IMG.getWidth());
        Fruit_Origin = Fruit_Loader.getOrigin(Body, Fruit_IMG.getWidth()).cpy();

        is_Next_Fruit_Touched = false;
        up = y;
        Gdx.app.log("Initial Y-coordinate", "Y at " + up);

        //Once it's touched, the next fruit will set to drag.
        if(n < 50)
        {
            n++;

        }else{

            System.exit(0);

        }
    }

    return true;
}

And take note, at show() method , the view size from the camera is at 720x1280:

    camera_1 = new OrthographicCamera();
    camera_1.viewportHeight = 1280;
    camera_1.viewportWidth = 720;
    camera_1.position.set(camera_1.viewportWidth * 0.5f, camera_1.viewportHeight * 0.5f, 0f);
    camera_1.update();

I know it's a good idea to add weight to make the falling object falls faster once I released the finger from the touchUp() after I picked the object from the upper right of the screen but the speed remains either constant or slow. How can I solve this? Can you help?


texts: Map logical coordinates to graphical for walking

texts:
I'm having a problem with mapping logical coordinates to graphical ones when my character is walking. I've been able to map them without the graphical walking in between, i.e it just "jumps" from one tile to the other.

The logical coordinates are represented such as [0,0], [0,1] etc. and a character can only
be in one of these tiles at a time. I want my character to graphically move from one tile to the next at a given speed/pixels per rendering update until it hits the logical tile's graphical position.

If I didn't phrase myself good, please don't be afraid to tell me.


texts: After baking my lights again in Unity, my character is black?

texts:
I had to re-bake my scene several times before getting the look that I wanted. This last time, the scene looks great, but my characters are now very dark and the playable character is completely black. He lights up only when the directional light hits him.
Saying this makes me realize the problem (sort of): All the spotlights from the room's interior were probably baked while the characters were turned off, making their solution require the only real-time light in the scene in order to be seen.
Still, I didn't think the characters would be involved in the lightmap data? How do I redo the lights just for characters and moving objects? How can I fix this and keep the scene lighting?


texts: How to make a Google Play app with paid and free-with-in-app-purchasing versions?

texts:
I want to implement an IAP system as well as a fully paid one in my game.
There are about 8 levels in my game. I want the paid version to cost around $4 and in case of IAP, each level can be unlocked for 0.99 cents.
Do I have to create two separate apps (one for paid and one for IAP) or can I have both of these in a single app? The user can then decide if they want to buy the entire game or unlock a few levels using the IAP feature.


texts:
I am working on a simple game with topdown movement, but I am unable to get the collisions to work properly. I know the collision detection itself works, but the constraining of the player is where I fail. It gets close to working, but on the corners it still clips into the squares. Also, if I add more squares for the player to collide with, it fails completely. I am programming this game in Processing, which uses Java. Here is my code:

void Collide(float WallX,float WallY,float WallWidth,float WallHeight) {

  this.WallX = WallX;
  this.WallY = WallY;

  this.WallWidth = WallWidth;
  this.WallHeight = WallHeight;

  float TestX = PosX;
  float TestY = PosY;

  if(PosX <= WallX) {
    TestX = WallX;
    CollideLeft();
  }

  if(PosX >= WallX+WallWidth) {
    TestX = WallX+WallWidth;
    CollideRight();
  }

  if(PosY <= WallY) {
    TestY = WallY;
    CollideUp();
  }

  if(PosY >= WallY+WallHeight) {
    TestY = WallY+WallHeight;
    CollideDown();
  }

  fill(255,0,0,150);
  ellipse(TestX,TestY,16,16);

  Dis = sqrt(sq(TestX-PosX) + sq(TestY-PosY));

  println("Dis= ",Dis,", TestX= ",TestX,", PosX= ",PosX,", TestY= ",TestY,", PosY= ",PosY);

}

boolean CollideLeft() {

  if(Dis <= Radius+5) {
    //PosX = WallX-Radius;
    return CollideLeft = true;
  }
  else {
    return CollideLeft = false;
  }

}

boolean CollideRight() {

  if(Dis <= Radius+5) {
    //PosX = WallX+WallWidth+Radius;
    return CollideRight = true;
  }
  else {
    return CollideRight = false;
  }

}

boolean CollideUp() {

  if(Dis <= Radius+5) {
    //PosY = WallY-Radius;
    return CollideUp = true;
  }
  else {
    return CollideUp = false;
  }

}

boolean CollideDown() {

  if(Dis <= Radius+5) {
    //PosY = WallY+WallHeight+Radius;
    return CollideDown = true;
  }
  else {
    return CollideDown = false;
  }

}

void Move() {

  if(MoveRight && !CollideLeft) {
    MoveX(1);
  }
  if(MoveLeft && !CollideRight) {
    MoveX(-1);
  }
  if(MoveDown && !CollideUp) {
    MoveY(1);
  }
  if(MoveUp && !CollideDown) {
    MoveY(-1);
  }

}


texts: Data structures for territories in a 2D map

texts:
I am diving into game development with a 2D game. The game will display a territorial map (borders, capitals, etc.).

What is a common data structure to use for storing and manipulating the data in such a game? I'm considering using a graph (as in Graph Theory, not graphing).

Also, what are common file formats for storing the "polygon data" for each territory? Are there any standard or semi-standard formats?


texts: How can people recognize what engine a game uses, based off its graphics?

texts:
With many games, you can say "oh, that's the Unreal Engine, for sure", or "this was made with an upgraded Rockstar Advanced Engine". We can often recognize the engine used for a game just by looking at its graphics, disregarding user interface.

Why is this? All game engines use the same 3D rendering technology that we all use, and the different games usually have a distinct art style. What's left to recognize?


texts: Why is the position of this image changing?

texts:
I have a python script to simulate a wrench moving, I have calculated it's origins position in x and y as a function of time, the problem is when I try to rotate the image, my code moves the image out of frame.

import pygame, sys
import math

screen = pygame.display.set_mode((700, 400))
wrench = pygame.image.load('prueba.bmp')
white = (255,255,255)

ox = 20
oy = 32
running = True
posX = 100 - ox
posY = 100 - oy

pygame.init()
while running:
    event = pygame.event.poll()
    if event.type == pygame.QUIT:
        running=0
        screen.blit(wrench, (posX, posY))
    if(pygame.time.get_ticks() <= 20000):
            screen.fill(white)
            t = pygame.time.get_ticks() / 1000
            print(t)
            ang = math.degrees((math.pi / 2 * math.cos(math.pi * t)))
            posX = 100 + (50 * math.cos(math.pi * t)) - ox
            posY = 100 + (20 * math.sin(math.pi * t)) - oy
            wrench = pygame.transform.rotate(wrench, ang)
            screen.blit(wrench, (posX, posY))
    pygame.display.flip()

Does anybody knows why this is happening?


texts: How to force playing attack animation until the end?

texts:
I rework the code to make it more easier to manage. How can I force the player cannot change the sprite animation by pressing any keys until the attack animation completely ends?

class Player
{
    Animation playerIdle;
    Animation playerRun;
    Animation playerAtk;

    public void Load(ContentManager content)
    {
        playerIdle = new Animation(content, "idle", 144, 128, 8, 30);
        playerRun = new Animation(content, "run", 160, 112, 8, 30);
        playerAtk = new Animation(content, "atk", 154, 131, 2, 30);

        playerIdle.EnableRepeating();
        playerRun.EnableRepeating();
        playerAtk.EnableRepeating();
    }

    public void Update(GameTime gameTime)
    {
        playerIdle.Update(gameTime);
        UpdateControl(gameTime);
    }

    #region Update Control
    string selectSpriteSheet;

    KeyboardState mPreviousKeyboardState;
    SpriteEffects spriteEffects = SpriteEffects.FlipHorizontally;

    Vector2 feetPosition = new Vector2(0, 350);
    Vector2 mSpeed = Vector2.Zero;
    Vector2 mDirection = Vector2.Zero;
    Vector2 mStartingPosition = Vector2.Zero;

    int CHARACTER_SPEED = 50;
    int MOVE_LEFT = -5;
    int MOVE_RIGHT = 5;
    int MOVE_UP = -5;
    int MOVE_DOWN = 5;

    enum State
    {
        Running,
        Jumping,
        Attacking,
    }

    State mCurrentState = State.Running;

    public void UpdateControl(GameTime gameTime)
    {
        KeyboardState aCurrentKeyboardState = Keyboard.GetState();

        feetPosition += mDirection * mSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
        selectSpriteSheet = "idle";
        UpdateMovement(aCurrentKeyboardState, gameTime);
        //UpdateJump(aCurrentKeyboardState, gameTime);

        mPreviousKeyboardState = aCurrentKeyboardState;
    }

    private void UpdateMovement(KeyboardState aCurrentKeyboardState, GameTime gameTime)
    {
        if (mCurrentState == State.Running)
        {
            mSpeed = Vector2.Zero;
            mDirection = Vector2.Zero;

            if (aCurrentKeyboardState.IsKeyDown(Keys.Left) && !aCurrentKeyboardState.IsKeyDown(Keys.Right))
            {
                playerRun.Update(gameTime);

                selectSpriteSheet = "run";
                spriteEffects = SpriteEffects.None;
                mSpeed.X = CHARACTER_SPEED;
                mDirection.X = MOVE_LEFT;

            }
            else if (aCurrentKeyboardState.IsKeyDown(Keys.Right) && !aCurrentKeyboardState.IsKeyDown(Keys.Left))
            {
                playerRun.Update(gameTime);

                selectSpriteSheet = "run";
                spriteEffects = SpriteEffects.FlipHorizontally;
                mSpeed.X = CHARACTER_SPEED;
                mDirection.X = MOVE_RIGHT;
            }

            if (aCurrentKeyboardState.IsKeyDown(Keys.Z) && mPreviousKeyboardState.IsKeyUp(Keys.Z))
            {
                mCurrentState = State.Attacking;
            }
        }

        if (mCurrentState == State.Attacking)
        {
            playerAtk.Update(gameTime);

            selectSpriteSheet = "hit";
            mCurrentState = State.Running;
        }
    }
    #endregion

    public void Draw(SpriteBatch spriteBatch)
    {
        //playerIdle.Draw(spriteBatch, feetPosition, (float)MathHelper.ToRadians(0), 1.0f);
        if (selectSpriteSheet == "idle")
            playerIdle.Draw(spriteBatch, feetPosition, spriteEffects, (float)MathHelper.ToRadians(0),1.0f);
        else if (selectSpriteSheet == "run")
            playerRun.Draw(spriteBatch, feetPosition, spriteEffects, (float)MathHelper.ToRadians(0),1.0f);
        else if (selectSpriteSheet == "hit")
            playerAtk.Draw(spriteBatch, feetPosition, spriteEffects, (float)MathHelper.ToRadians(0), 1.0f);
    }
}


texts:
I accidently pressed some key combination which turned all the gameobjects in Unity engine gray and now I cannot restore them to the original form. Any suggestions?
Below is the link of what I am talking about: https://ibb.co/izAVRo


texts: Additive Scene Loading Buttons not Becoming 'Active'

texts:
I'm quite new to Unity but I'm making a game, and have created a simple Pause menu, when a key is pressed (escape), I just load a Pause scene, additively, and set that Pause scene to the active scene, however, only the buttons on the previous 'game' scene are interactive.
The mouseEnter, exit etc aren't triggering on the pause menu buttons, despite the pause menu being overlayed on top of the 'game' scene; the Pause scene being the active one and the 'game' scene buttons are still the interactive ones (i.e. register clicks, mouse overs etc).
Obviously when I open the pause menu, I want the pause menu buttons to be the interactive ones (registering clicks, mouse over etc), not the previous 'game' scene buttons.
The pause menu scene interacts perfectly when loaded additively with a scene that had no buttons.
Many thanks.


texts: Getting Rotation Values From A Rotation Matrix

texts:
I'm trying to get rotation values along the x, y and z axis from a matrix that can include rotation, translation and scale data. Currently I have this function to return the y rotational value:

float GetYRotDegree( void )
{
  return D3DXToDegree( asin( m_mMatrix._13 )  );
};

What I'm doing to test this is first rotating along the y by 90 degrees, then rotate it by 1 more degree, and this returns 89, not 91.

I understand that this is caused because of using asin, and I did find a Stack Overflow question that was 100% identical to mine, and was solved by doing this:

Degree(atan2(orientmatrix[0][2], orientmatrix[0][0]))

The problem with this is, it assumes that there's no other rotational, scale and translation in the matrix, however I do have other data in it.

Any help would be great, and I do appreciate any help given!


texts: Different number of lights => different shader

texts:
I have a shader that computes lighting for each light.

PointLight PointLights[10];

uniform const float NumPointLights;

for(int i = 0; i < NumPointLights; i++)
{
lightVec = PointLights[i].Position - pos;
lightDist = length(lightVec);
    // Do other stuff with light here, etc.
}

If I set NumPointLights to 2, the loop still iterates 10 times, and discards the result of the last 8 iterations.

Should I set a compiler flag that will permit the loop to actually loop only 8 times, or should I make 10 shaders, a shader for each number of lights that can be rendered?

On some small pieces of geometry I occaisionally need 10 lights. 90% of the time I only need 1-2 lights. How do I proceed?


texts: How can I compute a 3D picking ray from 2D screen coordinates?

texts:
I have a view matrix via glm. I want to make a ray casting system that receive an X and Y coordinate from the screen and generates a ray in the world. What math is needed?

My view matrix is built with this function:

glm::mat4 Camera::cameraViewMatrix()
{
    glm::mat4 matrix;

    matrix = glm::rotate(matrix, glm::radians(pitch),     {1, 0, 0});
    matrix = glm::rotate(matrix, glm::radians(yaw),       {0, 1, 0});
    matrix = glm::rotate(matrix, glm::radians(roll),      {0, 0, 1});

    matrix = glm::translate(matrix, glm::vec3(position.x, position.y + height, position.z)*-1.f);

    int width, height;
    SDL_GetWindowSize(display.GetWindow(), &width, &height);

    return glm::perspective(glm::radians(fov), (float)width/(float)height, 0.001f, 1000.f) * matrix;
}

I'd like to use this to select objects under the cursor.


texts: How do I generate solar systems for a 2d universe map, but still look random

texts:
I need to generate 64 systems separated into 16 sectors, each with 4 systems.  Each system must have another system within 10 units in it's own sector, but no closer than 3.  One system in a sector must have a non-sector system within 20 units, but no closer than 8.  When I made a formula that satisfies these requirements, I end up with a very visible grouping of 16 sectors in a box formation with very little variety.  Probably because I want it output into an array so I can track distances, etc.

I'd do a random generation, where it just places a system on a grid and then makes sure it doesn't conflict with a rule, and then find a way to group them, but it just seems beyond me right now.  I wouldn't be sure how to check for inability to place another system... I'm probably looking at the problem from the wrong angle.

Any help?

Each dot is a system, the grey background is just a box to make it temporarily easier to see.


texts: Appropriate level representation / data stucture for a 2D platfrom game?

texts:
I'm about to program a copy of Mario in Java. I'm thinking on 2 representations/data structures for the levels but I'm not sure which one should I choose:

A 2D integer array.
A quadtree to divide the level in pieces.

What are its advantages and disadvantages?


texts:
I'm making a game with simple movement code. I don't want the movement to be too complex since it's going to be a small game once it's done.

Right now the character moves 10 units at a time, then stops, then 10 units, then stops, and this looks jerky.

I'd like the character to move continuously, without stopping in between. I tried lowering the playerSpeed to make it less jerky, but then the character moved too slowly and players got bored. Instead I want the character to move a little every frame, not a big jump with delays in between.

Here's what I've tried so far:

playerSpeed = 10;

document.addEventListener('keydown', function(e){
 if(e.key === 'w' && playerY >= 5){
  playerY-= playerSpeed;
  ctx.clearRect(0, 0, outerWidth, outerHeight);
  drawProtagonistFacingUp();
}
 if(e.key == 'd' && playerX < outerWidth - 50){
  playerX+= playerSpeed;
  ctx.clearRect(0,0,outerWidth, outerHeight);
  drawProtagonistFacingRight();
}

if(e.key == 's' && playerY < outerHeight - 100){
 playerY+= playerSpeed;
 ctx.clearRect(0,0,outerWidth, outerHeight);
 drawProtagonistFacingDown();
}

if(e.key == 'a' && playerX > 5){
  playerX-= playerSpeed;
 ctx.clearRect(0, 0,outerWidth, outerHeight);
 drawProtagonistFacingLeft();
}
});


texts:
i've imported a door from blender to unity.  it has two animations, open and close.

i've put an animator and script on it, and everything works fine.  it opens and closes when i press x using a box collider, just peachy.

the problem is that the door starts out opened when I run the game.  I need it to start out closed.  i have it set to closed as the default state, thinking that would work, but what happens is w hen you start the game, it just closes immediately, and then you can open it and close it after that.  how would I go about setting it to closed when running the game?


texts:
For a client I might be making a small puzzle game about getting a item out of a puzzle. The concept will strongly resemble this game :

http://www.alibaba.com/product-gs/355972089/Car_Park_Game_Brain_Teaser_IQ.html

But will not be about cars or parking, and we will make our own "levels".

The game will not be a board game, but a smartphone game (iOS + Android devices).

But does ThinkFun sit on the concept so heavily that I can't make a game like this ? And where does "the line" go to what is acceptable?

The game will be free, and we are a non-US company (based in Denmark, Europe) if that makes any difference.


texts: Maze or puzzle algorithm for something similar to noodles

texts:
Not sure if anyone has played Noodles at all https://itunes.apple.com/gb/app/noodles!/id967624193?mt=8 but it is a simple puzzle game, that involves rotating tiles until they link up. The tiles are either 4-sided or 6-sided and each tile can have 1 of a set number of 'pipes' including end pipes. There's only one solution which you reach by joining all the pipes together to a special 'starter' pipe which can take the form of any of the other pipes. There's also no loops.

What type of algorithm would someone use for this? I thought it could perhaps be a maze algorithm, but I'm struggling to understand how you would go about this.I think it's because in essence there aren't any walls, just different styles of connectors. But is this in essence a perfect maze? Does anyone have an idea of a starting point for an algorithm to accomplish something similar?

I'm not specifically looking for code, but a help in the right direction to identify a relevant algorithm or how someone might go about this. Though I have tagged this 'ios' as that's what I would ultimately be targetting


texts: CustomEditor GUI button hides all public fields in inspector?

texts:
I am new to Unity. I have a simple game object with one script attached to it and then another script to add a button which will call the function within the script attached to the game object. My problem is I want to have two editable fields height and width but if the custom editor is added to the game object then those public fields no longer display in the inspector window...Not sure why?

WorldGenerator.cs:

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

public class WorldGenerator : MonoBehaviour {

public int height;
public int width;

public void RunWorldGeneration()
{
    Generate worldGenerator = new Generate();
    float[,] world = worldGenerator.GenerateWorld(width, height);

}
}

WorldGeneratorEditor.cs:

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

[CustomEditor(typeof(WorldGenerator))] // If I comment this out the public variablbes show
// If it is uncommented, then just the button with "Generate" text shows
public class MapGeneratorEditor : Editor
{

public override void OnInspectorGUI()
{
    WorldGenerator worldGen = (WorldGenerator)target;

    if (GUILayout.Button("Generate"))
    {
        worldGen.RunWorldGeneration();
    };
}
}


texts: Accuracy and frame-rate in a rhythm game

texts:
My question is related with Fixed time step vs Variable time step. But where a fixed frame-rate improve the consistency of a physics based game, is it the case for a rythm game, or wouldn't it be preferable to use a variable frame-rate ?

Say, I set the frame-rate to 100/sec, that will lead to an accuracy of 10ms, which is correct, but depending on the computer it will be possible to have a better accuracy. And if I set a too high frame-rate, some other computers may not follow, which may resolve in unsyncing the game and the music.

The first solution that came in my mind is to use a variable frame-rate. This way, the game will not be unsynchronized with the music, but the accuracy is too dependent of the computer.
Another, better, idea (I don't know if this is possible or not), would be to get the instant when has been pressed a key, and the accuracy will be no more dependent of the frame-rate. I'll make this game with LWJGL and I while reading the javadoc I found the method getEventNanoseconds(), and I was wondering how it is reliable since it's written "Only useful for relative comparisons with other Keyboard events, as the absolute time has no defined origin.".

What game loop method, do you think, is the most appropriate for a rythm game ? And for a rythm game with keysound ?
Did you made a rythm game, or some game that require a good accuracy and how did you manage the updating ?

Thanks for your help ! :)


texts:
I have a game developed in lua using love 2d, and now i want to run it in ios/android.

Is there any porting or way available to do that.

Thanks.


texts: Unity - Random Spawned Enemy Is Not Moving

texts:
I want to make an enemy spawner with random rotation left and right in unity. Its an 2d platformer. The random rotation is working, but the enemy is not moving after it's spawned.

I put the rigidbody of the enemy in the value enemiesrb in the script EnemySpawn and gave it an .velocity = new Vector.

I have 2 scripts

  EnemyPatrol:

public float moveSpeed;
public bool moveRight;

public Transform wallCheck;
public float wallCheckRadius;
public LayerMask whatIsWall;
private bool hitWall;

public float lockPos = 0;

// Use this for initialization
void Start () {

}

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

    hitWall = Physics2D.OverlapCircle(wallCheck.position, wallCheckRadius, whatIsWall);

    if (hitWall)
    {
        moveRight = !moveRight;
    }

    if (moveRight)
    {
        transform.localScale = new Vector3(-1f, 1f, 1f);
        //GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
    }
    else
    {
        transform.localScale = new Vector3(1f, 1f, 1f);
        //GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
    }

  and EnemySpawn

public GameObject enemies;
private Rigidbody2D enemiesrb;

public float spawnTime;
public int maxEnemies;
public int lofr;

private int amount;

public float moveSpeed;
void Start()
{
    enemiesrb = enemies.GetComponent<Rigidbody2D>();
}

void Update()
{
    //enemies = GameObject.FindGameObjectsWithTag("Enemy");
    //amount = enemies.Length;

    if (amount != maxEnemies)
        InvokeRepeating("spawnEnemy", spawnTime , spawnTime);

}

void spawnEnemy()
{
    lofr = Mathf.Abs(Random.Range(0, 1));

    if (lofr == 1)
    {
        Instantiate(enemies , transform.position, Quaternion.Euler(1,180,1));
        enemiesrb.velocity = new Vector2(moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
    }
    else if(lofr == 0)
    {
        Instantiate(enemies , transform.position, Quaternion.Euler(1,1,1));
        enemiesrb.velocity = new Vector2(-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
    }
    CancelInvoke();
}

the lofr means left or right. it defined if it need to spawn left or right


texts: How can I get fastest region server in Photon C++ Client API?

texts:
I am facing problem with my online multiplayer board game. It takes long time to create and join room. Also sometimes other player doesn't get the data. After searching all over the Photon C++ code I found this function :

void NetworkLogic::onAvailableRegions(const ExitGames::Common::JVector<ExitGames::Common::JString>& availableRegions, const ExitGames::Common::JVector<ExitGames::Common::JString>& availableRegionServers)
{
    EGLOG(ExitGames::Common::DebugLevel::INFO, L"%ls / %ls", availableRegions.toString().cstr(), availableRegionServers.toString().cstr());
    mpOutputListener->writeLine(L"onAvailableRegions: " + availableRegions.toString() + L" / " + availableRegionServers.toString());
    // select first region from list
    mpOutputListener->writeLine(L"selecting region: " + availableRegions[0]);
    mLoadBalancingClient.selectRegion(availableRegions[0]);
}

In the last line its just passing 0th region of the available regions. I think that region could be the slower one. Anyways, I am still facing the problem and I need help. Thanks.


texts: What’s the best way to create a homebrew game project for a vintage system, so it can also be distributed on other hardware?

texts:
For years, i’ve considered writing an NES, Game Boy or maybe even a SNES homebrew title.  I’m not expecting to make a knockout success but whatever I make, I’d like it to be easily distributable.

I’ve dabbled in the area of homebrew game dev before but I’ve never taken it to far because I’d also like to have the potential/option to release it as a stand alone app for PC/Mac/Linux and even to smart phones and possibly even distribute it through Steam.

I know that when you create multi-platform software, it’s generally a task of designing cross-compilable software that compiles down to bitcode for each target device.  That might be the case for a project like this but since my #1 goal is to essentially make a ROM that can be played on legit early console hardware, I’d assume there might be special tools out there that help you take game ROMs and then wraps them into specific “emulation” applications which can be served to these other platforms types of devices and run on various operating systems.

I’m curious if anyone has had experience creating an old console homebrew project and has also distributed their game for multiple platforms like I’d like to do.  What had worked and what hasn’t?  I’m not trying to ask to broad of a question.  I assumedly see two paths I could take— create a ROM title and wrap it in an emulator or setup a cross platform project that can also compile down to multiple platforms.  What’s the best way to start a project like this, and set it up correctly from the beginning, so I can worry as little as possible about cross-platform development, and focus on writing the game logic?


texts: Tiled based pathfinding in a 1- or 2-dimensional array

texts:
As far as I know all tile based map editors export a JSON object containing one dimensional arrays. While most pathfinding libraries/tutorials are only provided for two dimensional arrays.

Also if for example I would like to do pathfinding in this one dimensional array and this array is huge i'm geussing this would cause performance issues.

So why is it that most tile based map editors output a one dimensional and how should I handle those regarding pathfinding?

example tile editor:

http://elias-schuett.de/git/Online-Tile-Map-Editor/#

Just google pathfinding to find all the two dimensional patfhfinding tutorials


texts: Creating a collision shape for a complex model

texts:
I'm currently creating the collision system for my 3D XNA game.

To check collisions with models (especially complex ones) like trees or other plants, I thought about rendering a low poly version of this object and check if the player is in collision with that low-poly shape.

I succeeded in getting all the positions of all vertices in my models. If my model is a cube, I get the 8 vertices, but how can I check if the player is inside this shape?


texts: Will a polled event system cause lag for a server?

texts:
I'm using a library called ENet. It is a reliable UDP library.

The way it works is a polled event system like this:

  ENetEvent event;

    /* Wait up to 1000 milliseconds for an event. */
    while (enet_host_service (client, & event, 1000) > 0)
    {
        switch (event.type)
        {
        case ENET_EVENT_TYPE_CONNECT:
            printf ("A new client connected from %x:%u.\n",
                    event.peer -> address.host,
                    event.peer -> address.port);

            /* Store any relevant client information here. */
            event.peer -> data = "Client information";

            break;

        case ENET_EVENT_TYPE_RECEIVE:
            printf ("A packet of length %u containing %s was received from %s on channel %u.\n",
                    event.packet -> dataLength,
                    event.packet -> data,
                    event.peer -> data,
                    event.channelID);

            /* Clean up the packet now that we're done using it. */
            enet_packet_destroy (event.packet);

            break;

        case ENET_EVENT_TYPE_DISCONNECT:
            printf ("%s disconected.\n", event.peer -> data);

            /* Reset the peer's client information. */

            event.peer -> data = NULL;
        }
    }

It waits up to 1000 milliseconds for an event. If I'm hosting say 75 event driven card games and a lobby on the same thread as this code, will it cause any problems.

If my understanding is correct, the process will simply sleep until there is an event, when there is one, it will process the event then come back here where potentially 5 or so events have queued up since so enet_host_services would return right away and not cause lag.

I have been advised not to use multiple threads, will that be alright like this?

Thanks


texts: How do I test for intersection between a ray and a cone?

texts:
I decided that writing a ray-tracer in my game was a brilliant idea, and so now I am looking for code to use for ray to primitive intersection tests. I have based my effort on this very nimble yet complete code. It works well but only supports sphere primitives. I have added plane, disk and ring (in that order) because they are easy. Next I am thinking about adding box and cone.

But while sphere and plane intersection tests are really simple cone seems really difficult.

I have yet to find a simple and easy to adapt java implementation of a ray cone intersection test. I am in this to get a ray-tracer up and working quickly without learning too much math underway, so is does anyone have a java snippet lying around that performs a trivial ray cone intersection test suitable for a small ray-tracer?


texts: How do I use this Perlin Noise texture to change the mesh?

texts:
Using the Unity docs page on Perlin noise, I made this script:

// Width and height of the texture in pixels.
public int pixWidth;
public int pixHeight;

// The origin of the sampled area in the plane.
public float xOrg;
public float yOrg;

// The number of cycles of the basic noise pattern that are repeated
// over the width and height of the texture.
public float scale = 1.0F;

private Texture2D noiseTex;
private Color[] pix;
private Renderer rend;

void Start()
{
    rend = GetComponent<Renderer>();
    scale = Random.Range(15, 20);
    xOrg = Random.Range(0, 20);
    yOrg = Random.Range(0, 20);
    // Set up the texture and a Color array to hold pixels during processing.
    noiseTex = new Texture2D(pixWidth, pixHeight);
    pix = new Color[noiseTex.width * noiseTex.height];
    rend.material.mainTexture = noiseTex;
}

void CalcNoise()
{
    // For each pixel in the texture...
    float y = 0.0F;

    while (y < noiseTex.height)
    {
        float x = 0.0F;
        while (x < noiseTex.width)
        {
            float xCoord = xOrg + x / noiseTex.width * scale;
            float yCoord = yOrg + y / noiseTex.height * scale;
            float sample = Mathf.PerlinNoise(xCoord, yCoord);
            pix[(int)y * noiseTex.width + (int)x] = new Color(sample, sample, sample);
            x++;
        }
        y++;
    }

    // Copy the pixel data to the texture and load it into the GPU.
    noiseTex.SetPixels(pix);
    noiseTex.Apply();
}

void Update()
{
    CalcNoise();
}

The only difference between this code and the Unity docs example is that I added some randomness to the size and origin points of the texture.

I attached the script to a plane, and now when I run the game, the plane has a random noise texture on it.

Now I want the texture to give height to the mesh, so it will look like a terrain.
How do I do this?


texts: How should I efficiently clear and redraw my canvas with lots of animated sprites?

texts:
My current solution is to clear the entire canvas and redraw all sprites on every requestFrame().  This works but feels inefficient:

I only need to clear the part of the canvas made invalid by animations.
I only need to redraw objects that intersect the invalid part of the canvas.

I can track invalidated sections, and during requestFrame() I can find out which objects intersect an invalid section and redraw only them, but I'm not sure if that's an improvement or a step back.  If I have 100 sprites and 10 of them are moving, that means I need to do 10 searches through all 100 sprites.  Tall order for every request frame.

I can also put every sprite on its own canvas and remove sprite interaction from the equation, but I haven't been able to find insight into how many canvases is too many.

This seems like a problem that's been solved already, but I haven't found any resources on the topic.


texts: How do I implement 3D A* Pathfinding in libgdx?

texts: I am using BDX (Blender with libgdx engine) to create my game. I am not sure on how to implement 3D path finding using A* search. I looked into gdx-ai, but that is for 2D.


texts: How can I rotate a quad around it's center?

texts:
My code is:

GL11.glPushMatrix();

// rotate around center
GL11.glTranslatef(-200/2, -200/2, 0);
GL11.glRotatef(30, 0.0f, 0.0f, 1);
GL11.glTranslatef(200/2, 200/2, 0);
// draw quad
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0f,0.5f);
GL11.glVertex3f(50,50,1);
GL11.glTexCoord2f(0.5f,0.5f);
GL11.glVertex3f(50+200,50,1);
GL11.glTexCoord2f(0.5f,0f);
GL11.glVertex3f(50+200,50+200,1);
GL11.glTexCoord2f(0f,0f);
GL11.glVertex3f(50,50+200,1);
GL11.glEnd();

GL11.glPopMatrix();

and it's not rotating it around the center, am I doing this correctly? if not how would I?


texts: What will AMD Fusion or likewise hybrid CPU/GPU will change for the 3D programmer ? Are they potentially faster?

texts:
Since the early days of accelerated graphics, programmers were obligated to use hardware-supported libraries like directX or OpenGL.

If we wanted to explain someone what happened by introducing a graphic chip, the simple thing to say is "we just copy the 3D data into a new memory, where another processor will take care of it, because this one processor is just faster at it".

During this period, the processors have never ceased to evolve in term of speed and power.
Today with the upcoming of multiple core processors, x86 is still there, graphic card get more power, and are now taking the role of a CPU with tools like OpenCL and CUDA.

Back in the year, the AGP port speed was quite important, and PCI-express gave another big boost.

I didn't heard a lot about AMD Fusion, but the idea might have come into the mind of any computer engineer:
Since the heavy calculations made in a computer are either graphical or not, we separate them into 2 dedicated chips.

But nowadays, any computer power is needed for both, especially in 3D games: to put it simply, at the beginning computer were just dealing with text, but today they all deal with at least 2d graphics, so why not design one chip that would take the role of both a CPU and a GPU ? Instead of having two memory block and having to copy all the textures and models into the graphic memory when a game loads, the "CGPU" would have some GDDR3, instead of having two separate memories, again cutting costs.

I still wonder how this AMD fusion will have to be used from a programmer viewpoint, but I wonder that the graphic library would be somewhat easier to deal with that directX or OpenGL, since we would program just one processor.

Is it right to think that this kind of dedicated hardware would also potentially just be faster for 3D games ?

Pro:
Single memory, no more AGP transfers, simple for the 3D programmer, cheaper to build.
Cons:
Complicated to come with such hardware, long and expensive research because of both new hardware AND software standards.

What are you thinking ? Is it a new incoming step for computers, or just scifi ?

EDIT: Since I got an appropriate answerm I leave the question as I wrote it, I just add something to it:

Since all computers, and especially consoles, require graphics acceleration, and since it requires a lot of transistor, and with the upcoming of tools like CUDA and OpenCL, why no industrial has yet come with a "gaming chip", some sort of processor with an integrated graphic card, but nothing like a low-end chip; something more like an all-in-one processor unit, with the GPU and the CPU on the same die, but still clearly separated ?

Since the playstation 3 has dedicated chips and since games requires that extra power desktops or servers don't, can it reduce costs and give a little boost ?


texts:
For Ogre experienced people, but also experts in the field:
Early Z culling is sometimes quite desirable, and that's what I tried to do in Ogre by using a two pass material. The first one is writing to the Z Buffer, but not to the frame buffer. This is how it looks like:

 pass EarlyZ
    {
        texture_unit TU0
        {
            //ambient diffuse texture
            texture $TU0_TEXTURE
            tex_coord_set 0
            filtering trilinear
        }
        //cull_software none
        //cull_hardware none
        lighting off
        colour_write off
        shading flat
        //scene_blend alpha_blend
        alpha_rejection  greater_equal 200
        depth_bias  -5 -5 // ugly hack - without it, objects tend to flicker
    }

The biggest problem I get is with alpha objects and shadows. For example, now I can't get  tree impostors to cast correct shadows instead of blocks. Although they are rendered correctly, the PSSM isn't working correctly, so the shadows tend to look like stencil shadows. Any ideas on how to fix it? As many people said: is it possible to perform early Z culling and still have transparent objects in the scene? If yes, some hints to do it in Ogre? Here are some screenshots:


texts: Count the number of on-screen pixels occupied by an object

texts: I need to find the number of pixels an object occupies on screen. How do I do that using DirectX?


texts: With Google Admob, how do I handle two different rewards for a rewarded ad?

texts:
I'm implementing reward based video ads in my game using Google Admob. There are two functions that provide the reward. One is a ReceiveLife() function where once the player dies, if they click on the revive button the game restarts and the score is set to score before the player dies instead of 0. The other function is ReceivePoints(), where if the player clicks on the add points button, they are rewarded with 100 extra points. I looked at the documentation provided in google admob regarding loading multiple rewarded ads, but I'm unsure of how to go about calling these two functions in the "HandleRewardedAdClosed" function. Here is the code that works for only function (ReceiveLife()):
public class AdScript : MonoBehaviour
{
    string Video_Ad_Id = "ca-app-pub-3940256099942544/5224354917";
    private RewardedAd rewardedAd;

    void Start()
    {
        MobileAds.Initialize(initStatus => { });
        RequestRewardBasedVideo();
    }

    public void RequestRewardBasedVideo()
    {
        this.rewardedAd = new RewardedAd(Video_Ad_Id);
        this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
        this.rewardedAd.OnAdClosed += HandleRewardedAdClosed;
        // Other event hooks...
        AdRequest request = new AdRequest.Builder().Build();
        this.rewardedAd.LoadAd(request);
    }

    public void ShowVideoRewardAd()
    {
        if (this.rewardedAd.IsLoaded())
            this.rewardedAd.Show();
    }

    public void HandleRewardedAdClosed(object sender, EventArgs args)
    {
        this.RequestRewardBasedVideo();
    }

    public void HandleUserEarnedReward(object sender, Reward args)
    {
        GameManager.instance.ReceiveLife();
    }
}

How do I call two rewarded functions in the HandleUserEarnedReward() function above. Can someone please help?


texts:
I struggle to find coordinates of point B in the picture below. I know the positions of A and C, the length of arm c and angle beta

I need it to make a gun next to the player point to the direction of a cursor. And the gun will rotate with the player. I think there must be a simple way to do it, but I'm missing it somehow. Could you point me to the right direction?


texts: Correctly map a Mount&Blade style aiming rectangle to the projectiles flying direction?

texts:
So I implemented a game mechanic where drawing a bow will display a shrinking rectangle that should represent the shooting accuracy. The rectangle is smallest after about 1.5 seconds of drawing the bow.

Now the question is, how do i correctly map the size of the rectangle to the projectiles flying direction?

My first though is to give the projectile a random angle deviation and the aiming rectangle is the max angle deviation, but I guess I somehow have to take the FoV angle into consideration somehow? Furthermore, is the FoV Angle uniformly distributed across a 2D screen or is the change of angle greater at the edges of the screen?

With a uniform distribution I guess it comes down to a very simple calulation.

FoV = 70°
Max Yaw and Pitch deviation at 1.5 seconds = 10°
Screen resolution: 1920x1680

Size of aiming rectangle:

width: 10/70 * 1920 ~= 274 pixels
height: 1680/1920 * 274 ~= 239pixels

Is that correct?

For clarity here is a screenshot of that aiming rectangle that shrinks over time: https://www.vintagestory.at/uploads/monthly_2017_07/2017-07-22_22-48-10.png.86e757f209fde73b769726e7c12aaeb1.png


texts: Unity 2D Tap to shoot at mouse position on android device

texts:
Hello everyone i am really stuck at the moment and would appreciate any help if possible. I have my game where i move the player up and down with 2 buttons on the bottom left of screenshot.

I also have a button over the entire screen for tap to shoot and this moves the weapon to my finger position where i have tapped and it shoots towards that position using mouse.position.

Now the problem is when i am on my android device and i am moving up and down but when i also tap to shoot the gun it moves towards my up and down buttons and this is not what i want.

i want to be able to move with my finger and also shoot towards the second finger.

Any ideas would be greatly appreciated.

Here is my Tap to shoot button code!

public void ShootButton()
{
 timer = 0;
 Face = true;
 //if finger presses Shootbutton
 //then activate this

 Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) -
 transform.position;
 // subtracting the position of the player from the mouse position.
 difference.Normalize(); //normalizing the vector meaning all the sum of the
 vector will be = to 1.

 float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;//find
 the angle in degree.

 WeaponTrans.transform.rotation = Quaternion.Euler(0f, 0f, rotZ +
 rotationOffset);
 if (reloading == false)
 {
     if (fireRate == 0)
     {
         {
             Shoot();
         }
     }
     else
     {
         if (Time.time > timeToFire)
         {
             timeToFire = Time.time + 1 / fireRate;
             Shoot();
         }
     }
 }
}


texts: Using GraphicsDevice.Viewport.Project with a small farPlaneDistance

texts:
I am using "GraphicsDevice.Viewport.Project()" to create a "3D" waypoint system like so;

I have a farPlaneDistance of 5000 in my camera;

objProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), flAspectRatio, 1.0f, 5000.0f);

Obviously when the waypoint is farther than 5000, it cant find it within the viewport and bugs out. Is there another way to display waypoints on screen (within a 3D world) without using GraphicsDevice.Viewport.Project()?

Or, is increasing my z buffer out to 100,000 not that big of an issue (i find this hard to believe)?

Learning as I go,
Thanks in advance!

Linuxx


texts: Can Unity 2D be used to make pixel-art games?

texts:
I'm looking at the new 2D features introduced in Unity 4.3, and I think I might be missing something.

To me it looks like they are designed for high-res 2D games, where scaling the sprites is ok, but it is unsuitable for pixel-art games.

A pixel-art sprite is designed to be displayed exactly 1:1 pixels on the screen: scaling destroys it (linear up-scaling is an exception, i.e. you may scale it 2x, 3x, 4x etc.).

However I've found no way to "just display it as-is", apparently Unity insists in scaling it to whatever resolution it sees fit: I may control the Camera.size parameter, and the "pixels to units" parameter of the sprite, but I didn't manage to obtain this result.


texts: Drawing different per-pixel data on the screen

texts:
I want to draw different per-pixel data on the screen, where each pixel has a specific value according to my needs. An example may be a random noise pattern where each pixel is randomly generated.

I'm not sure what is the correct and fastest way to do this. Locking a texture/surface and manipulating the raw pixel data? How is this done in modern graphics programming?

I'm currently trying to do this in Pygame but realized I will face the same problem if I go for C/SDL or OpenGL/DirectX.


texts: Getting error when following learnopengl.com "Hello Window" Tutorial; how can I fix them?

texts:
I am not sure what to do, I have added the include / lib files in the IDE include / lib folders. But I am getting these errors. Someone please help me! What am I doing wrong? Do I need to add some more code or what?
Errors

Error C1189   #error:  OpenGL header already included, remove this include, glad already
provides it OpenGLSetup
c:\program files (x86)\microsoft visual studio 14.0\vc\include\glad.h 26

Error (active)        #error directive: OpenGL header already included, remove
this include, glad already provides it    OpenGLSetup
c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\glad.h 26

======
Here is a link to the project on gitub: https://github.com/Kraycon/OpenGLSetup


texts: Algo for given an amount of XP, find a character's level

texts:
In a RPG context, what are the ways to quickly find a character's level, given his XP? There are two cases which I am looking at:

For when a formula is defined, like in the case of D&D, which is N = N*(N-1)*500, where N is the desired level.
When no formula is defined, each level has an amount of XP require which is defined by a table.

I guess the easiest way is to do a for loop and subtracting the XP required for that level from the character's XP pool, till he reaches a point where you can't attain the next level. What other ways are there to, given a character's XP, to find his level?

Edit: The language is PHP


texts:
Here's what I have in our little Unity game:

If an asset (mostly a prefab or a texture) has to be accessed (e.g. to instantiate a game object), it is often passed as [SerializeField] to the script component. Scripts that are not components get their assets through the constructor so the assets are passed down until the class where they are needed. It's ugly.
If a lot of assets are needed (like textures of an animation), they are moved into a folder called "Resources" and accessed through the Resources class. The documentation explicitly says "don't use it".

What I want:

To access assets through a name or path to create objects at run-time.

What I found:

The AssetDataBase class looked promising until I couldn't locate it and found out it is deprecated (and the documentation does not tell how to replace it).
Nothing on Google but a lot of outdated things
Asset bundles look promising too, but they are quite complicated and there are no really good migration tutorials and I don't know how to use them.

Any suggestions? How do small/mid sized/bigger Unity games handle their resources?


texts: how to make the capsule move during anims

texts: I'm trying to make a cartwheel/ dodge to the side in ue4 but when the animation plays it moves out of the capsule and slides back. Is there a way to make the capsule move with the character in the animation.


texts: How can I make simple launcher for FiveM server?

texts: I would like to know how to create simple launcher for FiveM server. I don't need help about UI, design, etc. only script when someone clicks 'Play' it connects him to server. Thank you very much!


texts:
I began learning OpenGL recently and am having problems visualizing what matrices are and their role in computer graphics. Given the template of a 4x4 matrix like this:

I would assume that each matrix like this are the coordinates of a vertex in world space. And several of them put together and shaded give an object?

But why is there a Xx, a Xy and an Xz? I read that its a different axis (up, left, forward) but still can't make heads or tails of the significance.


texts: C# and Unity - Learning to Develop a game by developing the game I want to develop

texts:
So I am pretty new to C#, I have some python and javascript experience, but nothing substantial.

I have read a lot about C# and Unity and I know they are the tools I want to use.

My question is: Should I be reading books about C# or should I just start hacking in unity and piecing the game together part by part?

Right now I am going through the book, HeadFirst C#, and it is very good, but I taught myself web design and javascript by just creating and hacking until I got the results I wanted then looked at other code to see ways they did it and improved my code.

The issue is that with the browser I got immediate results and it was all under one roof, where developing games is a completely different monster. I am just wondering if my time would be better spent buying a book that uses C# to teach you unity, and doing that instead, or if the time spent in HeadFirst book is going to be valuable.

Thanks a ton, I am having difficulties using my time, and I just want to maximize it as I don't have a lot of free time.

Edit: Hopefully this isn't to broad? If it is, I will delete and go elsewhere just let me know. Thanks.