Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Mar 2013
Offline Last Active Yesterday, 07:57 PM

#5167647 Game engine architecture

Posted by EarthBanana on 18 July 2014 - 11:48 AM

Assimp does not limit 1 material per mesh - very roughly speaking what Assimp calls a Scene is what LSpiro is referring to as a mesh, and what Assimp calls a Mesh is what LSpiro is calling a Subset


Assimp loads the "Scene" as an array of "Meshes" which each have an index in to the array of Materials for the scene


This translates, in my engine, as a Mesh which contains an array of Submeshes, each with integer handles to the material.. Each Submesh can refer to only 1 material.. Each Material then contains an integer handle to the Shader responsible for drawing the material


When using components, don't call your resources components - anything that you have to load could be considered a resource - textures, meshes, animations, audio clips, shaders, etc

You only want to load these things once - and either pass around handles or pointers to these within the engine


IE if you want to have a Render component, it should contain a pointer or handle to a mesh rather than the mesh itself

#5167641 Assimp with Visual Studio Express 2013 and CMake

Posted by EarthBanana on 18 July 2014 - 11:08 AM

Why are you building it yourself? It comes with the necessary lib files for x64 and x86 - you simply need to add the libraries to your project..


Also you will have to add the assimp32 or assimp64 dll file (located in the bin/x86 or bin/x64 folders respectively) to the same folder where visual studio puts your build exe file


To include the libraries just uncompress the sdk to some folder like c:\Assimp

Then add the include path for assimp to the include path for VS2013

To do this right click on your project in solution explorer, go to properties and under Configuration Properties go to VC++ Directories


Under "Include Directories" add the c:\Assimp\Include (or wherever yours is at) folder

Now under "Library Directories" add "c:\Assimpl\lib\x86" assuming you want to use the 32 bit version

Now click on "Linker" in the left pane and add "assimp.lib" to the Additional Dependencies section


Finally go to your Assimp\bin\x86 folder and grab the Assimp32.dll and put it wherever the program your writing's exe is at


I am not using the brand new assimp library - but a recent version (from a few months ago) so the procedure should be the same


To use assimp just #include <assimp/whatever assimp file you need>


Hope that helps - if you already know all this then sorry!

#5153783 Can a non-programmer make games?

Posted by EarthBanana on 15 May 2014 - 08:30 AM

You know - just thought I would mention - I hated computer science.. It just wasn't a very fun or challenging program at my University. I got my degree in something else instead that I was more interested in while learning to program on my own.


I love programming and I have made a lot of stuff by now!


My point is that just because you don't like comp sci doesn't mean you don't like programming or coding in games. Go ahead and get your degree in a program that is interesting to you at the University you are attending - but try learning some programming on your own for fun. I think you will be surprised at how much fun stuff you can do without needing a computer science degree.

#5153591 Creating a Data Block Loader or something?

Posted by EarthBanana on 14 May 2014 - 10:14 AM

You can use templated classes to load different types - in fact its how I load different types of components in to one component vector.. just make whatever your container class is (in my case Entity) templated so that it can call new TemplateType() on whatever subclass type you are trying to add to the vector..


ie my templated Entity class adds components like this

	template<class CompType>
	CompType * createComponent(NSbool pOverwrite=true)
		CompType * comp = new CompType(this);
                mComponents[CompType::getType()] = pComp;
		return comp;

 where mComponents is a vector of component pointers (I removed some error checking stuff to make it more readable)... I personally use a known index system so that certain components are always at certain positions in the vector - but that is irrelevant for you - you could just add the new component with a push back


Also - when you get you menus.. if you have a templated container class to get them from - you can get them without having to typecast each time... just define a getMenu function and do the typecast within the function returning the templated type.. something like this..

template<class MenuType>	
MenuType * getMenu(std::string & pMenuName)
	if (hasMenu<MenuType>(pMenuName)) // check to make sure it has the menu
		return (MenuType*)mMenus.findMenu(pMenuName); // do the typecast here - you might want to use a different type of cast but even this should work
	return NULL; // if no menu was found return NULL

Hope that helps

#5151662 What is your opinion and how would you do a structure that has multyple funct...

Posted by EarthBanana on 05 May 2014 - 12:32 PM

It seems like you are trying to implement a component system - I agree that you don't really need bit fields to do that - why don't you do something like make a base struct called Component (or something similar) and then make all of your other structs inherit from that struct?


In your objects you could do something like have a vector of pointers to Component structs.. then you can add and remove components dynamically


You could either create virtual serialize and deserialize functions in your base component struct that inheriting structs must define for writing and reading their contents to and from file - or if you make all parts of your struct components constant sized (ie no std::string or pointers or anything like that) you could directly read and write them to file as lump memory blocks ( outFile.write((char*) myComponent, sizeof(MyComponent)) )


Just an idea

#5150774 What's a good language/engine to try for someone who can animate and lear...

