Tag Info

New answers tagged

1

The dilatation will seem to work, but it is an imperfect solution because it is undersampled, it re-uses information (entropy coming from light irradiance samples) and spread it over, effectively creating extrapolation. The correct thing to do here is to use conservative rasterization which is not trivial at all to do. Your rasterization is based on the very ...


0

DirectXMath has the overloads needed for this operation: struct XMMATRIX { XMMATRIX& operator*= (float S); XMMATRIX operator* (float S) const; friend XMMATRIX XM_CALLCONV operator* (float S, FXMMATRIX M); }; Likely the problem you are having is that you do not have the proper namespace scope active to find the operator* ...


3

Following the half-plane method, you'll have found the line segments to every other point and the perpendicular bisectors of each of those which you then intersected to find potential vertices of the Voronoi cell. Now, you want to exclude the ones that intersect any of the "distant" half-planes formed by the bisectors. I coloured the "distant" ...


3

You may simply iterate over edges and filter out all vertices that are not in same half-plane with point of interest. As optimisation, iterate from nearest edges to farthest. I think you may even filter vertices while generating slices. It is like slicing pie with endless knife, until only small piece left with cherry on it. If you like analogies. Just cut ...


2

With anything more than trivial rendering, you cannot realistically aim at having 1000+ fps framerate. Besides, that does not makes sense if you think about it - your display refresh rate is probably only 60Hz. Instead you need to rethink your approach. So data can be displayed at 60fps max. The rest just needs to be discarded. Can you do that before ...


1

In SDL2 the creation of the window is separate from the rendering environment used to draw into that window. So, while you might pass "SDL_WINDOW_OPENGL" to SDL_CreateWindow(), this simply states that the window should support rendering from an OpenGL context later down the line and doesn't actually create an OpenGL context at that point. So, from ...


1

I think your playerRadius is twice as big as it should be. Your vectorToCentre is measured from targetCentrePos, but you use the full width() or height() of playerBoundingRect to determine radius. I suggest this change: const qreal playerRadius = qMax( playerBoundingRect.width() / 2, playerBoundingRect.height() / 2);


2

You should not mix the view which defines how things look, like the teams' HUDs with the teams' model, their data structure or class instance. Like @pctroll said, the teams could be instances of a Team class. In my opinion, the Team class should simply be a glorified array of players and some methods that tally up score. The player class should have a ...


12

The two key benefits that I constantly hear lauded about entity systems are 1) the easy construction of new kinds of entities due to not having to tangle with complex inheritance hierarchies, and 2) cache efficiency. Note that (1) is a benefit of component-based design, not just ES/ECS. You can use components in many ways that do not have the "systems" ...


3

Take the following relations into account A team has players Team Red is a team A player is associated with a team So, the following approach should give you a good hint. Team Red and Team Blue are instances of a team, with the same attributes but they just differ in values. Unless you need to implement different behaviors (member functions) for each ...


0

This is a general explanation answer, you'll have to check with the code yourself. Perspective projection looks like this from above: Near clipping plane is what you see on your screen. Now see that the farther you get from it, the more you need to move the object to have it in the same position on the screen. For example take Blue point, it got moved ...


2

Once upon a time there was Google. Now this seems to be what you are looking for: const char* SDL_GetCurrentVideoDriver(void) Returns the name of the current video driver or NULL if no driver has been initialized.


-4

A spinning animation can be done in several ways. An easy way is to create 2D sprites at the bottom of the machine and move them upwards until they hit the top then you move the sprite of the machine over the sprite of the symbol. If the symbol's bottom hit the bottom of that part of the machine then you make it disappear. An alternative if you want 3D is to ...


1

If you want to do it using Win32 API then here's code : // the Windows Procedure event handler LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { case WM_MOUSEMOVE: // save old mouse coordinates oldMouseX = mouseX; oldMouseY = mouseY; // get mouse coordinates from Windows mouseX = ...


4

"My goal was to teach them the fundamentals of C++ using OOP", following this, I think you're making the right choice. I find the OpenGL API doesn't lend itself to OOP( in the programming sense, anyway ) very well. I'm surprised you're even exposing 12th grades to C++ and OpenGL. Most university courses I've seen avoid both of these like the plague. So, ...


1

You have multiple ways to interact from c++ to javascript. I can show you one way I find quite handy: in the js library file // here you write JS "handlers" mergeInto(LibraryManager.library, { new_cube: function(size, color) { var cube = new THREE.Mesh( new THREE.BoxGeometry(size, size, size), new THREE.MeshBasicMaterial({ ...


0

