void main(void *arg) { if(1)//ISUVDEFINED(uvCoord().x, uvCoord().y) { if (fileTextureName() != eiNULL_TAG) { eiTag tex = fileTextureName(); scalar filterWidth = filterType()>0.0f ? filter() : 0.0f; // we ingore single-channel case //if( num_channels() == 1 ) //{ // /* We must read single-channel files as float or only the red // channel will be filled. */ // scalar r = scalar_texture(tex, 0, uvCoord().x, uvCoord().y) // outColor() = color(r, 0.0f, 0.0f); //} //else { outColor() = color_texture(tex, 0, uvCoord().x, uvCoord().y); } if( fileHasAlpha() ) { outAlpha() = scalar_texture(tex, 3, uvCoord().x, uvCoord().y); }else{ outAlpha() = luminance( outColor() ); } } } else { outColor() = defaultColor(); outAlpha() = luminance( outColor() ); } outTransparency() = color(1.0f-outAlpha(),1.0f-outAlpha(),1.0f-outAlpha()); }
bool CXsiObjConverter::DotXSILoadMesh(CSLModel* pModel, CObjFile::CGroup& objGroup) { OBJ_ASSERT(pModel); if(!pModel) return false; CSLTransform* pTransform = pModel->Transform(); // Get the transform of thie model OBJ_ASSERT(pTransform); if(!pTransform) return false; CSLMesh* pMesh = (CSLMesh*)pModel->Primitive(); // Get the mesh of this model OBJ_ASSERT(pMesh); if(!pMesh) return false; CSLBaseShape* pShape = pMesh->Shape(); // get the Shape of this model OBJ_ASSERT(pShape); if(!pShape) return false; // Vertex Positions { CSLBaseShape::CSLVector3DArray* pVertices = pShape->GetVertexList(); Vector3DVector& objVertices = m_pObjFile->GetVertexPositionVector(); CSIBCVector3D* pVector3D = NULL; Vector3D vertPos(3); objVertices.reserve(pVertices->GetSize()); for(long vertexIt = 0; vertexIt < pVertices->GetSize(); ++vertexIt) // for each OBJ vertex position { pVector3D = &(*pVertices)[vertexIt]; vertPos = CXsiFtkGeometryUtil::TransformAndConvertVector(pTransform, pVector3D); // Transform vertex position objVertices.push_back(vertPos); // add a vertex position } } // UV coordinates { long uvCoordArrayCount = ((CSLShape_35*)pShape)->GetUVCoordArrayCount(); if( uvCoordArrayCount > 0 ) { Vector3DVector& objTexCoords = m_pObjFile->GetTextureCoordVector(); CSLUVCoordArray** pUvCoordsArrays = ((CSLShape_35*)pShape)->UVCoordArrays(); for(long uvArrayIndex = 0; uvArrayIndex < uvCoordArrayCount; ++uvArrayIndex) // for each uv array { CSLUVCoordArray* pUvCoordArray = pUvCoordsArrays[uvArrayIndex]; long uvCoordCount = pUvCoordArray->GetUVCoordCount(); if(uvCoordCount > 0) { CSLBaseShape::CSLVector2DArray* pVector2DArray = pUvCoordArray->GetUVCoordList(); CSIBCVector2D* pVector2D = NULL; Vector3D uvCoord(3); objTexCoords.reserve(pVector2DArray->GetSize()); for(long uvCoordIndex = 0; uvCoordIndex < uvCoordCount; ++uvCoordIndex) // for each OBJ texCoord { pVector2D = &(*pVector2DArray)[uvCoordIndex]; uvCoord[0] = pVector2D->GetX(); uvCoord[1] = pVector2D->GetY(); uvCoord[2] = 0.0f; // no W in dotXSI objTexCoords.push_back(uvCoord); // add a UV coordinate } } } } } // Normals { long normalCount = pShape->GetNormalCount(); if(normalCount > 0) { CSLBaseShape::CSLVector3DArray* pNormals = pShape->GetNormalList(); Vector3DVector& objNormals = m_pObjFile->GetNormalVector(); CSIBCVector3D* pVector3D = NULL; Vector3D normal(3); objNormals.reserve(pNormals->GetSize()); for(long normalIt = 0; normalIt < pNormals->GetSize(); ++normalIt) // for each OBJ normals { pVector3D = &(*pNormals)[normalIt]; normal[0] = pVector3D->GetX(); normal[1] = pVector3D->GetY(); normal[2] = pVector3D->GetZ(); objNormals.push_back(normal); // add a normal } } } bool bPolygonList = false; bool bTriangleList = false; bool bTriangleStripList = false; if(pMesh->GetPolygonListCount() > 0) { bPolygonList = true; DotXSILoadPolygonList(pMesh, objGroup); } else if(pMesh->GetTriangleListCount() > 0) { bTriangleList = true; DotXSILoadTriangleList(pMesh, objGroup); } else if(pMesh->GetTriangleStripListCount() > 0) { bTriangleStripList = true; DotXSILoadTriStripList(pMesh, objGroup); } return true; }