Results 1 to 9 of 9

Thread: (VB6) Drawing Irregular Polygon

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    5

    (VB6) Drawing Irregular Polygon

    Dear all,

    I have finally completed my first stage of the character generation program.

    However, I would like to make some adjustment to it, and it involves drawing out irregular polygon. I have conduct a serach on this topic over the internet, and understand that it can only be achieved with API.

    Being a starter in visual basic, I am not able to identify the errors of the samples found, thus am not able to amend the script to achieve what I have in mind. As such, I need to troubled you guys again.

    Basically, I wish to use the program to draw a polygon to illustrate the results generated.

    For example: There are 8 results.

    if the result of point1 = 0, then it will not be taken into account
    if the result of point2 > 1, then the coordinates of the point of polygon will be (x2,y2)
    so on and so forth.
    the polygon will be formed by joining the adjcent points (ignoring the point if the result = 0)

    in other words, if 5 points of 8 result are 0, the diagram form will actually be a triangle of a designated size.

    Can anyone advised me on how this can be done?

    Furthermore, It there anyway to locate the coordinates of the point where the mouse is pointed in visual basic?

    Thanks for everything.

  2. #2
    Junior Member
    Join Date
    Mar 2007
    Location
    New Jersey
    Posts
    30

    Re: (VB6) Drawing Irregular Polygon

    I'm not quite sure what your first question is, but you might want to go through the list of points and then just drawn a line between all of the points > 0.

    Second question: if this is in a form then use the mousemove event for the form. X and Y are given parameters which will tell you the mouse's x,y position on the form.
    Final Fantasy Tactics Online
    Blank Engine (3D, Opensource, VB Engine)(Under construction but does have a download)

  3. #3
    Hyperactive Member singularis's Avatar
    Join Date
    Nov 2006
    Location
    Over There!
    Posts
    372

    Re: (VB6) Drawing Irregular Polygon

    I do not understand your first question, What is a result?

    As BinaryCode said you can get the cursor position "The Beginners way" through the form. You can also get the cursor position with API such as getCursorPos OR DirectInput. However as you state you are a beginner I will remind you that when you get mouse input from the form the X and Y coordinates will be in twips.

    What are you using to draw to the screen?
    If what I said was helpful, give me rep!

    My Complete Games: -- 2D Zone (Space Shooter game) || _2D Zone 2_ || Ninja Blob (2D platformer) || Dren (Co-op up to 4 player base defence game)

    My Projects: -- The Dread Engine (2D VB game Engine) || A* Path Finding


    An excellent site for learning DirectX7, 8 & 9 (for VB6, C# & VB.net) would be: directx4vb.vbgamer.com --- For my projects and games see: pieper.freehostia.com

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    5

    Re: (VB6) Drawing Irregular Polygon

    Thanks for the reply,

    Let me rephase my first question.

    I need to draw a polygon based on the results determined through the program.

    As mentioned, there will be 8 results being considered, and each result determine the existence of each point.

    For example:
    If all the 8 results are more than 0, then there will be 8 points where it can be joint up to form a 8 sided polygon.
    However, if out of the 8 results, only 3 of them are more than 0, then 5 points will be ignored. Therefore, a triangle (3 sided polygon) is being form instead.

    Depending on the result, the coodinates of each point will vary.

    For example: if result1 = 1 then, x1 = 6, y2 = 6, elseif result1 = 2 then, x1 = 9, y2 = 9.

    x refers to the position of the point along xaxis, while y refers to the position of the point along y-axis

    In other words, I wish to know how to draw a polygon where I will assign the points (edge) of the polygon, and the number of sides, depending on the resulted being determined in the program.

    Hope the above clarification is clear enough for someone to assist me on this.

    Thanks again

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    5

    Re: (VB6) Drawing Irregular Polygon

    Thanks for the reply,

    Let me rephase my first question.

    I need to draw a polygon based on the results determined through the program.

    As mentioned, there will be 8 results being considered, and each result determine the existence of each point.

    For example:
    If all the 8 results are more than 0, then there will be 8 points where it can be joint up to form a 8 sided polygon.
    However, if out of the 8 results, only 3 of them are more than 0, then 5 points will be ignored. Therefore, a triangle (3 sided polygon) is being form instead.

    Depending on the result, the coodinates of each point will vary.

    For example: if result1 = 1 then, x1 = 6, y2 = 6, elseif result1 = 2 then, x1 = 9, y2 = 9.

    x refers to the position of the point along xaxis, while y refers to the position of the point along y-axis

    In other words, I wish to know how to draw a polygon where I will assign the points (edge) of the polygon, and the number of sides, depending on the resulted being determined in the program.

    Hope the above clarification is clear enough for someone to assist me on this.

    Thanks again

  6. #6
    Hyperactive Member singularis's Avatar
    Join Date
    Nov 2006
    Location
    Over There!
    Posts
    372

    Re: (VB6) Drawing Irregular Polygon

    So you want your program to work out how many sides a shape has?

    OR

    Do you specify how many sides a shape has and then your program makes it?

    If neither of these are right, tell me what your problem is rather than telling me how you would do it.
    If what I said was helpful, give me rep!

    My Complete Games: -- 2D Zone (Space Shooter game) || _2D Zone 2_ || Ninja Blob (2D platformer) || Dren (Co-op up to 4 player base defence game)

    My Projects: -- The Dread Engine (2D VB game Engine) || A* Path Finding


    An excellent site for learning DirectX7, 8 & 9 (for VB6, C# & VB.net) would be: directx4vb.vbgamer.com --- For my projects and games see: pieper.freehostia.com

  7. #7

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    5

    Re: (VB6) Drawing Irregular Polygon

    Sorry that I failed to explained myself once again.

    This time round, to facilitate my explanation, I have enclosed a picture file for reference.

    The polygon i have in mind is something as shown in the picture. It will be determined based on the 8 results.

    For example, based on a scale of 0 to 5:
    0 means that the character has no potential in that particular talent.
    5 means that the character specialized in that particular talent.

    depending on the results determined, it will affect the shape, and sizes and sides of polygon.

    Hope this help.

    Sorry again for the poor elaboration.
    Attached Images Attached Images  

  8. #8
    Junior Member
    Join Date
    Mar 2007
    Location
    New Jersey
    Posts
    30

    Re: (VB6) Drawing Irregular Polygon

    Here's what I am thinking. Instead of just throwing out all the 0s, just draw a line between them, because if you don't it look kind of weird (unless you were planning on doing that). Then you would have an array representing the 8 points that would hold 1 value (integer, long, byte, w/e). Then start with 12 o'clock you would put the point at the array's first value (ie: array(0) = 1; point0.y = 1) and then you would hardcode where each point would go like a graph (array(1) = 2; point2.x = 2: point2.y = 2; gives you a diagnal) then go through each point in the array adding and subtracting the value to put it in it's spot. Then you could either use the vb draw line (look in the object browser under form or picturebox for syntax) or google for a gdi declare for drawing lines. Hopefully that helps you out.
    Final Fantasy Tactics Online
    Blank Engine (3D, Opensource, VB Engine)(Under construction but does have a download)

  9. #9
    Hyperactive Member singularis's Avatar
    Join Date
    Nov 2006
    Location
    Over There!
    Posts
    372

    Re: (VB6) Drawing Irregular Polygon

    The pictures were a huge help!

    BinaryCode 's method is simpler than mine but here goes:

    Are you any good at trigonometry? If so you will realise a pattern with the points:

    The top one, we shall call it v(0) and the one to the right of that I will call v(1) and so on.....

    If you are using form controls and not DirectX then replace (.x) with (.left) and (.y) with (.top).

    The ValueOfSkill array holds the value of each of your "skills".

    Code:
    for i = 0 to 7
    v(i).x = sin(angle * pi / 180) * ValueOfSkill(i)
    v(i).y = cos(angle * pi / 180) * ValueOfSkill(i)
    next i
    IF gonz.beginner = false THEN

    For the drawing side of things, start learning DirectX8. This thing would be a doddle in DX8. This is because DX8 deals with vertex data and draws it to the screen AND when you first learn DX8 the first thing you learn how to do is draw a polygon (specifiying vertexes/coordinates).

    ELSE

    Do what BinaryCode said

    END IF
    If what I said was helpful, give me rep!

    My Complete Games: -- 2D Zone (Space Shooter game) || _2D Zone 2_ || Ninja Blob (2D platformer) || Dren (Co-op up to 4 player base defence game)

    My Projects: -- The Dread Engine (2D VB game Engine) || A* Path Finding


    An excellent site for learning DirectX7, 8 & 9 (for VB6, C# & VB.net) would be: directx4vb.vbgamer.com --- For my projects and games see: pieper.freehostia.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width