locked
Fill area with Direct3D

    Question

  • Hi, i used GDI+ and could draw polylines on a path then fill the path so the area between the polylines would be filled with a color, how do i do the same thing with Direct3D?

    sorry my poor english,

     

     

    Thursday, October 20, 2011 4:16 PM

Answers

  • The common way to present a planet is to render a texture that contains the surface on a sphere. You can use your data and classic 2D techniques to build such a texture.

    If you want to render it a geometry based on your raw data there is no other way than generating polygons from your data set. You can simplify this by splitting the large areas to smaller sections. But in the end you will always need polygons to get filled surfaces. That’s the way 3d APIs work.

    Sunday, October 23, 2011 7:56 AM

All replies

  • In Direct3D things work different then in GDI. If you have never worked with a 3D API before you might start with some introduction articles to understand the concepts. For a first impression you can check the older Direct3D 9 introduction: http://msdn.microsoft.com/en-us/library/bb173466(v=VS.85).aspx Please be aware that Metro style applications require the usage of Direct3D 11/11.1 but the basic are mostly the same.

    If you are just interested in drawing 2D graphics Direct2D might be a better solution for you: http://msdn.microsoft.com/en-us/library/dd370990(v=VS.85).aspx

     

    Thursday, October 20, 2011 4:35 PM
  • As Ralf says, Direct2D is a much closer analog to GDI than Direct3D is.  There is an article describing how to create paths in Direct2D and fill them at http://msdn.microsoft.com/en-us/library/ee264309%28v=VS.85%29.aspx

    --Rob

    Thursday, October 20, 2011 4:44 PM
    Moderator
  • Thanks, yes im really new to DirectX and how it work but it seems very interesting. I have made a datafile that has about 280 000 geographic coordinates, longitudes and latitudes and i made a function that calculate x,y,z for each of those coordinates.

    An array of CustomVertex.PositionColored[] vertices hold these calculated points and then i use device.DrawUserPrimitives(PrimitiveType.LineList, numofpoints, vertices); to display the lines between these points. It work well as you see below but i have no idea how to make the land and sea area have a texture. Subdividing the large irregular polygons to real polygons seems to be impossible?


    • Edited by Ove Sunday, October 23, 2011 7:25 AM
    Saturday, October 22, 2011 9:19 PM
  • The common way to present a planet is to render a texture that contains the surface on a sphere. You can use your data and classic 2D techniques to build such a texture.

    If you want to render it a geometry based on your raw data there is no other way than generating polygons from your data set. You can simplify this by splitting the large areas to smaller sections. But in the end you will always need polygons to get filled surfaces. That’s the way 3d APIs work.

    Sunday, October 23, 2011 7:56 AM
  • Thanks, yes im really new to DirectX and how it work but it seems very interesting. I have made a datafile that has about 280 000 geographic coordinates, longitudes and latitudes and i made a function that calculate x,y,z for each of those coordinates.

    An array of CustomVertex.PositionColored[] vertices hold these calculated points and then i use device.DrawUserPrimitives(PrimitiveType.LineList, numofpoints, vertices); to display the lines between these points. It work well as you see below but i have no idea how to make the land and sea area have a texture. Subdividing the large irregular polygons to real polygons seems to be impossible?


    Hello Ove,

    Did you solve your problem? If yes, how did you solve it? I meet a similar task to yours in my project.

    Friday, February 7, 2014 4:17 AM
  • The common way to present a planet is to render a texture that contains the surface on a sphere. You can use your data and classic 2D techniques to build such a texture.

    If you want to render it a geometry based on your raw data there is no other way than generating polygons from your data set. You can simplify this by splitting the large areas to smaller sections. But in the end you will always need polygons to get filled surfaces. That’s the way 3d APIs work.


    The most difficult task is to "You can simplify this by splitting the large areas to smaller sections". In Ove's case, his data are actually complex polygons that are difficult to split. I read somewhere else that tessellation can split polygons, but am not sure if it is a viable solution.
    • Edited by Leonard Friday, February 7, 2014 4:21 AM
    Friday, February 7, 2014 4:21 AM