Jump to content

  • Log In with Google      Sign In   
  • Create Account

hannesnisula

Member Since 18 Sep 2008
Offline Last Active Today, 06:24 AM

Topics I've Started

Text file I/O - read line functions and buffering

05 July 2013 - 12:25 PM

Hi!

 

I'm looking into file I/O for text files and I've been wondering about functions which read lines from files. Does anyone know if they normally read in every iteration (for each character) or read into a buffer to maybe speed things up?

 

I'm developing for Windows and I know the OS buffer readings from files (although one can specify not to, with a flag). Because of this I imagine that reading a single character from a file (the cache, really) in every iteration wouldn't be all too bad compared to buffering the file data yourself, right? Has anyone delved into this or perhaps even benchmarked it?


Swapping weight sets and storing meshes

02 March 2013 - 05:31 PM

In Unreal Engine 3 they support multiple weight sets for meshes so they can have limbs detached but not having weird artifacts where the removed bones are influencing the body (described a little bit here).

 

My question is, do any of you have an idea how this might be done? I've been thinking they store each part/limb in its own vertex buffer and swap the buffer used depending on the weight set wanted. They also say that when exporting meshes from 3d modelling software "There is no performance penalty for creating your skeletal meshes this way. The individual parts are all combined when being imported into Unreal Editor." Does this mean they are all stored in the same buffer? Otherwise it would be a penalty right?

 

When having an object (in this case a humanoid) that's rigged with a skeleton and have multiple meshes (parts of the body), how are they connected? Let's say I have a class for objects like this and I want to be able to cut off limbs and having these limbs be completely separate objects, should the bones from the skeleton have a mesh associated with them? Because some parts may contain several bones (like the hand) and I want to keep the hand like 1 logical object and not destructible, how can this be structured in the code?

 

Let's say I want the forearm and hand to be one atomic part of the body and it contains multiple bones from the skeleton and perhaps several different meshes (maybe not this exact case, but there are other cases). If this is an object of its own, it's not clear to me what would be this objects transform, as there are several bones inside of it with their own transforms. Does anyone have experience with similar stuff?

 

I'm not sure I was sufficiently clear about these questions, and there are a lot of them, and if so I apologize and just ask and I'll try to clarify.


Handling of game objects (projectiles, players etc)

07 May 2012 - 06:28 AM

I started to write some code for weapons and firing them when I realized the structure of the game code was a bit weird. I store an array of players in my Game class, I store an array of enemies in my AIManager class but I didn't know where to store the projectiles. I wanted to store the projectiles in Game first, but I can't "put it there" because Game includes Projectile.h and Projectile.h would then have to include Game.h to be able to call its methods, right? Now I wonder how a good way to structure all of the game code would be. It's a very broad term I know and there are probably very many different ways to go about it.

Say I have stored my projectiles somewhere and then I want to detonate it and deal damage to everyone around it, then I need access to all players and enemies and perhaps doodads to check the distance and calculate damage. But how do I access it? What's a general good advice? I thought of sending a pointer to the array of objects to be possible victims but then again I stored all objects in different arrays depending on what kind of object, and in different places and I then I took a break.

What are some general ways to structure this whole mess? I want to have some kind of decoupling of the responsibilities. For example the renderer class is separate from everything. I would like the objects to handle themselves like the projectile would do the exploding itself and doing damage in its own method or something similar.

I suppose the question is kind of unclear and I'm sorry for that, but I don't really know how to put it in a different way. I'm very thankful for any input I may receive!


EDIT: I was thinking of a system where every object handled everything themselves, collision detection and response, updating health points, animations and other possible events. I was looking at the SC2 map editor and it seems kind of complex but incredibly powerful and flexible. Are they doing something close to this?

Right now the code is kind of like containers of players, projectiles, enemies and the Game performs the calculations and updates, I suppose it would generally be a better idea to leave this to the individual objects considering they do different things in their updates. But then I imagine everything would be like a huge array of objects that are just looped through and have their Update method called, more or less. What are you thoughts on this?

Spatial partitioning

19 December 2011 - 08:37 AM

Hi!

I was thinking I would store everything in my world in a quad tree and I thought I had it all solved and settled. So I thought I was going to store the terrain patches in (not the lowest) level of the quad tree and the objects, both static and dynamic, in the lowest levels/leaves. Also, I thought the rule that every item would only be a child of 1 quad tree node would make it easier to do things in the code.

Then it hit me that how do I decide in what node will the object be in? Well, the only reasonable solution would be in the node which the position of this object is in. But then I thought of bigger objects, and also smaller. If I was going to use the quad tree for visual culling some objects might be culled though the item actually intersects the view frustum and hence the object will pop up when I turn around or move.

Another idea I was having that perhaps (?) I might get a performance boost (a small one) if I store adjacent nodes in each lowest level-node for collision detection, for I've planned to do collision detection against objects in the object's node and also those around it to avoid errors if close to the edge. But then if some objects might be huge (castles and stuff) they might overlap with one of the adjacent nodes but not being checked for collision against. This might be solved with bigger lowest level-nodes or having to chop up big objects to fit in one node.

I wonder what are the general solutions to this? I thought I had it all planned but now I'm hesitating on how to do this.

I thought it was possible to loop through parent nodes in the quad tree for collision detection so the big items could be stored there, but I want to avoid this.

[SlimDX] Compile shader

08 October 2011 - 11:09 AM

Hello I've been trying to compile shaders with SlimDX and ShaderBytecode.CompileShader() but I always get the exception that says unexpected 'something' and that something is always the first character in the shader. I've also tried with different shader profiles as "vs_1_0", "vs_3_0" etc so I guess that's not the problem. I set the entry point to the name of the function, for my testing I put it as "vertexShaderEntry" am I supposed to specify parameters or something in that string in the CompileShader() call as well?

From what I've tried I believe there's something wrong with my byte array made from the string containing my whole shader code.


byte[] byteArray = new byte[currentShader.shaderData.Length * 2];
byte[] tempBytes = null;

for(int i = 0; i < currentShader.shaderData.Length; ++i)
{
	tempBytes = BitConverter.GetBytes(currentShader.shaderData.ToCharArray()[i]);
	byteArray[i * 2] = tempBytes[0];
	byteArray[i * 2 + 1] = tempBytes[1];
}

This is the code where I take the shaderData string, consisting of the full shader code, and turn it into a byte array. The string is taken from a multiline textbox control.

I can't seem to find any errors so I'd appreciate if anyone else finds any.

PARTNERS