1 #ifndef DALI_TOOLKIT_INTERNAL_OBJ_LOADER_H
2 #define DALI_TOOLKIT_INTERNAL_OBJ_LOADER_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/rendering/renderer.h>
51 Vertex( const Vector3& position, const Vector3& normal, const Vector2& textureCoord )
52 : position( position ), normal( normal )
64 VertexExt( const Vector3& tangent, const Vector3& binormal )
65 : tangent( tangent), bitangent( binormal )
76 pointMin = Vector3( std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max() );
77 pointMax = Vector3( std::numeric_limits<float>::min(), std::numeric_limits<float>::min(), std::numeric_limits<float>::min() );
80 void ConsiderNewPointInVolume( const Vector3& position )
82 pointMin.x = std::min( position.x, pointMin.x );
83 pointMin.y = std::min( position.y, pointMin.y );
84 pointMin.z = std::min( position.z, pointMin.z );
86 pointMax.x = std::max( position.x, pointMax.x );
87 pointMax.y = std::max( position.y, pointMax.y );
88 pointMax.z = std::max( position.z, pointMax.z );
95 //Defines bit masks to declare which properties are needed by anyone requesting a geometry.
98 TEXTURE_COORDINATES = 1 << 0,
104 virtual ~ObjLoader();
106 bool IsSceneLoaded();
107 bool IsMaterialLoaded();
109 bool LoadObject( char* objBuffer, std::streampos fileSize );
111 void LoadMaterial( char* objBuffer, std::streampos fileSize, std::string& diffuseTextureUrl,
112 std::string& normalTextureUrl, std::string& glossTextureUrl );
114 Geometry CreateGeometry( int objectProperties );
121 bool IsTexturePresent();
122 bool IsDiffuseMapPresent();
123 bool IsNormalMapPresent();
124 bool IsSpecularMapPresent();
128 BoundingVolume mSceneAABB;
131 bool mMaterialLoaded;
132 bool mHasTexturePoints;
134 //Material file properties.
137 bool mHasSpecularMap;
139 Dali::Vector<Vector3> mPoints;
140 Dali::Vector<Vector2> mTextures;
141 Dali::Vector<Vector2> mTextures2;
142 Dali::Vector<Vector3> mNormals;
143 Dali::Vector<Vector3> mTangents;
144 Dali::Vector<Vector3> mBiTangents;
145 Dali::Vector<TriIndex> mTriangles;
147 void CalculateTangentArray( const Dali::Vector<Vector3>& vertex,
148 const Dali::Vector<Vector2>& texcoord,
149 Dali::Vector<TriIndex>& triangle,
150 Dali::Vector<Vector3>& normal,
151 Dali::Vector<Vector3>& tangent );
153 void CenterAndScale( bool center, Dali::Vector<Vector3>& points );
156 void CreateGeometryArray( Dali::Vector<Vertex> & vertices,
157 Dali::Vector<Vector2> & textures,
158 Dali::Vector<VertexExt> & verticesExt,
159 Dali::Vector<unsigned short> & indices );
165 } // namespace Internal
167 } // namespace Toolkit
174 #endif // DALI_TOOLKIT_INTERNAL_OBJ_LOADER_H