Apply auto cap textures to make caps

This commit is contained in:
Mattia Basaglia
2015-07-19 10:31:22 +02:00
parent c311c99f37
commit f3e01fbe74
+34 -32
View File
@@ -67,6 +67,32 @@ void Scene_PatchConstructPrefab( scene::Graph& graph, const AABB aabb, const cha
}
}
void PatchAutoCapTexture( Patch& patch ) {
AABB box = patch.localAABB();
float x = box.extents.x();
float y = box.extents.y();
float z = box.extents.z();
int cap_direction = -1;
if ( x < y && x < z )
cap_direction = 0;
else if ( y < x && y < z )
cap_direction = 1;
else if ( z < x && z < x )
cap_direction = 2;
if ( cap_direction >= 0 )
patch.ProjectTexture(cap_direction);
else
patch.NaturalTexture();
}
void Patch_AutoCapTexture(){
UndoableCommand command( "patchAutoCapTexture" );
Scene_forEachVisibleSelectedPatch( &PatchAutoCapTexture );
SceneChangeNotify();
}
void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, const char* shader ){
if ( ( type == eCapEndCap || type == eCapIEndCap )
@@ -89,8 +115,10 @@ void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, co
NodeSmartReference cap( g_patchCreator->createPatch() );
Node_getTraversable( instance.path().parent() )->insert( cap );
patch.MakeCap( Node_getPatch( cap ), type, ROW, true );
Node_getPatch( cap )->SetShader( shader );
Patch* cap_patch = Node_getPatch( cap );
patch.MakeCap( cap_patch, type, ROW, true );
cap_patch->SetShader( shader );
PatchAutoCapTexture(*cap_patch);
scene::Path path( instance.path() );
path.pop();
@@ -102,8 +130,10 @@ void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, co
NodeSmartReference cap( g_patchCreator->createPatch() );
Node_getTraversable( instance.path().parent() )->insert( cap );
patch.MakeCap( Node_getPatch( cap ), type, ROW, false );
Node_getPatch( cap )->SetShader( shader );
Patch* cap_patch = Node_getPatch( cap );
patch.MakeCap( cap_patch, type, ROW, false );
cap_patch->SetShader( shader );
PatchAutoCapTexture(*cap_patch);
scene::Path path( instance.path() );
path.pop();
@@ -196,34 +226,6 @@ void Scene_PatchCapTexture_Selected( scene::Graph& graph ){
SceneChangeNotify();
}
void PatchAutoCapTexture( Patch& patch ) {
AABB box = patch.localAABB();
float x = box.extents.x();
float y = box.extents.y();
float z = box.extents.z();
int cap_direction = -1;
if ( x < y && x < z )
cap_direction = 0;
else if ( y < x && y < z )
cap_direction = 1;
else if ( z < x && z < x )
cap_direction = 2;
if ( cap_direction >= 0 )
patch.ProjectTexture(cap_direction);
else
patch.NaturalTexture();
}
void Patch_AutoCapTexture(){
UndoableCommand command( "patchAutoCapTexture" );
Scene_forEachVisibleSelectedPatch( &PatchAutoCapTexture );
SceneChangeNotify();
}
class PatchFlipTexture
{
int m_axis;