1 // Created on: 1997-07-28
2 // Created by: Pierre CHALAMET
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Graphic3d_TextureEnv.ixx>
18 #include <Graphic3d_TypeOfTexture.hxx>
19 #include <Graphic3d_TypeOfTextureMode.hxx>
20 #include <Graphic3d_TextureParams.hxx>
21 #include <TCollection_AsciiString.hxx>
23 static const char *NameOfTexture_to_FileName[] =
35 // =======================================================================
36 // function : Graphic3d_TextureEnv
38 // =======================================================================
39 Graphic3d_TextureEnv::Graphic3d_TextureEnv (const TCollection_AsciiString& theFileName)
40 : Graphic3d_TextureRoot (theFileName, Graphic3d_TOT_2D_MIPMAP),
41 myName (Graphic3d_NOT_ENV_UNKNOWN)
43 myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
44 myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
45 Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
46 Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
49 // =======================================================================
50 // function : Graphic3d_TextureEnv
52 // =======================================================================
53 Graphic3d_TextureEnv::Graphic3d_TextureEnv (const Graphic3d_NameOfTextureEnv theNOT)
54 : Graphic3d_TextureRoot (NameOfTexture_to_FileName[theNOT], Graphic3d_TOT_2D_MIPMAP),
57 myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
58 myTexId = TCollection_AsciiString ("Graphic3d_TextureEnv_")
59 + NameOfTexture_to_FileName[theNOT];
61 myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
62 myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
63 Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
64 Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
67 // =======================================================================
70 // =======================================================================
71 Graphic3d_NameOfTextureEnv Graphic3d_TextureEnv::Name() const
76 // =======================================================================
77 // function : NumberOfTextures
79 // =======================================================================
80 Standard_Integer Graphic3d_TextureEnv::NumberOfTextures()
82 return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
85 // =======================================================================
86 // function : TextureName
88 // =======================================================================
89 TCollection_AsciiString Graphic3d_TextureEnv::TextureName (const Standard_Integer theRank)
91 if(theRank < 1 || theRank > NumberOfTextures())
93 Standard_OutOfRange::Raise ("BAD index of texture");
96 TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
97 Standard_Integer i = aFileName.SearchFromEnd(".");
98 return aFileName.SubString (5, i - 1);