Tag Info

New answers tagged

2

To find the normal, you can use the cross product of three of the points in the polygon. Create two vectors from those three points and find the cross product of those. To find the intersection of the ray with the polygon, you will first need to ensure it intersects with the plane of the polygon. To do this, you will need to do some algebraic manipulation ...


0

If the DLL is not a .Net assembly (i.e. cannot be loaded in the References folder) put it in the root folder (not the assets)


2

It's pretty straightforward, if not entirely well documented. Reading the source (not sure if the released version differs significantly) tells me that you must export an environment variable SDL_DYNAMIC_API with the name of the .so you want to load. That .so must contain a symbol SDL_DYNAPI_entry with signature: Sint32(SDLCALL*)(Uint32 apiver, void *table, ...


0

You just need a simple DFS algorithm ! Here you go: Run DFS every time player go on a empty block. Your DFS should navigate empty block until reach a filled (blue) block. this is stop condition of your DFS. Then in DFS, check if all DFS-branches stuck to a filled block. not your game-world border. if yes, Run That DFS again, and fill all blocks which DFS ...


-1

Your question IS broad, however it is answerable. What should the client do in a multiplayer RPG: Display the scene. Receive updates from the server. Send request to the server. Repeat. What should the server do in a multiplayer RPG: Send Player / Monster / NPC / etc coordinates. Determine if a player request is valid IE: Enough gold for purchase ...


1

The sf::IntRect that you will use will be the same for both directions. What will need to be changed is the scale of the sf::Sprite variable. You will simply need to do something similar to this: // Assumes that the image side is 24x32 and it is the first frame of the sprite sf::IntRect test(0,0,24,32); playerSprite.setTextureRect(test); if( walkingleft ...


2

