2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "game-model.h"
19 #include "game-utils.h"
21 using namespace GameUtils;
25 // 'MODV' tag stored in the big-endian (network) order
26 const uint32_t MODV_TAG( 0x4D4F4456 );
29 GameModel::GameModel( const char *filename )
34 if( !LoadFile( filename, bytes ) )
39 mHeader = *(reinterpret_cast<ModelHeader*>( bytes.data() ));
42 if( MODV_TAG != mHeader.tag )
44 // jump to little-endian variant
45 mHeader = *(reinterpret_cast<ModelHeader*>( bytes.data() + bytes.size()/2 ));
48 mVertexBuffer = Dali::PropertyBuffer::New( Dali::Property::Map().
49 Add( "aPosition", Dali::Property::VECTOR3 ).
50 Add( "aNormal", Dali::Property::VECTOR3 ).
51 Add( "aTexCoord", Dali::Property::VECTOR2 )
54 mVertexBuffer.SetData( bytes.data() + mHeader.dataBeginOffset, mHeader.vertexBufferSize/mHeader.vertexStride );
56 mGeometry = Dali::Geometry::New();
57 mGeometry.AddVertexBuffer( mVertexBuffer );
58 mGeometry.SetType( Dali::Geometry::TRIANGLES );
60 mUniqueId = HashString( filename );
65 GameModel::~GameModel()
69 Dali::Geometry& GameModel::GetGeometry()
74 bool GameModel::IsReady()
79 uint32_t GameModel::GetUniqueId()