Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / ViewScene Texture Mapping Issue
  RSS 2.0 ATOM  
2 pages: 1.2 last

ViewScene Texture Mapping Issue
Rate this thread
 
39682
 
Permlink of this thread  
avatar
  • m210
  • Posted: 11 February 2010 10:06 AM
  • Total Posts: 18
  • Joined: 01 July 2008 01:47 PM

I replaced the TGA Loader with a TIFF library and tried to load a FBX file. Everything appears to work fine, except for the texture mapping.  The attached images show the problem.

I have only changed the texture loader and some settings to do with packing alignments and format.  Otherwise, the images are rendered as if it were TGA.

Any ideas on how this can be corrected?
Is it a bug in the ViewScene code or SDK?

These files were exported from 3ds Max 2010 with the FBX 2010.2.1 plugin and the ViewScene code is from the FBX 2010.2 SDK.



Attachment Attachment
Attachment Attachment
Attachment Attachment
Attachment Attachment
Replies: 0
avatar
  • m210
  • Posted: 13 February 2010 07:11 AM

Well, here is the offending section of code.  As you can see, I have only made a change to one line to accommodate the TIFF format, “glTexImage2D” has been switched to GL_RGBA:

void GlDrawMesh(KFbxXMatrixpGlobalPositionKFbxMeshpMeshKFbxVector4pVertexArrayint pDrawMode)
{
    int                            lDrawMode    
(pDrawMode == DRAW_MODE_TEXTURED && pMesh->GetTextureUVCount() == && pMesh->GetLayer(0)) DRAW_MODE_WIREFRAME pDrawMode;

    
KFbxLayerElementArrayTemplate<KFbxVector2>* lUVArray NULL;    
    
pMesh->GetTextureUV(&lUVArrayKFbxLayerElement::eDIFFUSE_TEXTURES) 

    KFbxLayerElement
::EMappingMode lMappingMode KFbxLayerElement::eNONE;
    
VSTexture*                     lTexture     NULL;

    
if(pMesh->GetLayer(0) && pMesh->GetLayer(0)->GetUVs())
        lMappingMode 
pMesh->GetLayer(0)->GetUVs()->GetMappingMode()


    
// Find the texture data
    
if (lDrawMode == DRAW_MODE_TEXTURED)
    {
        KFbxTexture
lCurrentTexture           NULL;
        
KFbxLayerElementTexturelTextureLayer NULL;
        
KFbxSurfaceMateriallSurfaceMaterialKFbxCast <KFbxSurfaceMaterial>(pMesh->GetNode()->GetSrcObject(KFbxSurfaceMaterial::ClassId0))

        if(lSurfaceMaterial)
        {
            KFbxProperty lProperty
;
            
lProperty lSurfaceMaterial->FindProperty(KFbxSurfaceMaterial::sDiffuse)
            if(lProperty
.IsValid())
            {   
                lCurrentTexture 
KFbxCast <KFbxTexture>(lProperty.GetSrcObject(KFbxTexture::ClassId0)) 

                int i
lCount gTextureArray.GetCount()
                
for (i=0i<lCounti++)
                
{
                    
if (gTextureArray[i]->mRefTexture == lCurrentTexture)
                    {
                        lTexture 
gTextureArray[i];
                        break;
                    
}
                }
            }
        }
    }

    lDrawMode 
(lDrawMode == DRAW_MODE_TEXTURED && lTexture) lDrawMode DRAW_MODE_WIREFRAME;

    
int lGLPrimitive lDrawMode == DRAW_MODE_WIREFRAME GL_LINE_LOOP GL_POLYGON;

    
glColor3f(0.50.50.5)
    glLineWidth(1.0)

    glPushMatrix()
    glMultMatrixd((double
*) pGlobalPosition)

    int lPolygonIndex
;
    
int lPolygonCount pMesh->GetPolygonCount()

    
if (lDrawMode == DRAW_MODE_TEXTURED)
    {
        glEnable(GL_TEXTURE_2D)
        glTexParameteri(GL_TEXTURE_2D
,GL_TEXTURE_MAG_FILTERGL_NEAREST)
        glTexParameteri(GL_TEXTURE_2D
,GL_TEXTURE_MIN_FILTER,GL_NEAREST)
        glTexParameteri( GL_TEXTURE_2D
,GL_TEXTURE_WRAP_S,GL_CLAMP )
        glTexParameteri( GL_TEXTURE_2D
,GL_TEXTURE_WRAP_T,GL_CLAMP )
        glTexEnvi( GL_TEXTURE_ENV
,GL_TEXTURE_ENV_MODEGL_REPLACE)

        glTexImage2D(GL_TEXTURE_2D
0,  4lTexture->mWlTexture->mH0,  GL_RGBA,  GL_UNSIGNED_BYTE,  lTexture->mImageData)
    }

    
for (lPolygonIndex 0lPolygonIndex lPolygonCountlPolygonIndex++)
    {
        int lVerticeIndex
;
        
int lVerticeCount pMesh->GetPolygonSize(lPolygonIndex)

        glBegin(lGLPrimitive)

        
for (lVerticeIndex 0lVerticeIndex lVerticeCountlVerticeIndex++)
        {
            
if (lDrawMode == DRAW_MODE_TEXTURED)
            {
                int lCurrentUVIndex
;

                if 
(lMappingMode == KFbxLayerElement::eBY_POLYGON_VERTEX)
                {
                    lCurrentUVIndex 
pMesh->GetTextureUVIndex(lPolygonIndexlVerticeIndex)
                }
                
else // KFbxLayerElement::eBY_CONTROL_POINT
                
{
                    lCurrentUVIndex 
pMesh->GetPolygonVertex(lPolygonIndexlVerticeIndex)
                }
                if(lUVArray)
                    glTexCoord2dv(lUVArray
->GetAt(lCurrentUVIndex).mData)
            }

            glVertex3dv((GLdouble 
*)pVertexArray[pMesh->GetPolygonVertex(lPolygonIndexlVerticeIndex)])
        }

        glEnd()
    }

    
if (lDrawMode == DRAW_MODE_TEXTURED)
    {
        glDisable(GL_TEXTURE_2D)
    }

    glPopMatrix()
}

