texts: Composition heavy OOP vs pure entity component systems?

texts:
I admit, I have made the sin of overusing, and even abusing inheritance. The first (text) game project that I made when I was taking my OOP course went as far as "Locked door" and "unlocked door" from "Door" and "Room with one door", "Room with two doors", and so on from "Room".

With the (graphical) game I worked on recently, I thought I had learned my lesson and put a limit on using inheritance. However I noticed the problems soon beginning to appear. My root class was beginning to bloat more and more, and my leaf classes were full of duplicate codes.

I thought I was still doing things wrong, and after looking it up online I discovered that I wasn't the only one with this problem. It's how I ended up discovering Entity systems after some thorough research (read: googlefu)

When I began reading on it, I was able to see how clearly it was able to solve the problems I was having with the traditional OOP hierarchy with components. These were in the first readings however. When I stumbled upon more… “radical” ES approaches, such as the one at T-machine.

I began disagreeing with the methods they were using. A pure component system seemed either overkill, or rather, unintuitive, which is probably the strength of OOP. The author goes so far as to say that ES system is the opposite of OOP, and while it may be usable along OOP, it really shouldn’t. I'm not saying it's wrong, but I just didn't feel like a solution I would like to implement.

So to me, and to solve the problems I was having at the beginning of the post, without going against my intuitions, is to still use a hierarchy, however it won’t be a monolithic hierarchy like the ones I used before, but rather a polylithic one (I couldn’t find a word opposite to monolithic), which consists of several, smaller trees.

The following example shows what I mean (this is inspired by an example I found in Game Engine Architecture, Chapter 14).

I would have a small tree for vehicles. The root vehicle class would have a rendering component, a collision component, position component etc..

Then a tank, a subclass of vehicle would inherit those components from it, and be given it's own "cannon" component.

The same goes for the Characters. A character would have it's own components, then the Player Class would inherit it, and be given an Input controller, while other enemy classes would inherit from the Character class and be given an AI controller.

I don't really see any problems with this design. Despite not using a pure Entity Controller System, the problem with the bubbling up effect, and the large root class is solved by using a multi-tree hierarchy, and the problem of the heavy, code duplicating leafs is gone since the leafs don't have any code to begin with, just components. If a change needs to be done to the leaf level, then it's as simple as changing a single component, instead of copy pasting the code everywhere.

Of course, being as inexperienced as I am, I did not see any problems when I first started using the single hierarchy, inheritance heavy model, so if there are problems with the model that I'm currently thinking of implementing, I wouldn't be able to see it.

Your opinions?

P.S: I am using Java, so using multiple inheritance to implement this instead of using normal components is not possible.

P.P.S: Intercomponent communications will be done by linking dependent components to each other. This will lead to coupling, but I think it's an ok trade off.


texts: Why does a physics engine produce different results each run through?

texts:
There are no random numbers in the engine and everything is calculated the same way. How can it happen differently each time?

This is on my own small physics engine that I made earlier that is written in lua and runs in the Moai SDK


texts:
I'm having an issue with calculating the predicted linear angle a projectile needs to move in to intersect a moving enemy ship for my 2D game.

I've tried following the document here, but what I've have come up with is simply awful.

protected Vector2 GetPredictedPosition(float angleToEnemy, ShipCompartment origin, ShipCompartment target)
{
    // Below obviously won't compile (document wants a Vector, not sure how to get that from a single float?)
    Vector2 velocity = target.Thrust - 25f; // Closing velocity (25 is example projectile velocity)
    Vector2 distance = target.Position - origin.Position; // Range to close
    double time = distance.Length() / velocity.Length(); // Time

    // Garbage code, doesn't compile, this method is incorrect
    return target.Position + (target.Thrust * time);
}

I would be grateful if the community can help point out how this is done correctly.


texts: How to handle multiple game sessions where players turn can timeout, using Python and Socket.IO?

texts:
I want to make a multi player card game, allowing several people to play with each other (each game session should be able to have between 5 - 10 players).

I'm doing this in Python (Django and Socket.IO).

Because you have to wait for all players to finish before you can move on to the next round, issues will arise if one player leaves his computer or is disconnected, thus leaving all the other players waiting.

To solve this, I want to give each player a time limit to act within.

If there are 1,000 games going on at the same time, and 5 players in each game, that would hypothetically mean that at one point, you could have 5,000 timers counting down at the same time (or if not timers, some other way of dealing with this issue).

What is the best way to do this in Python?
Spawn loads of threads with timers?
Have something more complex like a dictionary with 100 games in each dictionary, and for every second, iterate through the list and check each player? (seems a bit finicky)?

I really want to hear what the best approach to this would be.


texts:
I would like to have realistic voxel clouds in Unity game - I found a very promising article on fast fluid simulations, however the the output of the algorithm itself is 3D grid of cloud densities (=3D texture). My question is - how can I render such 3D texture into clouds?

My research so far:
The original article suggest two pass rendering of particles for each voxel, in first pass reading output after each particle(!) is rendered. This approach is both slow and outdated not leveraging modern shader pipeline in addition to being overly complicated.
Searching for voxel clouds in Unity suggests using ray marching while the actual implementations does not seem to do any ray marching, but rather using Fractal Brownian Motion to same 2D noise texture. This approach gives decently looking results (with some problems addressed in horizon zero dawn slides), but would not make use of my realistic simulation.
The most promising source I could find was this answer, namely last paragraphs. However the answer itself rather vague on actual algorithm and links it provides are either broken or inacessible.


texts: Reducing the number of edges in a pathfinder

texts:
I've worked out an algorithm for pathfinding in a quite free-form terrain (not constrained to grids), with the limitation that it doesn't allow the moving character to rotate. I'll use it for AABBs so that's not a problem, and I'll assume AABBs below.

However, one of the steps consists of creating a graph in which the path is to be found, and that's where the problem is: it seems to me that the number of graph edges to construct is going to be O(V²) where V is the number of vertices. Yet when looking at a typical graph, it is apparent that many of these edges do not need any consideration at all. So the question is if there is a way to reduce the number of edges.

The algorithm goes like this. The input is a traveler, a series of boxes (the maze) and a destination point:

http://www.formauri.es/personal/pgimeno/temp/rect4572.png

(in this example, the reference point of the traveler is at the bottom right of the rectangle because I made a mistake estimating the MDs by hand; sorry about that)

Calculate the Minkowski difference of the traveler and each box in the maze: http://www.formauri.es/personal/pgimeno/temp/rect4574.png - this reduces the problem to having a point crossing that maze, simplifying analysis.
Create the graph:

2.1. Each vertex is a corner of one of the boxes in the Minkowski difference.
2.2. For each pair of vertices, there is an edge iff the line between them does not have any point inside one of the boxes. In other words, if there is a direct line of sight between them.

Result: http://www.formauri.es/personal/pgimeno/temp/rect4758.png (done by hand - I may have forgotten edges)
Run a pathfinding algorithm on that graph. http://www.formauri.es/personal/pgimeno/temp/rect4776.png

The path found is directly usable in the original map: http://www.formauri.es/personal/pgimeno/temp/rect5158.png

The problem is step 2.2. Is it possible to reduce the number of edges?

I'm not aware of any pitfalls in the algorithm, but if you see one, please let me know as well.


texts: How can I create an "afterimage" effect like this one?

texts: How can I make an effect like this? With a particle system?


texts: How can I draw a part of a texture in slick2d?

texts:
I know the method for drawing a region of a texture in slick2d:

image.draw(x, y, srcX, srcY, srcX2, srcY2);

But I have no idea how the texture coordinates work. To draw a region of x:16, y:16, width:32, height:16 from a texture. I tried:

image.draw(0, 0, 16, 16, 32, 16);

and I have tried many other things with no luck. All I get is weirdly cropped and stretched images. Help?


texts: Texture Not Rendering in C++ SDL OpenGL(glut)

texts:
I don't understand why my texture("texture.bmp"), is not showing on the screen. Please help me.

The whole drawing function:

