Results 1 to 6 of 6

Thread: [Resolved] x-file looks strange

Threaded View

  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.

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