Tag Info

New answers tagged

0

Here is the answer in cocos2d-x forum: http://discuss.cocos2d-x.org/t/cocos2d-x-how-to-draw-in-specific-free-form-area/17623


1

You are blocking on pollEvent. window.PollEvent is for handing events, not your draw loop. Since you are looking at the keypresses every frame, you can't do it in the event handling - it is only trigger on the actual keypress events (which you are now ignoring, which is fine). Move it into the draw loop. Take a look at this sample: ...


0

I'm not sure what you mean 'these equations'. I think you mean the inputs into equations. I would store rotations as quaternions (x,y,z,w) as mentioned. Interpolating from a key-A to key-B would use a slerp or nlerp function (http://keithmaggio.wordpress.com/2011/02/15/math-magician-lerp-slerp-and-nlerp/). Translation is stored as x,y,z and uses a simple ...


1

You can't rewrite that loop so that it can't be unrolled. GPUs do not in general support a varying number of attributes to be passed between stages. You can, however, eliminate the loop entirely. Just pass vPosWS to the fragment shader, and do the loop there. Then the unrolling will actually be helpful. Bonus: You don't waste an absurd amount of bandwidth ...


0

Unroll. The instruction cost is minimal - just a subtraction! You can try and put "[unroll]" (without quotes) just above the "for" line, or just unroll manually, but, really, unroll. You won't even have the comparison instruction for the for loop check.


0

This website isn't about "please do the research for me". It's more like "I've done my work, here's my code, yet I don't know what I'm doing wrong, since it's not working". My library of choice right now (and for quite some time already) is SFML. It's a multimedia library split into several parts (graphics, audio, system stuff, etc.). Determining the ...


2

Your input layout defines POSITION as R32G32B32_FLOAT but Vertex's first member is an XMFloat4. This results in garbage in the TEX input. To fix the problem, switch to a XMFloat3 for the Vertex position member. Also, the offset for your NORMAL is set to zero - this should be D3D11_APPEND_ALIGNED_ELEMENT as well.


0

I've worked on a number of large titles. Short answer: It's possible if you're insanely rigorous, but probably not worth it. Unless you're on a fixed architecture (read: console) it's finicky, brittle and comes with a host of secondary problems such as late join. If you read some of the articles mentioned, you'll note that while you can set the CPU mode ...


0

False alarm, my apologies. I was passing the number of texels to the initial data struct's row-stride field, rather than the number of bytes. By pure unlucky coincedence, the other unit tests I had on this area were using single-element 8-bit texel formats, which meant I was getting really lucky (as the texel count and the byte count were the same). ...


1

First you get the uniform's location: GLint location = glGetUniformLocation(programId, "uniform name"); Once you have the location you can send the entire value of the matrix via glUniformMatrix4fv: const GLFloat matrix[] = { ...16 values of the matrix here... }; glUniformMatrix4fv(location, 1, GL_FALSE, matrix); Thus, to change a single element, ...


0

using glUniformMatrix4fv: float[16] matrix = {/*16 individual values*/}; glUniformMatrix4fv(location​, 1, GL_FALSE, matrix ​); this will overwrite all 16 values, if you want to keep the old ones you can keep them yourself or query them with glGetUniform


1

I assume your world is represented as a grid, the algorithm you need to do line grid intersection is called Digital differential analyzer algorithm. The code too much to write quickly, you can find a full explanation here. This algorithm/technique is used to solve different problems that need interpolating a variable over an interval. It's similar to ...


1

I didn't read your code, but I would recommend having a position for "the group" and then have each alien have its own "offset" position from that group position. Then when you draw them you add the two together, and to move the group you move the one group position.


2

Where to put the data depends on what the data is and how large it is. You can embed the data in the executable and then just reference the byte array when you need it. This has the upside that the data is loaded in memory automatically but it will remain in memory until the game is exited. The data also cannot be changed unless you recompile the entire ...


1

You could use a modified Flood Fill starting from a floor tile to check for the presence of grass tiles. In this case, the wall would count as a boundary and floor tiles would count as open space. If at any point during the flood fill you reach a grass tile then you know that the floor is not surrounded by walls.


