• Content count

  • Joined

  • Last visited

Community Reputation

108 Neutral

About Sawiner

  • Rank
  1. iedoc - first of all, that makes a lot of sense. Thanks for that information. That being said though, how is the render loop in another thread suppose to look like then? Assuming i'm looking for a variable time step (so I can't base the loop on time), and no vsync.   I tried looking into getting the current monitor refresh rate, then limiting the amount of draw calls to that, however as far as I can tell, there is no "secure" (one that will always bring a result) method of doing such thing. For example, EnumDisplaySettings() and DEVMODE structure ( ) , say that if the value is 0, it uses the adapter default refresh rate. However, I can't seem to find a way to get the adapter default refresh rate.   Also, is that a good idea? if not, how else should I do such thing?
  2. iedoc - thanks for your reply.   I was wondering though, what makes the message loop lock the screen? I "watched" the messages, and most of the time the messages the GetMessage() was stuck on were something like WM_NCACTIVATE and WM_MOUSEFIRST - that is, messages that aren't related to paint.   Although, assuming the message pump does lock the screen, I agree with you - rendering from another thread would be dangerous.     I have to say though, the documentation about DXGI and multi-threading make me thinks as if what i'm trying to accomplish should be possible; take a look here:   The multi-threading part there talks about deadlocks (which I have avoided, so far anyway). That is, it implicity tells you it's ok to call Present() from another thread.   Few questions then: 1. so what am I missing here? how am I suppose to write a game that call Present() from another thread, in a variable time step, without vsync (that is, fast as possible) ?   2. Assuming I do keep the Present() call in the UI thread, and does the rendering in another thread, how do I know which parts Present() will draw and which not?   I know I can use synchronization primitives such as mutex, I am talking about a case where I wouldn't use one, and wouldn't use D3D11_CREATE_DEVICE_SINGLETHREADED flag as well, meaning I can call the methods from multiple threads.     p.s. I also just found out if i'm calling Present(1, 0), it's working as well. As far as I understood, this is vsync. so as far as I can tell, the problem is when Present() need to actually draw(), which happens a lot more without vsync (since vsync waits, if I understand correctly). However, I do not wish to use vsync. I wrote this to hopefully, give some more helpful information.
  3. Hi guys.     I'm trying to make a simple game loop, where the usual window message pump is in the initial thread, while the directx rendering is at another thread.   The code is something like that:   // The next method runs at the initial thread // it is called after DirectX and win32 initialization. int Run() { std::thread tRender(&ThreadProc_Render); if (tRender.joinable()) tRender.detach(); MSG msg; while (this->m_bRun) { BOOL bGetMsg(::GetMessage(&msg, NULL, 0, 0)); if (bGetMsg == -1) // Error { this->m_bRun = false; } else if (bGetMsg == 0) // WM_QUIT this->m_bRun = false; else { // ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } return (msg.wParam); }     ThreadProc_Render: void ThreadProc_Render() { StopWatch sw; // Render Loop while (pWnd->m_bRun) { uint32 nMS = sw.Restart(); HRESULT hr(gpSwapChain->Present(0, 0)); // ::Sleep(15); std::this_thread::yield(); } }   in case you're wondering, StopWatch is a class of mine. Restart() sets the watch old time to now, and return the different between the old and the new time.   The problem is, the window it self is not responding (can't move or resize it) It seems as if the other thread is taking all the GetMessage() thread resources.   However, as you can see, the function call to sleep with 15 ms is commented out. when it's not commented out, the program runs fine.   Also, if I comment out the Present() call, same thing - window seem to "work" again (can resize, move).   Also, when looking at task manager, the application doesn't seem to consume high cpu at all.   As far as I can see, it looks like a blocking issue. The thing is, there is no blocking at all. I even tried replacing GetMessage() wit PeekMessage(), and calling 'yield' when there are no messages. That gave me the same result though, window stuck unless Present() line is commented out (or Sleep isn't).     Why is this even happening? What am I missing here?  
  4. Not a single comment? nor a confirmation about my case? anythig? ...
  5. I'm working on a project of mine, using D3D11 C++, and from some reason I keep getting the warning that an index buffer has not enough space. I'm afraid the code is not as simple to debug, not as short and straight forward, so I would rather not write it here. I did however captured a frame using PIX, and uploaded it. Notice if you go to the last draw frame, and to the 'Render' tab, you'll see the warning. The full warning is: D3D11: WARNING: ID3D11DeviceContext::DrawIndexed: Index buffer has not enough space! [ EXECUTION WARNING #359: DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL ] You can look at the index buffer size, and the parameters to the DrawIndexed. Combining everything together, the size of the buffer is big enough. Also, everything is rendering fine. The only problem is the warning. Note: I know PIX is old, however the "new pix" is available in visual studio, but not in express edition. PIX however, is still free. Which is why i'm using it. The PIX File:!131&authkey=!AJZnMjFLeh9v7Pc If anyone has any other place he would like me to upload the PIX file to, please say so. Also, it would be nice if someone can at least comment and say he see the same thing as me - that is, he see the warning while also seeing buffer is big enough.
  6. I have been reading the document ( ) and implement it. I have almost succeeded, however I am having a few troubles with the EF/FF states; I am not sure which one is the problematic, I keep getting into infinite loop where I keep changing from first feature to the second one, and then back to the first one. After debugging, I noticed something wrong with my topology; That is, I noticed one of my edges contain a plane, which should contain the set of all points that are closest to that edges, but isn't. The problem is, I am constructing the polygon using Incremental algorithm (convex hull construction). That is, the algorithm is creating triangles and not quadrants, even if they match. e.g. for a cube, the result will be 12 triangles, and not 6 quadrants. I was wondering then, how in such case I should handle. As far as I can see, I have two options: (a) quadrangulation (not sure how it's written); However, I haven't found any algorithm for it, and really not sure how to do so. (b) Make the edge have the correct planes. The problem is, the edge shouldn't even have a plane. The sets of points that are closest to the edge are all only the points above that edge. Also, if that is the case, how can I represent and create such set of points? Also, if anyone has any suggestion on how to correctly debug such an algorithm, I would be helpful. The problem debugging such code is understanding the meaning of the values. I understand the code and what it's supposes to do, but I can't be sure if it does it right or wrong because of the values, and something the scene isn't clear enough.
  7. OBB and SAT Question

    I apologize ahead for bringing this thread up again, however I am facing with similar function and I think it will fit the best into here. much like Raeldor (I think) , I am failing to understand how the projected radiuses of the cross product vectors are found; I didn't saw any response to it on this thread too. According to 'jyk' and 'Christer Ericson' , the general formula is: [color=#1C2837][font=CourierNew, monospace][size=2]r = e[sub]0[/sub]|A[sub]0[/sub].N| + e[sub]1[/sub]|A[sub]1[/sub].N| + e[sub]2[/sub]|A[sub]2[/sub].N|[/size][/font][/color] [color=#1C2837][font=CourierNew, monospace][size=2] [/size][/font][/color] [font="Arial"][size="2"][color="#1C2837"]for the cross product of vectors uA0 and uA1, regarding the projected radius of a;[/color][/size][/font] [font="Arial"][size="2"][color="#1C2837"] [/color][/size][/font] [font="Arial"][size="2"][color="#1C2837"]ra =[/color][/size][/font] [font="Arial"][size="2"][color="#1C2837"] eA0 * |dot(uA0, N)| + [/color][/size][/font] [font="Arial"][size="2"][color="#1C2837"] eA1 * |dot(uA1, N)| +[/color][/size][/font] [font="Arial"][size="2"][color="#1C2837"] eA2 * |dot(uA2, N)|;[/color][/size][/font] [font="Arial"][size="2"][color="#1C2837"] [/color][/size][/font] [font="Arial"][color="#1C2837"][size=4]I believe the first line can be removed since N has a 90º angle with uA0 and cos(90) = 0 ...[/size][/color][/font] [font="Arial"][color="#1C2837"][size=4] [/size][/color][/font] [font="Arial"][color="#1C2837"][size=4]regarding the second line:[/size][/color][/font] [font="Arial"][size="2"][color="#1C2837"] [/color][/size][/font] [font="Arial"][size="2"][color="#1C2837"]N is (right handed cross product):[/color][/size][/font] [font="Arial"][size="2"][color="#1C2837"] N.x = (uA0.y*uA1.z) - (uA0.z*uA1.y); N.y = (uA0.z*uA1.x) - (uA0.x*uA1.z); N.z = (uA0.x*uA1.y) - (uA0.y*uA1.z); so further expanding the second line (ignoring the third one, for now) eA1 * dot(uA1, N) = eA1 * ( [size="2"]uA1.x * (uA0.y*uA1.z) - (uA0.z*uA1.y) +[/size] [size="2"] uA1.y * [/size](uA0.z*uA1.x) - (uA0.x*uA1.z) + uA1.z * (uA0.x*uA1.y) - (uA0.y*uA1.z) ); To be honest, I even opened it further on, on a paper; I won't do it here though, since I didn't end up nowhere. I do know in the table it listed that: ra = eA1 * |r20| + eA2*|r10| hence the expanded value of dot(uA1, cross(uA0, uB0)) should be equal to r20. however, in r20, we actually have dot(uA2, uB0); I believe i'm missing something, but I can't find a direct connection between the 2 terms. What am I missing then? p.s. I apologize for my notation in here; I'm not familiar with any better way to do so, not in a forum post anyway.[/color][/size][/font]
  8. DonDickieD - thanks for your reply. I have to say I don't usually buy books, but then again I don't usually do this kind of math (which seem hard). Since you've both authored and edited it, let me ask you: is there any chance you can list the prerequisite for it? that is, "how much"(what subjects) math should I know/learn before attempting to read it? Also, I was able to read the table of contents on your book in ; there seem to be like the subject i'm looking for (quaternion based constraints) is chapter 9. Do I also need to learn the 8 chapters before it, or some of them? If so, can you list the prerequisite math knowledge for them too? Also note I prefer to find a free online solution. The reason is because I currently can't use my credit card to purchase items out of the country, and ordering seem to take over a month. I will however use it if I find no other solution, which seem to be like that so far, and if(or when) I will be able to read it. Thanks, Matan.
  9. Well if I use euler angles to represent rotations, i'm having a problem: I need also a way to construct an euler angles (yaw pitch roll) from axis angle (quaternion); There are 2 reasons for this: 1. When loading a model (.fbx file) it only contains a matrix which defines the total transform including translation rotation and scale. Using matrix decomposing, I can get the rotation translation and scale out of it; The problem however, the rotation is given out as quaternion. Hence the base rotation is quaternion, and not euler angles. 2. When my Limb IK solver goes over each bone, it calculates 2 vectors: * from the bone position to the end effector bone position, * from the bone positions to the goal position then, it calculates the axis (cross product) and angle (dot product), and create a quaternion from it. I can obviously create a matrix from it too, not how to convert axis angle to euler angles though. Note I did found some help on how to convert axis angle rotation to euler angles, however it has a problem with many rotations, if I understand correctly, this is due to singularity. What should I do then? Thanks, Matan.
  10. A bit more than a week ago I have started creating a real-time IK system for my solvers. I looked up solvers and implemented the simplest one, CCD Limb IK Solver. It was really easy creating it, however after first few times of checking I noticed the problem: the joints were rotating in a way that is not humanly possible, and I figured I need joint rotational constraints, so joints like the elbow won't be able to rotate everywhere they go. I represent rotations using quaternions. My initial idea was at each step of the solver, to take the rotation defined by a quaternion that the solver find(calculates), and constraint it using 6 floats: minX, maxX, minY, maxY, minZ, maxZ. I tried to look it up online, and it seem to involve a lot of math; A lot more I thought I initially thought I will need. Then I also thought I could try to convert the quaternions to euler angles (probably Yaw Pitch Roll), clamp them, then create the quaternion from it again. The problem of it is, I would lose all the advantages of using quaternions over euler angles... right? My questions are these then: 1. Is there a better way to create joint rotational constraints? or even a better approach for constraining the joint, so such a problem like the elbow problem I mentioned above won't happen ? (hopefully while still using quaternions) 2. If this is the only approach to, and I just need to learn more mat in order to constrain the quaternions, can anyone refer/suggest me to a good resource (such as a website or even book), perhaps including some specific subjects I should learn ? Yours, Matan. p.s. I'm using xna and quaternions, and I have to say I wasn't sure if this is the right forum to post this message in. However my question is more math related than xna related, so I hope this is the right forum to post this in.