D3D .x file texture/material problem

Discussion in 'C' started by pbdrew04, Mar 25, 2007.

  1. pbdrew04

    pbdrew04 New Member

    Joined:
    Mar 25, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I've created several models in 3Dstudio max and exported them using PandaSoft plug-in to .X files. I can load and render the .X files in my app.

    The problem is that the texture and material information is not used. The textures are all skewed and the materials are not present, such as reflectivity. They are correct in 3Dstudio before exporting.

    Any ideas?

    Thanks
    -Andrew
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Using my crystal ball, I would suggest that your app is incorrectly written where the rendering of textures and materials are concerned. I looked very closely, but couldn't quite make out the line numbers of said offending code.
     
  3. pbdrew04

    pbdrew04 New Member

    Joined:
    Mar 25, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    dont be condescending

    this is the render model method:
    models hold the material info, texture number (points to a texture array) and the mesh. Textures and meshes loaded using native D3DXLoadMeshFromX, D3DXCreateTextureFromFile, nothing out of the ordinary.

    Code:
    void cGraphics::RenderModel(int iModelNum, float fPosX, float fPosY, float fPosZ, float fRotX, float fRotY, float fRotZ) {
    	
    	//temp matrices
    	D3DXMATRIX Rotation_Matrix;
    	D3DXMATRIX Translation_Matrix;
    	D3DXMATRIX World_Matrix;
    
    	//rotations
    	D3DXMatrixRotationYawPitchRoll(&Rotation_Matrix, fRotY, fRotX, fRotZ);
    
    	//position
    	D3DXMatrixTranslation(&Translation_Matrix, fPosX, fPosY, fPosZ);
    	
    	//combine rotation and position	
    	World_Matrix = Rotation_Matrix * Translation_Matrix;
    
    	//apply world transforms
    	p_device->SetTransform(D3DTS_WORLD, &World_Matrix);
    
    	//draw model subsets
    	for(int i = 0; i < Model[iModelNum].iTexNum.size(); i++)
    	{
    		p_device->SetMaterial( &Model[iModelNum].Material[i] );
    		p_device->SetTexture(0, Textures[Model[iModelNum].iTexNum[i]]);
    		Model[iModelNum].Mesh->DrawSubset(i);
    	}	
    }
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    They say there are no stupid questions, but there are sure stupid ways to ask them. First you choose to do that, then you choose to instruct me in how I should respond to such a question. Sonny boy, you can't afford my help, now.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice