texts: What is the correct way to use GameObject.Find in Unity?

texts:
I have been following along with a Lynda.com video course to familiarize with Unity. I am currently attempting to grab a reference to a scene's First Person Controller's transform as follows:

Transform targetObject;

// Use this for initialization
void Start ()
{
    targetObject = gameObject.Find("First Person Controller").transform;
}

And this is within a script/class that inherits from MonoBehaviour. However, this gives the error:

 Static member `UnityEngine.GameObject.Find(string)' cannot be accessed with an instance reference, qualify it with a type name instead

I am sure there is a way to just change the logic and get the desired affect with a different approach.  But I do not understand why this results in an error. It is the same code used by the instructor of the course, and from the Unity Script Reference, I can see that MonoBehaviour inherits a gameObject member which has the Find() method.  So this error is saying there is only one GameObject instance for all MonoBehaviour classes right? But shouldn't I still be able to call it's methods?

I am using Unity 4.1 with C# while the instructor is using 3.5 (with JS) if that helps any.


texts: I've been thinking about how Zelda: Majora's Mask manages all its character events during the day and thinking about the best way to implement this. Initially I thought of each character entity polling the timer, or the timer sending out events to subscribers of it, but both of these seem wasteful. What are some approaches to solving this?


texts:
Shadow mapping uses the depth buffer to calculate where shadows should be drawn.

My problem is that I'd like some semi transparent textured quads to cast shadows - for example billboarded trees. As the depth value will be set across all of the quad and not just the visible parts it will cast a quad shadow, which is not what I want.

How can I make my transparent quads cast correct shadows using shadow mapping?


texts: Can the different computation power in a multi-player game affect each player's performance?

texts:
In case an RTS game allows the clients to perform some calculations such as path-finding after the player clicks the map for a destination, and taking into account the game should be synchronised for all clients, there is clearly a chance that one of the machines is so slow that such computation (if it is done on a different process) might take much longer than in another client.

Therefore, the first player would experience a processing delay of his commands (and his units would be stopped for some time), giving the second player a clear advantage.

Now, how is this usually managed in the commercial RTSs?

Are all computations handled by the server and sent back to the clients?
In case processing in the client would be preferred, how would you implement a system to avoid such a player advantage?

Note: In SC2 I have seen how the server notifies the players that someone is slowing down the match. But I guess that is just the client has not enough speed to compute the visualisation.


texts: Graphics module: Am I going the right way?

texts:
I'm trying to write the graphics module of my engine. That is, this part of the code only provides an interface through which to load images, fonts, etc and draw them on the screen. It is also a wrapper for the library I'm using (SDL in this case).

Here are the interfaces for my Image, Font and GraphicsRenderer classes. Please tell me if I'm going the right way.

Image

class Image
{
  public:
    Image();
    Image(const Image& other);
    Image(const char* file);
    ~Image();

    bool load(const char* file);
    void free();
    bool isLoaded() const;

    Image& operator=(const Image& other);

  private:
    friend class GraphicsRenderer;
    void* data_;
};

Font

class Font
{
  public:
    Font();
    Font(const Font& other);
    Font(const char* file, int ptsize);
    ~Font();

    void load(const char* file, int ptsize);
    void free();
    bool isLoaded() const;

    Font& operator=(const Font& other);

  private:
    friend class GraphicsRenderer;
    void* data_;
};

GrapphicsRenderer

class GraphicsRenderer
{
  public:
    static GraphicsRenderer* Instance();

    void blitImage(const Image& img, int x, int y);
    void blitText(const char* string, const Font& font, int x, int y);
    void render();

  protected:
    GraphicsRenderer();
    GraphicsRenderer(const GraphicsRenderer& other);
    GraphicsRenderer& operator=(const GraphicsRenderer& other);
    ~GraphicsRenderer();

  private:
    void* screen_;

    bool initialize();
    void finalize();
};

Edit: Some changes to the code and more details.

Per some of the discussions here I decided to replace my use of void* with something like this:

class Image
{
  private:
    struct ImageData;
    std::shared_ptr<ImageData> data_;
};

(Obviously I'll do the same thing for the Font class.)

I should also mention hat these are not my final, complete classes. I only show here the basic functionality (loading and rendering). Instead of telling me what functionality you think I might need to add (rotating images, skewing, scaling, etc) just concentrate on reviewing what I already have. I'll try to defend my choices it I can, or change my approach if I cannot.


texts:
I have a problem with rotation of my hero in 2D space.  The hero is made of body parts such as: head, arms etc.  Every part is a separate sprite. When I want to rotate the hero, I have to rotate all of its parts.
I know the hero position, and I save the parts positions as:
head = (heroPosition.x+20, heroPosition.y+20)

In other words I know the positions of all parts while the hero was not rotated.  After rotation I know only the hero position and the rotation angle(Grades).
How can I calculate the new position for each part?


texts: In Unity 2019.3.0a2 I have a labyrinth with multiple rooms. I want the music to change when I get from one room into another. How can I do it so that music from room 1 is only hearable in room 1, and so on..?


texts: Scaling and new coordinates based off screen resolution

texts:
I'm trying to deal with different resolutions on Android devices.

Say I have a sprite at X,Y and dimensions W,H.

I understand how to properly scale the width and heigh dimensions depending on the screen size, but I am not sure how to properly reposition this sprite so that it exists in the same area that it should.

If I simply resize the width and heigh and keep X,Y at the same coordinates, things don't scale well.

How do I properly reposition? Multiply the coordinates by the scale as well?


texts: When and where and how to turn on back the Player first person when loading a scene on button click ?

texts:
In the Build Settings I have two scenes at index 0 and index 1:

Then in the Hierarchy I have the two scenes:
The active scene is the MainMenu:

In the StartGameButton I added to it a script component.
In the script:

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

public class LoadSceneOnClick : MonoBehaviour
{
  public void LoadByIndex(int sceneIndex)
    {
        SceneManager.LoadScene(sceneIndex);
    }
}

And this is the StartGameButton Inspector:

I dragged the script on the OnClick
I selected the function LoadSceneOnClick
And set the index to 1

When the game start and I click on the button it stay on the Main Menu scene and not loading anything.

The problem I guess is that I'm getting error in the game No cameras rendering:

The problem is that when I'm running the game and it start from the main menu scene in the space station scene I'm enable false the Player and the Player is a first person character with a camera:

You can see in the Inspector that the Player is unchecked the Player is not enabled. If I will enable the Player and even if the main menu scene is the active one it will show me the player and the player camera and not the main menu. So I had to turn off the Player.

The question now is where by script do I enable back the Player when it's loading the scene ?

Inside the LoadSceneOnClick script ?


texts: Why does the X Y Z translations now rotate along with my static meshes?

texts:
So I was making a map for UT3, using the Unreal 3 Editor provided, and all was going well.

However I was doing some work with InterpActors and Vehicle Spawners, when I must have hit a key by mistake (or other wise somehow changed something) by mistake.

Now the X Y Z translations that are used to move objects around in the editor will rotate along with the object (Ive put images down below to help show what I mean)

This is very annoying because it also changes the direction the arrow keys move a rotated object, in the example below, the Down arrow key will now move the object to the right.

How can I fix this?

(Note both images are taken from the same viewpoint)

Before Rotation:

After Rotation:

P.S. If someone could please provide me with the correct / better name for the X Y Z "things" it would be much appreciated, thanks!


texts: Circle-line segment collision resolution

texts:
I'm trying to make a side-scrolling game using this method and I'm having some trouble getting it to behave right. The collision shapes consist of multiple connected line segments and I'm checking them one at a time in order from first to last, so in one direction the collisions are resolved in the wrong order and the circle can't move over the connection point.

Is there a way of fixing this that isn't a hack, or should I try preventing the collision from happening in the first place instead?

ETA: The circle is moved straight up if the overlapping line segment is below and not too steep (approx. 50 degrees maximum) to enable it to move on slopes without resistance. In all other cases, the minimum displacement vector is used to resolve the collision.


texts: Simple speed deceleration with variable time step?

texts:
When you use a fixed time step you can call speed=speed*0.95 to emulate speed deceleration in a simple way.

I want to do the same thing with variable time step.

I wish to have a simple function speed=f(speed,dt); where dt is the time step since last frame.


texts: I noticed that the Flappy Bird .apk is only around 900 KB. I'd like to know how I can achieve a similar optimization in .apk file size for my own games, which use Unity. A small single-scene game developed with Unity will have an .apk size of nearly 10 MB, in comparison.


texts: Working with multiple language text files in multilingual games

texts:
What kind of tools and practices are used for maintaining text for multilingual games? By "text" I mean literally any piece of text you see in the game: dialog, menu options, tutorials, etc.

I want to keep it as modular as possible and make it very easy to add new language options by simply providing a new set of files.

Are there publicly available tools that I can use to maintain these text files and, preferably, pass it to others that can perform the translation process and allow them to put together all of the input data without me having to hardcode anything into the game?


texts: glGenArrays - This functionality is not available

texts:
Whenever I call glGenVertexArrays(), I get the following exception:

  Exception in thread "main" java.lang.IllegalStateException: This functionality is not available.
      at org.lwjgl.system.Checks.checkFunctionality(Checks.java:36)
      at org.lwjgl.opengl.GL30.getInstance(GL30.java:651)
      at org.lwjgl.opengl.GL30.nglGenVertexArrays(GL30.java:3101)
      at org.lwjgl.opengl.GL30.glGenVertexArrays(GL30.java:3128)
      at me.package.name.ClassName.methodName(ClassName.java:ANY_LINE_NUMBER)

The operating system is OS X Yosemite 10.10.2, Java 7. I think that this problem is OS X specific.

Immediate mode drawing does work.

I am using LWJGL 3.


texts:
What resources are available, including both free articles/ebooks and physical books and things, for game developers looking to begin simple AI programming/design?

Note: I know of this question, but that's more asking about where to start on a specific topic; I'm more asking about resources in general.


texts: Some GAME MAKER function for windows close button?

texts:
In my game there are variables that go through all rooms, so if the player leaves the "variable x" worth 10, and goes to another room, when he returns there is the "variable x" worth 10, same thing when he close the game by the button (exit) that I created in the main menu.

It turns out that if for some reason he closes the game by the "close button of windows", this variable is not saved.

This is clear because there is no command for it to happen, it happens that I did not find anything related to the "physical button close windows window" in the game maker.

Detail that my game is not full screen, but if there is no way to create an event in the game maker so that the "variable x" is saved before closing, tell me how do I delete the "physical buttons of the windows window ".

I'm sorry for the awful translation, I'm not an English speaker.


texts:
I want to show a leaderboard of facebook friends scores in a game.
So I need access to the user_friends permission.
In order to get that permission I have to send a working build using that permission to facebook that they can review.
So I need to keep my app on facebook in development mode, and test it with test users so I can build this feature and get it working.
However when I build the game and try and login to facebook I get this...

It did not give me a chance to login as a test user or anyone else. I didnt log in at all, it just went straight to this screen when I requested login.
Now the solution for this error that I have found many instances of, is to set your app 'live'. But that wont work in my case.. I need the app the be in development mode so I can test this feature.. If the app is live no-one will have access to the user_friends permission including test users.

So this seems like a paradox.
What can I do?


texts: Are loading screens more important than they appear to be?

texts:
I am creating a game in Unity that is really low poly and uses few resources on mobile. It runs quite fast on old, low end phones so the new, high end phones have no problems running it. There are no load times between scenes which makes the game load each scene instantly, yet this gives a sense of simplicity and that the game is really cheap.

So here is my question: would the implementation of a "fake" loading screen give the player the feeling that the game is complex and create that transition between scenes? Or should I stick with the fact that everyone hates loading screens and therefore should leave the game as it is? What other options could I use to convey the feeling to the user of complexity despite the low graphics?


texts: How can I simulate the effects of network latency to test my lag compensation?

texts:
I am trying to observe the effects of lag compensation in my game by increasing my ping to 200+, adding loss, and by the limiting bandwidth to simulate wide area network delays using Network Emulator for Windows Toolkit.

It seems no matter the degree of latency that is applied I never see any visual changes to my character position on the server, as the lag compensation / interpolation method is always able to predict my exact position.

But in real-world situations, players connected from a far distance away do have poor synchronization. How can I produce the same poor synchronization that I witness in players connected from a far distance so that I can choose the ideal lag compensation technique for my game.

For reference, I'm making this game using Unity 3D and it's a fast-paced, twitch shooter game.


texts:
In a GLSL fragment shader I am trying to cast a float into an int. The compiler raises an error:

ERROR: 0:60: '=' :  cannot convert from 'mediump float' to 'highp int'

I tried raising the precision of the int:

mediump float indexf = floor(2.0 * mixer);
highp int index = indexf;

but to no avail.

How do I cast the int properly?


texts:
I got the new android studio, and I noticed one thing when creating a new activity.

The layout that corresponds with the java for the activity is made twice, once as a content:

This new layout is an exact replica of the regular activity_menu.xml except this one is called content_menu.xml. I also noticed this piece of code in the layout code of activity_menu.xml:

    <include layout="@layout/content_menu" />

What is the point of this extra layout? Can I delete it? I found this on the official documentation, but I still don't understand why it is necessary. This wasn't there in the first update...

Thanks,

Ruchir


texts: Does the order in which RPCs are called match the order they are invoked locally?

texts:
For example:

void A()
{
    Debug.Log( "A was called." );
}
void B()
{
    Debug.Log( "B was called." );
}
void C()
{
    NetworkView view = GetComponent<NetworkView>();
    if( view != null )
    {
        view.RPC( "A", specificNetworkPlayer );
        view.RPC( "B", specificNetworkPlayer );
    }
}

Is A guaranteed  to be called before B on the "specificNetworkPlayer"'s machine? If not, what is the order, if any?


texts: How to convert Unreal Engine 4 spline to a bezier curve?

texts:
I have read the source code of USplineComponent and found that for a curve in Unreal, the result is calculated via FMath::CubicInterp:

/**
 * Performs a cubic interpolation
 *
 * @param  P - end points
 * @param  T - tangent directions at end points
 * @param  Alpha - distance along spline
 *
 * @return  Interpolated value
 */
template< class T, class U >
static FORCEINLINE_DEBUGGABLE T CubicInterp( const T& P0, const T& T0, const T& P1, const T& T1, const U& A )
{
    const float A2 = A  * A;
    const float A3 = A2 * A;

    return (T)
           (((2*A3)-(3*A2)+1) * P0)
         + ((A3-(2*A2)+A) * T0)
         + ((A3-A2) * T1)
         + (((-2*A3)+(3*A2)) * P1);
}

You can follow the logic in USplineComponent::Draw to be convinced.

And the calculation approach above is the same as the cubic hermite spline:

$$
\boldsymbol{p}(t) = (2t^3-3t^2+1)\boldsymbol{p}_0 + (t^3-2t^2+t)\boldsymbol{m}_0 + (-2t^3+3t^2)\boldsymbol{p}_1 +(t^3-t^2)\boldsymbol{m}_1
$$

Then the problem becomes how to convert a cubic hermite spline to a bezier curve.

I have tried several conversion methods on SO:

https://stackoverflow.com/a/1099357/3427520
https://stackoverflow.com/a/42587252/3427520
https://stackoverflow.com/a/42590480/3427520

But all failed to get a correct bezier curve as USD that can be correctly rendered by Houdini.

But what I have been worrying most is that USplineComponet is not a cubic hermite spline. I'm not sure since I knew few about curve math, even after reading some introduction of curve wiki, PDFs and articles.

The bezier curve data to USD bezier-basis curve procedure may also fail, I don't have a solution to verify converted bezier curve is correct (can generate the same shape in UE4) or not.


texts: Initial setting of camera and ppu to match playing table

texts:
My goal is to implement another board game as close as possible as I would play it on a table - to not much think about how to arrange elements. The used space on table is in the dimensions of around 1x2m and most of my assets are scans of game cards with a touch of Photoshop (for personal use only). My question is regarding the camera, pixel on import of asset and converting to units. There are no physics in the game involved and it is 2D. For now it will be tailored to my own mobile but I would like to know if one way is preferred if I wanted to later change resolution or is just better best practice. From my understanding it would result both in the same outcomes but there might be some hidden trouble or side effects.

Should I (convert for myself to get a feel for dimensions) take 1 unit as 10cm -> scene of 10x20 units would represent my table or rather have a 1x2 unit scene (since most take one unit as one meter)
Assuming my scanned card has something like 2000x1000 pixel (and is 10x5cm big on a real table), does it make more sense to have it imported as 2000/20000 under pixel per unit or downscale the image first before importing it with a lesser value? I don't really care currently about build/ asset size.


texts: fade/transparence for object by shader graph?

texts: I'm trying to make a simple fade/transparence for my object using shader graph. I got a result with dither but I don't like it. I want something smooth without dots. How to get it?


texts:
I've been having trouble with getting scene2d to erase my old texture when I switch screens, and also when I change my label the old label string is still drawn underneath.

public StartScreen(MainGame game){
    this.mainGame = game;

    viewport = new FitViewport(640, 360, new OrthographicCamera());
    stage = new Stage(viewport, game.batch);

    Texture button = new Texture("playButton.png");
    Button.ButtonStyle bs = new Button.ButtonStyle();
    bs.up = new TextureRegionDrawable(new TextureRegion(button));
    startGameButton = new Button(bs);

    Table table = new Table();
    table.top();
    table.setFillParent(true);

    table.add(startGameButton).expandX().padTop(10);

    stage.addActor(table);

    startGameButton.addListener(new ClickListener(){
        @Override
        public void clicked(InputEvent event, float x, float y) {
            mainGame.SetClassScreen();
        }
    });

    Gdx.input.setInputProcessor(stage);
}

public void render(float delta) {
    mainGame.batch.setProjectionMatrix(stage.getCamera().combined);
    stage.act(Gdx.graphics.getDeltaTime());
    stage.draw();
}

In the constructor I have tried using Dispose() when changing the screen and it doesn't work.

When the screens are changed, The playButton still shows in the next screen. I also have a Label which displays text depending on a button pressed, but when it's pressed it writes the string over the old string to look like a jumbled mess.

I have a feeling I'm not updating something to be redrawn somewhere but I can't find it.

public PickClassScreen(MainGame game){
    this.mainGame = game;

    viewport = new FitViewport(640, 360, new OrthographicCamera());
    stage = new Stage(viewport, game.batch);

    //All initialization of Scene2d stuff.

    stage.addActor(table);

    Gdx.input.setInputProcessor(stage);
}

@Override
public void show() {

}

@Override
public void render(float delta) {
    mainGame.batch.setProjectionMatrix(stage.getCamera().combined);
    stage.act(Gdx.graphics.getDeltaTime());
    stage.draw();

}

The screen that I am switching to. ^


texts: Moving sprite using the accelerometer in LibGDX?

texts:
I don't know how to use accelerometer in LibGDX; how could I use the the motion sensor? I'm working for a top down game with the motion sensor. I'm new to this framework. My sprite image is already working and I want to control it using the accelerometer.

All comments are much appreciated, thanks in advance :)

Here is my code:

public class IngameDayOne extends ApplicationAdapter implements Screen {

// Constant rows and columns of the sprite sheet
private static final int FRAME_COLS = 5, FRAME_ROWS = 1;
// Objects used
Animation<TextureRegion> walkAnimation; // Must declare frame type (TextureRegion)
private Texture cat ;
SpriteBatch spriteBatch;
Texture Background;
// A variable for tracking elapsed time for the animation
float stateTime;

@Override
public void create() {
    // Load the sprite sheet as a texture
    cat = new Texture(Gdx.files.internal("cat2.png"));

    //Accelerometer
    float accelX = Gdx.input.getAccelerometerX();
    float accelY = Gdx.input.getAccelerometerY();

    if (accelX < -1){
        //go up
    }
    if (accelY < -1 ){
        //go left
    }
    if (accelY > +1){
        //go right
    }

    // Use the split utility method to create a 2D array of TextureRegions. This is
    // possible because this sprite sheet contains frames of equal size and they are
    // all aligned.
    TextureRegion[][] tmp = TextureRegion.split(cat, cat.getWidth() / FRAME_COLS, cat.getHeight()/ FRAME_ROWS);

    // Place the regions into a 1D array in the correct order, starting from the top
    // left, going across first. The Animation constructor requires a 1D array.

    TextureRegion[] walkFrames = new TextureRegion[FRAME_COLS * FRAME_ROWS];
    int index = 0;
    for (int i = 0; i < FRAME_ROWS; i++) {
        for (int j = 0; j < FRAME_COLS; j++) {
            walkFrames[index++] = tmp[i][j];
        }
    }
    // Initialize the Animation with the frame interval and array of frames
    walkAnimation = new Animation<TextureRegion>(0.090f, walkFrames);

    // Instantiate a SpriteBatch for drawing and reset the elapsed animation
    // time to 0
    spriteBatch = new SpriteBatch();
    stateTime = 0f;
    Background = new Texture(Gdx.files.internal("floor.png")); //File from assets folder
}

@Override
public void show() {
}

@Override
public void render(float delta) {

}

@Override
public void resize(int width, int height) {

}
@Override
public void render() {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear screen
    stateTime += Gdx.graphics.getDeltaTime(); // Accumulate elapsed animation time
    // Get current frame of animation for the current stateTime
    TextureRegion currentFrame = walkAnimation.getKeyFrame(stateTime, true);
    spriteBatch.begin();
    spriteBatch.draw(Background,0,0);
    spriteBatch.draw(currentFrame, 50, 50); // Draw current frame at (50, 50)
    spriteBatch.end();

}
@Override
public void pause() {

}

@Override
public void resume() {

}

@Override
public void hide() {

}

@Override
public void dispose() { // SpriteBatches and Textures must always be disposed
    spriteBatch.dispose();
    cat.dispose();
    Background.dispose();
}
}


texts:
Hi I am currently building a cocos2d-x game which incorporates pinch zoom using CCLayerPanZoom class which can be found here

The problem is basically when using CCFollow and zooming and out, it does'nt zoom on the actually followed node, so the camera appears to zoom towards the bottom left corner of the screen, when I would rather it zoom centrally on the followed node.

If I could resolve this I would pretty darn happy. I converted a fix from the cocos2d objective C version in the CCfollow class to cocos2d-x which improved the issue,but if you look at the post in latter link you will see the guy is having the exact same problem, he gave up on fixing it sadly.

I think its close but I don't really know what going on, hopefully someone out there has already faced and fixed this problem.

My converted code is below.

    CCPoint p1 = ccpMult(m_obHalfScreenSize, m_pTarget->getScale() );
    CCPoint p2 = ccpMult(m_pobFollowedNode->getPosition(), m_pTarget->getScale()  );
    CCPoint offect = ccpMult(ccpSub(p1, m_obHalfScreenSize), 0.5f);
    CCPoint tempPos = ccpAdd(ccpSub(p1, p2), offect);
    m_pTarget->setPosition(ccp(clampf(tempPos.x,m_fLeftBoundary,m_fRightBoundary),
                               clampf(tempPos.y,m_fBottomBoundary,m_fTopBoundary)));

I have attached before and after to hopefully make things more clear.


texts: Creating a fragment shader to darken a white texture over time - OpenGL GLSL

texts:
So as a part of learning OpenGL, I've now decided to try and be a bit more creative with shaders, as part of a practice game I'm making using C/OpenGL.

I'm completely new when it comes to working with shaders, so I'm still trying to get used to the thought process behind creating something with it. To this extend, here's what I want to attempt.

As a part of the gameplay, the entire background of the game consists of a white, plain, 2D texture. The white texture should slowly animate black circles into it over time, until finally the entire texture is completely black.

I've considered some different approaches to the problem, and would like to know which one will be the most practical when it comes to shaders.

Using framebuffers: As I've understood from looking around the internet, you can't really, say, apply certain colors to a specific area of fragments in your fragment shader (like creating a black circle), and then save the state of those fragments for the next frame. Instead, I would have to apply the effect, and render the texture to a framebuffer and then re-use it again the next frame. I could then continuously do this slowly add black circles to the texture. The problem is, is this really too much work to do for something simple as this? Or would it be fast enough? As far as I've seen, framebuffers are usually used to post-process effects for entire scene frames. This would not be for the entire scene, only for the background. The advantage of this approach would be that it's relatively simply to work with as you're only working on one texture.

Creating individual circle objects with own fragment shaders: This was another approach I thought about doing. Basically, instead of having one shader work on the entire background texture, I would simply spawn textured quads that each individually run a fragment shader that just turns their texture black over time using a simple percentage value input as a uniform. The disadvantage of this solution is that you make it a bit more complex by having to handle more objects at runtime, instead of simply working with one texture. More vertices would also have to be handled when rendering.

Of these two approaches, I don't know really what would be a good solution to run with. I would like to use the framebuffers approach but I don't know if I would "abuse" the technique with this kind of problem or not.

Or perhaps there's another way of doing this that I've completely missed because I'm new to shaders, in that case other suggestions would be welcome!

Thank you all for your help :)


texts: Ray Caster - How do I fix fish eye effect on side walls?

texts:
I've come here because I can't seem to find out what's wrong with my ray tracer.

I fixed the fish eye effect when looking straight on at walls, but the effect remains when the player is looking at walls to the side.

I think it's because most of the rays hit the surface close to the player, while fewer and fewer rays hit more distant walls, resulting in a curve. The only problem is I don't know how to make it appear linear.

    float dist = distance*cos(angle); //fix distorted distance
    float rat = (depth-(dis))/depth; //calculate ratio for wall height
    float h = 64*rat; //calculate height
    PImage slice = sprites[0].get((int)(inter/2),0,1,16); //get image slice
    image(slice,i*4,768-h/2,4,h); //display image slice

In this example, the top screen is the raw data while the bottom screen it the ray traced 2.5D image. I've made the rays visible.

Edit: I changes "rat" to be 192/dis. This seems to look a bit better, but is still slightly curved...


texts:
Okay so I am working on a game engine and this was my previous game loop:

Game::Run()
{
    While(!m_GameDone)
        Client.Update();
        LocalServer.Update();
}

but what I want to do is:

Game:Run()
{
    ClientThread = new CThread(...);
    ServerThread = new CThread(...);
    ClientThread.StartTask(Client::Run);
    ServerThread.StartTask(LocalServer::Run);
    CThreadSystem.WaitForTasksToFinish();
    return;
}

And then Client::Run and Server::Run would be:

Client::Run()
{
    while(!m_Gamedone)
    {
        this.Update();
        this.Render();
    }
}
Server::Run()
{
    while(!m_Gamedone)
        this.Update
}

So my two big questions are.. Is this a good idea? and How do I make a thread execute a function from a class instance?
The threading system I am using right now is WinAPI and XTL (not STL).

UPDATE:

Okay, everyone wants to tell me about locks and data sync.
The client and server threads DO NOT SHARE ANY COMMON DATA/OBJECTS.
The client and server threads have their own serialized update loops and don't use any common classes or structures. I just wanted to know how to start a thread with a function in class instance scope.


texts: Synchronizing with monitor refreshes without vsync

texts:
What is the preferred way of synchronizing with monitor refreshes, when vsync is not an option? We enable vsync, however, some users disable it in driver settings, and those override app preferences. We need reliable predictable frame lengths to simulate the world correctly, do some visual effects, and synchronize audio (more precisely, we need to estimate how long a frame is going to be on screen, and when it will be on screen).

Is there any way to force drivers to enable vsync despite what the user set in the driver? Or to wait for a swap manually? We have issues with manual sleeping when our frame boundaries line up closely to buffer swaps. It causes occasional missed frames, and up to 1 extra frame of input latency.

We mainly use OpenGL, but Direct3D advice is also appreciated.


texts: SerialPort() data reading slowing down Unity

texts:
I am sending a few data from Arduino Uno to Unity using serial Port, baud rate is 115200. Still Unity is response time is pretty poor.

At first it takes fraction of seconds to process, but as time goes response time increases a lot.

What can I do ?

Is there a better way to send data ?
I have heard using byte[] will be very helpful. Can anyone please tell me how to send Vector from Arduino as byte & recieve in Unity, if actually possible.

As I said I will open-source the project. Take a look.


texts:
I'm looking for the most capable C++ model loading API.

So far I've found tons of ply, obj, and other such file format loaders.  But the libraries I've found tend to load just one model type, and this requires you to learn quite a few api interfaces?

Is there One API To Load Them All, One API To Parse Them, One API To Bring Them All, And In the Vertex Buffer, Bind Them?


texts:
I want to create a simple console-like custom EditorWindow in Unity.
There is a bunch of lables (console lines).

I'm using GUILayout.Begi/EndScrollView to position all the labels in one column.
The problem is that it places all the content inside the rectangle that matches label bounds, not EditowWindow bounds. As a result, I see weird placed scrollbars.

I would be happy to recalculate ScrollView bounds, but can't find any clue in documentation how to make so.
Here is my code:

using UnityEditor;
using UnityEngine;
using System;

public class MyEditorWindow : EditorWindow
{
    Vector2 scrollPosition = Vector2.zero;

    [MenuItem("Window/MyEditorWindow")]
    public static void ShowExample()
    {
        var wnd = GetWindow<MyEditorWindow>();
        wnd.titleContent = new GUIContent("MyEditorWindow");
    }

    private void OnGUI()
    {
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(position.width), GUILayout.Height(position.height));

        var elapsed = new TimeSpan();
        for (int i = 0; i < 100; i++)
        {
            elapsed = elapsed.Add(TimeSpan.FromSeconds(1));
        }

        for (int i = 0; i < 100; i++)
        {
            GUILayout.Label("Some long long long long text");
        }

        GUI.EndScrollView();
    }
}

What is the proper way of making scrolbars which bound to the edges of the EditorWindow?


texts: ID3D11Buffer and std::array : buffer looks empty

texts:
I am having trouble at rendering vertices stored in a std::vector.

// Create and initialize the vertex buffer.
D3D11_BUFFER_DESC vertexBufferDesc;
ZeroMemory(&vertexBufferDesc, sizeof(D3D11_BUFFER_DESC));
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.ByteWidth = sizeof(VertexData) * this->vertex_data.size();
vertexBufferDesc.CPUAccessFlags = 0;
vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;

D3D11_SUBRESOURCE_DATA resourceDataVertex;
ZeroMemory(&resourceDataVertex, sizeof(D3D11_SUBRESOURCE_DATA));
resourceDataVertex.pSysMem = &(this->vertex_data);

HRESULT hr = pDevice->CreateBuffer(&vertexBufferDesc, &resourceDataVertex, &(this->pVertexBuffer));
if (FAILED(hr)) return false;

this->vertex_data being a std::vector<VertexData> with VertexData being:

// Vertex data
struct VertexData {
    XMFLOAT3 v;
    XMFLOAT2 vt;
    XMFLOAT3 vn;

    VertexData(XMFLOAT3 v, XMFLOAT2 vt, XMFLOAT3 vn) : v{ v }, vt{ vt }, vn{ vn } {}
};

Now I'm not sure doing resourceDataVertex.pSysMem = &(this->vertex_data); is a good idea. I can render another mesh without problem just by changing the ID3D11Buffer vertex buffer (said mesh being known at compile-time and stored in a C-Array).

This time around I simply get no render at all. I triple checked my object is in sight and vertex_data is fully populated.


texts: How do I change a Unity 4.6 Sprite's textureRect at runtime?

texts:
I'm using Unity 4.6, and I've made a sprite like this:

    AtlasFrameData frame = _testAtlas.GetFrameByIndex(0);
    Rect spriteRect = new Rect(frame.Position.x, frame.Position.y, frame.FrameSize.x, frame.FrameSize.y);
    Sprite _theSprite = Sprite.Create(_testAtlas.AtlasTexture, spriteRect, new Vector2(0, 0));

The texture is an atlas, and I have a bunch of data read in from an XML file telling me where the frames are. I want to do this in Update():

    AtlasFrameData frame = _testAtlas.GetFrameByIndex(_currentFrame);
    Rect spriteRect = new Rect(frame.Position.x, frame.Position.y, frame.FrameSize.x, frame.FrameSize.y);
    _theSprite.textureRect = spriteRect;

But I'm unable to do this since .textureRect is readonly. I could create a new Sprite each frame, but I suspect this is not going to perform well with tons of Sprites.


texts: How to simulate pressure with particles?

texts:
I'm trying to simulate pressure with a collection of spherical particles in a Unity game I'm building. A couple notes about the problem:

The goal is to fill a constantly changing 2d space/void with small, frictionless spheres. The game is trying to simulate the ever-growing pressure of more objects being shoved into this space.
The level itself is constantly scrolling from left to right, meaning if the space's dimensions are not changed by the user it will automatically get smaller (the leftmost part of the space will continually scroll off-screen).

I'm wondering what some approaches are that I can take to tackling these problems...

Knowing when to detect when there is space to fill and then add spheres to the space.
Removing spheres from the space when it is shrinking.
Strategies to simulate pressure on the spheres such that they "explode outwards" when more space is created.

The current approach I am contemplating is using a constantly moving wall, that is off screen and moves with the screen, as this image illustrates:

.

This moving wall will push and trap the spheres into the space. As for adding new spheres, I was going to have either (1) spheres replicate themselves upon detecting free space, OR (2) spawn them at the left side of the space (where the wall is) - pushing the rest of the spheres to fill the space. I foresee problems with idea #1 because this likely wouldn't really create/simulate pressure; idea #2 seems more promising, but raises the question of how to provide a location for these new sphere particles to spawn (and the ramifications of spawning them when there IS no space).

Thanks so much in advance for your wisdom!


texts: XNA draw texture/font and DrawIndexedPrimitives at the same time

texts:
When i Draw a texture2d or a font with spriteBatch and also draw GraphicsDevice.DrawIndexedPrimitives, the frame is draw weird

SpriteBatch  spriteBatch = new SpriteBatch(GraphicsDevice);
BasicEffect basicEffect = new BasicEffect(GraphicsDevice);

protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.Clear(Color.LightSteelBlue);
    RasterizerState rasterizerState = new RasterizerState();
    rasterizerState.CullMode = CullMode.None;
    GraphicsDevice.RasterizerState = rasterizerState;

    //for(...) {
    GraphicsDevice.SetVertexBuffer(vertexBuffer);
    GraphicsDevice.Indices = indexBuffer;

    foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
    {
        pass.Apply();
        GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 8, 0, 20);
    }
    // } end for

    spriteBatch.Begin();
    spriteBatch.DrawString(MainFont, "FPS: " + Math.Round(1 / (float)gameTime.ElapsedGameTime.TotalSeconds, 2), new Vector2(200, 10), Color.Red);
    spriteBatch.End();

How can i solve this ?


texts: How to avoid ghosting when pressing multiple keys?

texts: I am working on a 2d side-scrolling pc game that uses SFML game library. The problem that I am not able to solve is that in many keyboards combination of three or more keys (like w + d + k) is not working. Is there any way to solve this issue?


texts: Efficient Tile-based collision detection for a lot of squares?

texts:
currently I am working on my own take of a tile-based game (think Terraria, but less fantastical (I think that's a word? Sorry if it isn't)).

Anyway, I currently have collision detection working (for corner cases even!) which was a big step for me. There is something extremely gratifying about seeing a sprite not run through a block. But then I had the idea to benchmark. Bad idea.

1,000 squares, no problem.
10,000 squares, for 3 characters was kind of laggy.
100,000 squares (really huge map), for 3 characters was unplayable.

I'm having the issue where I don't want to even consider the blocks that are too far from the player, characters, items, etc., but I don't want to load those in-out of memory constantly.

Here's my algorithm so far, feel free to criticize.

foreach (Block in level)
{
    if (distance from block to player > a specified amount)
        ignore this block;
    else
    {
        get the intersection depth between the two bounding boxes
        if (depth of intersection != Zero-vector)
        {
            check y size vs x size
            resolve on smallest axis
        }
    }
}

As you will note, when the level size get's bigger, the Order of this algorithm grows by N blocks. I would like to not even consider blocks that aren't even near the player.

I'm thinking maybe use a (0,0) to (mapWidth,mapHeight) double-array of blocks instead of a list, calculating a danger-zone depending on the person's position e.g., if player's position is at (10, 20) it will look from (0, 10) to (20, 30), or so on.

Any thoughts and considerations are awesome, thank you.


texts: Continuous world and very large levels: going around the FPU limitations with Ogre3D

texts:
I'm currently using Ogre3D, and I'm wondering is it's possible to have a very large level (hundreds of kilometers) using the right scenemanager. Storing or having the level is not a problem, since I can repeat objects in a procedural fashion, my objective is level size, not quality.

Taken from http://floatingorigin.com/mirror/continuous-world.htm :

Imagine two characters walking in formation two meters apart heading east away from the origin. At some point, the distance from each other is overwhelmed by the distance from the origin, and the characters will appear to be “at the same location”.

I'm wondering if solutions for those problem like the one described in the Dungeon Siege article are the only viable ones, and if it requires a deep engine modification or not. I'm not sure the paged scenemanagers or PCZ scenemanager reset the zero like I think.


texts:
I am looking for an easing equation with the following properties:

It starts at a velocity of zero, and eases into a constant velocity of 1 for a duration of t_1 seconds (cubic, exp, or quintic, doesn't matter)
It then has a constant velocity of 1 for t_2 seconds.
Finally, it eases down to zero velocity for a period of t_3 seconds.
t_1 + t_2 + t_3 = t_max
The function starts at zero and ends at 1.
t_2 will be chosen by the easing function to satisfy (4) and (5), given t_1, t_3, and t_max.

Therefore the function has the form:

float EaseConstantVelocity(float current_time, float t_1, float t_3, float t_max)
{
    // ?
}

How do I construct such an easing function?

Edit:

What I'm looking for is conceptually similar to the CubicInOut function, except in the case of CubicInOut, t_2 is 0.


texts: Mixing Perspective and Orthographic Projections?

texts:
I'm going to start with some background, so jump to my question at the bottom for the TLDR version.

Problem:

In a Japanese 4gamer article (english translation via Chev on Polycount) explaining some of the technology and design behind Guilty Gear Xrd (a highly-stylized, 2.5D, toon-shaded fighting game) they detail some of the challenges concerning the game's development. One of the challenges had to do with the use of an orthographic 2D collision detection system on top of 3D character models that were rendered in perspective. In short, rendering character models through a perspective projection would naturally result in the characters looking wider towards the edges of the camera. As such, at various points on the screen the visual representation of the characters would fail to accurately represent their 'hitboxes' and 'hurtboxes'.

Example 1: Models using perspective projection.

The character model for Player 2 (orange) more closely matches his collision data because of his location towards the center of the screen.

Example 2: Models using orthographic projection.

Using an orthographic projection, characters are accurately aligned with their collision data regardless of position. However, the desired visual effects of perspective are lost.

Their Solution:

The developers at Arc System Works solved this issues by creating a 'partial perspective' projection - a non-uniform mixture of perspective and orthographic (maybe parallel is more accurate) projections. On the horizontal axis, the camera's projection is said to be a '70% orthographic and 30% perspective' hybrid. On the vertical axis, the projection remains 100% perspective.

Example 3: Models using 'hybrid' projection.

Mixing perspective and orthographic horizontally allowed them to preserve collision alignment and visual spacing (an important aspect in competitive fighting games). At the same time, the 'fully perspective' projection on the vertical axis allowed them to achieve extra visual depth when the characters jump.

My Question:

How would one go about achieving this kind of non-uniform, semi-perspective, semi-parallel camera projection?

When I think about this, I can imagine a camera frustum with a wide vertical FoV and a somewhat more narrow (but not necessarily parallel) horizontal FoV. Is this the correct interpretation of what they're describing, or am I visualizing it incorrectly?

Typically how would you generate a projection/modelview matrix like this? Is there a way to ask libraries like OpenGL and Direct3D for non-uniform matrices like these, or is there some way to combine an orthographic matrix and a perspective matrix in a non-uniform way through matrix math?


texts: How can I deploy and unreal engine windows exe build to the cloud?

texts:
I don’t have a coding background, so I am struggling with this. Someone will have to dumb down a lot of the language for me.

I’m trying to deploy my unreal engine game to a cloud computing service using the .exe file I built. I would like to do this in order to maintain the maximum quality of the game and have multiple users access the game simultaneously by a hyperlink. I don’t need the users interacting with each other. I was able to get this to work with x.io but that service is kind of limited. I also messed around with AWS but all of that was too confusing for me. Please let me know if the community can guide me.


texts: How do I change a shape without affecting the rest of the screen?

texts:
I have drawn a shape like this in OpenGL:

 glColor4f(red,green,blue);
        glBegin(GL_QUADS);
            glVertex2f(x1,y1);
            glVertex2f(x2,y2);
            glVertex2f(x3,y3);
            glVertex2f(x4,y4);
        glEnd();
glFlush();

and I want change one the vertices like

glVertex2f(x_delta,y_delta);

But how do I redraw the shape without altering the other components of the screen?


texts:
I have developed a game engine in c/c++ and DirectX.

I have a tile engine for the maps, animated player/npc sprites, talking to the npc, menus, and level changing but there is no game, it just feels empty.

I have looked around and keep hearing buzzword answers but I want to know how to implement a story in my game.

Some people have said a save file that holds flags governing every possible action/state available in the game but this sounds ludicrous.

It is a bit ambitious but I am aiming to get a game like the older Pokemon/Final Fantasy games.

Does any one know how these games work or the theory used?

I have been looking for a while and would really appreciate any input people have.


texts: Game Publishing & Income : Quality vs Quantity

texts:
As a casual flash gamer, I see lots of "games" released that are ... terrible. And that's an overstatement. But I'm wondering, are these developers onto something? Is this a comparatively good source of income, considering how much time a quality game takes to make?

I'd like to consider it from a developer's perspective, though the concept may extend to all games and not just flash. Someone who wants to earn money - say, via sponsors (Amor Games, Crazy Monkey) or flash gaming sites (Kongregate, NewGrounds). (I don't think sponsors will sponsor a half-baked game, though).


texts: Easiest turn-base games you can think of?

texts:
I'm planning to get into the process of programming multiplayer turn-base games. I would like to start off by making some of the simplest (yet fun) multiplayer turn-base games out there. What are some that you can provide? For example:

Tic-Tac-Toe
Rock-Paper-Scissors
Checkers

Some not so easy games:

4 in a row
chess
poker

In terms of "ease" of implementation I'm mainly looking at logic. For example, Rock-Paper-Scissors has very simple logic, while chess has logic that is more complicated.

So far I have the following:

Hexagon
Heroes of Might and Magic
Nine Men's Morris
Connect 4
21 (card game)
Pen the Pig (The Dot game)
Memory Match


texts: How do I change the name of map shown in Warcraft 3 list of available maps?

texts:
I used an MPQ editor to change some things in one of my maps.  Among those changes was the map name defined as a text string in the war3map.wts inside the map.
Now, however, I see that the name of the map, as shown in the list of maps, was unchanged and — of course — differs from the name of the map shown everywhere else:  above the preview, e.g.

How do I change the list name?
Do I actually need to resave it in a map editor, e.g. Blizzard's “World Editor”?


texts:
I would like to know how to best achieve lighting effects with 2D.

I guess the only way is to make sprites of the area to be lit in specific colors?
Say I have a streetlamp, and around this place sprites to make it appear lit?

Is there a better way?

Edit: Found a good screenshot of what I'm looking for:
http://www.saltgames.com/wp-content/uploads/2009/11/multipleLights.png


texts: Where to start for implementing vehicle physics?

texts:
A little background for myself. I am relatively experienced with 3rd part physics engines such as Havok, Box2D, Bullet and have successfully integrated them in custom engine(s). I have also made a simple physics engine by following a few known books.

Now I am interested in diving into vehicle physics. There are a couple of books that skim over the topic but do not go over in enough detail for me to grasp anything useful. So I would like to know of good books/resources that are not too heavy (by that I mean a book that is pure vehicles and made for engineers rather than game developers) that help me get started on vehicle physics. Here get started = at least guide me through creating a simple vehicle in 3D with modern features found in most games (suspension/transmission etc.)

Note: I searched for a similar question but did not find one, but if one exists, please post the link and feel free to close the question.


texts: How can I better structure my code to reduce coupling between input and graphics?

texts:
I've been working through a few OpenGL tutorials, and decided to give myself the exercise of trying to draw a grid, with the added requirement of being able to press the - and + keys to change the dimensions of the grid.  I've achieved what I set out to, however, it's left me with a few questions on how to go about separating some of the logic.

My biggest concern is to do with the input handling.  Right now, I'm handling it like so:

Grid grid;

void key_callback(GLFWwindow* window, int key, int scanCode, int action, int mode)
{
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
        glfwSetWindowShouldClose(window, GL_TRUE);

    if (key == GLFW_KEY_MINUS && action == GLFW_PRESS)
        grid.DecrementGridSize();

    if (key == GLFW_KEY_EQUAL && action == GLFW_PRESS)
        grid.IncrementGridSize();

    grid.Build();
    glBufferData(GL_ARRAY_BUFFER, grid.Size() * sizeof(Vector3D), grid.Data(), GL_STATIC_DRAW);
}

There are several things I don't like about this:

This is at the top of my main.cpp file, so grid is global, purely so it can be used in the input handler.
I've coupled the glBufferData() call with the input handling.

I'm not sure how to go about solving point 1, as I'm inexperienced with C++, but, for 2, I've considered the idea of having a separate Update() method that would be called at the end of the handler, rather than calling glBufferData() directly.  Update() would then take care of updating the contents of the buffer.

The problem I see with that is how you would pass the data from grid to it.  In my simple program, passing one set of vertices is absolutely no problem, but I'm not sure how you'd handle doing that when you have a whole bunch of different objects with their own vertices.  I assume there are different patterns that already exist for handling this, so I'm more looking for some phrases I can Google really.

What can I do to improve the situation?


texts:
Using Blender 2.6. My model has its location and rotation zeroed out, scale set at 1.0, and generally conforms to every guideline detailed on this site and misc google results. When exporting it, I check 'XNA Strict Options'. Y up and -Z forward seems right.

However, it still ends up sideways. I found that a possible fix was to just set the X Axis Rotation in the Content Processor properties to -90, but that ended up being worthless when I started checking out collision spheres and realized that they lay in that skewed orientation.

What could I be missing?

Edit: Drawing code:

Matrix[] bones = animPlayer.GetSkinTransforms();
foreach (ModelMesh mesh in model.Meshes)
{
    foreach (SkinnedEffect fx in mesh.Effects)
    {
        fx.SetBoneTransforms(bones);
        fx.View = camera.viewMatrix;
        fx.Projection = camera.projectionMatrix;
        fx.EnableDefaultLighting();
        fx.World = worldMatrix;
    }
    mesh.Draw();
}

Where

worldMatrix = rotMatrix * moveMatrix;
camera.viewMatrix = Matrix.CreateLookAt(camPosition, target+camTargetOffset, camUp);
camera.projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)game.Window.ClientBounds.Width / (float)game.Window.ClientBounds.Height, 1, 100);


texts:
I'm implementing a D3D10 version of my renderer (not porting to avoid losing Windows XP support). I didn't go straight to D3D11 because MSDN and other sources recommend upgrading to 10 and then to 11.

From what I've read so far, what used to be done with IDirect3D9::SetRenderState is done in D3D10 with ID3D10RasterizerState, ID3D10BlendState and ID3D10DepthStencilState. You declare and fill a descriptor structure, tell the device to create a state object, and then bind it to the device. For example:

//D3D9
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

//D3D10
//This defines the ID3D10RasterizerStatePtr type used below
_COM_SMARTPTR_TYPEDEF(ID3D10RasterizerState, __uuidof(ID3D10RasterizerState) );
//...
ID3D10RasterizerStatePtr pRasterState;
D3D10_RASTERIZER_DESC rasterDesc;
rasterDesc.CullMode = D3D10_CULL_NONE;
if( !CheckErrorCode( m_pImpl->pDevice->CreateRasterizerState( &rasterDesc, &pRasterState ), "InitDevice", "CreateRasterizerState" ) )
    return false;
m_pImpl->pDevice->RSSetState( pRasterState );

However, now that I have to "port" the line...

 m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );

... I cannot find a related property in any of the descriptors. From what I've seen, most  examples implement lighting in HLSL, so perhaps I don't need to explicitly disable lighting, because my shaders don't do it?

This is a desktop app, no fancy Metro stuff. Using unmanaged C++.


texts: OpenGL behaviour depending on the graphics card?

texts:
This is something that never happened to me before. I have an OpenGL code that uses GLSL shaders to texture a 3D model. The code involves a lot of GPU texture processing, blending, etc...

I wanted to check how the performance of my code improves using a faster graphics card (both new and old are NVIDIA, using always the NVIDIA development drivers). But now I have found that once I run the code using the new graphics card, it behaves completely different (the final render looks wrong), probably because some blending effect is not performed correctly.

I haven't really look into what has changed, but I am guessing that some OpenGL states are, by default, set different. Is this possible? Have you ever found different OpenGL/GLSL behaviour using different graphics cards? Any "fast" solution? (So far I've thought of plugging back the old one, push all OpenGL default states, and compare with the ones I initially get using the new card..)

Edit #1: The graphics cards are NVIDIA Quadro GX7300 (in which my code works OK) and NVIDIA GeForce GTX 560 Ti (in which the results changes / fails)

Edit #2 I have commented out a lot of my code, and apparently the strange behaviour has nothing to do with texture handling. A simple chessboard-like floor looks differents. The diagonal white lines did not appear using the old NVIDIA Quadro GX7300. Any guess what OpenGL related thing could be causing this?

Figure 1

Edit #3 I have now fixed the issue commented on the previous edit, regarding the weird unwanted diagonal thin whit lines. As I commented below, I had to remove the glEnable(GL_POLYGON_SMOOTH);, which was affecting the NVIDIA GeForce GTX 560 for whatever reason (probably due to reasons explained by mh01 in his answer.

However, I am still facing a "texture blending" problem when using the NVIDIA GeForce GTX 560. I have a 3D model that is being textured using a shader that blends 8 different images to compute the right texture, depending on where the camera is at that particular moment. The resulting texture is then a combination of different images, and ideally they were blended nicely, using a set of blending weights computed each time the camera moves. The blending weights are still well computed, but the resulting texture is wrong. I am guessing that the GL_BLEND function is somehow behaving different, but I have checked it in both graphics cards and it is actually the same one. I have no idea what else can be involved in getting this wrong result:

As you can imagine, the black line is where two original textures are being blended in order to get a seamless texture. If I use the exact some code and a NVIDIA Quadro GX730, the shader works as expected. However, when I use the NVIDIA GeForce GTX 560, the texture blending goes wrong. Any guess?

This is the GLSL shader I am using.


texts: SceneNode transform and Eye and Center position

texts:
I am learning some inner workings of game engine development and have come across this confusion. To explain what I am trying to do, I want to start with an example:

Let's say that I have an object (e.g a cube) that moves forward. I want to add a camera that follows the object (e.g 3rd person camera). For this, my SceneGraph looks like this (XML type markup to show hierarchy):

<GameObjectNode mesh="cube.mesh" position="(0.0, 0.0, z)">
    <CameraNode position="(0.0, 10.0, 15.0)" />
</GameObjectNode>

This allows my camera to "follow" the cube because the camera's world transformation is:

camera.worldTransform = parent->worldTransform * camera.transform;

This all makes sense in terms of transformations in the world. However, when it comes to view transforms, this is where I am confused about. All the hardware APIs use have something like setViewTransform(float *matView, float *matProjection) and the view matrix is typically calculated using something like lookAt(vec3 eye, vec3 center, vec3 up).

My camera transform is calculated using the formula above. However, the lookAt matrix function requires position as vector (eye). Is there a way to create lookAt matrix function that does not use vectors to get position? Or is there a way to extract position from transform matrix?

EDIT: I was able to use the worldTransform matrix last "vector" to get the position vector as that's where the translation parameters were. However, I still have a problem with center one because the the center vector must also be calculated using matrix transform. How can I get the coordinates of center in relationship to Eye.


texts: I just made an A* Pathfinding system in unity that doesn't calculate the f cost (g cost + h cost) and I wondering why do u actually have to calculate the f cost? I mean my pathfinding system that works perfectly fine. Any ideas?


texts:
In 3ds max, I've made a Cannon that sets itself up, but I only want this animation to play once, here's where I'm trying to make it loop only once:

When I click the toggle at the bottom, it stops the animation for constantly looping, but when I click 'Save', and run my game, it still continues to loop.
What am I doing wrong?


texts: Merging tesselated terrain with manually modelled

texts:
In my flighsim visual system I am rendering large scale terrain using fixed grid mesh which is tesselated and displaced using height map. But for some relative small area (usually airports) we have much more detailed models including terrain, runways and so on. And here is a problem how can I merge tesselated terrain with modelled one?

On the picture bellow grey is a tesselated terrain, and blue is modelled with 3dsmax.


texts: What are the fundamentals of a Quad Billboarding effect?

texts:
I'm taking my first venture in to writing a shader and what I really need to do is create a billboarding effect. A thorough Google search turns up a number of threads on the topic and they always end with

A) Figured it out. Thread closed.

B) Anyone?

C) "long language/system-specific answer without explanation"

Most commonly, people are directed to Riemers which is fine, except his code isn't compatible with XNA 4.0 (what I'm using) and he doesn't explain the shader itself.

Can anyone explain/direct-me-to a language/system agnostic answer of how quad billboarding works?

EDIT: For others so they don't need to dig through the comments: NtscCobalt pointed out that I was attempting to use an orthographic camera when applying the shader. This essentially voided some of the effects of the shader. After changing to a perspective-based cam, the shader worked as it should have.


texts: Stepping from Point out on Archimedes Spiral for Length along Arc

texts:
I wasn’t sure whether to put this question in mathematics or programming?

My question has two parts with the second part dependent on the first.
I’m looking to use Archimedes spirals in some game code I’m writing.

I figured that there is possibly a unary Archimedes spiral from which all other achimedes spirals can be derived.  (Hopefully the use of ‘unary’ is correct here?)  That is a unary Archimedes spiral is one where the spiral spirals one radian outwards for every radian of angle starting at centre.

So my first question is:  Is that true?  Can every Archimedes spiral be derived from a ‘unary Archimedes spiral’  like I’ve described?

By derived I mean by the use of simple multiplication and division to transform from the unary Archimedes spiral to any Achimedes spiral with a different rate of out-spiral.

eg.  spiral20RadiansOutPerRadian = unaryspiral * 20

If that is the case then could someone possibly help me also with this second question?

I’m looking to step a measured arc length outwards (and inwards) from a point that is out on a measured Archimedes spiral.  So not from the zero or centre point but from somewhere out on the spiral.  The begin point out on the spiral is represented by a measured radius from zero (or centre).

I’m looking to find:  r' = f(r , arclen)

where r is the initial radius, arclen is the length stepping outwards along the arc (negative to step inwards) and the resultant r' is the new radius at that stepped to point.

My process for deriving from the unit spiral would hopefully then be:

Programmer sets a value for delta_radius which is per radian of angle.
Programmer sets a value for start_radius.
Programmer sets a value for step_length which is the length to step around arc.

The unary_step_length is worked out by dividing step_length by delta_radius.
The unary_start_radius is worked out by dividing start_radius by delta_radius.

We call achimedes() function with the two unary values and it returns unary_end_radius.

The actual end_radius is worked out by multiplying unary_end_radius by delta_radius.
The delta_angle is worked by subtracting unary_end_radius from the unary_start_radius.

My second question is:  Could somebody please help me to write this achimedes() function (if the answer to question 1 is yes)?

I’m looking to have function be of the form:

unary_end_radius = archimedes(unary_start_radius , unary_step_length)

where the unary_delta_radius is understood to be 1 radian.


texts:
I'm having a strange problem. I'm creating a 2D platformer, and creating the gameplay map by reading a csv file and placing prefabs of the appropriate type on map.

One part of the map is a simple straight line of blocks. I can move across them no problem except that there's this particular area where I simply can't move over it.

(In the image the blue tiles are the ones I'm colliding with. I added that to help debug it). The block itself is not higher than any other blocks in the rest of the line, comes from the same prefab et cetera.

If I remove "Fixed Angle" from the player character block, when passing from this block it'll start to rotate wildly instead - suggesting that it's colliding with some sort of edge.

Here's the code I'm using to generate the blocks

 for (int x = 0; x < tiles.GetLength(0); x++)
        {
            for (int y = 0; y < tiles.GetLength(1); y++)
            {
                var tile = tiles[x, y];

                if (tile.HasValue)
                {
                    switch (tile.Value)
                    {
                        case TileType.MAIN_CHARACTER:
                            Instantiate(mainCharacter, new Vector3(x * TILE_SIZE, -y * TILE_SIZE), Quaternion.identity);
                            break;
                        case TileType.NORMAL:
                            Instantiate(maintile, new Vector3(x * TILE_SIZE, -y * TILE_SIZE), Quaternion.identity);
                            break;
                        default:
                            throw new NotImplementedException("No code for tile value " + tile.ToString());
                    }
                }
            }
        }

So, what am I doing wrong exactly? Is there a way to tell Unity to ignore these 'tiny' collisions?

EDIT 1: If it makes any difference, I'm using BoxColliders2D around each block


texts: Unity - Mathf.Lerp() didn't work as expected?

texts:
I want to rotate an object 360 degrees so this is what I did:
xRotation = Mathf.Lerp(0, 360, Time.fixedDeltaTime * lerpTime)
and then I used Quaternion.Lerp() to rotate the Object so:
targetRotation = Quaternion.Euler(initialRotation.x + xRotation, initialRotation.y, initialRotation.z);
transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, Time.fixedDeltaTime * lerpTime);

But it didn't work as expected, the xRotation didn't go from 0 to 360, it just changed from 0 to 9 (instantly), and that's it, it never changed.
This is my full code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class QuaternionExpirement : MonoBehaviour
{

    [SerializeField] [Range(5, 10)] float lerpTime;
    Vector3 initialRotation;
    bool mousePress, readyToRotate;
    float xRotation;

    private void Awake()
    {
        initialRotation = Vector3.zero;
        mousePress = false;
        readyToRotate = false;
        xRotation = 0;
    }

    private void Update()
    {
        mousePress = Input.GetMouseButtonDown(0);
    }

    private void FixedUpdate()
    {
        if (mousePress)
        {
            initialRotation = transform.eulerAngles;
            readyToRotate = true;
        }

        if (readyToRotate)
        {
            xRotation = Mathf.Lerp(0, 360, Time.fixedDeltaTime * lerpTime);
            Quaternion targetRotation = Quaternion.Euler(initialRotation.x + xRotation, initialRotation.y, initialRotation.z);
            transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, Time.fixedDeltaTime * lerpTime);

            if (xRotation >= 360)
            {
                readyToRotate = false;
            }
        }
    }

}


texts: How to use separating axis theorem to allow for sliding along walls

texts:
I'm making a 2D platformer game and using the separating axis theorem for collision detection, but I want the player to be able to walk along the ground and slide on walls and other stuff and I can't find anything online.

For moving I have:

//in my Entity class, where each entity has a collider
//and is added to the world on creation
public void Move(Vector amount)
{
    Pos += amount;
    if(world.isCollidingWithAnything(this))
    {
        Pos-=amount;
    }
}

If I move into a collision it stops all movement that frame, even if the movement is parallel to the obstacle. How do I make it to where they can walk along the ground without splitting the x and y movement?


texts: Is speed and direction generally combined into one vector, or separated into two?

texts:
Couldn't find this answered already, surprisingly.
For example, for a game (in my case a 2D top-down one), there could be advantages to doing so. For example, whenever you want to change an entity's direction, you just assign entity.direction = unitVector and bam, the direction is changed.
Similarly, if you want to apply a powerup that increases their speed, you just do entity.speed += 5, since it's a scalar value.
However, I also see advantages to keeping them combined. For one, a vector is already the combination of magnitude and direction, so it feels natural to combine into a single value. Secondly, it prevents desync. For example, if you have some sort of function that modifies the an entity's velocity, you have to constantly check whether you're dealing with direction or speed, and also be sure to update both values independently, which can be confusing.
How is this generally handled in the majority of cases? Are they combined, or not? And if they are combined, what are the recommended ways of changing just the speed, or changing just the direction of this combined vector value?


texts: Making smooth walk/jump/fly etc animations

texts:
i am soon gonna start with developing my own game for the iOS, i have the plan and idea of the game ready. BUT i have 1 question. How do people make such a smooth animation? Lets take for example: Angry Birds, if you pull on the rope to shoot the bird everything looks so smootthh or take Tiny Wings for example.., how did they make this? Did they made an image for every frame of the animation in photoshop and putted it in a plist? or how?

Ty in advance!


texts:
I have a scene that contains 3 elements:

Main Camera
A 2D Sprite that renders a single white pixel image, scaled to 2000 x 1000
A point light with a yellow color

What should be done so that the light is actually rendered on the sprite?
I have recorded a short video showcasing the issue: https://www.youtube.com/watch?v=g2iZB6BXhPs


texts:
I've been thinking about how to implement a portal, and after a quick search, everyone seems to do it by adding a camera per portal and then just update the other portal's view with that camera's view.

But if portals were real (like our real, the real in front of the monitor), they'd bend space in another dimension. Like the puzzle where you draw 5 points randomly on a sheet of paper and tell someone to connect those dots to all other dots without crossing lines (possible for 4 but not 5 dots). The trick to solving this puzzle is by bending the paper and poking through it at the right location (creating a "portal").

My question now is, can you implement the same technique in a game (engine) in 3D? Has someone done it before, and if yes, how does the math look like? Also, what would the pros and cons of doing it like this be? Is it more computational work to do? It sounds like it's just calculating with matrices, so doesn't sound that difficult for a GPU.

Please help me prevent another sleepless night, I've got stuff to do tomorrow. /s


texts: Zune same features as WP7? (gesture, accelerometer)

texts:
We don't have zune HD in Canada (yet) just wondering if it has the same programmable features as WP7? Like gestures and accelerometer.

Basically if I am just making a game, with screen controls (thumbsticks on the screen) is this an easy port to zune?

Thanks!


texts: How can I approach writing a GUI framework for my game?

texts:
The problem

I want to write a simple GUI framework designed for a game, in order to learn the inner workings and nitty-gritty of how GUI 'engines' such as Unity3D's GUI work. I can't find any resource to help me get started.

What I'm looking for exactly is the abstract methodology of GUI programming, so things like what are the components of a GUI framework, how often and in what ways should the interface be updated with data, what are the different ways to connect the visuals in the interface to the logic behind them, how should clicking events be handled, things like that.

What I tried

I've been trying to research my options for months but to no avail. Looking up keywords like "GUI programming" or "GUI programming philosophies" leads nowhere and doesn't answer the questions I mentioned above.

There are plenty of resources and tutorials out there for things like OpenGL, how to write a game loop, how to write a physics engine, but nothing like that for writing GUI systems. The wikipedia pages for these topics are also usually a good starting point, but the GUI entries are too design-focused, failing to focus on programming-specific methodology/architecture.

I also tried starting from the web GUI frameworks I know such as React and Angular, and learned a few interesting things like the the view-model-viewmodel architecture and React's virtual DOM, but I still don't know how to apply them, how to generalize them into some framework/philosophy I can follow while coding, and whether there are any other possible options.

P.S. My environment is C# and OpenGL through OpenTK, but that hopefully won't matter in terms of respondents giving a broad overview.


texts: What are some easy to use 3D painting programs?

texts:
I'm looking for an (easy to use) "3D painting" program, a program that lets me load up a UV-mapped mesh, some textures and lets me 'paint' with those different textures.

Exactly like all those terrain painting programs (Unity 3D has one integrated for example) but for a generic mesh, not just a height map.

Cheap is better of course but ease to use is the most important.

Script support is a big plus though.


texts: Difference between Decision Trees & Behavior Trees for Game AI

texts: What are some differences between Decision Trees and Behavior Trees for AI Game Development?  For what applications would you use one over the other?


texts:
I read the answers from What exactly is UV and UVW Mapping? and How does UVW texture mapping work?, which are quite nice, but am still not 100% sure, if I understand correctly.

Lets start with a 2D example. So, say I have a triangle (obviously described by 3 vertices). Now my question is, how do I convert a (x,y)-coordinate to the (u,v)-coordinate of my texture? Since {x,y} could be any value between [0,n] with n being all real numbers, considering that it is in object space. But my texture coordinates are between [0,1]. How do I know how to map lets say (3,4) to (u,v)? If I know how to map the object coordinates to the texture coordinate it is easy to interpolate the values, I assume (either using bilinear interpolation or barycentric interpolation).

And then how would this work for 3D? Lets say in this case we would have a pyramide with 5 vertices (4 bottom, 1 tip). I guess the procedure would be similar, with the exception that I know have an additional depth value. But how does the mapping of a 2D texture work on a 3D object, when I don't have nice flat surfaces like on a pyramide, but instead have a circular surface, like a tea pot?

I hope I'm clear in my questions. I'm still little confused myself. I just don't quite get the mathematical background of texture mapping.

It would be enough, if you could point me to some website with good explanation, maybe with clear graphics and step by step description.

Thanks for your time!


texts: Calculating the difference between two numbers using exponential growth

texts:
I think this is a very basic game programming question, but I am bad with math and new to programming & game programming so I'm looking for some advice. I'm making a 2D sprite game for iOS. Every frame in my game loop I check to see if player moves past a boundary in the game; if so, I scroll the camera's view:

    if playerPosition.x > rightBound {
        let amt = playerPosition.x - rightBound
        camera.position = CGPoint(x: camera.position.x + (amt * 0.1), y: camera.position.y)
    }

This works OK; the camera scrolls slowly when the player exceeds the boundary by a small amount and scrolls more quickly when they exceed the boundary by a larger amount. So the scrolling speed scales up linearly. However, I would like the scrolling speed to scale up faster, perhaps in at a more "exponential" rate. (Enter my terrible understanding of math...)

I don't know the best way to express this mathematically. I know that exponential growth is an actual thing in math, but I actually had to look it up on Wikipedia. And I don't know the best way to implement that in game programming.

To clarify with a simple hypothetical, say that the boundary x position is at 0. When the player moves past it in the first frame his position is 1, so the difference between the two positions is 1. Then next frame his position is 2 so the difference increases to 2, and so on. So the difference between the positions grows like 1, 2, 3, 4, 5, 6, etc. However, I want to calculate the difference between these positions so that my result grows more like 1, 2.1, 3.3, 4.5, 6.1, 7.8, etc.

This graph suggests that I might want to use cubic growth or exponential growth:

But I'm not sure how to express such a formula programmatically. Perhaps more importantly, I don't know if that is the best way to approach this sort of calculation from a game programming perspective. This calculation will run four times every frame, and performance is a concern so I'm trying to find an efficient solution rather than some crufty version I arrive at by myself.

Can anyone provide some advice? I'm working in Swift but I think this is a language-agnostic problem. If you express the answer in another language I can probably figure out how to implement that in Swift.

UPDATE:

Thanks to tom10, I ended up going with this formula for exponentially increasing my camera scrolling speed based on how far the player has passed beyond a boundary:

if playerPosition.x > rightBound {
    let dx = playerPosition.x - rightBound
    let baseAmt = dx * 0.033
    let amt = baseAmt + pow(2, baseAmt * 0.25)
    camera.position = CGPoint(x: camera.position.x + amt, y: camera.position.y)
}

0.033 and 0.25 are "magic numbers" that work well for my game; I arrived at them by trial & error.


texts: How does a game like Minecraft generate new chunks in realtime?

texts:
I imagine looping through all 65,536 blocks with a noise function to set their type would be very slow. And Minecraft usually generates a ton of chunks at once. I read in one source online that Minecraft creates a column of 16x16x16 chunks, although I can't find any more information on that subject, and that doesn't really change how many blocks there are in one chunk "column". I assume there are optimizations made to make it work, although I can't find much about this subject online.

Edit: The way I am generating chunks in my own (2D) game is by looping through a 16x16 array using a Perlin Noise function for every chunk. With 16x16 chunks it runs fine in realtime. I want the chunks to be 3600 tiles high, and changing the size to be 16x3600 runs very slowly.


texts:
I am working about box2D.
Even if I set userData, when I retrieve it via getUserData(), it returns null. Using debugger, I noticed that object passed to setUserData() is not null, but on the next istruction: fixtureDef.shape.dispose();
Body user data returns being null, such as setUserData() set on a copy of body. I read on other topics that setUserData() must be called before body creation...but it throws an exception
      @Override
public void setPhysic(@Null Shape shape, BodyDef.BodyType bodyType, FixtureDef fixtureDef) {

    if(shape == null) {
        PolygonShape polygonShape = new PolygonShape();
        BoundingBox boundingBox = this.model.calculateBoundingBox(new BoundingBox());
        polygonShape.setAsBox(boundingBox.getWidth(), boundingBox.getHeight());
        fixtureDef.shape = polygonShape;
        fixtureDef.density = 1f;
    }else{
        fixtureDef.shape = shape;
    }

    BodyDef bodyDef = new BodyDef();
    bodyDef.type = bodyType;
    bodyDef.position.set(this.getPosition().x, this.getPosition().y);

    this.body = Game.world.createBody(bodyDef);
    this.body.setUserData(this); //<-- Add this line to fix the problem
    this.body.createFixture(fixtureDef).setUserData(this);

    fixtureDef.shape.dispose();
}

Here I get userData:
  if(body[0].getUserData() instanceof Block){
            if(button == Input.Buttons.RIGHT){
                ((Block)body[0].getUserData()).onBlockClicked(player);
            }else if(button == Input.Buttons.LEFT){
                player.onPlayerBlockDestroying((Block)body[0].getUserData(), mouseCords);
            }
        }


texts: Objective-C to plain c iPhone game performance improvements

texts:
I'm testing a 2D OpenGL ES based iPhone game on both the iPhone 3G and the iPhone 4.  It runs great on the iPhone 4... and pretty well on the 3G.  The game state is updated at 60 Hz... and the rendering is done at 60 fps.  Would the following conversion from Objective-C to c improve the performance at all?

// current Objective-C function
- (void) updateSomething {
    // simple update like x_position += 2.0;
}

// plain c function
void updateSomething(){
    // simple update like x_position += 2.0;
}

Assume these functions are called at a rate of 60 Hz.  The reason I'm curious is this blog post.  The author mentions substantial performance improvements when making a similar conversion.

Cheers!

Edit:  after running w/ the CPU Sampler instrument in XCode it looks like about 65% of the function calls are to mach_msg_trap.  objc_msgSend apparently takes up a trivial amount of resources.


texts:
I put together a quick demo of a 4d first person environment last night in XNA. It  uses 3d cross-sectioning instead of projection. (Use A and O to move in and out from 0 to 1 in the W axis.)

In my demo I made a tunnel where it's blocked off at first, but the path appears as you travel in W. I immediately noticed while trying it that it doesn't feel very interesting. It looks the same as if you were just pushing the block out of the way. Of course the block could change shape too but it doesn't help the feel much.

There are some other approaches I could try to make it more interesting:

Miegakure, from the demo videos, uses cross sectioning, but it also seems to allow you to swap one of your spatial axes for W, so you can see the movement in that direction.

I could try to do 3d projection instead of cross sectioning. For this to have any noticeable effect, I would have to also allow rotation that lets you look "around" objects in 4D, giving you something like this. I feel like this could be insanely confusing to a player, and also would make it really tough to design workable puzzles.

The last thing I could try that seems reasonable would be to keep my cross-section approach, but allow the objects to rotate in W, and implement the truncated solid calculations.

I'm looking for feedback on whether these would be usable as mechanics or if it's just way too confusing to a player, or even a level designer. What has been tried successfully, beyond simple demos? So far it looks like Miegakure is the only game that has been taken seriously.


texts: How do I get the correct values from glReadPixels in OpenGL 3.0?

texts:
I'm currently trying to Implement mouse selection into my game editor and I ran into a little problem when I look at the values stored in &pixel[0],&pixel[1],&pixel[2],&pixel[3]; I get

r: 0
g: 0
b: 0
a: 0

As you can see I'm not able to get the correct values from glReadPixels();

My 3D models are red colored using glColor3f(255,0,0);

I was hoping someone could help me figure this out.

Here is the source code:

  case WM_LBUTTONDOWN:

  {

    GetCursorPos(&pos);
    ScreenToClient(hwnd, &pos);

     GLenum err = glGetError();

     while (glGetError() != GL_NO_ERROR) {cerr << err << endl;}

     glReadPixels(pos.x, SCREEN_HEIGHT - 1 - pos.y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel[0] );

    cerr << "r: "<< (int)pixel[0] << endl;
    cerr << "g: "<< (int)pixel[1] << endl;
    cerr << "b: "<< (int)pixel[2] << endl;
    cerr << "a: "<< (int)pixel[3] << endl;

    cout << pos.x << endl;
    cout << pos.y << endl;

  }

break;

I use :

WIN32 API
OPENGL 3.0
C++


texts: Computer Graphics degree or Game Development degree to get into game industry?

texts:
I am currently having a BSc degree in Computer Science. I want to get into AAA game industry. My focus is on the core stuffs like rendering, physics, graphics programming. I plan to get a master's degree for that. Now, should I choose a broader branch, Computer Graphics, or should I go for the specific Game Development for the degree?
Note: It maybe easier for me to get the Computer Graphics degree. And I know that I have to show some complete projects, practical knowledge, passions to get the job in the industry.


texts:
I'm trying to make a camera that follows my character and it seems I've managed. However, I don't know how to limit that my camera don't follow me when my character reachs the boundaries of the windows (it's ugly see black spaces beyond my tile map x_x).

So, this is my code:

public class Camera {
    public void update(Vector2f spritePos) {
        Vector2f pos = new Vector2f(spritePos.getX()-368, spritePos.getY()-268);

        if((pos.getX()+368 > 368) && (pos.getY()+268 > 268)) {
                glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(pos.getX(),
                pos.getX() + Display.getDisplayMode().getWidth(),
                pos.getY() + Display.getDisplayMode().getHeight(),
                pos.getY(),
                -1,
                1);
            glMatrixMode(GL_MODELVIEW);
        }
    }
}

I substract 368 to the X position, because I want to place my character at the center of my camera. Same with 268. This is a bad way to archieve this, because my camera "jumps" roughly to the position of my character >.

Thank you very much.


texts: Need to find a web database of german words for taboo game

texts: I am looking for a web database of german words like this in english. Anyone knows sth about this? I develop the game based on such database of words, so this is why I asked about this here.


texts:
Lets take the simple example of a ball bouncing off a wall. The physics is separated from the display. The physics is set to run at say 20 frames per second and the display is running faster than this (usually something like 60 fps).

In order to have smooth rendering, the render function gets a parameter called alpha that is a percentage (float/double value between 0 and 1) of time elapsed for frame (ie. alpha = accumulator / time_per_physics_frame). And we interpolate using this value:

position = currentPosition * alpha + previousPosition * (1 - alpha)

This works well when moving from one position to the next. For example, if x = 2 and we moving at dx = 4 at high fps the ball gets rendered at x from 2 to 6.

Now say the ball has x = 2, dx = -4 and there is a wall at x = 0. The physics simulator updates the ball to x = 2, dx = 4 (Collision retains all energy and no elastic properties). So using the above interpolate there is no rendering of the ball hitting the wall.

How can the interpolate function handle things like wall collisions?


texts:
I have the following code to animate the Camera's FOV change:

public float fieldOfView;
public Camera theCamera;
public float animTime;

private float origFOV;

void OnTriggerEnter(Collider other) {
    origFOV = theCamera.fieldOfView;

    Hashtable h = new Hashtable ();
    h.Add ("from", (float)origFOV);
    h.Add ("to", (float)fieldOfView);
    h.Add ("time", animTime);
    h.Add ("onupdate", "OnFOVUpdate");

    iTween.ValueTo(theCamera.gameObject, h);
}

void OnTriggerExit(Collider other) {
    Hashtable h = new Hashtable ();
    h.Add ("from", (float)fieldOfView);
    h.Add ("to", (float)origFOV);
    h.Add ("time", animTime);
    h.Add ("onupdate", "OnFOVUpdate");

    iTween.ValueTo(theCamera.gameObject, h);
}

void OnFOVUpdate(float val) {
    theCamera.fieldOfView = val;
}

but I always get the following error when the script compiles:

iTween Error: ValueTo() requires an 'onupdate' callback function and a 'from' and 'to' property.  The supplied 'onupdate' callback must accept a single argument that is the same type as the supplied 'from' and 'to' properties!

What am I doing wrong?


texts:
I'm making a card game to get my legs with phaser. I have an row of overlapping, face down cards. I want to detect when any card is covered by another card.

The deck is shuffled before being placed on the board, so the order is known card[1] thru card[54]. It goes card.events.onInputDown.add(tap, this) on each card during setup to detect interaction, and then calls tap(this):

function tap(pointer){
    console.log(pointer.z);
    let zpos = pointer.z
    if (Phaser.Rectangle.intersects(pointer, *abovecard*)) {
        console.log("covered");
    } else {
        pointer.play("front"); // anim to show the card back
    }
}

(abovecard is asterisked as a placeholder because I'm not sure what to put there)

A simple boundary overlap check seems to be the model to use. But when I go abovecard = card[zpos + 1], it doesn't see a card above it. Even when I do in the console Phaser.Rectangle.intersects(card[37], card[38]), which are visibly overlapping, it says false.

Primary question: What am I missing here?

2ndary question: Is there a better way, than what I've described, to detect if one sprite is overlapping another sprite (whether the other sprite is known or not)?


texts: C++ Frogger game - Logs on Water bounding boxes?

texts:
I am making a Frogger game in C++ using SFML but have come across a problem.
I have a block of water and log rectangles moving over it (All sprites) and would like the Frog sprite to do something when it hits the water, however with bounding boxes, even in the frog sprite moves onto a log it still passes the water bounding box and carries out the code for that. Is there any way to have the conditions so it intersects the water but only does something when it's not in collision with the log's?

Thank you.


texts: Ideas for attack damage algorithm (language irrelevant)

texts:
I am working on a game and I need ideas for the damage that will be done to the enemy when your player attacks. The total amount of health that the enemy has is called enemyHealth, and has a value of 1000. You start off with a weapon that does 40 points of damage (may be changed.) The player has an attack stat that you can increase, called playerAttack. This value starts off at 1, and has a possible max value of 100 after you level it up many times and make it farther into the game. The amount of damage that the weapon does is cut and dry, and subtracts 40 points from the total 1000 points of health every time the enemy is hit. But what the playerAttack does is add to that value with a percentage. Here is the algorithm I have now. (I've taken out all of the gui, classes, etc. and given the variables very forward names)

double totalDamage = weaponDamage + (weaponDamage*(playerAttack*.05))
enemyHealth -= (int)totalDamage;

This seemed to work great for the most part. So I statrted testing some values...

//enemyHealth ALWAYS starts at 1000
weaponDamage = 50;
playerAttack = 30;

If I set these values, the amount of damage done on the enemy is 125. Seemed like a good number, so I wanted to see what would happen if the players attack was maxed out, but with the weakest starting weapon.

weaponDamage = 50;
playerAttack = 100;

the totalDamage ends up being 300, which would kill an enemy in just a few hits. Even with your attack that high, I wouldn't want the weakest weapon to be able to kill the enemy that fast. I thought about adding defense, but I feel the game will lose consistency and become unbalanced in the long run. Possibly a well designed algorithm for a weapon decrease modifier would work for lower level weapons or something like that. Just need a break from trying to figure out the best way to go about this, and maybe someone that has experience with games and keeping the leveling consistent could give me some ideas/pointers.


texts: Should I avoid rescaling models when rendering?

texts:
I am quite new to game development and currently developing a simple 3D game with MonoGame and Blender. The game is basically a 3D version of Pong.

At first I developed the models at a constant size (e.g. a sphere with radius = 1) and then added a scale when I rendered it to make it proportionate to the other objects within the world. That way it was easy for me to play around and find good sizes for the objects without having to go back to Blender.

However, when I started to work on collision detection, I realized that it now was a lot harder to figure out how large the object is, because I had to manually recalculate the size of the object in the game world according to the scale factors I used. I could not simply look at the model and take the size values from there.

While the calculations might have been rather easy with a simple sphere, it got trickier when I had models I scaled differently in different dimensions. For example I rescaled a cube to be 10 times longer than high.

Pretty much the same problem with rotation.

How is this usually done in projects? Is it better to create the model already in the final size in Blender, so you don't have to keep track of the objects size within your code? Or is it ok to scale the model in code? If yes, how do you keep track of the changes?


texts: Trying to get enemy sprites to move on C#

texts:
In my XNA game, I'm have the enemy sprites loaded and in the game screen. However, I put in the code to update their position in the Update method of the main class. The objective is to get the sprites to move from the right hand side of the screen to the left, and the player has to jump over them. Here's my code in the update method(note, the enemy sprites are created in a Texture2d list, and their positions in a Vector2d list):

                Vector2 ep1 = enemyPosition[0];
                Vector2 ep2 = enemyPosition[1];
                Vector2 ep3 = enemyPosition[2];

                        if (enemyPosition[0].X < 800)
                        {
                            ep1.X--;

                        }

                        if (enemyPosition[1].X < 800)
                        {
                            ep2.X--;

                        }

                        if (enemyPosition[2].X < 800)
                        {
                            ep3.X--;

                        }


texts: How do I get a sprite's angle after collision?

texts: I'm using Cocos2d (version 3) and I want my hero sprite to be jostled around by incoming enemy sprites. The Chipmunk-based physics work, but I need some way to track the rotation of the sprite after a collision has ended. How do I do this? I tried sprite.rotation, etc.


texts: Rotate player to face direction it's moving in 3D space

texts:
I'm making a 3D game in XNA4.0. How do I rotate a model to face the direction that the user is pressing. I assume I need to set its look at to the direction being pressed, but can't figure out how to do that.

Cheers.


texts: Which Entities should be in my Pooling System?

texts:
Let's suppose that I'm designing a Tanks Battle Game, there will be a lot of projectiles and Tanks. Every Tank is composed with a Body, multiple Weapons such as Machine Guns, Missile Launchers, etc and different Shield Systems. I want to generate the Tanks at run-time and I will need to create and destroy them frequently. Should I add every type of Weapon, Shield, etc.. to my Pool System and recycle them when a Tank is destroyed, and later reuse them to assemble a new "Randomly" generated tank? Is this realistic? or should I just instantiate the Body, Weapons and Shields and don't use the Pool System for it? Do you have some tips for organize the Pool System?

I was looking for a advanced pooling system and I just got basic theory and examples. Any reference, suggestions, corrections or advice will be very grateful.


texts:
I'm working Opengles2 and I have a just a texture ID and a quad from an SDK and its shader, and I can not access their code, just the vertex and pixel shader.

The quad from the SDK is rotated and flipped. Is it possible to rotate the quad and flip its sides in shader ?

I don't have also the MVP matrix.