Results 1 to 6 of 6

Thread: [Resolved] x-file looks strange

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    27

    [Resolved] x-file looks strange

    Hi ,

    I want to create a function to load x-files. But my tests brought up strange-looking meshes with stranger behavior

    I used the tiger from the dx-sdk as x-file

    This is the function in Detail:

    Loading the mesh

    Code:
        '// load mesh
        '///////////////////////////////
        
        Set m_meshobj = g_d3dx.LoadMeshFromX(App.Path + "\tiger.x", D3DXMESH_MANAGED, _
                                       g_dev, m_AdjBuffer, MtrlBuffer, g_NumMaterials)
    Set the FVF
    Code:
           Set temp_meshobj = m_meshobj.CloneMeshFVF(D3DXMESH_MANAGED, D3DFVF_VERTEX, g_dev)

    Load a texture from ressource
    Code:
          tex = LoadResData(101, "CUSTOM")
          byte_length = UBound(tex)
          Set current_texture = LoadTextureFromFileFromMemory(tex, D3DFMT_UNKNOWN)
          Set g_Texture_checker = current_texture

    Set Material and Texture for each subset
    (I use just a default texture for all subsets till the mesh is properly displayed)

    get_material and texture fills current_texture (_material) with the ones assigned to the number. set_material (_texture) puts them into an array, checking if they already exist.

    Code:
        '// 4 each material
        '///////////////////////////////
        For i = 0 To (g_NumMaterials - 1)
            g_d3dx.BufferGetMaterial MtrlBuffer, i, current_material
            
           '// set material
           '///////////////////////////////
            get_material (1)
            set_material (1)
         
           '// set texture
           '///////////////////////////////
            texture_number = 1
            get_texture (texture_number)
            set_texture (texture_number)
        Next i
    At first I saw nothing but after doing some scaling the model appeared

    So here for the scaling
    Code:
        Set vb = temp_meshobj.GetVertexBuffer()                           '//VertexBuffer
    
        size = g_d3dx.GetFVFVertexSize(temp_meshobj.GetFVF())
    
        count_2 = temp_meshobj.GetNumVertices()
        ReDim verts(count_2)
    
        D3DVertexBuffer8GetData vb, 0, size * count_2, 0, verts(0)
    
    
        For i = 0 To UBound(verts)
            verts(i).x = verts(i).x / 1.09
            verts(i).y = verts(i).y / 1.09
            verts(i).z = verts(i).z / 1.09
        Next i
    '    rot_um_x 2 '// rotating 4 testing
    
    
        D3DVertexBuffer8SetData vb, 0, size * count_2, 0, verts(0)
    After that I do the optimize, this function works properly with my boxes created by the create_box-call

    The quadframe.AddD3DXMesh is a function from a M$-Common-files class, some might remember it. This function is also working properly by my create_box-meshes.


    Code:
        Optimize (texture_number)
        Set m_meshobj = temp_meshobj
    
        temp_meshobj.GetAttributeTable ByVal 0, AttributeNumber
        quadframe.AddD3DXMesh(m_meshobj, AttributeNumber).SetMaterial_and_texture AttributeNumber
        
        Set m_meshobj = Nothing
        Set temp_meshobj = Nothing

    Here are 2 pics of the rendered tiger.x

    The first pic shows the loaded model, the second the tiger rotated with 2°


    The model is loaded, right vertex-format, material and texture set, so why t.. h... is this mesh not shown properly? The only clue I have is that the buffer has false values, but it looks properly set up.

    Thank you for viewing, hope someone can solve this mystery.
    Attached Images Attached Images   
    Last edited by Mr Mint; May 23rd, 2007 at 02:45 AM.

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

    Re: x-file looks strange

    Woooooh There!

    Please post your code with the project, pasting a vast amount of code is really hard to read. Plus you miss out what your functions do, like get_texture and set_texture.
    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    27

    Re: x-file looks strange

    Hi sing,
    yes I know, thats why I gave some explanation before the code to explain what the functions are for.

    Hmm, don´t get it what you mean with "post your code with the project".

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    27

    Re: [Resolved] x-file looks strange

    Ehmm,

    Changing type long to single for my xyz-coordinates solved the problem in my test-app. Don´t know why because my real app has single as it should be.

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

    Re: [Resolved] x-file looks strange

    What I meant was that it is difficult to read a huge post, I would be handy if you posted your code
    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

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    27

    Re: [Resolved] x-file looks strange

    Ah, ok,
    I thought it was more readable in that way as in most forums people get angry when there is just one side of code without explenation of the functions and/or the intention of the programmer.

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