@ -111,12 +111,12 @@ public class MeshHelper extends AbstractBlenderHelper {
MeshBuilder meshBuilder = new MeshBuilder ( verticesAndNormals , verticesColors , this . areGeneratedTexturesPresent ( materials ) ) ;
MeshBuilder meshBuilder = new MeshBuilder ( verticesAndNormals , verticesColors , this . areGeneratedTexturesPresent ( materials ) ) ;
Pointer pMFace = ( Pointer ) structure . getFieldValue ( "mface" ) ;
if ( this . isBMeshCompatible ( structure ) ) {
if ( pMFace . isNotNull ( ) ) {
this . readTraditionalFaces ( meshBuilder , structure , blenderContext ) ;
} else {
this . readBMesh ( meshBuilder , structure , blenderContext ) ;
this . readBMesh ( meshBuilder , structure , blenderContext ) ;
} else {
this . readTraditionalFaces ( meshBuilder , structure , blenderContext ) ;
}
}
if ( meshBuilder . isEmpty ( ) ) {
if ( meshBuilder . isEmpty ( ) ) {
geometries = new ArrayList < Geometry > ( 0 ) ;
geometries = new ArrayList < Geometry > ( 0 ) ;
blenderContext . addLoadedFeatures ( structure . getOldMemoryAddress ( ) , structure . getName ( ) , structure , geometries ) ;
blenderContext . addLoadedFeatures ( structure . getOldMemoryAddress ( ) , structure . getName ( ) , structure , geometries ) ;
@ -235,6 +235,19 @@ public class MeshHelper extends AbstractBlenderHelper {
return geometries ;
return geometries ;
}
}
/ * *
* Tells if the given mesh structure supports BMesh .
*
* @param meshStructure
* the mesh structure
* @return < b > true < / b > if BMesh is supported and < b > false < / b > otherwise
* /
private boolean isBMeshCompatible ( Structure meshStructure ) {
Pointer pMLoop = ( Pointer ) meshStructure . getFieldValue ( "mloop" ) ;
Pointer pMPoly = ( Pointer ) meshStructure . getFieldValue ( "mpoly" ) ;
return pMLoop ! = null & & pMPoly ! = null ;
}
/ * *
/ * *
* This method reads the mesh from the new BMesh system .
* This method reads the mesh from the new BMesh system .
*
*
@ -316,7 +329,7 @@ public class MeshHelper extends AbstractBlenderHelper {
@SuppressWarnings ( "unchecked" )
@SuppressWarnings ( "unchecked" )
private void readTraditionalFaces ( MeshBuilder meshBuilder , Structure meshStructure , BlenderContext blenderContext ) throws BlenderFileException {
private void readTraditionalFaces ( MeshBuilder meshBuilder , Structure meshStructure , BlenderContext blenderContext ) throws BlenderFileException {
Pointer pMFace = ( Pointer ) meshStructure . getFieldValue ( "mface" ) ;
Pointer pMFace = ( Pointer ) meshStructure . getFieldValue ( "mface" ) ;
List < Structure > mFaces = pMFace . fetchData ( blenderContext . getInputStream ( ) ) ;
List < Structure > mFaces = pMFace . isNotNull ( ) ? pMFace . fetchData ( blenderContext . getInputStream ( ) ) : null ;
if ( mFaces ! = null & & mFaces . size ( ) > 0 ) {
if ( mFaces ! = null & & mFaces . size ( ) > 0 ) {
Pointer pMTFace = ( Pointer ) meshStructure . getFieldValue ( "mtface" ) ;
Pointer pMTFace = ( Pointer ) meshStructure . getFieldValue ( "mtface" ) ;
List < Structure > mtFaces = null ;
List < Structure > mtFaces = null ;
@ -362,6 +375,20 @@ public class MeshHelper extends AbstractBlenderHelper {
meshBuilder . appendFace ( v1 , v3 , v4 , smooth , materialNumber , uvs = = null ? null : uvCoordinatesForFace , true , i ) ;
meshBuilder . appendFace ( v1 , v3 , v4 , smooth , materialNumber , uvs = = null ? null : uvCoordinatesForFace , true , i ) ;
}
}
}
}
} else {
Pointer pMEdge = ( Pointer ) meshStructure . getFieldValue ( "medge" ) ;
List < Structure > mEdges = pMEdge . isNotNull ( ) ? pMEdge . fetchData ( blenderContext . getInputStream ( ) ) : null ;
if ( mEdges ! = null & & mEdges . size ( ) > 0 ) {
for ( int i = 0 ; i < mEdges . size ( ) ; + + i ) {
Structure mEdge = mEdges . get ( i ) ;
boolean smooth = ( ( ( Number ) mEdge . getFieldValue ( "flag" ) ) . byteValue ( ) & 0x01 ) ! = 0x00 ;
int v1 = ( ( Number ) mEdge . getFieldValue ( "v1" ) ) . intValue ( ) ;
int v2 = ( ( Number ) mEdge . getFieldValue ( "v2" ) ) . intValue ( ) ;
meshBuilder . appendEdge ( v1 , v2 , smooth ) ;
}
}
}
}
}
}