00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "Teddy/TeddyConfig.h"
00026 #if defined( TEDDY_INCLUDE_LW_SCENE )
00027
00028
00029 #if defined(_MSC_VER)
00030 # pragma warning(disable:4786)
00031 #endif
00032
00033
00034 #include "Teddy/Imports/LWClip.h"
00035 #include "Teddy/Imports/LWFile.h"
00036 #include "Teddy/Imports/LWLayer.h"
00037 #include "Teddy/Imports/LWModel.h"
00038 #include "Teddy/Imports/LWSurface.h"
00039 #include "Teddy/Imports/LWSurfaceBlok.h"
00040 #include "Teddy/Models/Geometry.h"
00041 #include "Teddy/Graphics/Texture.h"
00042 #include "Teddy/Graphics/ImageFileTexture.h"
00043 #include "Teddy/SysSupport/Messages.h"
00044 #include "Teddy/SysSupport/FileScan.h"
00045 #include "Teddy/SysSupport/StdMaths.h"
00046 #include "Teddy/SysSupport/StdIO.h"
00047 using namespace Teddy::Graphics;
00048 using namespace Teddy::SysSupport;
00049
00050
00051 namespace Teddy {
00052 namespace Imports {
00053
00054
00055 void LWSurfaceBlok::applyImageMap(){
00056
00057 if( enable == 0 ){
00058 return;
00059 }
00060
00061
00062 if( texture_channel != ID_COLR ){
00063 dmsg( M_LWO,
00064 "Texture channel %s not supported; only COLR channel is supported.",
00065 did( texture_channel )
00066 );
00067 }
00068
00069
00070 LWLayer *layer = dynamic_cast<LWLayer*>( surface->getLayer() );
00071 if( layer == NULL ){
00072 emsg( M_LWO, "Layer not found" );
00073 return;
00074 }
00075
00076 Model *model = surface->getModel();
00077 if( model == NULL ){
00078 emsg( M_LWO, "Model not found" );
00079 }
00080
00081 LWClip *clip = layer->getClip( texture_image_map );
00082 if( clip == NULL ){
00083 emsg( M_LWO,
00084 "Texture image map %d not found",
00085 texture_image_map
00086 );
00087 return;
00088 }
00089
00090 std::string texture_file_name = clip->still_image;
00091 std::string final_file_name = fix_file_name( "Data/textures/", texture_file_name.c_str() );
00092 dmsg( M_LWO, "Look for texture file '%s'", final_file_name.c_str() );
00093 Texture *t = new ImageFileTexture( final_file_name );
00094 surface->setTexture( t, true );
00095
00096
00097 switch( texture_projection_mode ){
00098 case LW_PROJECTION_PLANAR:
00099 model->getGeometry()->makePlanarTextureCoordinates(
00100 texture_center,
00101 texture_size,
00102 texture_major_axis
00103 );
00104 dmsg( M_TMAP, "Planar Image Map done" );
00105 break;
00106
00107 case LW_PROJECTION_CYLINDRICAL:
00108 model->getGeometry()->makeCylindricalTextureCoordinates(
00109 texture_center,
00110 texture_size,
00111 texture_major_axis
00112 );
00113 dmsg( M_TMAP, "Cylindrical Image Map done" );
00114 break;
00115
00116 case LW_PROJECTION_SPHERICAL:
00117 model->getGeometry()->makeSphericalTextureCoordinates(
00118 texture_center,
00119 texture_size,
00120 texture_major_axis
00121 );
00122 dmsg( M_TMAP, "Spherical Image Map done" );
00123 break;
00124
00125 case LW_PROJECTION_CUBIC:
00126 model->getGeometry()->makeCubicTextureCoordinates(
00127 texture_center,
00128 texture_size
00129 );
00130 dmsg( M_TMAP, "Cubic Image Map done" );
00131 break;
00132
00133 case LW_PROJECTION_FRONT:
00134 dmsg( M_TMAP, "Front projection not yet implemented" );
00135 break;
00136
00137 case LW_PROJECTION_UV:
00138 dmsg( M_TMAP, "UV projection not yet implemented" );
00139 break;
00140
00141 default:
00142 dmsg( M_TMAP, "Unknown projection mode" );
00143 break;
00144 }
00145
00146 }
00147
00148
00149 };
00150 };
00151
00152
00153 #endif // TEDDY_INCLUDE_LW_SCENE
00154