Merge "(Automated Tests) Added more coverage to Builder" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / model3d-view / model3d-view-impl.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "model3d-view-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/public-api/animation/constraint.h>
24 #include <dali/public-api/animation/constraint-source.h>
25 #include <dali/public-api/animation/constraints.h>
26 #include <dali/public-api/object/type-registry-helper.h>
27 #include <dali-toolkit/public-api/controls/model3d-view/model3d-view.h>
28 #include <dali/public-api/images/resource-image.h>
29 #include <dali/devel-api/adaptor-framework/file-loader.h>
30 #include <dali/devel-api/adaptor-framework/bitmap-loader.h>
31
32 // INTERNAL INCLUDES
33 #include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
34
35 namespace Dali
36 {
37
38 namespace Toolkit
39 {
40
41 namespace Internal
42 {
43
44 namespace
45 {
46
47 // Texture indices are constants.
48 enum TextureIndex
49 {
50   DIFFUSE_TEXTURE_INDEX,
51   NORMAL_TEXTURE_INDEX,
52   GLOSS_TEXTURE_INDEX
53 };
54
55 /**
56  * @brief Loads a texture from a file.
57  * @param[in] imageUrl The URL of the file
58  * @return A texture if loading succeeds, an empty handle otherwise
59  */
60 Texture LoadTexture( const char* imageUrl )
61 {
62   Texture texture;
63   Dali::BitmapLoader loader = Dali::BitmapLoader::New( imageUrl );
64   loader.Load();
65   PixelData pixelData = loader.GetPixelData();
66   if( pixelData )
67   {
68     texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
69     texture.Upload( pixelData );
70     texture.GenerateMipmaps();
71   }
72
73   return texture;
74 }
75
76 // Type registration
77 BaseHandle Create()
78 {
79   return Toolkit::Model3dView::New();
80 }
81
82 // Setup properties, signals and actions using the type-registry.
83 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Model3dView, Toolkit::Control, Create );
84
85 DALI_PROPERTY_REGISTRATION( Toolkit, Model3dView, "geometryUrl",  STRING, GEOMETRY_URL)
86 DALI_PROPERTY_REGISTRATION( Toolkit, Model3dView, "materialUrl",  STRING, MATERIAL_URL)
87 DALI_PROPERTY_REGISTRATION( Toolkit, Model3dView, "imagesUrl",  STRING, IMAGES_URL)
88 DALI_PROPERTY_REGISTRATION( Toolkit, Model3dView, "illuminationType",  INTEGER, ILLUMINATION_TYPE)
89 DALI_PROPERTY_REGISTRATION( Toolkit, Model3dView, "texture0Url",  STRING, TEXTURE0_URL)
90 DALI_PROPERTY_REGISTRATION( Toolkit, Model3dView, "texture1Url",  STRING, TEXTURE1_URL)
91 DALI_PROPERTY_REGISTRATION( Toolkit, Model3dView, "texture2Url",  STRING, TEXTURE2_URL)
92
93 DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Model3dView, "lightPosition",  VECTOR3, LIGHT_POSITION)
94
95 DALI_TYPE_REGISTRATION_END()
96
97
98 #define MAKE_SHADER(A)#A
99
100 //  Diffuse illumination shader
101
102 const char* SIMPLE_VERTEX_SHADER = MAKE_SHADER(
103   attribute highp vec3 aPosition;\n
104   attribute highp vec2 aTexCoord;\n
105   attribute highp vec3 aNormal;\n
106   varying mediump vec3 vIllumination;\n
107   uniform mediump vec3 uSize;\n
108   uniform mediump mat4 uMvpMatrix;\n
109   uniform mediump mat4 uModelView;\n
110   uniform mediump mat3 uNormalMatrix;
111   uniform mediump mat4 uObjectMatrix;\n
112   uniform mediump vec3 uLightPosition;\n
113
114   void main()\n
115   {\n
116     vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);\n
117     vertexPosition = uObjectMatrix * vertexPosition;\n
118     vertexPosition = uMvpMatrix * vertexPosition;\n
119
120     //Illumination in Model-View space - Transform attributes and uniforms\n
121     vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
122     vec3 normal = uNormalMatrix * aNormal;\n
123     vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
124     vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
125
126     float lightDiffuse = max( dot( vecToLight, normal ), 0.0 );\n
127     vIllumination = vec3(lightDiffuse * 0.5 + 0.5);\n
128
129     gl_Position = vertexPosition;\n
130   }\n
131 );
132
133 const char* SIMPLE_FRAGMENT_SHADER = MAKE_SHADER(
134   precision mediump float;\n
135   varying mediump vec3 vIllumination;\n
136   uniform lowp vec4 uColor;\n
137
138   void main()\n
139   {\n
140     gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a);\n
141   }\n
142 );
143
144 //  Diffuse and specular illumination shader with albedo texture
145
146 const char* VERTEX_SHADER = MAKE_SHADER(
147   attribute highp vec3 aPosition;\n
148   attribute highp vec2 aTexCoord;\n
149   attribute highp vec3 aNormal;\n
150   varying mediump vec2 vTexCoord;\n
151   varying mediump vec3 vIllumination;\n
152   varying mediump float vSpecular;\n
153   uniform mediump vec3 uSize;\n
154   uniform mediump mat4 uMvpMatrix;\n
155   uniform mediump mat4 uModelView;
156   uniform mediump mat3 uNormalMatrix;
157   uniform mediump mat4 uObjectMatrix;\n
158   uniform mediump vec3 uLightPosition;\n
159
160   void main()
161   {\n
162     vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);\n
163     vertexPosition = uObjectMatrix * vertexPosition;\n
164     vertexPosition = uMvpMatrix * vertexPosition;\n
165
166     //Illumination in Model-View space - Transform attributes and uniforms\n
167     vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
168     vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
169     vec3 normal = normalize(uNormalMatrix * aNormal);\n
170
171     vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
172     vec3 viewDir = normalize(-vertPos.xyz);
173
174     vec3 halfVector = normalize(viewDir + vecToLight);
175
176     float lightDiffuse = dot( vecToLight, normal );\n
177     lightDiffuse = max(0.0,lightDiffuse);\n
178     vIllumination = vec3(lightDiffuse * 0.5 + 0.5);\n
179
180     vec3 reflectDir = reflect(-vecToLight, normal);
181     vSpecular = pow( max(dot(reflectDir, viewDir), 0.0), 4.0 );
182
183     vTexCoord = aTexCoord;\n
184     gl_Position = vertexPosition;\n
185   }\n
186 );
187
188 const char* FRAGMENT_SHADER = MAKE_SHADER(
189   precision mediump float;\n
190   varying mediump vec2 vTexCoord;\n
191   varying mediump vec3 vIllumination;\n
192   varying mediump float vSpecular;\n
193   uniform sampler2D sDiffuse;\n
194   uniform lowp vec4 uColor;\n
195
196   void main()\n
197   {\n
198     vec4 texture = texture2D( sDiffuse, vTexCoord );\n
199     gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb + vSpecular * 0.3, texture.a * uColor.a);\n
200   }\n
201 );
202
203 //  Diffuse and specular illumination shader with albedo texture, normal map and gloss map shader
204
205 const char* NRMMAP_VERTEX_SHADER = MAKE_SHADER(
206   attribute highp vec3 aPosition;\n
207   attribute highp vec2 aTexCoord;\n
208   attribute highp vec3 aNormal;\n
209   attribute highp vec3 aTangent;\n
210   attribute highp vec3 aBiNormal;\n
211   varying mediump vec2 vTexCoord;\n
212   varying mediump vec3 vLightDirection;\n
213   varying mediump vec3 vHalfVector;\n
214   uniform mediump vec3 uSize;\n
215   uniform mediump mat4 uMvpMatrix;\n
216   uniform mediump mat4 uModelView;
217   uniform mediump mat3 uNormalMatrix;
218   uniform mediump mat4 uObjectMatrix;\n
219   uniform mediump vec3 uLightPosition;\n
220
221   void main()
222   {\n
223     vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);\n
224     vertexPosition = uObjectMatrix * vertexPosition;\n
225     vertexPosition = uMvpMatrix * vertexPosition;\n
226
227     vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
228     vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
229
230     vec3 tangent = normalize(uNormalMatrix * aTangent);
231     vec3 binormal = normalize(uNormalMatrix * aBiNormal);
232     vec3 normal = normalize(uNormalMatrix * aNormal);
233
234     vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
235     vLightDirection.x = dot(vecToLight, tangent);
236     vLightDirection.y = dot(vecToLight, binormal);
237     vLightDirection.z = dot(vecToLight, normal);
238
239     vec3 viewDir = normalize(-vertPos.xyz);
240     vec3 halfVector = normalize(viewDir + vecToLight);
241     vHalfVector.x = dot(halfVector, tangent);
242     vHalfVector.y = dot(halfVector, binormal);
243     vHalfVector.z = dot(halfVector, normal);
244
245     vTexCoord = aTexCoord;\n
246     gl_Position = vertexPosition;\n
247   }\n
248 );
249
250 const char* NRMMAP_FRAGMENT_SHADER = MAKE_SHADER(
251   precision mediump float;\n
252   varying mediump vec2 vTexCoord;\n
253   varying mediump vec3 vLightDirection;\n
254   varying mediump vec3 vHalfVector;\n
255   uniform sampler2D sDiffuse;\n
256   uniform sampler2D sNormal;\n
257   uniform sampler2D sGloss;\n
258   uniform lowp vec4 uColor;\n
259
260   void main()\n
261   {\n
262     vec4 texture = texture2D( sDiffuse, vTexCoord );\n
263     vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );\n
264     vec4 glossMap = texture2D( sGloss, vTexCoord );\n
265
266     float lightDiffuse = max( 0.0, dot( normal, normalize(vLightDirection) ) );\n
267     lightDiffuse = lightDiffuse * 0.5 + 0.5;\n
268
269     float shininess = pow (max (dot (normalize( vHalfVector ), normal), 0.0), 16.0)  ;
270
271     gl_FragColor = vec4( texture.rgb * uColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a);\n
272   }\n
273 );
274
275
276 } // anonymous namespace
277
278 using namespace Dali;
279
280 Model3dView::Model3dView()
281   : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) )
282 {
283   mIlluminationType = Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP;
284
285   mCameraFOV = Math::PI_OVER_180 * 45.f;
286
287   mControlSize = Vector2(100.,100.);
288 }
289
290 Model3dView::~Model3dView()
291 {
292 }
293
294 Toolkit::Model3dView Model3dView::New()
295 {
296   Model3dView* impl = new Model3dView();
297
298   Dali::Toolkit::Model3dView handle = Dali::Toolkit::Model3dView( *impl );
299
300   // Second-phase init of the implementation
301   // This can only be done after the CustomActor connection has been made...
302   impl->Initialize();
303
304   return handle;
305 }
306
307 void Model3dView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
308 {
309   Toolkit::Model3dView model3dView = Toolkit::Model3dView::DownCast( Dali::BaseHandle( object ) );
310
311   if( model3dView )
312   {
313     Model3dView& impl( GetImpl( model3dView ) );
314     switch( index )
315     {
316       case Toolkit::Model3dView::Property::GEOMETRY_URL:
317       {
318         if( value.Get(impl.mObjUrl) )
319         {
320           impl.LoadGeometry();
321           impl.CreateGeometry();
322         }
323         break;
324       }
325       case Toolkit::Model3dView::Property::MATERIAL_URL:
326       {
327         if( value.Get(impl.mTextureSetUrl) )
328         {
329           impl.LoadMaterial();
330           impl.CreateMaterial();
331         }
332         break;
333       }
334       case Toolkit::Model3dView::Property::IMAGES_URL:
335       {
336         if( value.Get(impl.mImagesUrl) )
337         {
338           impl.LoadTextures();
339         }
340         break;
341       }
342       case Toolkit::Model3dView::Property::ILLUMINATION_TYPE:
343       {
344         int illuminationType;
345         if( value.Get(illuminationType) )
346         {
347           impl.mIlluminationType = Toolkit::Model3dView::IlluminationType(illuminationType);
348           impl.CreateGeometry();
349           impl.CreateMaterial();
350           impl.LoadTextures();
351         }
352         break;
353       }
354       case Toolkit::Model3dView::Property::TEXTURE0_URL:
355       {
356         value.Get(impl.mTexture0Url);
357         break;
358       }
359       case Toolkit::Model3dView::Property::TEXTURE1_URL:
360       {
361         value.Get(impl.mTexture1Url);
362         break;
363       }
364       case Toolkit::Model3dView::Property::TEXTURE2_URL:
365       {
366         value.Get(impl.mTexture2Url);
367         break;
368       }
369     }
370   }
371 }
372
373 Property::Value Model3dView::GetProperty( BaseObject* object, Property::Index index )
374 {
375   Property::Value value;
376
377   Toolkit::Model3dView model3dView = Toolkit::Model3dView::DownCast( Dali::BaseHandle( object ) );
378
379   if( model3dView )
380   {
381     Model3dView& impl( GetImpl( model3dView ) );
382     switch( index )
383     {
384       case Toolkit::Model3dView::Property::GEOMETRY_URL:
385       {
386         value = impl.mObjUrl;
387         break;
388       }
389       case Toolkit::Model3dView::Property::MATERIAL_URL:
390       {
391         value = impl.mTextureSetUrl;
392         break;
393       }
394       case Toolkit::Model3dView::Property::IMAGES_URL:
395       {
396         value = impl.mImagesUrl;
397         break;
398       }
399       case Toolkit::Model3dView::Property::ILLUMINATION_TYPE:
400       {
401         value = int(impl.mIlluminationType);
402         break;
403       }
404       case Toolkit::Model3dView::Property::TEXTURE0_URL:
405       {
406         value = impl.mTexture0Url;
407         break;
408       }
409       case Toolkit::Model3dView::Property::TEXTURE1_URL:
410       {
411         value = impl.mTexture1Url;
412         break;
413       }
414       case Toolkit::Model3dView::Property::TEXTURE2_URL:
415       {
416         value = impl.mTexture2Url;
417         break;
418       }
419     }
420   }
421
422   return value;
423 }
424
425 /////////////////////////////////////////////////////////////
426
427
428 void Model3dView::OnStageConnection( int depth )
429 {
430   Control::OnStageConnection( depth );
431
432   CustomActor self = Self();
433   self.AddRenderer( mRenderer );
434
435   if( mObjLoader.IsSceneLoaded() )
436   {
437     mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ) );
438
439     CreateMaterial();
440     LoadTextures();
441
442     mRenderer.SetGeometry( mMesh );
443
444     //create constraint for lightPosition Property with uLightPosition in the shader
445     Vector3 lightPosition( 0, 0, 0 );
446     Dali::Property::Index lightProperty = mShader.RegisterProperty( "uLightPosition", lightPosition );
447     Constraint constraint = Constraint::New<Vector3>( mShader, lightProperty, EqualToConstraint() );
448     constraint.AddSource( Source( self, Toolkit::Model3dView::Property::LIGHT_POSITION ) );
449     constraint.Apply();
450   }
451 }
452
453 ///////////////////////////////////////////////////////////
454 //
455 // Private methods
456 //
457
458 void Model3dView::OnInitialize()
459 {
460   //Create empty versions of the geometry and material so we always have a Renderer
461   Geometry mesh = Geometry::New();
462   Shader shader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
463   mRenderer = Renderer::New( mesh, shader );
464
465 }
466
467 void Model3dView::LoadGeometry()
468 {
469   //Load file in adaptor
470   std::streampos fileSize;
471   Dali::Vector<char> fileContent;
472
473   if (FileLoader::ReadFile(mObjUrl,fileSize,fileContent,FileLoader::TEXT))
474   {
475     mObjLoader.ClearArrays();
476     mObjLoader.LoadObject(fileContent.Begin(), fileSize);
477
478     //Get size information from the obj loaded
479     mSceneCenter = mObjLoader.GetCenter();
480     mSceneSize = mObjLoader.GetSize();
481   }
482   else
483   {
484     //Error
485   }
486 }
487
488 void Model3dView::LoadMaterial()
489 {
490   //Load file in adaptor
491   std::streampos fileSize;
492   Dali::Vector<char> fileContent;
493
494   if( FileLoader::ReadFile(mTextureSetUrl, fileSize, fileContent, FileLoader::TEXT) )
495   {
496     mObjLoader.LoadMaterial(fileContent.Begin(), fileSize, mTexture0Url, mTexture1Url, mTexture2Url);
497   }
498   else
499   {
500     //Error
501   }
502 }
503
504 void Model3dView::Load()
505 {
506   LoadGeometry();
507   LoadMaterial();
508 }
509
510 void Model3dView::OnRelayout( const Vector2& size, RelayoutContainer& container )
511 {
512   UpdateView();
513 }
514
515 void Model3dView::UpdateView()
516 {
517   if( mObjLoader.IsSceneLoaded() )
518   {
519     //The object will always be centred
520
521     Matrix scaleMatrix;
522     scaleMatrix.SetIdentityAndScale(Vector3(1.0, -1.0, 1.0));
523
524     mShader.RegisterProperty( "uObjectMatrix", scaleMatrix );
525   }
526 }
527
528 void Model3dView::CreateGeometry()
529 {
530   if( mObjLoader.IsSceneLoaded() )
531   {
532     mMesh = mObjLoader.CreateGeometry( GetShaderProperties( mIlluminationType ) );
533
534     if( mRenderer )
535     {
536       mRenderer.SetGeometry( mMesh );
537       mRenderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::ON );
538     }
539   }
540 }
541
542 void Model3dView::UpdateShaderUniforms()
543 {
544   if( mShader )
545   {
546     //Update shader related info, uniforms, etc. for the new shader
547     UpdateView();
548
549     Vector3 lightPosition( 0, 0, 0 );
550     Dali::Property::Index lightProperty = mShader.RegisterProperty( "uLightPosition", lightPosition );
551
552     CustomActor self = Self();
553
554     //create constraint for lightPosition Property with uLightPosition in the shader
555     if( lightProperty )
556     {
557       Constraint constraint = Constraint::New<Vector3>( mShader, lightProperty, EqualToConstraint() );
558       constraint.AddSource( Source( self, Toolkit::Model3dView::Property::LIGHT_POSITION ) );
559       constraint.Apply();
560     }
561   }
562 }
563
564 void Model3dView::CreateMaterial()
565 {
566   if( mObjLoader.IsMaterialLoaded() && (mTexture0Url != "") && mObjLoader.IsTexturePresent() )
567   {
568     if( (mTexture2Url != "") && (mTexture1Url != "") && (mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP) )
569     {
570       mShader = Shader::New( NRMMAP_VERTEX_SHADER, NRMMAP_FRAGMENT_SHADER );
571     }
572     else if( mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_TEXTURE ||
573              mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP )
574     {
575       mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
576     }
577     else
578     {
579       mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
580     }
581   }
582   else
583   {
584     mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
585   }
586
587   mTextureSet = TextureSet::New();
588
589   if( mRenderer )
590   {
591     mRenderer.SetTextures( mTextureSet );
592     mRenderer.SetShader( mShader );
593     mRenderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
594   }
595
596   UpdateShaderUniforms();
597 }
598
599 void Model3dView::LoadTextures()
600 {
601   if( !mTextureSet )
602   {
603     return;
604   }
605
606   Sampler sampler = Sampler::New();
607   sampler.SetFilterMode( FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR_MIPMAP_LINEAR );
608
609   // Setup diffuse texture.
610   if( !mTexture0Url.empty() && ( mIlluminationType != Toolkit::Model3dView::DIFFUSE ) )
611   {
612     std::string imageUrl = mImagesUrl + mTexture0Url;
613
614     //Load textures
615     Texture diffuseTexture = LoadTexture( imageUrl.c_str() );
616     if( diffuseTexture )
617     {
618       mTextureSet.SetTexture( DIFFUSE_TEXTURE_INDEX, diffuseTexture );
619       mTextureSet.SetSampler( DIFFUSE_TEXTURE_INDEX, sampler );
620     }
621   }
622
623   if( mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP )
624   {
625     // Setup normal map texture.
626     if( !mTexture1Url.empty() )
627     {
628       std::string imageUrl = mImagesUrl + mTexture1Url;
629
630       //Load textures
631       Texture normalTexture = LoadTexture( imageUrl.c_str() );
632       if( normalTexture )
633       {
634         mTextureSet.SetTexture( NORMAL_TEXTURE_INDEX, normalTexture );
635         mTextureSet.SetSampler( NORMAL_TEXTURE_INDEX, sampler );
636       }
637     }
638     if( !mTexture2Url.empty() )
639     {
640       // Setup gloss map texture.
641       std::string imageUrl = mImagesUrl + mTexture2Url;
642
643       //Load textures
644       Texture glossTexture = LoadTexture( imageUrl.c_str() );
645       if( glossTexture )
646       {
647         mTextureSet.SetTexture( GLOSS_TEXTURE_INDEX, glossTexture );
648         mTextureSet.SetSampler( GLOSS_TEXTURE_INDEX, sampler );
649       }
650     }
651   }
652 }
653
654 int Model3dView::GetShaderProperties( Toolkit::Model3dView::IlluminationType illuminationType )
655 {
656   int objectProperties = 0;
657
658   if( illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_TEXTURE ||
659       illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP )
660   {
661     objectProperties |= ObjLoader::TEXTURE_COORDINATES;
662   }
663
664   if( illuminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP )
665   {
666     objectProperties |= ObjLoader::TANGENTS | ObjLoader::BINORMALS;
667   }
668
669   return objectProperties;
670 }
671
672 } // namespace Internal
673 } // namespace Toolkit
674 } // namespace Dali