# lawnjelly

Member

801

17

2. ## How to get the 3D position for the point with (0,0) UV coordinates?

Sorry I should have worded better, it is a good alternative solution.
3. ## How to get the 3D position for the point with (0,0) UV coordinates?

It is an established solution, it's easy to demonstrate working, just code it up. The transform isn't necessary because you are simply interpolating a triangle in both cases... However... Afaik what may be causing the confusion is that strictly speaking, the texture mapping used in general 3d is not 'physically correct' as you are seeing it. If you use a fish eye projection for a camera, and draw a triangle, in theory the texture should also be distorted, but if you render it with standard 3d games hardware it will not be distorted. Only the vertices are going through the transform matrix, the fragment shader afaik is typically given simple linear interpolation. This may not be the case in a ray tracer. So, you are actually right in a way I think.
4. ## How to get the 3D position for the point with (0,0) UV coordinates?

I had a little trouble conceptualizing this, I kind-of see where you are going but am not convinced it would work. You could try it out though, code it up and compare with the barycentric solution?
5. ## How to get the 3D position for the point with (0,0) UV coordinates?

You can do something like that, it is doing essentially exactly the same as the very first suggestion (using barycentric coordinates), except in an extremely roundabout fashion (going on a roundabout trip via the GPU). Of course, it depends what the actual use case is, whether the conversion is rare or needed as a realtime lookup. There are many cases where having a UV -> 3d mapping for the entire texture is useful rather than e.g. using the barycentric method per point, and using the GPU is an option to create this. In my own use cases I've been fine using the CPU to calculate this conversion texture, however it you needed to e.g. recalculate it on a per frame basis the GPU might be an option, bearing in mind the potential for pipeline stalls if you have to read this back.
6. ## How to get the 3D position for the point with (0,0) UV coordinates?

