1 /*
2 This file is part of Caelum.
3 See http://www.ogre3d.org/wiki/index.php/Caelum
4 
5 Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details.
6 
7 Caelum is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Caelum is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Caelum. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef CAELUM_HEADER__PRIVATE_UTILITIES_H
22 #define CAELUM_HEADER__PRIVATE_UTILITIES_H
23 
24 #include "CaelumPrerequisites.h"
25 #include "PrivatePtr.h"
26 
27 namespace Caelum
28 {
29     /** Private caelum utilities
30      *
31      *  This class constains various tiny utilities for caelum to use.
32      */
33     class CAELUM_EXPORT InternalUtilities
34     {
35     public:
36         /** Gets the interpolated colour between two pixels from an image.
37             Interpolate a texture pixel by hand. (fx, fy) are in texture coordinates,
38             ranging [0-1] across the entire texture.
39             Smooth blending is only done on the x coordinate.
40             Wrapping is only supported on X as well.
41 
42             @param fx Horizontal coordinate.
43             @param fy Vertical coordiate.
44             @param img The lookup image.
45             @param wrapX To wrap the x coordinate.
46             @return The interpolated colour.
47          */
48         static Ogre::ColourValue getInterpolatedColour (
49                 float fx,
50                 float fy,
51                 Ogre::Image *img,
52                 bool wrapX = true);
53 
54         /** Quickly format a pointer as a string; in hex
55          */
56         static const Ogre::String pointerToString(void* pointer);
57 
58         /** Creates a private clone of a material from a script.
59          *
60          *  When a class wants to modify a material at runtime it must not
61          *  modify the original material loaded from scripts. Instead it
62          *  should create a clone and use that.
63          *
64          *  This method throws a Caelum::UnsupportedException on failure.
65          *
66          *  @param originalName Name of the original material.
67          *  @param cloneName Name of the result clone.
68          *
69          *  @return A pointer to an unique material.
70          */
71         static Ogre::MaterialPtr checkLoadMaterialClone (
72                 const Ogre::String& originalName,
73                 const Ogre::String& cloneName);
74 
75         /** Fetch a compositor by name and check it can be loaded properly
76          *
77          *  This method throws a Caelum::UnsupportedException on failure.
78          *
79          *  @param name Name of the compositor to check.
80          *
81          *  @return A pointer to the compositor (can be ignored)
82          */
83         static Ogre::CompositorPtr checkCompositorSupported (const Ogre::String& name);
84 
85 	public:
86 		/** Enumeration of types of sky domes.
87 		 */
88 		enum DomeType {
89             DT_SKY_DOME,
90             DT_IMAGE_STARFIELD,
91         };
92 
93 		/** Creates a longitude-latitude sky dome.
94 		 *  @note Does nothing if the sphere already exists.
95 		 *  @param name The name of the mesh to be created.
96 		 *  @param segments The number of sphere segments.
97 		 *  @param domeType The type of dome to create.
98 		 */
99 		static void generateSphericDome (const Ogre::String &name, int segments, DomeType domeType);
100 
101 	private:
102 		/** Fills the vertex and index buffers for a sky gradients type dome.
103 		 *  @param pVertex Pointer to the vertex buffer.
104 		 *  @param pIndices Pointer to the index buffer.
105 		 *  @param segments Subdivision detail.
106 		 */
107 		static void fillGradientsDomeBuffers (float *pVertex, unsigned short *pIndices, int segments);
108 
109 		/** Fills the vertex and index buffers for a stardield type dome.
110 		 *  @param pVertex Pointer to the vertex buffer.
111 		 *  @param pIndices Pointer to the index buffer.
112 		 *  @param segments Subdivision detail.
113 		 */
114 		static void fillStarfieldDomeBuffers (float *pVertex, unsigned short *pIndices, int segments);
115     };
116 }
117 
118 #endif // CAELUM_HEADER__PRIVATE_UTILITIES_H
119