Posted by EarthBanana on 01 May 2014 - 12:21 PM

looks like your answer lies within Unity


and yes you can build up as you go, in fact I would argue that is the only way you should do it - just be aware that most code or scripts you make will eventually be replaced no matter how hard you try to make something reusable


so avoid trying too hard - reusable stuff can only be made with lots of experience


But you should take a look at Unity

#5127364 Hello

Posted by EarthBanana on 29 January 2014 - 09:21 PM

I can say, python was my first language and I don't regret it at all

#5126858 Hello

Posted by EarthBanana on 27 January 2014 - 08:31 PM

I just asked anyway because I thought their might be other languages which might more suitable to my long term goals for my games as I originally mentioned.


These languages are suitable for your long term goals - though that doesn't mean you will always use them. Languages are just tools - and if you stick with game dev you will likely learn many languages and when to use them for what.


C# is great for the app development world and is what a lot of tools that speed up the game dev process use. Python is just really easy to make things quickly. Both languages are fairly high level and forgiving - they make it harder for you to write bad programs (though of course you still easily can).


C++ is kind of a hot word- and its because its one of the most powerful and difficult to use effectively. Beginners are often shooed away from it because the development time for games (even using lots of libraries) is usually very long due to the complex nature of the language.


Java is similar to C++ though I have found it has a bit less steep learning curve due to its automatic garbage collection and not using pointers.


IMO, if your starting game dev because you love programming then go for c++ - you will do a lot of reinventing the wheel and get less extravagant final projects for equal amounts of time you could put in to developing with other languages/tools, but you will understand programming a lot better. It will also make picking up new languages easy - when you love programming learning c++ is very rewarding.


If your in it for making the games - ie your more interested in getting your idea for a game produced and working than you are in understanding the details of how the computer is making the game work - then definitely c# or python are good choices. With these languages you will be able to create games much more quickly than with c++ especially if you use tools such as Unity.


In the long road - you will likely use and learn different languages depending on the project your working on

#5125257 First game. Looking for some info/advice

Posted by EarthBanana on 21 January 2014 - 12:54 AM

For sharing files I would recommend Subversion with google code - it will keep track of you commits and changes and such for you

#5124633 Is using Java a good way to create a game?

Posted by EarthBanana on 18 January 2014 - 06:09 AM

You would draw your character sprite sheets (assuming you are talking 2d here) on regular image formats - png, jpg, whatever - then you would render those images on to quads which will have dimensions determined by the vertices that make up the quad.. a quad consists of 2 triangles which is 6 vertices..


The process of drawing the quad and rendering a loaded texture to that quad is different if you are using shaders or not - it is at least a few pages to describe these processes but there should be plenty of tutorials on how to do this using java/opengl


basically your characters would be sections of a sprite sheet texture rendered on to the quad - you can transform this quad around the screen and cycle through your sprite sheet to animate the character

#5124617 Is using Java a good way to create a game?

Posted by EarthBanana on 18 January 2014 - 03:00 AM

OpenGL is an interface for the video card - so calling opengl functions is the way that you ask the video card to draw stuff - you aren't actually "drawing" anything yourself - you provide opengl with the data by calling functions and then you have it draw using that data by again calling functions

#5124374 Is using Java a good way to create a game?

Posted by EarthBanana on 17 January 2014 - 06:47 AM

yeah java is legit for making games - either using game/rendering libraries or making your own


also it is a good beginner language as it does garbage collection for you - it also can be fairly powerful (used to make minecraft with opengl)

#5123513 is there a more confortable way to order tiles in a isometric game?

Posted by EarthBanana on 14 January 2014 - 03:03 AM

I think the first way you did it is most common




You can also easily do isometric using 3d with a fixed camera - might sound hard to do 3d but it could likely end up being a lot

easier because you wouldnt have to worry about draw order

#5118646 Setting up short animations (swinging sword, etc)...how? Timers?

Posted by EarthBanana on 21 December 2013 - 05:09 PM

What format are you using for your engine? Component entity? Inheritance Tree?


For my engine I solve the game state/ loop problem using systems that update components which could be attached to entities...


So for animation.. I have an animation component that can be attached to entities - this component contains a pointer to the actual animation data (each set of animation data can contain a number of animations (run, walk, jump etc) and for each animation there is a map of hashed bone string names to the bone channel data)


This animation component allows you to set the current animation, or animations if blending is enabled.. then the update function of that component checks if an "animate" flag is true and if it is it fills a vector of bone transforms based on the time passed in the update function.. the component also has a flag that tells whether the animation should loop or not... if looping is set to true then as long as animate is true it will keep filling the vector with new final bone transforms.. if looping is false it will set the animate flag to false once the animation has reached its duration


The "AnimationSystem" is then in charge of setting all the necessary variables in the animation components based on scripting/input etc  and also in charge of updating the components...