This indeed should be very simple, so I suspect you may have gotten some details wrong. The overall goal is to match up the center of the camera with the midpoint of the players. As you've found though, those values aren't immediately available to you, so you need to work them out. What you might have are (leaving out the Y axis stuff since we don't need ...


2

Hexagons as a grid type are not uncommon in games, particularly games involving tactical elements. In a 4-way movement scheme, in order to move diagonally you have to expend two moves. In a 8-way movement scheme, you either have to make the diagonal moves have a cost of two, one, or a fractional sqrt(2) cost in resources. Hexagonal grids allow movement ...


1

You need to remember that C++ is a multi-paradigmatic (OOP, functional, procedural, ..) language and you should use the programming paradigm that best solves your current issue. OOP doesn't lend itself well to this problem. In OOP you think about single objects in isolation (concept of "a tile"). But most of your algorithms will operate on a whole ...


1

I would advise against using inheritance to manage different tiles. Imagine how annoying it would be having to define a new class every time you add seemingly different types of tiles. That would result in a lot of implementations for simple things like a grass or a dirt tile. It is much simpler and more maintainable to make tiles configurable. Define a Tile ...


0

(I cannot comment so I'm answering) If you build an array with reference for the types of the files (I don't know much of C++, so I'll pseudocode) tiles[0,0] = ref_to_fire_tile tiles[0,1] = ref_to_fire_tile tiles[0,2] = ref_to_grass_tile ... Where ref_to_*_tile holds a reference for a specific type of tile which inherits from a generic one, this way ...


6

It is fine to have lots of instances. An instance of a class without virtual methods is just like a POD C struct in terms of memory consumption which is similar to primitive data types. It is no problem. Your concern when instantiating many instances of a class are resource related I would think. CPU - should not be affected because you will be ...


0

To give an example to my comment public class Tile { //some variable stuff; public Tile() { //some constructor stuff; } } public class FireTile { //some variable stuff; public FireTile : Tile() { //sets player on fire //some constructor stuff ...


0

It sounds like what you want is named delegates. If I understand it correctly, your actions are just a call to a function in an existing component. Then all you need is to store a member function pointer and a pointer to the component, instead of a custom class. You can do this directly with member function pointers, or wrap it in a delegate class. It would ...


2

To send constant values to shaders without using the effect framework, you create constant buffers and bind them to the pipeline with (for example) VSSetConstantBuffers. For example: // You can of course eschew the structure, but this allows you to stuff more data // into the pipeline with a minimum of fuss; you should generally create constant // buffers ...


3

The following code should work: var points = new float[] { 0.0f, 0.5f, 0.0f, 0.5f, -0.5f, 0.0f, -0.5f, -0.5f, 0.0f }; int vbo = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, vbo); GL.BufferData(BufferTarget.ArrayBuffer, points.Length * sizeof(float), points, BufferUsageHint.StaticDraw); ...


0

Message pack is a great alternative too! (http://msgpack.org)


0

Google FlatBuffers is an efficient cross platform serialization library for C++, with support for Java and Go. It was created at Google specifically for game development and other performance-critical applications. It is available as open source under the Apache license, v2.


0

If you are on a Linux platform, you can directly use json.h library for serialization. Here is sample code I have come across. Source: Json Serializer //============================================================================ // Name : JsonTest.cpp // Author : Manis Kumar Khedawat ...


2

I'm not sure if I should just delete the question since I solved it on my own or if I should leave it up for others to see in case they have the same problem. For now I am going to add my edit to this as an answer but if I should just delete the entire question let me know! I'm relatively new to Stack Exchange and am not really sure. The problem with the ...


0

Your top code chunk is: t2 * (t1 * direction * inverse(t1)) * inverse(t2) Your bottom chunk is: t3 * direction * inverse(t3) Given that t3 = t2 * t1 It's (t2 * t1) * direction * inverse(t2 * t1) As far as my knowledge of Quaternion multiplication goes, I don't think t2 * (t1 * direction * inverse(t1)) * inverse(t2) and (t2 * t1) * direction * ...


0

Give your tank a Property that Tracks where its Bounds are. Give all other objects a Bounds as well. Check against the two rectangles to see if they are binding. Rectangle rect1 = new Rectangle(x,y,width,height); Rectangle rect2 = new Rectangle(x,y,width,height); x and y would be your sprites location in the world (Vector2.X and Vector2.Y) Width and ...


0

the way to create your Quaternion rotations matrices (I assume from euler angles) look funny, I would expect you use unit vectors of each axis rather than axis XMMATRIX rotateQX = XMMatrixRotationQuaternion(MathHelper::XMConvertToQuaternion(XMFLOAT3(1, 0, 0), radianRotation.x)); XMMATRIX rotateQY = ...


0

On this line: XMStoreFloat4x4(&mWorld, scaling*rotateQX*rotateQY*rotateQZ*translate); does changing the order to: XMStoreFloat4x4(&mWorld, translate*rotateQX*rotateQY*rotateQZ*scaling); make a difference? If you meant to rotate about the origin then translate outwards then you need to be careful with your ordering, though I'm making assumptions ...


0

Your answer to the collision problem is true/false. Instead you can differentiate between no collision, penetration of the object and touching the object. Then only disallow movement in the case of penetration, but allow touching. I'd also suggest you move the collision code out of your tank and GameObject. Tanks and GameObjects both really just contain a ...


0

I like simple. If GLEW loaded correctly, this extension will be valid function pointer. Otherwise it will be null. if(wglCreateContextAttribsARB) wglCreateContextAttribsARB(hDC, hRC, &attribs)


2

I'd expect the conversion to be more like: static XMVECTOR XMConvertToQuaternion(XMFLOAT3 axis, float radian) { return XMVectorSet(sin(radian/2)*axis.x, sin(radian/2)*axis.y, sin(radian/2)*axis.z, cos(radian/2)); } in particular there is no need to push the coordinates through a cos and the w should be the last coordinate, there is a micro optimization ...


0

You can use a simple shader for this, but I wouldn't do so, simply due to the fact that you're doing simple tinting with one color (or shades of one color) only. The Unity script above would work with some modifications, but you'll have to keep in mind that there's additional overhead/metadata in there that doesn't belong to the actual GLSL code. What I'd ...


1

Do I use XMMatrixRotationQuaternion(XMVECTOR quaternion) and multiply the resultant Matrix with my scaling matrix and translation matrix to get my transformation matrix? I believe so. At least that's what I do with D3D9. (D3DXMatrixRotationQuaternion) You might already know but multiplication order should be : scalingMatrix * rotationMatrix * ...


3

glRotatef(GLfloat angle, Glfloat x, GLfloat y, GLfloat z); The Above function is what you need for your purpose. It " multiplies the current matrix by a rotation matrix", as the OpenGL documentation says. Here's how you use it- angle is the angle you want to rotate. (Duh.) The next three parameters define the axis around which you would like to rotate. You ...


1

As I understand from your question is that you to rotate the actual textures and not the polygon vertices. This can be done by modifying the Texture Matrix not the ModelView Matrix.(you're using fixed pipeline). In order to modify the texture matrix that actually transforms the UVs you need to enable it first. glMatrixMode(GL_TEXTURE); glLoadIdentity(); ...


1

C++ is really a family of languages that are all in one compiler, so it's difficult to be truly a master of everything. There's a 'core' language which is a 'better C', there's an objected oriented langauge (i.e. classes, inheritance, virtuals, etc), the Standard Library (including but not limited to the STL), and a meta-programming template language. Add in ...


0

I think this is subjective and a way to highlight someone who has both the experience in the language and the experience in the chosen industry. In that example, someone with 5+ years using C++ and working in the game industry may imply they are an expert and should apply. Another assumption is that you meet the same qualifications in the example above, but ...


4

First, I wouldn't say that in this case you are optimising too early, depending on your use case. In any case though, you've asked an interesting question and as I have experience with this myself, I'll weigh in. I'll try to just explain how I ended up doing things and what I found on the way. Each entity holds a vector of generic component handles which ...


2

To answer just this: My question is, since I am not iterating linearly one contiguous array at a time in these cases, am I immediately sacrificing the performance gains from allocating components this way? Is it a problem when I iterate, in C++, two different contiguous arrays and use data from both at each cycle? No (at least not necessarily). ...


2

Short Answer: Profile then optimize. Long Answer: But, when I am to iterate component arrays to do something with them from a system on an actual gameplay implementation, I notice that I almost always am working with two or more component types at once. Is it a problem when I iterate, in C++, two different contiguous arrays and use data from ...


0

Your rotation will clearly always be the same every frame. The code you wrote there just sets the rotation to one single value every frame, if this code is run every frame, that is. Instead, have a variable , say rotation_offset that will be updated each frame, and will have a scope outside this for loop you have there. You should do something like this: ` ...



Top 50 recent answers are included