Results 1 to 8 of 8

Thread: DirectX9, getting started

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    DirectX9, getting started

    This is probably directed at The Trick more than anyone else, but I'm certainly willing to listen/read any ideas.

    I'm going to take some time to get some vector graphics going. I've got all the vectors, and they're all 3D vectors, basically just two X,Y,Z end-points. There will also be a need to draw some spheres with an X,Y,Z centroid and an r radius. I suppose the vectors will also have a "thickness".

    Now, when doing vector graphics, I always think of a Camera Position. With respect to the camera, some people talk about Pan and Zoom. Pan is correct, but Zoom is not. It's my understanding that Zoom changes the magnification (which can distort things). Rather, I think a forward/backward Pan may be a better way to discuss it.

    Therefore, eventually, I will need to understand how to Left-Pan, Right-Pan, Up-Pan, Down-Pan, In-Pan, & Out-Pan. Also, I will need to understand how to rotate the camera. With respect to zoom, I'll always be staying at 100% (i.e., no distortion).


    Ok, to start with, let's forget about the camera. I'll just need to understand how to draw lines (i.e., 3D vectors) and spheres (i.e., 3D points in space). Setting the color of the background would also be very nice.

    Trick, I've looked at your examples, but they just get too complex too quickly for what I'm trying to do. Also, I've done ALL of this in DirectX8, but it's been a few years since I messed with it. And DX9 appears quite a bit different from DX8.

    Trick, if you could set up a down-and-dirty example on how to draw lines and spheres, I would be exceedingly grateful. Or, if anyone else has done it using his dx9vb.tlb TypeLib, I'd love to see it.

    All The Best,
    Elroy

    EDIT1: Maybe I should call them line-segments rather than vectors. It's really two vectors, and I'll be drawing a line between the two end-points.
    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.

  2. #2
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,797

    Re: DirectX9, getting started

    Hi, Elroy.
    I will comment about fixed-pipeline only, no shaders.

    Before make an example i need to clarify some things. What's distortion exactly?
    If you want to have no distortion at all (like 2d) you can use othographic projection (parallels lines always stay parallel), far objects has the original size without perspective correction.


    If you only want has the zoom like if it's just image and you need to scale it you need to change field of view. It's like as if you make zoom on photo-camera, no camera moving.

    Firstly i used pan-in and then FOV. https://msdn.microsoft.com/ru-ru/lib...(v=vs.85).aspx

    Now, when doing vector graphics, I always think of a Camera Position.
    Actually there is no camera at all but there is view transform. All world is drew from the (0,0,0) point during rendering time. For example, when you move camera to right all world is moved to left. All the camera's transformations are just inverse the world's transformations. You can read that basic information about view-transform.

    Therefore, eventually, I will need to understand how to Left-Pan, Right-Pan, Up-Pan, Down-Pan, In-Pan, & Out-Pan.
    You can just change the VIEW matrix.

    Also, I will need to understand how to rotate the camera. With respect to zoom, I'll always be staying at 100% (i.e., no distortion).
    That's very simple because you need to apply transformations in proper way (rotation-translation). Example.

    Ok, to start with, let's forget about the camera.
    You can draw without a camera if you want (see example with triangle where i used screen coordinates).

    I'll just need to understand how to draw lines (i.e., 3D vectors) and spheres (i.e., 3D points in space).
    You can draw as lines (D3DPT_LINELIST, D3DPT_LINESTRIP) as objects that represent lines (cylinders with different segments, planes). To create sphere you need to generate a surface (mesh) of sphere. I already have generated the procedural spheres in that project (balls). This project contains many procedural things (cylinders with segments etc.)

    Setting the color of the background would also be very nice.
    Using Clear method you can set the color of background.

    And DX9 appears quite a bit different from DX8.
    I don't work with Direct3D enough to see big difference between 8 and 9 (maybe shaders that i don't use ever). dx8vb has the advantages like the classes that i didn't implement but you always can use original D3DX functions from the system dlls.

    Maybe I should call them line-segments rather than vectors.
    Yes, a vector just direction and length.

  3. #3

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: DirectX9, getting started

    Hi Trick,

    Thank you greatly for replying!

    Let me see if I can answer your question ("What's distortion exactly?"). Maybe I'm thinking too much about a real camera (rather than DirectX). When using a real camera, you can get something that's called the Vertigo Effect. Here's a YouTube example out of Poltergeist. You simultaneously zoom-in-and-pan-out (or vice-versa), keeping some focal point the same size. That's not what I'm trying to do. In fact, I want my zoom to stay at 100%.

    You talked about "parallels lines always stay parallel". However, that's not quite it. If we have a cube, and we're looking head-on at it, the sides will start out parallel (on the 2D screen). However, if we pan down, the sides will no longer be parallel (at least, not on the screen). There's no way to avoid that.

    But with zoom, line-segments can become non-linear (i.e., curved) (particularly with zoom out, i.e., wide angle). Here's an example of that:

    Name:  Image1.png