///HERE EVERYTHING IS BEING RENDERED
void Main::display(){

    int startTime = GetTickCount();

    ///BACKGROUND COLOR
    glClearColor(0.3f, 0.3f, 2.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    ///LOAD THE IDENTITY MATRIX FOR THE DRAWING
    glLoadIdentity();

    ///SO EVERYTHING HAS THE CORRECT SIZE
    glTranslatef(0.0f, 0.0f, -5.0f);

    ///CAMERA MOVEMENT
    glTranslatef(cameraX, 0.0f, 0.0f);

    ///THE SUN
    glBegin(GL_QUADS);
        glColor3f(1.0f,1.0f,0.0f);

        glVertex2f(-3.0f, 2.0f); // The bottom left corner
        glVertex2f(-3.0f, 2.5f); // The top left corner
        glVertex2f(-2.5f, 2.5f); // The top right corner
        glVertex2f(-2.5f, 2.0f); // The bottom right corner
    glEnd();

    ///THE GROUND
    glBegin(GL_QUADS);
        glColor3f(0.5f,2.0f,0.5f);

        glVertex2f(-20.0f,-4.0f);
        glVertex2f(-20.0f,-1.0f);
        glVertex2f(130.0f,-1.0f);
        glVertex2f(130.0f,-4.0f);

        glColor3f(0.0f,1.0f,0.0f);

        for(float i = 0.0f ; i < 100.0f ; i += 5.0f){
            glVertex2f(i,-1.0f);
            glVertex2f(i,ranFloat[static_cast<int>(i-4.0f)]);
            glVertex2f(i+1.0f,ranFloat[static_cast<int>(i-4.0f)]);
            glVertex2f(i+1.0f,-1.0f);
        }
    glEnd();

    ///THE GRASS
    glBegin(GL_QUADS);
        glColor3f(0.0f,0.5f,0.0f);

        glVertex2f(-20.0f,-1.2f);
        glVertex2f(-20.0f,-1.0f);
        glVertex2f(130.0f,-1.0f);
        glVertex2f(130.0f,-1.2f);
    glEnd();

    ///THE PLAYER
    glTranslatef(playerX,playerY,0.0f);
    glBegin(GL_QUADS);
        glColor3f(1.0f,0.0f,0.0f);

        glVertex2f(-3.0f,-1.0f);
        glVertex2f(-3.0f,0.0f);
        glVertex2f(-2.8f,0.0f);
        glVertex2f(-2.8f,-1.0f);
    glEnd();

    ///TEXTUREEEEEEEEEEEEEEEEEEEEEE
    glBindTexture(GL_TEXTURE_2D,texture);
    glEnable(GL_TEXTURE_2D);

    int X = 0;
    int Y = 0;
    int Width = 1;
    int Height = 1;

    glBegin(GL_QUADS);
        glTexCoord2f(0, 0); glVertex3f(X, Y, 0);
        glTexCoord2f(0, 1); glVertex3f(X + Width, Y, 0);
        glTexCoord2f(1, 1); glVertex3f(X + Width, Y + Height, 0);
        glTexCoord2f(1, 0); glVertex3f(X, Y + Height, 0);
    glEnd();
    glDisable(GL_TEXTURE_2D);

    ///CLOUDS
    glBegin(GL_QUADS);
        glColor3f(1.0f,1.0f,1.0f);
        for(float i = 0.0f ; i < 100.0f ; i += 5.0f){
            glVertex2f(i,3.0f);
            glVertex2f(i,4.0f);
            glVertex2f(i+4.0f,3.0f);
            glVertex2f(i+4.0f,4.0f);
        }
    glEnd();

    if(Input::flying){
        Input::returnFly(0.007f);
    }

    elapsedMS = GetTickCount() - startTime; // Time since start of loop
    //std::cout << "FPS: " << elapsedMS << std::endl;

    ///THE ACTUAL MOVEMENT
    playerY += playerFly;//*elapsedMS;
    playerX += cameraSpeed*-1;//*elapsedMS;
    cameraX += cameraSpeed;//*elapsedMS;

    ///SWAP THE BUFFERS FOR SMOOTH RENDERING
    glutSwapBuffers();
  }

The rest of my code has nothing to do with the texture loading. The loading is not the problem, because I didn't get any errors.


texts: Unity: How to make input field respond to only double taps in Android?

texts:
I am using Unity in my Android project. There are input fields in my app. As soon as I click on the field the keyboard pops up. I want the keyboard to only show up when there is a double-tap on the field. But I am not able to get it to work and I have tried several ways.

Requirement 1: Single tap shouldn't open keyboard

Requirement 2: Double tap should open keyboard

I tried OnPointerClick method of IPointerClickHandler but this doesn't seem to work. I used this code in one of the scripts attached to input field with IPointerClickHandler.

public void OnPointerClick(PointerEventData eventData)
{
    if (eventData.clickCount == 2)
    {
        Debug.Log("UNITY - Double click");
    }
    else if (eventData.clickCount == 1)
    {
        Debug.Log("UNITY - Single click");
    }
}

Then there is also the question of how to hide the keyboard or prevent it from opening on single tap. This also I am not able to solve. I started with clicking the Hide Soft Keyboard in control setting of InputField in Unity editor. But surprisingly this starts opening a keyboard which has mobile input.

Can someone help? I have been stuck on this for some time I can't seem to be getting anywhere.


texts: Server costs and back loading for mobile devices

texts:
A company approached me to design an MMO for the mobile platform and I have the perfect idea for them. My question is how much would a server for a FTP game that has both a PVE element and PVP cost? Also do you think that it would be better or is it even possible to back load the data onto the phones (trying to come up with some interesting way to back up the data in case of emergency). I don't want the game to be totally online reliant (I want to appeal to not only phone users but also iPod touch users) and for there to be an offline mode.

If you can't tell this is my first game besides simple projects I've done on the side. Any help would be greatly appreciated.


texts: How can I compute a Jacobian matrix with dual quaternions?

texts:
I'm trying to understand an inverse kinematics algorithm realized with dual quaternions as presented here.

My Jacobian matrix, however, seems to be calculated wrong. Could somebody explain, step-by-step, how I would compute a Jacobian matrix with dual quaternions so that I can check my implementation?

I've read dozens of papers that cover dual quaternions but it's all theory. I'd love to see is an example (e.g. for a single one-, or two-linked chain).


texts: How to make HLSL effect just for lighting without texture mapping?

texts:
I created an effect and just want to use lightning but in default effect that XNA create we should do texture mapping or the model appears 'RED', because of this lines of code in the effect file:

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
float4 output = float4(1,0,0,1);

return output;
}

If I want to see my model, I must do texture mapping by UV coordinates. But my model does not have UV coordinates assigned or its UV coordinates are not exported.

I do texture mapping by this line of code in vertexshaderfunction:

 output.UV= input.UV

When I use BasicEffect I have no problem and model appears correctly.

How can I use "just" lightings in my custom effects?

here is inside of my Model Using BasicEffect

This is my code for drawing with or without BasicEffect inside of my draw() method:

    Matrix baseWorld = Matrix.CreateScale(Scale) * Matrix.CreateFromYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z)
            * Matrix.CreateTranslation(Position);

        foreach(ModelMesh mesh in Model.Meshes)
        {
            Matrix localWorld = ModelTransforms[mesh.ParentBone.Index] * baseWorld;

            foreach(ModelMeshPart part in mesh.MeshParts)
            {
                Effect effect = part.Effect;

                if (effect is BasicEffect)
                {
                    ((BasicEffect)effect).World = localWorld;
                    ((BasicEffect)effect).View = View;
                    ((BasicEffect)effect).Projection = Projection;
                    ((BasicEffect)effect).EnableDefaultLighting();
                }
                else
                {
                    setEffectParameter(effect, "World", localWorld);
                    setEffectParameter(effect, "View", View);
                    setEffectParameter(effect, "Projection", Projection);
                    setEffectParameter(effect, "CameraPosition", CameraPosition);
                }
            }
            mesh.Draw();
        }

setEffectParameter is another method that sets effect parameter if i use my custom effect.


texts: Click counting and actions based off count

texts:
So I have a button that is the 'mine' for my incremental game. I would like to track the number of times that it is clicked and be able to do two things:

Have events happen say every 5 clicks.
display the total number of times that is has been clicked.

This is what I have so far:

