Page 1 of 2 12 LastLast
Results 1 to 40 of 69

Thread: Please help!

  1. #1

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    Arrow Please help!

    I've searched all over the net and cant find anything!
    I've asked in this forum too without any success...

    How do i calculate a 3d dot's position on a 2d plane?

    x=?
    y=?

    Could that be so hard?

    If you're good at these stuff...please also tell me how to work with vectors!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Didn't the reply I gave work??
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    well....i didnt get it to work...maybe if i play around alot with it, but there must be someone that has a formula for calculating it.

    i went to www.howstuffworks.com and looked it up, but they didnt give me all of the formula...they just said something like this: "now you see how much calculations there is in a 3d scene", then i replied for myself "I DONT CARE! I WANT TO KNOW HOW!" hehe...im getting crazy searching for this! i dont know what to search for. i search for "3d math" and get alot of irrelevant stuff! damn...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  4. #4

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    this is what i made after reading at howstuffworks.com:

    VB Code:
    1. Option Explicit
    2. Const ScreenWidth As Long = 640     'the width of the world we're looking at
    3. Const ScreenHeight As Long = 480    'the height of the "world" we're looking at.
    4. Const Depth As Long = 2     'the depth (front to back) of the world we're looking at
    5. Dim Sy As Double            'height of our window into the world
    6. Dim Sx As Double            'width of our window into the world
    7. Dim Sz As Double            'a depth variable that determines which objects are visible in front of other, hidden objects
    8. Const D As Double = 0.75    'the distance between our eye and the window in this imaginary world.
    9.  
    10. Const Fov As Double = 22    'the total field of view
    11. Const Zn As Double = 1      'the point closest to us where we can no longer see into the imaginary world
    12. Const Zf As Double = 30     'the point farthest from us where we can no longer see into the imaginary world
    13.  
    14. Dim s As Double             'stuff
    15. Dim c As Double             'stuff
    16. Dim Q As Double             'stuff
    17.  
    18. Dim X As Double             'point coords
    19. Dim Y As Double             'point coords
    20. Dim Z As Double             'point coords
    21. Dim W As Double             'point coords
    22.  
    23. Dim X2 As Double            'point coords
    24. Dim Y2 As Double            'point coords
    25. Dim Z2 As Double            'point coords
    26. Dim W2 As Double            'point coords
    27.  
    28. Const PiDiv180 As Double = 1.74532925199433E-02     'Pi / 180
    29.  
    30.  
    31. Private Sub Draw()
    32.     X2 = X * c + ScreenWidth / 2
    33.     Y2 = Y * c + ScreenHeight / 2
    34.     Z2 = s * Zf * ((Z - Zn) / (Zf - Zn))
    35.     W2 = W * s * c
    36.    
    37.     PicDisp.PSet (X2, Y2)
    38.     PicDisp.Refresh
    39. End Sub
    40.  
    41. Private Sub Form_Load()
    42.     PicDisp.Width = ScreenWidth * Screen.TwipsPerPixelX
    43.     PicDisp.Height = ScreenHeight * Screen.TwipsPerPixelY
    44.    
    45.     Sx = ScreenWidth * D / Depth
    46.     Sy = ScreenHeight * D / Depth
    47.    
    48.     s = Sin(Fov / 2 * PiDiv180)
    49.     c = Cos(Fov / 2 * PiDiv180)
    50.     Q = s / (1 - Zn / Zf)
    51.    
    52.     X = -5
    53.     Y = 0
    54.     Z = 0
    55.    
    56.     Draw
    57. End Sub

    but theres still something missing! what?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  5. #5
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    What type of 3D are you trying to create? Perspective, isometric....

    Also, won't you need a position vector and an angle vector of the camera?
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  6. #6
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Did some googling and fond a few links that may be useful.

    For a nice explanatory page click below.

    http://www.geocities.com/ResearchTri.../tv_index.html

    Not sure how helpful the next page is, but it may be useful.

    http://216.239.51.104/search?q=cache...hl=en&ie=UTF-8

    BTW, i searched for "3d position 2d plane" on incase you're wondering (without the quotes).
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  7. #7
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I got a formula for ya, its taken me a while to get their and it still needs a tiny bit more.
    VB Code:
    1. Lander = (nx*(Bx-ax) + ny*(By-ay) + nz*(Bz-az)) / (nx*(cx-ax) + ny*(cy-ay) + nz*(cz-az))
    2.  
    3. X = ax + (cx - ax) * Lander
    4.  
    5. Y = ay + (cy - ay) * Lander
    6.  
    7. Z = az + (cz - az) * Lander
    I'll post a pic to tell you what the things all stand for...
    (just got to draw it first)
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  8. #8
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    The formula tells you the 3D position on the screen plane(its 3D because if you tilt the camera up it will need the screen plane to work in 3D) that the vector intercepts it. I'll get on to writing something now to change this 3D position into a 2D point on the screen.
    Attached Images Attached Images  
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  9. #9
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: Please help!

    Originally posted by cyborg
    If you're good at these stuff...please also tell me how to work with vectors!
    What sort of stuff do you want to know?

    Vectors are pretty simple really.

    A vector has 3 values, for positions & offsets (velocity) they're usually called x,y and z, for a direction vector you may call them something else (Pitch, Yaw & Roll for instance).

    To add them, simply add the x, y and z calues with another vectors x,y and z values respectivly.

    The opposite of a vector is simply (-x,-y,-z)

    Another thing you'll probably need to know is how to normalize a vector.

    This means, given a velocity vector (most common use), make it so that the speed is exactly 1, but the direction remains the same.

    Anything else?
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  10. #10
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    He's my works:
    Page1
    Attached Images Attached Images  
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  11. #11
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Page2
    Attached Images Attached Images  
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  12. #12
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Page 3
    Attached Images Attached Images  
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  13. #13
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Hehe, didn't realise the pics were so big, soz
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  14. #14
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Originally posted by Electroman
    Hehe, didn't realise the pics were so big, soz
    Let's hope cyborg isn't a 56ker.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  15. #15
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I'm using a 56K at the moment and it didn't take that long(mind the images are less than 100KB each) jpegs are doing some wicked compression, A??
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  16. #16
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    BTW, on the first page, shouldn't that 'b' be a 'c', if not where did it come from?
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  17. #17

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    Re: Re: Please help!

    Originally posted by SLH
    What sort of stuff do you want to know?

    Vectors are pretty simple really.
    I really want to use vectors! so i can move and rotate the camera! that would be nice...


    Electroman: I'll look into your stuff later...im a bit busy right now!


    Thanks for att your help!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  18. #18
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: Re: Re: Please help!

    Originally posted by cyborg
    I really want to use vectors! so i can move and rotate the camera! that would be nice...

    If you want to do that then your camera would have to have to vetors associated with it. One that was it's position, and one that was the direction it's facing.

    To make it move, you'd also want a veolcity vector.

    Making the camera move, would simply be camera.positionvector + camera.Velocityvector.


    The direction vector would have to be somehow incorperated into the 'graphics engine' (the system to draw your 3D stuf on a 2D screen).

    I'll try to write a little module with some common vector functions for you.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  19. #19
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    SLH: hehe, yea I noticed it just after posting the third page(my bad), it was cos instead of "c" I was using "b" then I changed my mine because "c" for camera, and I wanted to use "B" latter on .
    You'd think the letter "b" in nearly 2cm high text i'd of noticed it .
    I've nearly got the whole last bit done, wooohooo!!!!!
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  20. #20

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    That woul be really nice!

    The main problem i have is to write the functons that converts from 3d to a 2d plane...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  21. #21
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    By 2D plane am I write in assuming you mean Screen coordinates??
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  22. #22
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Originally posted by cyborg
    That woul be really nice!

    The main problem i have is to write the functons that converts from 3d to a 2d plane...
    Did you take a look at the links i suggested?


    Below is a few vector functions, they are quite low level, but more powerfull functions could easily be built on top of them.

    VB Code:
    1. Type TVector
    2.     X As Single
    3.     Y As Single
    4.     Z As Single
    5. End Type
    6.  
    7. Public Function VAdd(V1 As TVector, V2 As TVector) As TVector
    8.     VAdd.X = V1.X + V2.X
    9.     VAdd.Y = V1.Y + V2.Y
    10.     VAdd.Z = V1.Z + V2.Z
    11. End Function
    12. Public Function VNormalize(V As TVector, Optional Length As Single = 1) As TVector
    13.     Dim Mag As Single
    14.     Mag = VMagnitude(V)
    15.     VNormalize.X = V.X * Length / Mag
    16.     VNormalize.Y = V.Y * Length / Mag
    17.     VNormalize.Z = V.Z * Length / Mag
    18. End Function
    19. Public Function VEqual(V1 As TVector, V2 As TVector) As Boolean
    20.     VEqual = V1.X = V2.X And V1.Y = V2.Y And V1.Z = V2.Z
    21. End Function
    22. Public Function VMagnitude(V As TVector) As Single
    23.     VMagnitude = Sqr(V.X ^ 2 + V.Y ^ 2 + V.Z ^ 2)
    24. End Function
    25. Public Function VScale(V As TVector, Factor As Single) As TVector
    26.     VScale.X = V.X * Factor
    27.     VScale.Y = V.Y * Factor
    28.     VScale.Z = V.Z * Factor
    29. End Function
    30. Public Function VDotProduct(V1 As TVector, V2 As TVector) As TVector
    31.     VDotProduct.X = V1.X * V2.X
    32.     VDotProduct.X = V1.Y * V2.Y
    33.     VDotProduct.X = V1.Z * V2.Z
    34. End Function
    35. Public Function VIsZero(V As TVector) As Boolean
    36.     VIsZero = V.X = 0 And V.Y = 0 And V.Z = 0
    37. End Function
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  23. #23

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    Yes i did look at the links, but they allready showed me some stuff i've seen before that didnt help me much...

    Thanks for those functions!
    btw, whats does the normalization do?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  24. #24
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Here's an updated version, with a new function:

    VB Code:
    1. Type TVector
    2.     X As Single
    3.     Y As Single
    4.     Z As Single
    5. End Type
    6.  
    7. Public Function VAdd(V1 As TVector, V2 As TVector) As TVector
    8.     VAdd.X = V1.X + V2.X
    9.     VAdd.Y = V1.Y + V2.Y
    10.     VAdd.Z = V1.Z + V2.Z
    11. End Function
    12. Public Function VNormalize(V As TVector, Optional Length As Single = 1) As TVector
    13.     Dim Mag As Single
    14.     Mag = VMagnitude(V)
    15.     VNormalize.X = V.X * Length / Mag
    16.     VNormalize.Y = V.Y * Length / Mag
    17.     VNormalize.Z = V.Z * Length / Mag
    18. End Function
    19. Public Function VEqual(V1 As TVector, V2 As TVector) As Boolean
    20.     VEqual = V1.X = V2.X And V1.Y = V2.Y And V1.Z = V2.Z
    21. End Function
    22. Public Function VMagnitude(V As TVector) As Single
    23.     VMagnitude = Sqr(V.X ^ 2 + V.Y ^ 2 + V.Z ^ 2)
    24. End Function
    25. Public Function VScale(V As TVector, Factor As Single) As TVector
    26.     VScale.X = V.X * Factor
    27.     VScale.Y = V.Y * Factor
    28.     VScale.Z = V.Z * Factor
    29. End Function
    30. Public Function VDotProduct(V1 As TVector, V2 As TVector) As Single
    31.     VDotProduct.X = V1.X * V2.X + V1.Y * V2.Z + V1.Z * V2.Z
    32. End Function
    33. Public Function VIsZero(V As TVector) As Boolean
    34.     VIsZero = V.X = 0 And V.Y = 0 And V.Z = 0
    35. End Function
    36. Public Function VCrossProduct(V1 As TVector, V2 As TVector) As TVector
    37.     'Direction of VCrossProduct(V1,V2) is perpendicular to plane with vectors V1 and V2 on it,
    38.     'magnitude is VMagnitude(V1)*VMagnitude(V2)
    39.     VCrossProduct.X = V1.Y * V2.Z - V2.Y * V1.Z
    40.     VCrossProduct.Y = V1.Z * V2.X - V2.Z * V1.X
    41.     VCrossProduct.Z = V1.X * V2.Y - V2.X * V1.Y
    42. End Function

    The easiest way to think about the norm. function is by example.

    If the vector V was a velocity vector. Then it's magnitude is it's speed (how fast it's moving, ignoreing direction).

    If you want the speed to be reduced to 1, but keep the object moving in the same direction, you'd normalize it's velocity vector.

    Hope that was an adiquate explanation.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  25. #25
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I'll see what i can do with the 3D stuff now....
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  26. #26

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    Thanks alot! You've been really helpful!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  27. #27
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I think this will work, but i havn't tested it properly yet though...

    VB Code:
    1. Public Function Pos2Cord(DotPosition As TVector, CamPosition As TVector, CamPanning As TVector) As TCord
    2.     Dim PanPos As TVector
    3.     Dim DotPos As TVector
    4.     DotPos.X = DotPosition.X + CamPosition.X
    5.     DotPos.Y = DotPosition.Y + CamPosition.Y
    6.     DotPos.Z = DotPosition.Z + CamPosition.Z
    7.    
    8.     PanPos.X = DotPos.X * Cos(CamPanning.X) - PanPos.Z * Sin(CamPanning.X)
    9.     PanPos.Z = DotPos.X * Sin(CamPanning.X) + PanPos.Z * Cos(CamPanning.X)
    10.     PanPos.Y = DotPos.Y * Cos(CamPanning.Y) - PanPos.Z * Sin(CamPanning.Y)
    11.    
    12.     DotPos.Z = PanPos.Y * Cos(CamPanning.Y) - PanPos.Z * Sin(CamPanning.Y)
    13.     DotPos.X = PanPos.X * Cos(CamPanning.Z) - PanPos.Y * Sin(CamPanning.Z)
    14.     DotPos.Y = PanPos.X * Sin(CamPanning.Z) + PanPos.Y * Cos(CamPanning.Z)
    15.    
    16.     If DotPos.Z > CamPosition.Z Then
    17.         Pos2Cord.X = DotPos.X / DotPos.Z * Zoom + Form1.Width / 2
    18.         Pos2Cord.Y = DotPos.Y / DotPos.Z * Zoom + Form1.Height / 2
    19.     End If
    20. End Function

    i gtg soon, but i'll keep puzzling over it until i do.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  28. #28
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  29. #29
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Here we go agin:
    VB Code:
    1. d= Sqr(((X-Bx)^2) + ((Y-By)^2) + ((Z-Bz)^2))
    2. Theta = InverseCos((ux*dx + uy*dy + uz*dz) / u*d)
    3.  
    4. 'Now to find the (X,Y) screen co-ordinate:
    5. XOffSet = d*Sin(Theta)
    6. YOffSet = d*Cos(Theta)
    7. 'These OffSet values are from the center of the screen
    I'm goging to write a class to hold all this because these a lot of these things that will only change if the camera is adjusted so a Class could handle it very easily.
    Another diagram to describe the new stuff:
    Attached Images Attached Images  
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  30. #30
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Check out the files attached, I used a couple of your vector functions SLH to keep the codeshort in the class.
    Attached Files Attached Files
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  31. #31
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Originally posted by Electroman
    I used a couple of your vector functions SLH to keep the codeshort in the class.
    Glad they helped.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  32. #32

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    I cant get the class file to work...I get all kinds of error messages about the UTS's and functions..like this one for example:

    "Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types"
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  33. #33
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    try just throwing it into a normal code module then because I got that error and just had to use it sepratly, I don't get the error becasue I did decalare the "Type" in a public module
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  34. #34
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    You'll also need to change the params to ByRef cos there user-defined type, opps.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  35. #35

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    ok i'll try that!

    btw, what does ByRef mean?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  36. #36
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    ByRef is instead of ByVal, When you use ByVal only the Value of the parameter is sent to the sub, but when you use ByRef a pointer is sent that points to the variable that you used as a parameter so if in the sub the parameter is edited the variable you gave the procedure will also be edited. I'm sure someone could give you a better definition, I can't say what I mean if you get me??

    Try this example project, I can't seem to get it to work perfectly but it does display the points, just there all together:
    Attached Files Attached Files
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  37. #37
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I spoke too soon, change the FOV to about half what I set it to and move the cam pos to:
    VB Code:
    1. CamPos.X = 50
    2. CamPos.Y = 50
    3. CamPos.Z = 50
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  38. #38
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    heres what I have now, I found a typo in the ConvertVetor Procedure and I've fixed that, apart from that theres seems to be something up with the X and Z axis if the camera is set so LookAt.X = LookAt.Y I'm trying to fix that now but can't be sure if its actually just perspective?? Anyway take a look at the attachment, I also fixed a problem that caused the screen to be upside down, in my diagrams the vector u should be the oposite way round, my bad. I feel victory near.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  39. #39

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    yes, you're probably really close. i cant check anything right now cus the whole family is here visiting so i must be with them all the time. Lots of small kids
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  40. #40

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    this one looks pretty good, but its without vectors.
    maybe it will help you a bit
    Attached Files Attached Files
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

Page 1 of 2 12 LastLast

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