b311480e |
1 | // Created on: 1997-07-28 |
2 | // Created by: Pierre CHALAMET |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
42cf5bc1 |
17 | |
18 | #include <Graphic3d_TextureEnv.hxx> |
19 | #include <Graphic3d_TextureParams.hxx> |
7fd59977 |
20 | #include <Graphic3d_TypeOfTexture.hxx> |
21 | #include <Graphic3d_TypeOfTextureMode.hxx> |
42cf5bc1 |
22 | #include <Standard_OutOfRange.hxx> |
23 | #include <Standard_Type.hxx> |
7fd59977 |
24 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
25 | |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_TextureEnv,Graphic3d_TextureRoot) |
27 | |
896faa72 |
28 | static const char *NameOfTextureEnv_to_FileName[] = |
7fd59977 |
29 | { |
30 | "env_clouds.rgb", |
31 | "env_cv.rgb", |
32 | "env_medit.rgb", |
33 | "env_pearl.rgb", |
34 | "env_sky1.rgb", |
35 | "env_sky2.rgb", |
36 | "env_lines.rgb", |
37 | "env_road.rgb" |
38 | }; |
39 | |
bf75be98 |
40 | // ======================================================================= |
41 | // function : Graphic3d_TextureEnv |
42 | // purpose : |
43 | // ======================================================================= |
44 | Graphic3d_TextureEnv::Graphic3d_TextureEnv (const TCollection_AsciiString& theFileName) |
45 | : Graphic3d_TextureRoot (theFileName, Graphic3d_TOT_2D_MIPMAP), |
46 | myName (Graphic3d_NOT_ENV_UNKNOWN) |
7fd59977 |
47 | { |
bf75be98 |
48 | myParams->SetFilter (Graphic3d_TOTF_TRILINEAR); |
49 | myParams->SetGenMode (Graphic3d_TOTM_SPHERE, |
50 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
51 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
7fd59977 |
52 | } |
53 | |
bf75be98 |
54 | // ======================================================================= |
55 | // function : Graphic3d_TextureEnv |
56 | // purpose : |
57 | // ======================================================================= |
58 | Graphic3d_TextureEnv::Graphic3d_TextureEnv (const Graphic3d_NameOfTextureEnv theNOT) |
896faa72 |
59 | : Graphic3d_TextureRoot (NameOfTextureEnv_to_FileName[theNOT], Graphic3d_TOT_2D_MIPMAP), |
bf75be98 |
60 | myName (theNOT) |
7fd59977 |
61 | { |
bf75be98 |
62 | myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder()); |
63 | myTexId = TCollection_AsciiString ("Graphic3d_TextureEnv_") |
896faa72 |
64 | + NameOfTextureEnv_to_FileName[theNOT]; |
bf75be98 |
65 | |
66 | myParams->SetFilter (Graphic3d_TOTF_TRILINEAR); |
67 | myParams->SetGenMode (Graphic3d_TOTM_SPHERE, |
68 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
69 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
7fd59977 |
70 | } |
71 | |
1a6751b1 |
72 | // ======================================================================= |
73 | // function : Graphic3d_TextureEnv |
74 | // purpose : |
75 | // ======================================================================= |
76 | Graphic3d_TextureEnv::Graphic3d_TextureEnv (const Handle(Image_PixMap)& thePixMap) |
77 | : Graphic3d_TextureRoot (thePixMap, Graphic3d_TOT_2D_MIPMAP), |
78 | myName (Graphic3d_NOT_ENV_UNKNOWN) |
79 | { |
80 | myParams->SetFilter (Graphic3d_TOTF_TRILINEAR); |
81 | myParams->SetGenMode (Graphic3d_TOTM_SPHERE, |
82 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
83 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
84 | } |
85 | |
bf75be98 |
86 | // ======================================================================= |
87 | // function : Name |
88 | // purpose : |
89 | // ======================================================================= |
90 | Graphic3d_NameOfTextureEnv Graphic3d_TextureEnv::Name() const |
91 | { |
7fd59977 |
92 | return myName; |
93 | } |
94 | |
bf75be98 |
95 | // ======================================================================= |
96 | // function : NumberOfTextures |
97 | // purpose : |
98 | // ======================================================================= |
99 | Standard_Integer Graphic3d_TextureEnv::NumberOfTextures() |
100 | { |
896faa72 |
101 | return sizeof(NameOfTextureEnv_to_FileName)/sizeof(char*); |
7fd59977 |
102 | } |
103 | |
bf75be98 |
104 | // ======================================================================= |
105 | // function : TextureName |
106 | // purpose : |
107 | // ======================================================================= |
108 | TCollection_AsciiString Graphic3d_TextureEnv::TextureName (const Standard_Integer theRank) |
109 | { |
110 | if(theRank < 1 || theRank > NumberOfTextures()) |
111 | { |
9775fa61 |
112 | throw Standard_OutOfRange("BAD index of texture"); |
bf75be98 |
113 | } |
114 | |
896faa72 |
115 | TCollection_AsciiString aFileName (NameOfTextureEnv_to_FileName[theRank - 1]); |
bf75be98 |
116 | Standard_Integer i = aFileName.SearchFromEnd("."); |
117 | return aFileName.SubString (5, i - 1); |
7fd59977 |
118 | } |