Anyone see why the texture mapping is not working?



Replies: 0
avatar
  • m210
  • Posted: 13 February 2010 08:10 AM

Just to eliminate any changes I have made, I exported a Targa version of the model.  As you can see, the same texture mapping issue occurs.  So, the error is either in ViewScene’s texture mapping code, or the current SDK is outputting the wrong coordinates.



Attachment Attachment
Replies: 0
avatar

Hi, m210,
Could you attached the original 3DS Max file, with textures, and the exported FBX file here for us to do more test?
Thanks.



Jiayang Xu
Maya Data Platform
Autodesk

Replies: 0
avatar
  • m210
  • Posted: 21 February 2010 07:14 PM

I have attached the Alison TGA model (obj and fbx).  This is just a direct export from Poser as an obj file.  Import as obj file into Max then export as FBX.  If you then view it in viewscene, you should see what I get.

This file is hosted externally due to limitations on attachment size:

Alison TGA Model



Replies: 0
avatar

Hi, there
I checked your fbx file out, import it to Maya and Max, it works perfectly in both.
The ViewScene example is still using some old OpenGL stuff and has limitation on texture mapping.
In your file case, some meshs have multiple materials connected to them, ViewScene did not handle this, it only handle the first material it found.
So to validate your FBX file with textures, I suggest Maya or Max.



Jiayang Xu
Maya Data Platform
Autodesk

Replies: 0
avatar
  • m210
  • Posted: 24 February 2010 11:58 PM

I think you have this a little mixed up.  I’m already aware that I can view this model in either Max or Maya.  I’m looking for a reference example of how to use the SDK with OpenGL.  If AutoDesk doesn’t provide reference examples, then the FBX SDK becomes pretty useless. 

Being a closed format, not many are willing to invest time and money into developing FBX based apps as the SDK could be stopped, substantially changed or broken.  If leveraged as the primary format to exchange 3D data, that could leave many products at the whim of AutoDesk.  Add to that, the lack of proper code examples, it becomes too expensive to have someone hack their way through the SDK, as there is little ROI when compared with other established formats.

We already see this, in that, very few 3D products support FBX at all.

From a customer’s viewpoint, the FBX SDK has progressed little in the last 4 years and is as unusable as it ever was.  It is poorly documented, lacks proper examples, hinders rapid development and the support is non-existant.

For now, I am forced to drop FBX support as there is no example code to work from.  Thanks for your help and I hope you can fix this in the future.



Replies: 0
avatar

I do agree these FBX’s documentation and reference example need to be improved and I am glad this task is already on our schedule.

But I think there is one thing you need to understand, you should never expect to find an example, copy its code and then it fit your requirement perfectly.
Examples are just a begining for you to learn, in this special case, ViewScene already shows the basic/necessary workflow, what you may do is customize or improve it to reach your target.
If you got any questions during this process, for example, in this case, to handle the multiple materials, you can ask on this forum, and I am pretty sure that many people here would like to help you out.

Thank you a lot for your feedback.



Jiayang Xu
Maya Data Platform
Autodesk

Replies: 0
avatar
  • Eric Feng
  • Posted: 25 February 2010 07:04 PM

Hello there,

Thank you for giving this feedback to us. Many of your suggestions are right to the point.
As one of the fbx developers, I am well aware of these issues since you are not the first one who mentioned to us. Good news is that we already have made a plan to change this stituation and hopefully this will make the new users easier to adapt to our sdk. Although this wont happen in time for the up-coming release, for the next relase, there will be a lot improvement.

Thank you,
Eric

m210 25 February 2010 07:58 AM

I think you have this a little mixed up.  I’m already aware that I can view this model in either Max or Maya.  I’m looking for a reference example of how to use the SDK with OpenGL.  If AutoDesk doesn’t provide reference examples, then the FBX SDK becomes pretty useless. 

