|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| ViewScene Texture Mapping Issue
|
|
|
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(KFbxXMatrix& pGlobalPosition, KFbxMesh* pMesh, KFbxVector4* pVertexArray, int pDrawMode)
{
int lDrawMode = (pDrawMode == DRAW_MODE_TEXTURED && pMesh->GetTextureUVCount() == 0 && pMesh->GetLayer(0)) ? DRAW_MODE_WIREFRAME : pDrawMode;
KFbxLayerElementArrayTemplate<KFbxVector2>* lUVArray = NULL;
pMesh->GetTextureUV(&lUVArray, KFbxLayerElement::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;
KFbxLayerElementTexture* lTextureLayer = NULL;
KFbxSurfaceMaterial* lSurfaceMaterial= KFbxCast <KFbxSurfaceMaterial>(pMesh->GetNode()->GetSrcObject(KFbxSurfaceMaterial::ClassId, 0))
if(lSurfaceMaterial)
{
KFbxProperty lProperty;
lProperty = lSurfaceMaterial->FindProperty(KFbxSurfaceMaterial::sDiffuse)
if(lProperty.IsValid())
{
lCurrentTexture = KFbxCast <KFbxTexture>(lProperty.GetSrcObject(KFbxTexture::ClassId, 0))
int i, lCount = gTextureArray.GetCount()
for (i=0; i<lCount; i++)
{
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.5, 0.5, 0.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_FILTER, GL_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_MODE, GL_REPLACE)
glTexImage2D(GL_TEXTURE_2D, 0, 4, lTexture->mW, lTexture->mH, 0, GL_RGBA, GL_UNSIGNED_BYTE, lTexture->mImageData)
}
for (lPolygonIndex = 0; lPolygonIndex < lPolygonCount; lPolygonIndex++)
{
int lVerticeIndex;
int lVerticeCount = pMesh->GetPolygonSize(lPolygonIndex)
glBegin(lGLPrimitive)
for (lVerticeIndex = 0; lVerticeIndex < lVerticeCount; lVerticeIndex++)
{
if (lDrawMode == DRAW_MODE_TEXTURED)
{
int lCurrentUVIndex;
if (lMappingMode == KFbxLayerElement::eBY_POLYGON_VERTEX)
{
lCurrentUVIndex = pMesh->GetTextureUVIndex(lPolygonIndex, lVerticeIndex)
}
else // KFbxLayerElement::eBY_CONTROL_POINT
{
lCurrentUVIndex = pMesh->GetPolygonVertex(lPolygonIndex, lVerticeIndex)
}
if(lUVArray)
glTexCoord2dv(lUVArray->GetAt(lCurrentUVIndex).mData)
}
glVertex3dv((GLdouble *)pVertexArray[pMesh->GetPolygonVertex(lPolygonIndex, lVerticeIndex)])
}
glEnd()
}
if (lDrawMode == DRAW_MODE_TEXTURED)
{
glDisable(GL_TEXTURE_2D)
}
glPopMatrix()
}
Anyone see why the texture mapping is not working?
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
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
|
|
|
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.
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|