Results 1 to 7 of 7

Thread: Direct3D...

  1. #1

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417

    Direct3D...

    Hello

    Today's topic is, as you might have guessed Direct3D
    However, it concerns a certain topic within the allmighty Direct3D which is actually very bothering.

    As you might guess, I'm awfully new to Direct3D or anything that has to do with Graphic programming. However, I'm learning. But on my way, I tumbled over a serious problem that I don't know how to fix. That is because I don't know what's wrong...

    I've created a nice triangle. Looks pretty. But I want to change the view. How to? YES, a Matrix. So, I've set up the matrix, 3 matrices actually, but it just won't work! So anyone, please help me...

    Yes, I know, the coding's a bit hard, and no wonder. I like to program in my own language, but if you're good at this, you should be able to keep up with the Norwegian variables. But you can rename them if you like. Think of it as a challenge.

    In advance, thank you very much
    -Lars Espen Rosness
    Attached Files Attached Files

  2. #2
    Zaei
    Guest
    This is the same mistake that I made when i first started with this stuff. Ill list all of the change you need to make. I Left them in your own language, so you can just copy and paste:
    Code:
    Remove the "RHW as Single" line in your vertex.
    
    Change "D3DFVF_XYZRHW" to "D3DFVF_XYZ" in your FVF 
    definition
    
    Change this...
    With ObjektSpes
        .Windowed = 1
        .SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
        .BackBufferFormat = VisningsMetode.Format
    End With
    ...to This...
    With ObjektSpes
        .Windowed = 1
        .SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
        .BackBufferFormat = VisningsMetode.Format
        .AutoDepthStencilFormat = D3DFMT_D16
        .EnableAutoDepthStencil = 1
    End With
    
    Add this line after You set Lighting to 0:
    Maskineri.SetRenderState D3DRS_ZENABLE, 1
    
    Change the lines where you create your vertices to this...
    PuNkTeNe(0) = SnekrePunkt(-1, 0, 0, 1, R)
    PuNkTeNe(1) = SnekrePunkt(1, 0, 0, 1, G)
    PuNkTeNe(2) = SnekrePunkt(0, 2, 0, 1, B)
    
    In the SnekrePunkt Function, remove the line that assigns a value to RHW (dont change the paramters though)
    
    Change your call to "Clear" to "Maskineri.Clear 0, ByVal 0, D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, &H0, 1#, 0"
    Quite a bit, huh? Hope this helps you out.

    Z.

  3. #3

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417

    Question Thx BUT...

    Hello

    Thank you very much Zaei. What you did made my program work. However, I'm not actually sure of what I did all the time. You wouldnt be so kind to tell me WHY I did all that.

    -=[I'm not worth]=-
    ----------
    Lars Espen Rosness

  4. #4
    Zaei
    Guest
    Sure =).

    In the same order i posted the changes:
    Code:
    1 and 2:  Defining a vertex with RHW means that you dont want D3D to perform any transformation calculations on your vertices.  Basically, you tell D3D that you want this point to be at x,y position on the screen.  It is not in 3D at all.
    
    3: This just turns on the ZBuffer, which lets D3D know that Vertex A is in front of Vertex B (as an example).  This stops polygons that should be behind another from being drawn.
    
    4: Turns on the world Z axis.  
    
    5: Changes how you define your vertices.  Before, you were defining points on the screen.  Now you are in World space.  Units are in meters, for reference.
    
    6: If there isnt an RHW value in your vertex structure, you cant assign anything to it  =).  I told you not to remove the parameter because if you had, you would have to go and change all of the calls to the function.  Saves time  =).
    
    7: When you clean the backbuffer, you also have to clear the ZBuffer.
    Make sense?

    Z.

  5. #5

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417

    Oh yes

    Yes. That cleared up a whole lot. Thank you very much!
    However, beware. Later on, I will probably...no.. absolutely, ask
    other simple questions like these. Why? Well, because i've read
    a couple of tutorials in my life. Not only in D3D, but others as well, like 3D Studio MAX, other VB etc. etc. These tutorials show how to do a lot of things. What they don't say is WHY.
    A great tutorial should be able to explain a lot about WHY you do the things listed, and what the outcome would be if you don't or even different ways to do it. It would of course be a pretty long
    and complex tutorial, but I think it's the only way to learn easy things fast. Cause there's a lot of tutorials out there that aren't any good. You agree?

    However, thanks a lot! That was really nice of you.
    -=[Still not Worthy, but just wait...]=-
    -Lars Espen Rosness

  6. #6
    Zaei
    Guest
    I agree whole-heartedly. I will rarely post any code at all when helping people, unles it is the only way to describe something, because then they dont understand why. If tutorials explained the why, everyone would understand much better. If you ever need any more help, post here, or email me ([email protected]), and Ill help you out.

    Z.

  7. #7
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    All my tuts tell the WHY.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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