Being a closed format, not many are willing to invest time and money into developing FBX based apps as the SDK could be stopped, substantially changed or broken.  If leveraged as the primary format to exchange 3D data, that could leave many products at the whim of AutoDesk.  Add to that, the lack of proper code examples, it becomes too expensive to have someone hack their way through the SDK, as there is little ROI when compared with other established formats.

We already see this, in that, very few 3D products support FBX at all.

From a customer’s viewpoint, the FBX SDK has progressed little in the last 4 years and is as unusable as it ever was.  It is poorly documented, lacks proper examples, hinders rapid development and the support is non-existant.

For now, I am forced to drop FBX support as there is no example code to work from.  Thanks for your help and I hope you can fix this in the future.



Eric Feng, Framestore

Replies: 0
avatar
  • m210
  • Posted: 27 February 2010 03:46 AM

I do agree these FBX’s documentation and reference example need to be improved and I am glad this task is already on our schedule.

But I think there is one thing you need to understand, you should never expect to find an example, copy its code and then it fit your requirement perfectly.
Examples are just a begining for you to learn, in this special case, ViewScene already shows the basic/necessary workflow, what you may do is customize or improve it to reach your target.
If you got any questions during this process, for example, in this case, to handle the multiple materials, you can ask on this forum, and I am pretty sure that many people here would like to help you out.

I understand the concept of an example. :)

Seriously though, Autodesk needs to begin thinking from its client’s perspective.  Why would anyone start a long process of hacking this SDK, when they can obtain free libraries for other formats and be up and running in minutes?

With so many risks involved in adopting the format, a shortened learning curve and drop in code would sweeten the offer.  Waiting several days for an answer to a question, on this forum, would result in years of development time.

Perform a search for an OpenGL FBX viewer and I think you will find just the one.  This is the direct result of ViewScene not being fully complete.  No one really knows how to use your SDK with OpenGL and the ROI has to be justified for someone to sit down and figure it all out.  Why make your customers do that?  As a software development company, Autodesk needs to think of itself as a solutions provider, or a solver of problems, end-to-end.

Why force your customers to reinvent the wheel?  Classes for saving, loading and rendering (OpenGL and DirectX) should be pretty standard, fully featured and complete.  That would be a big win and rapidly expand the usage of FBX.  Think of ViewScene as a WYSIWYG external viewer and you will be on the right track. 

Thank you for giving this feedback to us. Many of your suggestions are right to the point.
As one of the fbx developers, I am well aware of these issues since you are not the first one who mentioned to us. Good news is that we already have made a plan to change this stituation and hopefully this will make the new users easier to adapt to our sdk. Although this wont happen in time for the up-coming release, for the next relase, there will be a lot improvement.

Eric good to hear that you have this in hand.  One thing I will suggest is that the example code should be fully featured and complete.  You need to assume that the customer knows nothing and doesn’t really want to know anything beyond that.  So, as much drop-in code as possible for a wide range of scenarios would be the ideal.  That’s the point of a good SDK.



Replies: 0
avatar
  • Eric Feng
  • Posted: 28 February 2010 03:52 PM

Eric good to hear that you have this in hand.  One thing I will suggest is that the example code should be fully featured and complete.  You need to assume that the customer knows nothing and doesn’t really want to know anything beyond that.  So, as much drop-in code as possible for a wide range of scenarios would be the ideal.  That’s the point of a good SDK.

That is exactly what we are thinking and planning to do! Thanks for your input. Actually, we also plan to divide the examples to different categories and fill them with small topics which will eventually cover all the features of fbx sdk(may not be finished adding in one release but we try to make it ASAP). Again, fbx is getting better gradually for your helpful suggestions.



Eric Feng, Framestore

Replies: 2
/userdata/avatar/7726n2x34_VRVuzix.JPG

Eric,
1: Can we get the rendering engine that is designed into “AutoDesk 3Dstudio Max” and drop it into the ViewScene or a DirectX version of the same, visual Workspace… This would seem to be the logical “WYSIWYG” solution as mentioned above.

2: If not, can you tell us when and/or if the following details will be completed/offered in your next release?
a. Full animations…
b. Full transparencies…
c. Full Shadow generation…
d. Full multi-materials-texturing, ALL 3DStudio Max content supported…(bmp,jpg,tga,gif,etc...)
e. Full Support for Shader models…
f.  Fully completed DirectX workspace reeady for integration with ‘the developers’ application process.

Author: Vuzix

Replied: 09 April 2010 08:22 AM  
/userdata/avatar/7726n2x34_VRVuzix.JPG

Question #1 above is the crooks of the problem and is truely the best fit solution…
Any and ALL content rendered in 3DStudio Max would render as “WYSIWYG” in the developers application interface straight out of the box and all would be stellar for ALL…

This is the NO COST solution…

AutoDesk can you get us this solution?

Author: Vuzix

Replied: 09 April 2010 08:56 AM  
2 pages: 1.2 last