Well not quite true (I do inverse UV calculations in 3d paint in quite a few places for instance, it might also be used in lightmapping, ray tracing etc etc), but it is probably rarely used by developers relying on 3rd party engines and tools to do this sort of thing for them. To elaborate a little, if the OP is talking about the very specific case of using a uniform transform to get all 3d verts into uv space (such as matching a viewport transform, e.g. 'project from view' in blender), rather than the more usual uv unwrapping or complex projections, then in theory to go from UV space back to 3d space you would simply use the reverse transform (e.g. inverse matrix). However in practice with a UV coordinate you have usually lost the 'depth' value (a degree of freedom I think this is called?), so even if you got back to the viewport x, y, you would have lost the depth information and thus the 3d position. I think also there might be issues once you are not using a simple orthographic projection (consider a fish eye lens and trying to extrapolate barycentric coordinates outside a central triangle, the relationship between uv and 3d space would break down I think). If you still had the 3d -> uv matrix and the uv depth value, then it may in some cases be possible to go directly back to a 3d vertex (don't quote me on that, I might be missing something obvious lol ). It is similar to any matrix transform in that respect.
7. ## (Android) Tossed Bones : Beyond Love Action-Adventure Platformer Game [FREE]

Looks very nice! Congrats!
8. ## How to get the 3D position for the point with (0,0) UV coordinates?

This is essentially correct. The 3d position of a particular UV coordinate only makes sense in terms of the triangle (or triangles) that encompass that point. If you pick a UV coordinate outside of the triangles for instance, it doesn't really represent any point in 3d space.
9. ## [SDL] shoot bullet projectile toward mouse position by calculating angle

Copying and pasting from examples can be okay but afterwards you should usually go through it to make sure you fully understand what it is doing (of course, we all copy and paste code sometimes! ). Yes, when correct, the code should work whatever the speed of the projectile. Here are some tutorials on 2d vector math for games, they will explain it far better than I can, e.g. http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/ https://www.gamefromscratch.com/page/Game-Development-Math-Recipes.aspx https://www.gamefromscratch.com/post/2012/12/17/Gamedev-Math-Handling-sprite-based-shooting.aspx https://www.google.com/search?q=2d+vector+math+games&oq=2d+vector+math+games The code that alvaro posted is basically how to normalize a vector, although you should usually do a check for zero length vector to prevent divide by zero, which will cause an error. Normalizing (aka Unitizing) a vector takes a vector in any direction (except zero length vector, because the direction is undefined) and resizes it so that the length in that direction is 1.0. It is a very common operation in games.
10. ## [SDL] shoot bullet projectile toward mouse position by calculating angle

Part of the problem for us is that your code shown includes too much irrelevant stuff to easily work out what is happening, or intended (for me, at least! ), and your explanation of what is intended is not clear. If you are reading the mouse x, y each loop and using the bullet start position each loop to determine the angle, you will get problems. Are you trying to have a bullet that has a constant direction? Or are you trying to create a homing missile? For a constant direction you could for example RECORD the target position when fired, then calculate the move towards this target each loop: e.g. // calculate offset from bullet to target // Where vector 2 is using floats rather than ints Vector2 ptOffset = ptTarget - ptBullet; // make offset length 1 ptOffset.Normalize(); // make length of offset equal to desired move length ptOffset *= fMoveLength; // probably have some logic for reaching target // .... // move the bullet towards target ptBullet += ptOffset; A similar approach to this might also work for a moving target (but usually you'd use something a bit more complex to limit bullet direction changes etc). You could also probably more appropriately use this kind of thing for a constant direction bullet: class CBullet { public: Vector2 m_ptPos; Vector2 m_ptVelocity; void Fire(const Vector2 &ptStart, const Vector2 &ptTarget) { m_ptPos = ptStart; m_ptVelocity = ptTarget - ptStart; m_ptVelocity.Normalize(); m_ptVelocity *= SPEED; } void Update() { m_ptPos += m_ptVelocity; } }; It seems like you are using a different x, y target position each time: (more like a homing missile) SDL_GetMouseState( &x, &y ); In which case any direction for a bullet move should be based on the current bullet position, not the bullet start position.
11. ## Generating skeleton bind pose from vertex weights

It just depends how accurate you want to go for. You can estimate a rough centre of mass for each bone by using something like this: // for through bones for (int b=0; b<32; b++) { Vertex3 ptAverage(0, 0, 0); float fTotalWeight = 0.0f; for (int n=0; n<nVerts; n++) { // for through weights for (int w=0; w<4; w++) { if (vert[n].boneID[w] == b) { ptAverage += vert[n].pos * vert[n].boneWeight[w]; fTotalWeight += vert[n].boneWeight[w]; } // if } // for w } // for n ptAverage /= fTotalWeight; print ("AveragePosition of bone " + b + " is " + ptAverage); } You can also estimate the orientations of the bones by e.g. making a guess of a orientated bounding box, guesstimate some joint positions etc.
12. ## [SDL] shoot bullet projectile toward mouse position by calculating angle

Just a quick guess (I haven't properly read your code) but it sounds like it might be an integer rounding issue. If your destination is e.g. at 190, 100 and you move 1/100th of the way each time, converted to integers you might either move 1, 1 pixel at a time or 2, 1 (depending on how you round) so you would end up at 200, 100 or 100, 100. If you move faster it will be more accurate (e.g. 19, 10 per move) and slower, less accurate.
13. ## Playing with water physics

Haha yep!! I haven't decided on game type yet, there's a few hungry shark games that do well lol. Can't decide whether to do something modern or ye olde with sailing. I guess I can do both.

15. ## How to implement an cross platform timer in single threaded app

Is this for a game engine driven by a scripting language, like godot or unity? The onus is usually on the user not to have infinite loops, or performance sapping code. You can easily check for this just with a simple: bool bQuit = false; while (!bQuit) { for (int n=0; n<10; n++) { bQuit = RunVMInstruction(); if (bQuit) break; } if (TimeTooLong() || TooManyInstructions()) bQuit = true; } If a timer check is expensive, surely you can move it out of an inner loop? Perhaps there is not enough information to properly understand why this is a problem, as Wessam says. Afaik event based timers involving the OS are often wildly inaccurate (+- lots of milliseconds) so you are usually better off doing this kind of thing yourself. Even if calling your OS gettime function was that expensive (even outside a loop), you could also just roughly calibrate a number of VM instructions that would run in a given time, and use the instruction counter.
16. ## Fixing your Timestep and evaluating Godot

Yes, I guess wishful thinking lol! I do mention it at the end, and the reference 3: http://frankforce.com/?p=2636 gives some discussion of the problem and possible solutions. Some of it may be a result of how close a frame is submitted to vsync giving stuttered delays. I'm really not an expert on deltaTime variations, perhaps a question on the forum might get you some good answers? There are quite a few more hardware orientated guys here. Running in the editor as you say is not a good way to get reliable measures of jitter for at least 2 reasons, afaik.. First is that all sorts of processing is going on in the editor aside from the game which can cause stutters and stalls. Second is that in my experience vsync doesn't tend to work in windowed mode, or at least not as you would expect it to. Another discussion: https://medium.com/@alen.ladavac/the-elusive-frame-timing-168f899aec92 http://bitsquid.blogspot.com/2010/10/time-step-smoothing.html

19. ## Help with 3d collision question

I can think of lots of ways of doing this, depending on your game details as TeaTreeTim says, however, quite a cool cheap way of doing it and colliding the boat against the edges: Take the lake geometry (a bunch of triangles with mostly shared vertices) and build this into a navmesh. Then use a standard navmesh solution to detect moves to neighbouring polys, and prevent moves or slide against boundaries of the lake. You don't mention an engine so I'm assuming you are writing this all yourself. You can get the poly geometry from blender (e.g. export as an obj and parse the file yourself) but presumably you are loading in the lake geometry already to render it, so you can derive the navmesh from this. If you are using an engine it will probably have a mechanism of reading the geometry. There are also point in concave polygon tests, however you might want something cheaper depending on the number of edges to the lake. You could e.g. grid up the lake and list the edges to check on edge grid squares, or whether a grid square is totally inside / outside the lake. Also agree that having something more like bezier curves round the edge might be cool, and you may also want to take account of lake depth (boats might not be able to go right up to lake boundaries).

21. ## Is audio always frame rate independent?

Or it can be running in a different thread. The audio often has multiple tiles to this audio buffer, and you fill one or several as they become free, perhaps in a callback. If you don't fill them on time you might get audio glitches as the audio plays tiles that contain old data. The size and number of tiles can affect the audio latency (the gap between playing a sound and hearing it). With a small buffer you can get small latency but you need to ensure it is filled 'on time'. With a larger buffer there is less need to keep it filled in a timely fashion. If the audio is running on a different thread, the effect of frame rate may be rather to affect the 'granularity' of sound effects playing in the game, unless the audio wrapper and system specifically compensates for this. Typically a game might issue a command like PlaySound(GUNSHOT) .. if it is running at 1fps, a bunch of these may be issued at the same time rather than spread out over the second. More likely to be the other way around if anything. If you can query your audio how far through it is, you know how far to advance your game. However with an accurate general timer this is less likely to be an issue, as most games are designed to be frame rate independent, i.e. they use their general timer to know how far to advance the game. The longer the audio the more the possibility of drift between general purpose timer and audio player rate, and afaik different sample players are not exact. This is more likely to be an issue in audio / music apps than in games though. Also note that you could in theory change the rate that audio plays, but this normally gives a change in pitch, which might be noticeable, especially with a varying frame rate. You can also do time stretching on audio, to shift the play rate without changing pitch, but that would probably be a very messy solution to this particular problem.

Full expected Hodgman / MJP etc to provide definitive answer on this , but afaik, it may depend on the hardware. See this thread: https://www.gamedev.net/forums/topic/655602-why-discard-pixel-take-a-noticeable-performance-hit/ And this linked page on the graphics pipeline: https://fgiesen.wordpress.com/2011/07/08/a-trip-through-the-graphics-pipeline-2011-part-7/
23. ## Scoring Navigation Precision on User Created Courses

I'm not that familiar with skiing / snowboarding, but as a novice I'd be expecting to have score lowered only if I went out of the gated route, i.e. measure the distance from the edges formed by adjacent flags to the player, if he is outside the route. For any map you might be able to just precalculate on a grid the closest edge, then do a point - line segment distance calculation. You may have to take account of players cutting corners (e.g. missing out a whole section of course). Another possibility is simply to have the gates change colour as the player goes through them. If they miss a gate they have to go back and get it to change colour, so there is a time penalty for missing a gate. Also I read for slalom there seems to be single red and blue gates, and you have to go through the appropriate right or left side I think. This is another idea that might be good for some courses.
24. ## In game or software studio's what kind of infrastructure is used..???

Coffee machine Pizza / chinese delivery Threat of impending closure That Joel Test though, using an example of microsoft as a paragon of software development, the irony, the irony.
25. ## Economic Development Simulation Game

I wouldn't worry about things being 'done before', economic and similar simulations are great subjects for games, because computers do them so well, and I think humans intrinsically tend to find such complex simulations interesting, the results are often hard to predict and sometimes counter-intuitive. On a related note I wish politicians would make better use of simulations for examining the impact of policies instead of essentially plucking them from the air with the view that 'god told them their way is the right way'. For instance simulations can clearly show the effects of taxing people too little or too much, welfare etc. But as it is we are often governed by those with the weakest brains, sigh lol. As your design seems based on the students making the decisions, rather than AI, I think to gain the numbers necessary for meaningful results, you may like to have each student make decisions for a large number of different individuals (perhaps different roles). Of course then you have the possibility that a student might rig a group of individuals to perform better as a group than they would as individuals .. which is artificial, but perhaps giving some interesting twists.