2 * Copyright (c) 2014 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.
19 #include <dali/internal/event/modeling/mesh-impl.h>
25 #include <dali/public-api/math/matrix.h>
26 #include <dali/public-api/geometry/mesh.h>
27 #include <dali/internal/event/common/thread-local-storage.h>
28 #include <dali/internal/event/modeling/material-impl.h>
29 #include <dali/internal/update/modeling/scene-graph-mesh.h>
30 #include <dali/internal/update/manager/update-manager.h>
31 #include <dali/internal/update/modeling/internal-mesh-data.h>
40 MeshIPtr Mesh::New( const Dali::MeshData& meshData, bool discardable, bool scalingRequired )
42 MeshIPtr mesh( new Mesh( meshData, discardable, scalingRequired ) );
47 Mesh::Mesh( const Dali::MeshData& publicMeshData, bool discardable, bool scalingRequired )
48 : mBoneContainer( publicMeshData.GetBones() )
50 ResourceClient& resourceClient = ThreadLocalStorage::Get().GetResourceClient();
52 // Copy the mesh-data into an internal structure, and pass ownership to the resourceClient
53 OwnerPointer<MeshData> meshDataPtr( new MeshData( publicMeshData, discardable, scalingRequired ) );
54 const ResourceTicketPtr& ticket = resourceClient.AllocateMesh( meshDataPtr );
56 mTicket = ticket.Get();
57 mTicket->AddObserver( *this );
59 Dali::Material materialHandle( publicMeshData.GetMaterial() );
60 Material& material( GetImplementation( materialHandle ) );
61 mMaterial = &material;
66 mTicket->RemoveObserver(*this);
69 ResourceId Mesh::GetResourceId() const
71 return mTicket->GetId();
74 MaterialIPtr Mesh::GetMaterial() const
79 const BoneContainer& Mesh::GetBones() const
81 return mBoneContainer;
84 void Mesh::UpdateMeshData( const Dali::MeshData& meshData )
86 DALI_ASSERT_DEBUG(meshData.GetFaceCount());
88 ResourceClient &resourceClient = ThreadLocalStorage::Get().GetResourceClient();
89 resourceClient.UpdateMesh( mTicket, meshData );
92 void Mesh::ResourceLoadingFailed(const ResourceTicket& ticket)
94 // This class is for programmatic meshes defined by the application
95 // and is not currently used by the model resource loader
98 void Mesh::ResourceLoadingSucceeded(const ResourceTicket& ticket)
100 // This class is for programmatic meshes defined by the application
101 // and is not currently used by the model resource loader
104 void Mesh::ResourceUploaded(const ResourceTicket& ticket)
108 void Mesh::ResourceSavingSucceeded( const ResourceTicket& ticket )
113 void Mesh::ResourceSavingFailed( const ResourceTicket& ticket )
118 } // namespace Internal