0

I did it! Well, kinda, at least I got it to draw a random line and not crash, which is a start :) m_pDeviceContext->PSSetShader(m_pPixelShader, 0, 0); m_pDeviceContext->VSSetShader(m_pVertexShader, 0, 0); Both of these lines might have been needed in my shader initialisation. I moved the mapping and unmapping into my gfx object and now the draw call ...


0

Well, this is awkward. I overlooked the fact that the Teapot model has FAR more vertices than 255 (the size of GLubyte). I changed my call to glDrawElements and my indices_ vector to use unsigned integers, problem solved!


0

It seems that it was in fact, caused by adding rigid bodies from different threads. After I moved the call to btDynamicsWorld::addRigidBody into the main thread, I did not receive this error again.


2

You do not need to test for nullness in this case. The reason is that the ultimate source of the object is your code. SDL_Event e; SDL_PollEvent(&e); Both ways of getting events from SDL demand that you pass in the event object to be filled, so it can thus not be NULL unless you fail to allocate one beforehand.


0

To do random numbers in C++ you need to #include <random> and #include<time.h> then create a seed using: srand(time(NULL)) Then you must create a random number like so. int randNum = rand() % 10 + 1; This will create a random number in the range of 0-9 but then we add 1 and it will be somewhere between 1-10. Keep in mind it's not the ...


2

You may do what you need in 2 step: Clustering: First you can cluster your point. There are many clustering algorithms which will put your points into multiple close-distance group. K-means is one of your options. Convex Hull: Then you can create Convex Hull for each cluster. such as: Gift wrapping algorithm, Quick Hull, Bridge, ... There is a trade-off ...


2

You have this code: GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(vertices.Length), vertices, BufferUsageHint.StaticDraw); This tells OpenGL to only upload as many bytes as there are elements in the array. That's why you see only small portion of the data on screen. You need to tell OpenGL how many bytes you actually want to buffer. ...


0

Kerbal Space Program used to have the same issue, and called it the Kraken. They solved by moving the bubble around the player it has a radius of 2.5 kilometers outside of which all objects end up "on rails" where the orbit is fixed and large jumps ahead are easily calculated. That can be done using the patched conics orbit model. Essentially it means ...


1

The best way to get around these types of limitations is to move the world, rather than move the player and camera. Strict Method Keep your camera and player at (0,0) if you're using 2D or (0,0,0) is you're using 3D. When you calculate the input to move your player, instead of moving them, move all the objects in the environment. When the objects get some ...


0

I highly recommend you look into spritesheets, for memory efficiency/performance. There are a couple of tools out there to help you convert your collection of images into a spritesheet, such as this open source one, or my Gimp plugin for it. A quick google found me this sdl2 tutorial on spritesheets.


1

For loading the images, you could do: std::vector<imagebatch> fotos; std::vector<SDL_Texture*> healerTexture; // Parts of filename string that occur multiple times. char* filenameBase = "DData/towners/healer/healer/Healer"; char* fileExt = ".png"; // This is 15 because of the number of images there are. for (int i = 0; i < 15; ++i) { ...


1

After your glClear call you can render a full-screen quad with your texture (loaded like you would any other). You may want to disable writing to the depth buffer to avoid odd rendering issues.


0

You already got your position and your rotation, just take those values from the spaceship and create a bullet from them. If you dont want them to start in the middle of your spaceship, move them a few times in velocitys direction.


5

A singleton works. A global works. I'll stand by that statement. I don't think they're the best solution for this particular case, though. Yes, you can put all your GameObject instances into a World of some kind. The World then likely needs to be managed by an object if you plan to have more than one of them, e.g. some kind of WorldManager. This manager ...


0

FBX supports a whole range of texture properties per surface material: diffuse, specular, etc.. The property names are stored in static char* fields in SDK classs FbxSurfaceMaterial. You can get a pointer to such a material by iterating across all materials of an FbxNode using functions GetMaterialCount() and GetMaterial(index). To load a texture, you first ...



Top 50 recent answers are included