Horde3D

Next-Generation Graphics Engine
It is currently 26.11.2024, 05:17

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 08.04.2011, 10:59 
Offline

Joined: 08.03.2011, 18:29
Posts: 17
I'm trying to use this codesniplet here

The generated geometry looks fine at first, but when I apply a material with normalmapping (for example the rock texture from the samples), the quad just becomes a single brown solid. I tried changing the normalData around, but the problem persists. How can I analyze this error further?


Top
 Profile  
Reply with quote  
PostPosted: 08.04.2011, 12:51 
Offline

Joined: 08.06.2010, 14:17
Posts: 63
Looks like the geometry is missing tangent data, maybe that's the problem?


Top
 Profile  
Reply with quote  
PostPosted: 08.04.2011, 20:46 
Offline

Joined: 08.03.2011, 18:29
Posts: 17
Trying to add that does not seem to help. I might be doing it wrong though. Here is a full snippet which should be copy&pasteable into any Horde3D setup (but don't work):
Code:
void StateGame::createSimpleGeometryRes() {
    // Cache the resources
    H3DRes matRes = h3dAddResource(H3DResTypes::Material, "models/stone/stone.material.xml", 0);
    h3dutLoadResourcesFromDisk( _params->ContentDirectory.c_str() );

    // Create the needed data for a simple quad that is textured on both sides
    float posData[] = {
        0,  0, 0,
        100, 0, 0,
        0, 100, 0,
        100, 100, 0
    };
    unsigned int vertexCount = 4;

    unsigned int indexData[] = { 0,1,2, 2,1,3,  3,1,2, 2,1,0 };
    unsigned int triangleIndexCount = 12;
    unsigned int triangleIndexMax = 3;
   
    short normalData[] = {
        0, 0, 1,
        0, 0, 1,
        0, 0, 1,
        0, 0, 1
    };
    short tangentData[] = {
        0, 1, 0,
        0, 1, 0,
        0, 1, 0,
        0, 1, 0
    };
    short bitangentData[] = {
        1, 0, 0,
        1, 0, 0,
        1, 0, 0,
        1, 0, 0
    };
    float uvData[] = {
        0, 0,
        1, 0,
        0, 1,
        1, 1
    };
   
    H3DRes geoRes = h3dutCreateGeometryRes("geoRes", vertexCount, triangleIndexCount, posData, indexData, normalData, tangentData, bitangentData, uvData, 0);
    H3DNode model = h3dAddModelNode( H3DRootNode, "DynGeoModelNode", geoRes );
    h3dAddMeshNode( model, "DynGeoMesh", matRes, 0, triangleIndexCount, 0, triangleIndexMax );
    //h3dSetNodeTransform( model, 0,0,0, 0,40,0, 1,1,1 );
}


Top
 Profile  
Reply with quote  
PostPosted: 15.04.2011, 12:50 
Offline

Joined: 08.06.2010, 14:17
Posts: 63
Did some more experimenting. Yeah, setting tangent data in CreateGeometryRes doesn't work for me either. But it works from MapResStream. Strange.


Top
 Profile  
Reply with quote  
PostPosted: 15.04.2011, 17:18 
Offline

Joined: 24.03.2010, 10:17
Posts: 55
Change line 680 in Horde3DUtils/main.cpp from
Code:
// Set number of streams
*( (uint32 *)pData ) = 1 + numTexSets + ( normalData ? 1 : 0 ); pData += sizeof( uint32 );
to
Code:
// Set number of streams
*( (uint32 *)pData ) = 1 + numTexSets + ( normalData ? 1 : 0 ) + ((tangentData && bitangentData) ? 2 : 0); pData += sizeof( uint32 );


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group