function addstone(){
        //stone = (parseFloat(stone) + 0.1).toFixed(1);
        //stone = stone + 1;
        var count = 0;
        var totalcount = 0;
            $("input[type='button']").click(function(){
                count = count + 1;
                if(count == 5){
                    stone = stone + 1;}
                if(count == 5){
                    count = 0;
                    totalcount = totalcount + 1;}
                }
                document.getElementById("stone").innerHTML = stone;
    }

So what do I need to do from here. My button calls function "mine1Click" which in turn calls the different resource addition functions. so for "mine1Click" I have this:

function mine1Click(){
    addstone();
    addwood();
    }

function addstone(){
        //stone = (parseFloat(stone) + 0.1).toFixed(1);     TOO LARGE
        //stone = stone + 1;                                TOO MUCH STONE
        var count = 0;
        var totalcount = 0;
            $("input[type='button']").click(function(){
                count = count + 1;
                if(count == 5){
                    stone = stone + 1;}
                if(count == 5){
                    count = 0;
                    totalcount = totalcount + 1;}
                }
                document.getElementById("stone").innerHTML = stone;
    }

function addwood(){
    wood = wood + 1;
    document.getElementById("wood").innerHTML = wood;
}

//function addcopper(){                                     UNIMPLEMENTED

//}

How should I go about this?


texts:
I have made a map via TilePallete tool.

Now I want to store information in certain tile.
How I can do this?

ForEx:

I'm hittin a certain tile and I need it to have info about health remaining.
For first hit I change a tile.
For second I set it to null.


texts:
I'm currently developing a game for some school work using the PyGame library for Python. I'm almost done with most of the game's core mechanics, but have gotten hung up on the shooting mechanics. My current code is too long to post fully, but I'll put excerpts of it and explain what I have so far.

all_sprites_list = pygame.sprite.Group()

bullets = []
bullet_list = pygame.sprite.Group()
bullet_speed = 10

class Bullet(pygame.sprite.Sprite):
def __init__(self):
    super().__init__()

    self.image = pygame.Surface([4,10])
    self.image.fill(red)
    self.rect = self.image.get_rect()

def update(self):
    if self.rect.x > chx:
        self.rect.x -= bullet_speed
    elif self.rect.x < chx:
        self.rect.x += bullet_speed
    if self.rect.y > chy:
        self.rect.y -= bullet_speed
    elif self.rect.y < chy:
        self.rect.y += bullet_speed

This code shows the class I have for my bullets and their movement. The problems with this right now are that A) the bullets get stuck around the crosshair position, of which the chx and chy variables show the x and y position of the mouse.

    if event.type == pygame.MOUSEBUTTONDOWN:
        bullet = Bullet()
        if weapon == "hg" and hg_move == True:
            bullet.rect.x = hgrect.x
            bullet.rect.y = hgrect.y
            all_sprites_list.add(bullet)
            bullet_list.add(bullet)

This code shows an example of one of the firing commands later in the main game loop. hg, hg_move, and hgrect.x/y are all variables used for the movement of the character depending on the type of weapon he is holding.

Some of the main issues are seemingly caused by the fact that I can't find a way store a static value of the likes of the crosshair positions, or to keep the bullets going on a trajectory until they leave the screen or hit an object.

Any help would be greatly appreciated!


texts: Background Scrolling like Zelda - A Link To The Past with XNA

texts:
i am trying to create a background that scrolls like the one in zelda - a link to the past.
in other words: i have a bigger "screen" than the camera covers, so i need to scroll over it, when moving. if the player reaches an edge of the screen, the camera is going to stop and the character moves out of the center.

my actual problem is, that i have to draw the objects in an other way than the background. i am getting the camera to track the player, but if i want to add another object like an enemy, i have to draw it with screen coordinates, which are not the same as the background coordinates. (background image is 1280x720 with a source rectangle of 640x360). so the player is usually drawn at 640/2, 360/2. but the player also is at position 600,600 of the background image.
so, if there is an enemy at 200,200 and the player moves to that point i want to draw the enemy on the screen. but, of course, i cant draw it at 200,200 in the screen that displays the sorucerectangle of the texture.

so i am looking for a way to kinda get the object into the texture, that there is only one coordinate system or at least a second coordinate system where all the object are in., which is as big as the texture itsself. with such a coordinate system i could get the absolute positions of the objects and draw it like the sourcerectanlge of a texture.


texts: Opengl occlusion culling huge performance drop

texts:
Hello I tried to implement occlusiong culling to my engine in opengl using java & lwjgl. Occlusion works but... performance drop is huge I mean from 60-70 fps to 3-6 fps. Here is my question what I'am doing wrong ? Here is my code:

                    //this code is after frustrum culling if object passed

                    glColorMask(false, false, false, false);
                    glDepthMask(false);

                    glBeginQuery(GL_SAMPLES_PASSED, query_id);
                    //renderable is cube not normal object
                    renderable.render();
                    glEndQuery(GL_SAMPLES_PASSED);

                    int iSamplesPassed = GL15.glGetQueryObjecti(query_id, GL15.GL_QUERY_RESULT);
                    if(iSamplesPassed == 0) {
                        //object is not visible don't render it
                        renderable.setVisible(false);
                    }
                    glColorMask(true, true, true, true);
                    glDepthMask(true);

query_id is simply:

query_id = glGenQueries(); //it is called only once on start

I look on some examples and I don't see any diffrences in code. Only diffrence is their and my framerate.


texts: Blueprint formula doesn't match material formula

texts:
I'm currently working on a physical water system for Unreal. To represent the water surface, I have a simple flat grid mesh that I then apply a material to which has a formula for world position offset.

The formula currently is pretty simple, I just have a simple sine wave powered by world X position and elapsed time, however despite both formulas being, as far as I can tell, the same, they give different outputs.

As you can see below, both formulas perform the same operations, and both are powered by the same input, world position and Game Time in Seconds. In theory,  the material (second-last image) should be dividing X position by 2000 and multiplying time by 0.1, just as those values are in the material, however instead the closest I could get to having both values line up is 314* and 0.625.

It's important that these values line up, as the blueprint version is meant to be used for buoyant objects to make sure they stay on the surface of the water, and probably other calculations as I progress.

Does anyone know why these formulas don't line up like they should? Does math work differently in the material editor? Does Absolute World Position give values in a different scale compared to Actor Position?

*I thought this might be 100 * PI, but that doesn't seem to line up exactly either so may be a coincidence.

The final result here is piped directly into World Position Offset.

Time parameter is updated every frame to match the blueprint version.

Blueprint function that I need to match the material formula for accurate buoyancy and such.

Included for completeness, an example of how the water height function is used.


texts: How can I move the view in a DirectX game?

texts:
I'm making a game in C++ using Direct3D 9. How do I move the camera at constant rate?

I'm making a Flappy Bird type game and I'd like to move the camera forward through the level.


texts: finding the angle to launch a projectile at a 3d coordinates

texts:
I have a game where the user can shoot a bullet and the bullet flies through 3 dimensional space and eventually hits the ground somewhere. My question is how can I calculate the pitch of the angle to make the bullet hit a specific coordinates with possibly different elevations.

My known factors are:

The gravity force
The initial projectile velocity
The shooting position
The target position

In my case I do not need to factor for target movement, I am trying to make something similar to an artillery weapon that fires into the sky and have the bullet land somewhere else at a target. Because I am trying to make an 'artillery-like' weapon I need the weapon to aim up at the sky, not directly at the target.


texts: How to calculate alpha for n channels, so the sum equals 1 (100% coverage)?

texts:
Having "n" number of overlaying channels (bitmaps in the same place, layers etc.) how to calculate required alpha for each of them, so they "hide" background completely?

Each layer can have equal value, sum should be exactly 1 ("full alpha"). "n" is 2 or more (likely up to dozens).

[Game example of this would be a Smoke Grenade in FPS game - multiple ("n") bitmaps, making area behind it completely invisible for player - if standing before smoked area (standing inside results in partly-covered vision).]


texts:
I'm working on a game like Settlers III/IV.
There are buildings which produce goods which have to be gathered by carrier units.

I have to find the carrier with the shortest path to collect the goods.
So far, not a big deal. I simple do a expanding circle, starting from the production building, and choose the first carrier found due it has the shortest direct way.

If this carrier can't reach the building (e.g. is on another island or so), the search goes on.

But now take a look at my awesome paintskills.
The black line is an obstacle which my minions can't get over.
Red lines are direct paths, blue is absolute path.

The first carrier is A, but it's direct way is blocked.
Second is B, direct way blocked as well and third, C, has the longest path of all.

As you easily can guess, I want to sent B due it has the shortest absolute path.

What's the lowest affort do determinate if a carrier with blocked direct way has a shorter way then a carrier with a longer direct way?

I'd love to have some lecture about that, but I only was able to find (a lot) of pathfinding where the unit itself searches the path, not the target searches the unit with shortest path.

Edit:
Simply trying out until the minion with shortest path is found is no solution.
I don't want to make it stuttering on a i7 or so. Settler 3 is a 17 years old game and somehow they have implemented such a functionality without needing over 9000 gigahertz.
If you have any idea which involves routing tables or whatever, I'm happy.
Goal is simply to find the minion which could arrive as fastest, in the shortest time possible. Not a big deal if therefore 200mb of routing table have to be generated or whatever.


texts:
I'm currently trying to develop a "Taxi-Driver" AI that intentionally makes sub-optimal pathing decisions. I need to have my driver go from point A to point B using a sub-optimal but still logical path. "Logical" in this case isn't a well-defined condition per-se but it is instead defined as a path that would make sense to a passenger (player).

Here's an example where

Green = Optimal
Red = Suboptimal but "logical"
Blue = Suboptimal but "illogical"

I'm currently using A* so I tried modifying node weights but I couldn't find a way to come up with a logical value for the weight. I've also tried to sometimes pick a random open node (in the right direction) instead of calculating the closest node. However this (understandably) made the pathing look even more illogical.

If it can be done I'd like an A* solution but I'm open to other solutions as well (even non-pathfinding solutions!). It is fine if a solution doesn't always give a sub-optimal path for certain conditions (e.g. only one path possible; all paths are the same length etc).


texts:
I'm creating a simple turn-based 2D Tile RPG in JavaScript/jQuery (using HTML5 Canvas) and the hardest part is the formulas. I got the EXP per level down. I have a base level. I'm trying to see what a reasonable way to come up with HP formula using said base level.

Any help?


texts: The collision log is displayed only for the original obstacle and not for the duplicates

texts:
This is my first game attempt and I'm trying to create a game where my player (a box) stops whenever it collides with an obstacle. However, the log for the collision is only displayed when the player collides with the original obstacle, while no message is displayed for colliding with any other obstacles.
Here's my code:

public class PlayerCollision : MonoBehaviour
{
    public PlayerMovement movement; //Reference to player movement script

    //This function will run when collision occurs, the info collision is stored in collisionInfo
    void OnCollisionEnter(Collision collisionInfo)
    {
        if (collisionInfo.gameObject.name == "Obstacle")
        {
            movement.enabled = false; //Stop the player from moving
            FindObjectOfType<GameManager>().EndGame();
        }
    }
}


texts: How can I determine the size of my app store bundle?

texts:
I made a very simple game. It only has Facebook, and Twitter share icons but it does have Ad Networks SDKs and adapters. My entire folder that contains all the SDK's is currently 200mb. The inmobi SDK alone takes 40mb and it is pretty huge for a super simple game.

Do the files in these folders contribute to the size of my app? Will this be the final app size when submitted on the appstore?


texts: How do I fit the camera frustum inside directional light space?

texts:
I'm trying to improve the coverage of a shadow map for a directional light. Currently, it works great if the camera is looking straight down. However, if the camera is close to the ground and looking toward the horizon, I can see where the shadow map ends because it doesn't cover enough of the scene.

I'd like to create a frustum for the directional light so that it entirely encloses the camera's frustum, as this article suggests in figures 14 and 15. (I'm not really worried about the near and far planes for the light; I've picked a number that works well for every test I've tried)

I know the direction of the light, and the position, rotation, and field of view of the camera. I'm using OpenGL.

How do I create a frustum for the light so that it encloses my view frustum?


texts:
I'm currently working on a 3D PC game (written in C++ and DirectX 9.0) and I'm trying to find the best way to store level data in the memory.

The game's action takes place under the ground, so there's always a ceiling above the player. The ground is rather bumpy and there are things like stalagmites present at all times. Levels are small-ish in size and mostly look like corridors. Here are the options that I've managed to find so far:

Two height maps stored on the hard drive as either a bitmap or binary/text file. One height map for the ceiling (top), one for the ground.

OR

A single 3D mesh in some 3D model format (say, .fbx, .x, .obj whatever).

How should I approach level data storage? What would my best option be, performance-wise speaking? I'm also having some trouble when it comes to texturing a level loaded via a height map; using a 3D model makes texturing a breeze.

Thanks!


texts: How to make character not enter the platform when colliding on the side with the platform?

texts:
I had a problem with detecting my character's collision with the enemy being detected in 2 ways:

side by side
when it (character) jumps into the enemy's head.

I imagine it to be basic, so I figured this question would be not only on the site but also in countless other places.

I researched this site and found related things, but not exactly what I would like:

Getting 2D Platformer entity collision Response Correct (side-to-side + jumping/landing on heads)

Handling exact collisions on character controller and/or other objects in unity? (eg. head shot, chest , leg,etc)

But because of this video I got it:

https://www.youtube.com/watch?v=9LbutnLIj84

The game I'm doing is platform, but instead of the character move, it's the platform that moves.

obj_Plataform - Step Event:

if jump==false{
    if !place_meeting(x,y+1,obj_Player){
        vspeed=-5;
    }else{
        vspeed=0;
    }
}else{
    if contJump<20{
        contJump+=1;
    }else{
        jump=false;
        contJump=0;
    }
}

This is a code that causes the platform to go up when it is not in contact with the player.

And it has a condition for the platform jump (it goes down and the jump variable becomes true, and after the counter reaches a certain value the jump variable becomes false).

My problem is that the character can not get into the platform by colliding on the side with it (The character is the white cube):

I thought about using place_meeting in relation to the x-axis, but the whole platform is just an object (error), because I do not know if it would be possible to move some of dozens of tiles at the same time in the correct way.

Plataform:

I also tried something related in a collision event among those involved, including using the character's x, but nothing worked.

I thought a condition to prevent the platform from walking left while it is colliding with the character.

obj_Plataform - Keyboard Event (left arrow):

x-=10;

Above the current code to move the platform to the left.


texts: Where to start learning OpenGL with C++?

texts:
Possible Duplicate:
  What are some good learning resources for OpenGL?

I have learnt C++ and made some cool text based games and such but I would love to start graphical programming. I'm a decent artist (I will have some of my work below) I know the basics of C++ but I really would like to get into OpenGL.

I need someone to show me some good tutorials for OpenGL with C++ so I can really get into game development. My goal is to be able to program a simple 2D game by the end of the year and I have lots of time to do so. I'm en-rolled in a game development course next year and really need some help with starting off.


texts: What's the best type of Movement/collision detection for high-Speed games?

texts:
Before I begin I'd just like to make it clear that I am not familiar with many programming/development terms, so if anyone can link articles to any terms used it would greatly help things move along:

I'm currently working on a game that plays similar to Sonic Mania. Obviously, when the player is moving they can reach really high speeds, but this brings up a problem with my collision detection.

What's essentially happening on the backend is that the player is moving too fast to collide with the enemy; With the way I have my movement set up, (Essentially Player.xposition += Player.xvelocity) the player "Teleports" Through the enemy instead of hitting it. I tried the workaround shown below to get this working, but so far it only works if I'm willing to mele enemies from 50ft away:

    public boolean touches(Entity e) {
        float ex = e.pos.x;
        float ey = e.pos.y;
        float ewidth = e.getWidth();
        float eheight = e.getHeight();
        float tx = this.pos.x;
        float ty = this.pos.y;
        Boolean xtouches= false, ytouches = false;

        for(int i = 0; i<= this.getXvel(); i++) {
//runs through all numbers up to the velocity of the player to see if they will collide in this frame
        if(ex > tx) {
            if (ex+ewidth <= (tx+i) -this.getWidth()) {
                xtouches = true;
                break;
            }else xtouches = false;
        }else if (ex < tx) {
            if (ex-ewidth >= (tx+i) +this.getWidth()){
                xtouches = true;
                break;
            }else xtouches = false;
        }else xtouches = true;
    }
        for(int i = 0; i<= this.getYvel(); i++) {
        if(ey > ty) {
            if (ey+eheight <= (ty+i) -this.getHeight()) {
                ytouches = true;
                break;
            }
            else ytouches = false;
        }else if (ey < ty) {
            if (ey-eheight >= (ty+i) +this.getHeight()){
                ytouches = true;
                break;
            }
            else ytouches = false;
        }else ytouches = true;
        }
        return (xtouches && ytouches);
    }

I've tried looking up different algorithms for hit detection online, but what I found is the same as what I have (without the for loops), and I don't know how else to change my movement methods without changing core mechanics in ways I don't want.
Is there a way to change either my hit registration or style of movement to prevent this problem?


texts: How to find the client's monitor valid refresh rates with Unreal Blueprints?

texts:
I am making a settings menu. This includes a combo box where you can change the refresh rate setting.

How do I find out the maximum allowable refresh rate of the current user's monitor, using Blueprints?


texts: Should I allow "low-level" access in my game for modders?

texts:
I'm thinking of adding a Lua interpreter in my game, giving various objects in the game script access to allow mods.

By how much should I expose to the scripting environment, I'm not sure.

Should I allow low-level access?

For example, should I just give the scripts a function to move a character (takes care of moving, playing walk animation, everything needed).

Or should I allow low-level functions instead: a function to play animation, separate from the function that moves the character, a function to receive damage (that won't care where the damage came from), perhaps even a function that just teleports a character anywhere.

One worry is that players would hack things that aren't meant to be. Then again, why not just let them do that?

EDIT: People have also pointed ease of use for the modders as a good concern, as well as being a security risk for the player's PC, so feel free to discuss those points as well in your answer.


texts: How do I export an animated scene with a rigged character and dds textures to blender from 3DSMAX 7?

texts: Which format should I use, which settings? Which plugin or script?


texts:
I am an MPhil student in Computing Science working on the problem of camera control in graphics. Though the literature of camera control dates back to the end of 1980s, the majority of them (up to my knowledge) is mainly academic and rarely used in games.

Now part of my thesis should be dedicated to camera control methods used in games. But the problem is that I have not implemented all the games in the world, so I can't speak about them. But I suppose there are some references that game developers usually use.

Can anybody help me with this? Even if it is from your own experience rather than a book.


texts: Unity a ball bounce inside a sphere sometime will penetrate and drop outside

texts:
i'have made a ball within a sphere (which imported from blender, with mesh collider), see the pic

after the scene started, the ball bounce inside around 5 seconds, and then the ball will penetrate (see the arrow) the sphere and drop out of sphere, anyone knows the reasons?


texts: Can XNA Content Pipeline split one content file into several .xnb?

texts:
Let's say I have an xml file which looks like this

<Weapons>
 <Weapon>
  <Name>Pistol</Name>
  ...
 </Weapon>
 <Weapon>
  <Name>MachineGun</Name>
  ...
 </Weapon>
</Weapons>

Would it be possible to use a custom importer/writer/reader to create two files, Pistol.xnb and MachineGun.xnb which I can load individually with Content.Load()?

While writing this I realized I could just import a Weapon[] list and split them up with a helper, but I'm still wondering if this is possible?


texts: Character and Weapon animation interaction

texts:
If I have two models, for example: some character, and a bow, how do I work with them together in 3DS Max to animate them both (for example, when the character shoots an arrow with his bow, the characters pulls his hand out, the bow is scratching etc).

Also, any guidelines on how to port custom weapon models to UDK?


texts: How do I add corner tiles to infinitely generated terrain base tiles?

texts:
I have a tileset as seen on the right and they make the images seen on the left:

In game I have placed the full grass and full stone tiles for each chunk (infinitely generated) using perlin noise as seen in the image below:

I am trying to find a way to determine what corner tiles to use and then place them.  As you can see there is so many possibilities that I don't know how to do it.  Using Lua with love2d engine by the way.

This question is different.  Everything I read about bitmasking with corners says that you need at least 48 tiles or more in a set to do corners.  I am wondering how and if it is possible to use the tile set at the right which doesn't need this many tiles to make any possible shape.  It only uses 14 original plus 2 existing tiles.  Here is a image of what tiles are used in bitmasking.


texts: Use an int as a reference to a specific class

texts:
So I'm trying to make an efficient game where there is a grid system and every grid has a number that is able to identify what kind of block is located there. This lets me just have an array of numbers rather than an array of block-objects.

But now here is my problem, when I want to call a method from one of block classes, I only have a number to reference it. And I don't want to have a giant switch block to try and determine which block it is.

So in short, how can I get an specific int to reference a certain class without a massive if chain or switch block?

I believe Minecraft does something like this. All the blocks are saved in memory as a number, and then when the game wants to draw or call a method on one of the blocks, it uses the number at that location to reference to block to call the method. How does it do this?


texts:
I'm trying to figure out how to perform tiled rendering of my 3d scene (OpenGL).  The motivation is to cut the scene up into several textures, combining them into a single image for saving at a very high resolution, or for printing.

I've done some reading on this and apparently I just need to put appropriate parameters into my projection matrix for each tile in the scene.  This is where I'm failing (miserably).  I can't see where or what to use for it.

My perspective projection matrix is pretty standard, like this:

const T fov2 = Math::Tan(fov / 2), extent = (farPlane - nearPlane);

assert(fov2 != 0);

Matrix4x4<T> r;

r.m11 = 1 / (aspect * fov2);    r.m12 = 0;          r.m13 = 0;                                      r.m14 =  0;
r.m21 = 0;                      r.m22 = 1 / fov2;   r.m23 = 0;                                      r.m24 =  0;
r.m31 = 0;                      r.m32 = 0;          r.m33 = -(farPlane + nearPlane) / extent;       r.m34 = -1;
r.m41 = 0;                      r.m42 = 0;          r.m43 = -(2.f * farPlane * nearPlane) / extent; r.m44 =  0;

return r;

I tried an implementation of glFrustum (no longer available as I'm using core profile of course) as follows:

Matrix4x4<T> r(InitialiseAs::InitialiseIdentity);

r.m11 = 2.0f * nearPlane / (right - left);  r.m12 = 0;                                  r.m13 = (right + left) / (right - left);                    r.m14 = 0;
r.m21 = 0;                                  r.m22 = 2.0f * nearPlane / (top - bottom);  r.m23 = (top + bottom) / (top - bottom);                    r.m24 = 0;
r.m31 = 0;                                  r.m32 = 0;                                  r.m33 = -(farPlane + nearPlane) / (farPlane - nearPlane);   r.m34 = -(2.0f * farPlane * nearPlane) / (farPlane - nearPlane);
r.m41 = 0;                                  r.m42 = 0;                                  r.m43 = -1;                                                 r.m44 = 0;

return r;

But, alas I'm not sure what parameters I need to use for left, top, right and bottom when iterating across the scene, viewport or screen.

Can anyone assist me?

Edit: I found this example (unfortunately D3D) of someone doing something similar. The author seems to be just multiplying _11 and _22 by the width (scale up) and then modifying _31 and _32 according to the current tile position - iterating through the whole grid.

I did try this but I got a black screen of doom.


texts:
This question builds upon the following question: How can I achieve a good fire effect with alpha blending and particles?

I want to achieve the visual effect of using SKBlendModeAdd on a black layer, but adding it to another (random) color background.

In the question posted above, it is explained how to do this: either by using an extra texture from which the alpha layer is removed or by using alpha premultiplication.

I've tried implementing both, but to no avail.

This probably has to do with the following:

  A particle is a textured and colored node whose contents are blended into the framebuffer. Although there is no visible class representing particles added by the emitter node, you can think of a particle as having properties like any other object.

From Apple's Documentation

My guess is that because it's a framebuffer, the workaround solutions do not work for Sprite-Kit.

So how would I go about implementing this with SKTexture or SKSpriteNode ?

See below an example of the difference in colours between dark and light backgrounds. I would like to get the exact same colours on the light background as I get on the dark background (because on the dark background it actually looks like fire).


texts: Getting the position of a directional light w.r.t. a moving object.

texts:
I have a forward vector of my object, which is a bike, and its position, and I have a directional light direction.

I would like to know where the light is with regards to the bike position/orientation, whether is it in front, on the right-hand side or on the left-hand side. The light will not move but the bike will.

Here is the code I have so far but it's not working as I expect:

Vector3 lightDirection = mDirectionaLightTransform.transform.position - Source.transform.position;
Vector3 normalizedLightDir = lightDirection.normalized;
Vector3 reflectedForward = Vector3.Reflect(normalizedLightDir, Vector3.forward);

float blobShadowAngle = Vector3.Dot(normalizedLightDir, reflectedForward);


texts: How to resolve collisions when using ray-casting to predict the location of future collisions?

texts:
I ran into a question I can't seem to solve, while implementing the movement/ collision checking code for my game. The game is in 2D and all objects in my game use either AABBs or circles as collision masks. My current procedure for moving a game object uses the following steps:

[Motion definition] Set the motion vector for the game object as vec2(xSpeed, ySpeed)
[Broad-phasing] Broad-phase to find potentially colliding objects
[Collision detection] Raycast the AABB along the motion vector, against all objects found in step 2, and find the first collision
[Collision resolution] Move the game object to this position where the first collision occurs

Below is a screenshot of the collision detection. It casts the object's AABB (bottom-left blue rectangle) along the motion vector (red line) and finds the points where the AABB would enter and exit the other object's AABB (big blue rectangle). It returns me the position, normal and lambda (progression [0.0, 1.0] along the motion vector when entering/ exiting the other object).

Practically, the ray casting of AABBs is performed as a line-raycast on the configuration space obstacle of the two AABBs. I've implemented this for line-circle, line-aabb, circle-circle, and aabb-aabb cases and they work correctly.

My problem is the collision resolution step. The problem is that my objects get stuck in eachother using the current procedure. The reason being that the raycast procedure returns the position where the object "just collides" with the other object. Because of this, on the next update of my game world, the object is already colliding before it even moves. When I perform my collision detection step, the results is that the "first collision" occurs at the starting position of the object.

I've been reading related questions here, but haven't found a definitive answer yet. Here are some of the things I've read and problems I found with them (from "bad" to "better"):

[Don't move if a collision is encountered on the way] This could cause jittery and weird behavior when moving towards an object. As, e.g. if the object is moving at 5 pixels per frame towards a wall, it will end up somewhere between 5 and 0 pixels away from the wall, depending on it's position. I suspect jittery behavior to happen when this solution is extended to collision checking between moving objects.
[Implement IsTouching() methods to check whether an object is colliding but not penetrating another object] I have no idea how to elegantly use this information in the raycasting algorithms to allow "sliding behavior" of shapes, without sacrificing performance (as the algorithms are very optimized right now). Also, I imagine objects "touching" is defined as having a penetration depth of 0.0. Checking for this could cause errors in case of float rounding errors.
[Push away both the object and the colliding object upon colliding] Some of my objects (such as walls and terrain) are static and I'd rather not move them even slightly to resolve collision problems.
[Push the object out of the colliding object along the collision normal] Using this solution, the object can get stuck in another object, as it gets "blindly" pushed out of a colliding object.
[Push the object out of the colliding object backwards along the motion vector] This sounds good as the object won't get stuck in other objects. However, I'm not sure how to choose "how much" to push the object out of the other object. The best thing I can think of is to move it using "a very small float number" such as 0.00001f. But this sounds very ad-hoc.

In short: Where do I move my object, if I know exactly where the first collision would occur, without getting it stuck in other object?


texts:
I am trying to write a simple GLSL shader that just renders the real (not normalized) depth of a fragment as a floating point value.

So far, I've figured out how to get the depth of a vertex, and just interpolate across the fragments, but I'm starting to realize that this is not going to give me the correct depth of each fragment, is it?

Here's what I have so far:

Vertex shader:

uniform mat4 world;
uniform mat4 view;
uniform mat4 projection;
attribute vec3 position;
attribute vec3 color;
varying float distToCamera;
void main()
{
    vec4 cs_position =  view * world * vec4(position, 1.0);
    distToCamera = -cs_position.z;
    gl_Position = projection * cs_position;
}

Fragment shader:

varying float distToCamera;

void main()
{
    gl_FragColor = vec4(distToCamera, distToCamera, distToCamera, 1.0);
}


texts: Unity3D: terrain object's textures flickering on long distances

texts:
I'm making RTS project on Unity3D.

I created terrain with Unity's standard Terrain tool, and added textures of grass, mood etc. on it. Then, for creating "man-made" objects of terrain (roads, sidewalks, road curbs etc) - I'm created this objects in separate assets, and placed on terrain.

And I have one issue with this solution. On moving camera away from the terrain, terrain's texture(e.g. mood) are flickering under roads, sidewalks and other objects. AFAIK, this bug caused by insuficcient accuracy of floating-point coordinates in Unity3D engine (?).

Now, as I concerned, my approach to creating terrain objects is not correct. I must create one mesh with terrain, and all manmade objects in 3D modeling software, and then create UV-map for texturing all of it. Is this approach correct? If "yes", is any special approach for modelling and texturing so large and complex object as terrain?


texts: How can I throttle certain player actions?

texts:
Background
I have a variable time step, component based game, with components that collectively hold an entity's properties and different systems that act on entities with certain required components.
The player controls a ship that can fire bullets. I have an input system that works on entities with a PlayerControlComponent (nothing more specific yet) and creates an entity every frame if a key is held down.

Question
How should I manage limiting or throttling this so that it can't occur closer than 1 second apart in a reusable way?


texts: Getting started to OpenGL - little question

texts:
Im starting to learn opengl, and after 2 days, searching and trying hard, i finally installed all the libraries i need (lol).
So, I'm following this tutorial, and it says to use glfwOpenWindowHint this way:
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); // 4x antialiasing
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // We want OpenGL 3.3
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL

But glfwOpenWindow didn't work with this Hint. So I made a little research, and changed the PROFILE parameter to this:
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, 0);

Ok, fine, now works.
My question is if it is a big deal to change the opengl profile, or this will make no difference. And why I can't use GLFW_OPENGL_CORE_PROFILE instead.


texts: XNA 2D Collision Detection without GetData()

texts:
I'm currently working on a Worms game which involves terrain deformation. I used to do it with .GetData(), modifying the color array, then using .SetData(), but I looked into changing it to make the work done on the GPU instead (using RenderTargets).

All is going well with that, but I have come into another problem. My whole collision detection against the terrain was based on a Color array representing the terrain, but I do not have that color array anymore. I could use .GetData() every time I modify the terrain to update my Color array, but that would defeat the purpose of my initial changes.

What I would be okay with is using .GetData() once at the beginning, and then modifying that array based on the changes I make to the terrain later on by some other means. I do not know how I would do this though, can anyone help?


texts:
I'm dealing with objects on 15x15 chunks in my game.
I'd like the chunks to rotate, for example, rotation version 0 is the original position of 2,5;
(EDIT: Oops, rotation 2 and 3 names need switching in the image)

How can I get the other positions in the simplest and quickest way? It only needs to rotate in 90 degrees increments, having 4 version (so 0, 90, 180, 270)


texts:
I'm currently writing a very small game engine for learning purposes, and hit a block when trying to separate the engine's logic from the "rendering" module.

My current approach is to feed my renderer with a pointer to a "Scene", iterate through its nodes, test them with a static_cast(yeah you read that right) to a "Renderable" object (for example a static mesh class that contains a material and a vertex array) and draw.

I'm aware that this approach is terrible but I can't think of an alternative. At this point I feel like my architecture is complete spaghetti. Any indication would be much appreciated.


texts: How can I compute spotlight attenuation when I only have a spotlight cutoff angle?

texts:
I am trying to compute the spot light attenuation, though I don't have a spotCosCutoff (cosine of the spotlight cutoff angle) predefined variable in the shader so I have to compute it myself. This is the function that I am using now:

float spotLightAttenuation(vec3 L)
{
    float theta= dot(normalize(spotDirection),-L);
    if(theta > cos(spotCutoff))
        return pow(max(theta,0.0),spotExponent);
    return 0.0;
}

But it doesn't really look like a spotlight. This is how it behaves (with a working, already tested, Phong shader) if the spot light direction is far from the light direction, with a low cutoff angle:

The cutoff angle is passed as a uniform, and it's 0.1 in this case. It is not really the angle between the spot direction and the end of the cone, it is an absolute angle. I should compute the cosSpotCutoff by making the dot product between the direction where the cone ends and the spot light direction, but since spotCutoff is just an angle, I'm not able to do it.

How do I convert it to a vector? Could anyone show me how to compute properly the attenuation?


texts: I cannot find any tutorial in Google and Youtube. I have a C++ program that uses OpenGL ES 2.0 API to render something on the screen. How can I debug my shaders? Any step-by-step guide? What is the easiest way to at least print variable values?


texts: How do 3D rendering pipelines render light effects?

texts: How does 3D software like Blender, Maya, Unity, or Houidini etc. render the effects of lights illuminating a 3D scene?


texts: Blender to Unity, Specular Hardness/Smoothness Texture

texts: In Unity there's a parameter for specularity (both modes) - Smoothness... I don't know what it corresponds to in Blender. You can bake two specularity maps: color and intensity, and at first I naively thought it to be intensity, but the result in Unity doesn't look quite right (beside the fact that it doesn't actually make sense). So I've decided that it's Hardness, but there's no baking option for Hardness in Blender, and I don't know what I'm supposed to do. I guess I could edit the alpha of the specular color texture down to prevent the object from looking like it's made from wet glass (although just the color is going to help there, I think), but maybe I'm missing something.


texts: How do I determine the distance between two points in tilemaps in unity?

texts:
If I have a tilemap with multiple layers, is there any way that Unity offers to help me infer the distance between the two points?

Also, as a related question: Are there any libraries written in C# that might also perform this logic, but without coupling to anything that might exist in Unity?

I'm specifically interested in specialized types or operations that can be performed on some kind of three dimensional array that I've loaded ahead of time.


texts: What causes undefined geometry to be drawn?

texts:
I am currently using the polygonSpriteBatch of libgdx to draw triangles, rectangles and a concave polygon as border. After adding the concave polygon for the colored borders everything seems to break and random geometry appears (sometimes even with a gradient).

Some Examples

Here you can see on the left everything looks good and after drawing the additional rectangle with its border and removing the other borders you can still see some weird red regions.

This is even more extreme. On the left part of the concave polygon is drawn with a different color, and after it despawns (on the right) there is still part of it left and other triangles not created by me are drawn.

I am quite confident that all convex polygons are defined in counter-clockwise ordering.

In the past I had trouble with providing the correct TextureRegion and it still doesn't feel like my current implementation is how it should be, but it worked for simple rectangles and triangles. Currently I have a (3px)*(3px) Region and all polygon vertices are between (0f,0f) and (3f,3f).

Because I define all triangles of the polygons myself the short array given to the PolygonRegion for a rectangle looks like this: (0, 1, 2, 3, 4, 5) and the corresponding Vector2 polygon array like this: ((0.0, 3.0), (0.0, 0.0), (3.0, 0.0), (0.0, 3.0), (3.0, 0.0), (3.0, 3.0))

I experienced even more artifacts when executing this on android and for some reason drawing a small rectangle for each vertice (for debugging) fixed some of the artifacts above.

This is quite a complex problem but I hope somebody knows what could cause such a behaviour.


texts:
I'm trying to get the width and height of a 2D GameObject.
My GameObject is simply a prefab created using sprite.

I have tried solutions from other posts but they don't work for me:

Vector2 size = myGameObject.GetComponent<CircleCollider2D>().bounds.size;
float width = size.x;
float height = size.y;

and

Vector2 size = myGameObject.GetComponent<Collider2D>().bounds.size;
float width = size.x;
float height = size.y;

My prefab has a Circle Collider 2D but x and y always returns 0

I'm using Unity 5.5.0f3, not sure if previous solutions apply to this version.


texts: How would I go about creating dynamic weapons using EC architecture?

texts:
I currently have a weapon component that contains common functionality across weapons  (mainly guns).

class Weapon : Component
{
    float fireRate;
    float reloadTime;

    void Reload() // Implements reload logic since it is common across all guns
}

The main thing that differentiates guns is firing (some deal splash damage, some fire in a cone, etc.)

The problem I am facing is how to implement the unique firing functionality? Should I make a ConeDamage component, a LinearShot component? If so how will it work?

Keep in mind I am using an EC architecture not ECS.


texts: How does Unity3D implement their system where if a class is derived from MonoBehaviour and has certain methods like Awake() or Update(), they are called accordingly? I want to do a similar system for classes inheriting from the class 'Ability' to store the classes in an array and call the callback method Execute() when they are being executed.


texts: Change screen dimensions in libgdx in HTML

texts:
Can i change the screen dimensions in libGDX in HTML?

If I inspect the element (the game) in Chrome and I change canvas width or height it changes the screen dimensions, but I don't know how to do it in the HTML file. I have the default file generated by libGDX.

The CSS path to the canvas containing the screen size is: #embed-html > table > tbody > tr > td > canvas

The HTML is:

          &#8635;


texts: game crash on android phone while using unity UI

texts:
I am trying to use an unity UI in my game. Initially I Created Canvas with all settings what I need then I compiled it on my phone its working perfectly. Inside the Canvas if I created any button or image means in editor its working fine but in android mobile the game get crash. I don't know what's happening?

Note: I already create the game with simple ui system. in that ui using box collider and listenerClicks() I handling all functions. Now i am trying to convert this system to Unity UI system.

Here my Logcat

I am using Unity 5.2, c#


texts: How to resolve multiple simultaneous ball collisions in a pool game?

texts:
I'm trying to simulate a break shot in billiards (1 ball hits a pyramid of 15 balls).
The formula for 2D ball collision works correctly in my game. But when it is applied to the break-shot, the result doesn't look realistic. (Only the 2 balls in the corners of the pyramid move, but the rest stays in place).

The problem is that because 15 balls are touching each other, there is an "infinite" number of simultaneous collisions following the first one.

What algorithm or formula can be used to resolve that?


texts: How can I fill the white color image to fill within that border in a shape of a glass?

texts: I'm using this in 2D canvas. Because I'm doing a health bar and it suppose to fill from the bottom to up but I don't know where to start from here.


texts: DirectX D3DXVec3Normalize unresolved external symbol

texts:
I have simple DirectX project:

#include <d3dx10.h>
#include <d3dx10math.h>

#pragma comment(lib, "d3d10.lib")
#pragma comment(lib, "d3dx10.lib")

int main()
{
    D3DXVECTOR3 u(1.0f, 2.0f, 3.0f);
    D3DXVECTOR3 v(2.0f, 1.0f, 3.0f);
    D3DXVECTOR3 a, b, c, d, e;

    float l = D3DXVec3Length(&u);
    float s = D3DXVec3Dot(&u, &v);

    D3DXVec3Normalize(&d, &u); // <- problem is here

    return 0;
 }

I added "include" and "lib" directories in my project properties and everything works fine, except D3DXVec3Normalize line. When I run the program it says: "error LNK2019: unresolved external symbol _D3DXVec3Normalize@8 referenced in function _main".

Can anyone explain why D3DXVec3Length and D3DXVec3Dot functions work OK (without Normalize line) and D3DXVec3Normalize produces error?

P.S. I use DirectX SDK June 2010 and Visual Studio 2012.


texts:
Say there is a card game and they have a feature that allows setting join requirement when hosting a game. These are:  Only people I like, No one I Dislike, Invite Only, Everyone.

If I created a card game and had a similar join requirement feature with similar features: eg: Only Buddies, No Enemies, Invitation, Everyone, is this copyright infringement or is it just an idea and not an expression of one?

Thanks


texts: How do I get my polygons to be lighted by either side?

texts:
Okay, I am using Ogre3D and Gorilla(2D library for ogre3D) and I am making Gorilla::Screenrenderables in the open scene.

The problem that I am having is that when I make a light and have my SR(screenrenderable) near it, it does not light up unless the face of the SR is facing the light...

I am wondering if there is a way to maybe set the material or code(which would be harder) so the SR is lit up whether the vertices of the polygon are facing the light or not. I feel it is possible but the main obstacle is how I would go about doing this.


texts:
Just recently trying to make sense of implementing a chunked level of detail system in Unity. I'm going to be generating four mesh planes, each with a height map but I guess that isn't too important at the moment. I have a lot of questions after reading up about this technique, I hope this isn't too much to ask all in one go, but I would be extremely grateful for someone to help me make sense of this technique.

1 : I can't understand at which point down the Chunked LOD pipeline that the mesh gets split into chunks. Is this during the initial mesh generation, or is there a separate algorithm which does this.
2 : I understand that a Quadtree data structure is used to store the Chunked LOD data, I think i'm missing the point a bit, but Is the quadtree storing vertex and triangles data for each subdivision level?
3a : How is the camera distance usually calculated. When reading up about quadtree's, Axis-aligned bounding box's are mentioned a lot. In this case would each chunk have a collision bounding box to detect the camera or player is nearby? or is there a better way of doing this? (raycast maybe?)
3b : Do the chunks calculate the camera distance themselves?
4 : Does each chunk have the same "resolution". for example at top level the mesh will be 32x32, will each subdivided node also be 32x32. Example below:


texts: How to move a player on a sphere surface using Ammo.js and Three,js

texts:
I am moving a rigidbody (the character) on the surface of a sphere, like what is described here.
I am facing the following issue that I am having hard time to solve:
After moving the character, it starts spinning really slightly around it's Y axis.
As a side note, I am using Ammo.js which is a javascript/webassembly port of Bullet 2.82, but this has no impact on the problem.
To "stick" the player (a dynamic rigidbody with a cylinder shape) to the sphere (a static rigid body with a sphere shape), here is the code, called on each game loop iteration:
function applyAttraction() {
    let sphereOrigin = this.body.getWorldTransform().getOrigin();
    let characterOrigin = this._characterEntity.body.getWorldTransform().getOrigin();

    // compute and apply sphere gravity to character body
    let sphereAttractionForce = new ammo.btVector3(
      characterOrigin.x() - sphereOrigin.x(),
      characterOrigin.y() - sphereOrigin.y(),
      characterOrigin.z() - sphereOrigin.z()
    );
    sphereAttractionForce.normalize();
    sphereAttractionForce.op_mul(gravity);
    this._characterEntity.body.applyForce(sphereAttractionForce, ammo.btVector3(0, 0, 0));

    // align character up with sphere origin
    const gravityDirection = bt2ThreeVec3(sphereAttractionForce).normalize().multiplyScalar(-1);

    // extract up axis of character transform basis
    let characterUp = new THREE.Vector3();
    this._characterEntity.graphic.matrixWorld.extractBasis(
      new THREE.Vector3(),
      characterUp,
      new THREE.Vector3()
    );

    // apply rotation to align up with gravity vector
    let verticalAlignmentRotation = new Quaternion()
      .setFromUnitVectors(characterUp, gravityDirection)
      .multiply(bt2ThreeQuat(this._characterEntity.body.getWorldTransform().getRotation()));

    this._characterEntity.body.getWorldTransform().setRotation(three2BtQuat(verticalAlignmentRotation));
  }

And to move the character on the sphere (I removed the code dealing with the mouse controlled orientation since it is irrelevant to track down the problem). This code is also called on every game loop iteration:
let scalingFactor = 0.02;
    let moveX = inputController.getMoveX();
    let moveZ = inputController.getMoveZ();

    if (moveX === 0 && moveZ === 0) return;

    let movement = new THREE.Vector3(moveX, 0, moveZ).normalize();
    movement.multiplyScalar(scalingFactor);
    let wantedWorldPos = this.graphic.localToWorld(movement);
    this.body
      .getWorldTransform()
      .setOrigin(new ammo.btVector3(wantedWorldPos.x, wantedWorldPos.y, wantedWorldPos.z));

In plain (approximative) English, what I am doing:

Get the direction from the player position to the center of the sphere
Apply a force using that vector: this._characterEntity.body.applyForce(sphereAttractionForce, ammo.btVector3(0, 0, 0));
Align the player Up with the gravity direction, to do so I:

normalize and "flip" gravity vector direction
extract character up vector and compute the quaternion which give the rotation to align this up vector with the gravity vector
compute the new player orientation by applying quaternion from 3.2 to it's current orientation

Apply movement (from keyboard inputs), in details:

get a vector resulting from the requested movement alongside x and z axis
convert this vector from player local basis to world basis: this.graphic.localToWorld(movement);
set the new transform origin with this new vector

The project may be seen here (with the spinning issue I am describing). You may need to move a bit on the sphere (with WASD keys).


texts: How can I calculate DeltaTime in seconds?

texts:
Here is how I've been trying to implement delta time based on different internet resources.

var startTime:Number = getTimer();
game.Update(deltaTime);
deltaTime = Number(getTimer() - startTime) * 0.001;

My issue with this is it doesn't seem to be giving me accurate timing. The main update shows the frame time at 0.001 and when reinitializing the level it goes to 0.002. I'm using dt else where for a timer and later on time based physics so I would like it to work as expected. I must be missing something silly.


texts: Is there an easy way to create an AI opponent for the Othello game?

texts: Is there a well known AI technique to create an opponent in the game Othello (aka Reversi)?


texts: Should I worry about Youtube Let's Plays when I'm creating a story-heavy game?

texts:
A few years ago, I watched a full playthrough of the first three Phoenix Wright games on Youtube. I enjoyed the story and characters a lot, hence why I pretty much binge-watched what is a series of very story-heavy games. I know it sounds stupid, but that's what happened.

As a consequence, I had no reason to buy and play any of those games. In hindsight, I realize I pretty much pirated the games without ever even playing them. It's not like I enjoyed the games because of their epic gameplay, I enjoyed them because of the story, and since I know what's going to happen, I don't have a reason to play them myself.

I still bought them in the end out of principle (even if it's Capcom...), but how many people are seriously going to do that? I doubt very many.

Now, I'm in the middle of creating my own story-heavy game, and I'm unsure because of how popular gaming channels have become on Youtube. I fear some big youtuber will play my game, a big portion of my potential playerbase will see the story and not be bothered to buy the game themselves. I mean, why should they if they've seen the story? Sure, I get some free publicity/marketing for my game, but what good is that if nobody's going to buy the game?

Is my concern valid? Or am I too pessimistic about people?


texts: Loop in coroutine stops after going halfway

texts:
I have a very weird problem with a particular loop in a coroutine:

    public IEnumerator DestroyCubesGameOver() {
    var startingCubeHolder = GameObject.FindWithTag("StartingCubeHolder");
    DestroyOutOfCameraCubes();

    Debug.Log(cubeGroup.transform.childCount);

    for (int i = 0; i < cubeGroup.transform.childCount; i++) {
        Debug.Log(i);
        Destroy(cubeGroup.transform.GetChild(i).gameObject);
        yield return new WaitForSeconds(0.001f);
    }

    Destroy(startingCubeHolder);
}

The loop starts doing its thing and it needs to do it 100 times for example. However it stops after going about halfway and after destroying about half of the objects. Even if I increase the delay for each repeat it still does the same exact thing - needs to repeat itself and destroy 100 objects, ends after destroying just 50. What is causing this?

Edit: If I make it just a void method it destroys all of the objects.

Edit 2: This loop was initially a foreach but I rewrote it to try the other way - same thing.


texts:
I have seen many examples of how to render sprites from a spritesheet but I havent grasped why it is the most common way of dealing with sprites in 2d games.

I have started out with 2d sprite rendering in the few demo applications I've made by dealing with each animation frame for any given sprite type as its own texture - and this collection of textures is stored in a dictionary. This seems to work for me, and suits my workflow pretty well, as I tend to make my animations as gif/mng files and then extract the frames to individual pngs.

Is there a noticeable performance advantage to rendering from a single sheet rather than from individual textures? With modern hardware that is capable of drawing millions of polygons to the screen a hundred times a second, does it even matter for my 2d games which just deal with a few dozen 50x100px rectangles?

The implementation details of loading a texture into graphics memory and displaying it in XNA seems pretty abstracted. All I know is that textures are bound to the graphics device when they are loaded, then during the game loop, the textures get rendered in batches. So it's not clear to me whether my choice affects performance.

I suspect that there are some very good reasons most 2d game developers seem to be using them, I just don't understand why.


texts: How can I simulate a bad internet connection for testing purposes?

texts: I am developing an online multiplayer game. It works well when I test it on the local area network, but before I release it I would like to test how the user-experience works out for someone who has not such a good connection to the server. How can I simulate a bad internet connection with high latency, low bandwidth, jitter and occasional packet loss when in a local environment?


texts: My texture is doing weird, either not loaded correctly or not rendered correctly. DirectX11

texts:
I'm loading a texture from a file called owl.png. But it renders really weird.

Original picture(512 X 512):

But it renders like this:

It's rendered on a square, that is initialized like this:

 { XMFLOAT4(-0.5f, -0.5f, 0, 0), XMFLOAT2(0,1) },
 { XMFLOAT4(-0.5f,  0.5f, 0, 0),XMFLOAT2(0,0) },
 { XMFLOAT4(0.5f,  0.5f, 0, 0), XMFLOAT2(1,0) },
 { XMFLOAT4(0.5f,  -0.5f, 0, 0), XMFLOAT2(1, 1) }

Where the XMFLOAT2 are the tex coords.
It's loaded like this:

ID3D11ShaderResourceView* m_texture;
DirectX::CreateWICTextureFromFile(device, fileName, 0, &m_texture);

My samplerDesc looks like this:

samplerDesc.Filter = D3D11_FILTER_ANISOTROPIC;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MaxAnisotropy = 4;

And I use the normal sample method in my PS.

What did I do wrong?


texts: What happens in pre production of a game?

texts: I see a lot of games in "pre-production" and was just wondering what actually happens in this stage. Is it just planning or does a prototype get made or what?


texts: Prefabs and materials not working on another system

texts:
Our problem seems like rare, as I did research and none find to answer my question.

The problem is, I have created prefabs ,materials on my system and then exported it to my partner's System.

Now when my partner import it on his system all prefabs and materials I created showing "white" icon (not gray)

When we try to drag it to scene its not working.

Does anyone know answer to it?


texts: Hardware for testing Mapper 30 NES homebrews

texts:
For someone wanting to get into NES/Famicom game development, and test on hardware (original and/or clones) to make sure the controls feel right, and to make sure the game is compatible for hardware play, what is a sure method for doing this?

Two SD/MicroSD hardware solutions I am aware of are EverDrive N8 and KrzysioCart.

Below are the Famicom versions of these cartridges respectively:

The end goal would be to flash the game to Muramasa hardware, so the game should play the same on the testing hardware as it does on the final hardware. What I know about these boards, I learned from this video. When it comes to distinctions between the various types of boards, I still have lots of questions, but that's another post for another day.

If the best solution is to strictly test through the Muramasa hardware (skipping SD/MicroSD cart solutions) by flashing to it each time (since that would be the final destination), then that's fine. I don't really know what workflow will be quickest when going back and forth between coding and testing. While not all testing will be through hardware (probably most will be via ROM), periodic hardware testing seems like a good idea, and so a quick workflow for that is desirable.

When it comes to flashing cartridges, the INLretro is the only hardware I am currently aware of for that, and I'm not sure how quick it would be workflow wise to flash with this over and over, or whether that's even a good idea. Workflow speed and ease of use are the main factors that have led me to look at SD cartridge solutions for testing.

Hardware testing workflow criteria:

Must support Mapper 30, which NESmaker uses.
Must work the same on the SD cart as on the final Muramasa hardware (if SD is used).
Must work with Famicom (my console is Japanese).

I've come across various forum threads discussing Mapper 30 compatibility with the SD cartridge solutions mentioned above, but couldn't pin down a definitive answer.

I realize this is a somewhat niche topic, but hopefully someone here has some experience with it and can offer some guidance. Thanks.


texts:
I would like to implement an intelligent bot for Quake-3. I downloaded the and built the code successfully under Linux. My problem is that I couldn't find any complete tutorial telling me how to build an agent; telling which files to use( as there are many files in the source code).

Can you give me a website or piece of source code telling me how to start? Or something like an example source code for a bot.


texts: Why does my game look different on my mobile device than in the editor?

texts:
I am new to Unreal Engine. My game in mobile looks totally different than in Unreal Engine editor.
In Editor:
In Mobile:
Is this a symptom of something obvious? How can I make it so that what I'll see in the editor will be the same thing that I'll see on my mobile device?


texts:
I'm using Visual Studio 2012 have just installed Windows 8 on my computer and tried to compile a game Im working on in XNA. When the game tried to build, I got the following errors:

Error   12  Could not copy the file "C:\Users\Computer\Documents\Visual Studio 2012\Projects\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\SkyDome\skycirrus01.xnb" because it was not found.
Error   13  Could not copy the file "C:\Users\Computer\Documents\Visual Studio 2012\Projects\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Fonts\Arial.xnb" because it was not found.
Error   14  Could not copy the file "C:\Users\Computer\Documents\Visual Studio 2012\Projects\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Fonts\ISOCP2.xnb" because it was not found.

skycirrus01.xnb is actually a .fbx. *Arial.xmb* and ISOCP2.xmb are my spritefonts within my project.

Prior to installing Windows 8 (store bought) my project compiled.
Does anyone know how to convert these to .xnb files? I'm assuming that will make them compatible.


texts: Problem with Moving object with touch and make camera to follow the object

texts:
I watched a tutorial about  Unity Mobile From Scratch: Moving a 3D Object with Touch in Perspective on YouTube but when I added a camera follow script to follow that 3D object the object keeps moving even I clicked or dragged the ball once. Does anyone know why this is happening?

This is the code of moving the ball with mouse or touch from the tutorial

if (Input.GetMouseButtonDown(0))
    {
        Ray mouseRay = RayGenerator();
        RaycastHit hit;

        if (Physics.Raycast(mouseRay.origin, mouseRay.direction, out hit))
        {
            if (hit.transform.gameObject.tag == "BowlingBall")
            {
                obj = hit.transform.gameObject;
                objPlane = new Plane(Camera.main.transform.forward * -1, obj.transform.position);

                Ray mRay = Camera.main.ScreenPointToRay(Input.mousePosition);
                float rayDistance;
                objPlane.Raycast(mRay, out rayDistance);
                ballTouchOffset = obj.transform.position - mRay.GetPoint(rayDistance);
            }

        }
    } else if (Input.GetMouseButton(0) && obj)
    {
        cameraFollow.enabled = false;
        isDragging = true;
        Ray mRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        Ray mouseRay = RayGenerator();
        Debug.DrawRay(mouseRay.origin, mouseRay.direction, Color.red);

        float rayDistance;

        if (objPlane.Raycast(mRay, out rayDistance))
        {
            obj.transform.position = Vector3.Lerp(transform.position, new Vector3(mRay.GetPoint(rayDistance).x + ballTouchOffset.x, obj.transform.position.y, obj.transform.position.z), sideForce * Time.deltaTime);
        }

    } else if (Input.GetMouseButtonUp(0) && obj)
    {
        obj = null;
        isDragging = false;
        cameraFollow.enabled = true;
    }
}

And this is the camera script to follow that ball

public Transform bowlingBall;
public Vector3 offset;
public float cameraSlideSpeed = 5f;

void LateUpdate()
{
    transform.position = Vector3.Lerp(transform.position, bowlingBall.position + offset, cameraSlideSpeed * Time.deltaTime);
}


texts: 2D Unity: How to make a enemy jump from a navmesh platform to another?

texts:
I'm currently working on a 2d platformer, however I came across an issue where the enemy moves within a certain range of the platform.

In this case I use a navmesh to limit the enemy's movement however I want the enemies to be able to jump within platforms.

I'm not sure how to achieve this effect, where the enemy moves in the platform a couple of times and the jumps into the next one until the player gets in range for it to attack the player.

How can I acheive this effect? Should i keep on using navmeshes or try another way around?


texts: Is information about game assets copyrighted?

texts:
Let's say I extracted some assets from a closed source game.

Am I allowed to publish information (something like a list of filenames, sizes, duration, dimensions...) about those assets?


texts: Looking for the name of the tap handle with four 'spokes'

texts:
I am looking for the name of this sort of tap handle. This is a screenshot of it in the game Monument Valley. It has four spokes and can be rotated, behaving as one would expect of a similar design on a bathroom tap releasing water.
It was during a game design class, that I am no longer a part of, where the teacher told us that there was a specific name for that sort of tool. But I have forgotten the name and I was wondering if anyone might know.
I tried searching things like "tap handle name", "tap handle four spokes name game design", but couldn’t find the term for it. I was expecting it to not just be limited to game design, since, in that lesson, the teacher also mentioned the book The Design of Everyday Things by Don Norman and I was thinking that it might be used as a general term for those types of tap handles. (He mentioned the book for the term "affordances" (which I had heard of before), in the context of the tap handle looking like what it does, and relying on that familiarity of users likely having seen those sorts of tap handles in their everyday lives before). But I also couldn’t find the name when I added the term "affordances" to the search.


texts: Setting up speedtests in Actionscript 3 for an entire game

texts:
I'm very new to this so please forgive the questions possibly ill-stated nature.

Firstly is this even a valid way to speedtest:

public function L1() {

        tree.x = 200;
        tree.y = 200;
        tree.healthPoints = 0;
        addChild(tree);
        var myTimer:Timer = new Timer(100,60);
        myTimer.addEventListener(TimerEvent.TIMER,someFunction);
        myTimer.start();
        addEventListener(Event.ENTER_FRAME, speedTest)

    }
    function someFunction(event:TimerEvent) {
        t++
    }
    public function speedTest (e:Event) {
        if (tree != null) {
            do { tree.healthPoints += 1; }
            while (tree.healthPoints < 10000) ;
            tree.healthPoints = 0;
                trace (t);

        }
    }

Secondly:
I want to actually speed-test the entire game somehow to check if adding new features or rewriting current features actually optimizes the game or not.

What are some ways to do this?


texts:
I am using SurfaceView to draw a lot of Bitmaps onto canvas. This causes really variable frame rates depending on how many objects are present. My code below:

public class OriginalView extends SurfaceView implements SurfaceHolder.Callback {
  private final static int THREAD_SLEEP_TIME = 32;
  private DrawThread drawthread;

  private onDraw(Canvas canvas);
  public void onSizeChanged(int w, int h, int oldW, int oldH);
  public void surfaceChanged(SurfaceHolder holder, int format, int width,
        int height);
  public void surfaceCreated(SurfaceHolder holder);
  public void surfaceDestroyed(SurfaceHolder holder);

  private DrawThread extends Thread {
    private SurfaceHolder surfaceHolder;
    public boolean threadIsRunning;
    public DrawThread (SurfaceHolder holder) {
      threadIsRunning = true;
      surfaceHolder = holder;
    }
    public void run() {
      Canvas canvas = null;
      while(threadIsRunning) {
        try {
          canvas = surfaceHolder.lockCanvas(null);
          synchronized (surfaceHolder) {
            if (canvas!=null) onDraw(canvas);
          }

          sleep(THREAD_SLEEP_TIME);

        } catch (InterruptedException e) {
          e.printStackTrace();
        } finally {
          if (canvas != null) surfaceHolder.unlockCanvasAndPost(canvas);
        }
      }
    }
  }
}

As you can see here in DrawThread's run function that the Thread is supposed to sleep for a constant value of time, predefined here as 32 milliseconds, but since sometimes onDraw(canvas) takes more time, varied due to number of components on screen, the frame rate per second that this code achieve is 17 - 51 fps in my game. This is highly unacceptable. How can I draw lots of Bitmaps onto a canvas, while maintaining high frame rates?


texts: InputAssembler and emtpy/incomplete buffers

texts:
I was wondering what the InputAssembler does if the size of the bound buffers does not match the vertex count of the Draw() call.

I've seen the example at http://msdn.microsoft.com/en-us/library/windows/desktop/bb232912%28v=vs.85%29.aspx where the InputAssembler is used without any buffers, however, the vertex shader input is simply defined as

struct VSIn
{
    uint vertexId : SV_VertexID;
};

and I understand that SV_VertexID is filled in by the InputAssembler.

But what if I define the input as follows?

struct VSIn
{
    uint vertexId : SV_VertexID;
    float4 color : COLOR;
};

I tested this and it appears that input.color always returns the default value float4(0, 0, 0, 0). Is this expected behavior or might other drivers produce different results?

A more elaborate example: If I bind a buffer with ten positions to slot 0 and a buffer with five colors to slot 1 and render ten vertices, will the first five vertices have the color as defined in the color buffer and the other five have color zero? I tested this as well and this seems to be the case. Again, Is this expected behavior or might other drivers produce different results?

And even if i can to this, should I?

Background: I have "regular" vertex data which I bind to slot 0. In some (rare) cases I have additional data which I bind to slot 1. At the moment if I don't have additional data I will still generate a secondary buffer of equal size as the "regular" buffer filling it all with zeros. I was wondering if this is necessary or if I can simply set the secondary buffer to null and let the InputAssembler do the work.

Bonus question: Can I change the default value the InputAssembler uses if there is no buffer value?


texts: How to stop objects pushing each other away on collision?

texts:
I'm creating something along the lines of Super Smash Brothers. There's a problem with the collision between the two players and projectiles.

We have rigid body on the characters and projectiles and every time they collide they push one another back, I know that is how it operates but is there a way to stop that from happening?


texts: What should i use as a board for my game?

texts:
I'm a beginning programmer and i need to make a game. The rough idea revolves around fleets fighting in turn based battles while you control your factions resources and manpower.

The original concept was to make a set of routes which the fleet could follow. A graph of location nodes connected by route edges that looks a bit like this:

I don't know how to make a map and make set locations on it.

On that note, i'm making this is html/javascript/css. This is a school assignment.


texts: Is there a concept of "pasted on theme" in video games?

texts:
I've prototyped an idea and so far it's quite fun to play. However, it's still abstract and uses placeholder art. I've been thinking about a theme/story to add to the game, but I don't want to make it too obvious it was added almost as an afterthought.
There's a concept of "pasted on theme" within the board game community which basically refers to a game which is easy to reskin without redesigning some of the mechanics. I was wondering how big of an issue this is with video games (indie games in particular of course) and anything else I could do about a story for my game.


texts: Error When Loading a .tmx TILED map through the TiledMap class

texts:
So I made a map using the TILED application and I have it as a .tmx for reasons, but whenever I use the TildMap class in the Slick2D library to render the map on the screen, it gives me an error. Here are the files:

Class file:

public TiledMap testMap = null;

//TILE-READER
public static TileReader tileReader;

public Game (int stateID) {}

@Override
public int getID() {
    return Main.game; //GAMESTATE = 1
}

@Override
public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException {
    worldMap = new Image ("res/in_game_map.png");
    player = new Player(playerX, playerY, mapX, mapY);
    tileReader = new TileReader();
    player.init(gameContainer, stateBasedGame);
    tileReader.init(gameContainer, stateBasedGame);

    testMap = new TiledMap("res/worldMap.tmx");
}

@Override
public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int delta) throws SlickException {
    player.update(gameContainer, stateBasedGame, delta);
    tileReader.update(gameContainer, stateBasedGame, delta);
}

@Override
public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException {
    graphics.scale(1.05f, 1.05f);

    graphics.translate(player.camera.getCamX(), player.camera.getCamY());
    gameMap.draw(mapX - mapLength, mapY - mapWidth);
    testMap.render(0, 0);
    tileReader.render(gameContainer, stateBasedGame, graphics);
    player.render(gameContainer, stateBasedGame, graphics);
    graphics.translate(-player.camera.getCamX(), -player.camera.getCamY());

    if (inputHandler.keyMAP) {
        worldMap.draw(0, 0);
    }

    graphics.drawString("Player X: " + player.getxPos(), 400, 400);
    graphics.drawString("Player Y: " + player.getyPos(), 400, 415);
}

And here is the error message that it provided me:

  Caused by: org.newdawn.slick.SlickException: Unsupport tiled map type: base64,zlib (only gzip base64 supported)

Is there an issue with the way I formatted the .tmx file or is it that I am using the latest version of Tiled and that slick2D is no longer compatible with the newer version?


texts: How to get the center position for AABB of rotated mesh right?

texts:
I want to calculate the AABB for my rotated & translated mesh, but whatever I tried, I can't calculate the center position correctly if the mesh is rotated.

My mesh is defined by an array of vertices, located around the coordinate origin (0,0,0) and a TRS matrix (containing translation & rotation only). To calculate the AABB I multiply each vertex of my mesh with the TRS matrix and check for min/max values on all three axes. My AABB is simply defined as
glm::vec3 center, extend; (extend = length from center to outer border of the AABB; extend * 2 = length of the AABB).
My TRS matrix is defined as:

 glm::translate(glm::mat4(), meshPosition) * glm::eulerAngleY(glm::radians(angle));

For each vertex I calculate:

glm::vec4 vert4 = glm::vec4(vertex.x, vertex.y, vertex.z, 1.0) * trsMatrix;
vert4 = vert4 / vert4 .w;

And search for the minimum/maximum x, y and z components in all vert4. Once the min/max values of all these vertices is found, the AABB is calculated as following:

extend = (max - min) * 0.5f;
center = min + extend;

First strange thing I noticed, is: even though my TRS matrix contains the translation for my model, the resulting AABB is still centered around the coordinate origin rather than the translation contained in my transformation matrix. I couldn't fully understand the reason yet, but it's not a big deal because I have the mesh position available anyway: so I thought I could just set the center position to the sum of the mesh position and the AABB center position.

center = center + meshPosition;

Unfortunately wrong: this works only as long as the angle of my rotation is around 0 or 180 degrees: In case of 90 or 270 degrees the position of the AABB relative to the mesh position is wrong (inverted on one axis).

I figured out the reason must be because the center of my mesh and the center of the AABB are different; the AABB center is "rotated" around the mesh center, when the mesh is rotated. If the mesh is facing in x+ or x- position, the center is correct calculated, if the mesh is facing in z+ or z- position the center of the AABB is in front of the mesh, instead behind it (and because of that not fully covering the mesh). How can I fix this/where is my error?

Note: This question is loosely related to my last question: How to recalculate AABB after rotation?


texts:
I am not sure if I should post this link, but I feel this falls into game development just as much as it does math. I have a ray cast's far and near values and I am trying to calculate the end point of the ray so that I can either draw a line to show the ray, or render an object at the end of 3d mouse position.

Here is my post on the stack overflow math site, if there is a problem with me doing this just close the thread. Thank you.
https://math.stackexchange.com/questions/15918/help-with-matrix-mathematica


texts: Not getting proper height in unity when android device has notch or navigation bar on screen

texts:
Screen.height is not giving the proper resolution of an Android device when that device has a notch or navigation bar.

Due to this there is offset at bottom of screen:

Here I have set the Admob banner to display at the bottom. But it shows with some offset away from the bottom edge of the screen.

How can I get the proper height of the device in Unity and work with the notch on devices that have them?