# Big Muscle

Member

14

135 Neutral

• Rank
Member
1. ## Optimize overlapping rectangles

If I describe a bit the original problem - I need to write a C++ function which receives an array of rectangles which do not overlap and look similary to the picture #2:   It is simply rectangular description of the geometry which results from subtraction of two overlapped rectangles. Overlapping can be arbitrary, the size of any rectangle can be arbitrary. I cannot influence the subtraction nor the format which I receive. My task is to inflate this geometry by some number and return it (in the same format - array of 0-4 rectangles). The problem is that returned (inflated) rectangles mustn't overlap - they can touch but not overlap.
2. ## Optimize overlapping rectangles

I used A,B,C,D marks only to specify their order. If array contains e.g. 3 items only I cannot say whether it is ABC, BCD, ACD or ABD.
3. ## Optimize overlapping rectangles

Hello,   I have an array of 0 - 4 rectangles (each one is specified with [left, top, right, bottom] coordinates) and these rectangles can overlap in some areas. Is there any algorithm which could help to reduce these overlapped areas (not to remove the intersection completely but to remove it only from one of the rectangles).   I can be sure that the number of rectangles is always from zero to four. The cases 0 and 1 can be ignored because there are no overlapping rectangles but the rest is always in the following form:   [attachment=18406:rectangles.png]   The order of rectangles is always maintained but any of them can be missing (which is the main problem here). So array can look e.g. ABCD or BC or AD etc. The goal is to get:   [attachment=18407:rectangles.png]   I tried several thing but without success. Could someone help? Thanks!
4. ## Drawing surface plot in C++ using GDI

Weird, I can't sometimes log in to this forum properly...   Does LGPL allow distributing without the source code? If it does not then it is still not suitable...   However, I noticed that there are two important functions in MathGL - rotate and calcScr which seem to be enough to correctly render 3D plot via my own algorithm, i.e. calling calcScr on each of p0,p1,p2,p3 (mentioned above) and it seems to be much faster then using MathGL completely. Both function just do some matrix operations and point scaling.
5. ## Drawing surface plot in C++ using GDI

Our goal was to make it as simple as possible. It does not have to be pure GDI but we should be able to achieve by GDI-like functions (i.e. DrawPolygon, FillPolygon etc.). I tried MathGL and it generates nice plot but its license (GPL) does not serve our purpose so it is probably unusable. Current 2D (bird eye) view is generated very simply as: for(int i = 0; i < x.size() - 1; ++i) for(int j = 0; j < y.size() - 1; ++j) { POINT points[4]; p[0] = x[i], y[j]; p[1] = x[i+1], y[j]; p[2] = x[i+1], y[j+1]; p[3] = x[i], y[j+1]; SetFillColorFromPalette(z[i][j]); Polygon(points, 4); }   I was thinking about function Project(x, y, z) which is called for each p0, p1, p2, p3 and just transforms the coordinate to the screen_x and screen_y and Polygon function will draw this transformed points then. But my expectance was probably too simple to make it work this way. Or maybe only the implementation of Project function was incorrect and transformation was wrong? I don't have much experience in this so I just tried what I remember from school - multiplying vector (x,y,z,1) by rotation matrix and scaling "x" and "y" by "z".
6. ## Drawing surface plot in C++ using GDI

Hello, I need a little help. I have to render 3D surface plot in C++ using GDI. I have approx. 1000 points [x,y,z] and I want to render a plot from them (it could be called height map or something like that.. exactly what Matlab "surf" function does). The speed is not big problem here, because the plot will be rendered once and then stored to image file so using GDI is enough.   I am able to render 2D plot (from bird view) without any problem by just omitting Z coordinate and simply drawing polygons from 4 neighbouring points. I even fill each rectangle by different color by differentiate their heights. I get this result (which is same as rotating Matlab plot to bird view):  [attachment=16122:plot2d.png]   But now I want to rotate it so the Z coordinate is visible - just to get something like this:   I tried to create projection matrix and multiply each point by it but I didn't get anything usable. Could anyone help me with this? Thank you!
7. ## Resizing primitives in vertex buffer

Yeah, vertex layout is known. Draw is classic device->Draw. I have no problem to modify the vertex buffer. The only problem is how to correctly and fastly compute the new coordinates (the request is to add 8 pixels to each edge of rendered primitive).
8. ## Resizing primitives in vertex buffer

Hello,   maybe I have a little non-standard request as I am developing a little bit non-standard application.   My library receives ID3D10Device1 before the content is rendered. I can get vertex buffer from this device via device->IAGetVertexBuffers which contains individual vertices. I know that the topology is triangle strip.   Now I need to enlarge the edges of the rendered primitive. The primitives are mostly the rectangles (4), rectangles with rectangle hole (10 or 22) or rectangles with rounded corners (34). The brackets contain known vertex count for each primitive. I know I can simply do if(vertexCount==4)  ... else.. and modify the original vertices but I would like to find more general solution.   The attached images show 2 possibilities of what I would like to do - black rectangles are the original one, red rectangles are what I want to achieve. Just any primitive will be resized that it covers some more pixels at each edge.   I hope it is understandable :-)
9. ## Why there is more D3D10/11Device::Draw (and some other functions) implementations?

Yes, the old functions come back (as I remember correctly it was something like Draw<0> is executed e.g. 500x, then function was swapped). Weird thing is that it does not happen always. Currently I wanted to track down how often the functions are swapped but it does not occur now :-/   However, some time ago, I was using following snippet running as background thread:   while(true) { if(device->Draw != myDraw) rehook(); Sleep(xxx); }   it just hooks Draw function still around. If sleep is not used then it works "correctly" (there is still possible race condition but very rare) - but consumes 100% CPU.. When there is Sleep (with > 0 ms) then it does not work, so the functions are swapped very often. Also, it is not something like "if(some_condition_is_true) Draw<0> else Draw<1>", The function pointer is changed directly in the device object's virtual address table.
10. ## Why there is more D3D10/11Device::Draw (and some other functions) implementations?

Hello,   I have a problem which I am trying to solve for a longer time and have not found a correct solution yet. I need to hook certain functions in Direct3D and replace them with my own implementation. Hooking itself is not the problem. The problem is that Direct3D library uses more implementations for some functions and "randomly" switches between them. So if I hook e.g. Draw function, it works only for a while and then the function is replaced with another implementation so my hook is not called until I rehook this another implementation too.   After debugging Direct3D library, I noticed it really happens. I have found functions such as: D3D10Device1::Draw_<0>, D3D10Device1::Draw_<1>, D3D10Device1::Draw_<2> etc. It is much worse for D3D11Device as there is 8 different implementation of Draw function.   Does anybody know the technical details why (or when) each of the <0>, <1> etc.. is called? What is the difference between them? My current solution for hooks is to periodically check Draw pointer and if it changes then rehook it again. It works but I don't see it as good solution (just because it requires additional code which can slow the things down).
11. ## Help with shader disassembling

so still something wrong, sometimes the value is incorrect.
12. ## Help with shader disassembling

Yes! +2 works with correct RGBA offset! thanks!
13. ## Help with shader disassembling

I tried to dump that buffer and it seems to be stored there, but not as pure alpha, but rather (1.0 - alpha). The blend state is following if it depends:     Now I need to find the correct index in constant buffer as it is on different position than I computed. I would expect that R-G-B-A has offsets 0-4-8-12, so alpha value is at offset 12. But here it seems to be at 8, so I think I have overlooked something in the shader assembly.