Views: 480
Size:  191.0 KB

    I want all my line-segments to always stay linear (i.e., 100% zoom).

    I've made a little video of what I'd like to do. This is using a file that I often process (a C3D file). However, this is not my software:
    http://motionlabresources.org/Untitled2.mp4

    As you can see, I can easily rotate the camera around the image. Furthermore, I can pan (not zoom) in and out. (There's also a way to pan left-right or pan up-down, but I didn't do that.) Most importantly, all the lines stay linear. That's what I've got to maintain.

    I do all kinds of processing with these files. For example, here's where I display what's in them (just one vector, changing through time):
    http://motionlabresources.org/Untitled.mp4

    I'd like to enhance that C3D viewer so that it actually shows all the vectors (and defined line-segments between them) as a "movie" (like that Untitled2.mp4 video).

    Also, just FYI, I'm doing all of this for free (no pay to me and open-source) ... just in between times I'm not working on "real" work, and answering other VBForums questions.


    However, getting started, I've got an even bigger question. As stated, I've got a bit of experience with DX8. I'm wondering if I should stick with that, or if I should learn DX9 (with your TypeLib). Attached is a little (partial) DX8 project I cobbled together a couple of years ago. One thing I remember is that it takes quite a bit of effort just to get the DirectX system up and running. That's the entire D3DInit.BAS module in that attached project. I just don't know how much of that is transferable to DX9 and your TypeLib.

    Any guidance you feel so inclined to provide would be graciously appreciated. Also, again, thanks for your post #2. Once I get "up and running", I will study it in detail, and I'm sure I'll get the panning issues sorted with minimal additional guidance. But just getting a basic project going is my first task.

    All The Best,
    Elroy
    Attached Files Attached Files
    Last edited by Elroy; Mar 12th, 2018 at 11:42 AM.
    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.

  4. #4
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,229

    Re: DirectX9, getting started

    Quote Originally Posted by Elroy View Post
    You talked about "parallels lines always stay parallel". However, that's not quite it. If we have a cube, and we're looking head-on at it, the sides will start out parallel (on the 2D screen). However, if we pan down, the sides will no longer be parallel (at least, not on the screen). There's no way to avoid that.
    it's called orthographic projection. That's why Trick mentioned it

    https://www.slideshare.net/SanuPhili...puter-graphics
    https://en.wikipedia.org/wiki/Orthographic_projection

  5. #5
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,797

    Re: DirectX9, getting started

    That's not what I'm trying to do. In fact, I want my zoom to stay at 100%.
    Okay, i understand. You just don't change both parameters at the same time.

    However, if we pan down, the sides will no longer be parallel (at least, not on the screen). There's no way to avoid that.
    Look at the first my screenshot.

    I want all my line-segments to always stay linear (i.e., 100% zoom).
    Okay, in Direct3D you don't have that distortions like fish-eye at all.

    I've made a little video of what I'd like to do.
    Okay, i understand. It's very simple way.

    As you can see, I can easily rotate the camera around the image. Furthermore, I can pan (not zoom) in and out.
    As far as i see in video you just move the camera, no zoom (like in photo-camera) at all.
    Difference between moving and zooming:


    I should stick with that, or if I should learn DX9 (with your TypeLib)
    DirectX12 The newest versions are better but they don't work on old machines. You should make the choice. DX9 works since XP.

    One thing I remember is that it takes quite a bit of effort just to get the DirectX system up and running.
    It's depending on features. Commonly you should create device and as least 1 vertex buffer (look at the triangle demo). Optionally you can setup lights, cameras, matrices, materials, textures, etc.

    Any guidance you feel so inclined to provide would be graciously appreciated. Also, again, thanks for your post #2. Once I get "up and running", I will study it in detail, and I'm sure I'll get the panning issues sorted with minimal additional guidance. But just getting a basic project going is my first task.
    Okay, i'll make simple project little bit later, just i don't have enough time right now.

  6. #6

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: DirectX9, getting started

    Ahhh, thank you Dex. I now see. Like a set of plans (or graph paper). And no, that's not what I'm after.

    I think most first-person games are doing what I'm after, all pan, no zoom, with the camera able to take any position and/or rotation you choose. Now, as that http://motionlabresources.org/Untitled2.mp4 video shows, I'll be rotating the camera as if it's on a ring around the room. However, once I get basic pan (translate) and rotate figured out, that'll be easy. I'll just translate the camera to the center of the room, rotate it, and then translate it back out in the same direction (using the camera (not room) as the coordinate basis to translate back out) (i.e., quaternion rotation with multiplication order swapped).

    Once I get boot-strapped on the DX initializations, I think I'll be off and running. Eventually, I'll have to figure out the frame-rate stuff, but that's down the road. I'll be happy right now if I can just draw some lines and spheres in a 3D space, and then pan (translate) and rotate the viewing perspective.

    All The Best,
    Elroy
    Last edited by Elroy; Mar 12th, 2018 at 01:27 PM.
    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.

  7. #7

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: DirectX9, getting started

    @The Trick: OMG, yes, exactly.

    A project with one line-segment and one sphere, in 3D space, with a simple pan (translate camera) and rotate camera would be crazy wonderful.

    And, with whatever is needed to initialize the Direct3D objects.

    Maybe in DX9 with your TypeLib. But I'd never be using a machine any older than Windows 7. So I'll let you decide on the DX version. However, I do want to stay "portable" though (no installation required), but I don't think that's a problem.

    I'm excited.

    Elroy
    Last edited by Elroy; Mar 12th, 2018 at 01:55 PM.
    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

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