1 // Created on: 1997-07-28
2 // Created by: Pierre CHALAMET
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 #include <Graphic3d_TextureEnv.ixx>
22 #include <Graphic3d_TypeOfTexture.hxx>
23 #include <Graphic3d_TypeOfTextureMode.hxx>
24 #include <Graphic3d_TextureParams.hxx>
25 #include <TCollection_AsciiString.hxx>
27 static const char *NameOfTexture_to_FileName[] =
39 // =======================================================================
40 // function : Graphic3d_TextureEnv
42 // =======================================================================
43 Graphic3d_TextureEnv::Graphic3d_TextureEnv (const TCollection_AsciiString& theFileName)
44 : Graphic3d_TextureRoot (theFileName, Graphic3d_TOT_2D_MIPMAP),
45 myName (Graphic3d_NOT_ENV_UNKNOWN)
47 myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
48 myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
49 Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
50 Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
53 // =======================================================================
54 // function : Graphic3d_TextureEnv
56 // =======================================================================
57 Graphic3d_TextureEnv::Graphic3d_TextureEnv (const Graphic3d_NameOfTextureEnv theNOT)
58 : Graphic3d_TextureRoot (NameOfTexture_to_FileName[theNOT], Graphic3d_TOT_2D_MIPMAP),
61 myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
62 myTexId = TCollection_AsciiString ("Graphic3d_TextureEnv_")
63 + NameOfTexture_to_FileName[theNOT];
65 myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
66 myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
67 Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
68 Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
71 // =======================================================================
74 // =======================================================================
75 Graphic3d_NameOfTextureEnv Graphic3d_TextureEnv::Name() const
80 // =======================================================================
81 // function : NumberOfTextures
83 // =======================================================================
84 Standard_Integer Graphic3d_TextureEnv::NumberOfTextures()
86 return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
89 // =======================================================================
90 // function : TextureName
92 // =======================================================================
93 TCollection_AsciiString Graphic3d_TextureEnv::TextureName (const Standard_Integer theRank)
95 if(theRank < 1 || theRank > NumberOfTextures())
97 Standard_OutOfRange::Raise ("BAD index of texture");
100 TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
101 Standard_Integer i = aFileName.SearchFromEnd(".");
102 return aFileName.SubString (5, i - 1);