I'm confused in using geometry shader for solve this problem:
I have two radius of a circle that every radius is a line and I called that's a line. every line is made of list of points that every points have a color.
so how fill between two lines with lines that's color of every point on a line has between colors of points of two lines on a equal radius.
it is so may be complex so I show it with a picture:
gradient Radiuses
.
I think best way of solving this problem is geometry shader but if you know better way that have good performance, I listen.
thanks.
Related
I have a question concerning the FME workbench. I would like to know how I can extract the coordinates of the intersection-points of a line intersecting an area (a mesh with poligons). The coordinates of the intersection-points should have a maximal precision.
To give you some more information about my problem I have attached some screenshots.
Here you can see the nodes in FME that create the lines. Each line is perpendicular to the mesh. The mesh is hollow inside, so the lines intersect the mesh twice. I would need the intersection coordinates from the first time the line intersects with the mesh
Here you can see the intersections of the lines with the mesh better
I would be very thankful, if you could provide any information on how to solve this problem. If you need any more infos, just let me know 😃
Thanks very much in advance!
use the FME transformer intersector. intersected lines will have attributes from polygon. And you can generate points at the ends(line).
and you can segregate the points based on the attribute of a polygon.
I'm trying to draw a circle with filled, randomly generated polygons drawn on top of it, but I can't work out how to make it so that the polygons are only drawn on top of the circle.
Here's a mockup as an example:
I have a achieved the random polygons drawn on a circle, using the love.graphics.polygon() function with a set of randomly generated points, but I'm looking for a way of clipping them when they're drawn so that they're only filled in on top of the circle.
Here's what I've actually got so far:
So, my question is: is there a function that I can call in the love.draw function that clips parts of the polygon drawn outside of a range, or is it going to be harder to fix than that?
Thanks in advance!
It turns out that I could have just spent a minute looking at the love.graphics documentation. Anyway, the love.graphics.stencil() function and its counterpart love.graphics.setStencilTest() are just what I needed.
You can pass the draw function for the circle to the love.graphics.stencil() function, and the using the setStencilTest(), you can make it not draw pixels outside that circle function. The documentation has some good examples.
I have two objects: A sphere and an object. Its an object that I created using surface reconstruction - so we do not know the equation of the object. I want to know the intersecting points on the sphere when the object and the sphere intersect. If we had a sphere and a cylinder, we could solve for the equation and figure out the area and all that but the problem here is that the object is not uniform.
Is there a way to find out the intersecting points or area on the sphere?
I'd start by finding the intersection of triangles with the sphere. First find the intersection of each triangle's plane and the sphere, which gives a circle. Then find the circle's intersection/s with the triangle edges in 2D using line/circle tests. The result will be many arcs which I guess you could approximate with lines. I'm not really sure where to go from here without knowing the end goal.
If it's surface area you're after, maybe a numerical approach would be better. I'd cover the sphere in points and count the number inside the non-uniform object. To find if a point is inside, maybe trace outwards and count the intersections with the surface (if it's odd, the point is inside). You could use the stencil buffer for this if you wanted (similar to stencil shadows).
If you want the volume of intersection a quick google search gives "carve", a mesh based CSG library.
Starting with triangles versus the sphere will give you the points of intersection.
You can take the arcs of intersection with each surface and combine them to make fences around the sphere. Ideally your reconstructed object will be in winged-edge format so you could just step from one fence segment to the next, but with reconstructed surfaces I guess you might need to apply some slightly fuzzy logic.
You can determine which side of each fence is inside the reconstructed object and which side is out by factoring in the surface normals along the fence.
You can then cut the sphere along the fences and add the internal bits to the display.
For the other side of things you could remove any triangle completely inside the sphere and cut those that intersect.
I'm using DirectX10 to simulate a water surface, and I'm now with a height map,which is a 2D array of the heights(y) at the points (x,z). But to draw it on the screen, I must turn it into a mesh or have a index to draw triangle topology.
But the data is too large to do it manually. Are there any methods for me to draw it on the screen. I hope it's easy to implement. If there is function included in DirectX10 which can make it, the it's the best one for me.
Create a mesh that format a grid of squares (each made of two triangles) and set all vertices y = 0. In the vertex shader sample the heightmap and add the value stored in the heightmap to the y of the vertice.
This might help you.
P.S: If the area you want it to cover is too big you should take a look at terrain LOD techniques (should work the same for water).
I'm sure you can make a mesh out of it. I doubt you can generate the heightmap for a water surface that is too large to "meshify".
Why are you looking at Diamond square. For a 512x512 heightmap all you need to do is define a set of point and then generate the triangles for it. Its really very simple.
I am writing a program (.net) to create a stadium style layout and need to determine the angle of rotation for each polygon compared to the horizontal.
This is so i can construct the contents of the polygon and also rotate this correctly to fit inside.
Given the below image as an example to simulate each variant of the facing direction (indicated by the red line) how could i determine the the rotation angle needed to get the shape to have the red line on top as is already shown by shape 5.
http://i40.tinypic.com/16ifhoo.gif
I have found logic to determine the angle of the points that make up the red line, but I also need to know the rotation to get it back to horizontal.
I'm not sure if i need some central reference point for all polygons to help.
How could I best solve this?
If you know the angle of the red line for some polygon (a, say), then the polygon is on one side or other of that line. So:
Use the average colour of some pixels near the line on both sides to determine which is the case.
If the polygon is above the line, the rotation angle is 180+a.
If the polygon is below the line, the rotation is a.
where above and below correspond to the smaller-angle side and larger-angle sides of the line according to how you measure a.
I would try to calculate the normal vectors on each red line (eg. 0 degrees for polygon 5, 45 degrees for 4, 90 degrees for 3, etc.) and then the angle you need to rotate that normal - and thus the matching polygon - so that the normal "points up" should be very simple.
Unfortunately I don't have the needed formulae available for you off the top of my head, but Googling "normal vector" and/or searching for it on Wikipedia should get you started just fine, I think. Possibly in the direction of the so called 'cross product'.
No central reference point for all polygons should be needed for this (normal direction is not related to absolute coordinates).
sin, cos, tan functions allow you to convert from triangle edge ratio to degrees.
Imagine, one end of red line is at (x1,y1) and other end is at (x2,y2). You can treat red line as hipotenuse of rectangular triangle and use arctan to get degrees.
Ratio between catheti is (x2-x1) / (y2 - y1). Rotation of red line then is arctan((x2-x1) / (y2 - y1)). Watch out for situations when y1-y1 is 0!
Let's try one example from your picture, polygon 6 with coords (55, 65) and (65, 55). Type in google: "arctan((65-55)/(55-65)) in degrees"