- Viewing Profile: Posts: f1af
14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!
Community Stats
- Group Members
- Active Posts 3
- Profile Views 378
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
100
Neutral
User Tools
Contacts
f1af hasn't added any contacts yet.
Latest Visitors
Posts I've Made
In Topic: lib3ds and texture mapping?
16 April 2012 - 05:38 AM
e, e. whell come to hell.. %))
In Topic: lib3ds and texture mapping?
16 April 2012 - 05:32 AM
it uogly, in the future I fix it function. but if call this function after load 3ds, tex coord will by fixed.
AI - its Array Indexes.
If u intresting, if u need, I can give my code of load 3ds. Its class, inherit from some python-3ds-module-source-code, not lib3ds. In the future I wont use lib3ds. But now.. my uogly, but working code:
void WorkBase::vertexNoDifTexCoordExtract( SPtr<BaseMesh> baseMesh ) const
{
SPtr<BaseSide> sptrSide;
SPtr<BaseAI> sptrBaseAI;
uint indexCount, indexOfVertex, pointCount = baseMesh->point()->count() / 8;
char doneIndex[pointCount];
memset( doneIndex, 0, pointCount*sizeof( char ) );
for ( uint i = 0; baseMesh->side()->next( &i, &sptrSide ); )
{
for ( uint j = 0; sptrSide->arrayIndex()->next( &j, &sptrBaseAI ); )
{
indexCount = sptrBaseAI->index()->count();
if (indexCount>64000) continue;
for ( uint n = 0; n < indexCount; n++ )
{
indexOfVertex = *sptrBaseAI->index()->atRo( n );
if ( !doneIndex[indexOfVertex] ) doneIndex[indexOfVertex] = 1;
else
{
for ( uint m = 0; m < 8; m++ )
{
if (( indexOfVertex*8 + m ) < baseMesh->point()->count() ) // TODO kastil', need normal fix
{
float varFloat = *baseMesh->point()->atRo( indexOfVertex * 8 + m );
baseMesh->point()->appendVar( varFloat );
}
}
*sptrBaseAI->index()->atRw( n ) = baseMesh->point()->count() / 8 - 1;
}
}
}
}
}
AI - its Array Indexes.
If u intresting, if u need, I can give my code of load 3ds. Its class, inherit from some python-3ds-module-source-code, not lib3ds. In the future I wont use lib3ds. But now.. my uogly, but working code:
#include "drawlib/scene/loader_3ds.h"
#include "drawlib/scene/scene_manager.h"
namespace drawlib
{
Loader3DS::Loader3DS( SceneManager *sceneManager )
{
m_sceneManager = sceneManager;
m_forStreamSteckStart = 0;
m_forStreamSteckEnd = 0;
m_wasError = false;
setIsSimple( false );
reset();
}
Loader3DS::~Loader3DS()
{
}
void Loader3DS:<img src='http://public.gamedev.net//public/style_emoticons/<#EMO_DIR#>/tongue.png' class='bbc_emoticon' alt=':P' />_updatePersent()
{
int persent = 1 + (( 100 * m_currentFileDevice->at() ) / m_currentFileDevice->size() );
if ( m_sceneManager->jobManager()->isThreadOn() )
setProgress( persent );
}
void Loader3DS::setWasErrorToFalse()
{
m_wasError = false;
}
bool Loader3DS::getWasError() const
{
return m_wasError;
}
void Loader3DS::load( SPtr<BaseMesh> baseMesh, QString fileName, QString *nameObject )
{
if ( nameObject ) *nameObject = "3ds";
m_sceneManager->storer()->mesh()->setHide( baseMesh, true );
m_listForStreamBaseMesh.append( baseMesh );
m_listForStreamFileName.append( fileName );
m_sceneManager->jobManager()->doRun( this );
}
void Loader3DS::reset()
{
JobThread::reset();
// m_sceneManager=0; - not need
m_baseAI.reset();
m_baseSide.reset();
m_baseMaterial.reset();
m_baseMesh.reset();
m_baseAIMaterial.reset();
m_baseSideMaterial.reset();
m_fileName = QString::null;
m_pathToFile = QString::null;
m_mapMaterial.clear();
m_indexOffset = 0;
m_version = 0;
m_count_mapUV = 0;
if ( m_forStreamSteckStart == m_forStreamSteckEnd )
{
m_forStreamSteckStart = 0;
m_forStreamSteckEnd = 0;
m_listForStreamBaseMesh.clear();
m_listForStreamFileName.clear();
}
}
/**************************************************************
************************ for QThread *************************
*************************************************************/
void Loader3DS::startJob()
{
m_baseMesh = *m_listForStreamBaseMesh.at( m_forStreamSteckStart );
m_fileName = *m_listForStreamFileName.at( m_forStreamSteckStart );
m_forStreamSteckStart++;
setName( "load: \"" + QFileInfo( m_fileName ).fileName() + "\"" );
m_baseMesh->reset();
m_pathToFile = QFileInfo( m_fileName ).dirPath();
// m_baseMesh->point()->setBlokSize( 250000 );
if ( !ProcessFile( m_fileName.latin1() ) ) m_wasError = true;
if ( m_version != 3 ) m_wasError = true;
}
void Loader3DS::endJob()
{
m_baseMesh = *m_listForStreamBaseMesh.at( m_forStreamSteckEnd );
m_forStreamSteckEnd++;
m_sceneManager->workBase()->vertexNoDifTexCoordExtract( m_baseMesh );
m_sceneManager->workBase()->normalize( m_baseMesh );
m_baseMesh->update();
uint textureId = 0;
QValueList<uint> filter;
for ( uint i = 0; m_baseMesh->side()->next( &i, &m_baseSide ); )
{
if ( !m_baseSide->getMaterialId() ) continue;
m_baseMaterial = m_sceneManager->storer()->material()->idToSPtr( m_baseSide->getMaterialId() );
textureId = m_baseMaterial->getTextureId();
if ( !textureId ) continue;
if ( filter.find( textureId ) != filter.end() ) continue;
else filter.append( textureId );
m_sceneManager->storer()->texture()->idToSPtr( textureId )->update();
}
m_sceneManager->storer()->mesh()->setHide( m_baseMesh, false );
reset();
}
/**************************************************************
********************* Check correct 3ds **********************
*************************************************************/
bool Loader3DS::UserVersion( uint version )
{
m_version = version;
if ( m_version != 3 ) return false;
return true;
}
/**************************************************************
*********************** Material list ************************
*************************************************************/
void Loader3DS::UserMatName( const string name )
{
uint id;
BaseMaterial *baseMaterial;
m_sceneManager->storer()->material()->create( baseMaterial, id );
m_baseMaterial.set( baseMaterial );
m_mapMaterial[name] = id;
}
void Loader3DS::UserMatColor( float c0, float c1, float c2, int flag )
{
if ( flag == 1 ) m_baseMaterial->color()->setColor( c0 / 1.4f, c1 / 1.4f, c2 / 1.4f );
else if ( flag == 2 ) m_baseMaterial->color()->setColorAmbient( c0, c1, c2 );
else m_baseMaterial->color()->setColorSpecular( c0, c1, c2 );
}
void Loader3DS::UserMapFile( const string fileName )
{
uint textureId;
BaseTexture *baseTexture;
SPtr<BaseTexture> baseTextureSPtr;
m_sceneManager->storer()->texture()->create( baseTexture, textureId );
baseTextureSPtr.set( baseTexture );
if ( m_sceneManager->loaderImage()->load( baseTextureSPtr,
m_pathToFile + "/" + QString( fileName ).lower() ) )
m_baseMaterial->setTextureId( textureId );
p_updatePersent();
}
/**************************************************************
*************************** Vertex ***************************
*************************************************************/
void Loader3DS::User3dVertCount( unsigned short count )
{
count = 0;
m_indexOffset = m_baseMesh->point()->count() / 8;
m_count_mapUV = 0;
p_updatePersent();
}
void Loader3DS::User3dVert( float x, float y, float z )
{
m_baseMesh->point()->appendVar( 0 );
m_baseMesh->point()->appendVar( 0 );
m_baseMesh->point()->appendVar( 0 );
m_baseMesh->point()->appendVar( 0 );
m_baseMesh->point()->appendVar( 0 );
m_baseMesh->point()->appendVar( x );
m_baseMesh->point()->appendVar( y );
m_baseMesh->point()->appendVar( z );
}
void Loader3DS::UserMapVertex( float u, float v )
{
*m_baseMesh->point()->atRw(( m_indexOffset + m_count_mapUV )*8 + 0 ) = u;
*m_baseMesh->point()->atRw(( m_indexOffset + m_count_mapUV )*8 + 1 ) = v;
m_count_mapUV++;
}
/**************************************************************
*************************** Index ****************************
*************************************************************/
void Loader3DS::User3dFaceCount( unsigned short )
{
m_baseSide = m_baseMesh->side()->createSPtr();
m_baseAI = m_baseSide->arrayIndex()->createSPtr();
m_baseAI->setMode( GL_TRIANGLES );
m_indexForSmoothCount = 0;
p_updatePersent();
}
void Loader3DS::User3dFace( unsigned short a, unsigned short b, unsigned short c, unsigned short )
{
m_baseAI->index()->appendVar( a + m_indexOffset );
m_baseAI->index()->appendVar( b + m_indexOffset );
m_baseAI->index()->appendVar( c + m_indexOffset );
}
void Loader3DS::UserFaceSmoothList( uint Index )
{
m_baseSide->appendSmoothFace( Index, m_indexForSmoothCount );
m_indexForSmoothCount++;
}
/**************************************************************
********************* Material on side ***********************
*************************************************************/
void Loader3DS::UserFaceMaterialName( string name )
{
m_baseSideMaterial = m_baseMesh->side()->createSPtr();;
m_baseAIMaterial = m_baseSideMaterial->arrayIndex()->createSPtr();
m_baseAIMaterial->setMode( GL_TRIANGLES );
m_baseSideMaterial->setMaterialId( m_mapMaterial[name] );
}
void Loader3DS::UserFaceMaterialNumber( int number )
{
uint a = m_baseAI->index()->atRo( number * 3 )[0];
uint b = m_baseAI->index()->atRo( number * 3 )[1];
uint c = m_baseAI->index()->atRo( number * 3 )[2];
m_baseAIMaterial->index()->appendVar( a );
m_baseAIMaterial->index()->appendVar( b );
m_baseAIMaterial->index()->appendVar( c );
m_baseAI->index()->atRw( number*3 )[0] = ( uint ) - 1;
m_baseAI->index()->atRw( number*3 )[1] = ( uint ) - 1;
m_baseAI->index()->atRw( number*3 )[2] = ( uint ) - 1;
}
void Loader3DS::User3dFaceFinish()
{
SPtr<BaseSide> oldBaseSide = m_baseSide;
SPtr<BaseAI> oldBaseAI = m_baseAI;
m_baseSide = m_baseMesh->side()->createSPtr();
m_baseAI = m_baseSide->arrayIndex()->createSPtr();
m_baseAI->setMode( GL_TRIANGLES );
for ( uint i = 0, a = 0; i < oldBaseAI->index()->count(); i++ )
{
a = oldBaseAI->index()->atRo( i )[0];
if ( a != ( uint ) - 1 ) m_baseAI->index()->appendVar( a );
}
m_baseMesh->side()->removeBySPtr( oldBaseSide );
if ( !m_baseAI->index()->count() )
m_baseMesh->side()->removeBySPtr( m_baseSide );
}
}
In Topic: lib3ds and texture mapping?
16 April 2012 - 05:00 AM
number of tex coord not equal numer of face. if tex coord on neighboring face is equal - both face has one texcoord.
for example, if you have default cube-object, you have 24 faces, but 8 vertexes and 8 texcoord.
this two face have 3 tex coord. not 6. 3 on both. somsing like that...
for example, if you have default cube-object, you have 24 faces, but 8 vertexes and 8 texcoord.
1,1 | | 1,1 0,0 0,1 | | 0,1 0,0 -------------- --------------
this two face have 3 tex coord. not 6. 3 on both. somsing like that...
- Home
- » Viewing Profile: Posts: f1af

Find content