Results 1 to 12 of 12

Thread: help help help

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2014
    Posts
    3

    help help help

    hi I need to draw some thing like this(only wire frame) in 3d using code and rotate it and zoom in and out to view using vb6
    Name:  9NLqpi.jpg
Views: 637
Size:  26.6 KB

    how this can be done direct 3d or open gl or other
    I need help with an example also please????

  2. #2
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    557

    Re: help help help

    Yes, you can do it with OpenGL or DirectX(direct3d), but if you need only wireframe, you can do it in purely VB code.


    Although you can set up OpenGL or DirectX with only a few lines of code, using either requires you to learn the basics of their framework and follow the rules. The pure code approach is simpler in many ways and will let you customize your code for wireframe representation. Once you have learned the basics about viewports and 3d world transforms, it will be rather easy to put your vertices data into simple arrays and apply rotation transforms and zooms.

    I suggest you google : vb6 3d cube source

    That should give you plenty of simple programs to start with, in all three options, and decide which approach you like best.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: help help help

    If you want to see a really neat (excellent in my opinion) example of wire frames using just VB & APIs. Here's one from a friend of mine that he posted on PlanetSourceCode
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2014
    Posts
    3

    Re: help help help

    This is not a cube
    I only want to draw some lines in 3d and zoom and rotate them smoothly
    I need a basic example for this in direct 3d or open gl which easier
    I need more help please

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2014
    Posts
    3

    Re: help help help

    any help

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: help help help

    Homework?
    The example LaVolpe linked to is probably WAY over your head (it is mine!!! :-))), so I assume what you want is someone to do your work for you so you don't have to do anything but copy-paste someone else's hard work.
    If I were you, I'd first learn to rotate a line. (Well, maybe you need to learn how to DRAW a line first...I don't know.), then experiment with your code and see if you can add a second 90-degree line to it and rotate both together. If you succeed, then obviously you have learned the techniques necessary to accomplish what you want to do.
    Otherwise, in order to get your homework done (by someone else), I'd suggest you GOOGLE the entire internet for examples (or full projects), rather than ask the folks here to do your work for you.
    The 'experts' on this site do not get paid a dime for their posts even though some have spent hours, days and weeks on the projects/code snippets they post. But please don't expect these fine folks to do this type of work for you. Even LaVolpe (who COULD probably whip out an example in a few minutes) offered the best advice....search the internet---he even posted one of his search results.
    So, let's see what code YOU have attempted first, and then I am sure there are some experts who could assist you in tweaking your efforts.

  7. #7
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: help help help

    You know what? I'll weigh in on this one. I'm just thinking through how I'd do this without the benefit of a vector graphics engine. Or, in other words, just using VB6's graphics statements (primarily the Line statement).

    First, I'd define each line end-point as a three element vector, which would signify a 3D coordinate based on some common origin (0,0,0) in 3D space. I might even have a UDT something like the following:

    Code:
    Type PointUdt
        x as Double
        y as Double
        z as Double
    End Type
    
    Type LineUdt
        StartPt as PointUdt
        EndPt as PointUdt
    End Type
    With the LineUdt, you could fairly easily define your 3D grid thingy.

    Next, I'd write a function that multiplied these LineUdt vectors by something called a quaternion. Now a quaternion is a strange and somewhat confusing animal, but they're not once you understand them. If you think of any 3D object (a jar, a dog, whatever), and then find its geometric center, and then project a ray out of that center in some direction, that's part of a quaternion. The last piece is a degree of rotation. Therefore, there are four pieces to a quaternion, x,y,z that define the direction of the ray projecting from the geometric center, and the angle. When a vector is multiplied by a quaternion, it is rotated in 3D space in any direction you like by any amount of degrees (angle) you like.

    Vector by quaternion math is fairly well worked out, and I won't make this post longer than it already is by working it out here.

    Once you have this, you just need to assemble your quaternion, multiply every line's start-point and end-point by this quaternion, and re-plot your image. You could even put your quaternion creation on the left,right,up,down arrow keys if you wanted.

    I'm worried about how speedy all of this would be because this is exactly the kinds of things that graphics accelerators and graphics cards were developed to do (so we wouldn't have to do them the "hard" way as outlined above).

    Regards,
    Elroy

    EDIT: You'd only need to use X and Y to do your plotting, but you'd have to internally keep track of X,Y, and Z so that you could correctly do your vector by quaternion multiplications thereby preserving the 3D appearance of the thing.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: help help help

    Just because my other projects are at nice stopping places, here's a fair image of how a quaternion works:

    Name:  axisAngle1.png
Views: 329
Size:  23.4 KB

    The individual points (defined by X,Y,Z vectors) might be anywhere, but they'll rotate around their origin (0,0,0). For instance, a point that has a value of (0, 5.444, 0) would reside on top of the Y axis. The quaternion is represented by the red vector in the image, as well as an angle for re-orientation, represented by some amount of degrees on the green circle. As each (all) vectors are multiplied by the quaternion, they will re-orient around in 3D space. Once you have them all re-oriented, erase your PictureBox and replot all the lines using only the X,Y portion (because the Z portion is effectively squashed onto the screen). However, when you further re-orient the image, you'll have the visual perception that it's a 3D object.

    Who knows, it might be fun to do in pure VB6. Purely an academic exercise though.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  9. #9
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: help help help

    Hmmm, zooming in and zooming out. (Just re-read the thread starter's post.) That'd just be going through all the X,Y,Z start/end points of all the lines and multiply or divide them all by a common factor, and then replot.

    There's also the issue of sliding (or changing the (0,0,0) origin). That's easy too. To slide in X, just go through all the X,Y,Z start/end points of all the lines and add (or subtract) a common term to them, and replot. Shifting in Y and/or Z is the same. And there IS a shifting in Z. You would particularly notice it when you re-orient the degrees of rotation. A Z orientation in the middle of the object would make it evenly spin. A Z orientation biased toward the front would make the object seem to flop toward the screen when reoriented on either X or Y. A Z orientation away would make it seem to turn further into the screen when re-oriented.

    *shrugs* I guess I need to find another project though.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  10. #10
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    557

    Re: help help help

    lolll don't waste your time

    Cube Cube Cube, load little vb project (20 lines of code), press run

    It the OP can't do a cube, I don't think quaternions will do much for his rescue

  11. #11
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: help help help

    Yeah, I know. I just couldn't find another thread to splash around in.

    Maybe I'll go back to the thread where the guy wants to change the pitch of a WAV file and do some Fourier transformations for him LOL. Pffff, just ANYTHING to keep from doing real work.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  12. #12
    New Member
    Join Date
    Sep 2022
    Posts
    1

    Re: help help help

    Someone has some code for his problem?

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