For most projects, COLLADA (.dae) is great, well-documented, and supported by (among many, many, other programs) Blender. Since it's XML-based, writing a parser should be a reasonably simple extension of a standard XML library. There are also a host of .DAE libraries for every language under the sun. http://en.wikipedia.org/wiki/.dae


1

You can get this information with the following code: char buffer[256]; char *getcwd( buffer, 256 ); One hint: when the working directory differs from the place where the binary is stored: do you start the app from an IDE like QtCreator. If yes: please change the working directory for the run in your IDE.


2

It's possible that you're running the executable in a different directory than the one that contains your resources folder. If you need to change the directory from, say, a makefile, just cd to the desired base directory and run the executable from there.


0

I think I understand what you are trying to do. You want the sum of all layers' alpha to be 1 so that there the total color is overdrawn. You are on the right track. But your error seems in the way you compute the alphas. Take for example this starting point: 1: 0.7 2: 0.3 3: 0.0 Now you apply 0.5 on layer 3, the result should look something like: ...


0

It's not clear from your image if that is a single plane and the far faces are overlaying the near ones, or if you are rendering several objects and the far ones overlay the near ones. If it's the second case, your problem is that you need to either sort the itens back to front or disable the depth test. If you render them out of order, OpenGL will discard ...


1

The shader was fine. But when I tried to use other shaders I realized what was wrong. It was the C++ code that was lacking lines (rrr!! This is the reason why I hate shaders! It's so complicated to make a link in your head between every line you write in one file and what must be written in the other for it to be recognized!). In the display function, I ...


0

Sachin. It is possible to share on facebook from windows phone 8 app. Sorry, can't share the code, but i can point to some markers that will help. This blog by Ujjwal, states how to call c# from c++ http://blogs.msdn.com/b/ujjwalk/archive/2014/05/05/calling-c-code-from-c-for-windows-phone-apps-and-games.aspx It is essentially 3 layered thing and gets ...


2

Your code looks like it wants to output 9 triangles each consisting of a discreet three vertex triangle strip, not 27 triangles. However you have set max_vertices to 3 in the layout statement at the top of the shader so it only emits one triangle before it hits that limit. (The limit is for the whole shader, not per-primitive, otherwise 3 would have been ...


2

This is a classical control problem. You want to create a feedback loop that takes the divergence from optimal position and applies the appropriate torque to nudge it back into position. btQuaternion targetOrientation = // whatever you need btQuaternion currentOrientation = myObject->getOrientation(); Getting the delta orientation is quite simple, ...


1

I approached with a little Googlesearch ;) From what I found bt:RigidBody::applyTorque(btVector3 & torque) takes a vector in WorldSpace and uses it as axis to apply a torque which has a strength of the length of the vector. The LocalSpace-Torque seems to be solved in this answer, even though the provided code looks like there has to be an easier ...


0

Metaballs is a good way to think about solving this problem. It's usually the way that people develop implicit surfaces using particle-based fluid simulation like Smoothed Particle Hydrodynamics. There have already been a few questions asked about how to render metaballs: How to render metaballs? 2D metaball liquid effect - how to feed output of one ...


0

From your question I think you want a way to efficiently access a block's neighbours vertically. I'm not sure why you decided you want a std::vector instead of a grid made of a 8x8 array (you know you can iterate through every block in an array too), but I think the array is the better choice. If you really want to use a std::vector, then you may want to ...


0

You can use std::ostringstreams to push anything (even non-char variables) into a stream and convert it to a string: std::ostringstream ss; ss << "Some text: " << some_variable; //... al_draw_text(font28, al_map_rgb_f(255, 255, 255), wWidth / 2, (wHeight / 2) - 28, ALLEGRO_ALIGN_CENTRE, ss.str().c_str()); ss.str(""); //Clear stream contents.


-1

in my case my problem was solved after writing this for background color change to white glClearColor(1.0,1.0,1.0,1.0);


1

If I understand what you're trying to achieve, you want your two active clients to send key strokes to your server, and you want your server to process them in the right order. If you have to encode a key code and possibly some timestamp to know exactly when the touch was pressed (timing may be important for combos), I guess it should fit in 4 bytes/key (4 ...


0

The simplest way, assuming you have a bare bones component/entity/system architecture, is to create a Audio system and an AudioComponent. The AudioComponent would contain a reference (maybe just a string) to some audio and a corresponding "state" flag. As with other systems, the Audio system would scan entities, extract those that have an audio component and ...


0

I think that it's better to use GLEW to export all the extensions functionality. It's cross platform and allows you to write conditional code for different configurations.


0

This is a very broad question. Honestly, I would need some idea of how you set it up so far and a more specific idea of what you hope to accomplish in order to answer. My best idea at the moment is create a base sound component with some way to retrieve sound information (virtual sound_data getSound() =0; as an example method). The constructer would add it ...


3

One reason you might prefer UDP over TCP is to save bandwidth. The drawbacks are pretty clear - if data gets lost on the way neither the sender nor the recipient will notice. In addition the order of packages may change if they take different routes in the network which would result in clients seeing wrong "combos" (e.g. Left-Down-Punch instead of ...


4

you can use a forward declaration of the class that are in circular dependency. Here an explanation class firstClass; //Here the forward declaration class secondClass { public: private: }; Then in the cpp of the second class you can include the firstClass header file.


1

Considerations: A. Do the color-frame less frequently, for example at 10 fps (every 6th frame if you run at 60fps). Small lag won't be that noticeable; B. Render color-frame at lower resolution, e.g. 1/4, if you don't need pixel-perfect precision; C. Render only one pixel that you need below the cursor. I'm not confident with the math, but surely there's ...


1

Well, i'd probably start by taking a look at the blender unwrapping code, since blender is some open souce flavor; it appears to start here: https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/uvedit/uvedit_unwrap_ops.c I know the have a "pack lightmaps" command in their uv unwrap menu, but I wasn't able to locate it in unknown ...


2

C++ should be very efficient, but it also would make me have to worry about low-level details like manual memory management, and compiling for different platforms. Modern C++ highly discourages manual memory management. You should instead use smart pointers like unique_ptr and allocation functions like make_unique and never manually allocate or ...


1

About c++: You dont really need to worry about memory management. Ofc you handle memory yourself, but its not as hard as in C. In C++ you just allocate your memory by creating a Object (new xyz();) and free this memory by deleting it (delete var;). No more manual malloc() and stuff) About Java: Java supports Call-by-value with primitives and ...


3

There are a variety of ways to run code written in other languages in Unity. Most of these are platform specific. iOS: Since xCode will also compile C++ code, you could add the C++ code to the plugins directory and it will be built when you build the iOS app. You'd then define the function prototypes in C# so they are accessible from Unity. Documentation is ...


0

map<Key, Value> (and it's mates) holds Value, well, by value. If you try to give it an instance of derived class to hold as value, most likely "slicing" will occur. More about slicing: http://stackoverflow.com/q/274626/1125702 std::unique_ptr<Component> seems exactly what you want. It manages lifetime and memory of owned object. By convention, ...


0

DBVH (dynamic bounding volume hierarchy) is a common approach to solving this need. A BVH is just a tree of nodes containing one or more bounding volumes (e.g., circles/spheres) that are grouped together into a large bounding volume encompassing the children. There are several ways to construct a BVH. Some are intended to produce optimal trees from a known ...


6

It might be silly, but you could make a small C++ program around the chess library, that takes a simple text board state or movelist as input and returns the AI's selected move. I don't know .net's system libraries off hand, but you can probably start it as a subprocess, send to its stdin and then poll its stdout for a reply. Local sockets are also a ...


0

I have founded the solution: https://www.youtube.com/watch?v=xf0VD4ba4ns In this video's desc link shows a file that I used to the new code wich is working


2

This is a good question. I was trying to express that instead of holding an array of pointers to game objects, you can hold an array of game objects themselves, as pointed out by API-Beast in the comments of your question. You can implement this swap operation like this, assuming the array holds structs with simple data (structs with ints, floats, etc., no ...


0

Setting the CVar might lag a little, sure, but that's okay - you're already parsing the text input from a command. To optimize it if you must, hashing the name to an int for a quick lookup map is all you need. You could also make a directory structure, EG sv points to the sub-map containing sv_cheats to further minimize lookup comparison count. It's getting ...


2

The solution can be pretty simple - just add a field or flag and dont release until n bullets of your burst have been fired. in weapon: int burst = 0; when hadling event: void onFireButtonPress() { //previously simple fire(); burst = burst > 0 ? BULLETS_PER_BURST : burst; //or some other behavoiur like burst += 3 etc. } in game loop: ...


1

You are talking about string interning. It is widely used in compilers to represent identifiers. Basically, when the string is parsed from the command line or a text file, it is looked up in a global table. If it is already present, then it is assigned a number, and that number is returned. If not, then it is assigned the next available number, which is ...


4

First, avoid premature optimization. As Matthias notes in the comments, keep your implementation simple until you actually experience a performance problem that you can attribute (via profiling) to the configuration variable system. One of the big potential performance issues in an implementation like the one you have described will be the string ...



Top 50 recent answers are included