texts:
I would like to present here my Question about VBOs and VAOs.
Basically from what i understand you can have different VAOs each of which can contain up to several VBOs , and by binding to the VAO's ID you can draw from the VBOs stored inside.

I have Wrote a simple class that reads a obj file then creates vertices, normals and uvs vector lists and upload those in 3 VBOs (vboID 1,2 and 3)

void Model::loadToVBO()
{
glGenVertexArrays(1, &vaoID);
glBindVertexArray(this->vaoID);

glBindBuffer(GL_ARRAY_BUFFER, vertexID);
glBufferData(GL_ARRAY_BUFFER, this->vertices.size()*sizeof(vec3), &this->vertices[0], GL_STATIC_DRAW);

glBindBuffer(GL_ARRAY_BUFFER, normalID);
glBufferData(GL_ARRAY_BUFFER, this->normals.size()*sizeof(vec3), &this->normals[0], GL_STATIC_DRAW);

glBindBuffer(GL_ARRAY_BUFFER, uvcoordID);
glBufferData(GL_ARRAY_BUFFER, this->uvs.size()*sizeof(vec2), &this->uvs[0],      GL_STATIC_DRAW);

glBindVertexArray(0);
}

if I do that in the render function i try to Bind to vaoID , and draw elements , but it would not work. To make it work i have to RELOAD vbo data every frame in Render Function (that happens because i have 2 models each model's constructor calls loadVBO , and obviously the second model overrides the first vbo's 1,2 and 3 ID positions(i was assuming that the vao generated from the first object will be entirely separate from the vao generated from the second model and each vao will have its own 3 VBOs). So maybe my code doesnt setup VAOs properly. Was reading something about how glEnableVertexAttribArray and glVertexAttribPointer
are used to set up current vbo state into vao , but could not understand it really well. Maybe because i use the same functions to bind to shaders variables ....

This code below is in the shader class and it loads the vbo data into shader's variables

void StaticShader::loadAttribute(GLuint bufferID, string variable, GLuint size)
{
GLuint variableID;
variableID = glGetAttribLocation(this->shaderProgramID, variable.c_str());
glBindBuffer(GL_ARRAY_BUFFER, bufferID);
glEnableVertexAttribArray(variableID);
glVertexAttribPointer(variableID, size, GL_FLOAT, GL_FALSE, 0, 0);
}

The Model Render Functions looks like that.
The loadToShader function loads: all model matrices + vertices + normals + uvs
This function calls the function loadAttribute for v, n and uvs ( i assume thats not where its supposed to be ... maybe)

void Model::Render()
{
glBindVertexArray(vaoID);
//loadToVBO();
loadToShader();
glDrawArrays(GL_TRIANGLES, 0, this->vertices.size());
glBindVertexArray(0);
}

My question is - Is it Bad (performance wise) to load VBO data every time render is called (i assume YES). Second part - Should i reload model data(meaning v/n/uvs) in shader every time its called to be rendered ?


texts: Authoritative movement with client side prediction

texts:
I don't fully understand how client side prediction works with authoritative movement.

Let's say we have:

client at position(0,0)
server at position(0,0)

Now the client wants to move forward and calls a client side function move and then sends the server that the client wants to move forward.

Now the client has moved to position(10,0), while the server is still at position(0,0). Now the server moves to position(10,0) and sends an update to all clients.

But the client has now moved to position(20,0) and now receives the position state from the server that the client should be at position(10,0).

What happens now? The client can't just apply the position from the server otherwise the client would jitter around.

One simple solution that I could think of would be a distance check.

if(Distance(position(10,0),position(20,0) > SomeNumber){
   ForceUpdatePos();
}

But this is probably not a good idea because SomeNumber depends on the MovementSpeed and latency.

I probably also would have to include a timestamp of the package because maybe the client has not heard back from the server for several ticks and then receives a bunch of unordered position updates.

What is a common technique to solve this problem?


texts: Who use javaFX for commercial quality games?

texts: Are there any companies work with javaFX for building videos games ?


texts: same 8bit created surface resulting in a different pitch value

texts:
Given:
const int w = 10;
const int h = 10;
const int d = 8;
uint8_t* pixels = new uint8_t[w * h]

SDL_Surface* src = SDL_CreateRGBSurfaceFrom(pixels, w, h, d, w, 0, 0, 0, 0);
SDL_Surface* dst = SDL_ConvertSurface(src, src->format, 0);
// src->pitch == 10;
// dst->pitch == 12;
//std:: cout << src->pitch == dst->pitch << std::endl;

My expected result is that the two pitches must match.
In this case I have the "weird" 12 pitch value for the dst image create from the src.

Is that due to memory alignment optimization?
Is there any reasonable explanation about it?
Are those padding bytes used somehow or just wasted?


texts: How do I know if my game's average game session time is too small?

texts:
My game has only one life, and the aim is to stay alive as long as possible to get as many points as possible (it's an endless runner).

Using Google Analytics I found that players are staying alive for an average of 17 seconds. I could easily increase or decrease this by manipulating acceleration or starting speed. The question is, should I change it at all? Is there any research or general ideas on the best playing time for a game like this? I would also like to know about any research about how long an ideal mobile game session should last.


texts: 2D platformers: why make the physics dependent on the framerate?

texts:
"Super Meat Boy" is a difficult platformer that recently came out for PC, requiring exceptional control and pixel-perfect jumping. The physics code in the game is dependent on the framerate, which is locked to 60fps; this means that if your computer can't run the game at full speed, the physics will go insane, causing (among other things) your character to run slower and fall through the ground. Furthermore, if vsync is off, the game runs extremely fast.

Could those experienced with 2D game programming help explain why the game was coded this way? Wouldn't a physics loop running at a constant rate be a better solution? (Actually, I think a physics loop is used for parts of the game, since some of the entities continue to move normally regardless of the framerate. Your character, on the other hand, runs exactly [fps/60] as fast.)

What bothers me about this implementation is the loss of abstraction between the game engine and the graphics rendering, which depends on system-specific things like the monitor, graphics card, and CPU. If, for whatever reason, your computer can't handle vsync, or can't run the game at exactly 60fps, it'll break spectacularly. Why should the rendering step in any way influence the physics calculations? (Most games nowadays would either slow down the game or skip frames.) On the other hand, I understand that old-school platformers on the NES and SNES depended on a fixed framerate for much of their control and physics. Why is this, and would it be possible to create a patformer in that vein without having the framerate dependency? Is there necessarily a loss of precision if you separate the graphics rendering from the rest of the engine?

Thank you, and sorry if the question was confusing.


texts: How to design game server to mitigate DDOS attacks

texts:
I'm in the design phase of a turn based game with low load on the server (<1 message every 10 seconds per user, <50'000 users at a time). The game is multi-platform.

The protocol has not been decided yet.

How can I mitigate DDoS attacks against such a server by design?


texts:
I rotate a 3D object to left and right with swipe to left and right. Problem is on different devices with different pixel densities, it gets faster and slower. i.e. if you move your finger 1 cmm on one device will not rotate the object same amount that it will on another device, like a Retina and non-Retina one.

Last time I wanted to solve this I could not as IIRC there was no way to get physical pixel density of device or it's dimensions (to get density via division over resolution)

Thanks.


texts: Bounding Box in Monogame for mouse picking

texts:
Hello guys so I'm implementing this mouse manager to be able to pick up objects.

My application uses mainly textured quads in 3d space.
I'm using bounding boxes in monogame to do so, however my solution lacks accuracy.

Right now what I have is this:
http://imgur.com/oySTCay

you can clearly see what the problem is, so this solution is probably not the best.

this is my method to calculate the bounding box:

        public BoundingBox GetBoundingBox()
    {
        Matrix transform = Node.GetTransformForBoundingBox();

        vertices[0] = Vector3.Transform(new Vector3(0, 0, 0), transform);
        vertices[1] = Vector3.Transform(new Vector3(Texture.Width * m_fTexturescale, 0, 0), transform);
        vertices[2] = Vector3.Transform(new Vector3(0, (Texture.Height * m_fTexturescale) * -1, 0), transform);
        vertices[3] = Vector3.Transform(new Vector3(Texture.Width * m_fTexturescale, (Texture.Height * m_fTexturescale) * -1, 0), transform);

        return BoundingBox.CreateFromPoints(vertices);
    }

And the mouse picking part is the standard ray tracing into near/far clipping planes with unproject.

So I was thinking, maybe if I do the other way around, and instead of un-projecting the mouse, i could project all the vertices and do some kind of polygon math to check if the mouse position is inside the polygon formed from the projected vertices, (occluded vertices are worrying me though).

Do you think is feasible, or is there any other option, should i just go for OBB?

Thanks alot,

Roger Martins

EDIT:

So after searching a bit for OBB's i found that CartBlanche had one implementation on his samples repo

this:
https://github.com/CartBlanche/MonoGame-Samples/blob/master/CollisionSample/BoundingOrientedBox.cs

so I just used it and it works pretty well, now i just have one bug that i cant figure out, one transformation must be wrong.¨

result : http://imgur.com/QOsIbj7

what i'm doing:
so now I have a box parameter in this class, nullable one.

how I build the bounding box :

  public SOrientedBoundingBox GetBoundingBox()
    {
        //create the initial bounding box
        if (obb == null)
        {
            //calculate the vertices for the textured quad in model space at the origin (inferior left corner is origin because we invert the y to conpensate for the perspective projection)
            vertices[0] = new Vector3(0, 0, 0);
            vertices[1] = new Vector3(Texture.Width * m_fTexturescale, 0, 0);
            vertices[2] = new Vector3(0, (Texture.Height * m_fTexturescale) * -1, 0);
            vertices[3] = new Vector3(Texture.Width * m_fTexturescale, (Texture.Height * m_fTexturescale) * -1, 0);
            //get bounding box and trasnform it to orientedboundingbox
            //TODO : remove the middle step
            BoundingBox box = BoundingBox.CreateFromPoints(vertices);
            obb = SOrientedBoundingBox.CreateFromBoundingBox(box);
            return obb.Value;
        }
        else
        {
            return obb.Value.Transform(Node.GetQuaternion(), new Vector3(Node.AbsolutePosition.X, Node.AbsolutePosition.Y * -1, Node.AbsolutePosition.Z)*Node.Scale);
        }

    }

I'm going to fiddle a bit more with it, but the problem is something minor, i think. But maybe one of you can detect something silly i did.

Thanks, Roger.


texts: What can I do to increase the female:male ratio of gamers in an online, casual gaming, community?

texts: Can I make a significant difference by changing the types of games that are available? Are there any generic features that I can add to games, which will help make them more attractive to casual female gamers?


texts: Setting up sequential animation clips in Unity

texts:
I'm trying to play two animation clips sequentially using Unity 2D. I've been using Mecanim for this so I've imported the two clips in a newly created controller and connected the first one to the next one. I also want the last clip to be looping so I set that toggle in the settings of the clip.
Now for some reason the first clip is played just fine but the second one doesn't animate at runtime. It loops fine in the Animator window and the clip itself works in the preview window but not at runtime.

I've also tried setting it up using the Animation Component and use the PlayQueued method but this doesn't give any animation.

I'm kind of lost on what to try next

EDIT: This is to be used on a Canvas UI Image


texts:
I started using the asset manager, so I could use a loading screen. Everything is working fine, but when the app enters a pause state, it unloads every asset and when it loads the screen all the assets are gone. I debugged and I found that they are waiting to be loaded again, I commit an update to do it but nothing happened.

Am I missing something? (In the pause method, I don't unload anything)


texts: How can I send a live notification when a user gets leveled up?

texts:
This question is about how to implement a live notification if the user gets leveled up. My leveling system consists of 100 levels, so every time a user levels up, a notification will pop up into their profile.

while($user->curr_exp >= $user->exp_needed){
      if($user->level == 10 || $user->level == 15 || $user->level == 20)
      {
      $user->reward_token += 1;
      }
      $user->curr_exp -= $user->exp_needed;
      $user->prev_exp = $user->exp_needed;
      if($user->level <= 19){
      $user->exp_needed = $user->prev_exp * 1.4;
      }
      elseif($user->level >= 20 && $user->level <= 39){
      $user->exp_needed = $user->prev_exp * 1.1;
      }
      elseif($user->level >= 40 && $user->level <= 59){
      $user->exp_needed = $user->prev_exp * 1.05;
      }
      elseif($user->level >= 60 && $user->level <= 79){
      $user->exp_needed = $user->prev_exp * 1.04;
      }
      elseif($user->level >= 80 && $user->level <= 99){
      $user->exp_needed = $user->prev_exp * 1.03;
      }
      elseif($user->level == 100){
      $user->exp_needed = $user->exp_needed * 0;
      }
      $user->level += 1;
      $user->save();
     }

Edit:
I have already added a toaster to my profile.blade.php here is the script:

<script type="text/javascript">
    $(document).ready(function(e){
     $.toast({
        text: 'You level up!',
        heading: 'Congratulations',
        icon: 'info',
        position: 'top-right',
        bgColor: '#d4af37',
        textColor: 'black'
    });
   })
  </script>

Now, everytime i refresh the profile.blade.php, the toastr pops up in the right corner, nonetheless, it's still a static functionality, what I want to happen is when the user gets the exp and gets leveled up, that will be the time the toastr will pop up. Any ideas on how do I call this up?


texts: Trying to create a UE4 blueprint or script to recognize set shapes

texts:
I'm currently developing an indie game using Unreal Engine 4 and I've stopped developing it within the last week because I have hit a massive roadblock..

I am trying to figure out how to create a blueprint (or c++ script if necessary) that can have a library of different shapes such as an L (2x1 blocks) in any order which would fit within a 5x5x5 (x,y,z) crafting grid in the game world. See the screenshot with the L shape near the green arrows as a sort of gun object to configure and craft from blocks so long as it matches that particular shape. It's almost like minecraft's crafting system but instead of in the menu this one is on a platform in the game world.

I've tried researching and looking at stuff on youtube and google searching like blueprinting, grid systems, shape systems, crafting systems, building systems, arrays, and now I am thinking maybe I have to use c++ instead just to try to figure out how to make it happen.

Does anyone with more experience on this stuff have any advice or better ideas on how I can create this? Any help to point me in the right direction is greatly appreciated, thanks in advance!


texts: Move the location of the XYZ pivot point on a mesh in UDK

texts:
When working with any mesh, you get an XYZ point somewhere on it. If you just want to move the mesh in any direction, it doesn't matter where this point is located.

However, I want to rotate a door. This requires the point of rotation to be very specific. I can't find anywhere how to change the location of the point. Can anyone help?

EDIT: solved, to change the pivot point, right click on the mesh, go to "Pivot" and move it. Then right click again and this time select "Save PrePivot to Pivot"


texts:
I am using SharpDX to create an application in Hololens and I'm trying to understand how to use DirectWrite to draw variable text in 3D stereoscopic view. I have gone through this question, but the answers rely on other libraries.

MVP Dwight Goins provided me with this Rendering-3D-Text tutorial to help me out which uses the DirectX ToolKit. The closest I've got to is the Holographic-Tag-Along sample for holographic applications given by Microsoft. These two samples pretty much cover what I'm looking for but it is in C++. However, due to some project constraints, I need this to be in C#.

I am pretty new to computer graphics and therefore I do not fully understand how to achieve the same thing that the above two samples I've mentioned does in C# using SharpDX. Any help that could be provided to achieve the same output in C# would be much appreciated.


texts: How can I identify feature regions in a procedurally generated world?

texts:
I'm building an Island. I use the classical heightmap solution : with a hill-building function, avoiding the corners of the map, I make altitude. Then, perlin noise give me some climatic variables to handle the biomes.
Now, I'm facing two challenges who are, in some way, connected :

In Dwarf Fortress, one of the neat aspects of world generation is how the game seems to "know" areas, and give them names, though they are not rectangular shapes. I would like to be able to "recognize" my forests, my rivers, my hills... any idea what kind of algorithm I could use to scan my map and interpret its areas ? And how would you store that ? I'm using a basic C++ graph made out of a vector of vector of "tiles object".
This Island should be divided in political areas, not only purely natural regions. I could use mountains and rivers to make "natural borders", but my procedurally generated map doesn't garantee I will have nice "enclaves" that would form a kingdom ; I could find myself having a gigantic "ribbon-formed" political areas surounded by micro-kingdoms.
Another possibility would be to look for appropriate areas for a city or a castle. Then, "grow" a political area around it. But there again, I'd like to have some well-known algorithms before trying to devise my own.

This question could be interpreted as a bit too vague, so one way of rephrasing it would be : how to partition (without modifying !) a procedurally generated world into areas suitable for gameplay ? Thanks in advance for your help.


texts: Why does my game exit immediately if I restart it after calling Exit()?

texts:
When launching a game multiple times in a console, the first time this.Exit() on the game class is called, all following games do not properly run. Instead they exit immediately.

For example, if I have a function that does:

foreach(var i in options) {
  using(var game = new MyGame()) {
    game.Run();
  }
}

and the game class has

protected override void Update(GameTime gameTime)
{
  if(gameTime.TotalGameTime.TotalSeconds > 3)
    this.Exit();
  base.Update(gameTime);
}

then the first instance will execute just fine (for 3 seconds), but the second will exit immediately.

How can I prevent XNA from making the second games die immediately?


texts: How to get started with Unreal Engine for iPhone?

texts: OK i have decent amount of knowledge of C++. I want to make cool games for iPhone using unreal engine and I have access to UDN. But everything seems cluttered on UDN. I have downloaded source from there. It would be great if someone can provide information about How to get started and list of resources. Thanks!


texts: Is there a portal dedicated to HTML5 games?

texts:
Just to get something straight; by "portal", I mean a website that frequently publishes a certain type of games, has a blog, some articles, maybe some tutorials and so on. All of these things are not required (except the game publishing part, of course), for example, I consider Miniclip to be a flash game portal. The reason for defining this term is because I'm not sure if other people use it in this context.

I recently (less than a year ago) got into HTML5 game development, nothing serious, just my own small projects that I didn't really show to a lot of people, and that certainly didn't end up somewhere on the web (although, I am planning to make a website for my next game). I am interested in the existence of an online portal where indie devs (or non-indie ones, doesn't really matter that much) can publish their own games, sort of like "by devs for devs", also a place where you can find some simple tutorials on basic HTML5 game development and so on... I doubt something like this exists for several reasons:

You can't really commercialize an HTML5 game without a strong server-side and microtransactions
The code can be easily copied
HTML5 is simply new, and things need time to get their own portals somewhere...

If a thing like this does not exist, I think I might get into making one some day...


texts: how to order entities by their distance from 0 on the x axis

texts:
I'm creating an infinite runner game in which you control several characters at once.  Right now when you press the spacebar, they all jump at once but, I want them to jump at separately, one after the other from right to left(largest x to smallest x) so I need to order them in some way to represent that.
I tried using bubble sort to do this with no success so I tried my own approach where I scan the screen for the x position of the characters and assign their order to the number of passes the loop has gone through:
public void SetJumpOrder()
    {
        int pass = 0;

        foreach (Alien a in handler.aliens)
        {
            for (int i = 1000; i > 0; i--)
            {
                if (i == a.position.X) a.jumpOrder = pass;
            }
            pass++;
        }
    }

The code above didn't work because it just gave the order of the aliens list instead.  Any suggestions?


texts: Issues with the value of transform.position.x

texts:
I'm trying to do something very basic:
"IF value of tranform.position.x equals 4.5 DO something"
Here is my code:
if(transform.position.x.Equals(4.5)){
        //(float)transform.position.x == (float)myGM.BottomRightCorner.x
        if(directionToMove.Equals(0.1f)){
            directionToMove = -0.1f;
            print("Direction To Move Changed");
        } else{
            directionToMove = 0.1f;
            print("Direction To Move Changed");
        }
    }
    transform.Translate(new Vector2(directionToMove, 0));

I've tried if(transform.position.x == 4.5), if(transform.position.x == 4.5f, if(transform.position.x.Equals(4.5), if(transform.position.x.Equals(4.5f)and of course I've tried putting the 4.5 in a variable (constant and regular)... but no matter what, when transform.position.x has a value of 4.5... nothing happens. it completely skips the if statement. I've been programming for 5 hours so far today, so my brain might just have crashed... Just for the sake of it, I did try if(4.5 == 4.5) just to make sure I wasn't going crazy and somehow wrote the if statement incorrectly... but no, that worked just fine (Thank god...)
I'd greatly appreciate it if anyone can point out any clues as to what I'm doing wrong here.
p.s. I'm aware that my code is not the most efficient thing in the world... I'm trying to see what I can do by myself without following any tutorial. As for what the statement is meant to do... before the transform reaches 4.5, starting from 4.0, increase the transform.position by 0.1f. Once it does reach that, decrease the transform.position by 0.1f.
Basically, move to one side of the screen, then go back to the other side of the screen. Initially, there was a check for the other side, but I stripped this to bare-bones to try and figure it out.
p.s.2: As a side note, this function is called via an "InvokeRepeating()". I'm going to try calling the method in another way, just in case... if that works, I'll remove this post.


texts: Duplicate a Prefab as a separate asset in Unity 5.2

texts:
I have a Asset which is a collectable object [Pickup] and I currently have eight in my scene, I'd like to duplicate this asset and use it to harm the player [Bad Pickup].

I decided to duplicate the asset because I wanted both assets to have the same components (Animation script, rigid body, mesh colider, etc...). However, when I edit the texture of my new asset [Bad Pickup], it changes the texture used for the original asset [Pickup] as well.

I've tried GameObject -> Break Prefab Instance on the object with the new asset but it doesn't appear to make a difference.

Is there a way to break this instance so that I don't have to make a completely new GameObject and add the same components manually?


texts: Aligning bullet's position in Asteroid Game

texts:
I'm writing an asteroid game and I would like to align the bullets on the ship's tip. I also want when the ship fires, the bullet gets the same orientation(angle, direction) of the ship and also be fired at a different velocity.

I'm drawing the ship by the following code:

gl::drawLine(Vec2f(-43,-52),Vec2f(59,1));
gl::drawLine(Vec2f(-14,-31),Vec2f(-14,38));
gl::drawLine(Vec2f(59,1),Vec2f(-43,54));


texts: Game Object will NOT stretch across entire content area

texts:
I'm loading prefabs into a content area using a content size fitter and vertical layout group. I've tried multiple things to get the loaded prefabs to stretch across the entire content size (including the Unity Manual for this issue), but I'm at an impass. I'll post a screenshot below to show what I'm working with:

Here's how I'm loading in the prefabs in case this is where i'm screwing up:

void CreateRaceSelect() {

 for (int i = 0; i < races.races.Count; i++) {
     raceButton = (GameObject)Instantiate(raceButtonPrefab);
     raceText = raceButton.transform.FindChild("Text").GetComponent<Text>();

     raceButton.name = i.ToString();
     raceButton.transform.SetParent(content.transform);
     raceButton.GetComponent<RectTransform>().localPosition = new Vector3(xPos, yPos, 0);
     raceText.text = races.races[i].ToString();
     yPos -= (int)raceButton.GetComponent<RectTransform>().rect.height;
    }
 }

I'm sure this is a minor screw up but at this point I have no other ideas.


texts:
I am making a game with web, iphone, and android front-ends.  I want to make them all able to interact well through the back-end so that any user can play with any user.

To do this I've decided to make an "API" or really just a Ruby on Rails back-end (with the rails-api gem).  Which option fits best:

1. Back-end First

Process would be building entire back-end functionality, one feature at a time until it is complete (can always expand missing features later).  Can test it using different types of tests.

2. Back-end alongside one platform (web)

Process would be building one feature in the back-end, then using it in the front-end to make sure it works.  Would be easy to build with web because most Rails projects already have views.

3. Back-end alongside each platform

Same as option 2, but building the feature in each platform before moving on to the next one.  Would allow fixes for cross-platform problems as you go along, being able to narrow it down precisely.

Essentially I know possible ways to go about it, but have never made an API or cross-platform game


texts: Hi what is the best model for creating client server application in one solution in xna, client as xna application, server as console and model as reference added to client and server? or maybe one xna application with global variable isHost passed from separate client/ server application running this xna application, or mayby different?


texts: What compilers are used in game development?

texts: I was kinda wondering what compilers are used in game development, since the game development industry always tries to squeeze every inch of performance out their software, using, among other, (sometimes very aggresive) compiler optimizations and the big boys in compiler technology (llvm, gcc), that excel in such kind optimizations are out of the game in the *Windows operating System*.


texts: How can I set up a Pong-style game using the physics system in Unity?

texts:
I've just been using Unity and chose to learn it by making a Pong game which sounded simple enough as a "hello world" type of game. My goal was to try and encompass enough of the built in engine without needing to write scripts but I ran into a few problems.

Here is my setup so far:

Paddle Game Object:

Box Collider
RigidBody (Set as Kinematic)

Ball Game Object:

Sphere Collider<
RigidBody (not kinematic)

Wall Game Object:

Box or Plane Collider

I've set my material on my Ball to 'Bouncy' and I get a pretty good bouncing ball (given a starting force).

I've also added the following script to the Paddles:

void OnCollisionEnter(Collision collision)
{
    BallRidigBody.AddForce(rigidbody.velocity);
}

Here are some of my problems:

Collision: I was trying to figure out why my kinematic objects wouldn't collide before stumbling upon the collision matrix. I was wondering what are good approaches to enable kinematic collisions for my setup;
Forces: I'm confused how ApplyForce should be used. Even if I pick ForceMode.Impulse, is that a constant force?
I'm a bit stuck on how to get proper bouncing off the walls and paddle. Since I've already applied a starting force, should my wall apply force on an onCollisionEnter method or change the velocity?


texts:
When creating a sprite animation in Aseprite, we can set the "Duration (milliseconds)", as show here:

But when setting up the animation in Unity, we have to specify "Samples" as shown here:

How can we convert from "Duration" to "Samples"?


texts: I am trying to learn Andengine, and it seems it does not support sprites in any other way other thab a Texture Atlas. I am using the Android AIDE app and importing the older Andengine .JAR because I dont have a laptop and dont plan on forking up $250-400 for one when I can get a quad core android for $100 flat. I want to make a simple .ATLAS file but dont know how. Does anyone else here know how to solve my problem?


texts: Getting Components to their respective System in Entity-Component Engine

texts:
I asked this question in stackoverflow, but I didn't get any responses. I think it's better suited in this exchange.

I'm building a game engine of sorts (purely educational) and am not sure the best way to keep a large system decoupled when using objects the are shared by systems.

My engine is making use of an entity-component design where components contain only state. Systems are the driving force of making these components run so I need to be able to register components with their respective system. I am just unsure on how to pass the components through the hierarchy which looks like this:

I can think of a few ways of dealing with this.

Option 1: Singleton.
If I make my Engine object a singleton I can use static methods directly in my input component to bind to the input system.

class InputComponent: public Component
{
    InputComponent()
    {
        Engine::getEngine()->getInputSystem()->bindInputComponent( this );
    }

    virtual ~InputComponent()
    {
        Engine::getEngine()->getInputSystem()->unbindInputComponent( this );
    }
}

This has the benefit of components automatically binding and unbinding themselves to their system which is convenient. It has the downfall of being a singleton (not necessarily bad, but it can possibly make my engine inflexible in the future) and my InputComponent "knows" about the InputSystem which might be bad design.

Option 2: Work down from scene system. I can make my scene system responsible for binding and unbinding components.

class SceneSystem: public System
{
    void setActiveScene( Scene* scene )
    {
        // Deactivate (and unset components) for the current scene.
        unsetActiveScene();

        for( auto i : scene->getEntities() )
        {
            for( auto j : i->getAllComponents<InputComponent>() )
            {
                // Send message through mediator to bind the component
                DataMessage<InputComponent*> bindMessage( MESSAGE_BIND_INPUT_COMPONENT, j );
                Message response;
                sendMessage( &bindMessage, &response, SYSTEM_INPUT );
            }
        }
    }
}

In this way the input component isn't worried about looking up the hierarchy. But now my scene system has to "know" about input components (and all other components that need to be registered). This is coupling my system.

Also if I need to add/delete components I'll need to do it through the scene system.

Option 3: Working up from input component. The last thing I can imagine is to instead work my way up the hierarchy from the input component. I think in this scenario I would also add a general bindComponent to the scene system so not too much complexity about the mediator messaging creeps into my components.

class SceneSystem: public System
{
    template <typename T>
    void bindComponent( T* component, int system )
    {
        DataMessage<T*> bindMessage( MESSAGE_BIND_COMPONENT, component );
        Message response;
        sendMessage( &bindMessage, &response, system);
    }
}

class InputComponent: public Component
{
public:
    InputComponent( Entity* parentEntity ) : m_parentEntity( parentEntity )
    {
        m_parentEntity->getParentScene()->getSceneSystem()->bindComponent<InputComponent>( this, SYSTEM_INPUT );
    }

    virtual ~InputComponent()
    {
        m_parentEntity->getParentScene()->getSceneSystem()->unbindComponent<InputComponent>( this, SYSTEM_INPUT );
    }

private:
    Entity* m_parentEntity;
}

This has the effect of my hierarchy being bidirectional (not sure if this is a bad thing)

Of these options, which is better for keeping such a system flexible and reasonably decoupled. Also point out other options especially if there are flaws with my current design and/or understanding of the problem.


texts: Unity: Trying to add a simple light to a prefab

texts:
A bit of a unity beginner here. I have a windmill prefab and I would just like to add a simple point or directional light to my prefab. I added the component for a light to the prefab and started the game, but it seems like no matter what I try, the light would not appear. I tried to move the component to the top in the Inspector window (thinking another component would overwrite the light properties).

Any ideas? Or things Im doing wrong?


texts: Is a programmer liable for copyright infringement in other people's mods to his games?

texts: If a programmer (P) releases a game, and a modder (M) releases a game modification which includes copyrighted content, can P be held liable for the copyright infringement in the mod?


texts:
I am working in unity and have flattened out a cylinder object to make a coin for a 3d coin flipping game, but I am not sure how to get the coin to flip when the player swipes across it and allow for a double flip if the player swipes over it a second time while in mid air.

here is what I have tried:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CoinFlip : MonoBehaviour {

    private Vector3 start;

    private void Start() {
        start = gameObject.transform.position;
    }

    void Update() {
        transform.position += transform.right * Mathf.Sin(Time.time * 0.45f) * -0.025f;
    }

    void OnEnable() {
        gameObject.transform.position = start;
    }
}


texts: Generating vertices for group of hexagons

texts:
I'm working on the map editor of a game, where you can create a grid of hexagons to paint. An example of a grid of radius 6:

What I want

Once map creation is done, I would like to generate a mesh for each of these islands of color, with the least possible number of vertices.

What I have so far

My approach gives me a list of outer vertices for an island and a list of inner edges, which represent holes in the mesh. Outer and inner edges never overlap.

The gray area on the right of the image above has 3 holes, so what my code gives me is a list of vertices around the gray area and 3 lists of vertices for each hole inside it.

Problems I'm having

While I can already triangulate islands without holes, I can't find a way to turn the ones with holes into meshs. How should I approach solving this problem?


texts:
I'm working on a basic roguelike using HTML5 and jQuery, and I've come across a problem.

The way the game currently stands, the system only saves the game state every time the user moves between floors - to minimize overhead. The peril of this is that, if the user gets in trouble, they can simply close the window and return to their game at the beginning of the current floor. This drastically reduces the difficulty of the game (and almost defeats the purpose of a roguelike) - but it's unreasonable to save the game state with every single player movement or attack.

I've researched ways to save the game state on browser window close, but I'm not happy with them. My question is this: assuming "saving a game state" means a moderately heavy ajax/post request, how do I thwart this cheating behavior? Is there a known methodology to quantify incremental/procedural changes to a 2d map, as opposed to saving the entire map state? Please note, I'm not asking for "the most efficient way" - I'm looking for existing methodologies to rectify my inexperience.


texts: Game engine + editor + gameplay dependency

texts:
I've tried to find my answer here but the other "similar topics" were different or just wasn't able to find the right one.

This is mainly a design (and some c++) question about the dependency between the different projects. Let me describe my problem:

So I've already used Unity and UE4 and I like the approach(es) they're using. They have a (game) engine an editor application and a user-created gameplay code. You can use your own gameplay code in the editor - you can assign scripts to objects, run/pause/step/stop (and debug!) the actual game in the editor.

I've checked the UE4 source code (which is actually pretty big) and the way this works is they're using custom build and preprocess tools (like Unreal Header Tool) and they've implemented everything they're using. As I could see, they're not using any STL class/function, they've implemented their own. This way they can make the "engine project" shareable, so they can build the libraries to dlls and that's it.

I'm using the same component-based approach. Different components can be attached to an object, and an important component base class is the Behavior. The "gameplay components" inherits from the Behavior base class.

So back to the problem: I (will) have 3 different projects:

Engine
Gameplay
Editor

The Engine is the core, that is a static library with every required thing except the game-specific code, of course. The Gameplay depends on the Engine and is built as an executable (*.exe). This contains the actual gameplay code while using the engine.

And here comes the real problem: the Editor depends on both the Engine and the Gameplay projects. Why? The Editor is using the Engine to create the window, draw buttons, log messages, etc. However it would be nice to be able to assign the "scripts" (in the terms of Unity) to objects and that would be the best if I could "play the game" in the editor, like in Unity.

Why is this a problem at all? Because I'm not able to use a shared library for the Engine project. Why? Because I should dll-export a lot of things which is not even possible while using the STL. It's a known "fact" that most of the STL objects cannot be used with dll-export (and I should write a lot of export code now, heheh). Also I don't want to use any bigger library like Boost or Qt.

However if I'm using static library for the Engine project then the Editor and the Gameplay will have its "own copy" of the Engine.

Maybe a half-solution could be the following: I could have a 4th project for the gameplay code exports which would be a dll. This project should only contain some functions which would be used in the Editor - eg. query the list of the available scripts with the visible variables, etc. However the game code is not actually available in the editor, so any "play in the editor" wouldn't be possible.


texts: Blender: calculation of elevation and rotation angle from plane

texts:
I have a generic plane (any location, any rotation around every axis) with its normal axis passing by the center. Then I have a generic point and I need to find the elevation and the rotation angle from the normal of the plane (as described before).

I need a solution that uses bones and constraints (drivers if necessary).

Note: to make it easy to understand. I am a little man standing over the plane. I want to know the pitch and the yaw (taking the upper edge center as the North) I need to apply to my head to look to the generic point.

Thanks in advance. Let me know if it is too difficult to understand :)


texts: Complete Math Library for use in OpenGL ES 2.0 Game?

texts:
Are you aware of a complete (or almost complete) cross platform math library for use in OpenGL ES 2.0 games?

The library should contain:

Matrix2x2, Matrix 3x3, Matrix4x4 classes
Quaternions
Vector2, Vector3, Vector4 Classes
Euler Angle Class
Operations amongh the above mentioned classes, conversions, etc..
Standardly used math operations in 3D graphics (Dot Product, Cross Product, SLERP, etc...)

Is there such Math API available either standalone or as a part of any package?

Programming Language: Visual C++ but planned to be ported to OS X and Android OS.


texts: Vulkan imageLoad data of r32f format in compute shader

texts:
I am doing add with a compute shader. All input-output data are stored in VkImage, the format is VK_FORMAT_R32_SFLOAT. In the shader, the corresponding layout is r32f.
I have two questions about this:

When imageLoad a r32f data, imageLoad always returns 4 components vec4 data. So will this waste some memory? It seems imageLoad doesn't support return a single component of data.
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/imageLoad.xhtml
The real output data, every 4 data followed by 4 0.0. Does it mean r32f is 64 bits?

The used shader (The test project: https://github.com/math3d/VulkanCompute/blob/master/examples/add_imager32f/add_imager32f.cpp):

layout(local_size_x = 1, local_size_y = 1) in;
layout(binding = 0, r32f) uniform image2D outputValues;

layout(binding = 1, r32f) uniform readonly image2D values;
layout(binding = 2, r32f) uniform readonly image2D filterValues;

void main() {
  uint row = (gl_GlobalInvocationID.x);
  uint col = (gl_GlobalInvocationID.y);
  vec4 x = imageLoad(values, ivec2(row, col));
  vec4 w = imageLoad(filterValues, ivec2(row, col));
  vec4 res = x + w;
  imageStore(outputValues, ivec2(gl_GlobalInvocationID.xy), res);
}

The result:

Compute input:
0.000000        1.000000        2.000000        3.000000        4.000000        5.000000        6.000000        7.000000        8.000000        9.000000        10.000000       11.000000   12.000000        13.000000       14.000000       15.000000       16.000000       17.000000       18.000000       19.000000       20.000000       21.000000       22.000000       23.000000   24.000000        25.000000       26.000000       27.000000       28.000000       29.000000       30.000000       31.000000

Compute filter:
0.000000        1.000000        2.000000        3.000000        4.000000        5.000000        6.000000        7.000000        8.000000        9.000000        10.000000       11.000000   12.000000        13.000000       14.000000       15.000000       16.000000       17.000000       18.000000       19.000000       20.000000       21.000000       22.000000       23.000000   24.000000        25.000000       26.000000       27.000000       28.000000       29.000000       30.000000       31.000000

Compute output:
0.000000        2.000000        4.000000        6.000000        0.000000        0.000000        0.000000        0.000000        8.000000        10.000000       12.000000       14.000000   0.000000         0.000000        0.000000        0.000000        16.000000       18.000000       20.000000       22.000000       0.000000        0.000000        0.000000        0.000000    24.000000        26.000000       28.000000       30.000000       0.000000        0.000000        0.000000        0.000000        32.000000       34.000000       36.000000       38.000000   0.000000         0.000000        0.000000        0.000000        40.000000       42.000000       44.000000       46.000000       0.000000        0.000000        0.000000        0.000000    48.000000        50.000000       52.000000       54.000000       0.000000        0.000000        0.000000        0.000000        56.000000       58.000000       60.000000       62.000000   0.000000         0.000000        0.000000        0.000000

```


texts:
I'm in the process of learning DirectX and in the book examples they have a very basic application which sets up DirectX and displays a blank screen. When I run this app however my computer starts making a whistling noise and I'm really curious as to why it does this.

If I maximize the screen the noise stops and this is the only time the noise happens. When I play normal games, run apps in XNA or do anything that doesn't involve directly using DirectX it doesn't happen.

The FPS is going up to 3000-4000 when the app is running and drops down to 1000 when the window is made to stretch the screen (and the noise stops). I'm taking a guess and saying it's something to do with that?

Anyway, does anyone have any ideas on what is creating this noise?

Thanks


texts: Is there a reason not to delete the System.Collections namespace in Unity3D?

texts:
I find various scripts on tutorials, books and even on the community wiki using the System.collections namespace without ever actually using it.

Is this an obscure Unity3D requirement, or are the authors using the default script template and forget/don't bother deleting the import?


texts: Material looks different on programatically generated mesh compared to resized default cube mesh

texts:
I've written some code that generates a mesh from some 2D nodes, generating both triangles and vertices. It seems to have worked pretty well, since I get a solid mesh without any weird rendering artefacts:

As you can already see in the preview, I am experiencing some problems with lighting and materials, despite the triangles and vertices being completely valid and wound correctly.
This is probably shown best by comparing this with a mesh created via right click > 3D Object > Cube, with the exact same material assigned as the programmatic mesh:

I have tried calling RecalculateNormals() on the mesh, but this doesn't help.
I'm really stuck trying to work out what's going on, so any help is very much appreciated.
Edit:
In lieu of the code, here are the vertices and triangles that I'm using in this mesh:
Vertices: [(0.5, 0.0, 0.5), (0.5, 0.0, -0.5), (-0.5, 0.0, -0.5), (-0.5, 0.0, 0.5), (0.5, -0.5, 0.5), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5), (-0.5, -0.5, 0.5)]

Triangles: [(3, 0, 1), (3, 1, 2), (5, 4, 7), (6, 5, 7), (0, 4, 5), (5, 1, 0), (1, 5, 6), (6, 2, 1), (2, 6, 7), (7, 3, 2), (3, 7, 4), (4, 0, 3)]

For @Phillip:
Mesh editing = Instantiate(new Mesh());

Vector3[] vertices;
int[] triangles;
GenerateVertices(out vertices);
GenerateTriangles(in vertices, out triangles);

editing.Clear();
editing.vertices = vertices;
editing.triangles = triangles;
editing.RecalculateNormals();


texts:
I'm, trying to wrap my head around assimp to import some files, including fbx/obj etc.

Normally my experience tells me that I start at root node and then recursively load child nodes until I load the entire hierarchy. Assimp seems to have the same thing with each aiNode->mNumChildren so that part is clear to me.

What I struggle to understand is the meaning of each aiNode. As it turns out, each aiNode can be a camera/light/group/mesh/other.

This is where I get confused, if I debunk a node, and it ends up having mNumMeshes = 1 and mNumChildren = 2, that confuses me. It tells me that node is both group and a mesh at the same time. Not to mention if meshes >1 then I have no idea how to interpret it.

On top of that there appear to be extra "dummy" assimp nodes for internal purposes or something like that? They have specific name somehow, what do I do with that?

So far, I filter all meshes/camera/lights into separate arrays and I cross check each aiNode against the camera/light node to find out whether that node is a camera or a light. Groups can be identified by checking whether mNumChildren > 0, but meshes are black magic to me. Not to mention dealing with transforms...

aiCamera is also confusing as it appears to have a Matrix4x4 for position as well as up/lookat/ etc? I'm lost, which matrix/coords do I use, those in aiNode, or aiCamera?

How can I interpret this to re-create a proper hierarchy tree?


texts: Best practices for UnitTesting heavy Flash game clients and libraries?

texts:
We have several quite heavy game clients completely written in AS3 (some also use Flex for UI). Some clients are built with PureMVC, others are a pile of spaghetti code that's grown over the years. We also have several libraries used by our game clients that are written in AS3/Flex.

I'm tasked to evaluate the benefits/risk/cost of applying unit-testing to our clients and libraries and decided to give FlexUnit a closer look. I chose FlexUnit for a first attempt over fluint since FlexUnit is definitively able to test pure AS3 projects while I'm not sure about that for fluint.

Now I'm wondering what some good starting points and best practices are to get unit-testing into previously untested applications.

So my questions for unit-testing game clients and libraries are:

How to get started? What are "low-hanging" (= easily testable) fruits to test with unit-testing?
What are commonly tested aspects of game clients?
Can you apply unit-testing to the BBOY design pattern or do you need to (extensively) refactor the game clients?
Is it useful (and does it make sense) to test asset loading? If so, how to do it (comparing a binary diff, or comparing hash checksums, or ...)?
How to test server communication and asynchronous commands?
How to integrate the whole thing with Hudson/Jenkins CI server and Maven? Are there any reporting tools that can generate overviews of the run tests and report which test failed on which function/class?

I'm thankful for all pointers about the issue (direct answers, blog posts, forum discussions, how-tos, etc. etc. etc.) since I have little previous practical experience with unit-testing.


texts: Per-Texel lighting? (not per-vertex or per-pixel)

texts:
In my game, I have a 3D shader that does lighting using color ramps on models with very low resolution textures. Basically, the vertex shader calculates color values for direct light and ambient occlusion, and then I look up into a color ramp what color to draw, and multiply this by the texture map.

Here's some pseudocode for that:

// vertex shader:
color_vert.r = ambient_occlusion(vertex)
color_vert.g = direct_lighting(vertex)
color_vert.b = shadow_lighting(vertex)

// fragment shader:
// First, the color is whatever the direct lighting was
color_fragment = direct_lighting_ramp_lookup(color_vert.g)
// Multiply by ambient occlusion and shadow
color_fragment *= ambient_lighting_ramp_lookup(color_vert.r)
color_fragment *= shadow_lighting_ramp_lookup(color_vert.b)
// Mutiply by the surface texture
color_fragment *= texture_lookup(color_vert.uv)

Now, this kind of lighting would be fine if I had very high resolution textures, but unfortunately my textures are very low resolution. So each texel (that is, the block of pixels corresponding to one pixel of the texture) is quite large, and lighting gets interpolated across the texel.

Here's an image of what that looks like:

And here's a closeup to show you what I mean:

Notice how the color is smoothly getting interpolated accross the low-resolution texels? How can I write my shader such that the lighting gets clamped on a per-texel basis? Is such a thing even possible? The only solution I can think of is to first generate a lightmap for the whole scene with 1-1 mapping to texels, but I'm afraid that would be too slow / use too much memory.


texts:
I created the following tile grid in unity3d:
The blue dot is the  absolute center point (0,0) of both scene space and tile map.

Now I am trying to calculate the X/Y position of points on the tile map ( the black coordinates). The red coordinates are positions in the scene space. Every calculation I make just gives me a wrong result. Is the tile map roatated the wrong way? Any help really apreciated!


texts: In Cocos2D, how do I check for collisions against an arbitrary user-drawn shape?

texts:
I want to detect a collision between a sprite and a user-generated shape of some sort.

For example. There are 3 objects on the screen. The user takes their finger and draws an abnormal shape around 2 of the objects. I need to detect those 2 objects.

How do I approach this efficiently using Cocos2D?


texts:
I have a rotation 4x4 matrix to generate a model matrix, but I would like to be able to control it like cinema4D or 3ds Max with three separate angles that are always perpendicular to each other, and so far I've had no luck...

Currently, every time I change one of the angles, I call a function containing the following code:

self->rot_matrix = mat4();
self->rot_matrix = mat4_rotate(self->rot_matrix, 1, 0, 0,
    rot.x);
self->rot_matrix = mat4_rotate(self->rot_matrix, 0, 0, 1,
    rot.z);
self->rot_matrix = mat4_rotate(self->rot_matrix, 0, 1, 0,
    rot.y);

This doesn't work though, because when I rotate around z or x, the y axis should change, but not the y angle... I'm terrible at this sort of mathematics, and would appreciate a simple explanation of what to do.

One idea I've had would be to have two vectors define the rotation system, and then use rodrigues rotation to update them, this I can do with ease, but I have no idea how to transform those two vectors back to a rotation matrix.

Thanks in advance!


texts: Tweening multiple image objects in html5/js

texts:
Is there an optimal way to choose when tweening multiple images as a single image?

For example let's say i have 10 preloaded image objects in my script, and i want to place them one on top of the other (the arrangement is supposed to be dynamic), and then tween it as a single "collage".

Do javascript tweening libraries like Tweenjs/GSAP etc, care about how many objects you tween concurrently (as long as in the end they move in the same direction and with same speed), or is it transparent for the fact that the hardware will move an array of pixels in the end?

Do you think that it would be better - performance-wize - to pre-combine the multiple images into one larger image, and then feed it to the tweening algorithm?

I would like to do it this way, as it would be more transparent to me, seperating the image "collage" process from the tweening process, but i haven't found a way to dynamically create javascript image objects by combining multiple single images.

Thank you.


texts:
I'm having trouble trying to get my character to move for a game I'm making in my sparetime for the Xbox. However, I can't seem to figure out what I'm doing wrong , and I'm not even sure if I'm doing it right. I've tried googling tutorials on this but I haven't found any helpful ones. Mainly, ones on 3d rotation on the XNA creators club website.

My question is : How can I get the character to walk towards the right in the MoveInput() function? What am I doing wrong? Did I code it wrong?

The problem is : The player isn't moving. I think the MoveInput() class isn't working.

Here's my code from my character class :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Jumping
{
class Character
{
    Texture2D texture;
    Vector2 position;
    Vector2 velocity;
    int velocityXspeed = 2;
    bool jumping;

    public Character(Texture2D newTexture, Vector2 newPosition)
    {
        texture = newTexture;
        position = newPosition;
        jumping = true;
    }
    public void Update(GameTime gameTime)
    {
        JumpInput();
        MoveInput();
    }
    private void MoveInput()
    {
        //Move Character right
        GamePadState gamePad1 = GamePad.GetState(PlayerIndex.One);
        velocity.X = velocity.X + (velocityXspeed * gamePad1.ThumbSticks.Right.X);
    }

    private void JumpInput()
    {
        position += velocity;

        if (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed && jumping == false)
        {
            position.Y -= 1f;
            velocity.Y = -5f;
            jumping = true;
        }

        if (jumping == true)
        {
            float i = 1.6f;
            velocity.Y += 0.15f * i;
        }

        if (position.Y + texture.Height >= 1000)
            jumping = false;

        if (jumping == false)
            velocity.Y = 0f;
    }
    public void Draw(SpriteBatch spriteBatch)
    {
        spriteBatch.Draw(texture, position, Color.White);
    }
}

}


texts: 3d rotation of a Gunner unit to shoot the target

texts:
I'm developing a scenario to shoot incoming targets by a specific gunner unit, however I'm confused to actual logic of shooting an object with a gun. I'm working in 3D environment.
I'v target's position vector i.e [x,y,z] and its rotation vector [x,y,z,angle], and also Gun's position vector i.e [x,y,z] and its rotation vector [x,y,z,angle]. The gun has two components, i.e a TopDondur and a set of Barrels, both components have the rotation along y-axis, i.e only angel of rotation vector [0 1 0 angle] is required to move the Gunner Unit to the target.

What rotataions shuould give the Gunner unit to rotate both TopDondur and Barrels, i.e TopDondur rotates to the target and Barrels are to move up/down with respect to that target.


texts:
I'm just getting started in DX12 after a bit of time in Vulkan, I am trying to update a part of a dynamically indexed buffer I'm using to hold mesh transforms.
I'm using the MSFT MiniEngine examples which include wrappers for upload buffers, and am not sure if I can use them to update an existing buffer, or if they're supposed to be the main resource used in place of the "GpuBuffer" in the same engine.
Any specific insight into the use of those classes would be really useful, but more generally, is it possible to update part of a buffer, or will I have to upload a copy of the whole thing?
Obviously a simple example would be brilliant if anyone has one..


texts: Determine Mesh Vertex Index Given Another Mesh Index

texts:
Please bare with me as I explain what I am trying to accomplish :P

Each 'X' below represents a mesh vertex:

For my Unity3d GameObject (G1); the mesh vertices are stored in a C# List object in the following order. *Note the mesh index 'A'. This is a value I know - in this case A=16 (mesh index 16).

I have another GameObject (G2) whose shape is the same (a simple rectangle) but the mesh vertices are ordered differently.*Note the mesh index 'B'. This is a value I dont know and I want to find this value (mesh index) - in this case B=17 (mesh index 17).

As you can see the mesh arrangement is pretty much the same except rotated 90 degrees. If I know the 'mesh vertex index' of A how can I find the 'mesh vertex index' of B?

Whats an algorithm that can calculate the mesh index of B? My attempt is not working at all:

uint A     = 16;
uint nCols = 6;
uint nRows = 4;

// Technically both B and A sit on Row 3, Column 5 so if I can find A's row and column maybe I am there?
uint aCol = 16 / nCols;        // nup not right
uint aRow = (16 % nCols) - 1;  // gives 3

// Once I've calculated aCol and aRow its easy
uint B    = (aRow * nRows) + aCol;  // ie, (3 * 4) + 5 = 17


texts: Rotating a model AND translating it forward in XNA

texts:
I have this enemy class, and I want it to

1) Spawn at a certain place Vector3 pos

2) Rotate to face my player position

3) Move forward

As this code is now, it will appear at it's specified place: pos, and attempt to rotate to face it's target: targetShip. It fails to correctly face it's target, because of this offset.

If I remove the code that assigns a value to translation, or if I normalize pos then the model will appear at   the origin and rotate to face it's target correctly.

If I try to move it at all using any of the comment out code regarding translation, It appears to start someplace else and I never can find it.

However, if I remove the code relating to rotation, and uncomment the code relating to translation, then I can get it to move forward.

The trick is doing it all together.

    class Enemy : BasicModel
    {

        Matrix rotation = Matrix.Identity;
        Matrix translation = Matrix.Identity;
        public Vector3 pos, up, right, targetShip,dir;

        public Enemy(Model m, Vector3 pos)
            : base(m)
        {
            up = Vector3.Up;
            //sets the position to the Vector3 as it's spawn point.
            translation = Matrix.CreateTranslation(pos);

        }

        public override void Update()
        {
            //Glo is a global class, where I store the player world.
            targetShip = Glo.world.Translation;
            targetShip.Normalize();

          pos = transform.Translation;

          rotation = RotateToFace(targetShip, pos, Vector3.Up);
          //Attempt at moving the model forward. Causes it to go out of view
          //translation *= Matrix.CreateTranslation(this.GetWorld().Backward);
          //translation *= Matrix.CreateTranslation(pos);
        }

        public override Matrix GetWorld()
        {
            return rotation * world * translation ;

        }

        /*Params: O = Our target
         * P = Our position
         * U = up.
         *
         * Code from some site I googled up.
          */
        Matrix RotateToFace(Vector3 O, Vector3 P, Vector3 U)
        {

            //The direction we're facing.
            Vector3 D = (O - P);
            //Our relative Right.
            Vector3 Right = Vector3.Cross(U, D);
            Vector3.Normalize(ref Right, out Right);
            //Our back
            Vector3 Backwards = Vector3.Cross(Right, U);
            Vector3.Normalize(ref Backwards, out Backwards);
            //Our relative up
            Vector3 Up = Vector3.Cross(Backwards, Right);
            //Make a matrix out of all of these.
            Matrix rot = new Matrix(Right.X, Right.Y, Right.Z, 0, Up.X, Up.Y, Up.Z, 0, Backwards.X, Backwards.Y, Backwards.Z, 0, 0, 0, 0, 1);
            return rot;
        }

    }
}

----

This is fixed now, and all this code is mostly obsolete.


texts: Using real football (soccer) names from the past?

texts:
Is it legal to use really old names in a manager style game?
It there an expiration on name license rights?


texts: How to create a 2D tile-map in python ASCII style

texts:
Still learning about python programming and I wanted to create a little map like below but the thing is I know a for loop will draw down not draw across. However, I want to change the size of the area and add new tiles later on. I understand that this might be a really bad question but I cannot wrap my head around this.
posX = 0
posY = 0

tile1 = 'X'
tile2 = 'O'

width = int(12)
height = int(9)

'''

<--- 12 --->
XXXXXXXXXXXX ^
XOOOOOOOOOOX |
XOOOOOOOOOOX |
XOOOOOOOOOOX
XOOOOOOOOOOX 9
XOOOOOOOOOOX
XOOOOOOOOOOX |
XOOOOOOOOOOX |
XXXXXXXXXXXX v

'''

#Draws down and across
for i in range(width):
    print(tile1 * width)


texts: Video game entity storage and structures

texts:
I finally have all the working input/output of a game engine.

However, I'd like to be able to put an amount of about 2000 shots being simulated in a region, total. I have done other games where all the data was stored in a linear array and iterated every turn, and referenced by index number.
This method seems to be fast enough, grants random access instantaneously and I'd say it "just works". However, inserting a new element requires searching for an empty space, and iterating over the "inactive" shots.

Considering the amount of max shots, what would be the best approach to this? Am I thinking too much about this, perhaps, and the array is a good enough system?

The engine works in C99. Shots will be destroyed when out of "practical" range and collisions will be done around the player rather than the entire working map. The game is real-time action style so updating needs to be quick, and shots might need to be accessed by position, which is another weakness of the array approach (unless I add that information to "slices" of the main map, I guess).

To summarize. What would be the best data structure in terms of insertion speed, allowing random access and iterating without gaps? A name, if it exists,  would be enough.


texts: Basic terrain shader without using external texture

texts:
I have this:

(Right now I have the height map in a x*x size 2D array and a 1D vector too.)
What I am trying to achieve is something like this:

Without using any textures, only plain colors. So basically smooth transitions and some shadow (using shaders).
My vertex shader looks like this:
    #version 330
    layout (location = 0) in vec3 Position;
    layout (location = 1) in vec3 Normal;
    layout (location = 2) in vec3 Color;

    out vec3 fragmentNormal;
    out vec4 ex_color,pos;
    out vec3 N;
    out vec3 v;

    void main () {
    pos= vec4(Position,1);
    ex_color = vec4(Color,1);
    fragmentNormal = Normal;

    v = vec3(gl_ModelViewMatrix * pos);
    N = normalize(gl_NormalMatrix * Normal);

    gl_Position = gl_ModelViewProjectionMatrix * vec4(Position,1);

I have normals for all the vertices. Color is set simply in the c++ code based on height.
Here is the fragment shader
    in vec3 N;
    in vec3 v;
    in vec4 ex_color;
    void main(void)
    {
       vec3 L = normalize(gl_LightSource[0].position.xyz - v);
       vec4 Idiff = gl_FrontLightProduct[0].diffuse * max(dot(N,L), 0.0);
       Idiff = clamp(Idiff, 0.0, 1.0);
       gl_FragColor = Idiff*ex_color;
    }

So I guess my problem is what formula should I use to mix the colors. I think I don't need to set the colors in the c++ code but in the shaders.
Update:
Here is the wireframe of the terrain.

Update2:
Based on @Babis' answer the result is:

So the gradient is not "projected" onto the surface as I would like to do. What could cause this? Maybe my qustion wasn't clear.


texts:
I have a very minor NPC. A chicken. My target is for it to move a random amount, in a random direction for a random time then wait a random amount of time before moving again. Like a chicken. But I do not want it to be to complicated. Still as I am very new in Unity and C# it really got me (it was easier to make a controllable character)

This is my code:

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

public class CockBrain : MonoBehaviour {

    public float duration;    //the max time of a walking session (set to ten)
    float elapsedTime   = 0f; //time since started walk
    float wait          = 0f; //wait this much time
    float waitTime      = 0f; //waited this much time

    float randomX;  //randomly go this X direction
    float randomZ;  //randomly go this Z direction

    bool move = true; //start moving

    void Start(){
        randomX =  Random.Range(-3,3);
        randomZ = Random.Range(-3,3);
    }

    void Update ()
    {

        //Debug.Log (elapsedTime);

        if (elapsedTime < duration && move) {
            //if its moving and didn't move too much
            transform.Translate (new Vector3(randomX,0,randomZ) * Time.deltaTime);
            elapsedTime += Time.deltaTime;

        } else {
            //do not move and start waiting for random time
            move        = false;
            wait        = Random.Range (5, 10);
            waitTime    = 0f;
        }

        if (waitTime < wait && !move) {
            //you are waiting
            waitTime += Time.deltaTime;

        } else {
        //done waiting. Move to these random directions
            move = true;
            randomX = Random.Range(-3,3);
            randomZ = Random.Range(-3,3);
        }
    }

}

What is happening: they are "vibrating" and rotating randomly, then stop after duration and never move again. The prefab is set up like this.


texts: Translating an Object to a certain Vector 3 in OpenGL and Java LWJGL

texts:
So after almost two hours, I got the hang of using glTranslated() (with Java and LWJGL). If I am correct, applying glTranslated on an object moves that object with the x,y,z relative to the previously moved object. I believe the correct term for this is local vs global, global being the one I want. I was wondering if there was a way to translate an object to a specific XYZ position, or relative to the origin. Thanks!

(Code or other details can be supplied if it helps, just let me know. Also sorry if this is a noob comment, Im very new to OpenGL.)


texts:
I have a decent background in 3D graphics and programming, but I'm new to game development. I'm currently exploring different possibilities and I really want to make an RPG game. I was thinking about classic 2D isometric view, but I really love how Diablo 2 looks and feels to play.

My question is - how can I achieve Diablo 2's parallax effect? Everything looks hand drawn with baked lights and shadows and looks awesome, but when you move around you notice some perspective.

For example, let's say that I drew a big hall with columns in Photoshop with an orthographic perspective (classic pixel art style, just parallel lines). How would I give parallax effect to this scene when the character moves around? If I use camera-facing sprites for everything it would probably look OK in the distance, but it would be really fake when a character comes close to a column (cylinder) for example.

Any suggestions? How did Blizzard make the parallax effect in Diablo 2?

See this screenshot: http://guidesmedia.ign.com/guides/10629/images/act2tombs.jpg


texts: How to protect save game data when saving game over the network?

texts:
Newbie question please - I am working on my own RPG, using Unreal Engine 4 and C++.

Regarding data formats - I figured I would just make HTTP Post requests to store the data as JSON in AWS's DynamoDB, are there any security considerations to avoid players somehow tampering with the APi request/response such as, modifying progress state or items state - how is data safety ensured when making server calls? Should I encrypt the game data and decrypt it on the client?

I only want to prevent "casual tampering", because obviously client decryption will never be 100% safe. I just don't want to make it super easy to figure out "if I modify this value here, my armor increases 1000%"

Thank you,


texts: What are the best alternatives to Unity Asset Store for publishing game assets?

texts: I'm not sure if this is the right place to ask this so go easy on down-voting


texts:
I'm having some issues loading in textures in OpenGL, as my textures keep rendering incorrectly or coming out looking muddy. For instance, here I tried to load a 256x256 color spectrum image. On the left is how it looks in OpenGL and on the right is how it looks in an image viewing program:

As you can see, while the left image resembles the right image, the left image appears to squish the blues, and greens, and extend the pinks.

I also tried loading in this 512x512 image of a dog and the result came out like this (again, left is OpenGL, right is image viewer):

For this image, the image looks like it has lost a lot of its color, resulting in something that looks white washed and like it came out of a 1970s camera. (the fact that is flipped is fine however since the cube that I am drawing this on has some texture coordinates flipped to accommodate for a different image).

I load in these .BMP textures using SOIL, as such:
    glEnable(GL_TEXTURE_2D);

GLuint texID = 0;
glGenTextures(1, &texID);

int height = 0, width = 0;
unsigned char* imgData = SOIL_load_image(filePath.c_str(), &width, &height, 0, SOIL_LOAD_AUTO);

glBindTexture(GL_TEXTURE_2D, texID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, imgData);
// set texture filtering, gen mip map

Then in my fragment shader I do the following to apply the texture:

#version 330 core
in vec2 TexCoord;

uniform sampler2D textureSampler;

void main() {
    gl_FragColor = texture2D(textureSampler, TexCoord);
}


texts: How can I render something like the swirling clouds of Jupiter?

texts:
The effect should be as similar as possible to this, though it does not need to be at planetary scale.

I was thinking that it could be done offline via particles, perhaps by directing their motion in some way. Then rendering the frames to a texture and playing these back in a loop for real-time rendering?

But I wonder if there is some other real-time way... maybe mesh patches shaped like swirls can be moved around, after being textured carefully, to imitate the motion of swirls of gaseous matter?


texts:
Getting my feet wet with Stride (formerly Xenko), I want to build a level editor where a user can drag the mouse to create walls at runtime.

I found documentation on how to immediate draw vertices per frame, but I want those vertices to be persistently stored for a mesh.

So I tried navigating through the API with IntelliSense, but didn't get further than this:

public class MeshScript : SyncScript
{
    public override void Start()
    {
        Mesh mesh = new Mesh();
        // The following is what I expected, but the properties do not exist:
        mesh.Vertices = new Vector3[] { ... };
        mesh.Indices = new ushort[] { 0, 1, 2, 0, 2, 3 };

        Model model = new Model();
        model.Meshes.Add(mesh);

        Entity.Add(new ModelComponent(model));
    }

    public override void Update() { }
}

Does anyone have a link or can explain to me which steps are needed to do this?


texts:
for my current project I use gamepad. I was successfull in hooking it up in C# through SlimDX. Everything works fine, only problem is that thumbsticks don't fully use the active range.

If I move stick all the way to left on X axis, I get maximum value half-way through. Then the driver clips the values returned.

I understand, why this happens. The driver operates in square area, but the stick in circle.

The red square marks values I get from driver. The blue area represents actuall physical range of sticks and the green one is what I want to get from the gamepad. I get these readings in calibration utility and in my program too.

My question is: is this normal behaviour for gamepads? Do I have to buy better one? Currently I'm using really cheap one - Genius MaxFire Grandias 12, as I don't want to invest much into this.


texts:
My game uses an entity manager and entities to represent everything including the player, enemes, items, ..everything in the game. In my engine it's the responsibility of every entity to update itself.

Sometimes an entity finds out it has expired somehow, and thus needs to remove itself from the entity manager. My question is: Is it safe to have an object delete itself? I will illustrate what I mean.

void EntityManager::remove_entity(Entity* entity) {
    m_entities.erase(std::remove_if( //...
}

void Entity::update() {
    if (has_expired)
        m_manager.remove_entity(this); // <- safe?
}

I can't concretely prove a bug by using this, but it kind of looks and feels like it should at least be undefined behaviour. So is it OK? If not, what is a common practice for dealing with this situation?


texts: What advantages does multisampling have over supersampling?

texts:
I never really fully understood this, or found an article which explained all the steps in a friendly way.

I'll start with what I do know already (which I hope do not contain misconceptions). I'm pretty sure allocating a multi-sampled frame buffer requires as many times the memory (of a regular buffer) as the number of samples (N). This makes sense because each pixel may be sampled up to N times.

During rasterization, the GPU generates a fragment for the MS frame buffer by testing if each sample is inside of the geometry being drawn. This is what provides edge anti-aliasing. Each sample produces a fragment.

I'm unsure about what occurs when all samples of a pixel are inside the geometry. How many fragments are generated? Is this configurable? What if I want to sample the "inside" pixels 4 times, and the edge pixels 16 times? This would require a 16x MS frame buffer.

Are there other differences? It seems like if the fragment shader is run once on each sample then we are left with something not much different from basic supersampling with the exception of jittered sample locations.

Actually, I'm also a bit unsure about what a frogment really is. It seems like a fragment shader gets (can get) executed more than once per pixel in a multi sampled scene, however this doesn't seem to necessarily mean that a fragment is more related to the sample than the pixel. Is a fragment best thought of as a sample, a pixel, or something else?


texts: Finding translation component of a 4x4 matrix inverse

texts:
I have 4x4 matrix (A) (maya softw):

|Xx Xy Xz 0| - basis of X and dummy 0
|Yx Yy Yz 0| - basis of Y and dummy 0
|Zx Zy Zz 0| - basis of Z and dummy 0
|Tx Ty Tz 1| - Position x, y, z and dummy 1

In this case, I know there is no scaling or sheer, so the upper-left 3x3 portion is a pure rotation matrix. That means I can invert this portion by taking the transpose.

So inverting the matrix should give me something like this:

|Xx Yx Zx 0|
|Xy Yy Zy 0|
|Xz Yz Zz 0|
|T? T? T? 1|

But I don't know how to find the T? values that correctly invert the translation component of the matrix. It's not just the inverted position (T-1)

My thinking so far:

Matrix of an untransformed object at the origin - (I - identity):

| 1  0  0  0 |
| 0  1  0  0 |
| 0  0  1  0 |
| 0  0  0  1 |

Matrix of a translated object (Tx=3, Ty=4, Tz=5) (A):

| 1  0  0  0 |
| 0  1  0  0 |
| 0  0  1  0 |
| 3  4  5  1 |

Inverse matrix of A (A'):

| 1  0  0  0 |
| 0  1  0  0 |
| 0  0  1  0 |
|-3 -4 -5  1 |

Matrix of translated and rotated(Y=90) object(B):

| 0  0 -1  0 |
| 0  1  0  0 |
| 1  0  0  0 |
| 3  4  5  1 |

inverse matrix of B (B'):

| 0  0  1  0 |
| 0  1  0  0 |
|-1  0  0  0 |
| 5 -4 -3  1 |

Strange things start to happen when you take two differently-rotated matrices with the same translation and you get different inverse translations!

It seems like some dot product is involved in the translation calculation.


texts: SharpDx how to detect if Mouse Button is pressed?

texts:
I'm wondering how it's possible to detect if a mousebutton is pressed or released.

var di = new DirectInput();
_mouse = new Mouse(di);
_mouse.Acquire();
_mouseState = _mouse.GetCurrentState()

All I can access is now the X Y and Z Axis of the Mouse and the Boolean array Buttons.
Any Ideas?


texts: How could an XNA game close with no exception being thrown?

texts:
I've been messing with my game's network code recently (TCP/UDP sockets) and my game keeps shutting down with no exceptions being thrown at all.

It runs fine until the disconnection of a client, so I already know that it has to be related to the network.

My real problem is that no exception is thrown and the game silently exits on both the client and server sides. How's that even possible? What could end the runtime of an XNA game?


texts: LibGDX How to take screenshot and use as background for pause screen

texts: So I am trying to take a screenshot of the current situation during the PlayState of the game and when the player pauses the game I want the game to take a "screenshot" save it in memory and not as a file and use it as the background for the pause screen. Any ideas because I have no clue.


texts: Drawbacks to an Octree and Quadtree hybrid?

texts:
I've implemented an octree to divide 3D space that contains several objects.
I've noticed in certain octree nodes I could use more refinement in some axis, but splitting the node into 8 children is a bit overkill.
Imagine a neighborhood full of buildings. At some point, it doesn't make sense in my case to further subdivide in height, but I need more precision in the other two axis.

Is there any major drawback to subdivide an octree cell into just 4 children, ie., subdividing in only two axis?
This would create a hybrid between an octree and a quadtree.

I haven't found any documentation related to this, which seems strange to me, given it looks like a simple approach to a common problem.


texts:
I am using this script below to move an animation in unity with no root-motion. It simply walks across the terrain.

I have timer attached also so the animation doesn't start to walk for 60 seconds. This works fine in the scene when played…but when I navigate into this scene from another home scene the timer delay doesn't work as I guess it has been triggered already and has already reached the 60 second mark? I have tried using DontDestroyOnLoad but this just recreates the animation in the home scene also.

I'm trying to keep the code as simple as possible and maybe add to the code below to fix it:

void Update ()
{
    if (Time.time > 60)
    {
        transform.Translate (0, 0, Time.deltaTime);
    }
}


texts:
The documentation on how to use IK functions clearly states that an Animator Controller with at least one animation for the character is required and then Layers pane, IK pass, etc...

However, I cannot have an animator controller due to my using a motion-capture plug-in for Unity (Xsens motion capture). If I add one, it starts off with that animation and then no live streaming of motion data...

I would still like to be able to use some IK functions though. I am not yet clear how they might help me, but basically I wanna apply the motion that, say, animates a character's right hand to another character's left hand, to create the impression that one character is responding to the other by copying his movements in a similar way. Is there any other way of using IK functions? Perhaps somehow in LateUpdate?

I do now know whether this is possible in MecAnim because maybe right and left hands and their bone structures (topology) are different.


texts:
I am currently working on a small side project (as usual), and trying to build up from previous experiences.

I have the following elements in the game:
1) Region: which contain a "food" target that has to be met
2) Location: Each region has a few location, where crops can be sown
3) Crop: A variety of crops with different effects

I currently have a system where I have a Region monobehaviour script that only considers the production of food from the crops.
The location monobehaviour, stores the current state of the location, namely what crop is currently on it and how much food is currently available.
I also have all the food production logic on that script.
The crop scripts are scriptable objects with different food production rates and water consumption values.

I run into a problem when I started to want to add other types of elements to the location, or rather, have crops that don't necessarily produce food but have another effect on the game.

I decided to build another system, where instead of having the logic that triggers the various methods on the location script (for example the ProduceFood(), SendFood(), ReceiveFood()) within the location script itself or via hard links from UI elements.

This new systems is centred on Action scriptableObjects that can be added to the Crop scriptableobjects. The action script contains an Act(Location loc) method as well as a SetUp(Location loc) and Disable(Location loc). I can now customise how and when the ProduceFood(), SendFood(), ReceiveFood(), etc methods on the location script get called. For example the ProduceAction will add the Act method to a delegate event on the location script that triggers when a global OnProduction event gets triggered. Similarly, my hard UI links now point to a method on the location script called UITriggerAction(int index) which triggers the Act method registered to a delegate array on the location script.

Now each time a change the crop at a location I call the Disable method on all the Actions of the current crop, then I replace the crop and call the SetUp method on it, which will either register the associated Act method to the array accessible from UI, or to some other custom event.

The Act methods would be simple and look like:

Act(Location loc)
{
    loc.Produce();
}

or

Act(Location loc)
{
    if(loc.HasProduced())
    {
        loc.SendFood();
    }
}

By doing it this way I keep the variables specific to the location on the location script as well as the logic on it. In addition I avoid any dependency between the current crop at a location and the rest of the game. For example I could have a method from the Region script, that would check all the currentFood values on the locations, and it would still work even if the crop at that location doesn't impact the currentFood value at that location.

int AvailableFood()
{
    int availableFood = 0;
    for (i = 0; i < loactions.Length; i++)
    {
        availableFood += loactions[i].currentFood;
    }
    return availableFood;
}

I just control the way in which I call those methods using a more versatile system.

My question is: Is this likely to lead to a very messy code on the location script where I will have all the variables and all the methods to do everything?

Do you have any suggestions on how I can improve that system?

Supporting code:

class Location : MonoBehaviour
{

    Region parentRegion;
    Crop currentCrop;
    public int currentFood;
    int maxFood;

    public delegate CropAction(Location loc);
    public CropAction[] actions = new CropAction[6] // 6 possible actions accessible from UI

    public void UITriggerAction(int index) { actions[index](this);  }

    public void Produce() { // Do stuff   }
    public void SendFood() { // Do stuff   }
    public void RecieveFood() { // Do stuff   }
    public void UseWater() { // Do stuff   }
    public bool HasProduced() { return currentFood > 0;  }

    public AddCrop(Crop crop)
    {
        loc.Produce();
    }
}


texts: What's the preferred way to put music in a java applet?

texts: Is there an easy way to put music in a java applet? Preferably streaming so that it doesn't need to be preloaded.


texts:
The problem :

I tried adding deltaTime into my game, which seems to not be working when I try to smoothly move a object in my game.

 How I calculate delta time :

Delta Time variables :

float elapsedTime = 0;
float lastFrameTimeElapsed = 0;
float deltaTime = 0;

At start of game loop I do this :

elapsedTime = SDL_GetTicks();

At end of game loop I do this :

deltaTime = elapsedTime - lastFrameElapsedTime;
lastFrameTimeElapsed = elapsedTime;

And then the game loop ends.

 How I try to move my object using delta time :

My SDL_Rect variable :

Definition :

SDL_Rect* m_rect;

Initialization :

m_rect = new SDL_Rect();

My move function :

void Sprite::Move(float offsetX, float offsetY)
{
    m_rect->x += (int)offsetX;
    m_rect->y += (int)offsetY;
}

How I call the move function :

Move(5 * deltaTime, 0 * deltaTime);


texts:
In my current project, Lua scripts are called by the C++ functions on the server side.
After that, the scripts again call the C++ functions still in that solution.
Why should we do such things and not call the C++ function directly?
What are the situations in which scripts are needed?


texts: What's the use and difference between Forward, Deferred and Physically Based Rendering?

texts:
Maybe I'm still confused about my own understanding,

Forward Render: render the lighting of an object according to the light source in the scene. (e.g Phong)
Deferred Render : render the scene to get geometric information, store it in a buffer, and then apply lighting. (e.g ?)
PBR : treats lights in the scene the way it behaves in the real world. (e.g Ray tracing, Photon Mapping)

I don't see how Forward and Deferred render are going to give much difference to the scene. Why do we need to store the geometrical value in Deferred Render before applying lighting ? Why don't we just compute lighting right away like Forward Render ?

Also for Physically Based Rendering, computing each light takes a lot of time, and almost impossible to be done in real time. But why this technique is always considered the best ?


texts: How to create OpenGL models like the ones created by blender's wireframe modifier?

texts:
How could I create programatically wireframe models like this out of a triangular mesh? What'd be the algorithm behind?

(Source)

Creating an additional mesh using lines instead triangles or just using a single mesh with the typical geometry shader using barycentric coordinates are the most straightforward approaches. But they're far away from being as cool as the results shown in the above link.

So I was wondering how difficult would be creating a new mesh like the shown in the above link, would it be possible to achieve by just having a simple triangle soup?


texts: Unity won't Instantiate() outside of Start(), even though code is the same

texts:
I am trying to add a gameobject to my game using a socket connection. I have a SocketHandler class, which simply connects to my NodeJS socket server, which can also call a method on another class, which will add a new gameobject to the game. Here is how it basically works:

void Start () {
    GameObject car = Instantiate(CarGameObject);
    car.transform.parent = this.transform;
    car.GetComponent<TestCar>().text.text = "Volkswagen";
}

This works fine and it adds the gameobject to the game upon starting. However, if I do something like this in my SocketHandler, it doesn't work:

var addCar = new AddCar();
socketio.On("addCar", (data) => {
    string str = data.ToString();
    Car data2 = JsonConvert.DeserializeObject<Car>(str);
    addCar.AddNewCar(data2);
});

and then inside my AddCar class, I have the AddNewCar() method:

public void AddNewCar(Car input) {
    GameObject car = Instantiate(CarGameObject);
    car.transform.parent = this.transform;
    car.GetComponent<TestCar>().text.text = input.name;
}

it does not work. If I do a Debug.Log(input.name) inside the AddNewCar() method, it does log the name the server sends. It should do the exact same thing, but the AddNewCar() doesn't get added to the game. It simply does nothing.

What could be wrong?


texts: Only part of my model animates, the rest stays still

texts:
I made an animation for when my character grabs a ledge, which has him set his arms and head into a position, and have him swing his legs back and forth, however only his legs move and his arms and head stay in the default resting position of the model.
I have a video of what's happening. you can see the intended animation on the bottom right, and you can see what happens instead in the video.
Video link: https://youtu.be/PwrBdEsvgpY


texts:
I'm working on a top-down (oblique) tile-based engine. I would like for the tiles to have a definable height in the world, with Characters being occluded by them, etc.

This has led to a desire to be able to "rotate" the view of the world, even though I'm using all hand-drawn graphics and blitting.

Therefor, I need to rotate the actual world itself, or change how the Camera traverses these arrays.

How can, or should, I create individual rotations of 90 degrees, when I have multi-dimensional arrays?

Is it faster to actually rotate the array, to access it differently, or to create pre-computed accessor(?) arrays, something like how my chunks work?

How can I rotate an individual chunk, or set of chunks?

Currently I establish my tile grid like this (tile height not included):

function Surface(WIDTH, HEIGHT)
{
  WIDTH = Math.max(WIDTH-(WIDTH%TPC), TPC);
  HEIGHT = Math.max(HEIGHT-(HEIGHT%TPC), TPC);

  this.tiles = [];
  this.chunks = [];

  //Establish tiles
  for(var x = 0; x < WIDTH; x++)
  {
    var col = [],
        ch_x = Math.floor(x/TPC);

    if(!this.chunks[ch_x])
      this.chunks.push([]);

    for(var y = 0; y < HEIGHT; y++)
    {
      var tile = new Tile(x, y),
          ch_y = Math.floor(y/TPC);

      if(!this.chunks[ch_x][ch_y])
        this.chunks[ch_x].push([]);

      this.chunks[ch_x][ch_y].push(tile);

      col.push(tile);
    }

    this.tiles.push(col);
  }
};

Even some basic advice on my data struct would be much appreciated.


texts: How to implement a save/load system in Unity?

texts:
Many game allows the player to save progress at any time and load the save back at any time (like Minecraft and Doom 3).

I would like to implement it in Unity.

I think I will need to put the value of every variable in every script into a save file, but how?
Or maybe not?


texts: How do I set the mouse to control views like zoom in and out?

texts:
How would I go about using the mouse to zoom in and out of my current isometric tiled map, where the tiles need to be in the center of the view when the application has started?

This is what I have, so far:


texts: Help Applying SDL_Surface on an array of SDL_Surface?

texts:
I'm trying to make a 4x4 blocks (50x50 px) with SDL Surface. Added another block (50x50 px, I wrote the variable as 'flag') that can only move within the 4x4 blocks, so I can select one of the blocks with this one.
The problem is when I move it (say I move it to flag_x + 50), the previous surface (flag_x) is still there, even though I already use blit surface. It's like taking a multiple snapshots of walking person. How can I move 'flag' normally within the 4x4 blocks? Or do I use the wrong method?

Below is the code

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
#include <string>
#include <sstream>

using namespace std;

//Screen attributes
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BPP = 32;

//The frame rate
const int FRAMES_PER_SECOND = 20;

//The surfaces
SDL_Surface *screen = NULL;
SDL_Surface *matchbox[4][4];
SDL_Surface *flag;

....
....
....

bool load_files()
{
    flag = load_image("matchbox2.png");
    if( flag == NULL )
   {
       return false;
   }

   for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
         matchbox[i][j] = load_image("matchbox.png");
         if( matchbox[i][j] == NULL )
            return false;
      }
   }
   return true;
}

void clean_up()
{
//Free the surfaces
SDL_FreeSurface( flag );

for(int i=0;i<4;i++){
   for(int j=0;j<4;j++){
      SDL_FreeSurface(matchbox[i][j]);
      matchbox[i][j] = NULL;
   }
}
//Quit SDL
SDL_Quit();
}

int main( int argc, char* args[] )
{
   for(int i=0;i<4;i++){
      for(int j=0;i<4;i++) {
         matchbox[i][j] = NULL;
      }
}

   Timer fps;

   bool quit = false;

   //Initialize
   if( init() == false )
   {
      return 1;
   }

   //Load the files
   if( load_files() == false )
   {
      return 1;
   }

   int matchbox_x = 50;
   int matchbox_y = 50;
   int flag_x = 50;
   int flag_y = 50;

   //Fill the screen white
   SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );

   //Apply matchbox to the screen
   for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
         apply_surface( matchbox_x , matchbox_y , matchbox[i][j], screen );
         matchbox_x += 50;
      }
      matchbox_x = 50;
      matchbox_y += 50;
   }

   //key event
   while( quit == false )
   {
      fps.start();

      //While there's events to handle
      while( SDL_PollEvent( &event ) )
      {
         //If a key was pressed
         if( event.type == SDL_KEYDOWN )
         {
            switch( event.key.keysym.sym )
            {
                case SDLK_UP: flag_y -= 50; break;
                case SDLK_DOWN: flag_y += 50; break;
                case SDLK_LEFT: flag_x -= 50; break;
                case SDLK_RIGHT: flag_x += 50; break;
            }
         }
         else if( event.type == SDL_QUIT )
         {
            quit = true;
         }
     }

     //collision detection
     if(flag_x < 50)
        flag_x += 50;
     if(flag_x > 200)
        flag_x -= 50;

     if(flag_y < 50)
        flag_y += 50;
     if(flag_y > 200)
        flag_y -= 50;

     apply_surface(flag_x, flag_y, flag, screen);

     //Update the screen
     if( SDL_Flip( screen ) == -1 )
     {
        return 1;
     }
     //Cap the frame rate
     if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
     {
        SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
     }

  }

  //Free the surfaces and quit SDL
  clean_up();

return 0;
}

function examples taken from http://lazyfoo.net/SDL_tutorials/index.php


texts: What is physically correct lighting all about?

texts: I can't find anything comprehensive using Google. I'm wondering what the core concepts of physically correct lighting are, and where I could read up on it. What's physically correct lighting all about? Is Phong illumination generally physically incorrect?


texts:
I'm getting this error when I compile this code.

D3D12CreateDevice(pAdapter, D3D_FEATURE_LEVEL_12_0,
IID_PPV_ARGS(&pDevice)).
Error! No such Interface supported

I've got a rtx 2060 GPU installed in my computer.
All my GPU drivers are up to date.
I've got the windows 10 version 1803(OS Build 17134.590)
I've got visual studio 2017 installed and used to compile my code.

Here is the code I'm trying to compile.
https://github.com/acmarrs/IntroToDXR

What, in the hell is this error man its so stupid.
I've been stuck for over 6 damn hours man.
Any help, much appreciated.