How does an animation component know how long it should play if its not set to loop? Well what I do... is in the AnimationData that the animation component points to I store the duration of the animation in ticks, and then I store the speed of the animation in ticks per second. Then in each bone channel, I store each keyframe quaternion/scaling vector/translating vector with its tick value...


To get a specific bone transform first I get the current "tick" value by doing


currenTick = currentTime*ticksPerSecond


And now you have a tick value that will likely be between two of your bone channel keys... so you use this tick value to do your interpolation between the keys


And you can also test this tick value to see if it is over the animation's duration in ticks... if the animation shouldn't be looping you can check this and set the "animate" flag to false if the currentTick value is > durationInTicks (I actually use the AnimationSystem to do this check and change the value)


Why use ticks? because you can then slow down and speed up an animation (and the duration will change accordingly) simply by changing the "ticksPerSecond" variable and thats it.. a lot easier than storing absolute time values for duration and bone keys etc..


Then handle all animation switching in the AnimationSystem which can switch entitie's animations based on input or based on anything you need really... If you want a button to play cast a spell animation you might check the InputComponent and see if it says to cast a spell... Then you might have an InputSytem that sets the InputComponent values based key presses and rules (ie maybe the player can only cast a spell when it has a target selected) etc...


This works really well for the component type of system...


I'm not sure if this was what you were having a hard time with or not but I hope it helped somehow!

#5117253 books/resources for c++ graphics programming(and maybe math too)

Posted by EarthBanana on 16 December 2013 - 12:55 AM

Well - if you want to start somewhere with learning how to program graphics opengl is a great place to start. Once you learn either opengl or directx - moving to the other is not very hard - there is really just different function calls that do that same things. I like opengl because the function calls and types and everything else don't look like such eye sores in the code - and its cross platform which is nice.


Here is a list of opengl books (that you may have already found)



But - I know you said you didn't want online tutorials - but this tutorial is really good for learning how to use shaders for lighting/shadows/drawing starting from step one...

http://ogldev.atspace.co.uk/  - its great for learning the basics and getting some cool stuff working using opengl - it will teach you a lot


As for the math... You really only need to know a few things because there are good math libraries out there to use (such as glm).. but I'll give a quick explanation..

The tutorial I listed above goes through a lot of these things


Trigonometry - understand the basic relations of a right triangle (including the sin/cos/tan relations)


Vectors - understand that a position in 3d space can be represented by 3 values - an x y and z

a position in 2d can be represented by 2 values - an x and y - this would be a 2d vector

and in general you can have n number of values represented by an n dimensional vector


Linear Algebra - you don't really have to know how to do the math behind it if you use a math library, but you need to understand that if you have 3 vertices of a triangle, each represented in 3d space by a 3d vector (actually in general the vector is 4d - but no need to worry about the 4th value yet), you can multiply these vectors by a matrix to TRANSFORM their positions to a different coordinate system - why is this useful?


Lets pretend we have a triangle represented by 3 vectors (1 for each vertex).. how would you make something in 3 dimensions appear on a 2 dimensional screen? Well it turns out you would use something called a Projection Matrix to TRANSFORM those vectors from the 3d coordinate system to a 2d screen coordinate system.. so in pseudo-code it would be something like


screenSpaceVector = ProjectionMatrix * worldSpaceVector


In general you can use this for anything though... for example if you wanted to view the world from some other point other than the origin (usually represented by a "camera") you can just create a matrix from that point and multiply the world space vector also.. so you would have


screenSpaceVector = ProjectionMatrix * CameraMatrix * worldSpaceVector


The beauty of a matrix is that it can not only transform positions from one coordinate system to another, but also rotations and scalings... so lets say you rotate the triangle, move it somewhere else in the world, and scale it to some new size... you can represent all of that information by a single 4x4 matrix (which math libraries will generate for you if you give them the position, scaling, and rotation information).. so now, you could draw that scaled/rotated/and moved triangle from the point of view of a camera (which can also have position/rotation/scaling) on a 2 dimensional screen with the following...


screenSpaceVector = ProjectionMatrix * CameraMatrix * PositionRotationScaleMatrix * worldSpaceVector


and that is basically what you do in a "vertex shader" for every vertex you want to draw. A mesh is just a collection of triangles, which each have 3 vertices - in the shader you would transform each of these vertices by multiplying their position vectors by matrices as above.. You can provide these matrices to the shader using opengl function calls and constructs. You use an opengl draw call to provide the shader with vertices, and the "vertex shader" that is currently bound (you compile and bind shaders that you write using open gl function calls) will execute once for each vertex.


from there an optional geometry shader can be executed, then each primitive will be rasterized (primitive being a set of three vertices in the case of triangle primitives) and each pixel covering the triangle will be sent to the fragment shader...


The tutorial I linked and the books on opengl will give a much deeper explanation to each of these steps, but that basically sums up drawing things using opengl