TestDynamicsShape::TestDynamicsShape( TraceCallStack& trace )
-: mVertices( NULL ),
- mFaces( NULL ),
- mTrace( trace )
+: mTrace( trace )
{
mTrace.PushCall( "DynamicsShape::DynamicsShape", "" );
}
mTrace.PushCall( "DynamicsShape::Initialize", "" );
}
-void TestDynamicsShape::Initialize( int type, const MeshData::VertexContainer& vertices, const MeshData::FaceIndices& faceIndices )
-{
- mTrace.PushCall( "DynamicsShape::Initialize", "mesh" );
-}
-
TestDynamicsBody::TestDynamicsBody( TraceCallStack& trace )
: mSettings( NULL ),
mConserveVolume( false ),
public:
void Initialize( int type, const Vector3& dimensions );
- void Initialize( int type, const MeshData::VertexContainer& vertices, const MeshData::FaceIndices& faceIndices );
-
-public:
-
- MeshData::VertexContainer* mVertices;
- MeshData::FaceIndices* mFaces;
-
private:
TraceCallStack& mTrace;
mTrace.PushCall( "DynamicsBody::GetTransform", "" );
}
- inline void GetSoftVertices( MeshData::VertexContainer& vertices ) const
- {
- mTrace.PushCall( "DynamicsBody::GetSoftVertices", "" );
- }
private:
Dali::Integration::DynamicsBodySettings* mSettings;
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/geometry/mesh-data.h>
namespace Dali
{
virtual void SetTransform( const Vector3& position, const Quaternion& rotation ) = 0;
virtual void GetTransform( Vector3& position, Quaternion& rotation ) = 0;
- /**
- * Get the vertices and normal from a soft body
- * @param[in,out] meshData A MeshData object with preallocated space for all the vertices.
- */
- virtual void GetSoftVertices( MeshData::VertexContainer& meshData ) const = 0;
-
}; // class DynamicsBody
} //namespace Integration
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/geometry/mesh-data.h>
namespace Dali
{
*/
virtual void Initialize( int type, const Vector3& dimensions ) = 0;
- /**
- * Initialize the shape
- */
- virtual void Initialize( int type, const MeshData::VertexContainer& vertices, const MeshData::FaceIndices& faceIndices ) = 0;
}; // class DynamicsShape
#include <dali/internal/event/actors/camera-actor-impl.h>
#include <dali/internal/event/actors/text-actor-impl.h>
#include <dali/internal/event/actors/image-actor-impl.h>
-#include <dali/internal/event/actors/mesh-actor-impl.h>
#include <dali/internal/event/actors/layer-impl.h>
#include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
#include <dali/internal/event/actor-attachments/camera-attachment-impl.h>
#include <dali/internal/event/actor-attachments/text-attachment-impl.h>
#include <dali/internal/event/actor-attachments/image-attachment-impl.h>
-#include <dali/internal/event/actor-attachments/mesh-attachment-impl.h>
#include <dali/internal/event/animation/animation-impl.h>
#include <dali/internal/event/animation/animator-connector.h>
#include <dali/internal/event/images/image-impl.h>
#include <dali/internal/event/images/image-factory-cache.h>
#include <dali/internal/common/text-parameters.h>
-#include <dali/internal/event/modeling/mesh-impl.h>
-#include <dali/internal/event/modeling/material-impl.h>
#include <dali/internal/event/resources/resource-ticket.h>
#include <dali/internal/event/resources/image-ticket.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
-#include <dali/internal/update/modeling/internal-mesh-data.h>
-#include <dali/internal/update/modeling/scene-graph-animatable-mesh.h>
-#include <dali/internal/update/modeling/scene-graph-material.h>
-#include <dali/internal/update/modeling/scene-graph-mesh.h>
#include <dali/internal/update/node-attachments/node-attachment.h>
#include <dali/internal/update/node-attachments/scene-graph-camera-attachment.h>
#include <dali/internal/update/node-attachments/scene-graph-image-attachment.h>
-#include <dali/internal/update/node-attachments/scene-graph-mesh-attachment.h>
#include <dali/internal/update/node-attachments/scene-graph-text-attachment.h>
#include <dali/internal/update/resources/bitmap-metadata.h>
#include <dali/internal/render/gl-resources/bitmap-texture.h>
-
-#include <dali/internal/render/renderers/render-material.h>
#include <dali/internal/render/renderers/scene-graph-image-renderer.h>
#include <dali/internal/render/renderers/scene-graph-text-renderer.h>
-#include <dali/internal/render/renderers/scene-graph-mesh-renderer.h>
using Dali::Internal::GestureEventProcessor;
using Dali::Internal::ThreadLocalStorage;
sizeof( Internal::SceneGraph::TextAttachment ) +
sizeof( Internal::TextParameters ) +
sizeof( Internal::SceneGraph::TextRenderer ) );
-const int MESH_ACTOR_MEMORY_SIZE(
- sizeof( Internal::MeshActor ) +
- sizeof( Internal::MeshAttachment ) +
- sizeof( Internal::SceneGraph::Node ) +
- sizeof( Internal::SceneGraph::MeshAttachment ) +
- sizeof( Internal::SceneGraph::MeshRenderer ) );
const int IMAGE_ACTOR_MEMORY_SIZE(
sizeof( Internal::ImageActor ) +
sizeof( Internal::ImageAttachment ) +
sizeof( Internal::BitmapMetadata ) +
sizeof( Internal::BitmapTexture ) +
sizeof( Internal::ImageTicket ) );
-const int MESH_MEMORY_SIZE(
- sizeof( Internal::Mesh ) +
- sizeof( Internal::MeshData ) +
- sizeof( Internal::SceneGraph::Mesh ) +
- sizeof( Internal::ResourceTicket ) );
-const int MATERIAL_MEMORY_SIZE(
- sizeof( Internal::Material ) +
- sizeof( Internal::SceneGraph::Material ) +
- sizeof( Internal::SceneGraph::RenderMaterial ) );
} // namespace Profiling
ResourceNativeImage,
ResourceTargetImage,
ResourceShader,
- ResourceMesh,
ResourceText
};
TextResourceType& operator=(const TextResourceType& rhs);
};
-
-/**
- * MeshResourceType describes a mesh program resource, which can be created
- * using ResourceManager::AllocateMesh.
- */
-struct MeshResourceType : public ResourceType
-{
- /**
- * Constructor.
- */
- MeshResourceType()
- : ResourceType(ResourceMesh) {}
-
- /**
- * Destructor.
- */
- virtual ~MeshResourceType() {}
-
- /**
- * @copydoc ResourceType::Clone
- */
- virtual ResourceType* Clone() const
- {
- return new MeshResourceType();
- }
-
-private:
-
- // Undefined copy constructor.
- MeshResourceType(const MeshResourceType& typePath);
-
- // Undefined assignment operator.
- MeshResourceType& operator=(const MeshResourceType& rhs);
-};
-
inline bool operator==(const TextResourceType::GlyphPosition& lhs, const TextResourceType::GlyphPosition& rhs)
{
return lhs.character == rhs.character && lhs.xPosition == rhs.xPosition && lhs.yPosition == rhs.yPosition && lhs.quality == rhs.quality;
class CameraAttachment;
class ImageAttachment;
class TextAttachment;
-class MeshAttachment;
typedef IntrusivePtr<ActorAttachment> ActorAttachmentPtr;
typedef IntrusivePtr<CameraAttachment> CameraAttachmentPtr;
typedef IntrusivePtr<ImageAttachment> ImageAttachmentPtr;
-typedef IntrusivePtr<MeshAttachment> MeshAttachmentPtr;
typedef IntrusivePtr<TextAttachment> TextAttachmentPtr;
} // namespace Internal
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/actor-attachments/mesh-attachment-impl.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/internal/update/node-attachments/scene-graph-mesh-attachment.h>
-#include <dali/internal/update/modeling/scene-graph-material.h>
-#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/update/nodes/node.h>
-
-using Dali::Internal::MeshIPtr;
-using Dali::Internal::MaterialIPtr;
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-MeshAttachmentPtr MeshAttachment::New( Stage& stage, const SceneGraph::Node& parentNode )
-{
- MeshAttachmentPtr attachment( new MeshAttachment( stage ) );
-
- // Transfer object ownership of scene-object to message
- SceneGraph::MeshAttachment* sceneObject = SceneGraph::MeshAttachment::New();
- AttachToNodeMessage( stage.GetUpdateManager(), parentNode, sceneObject );
-
- // Keep raw pointer for message passing
- attachment->mSceneObject = sceneObject;
-
- return attachment;
-}
-
-MeshAttachment::MeshAttachment( Stage& stage )
-: RenderableAttachment( stage ),
- mSceneObject( NULL )
-{
-}
-
-MeshAttachment::~MeshAttachment()
-{
- // Belt and braces - should already have been disconnected from stage
- if ( Stage::IsInstalled() &&
- OnStage() )
- {
- DisconnectMaterial();
- }
-}
-
-void MeshAttachment::SetMesh( const MeshIPtr meshPtr,
- ResourceId meshId,
- const BoneContainer& bones,
- const MaterialIPtr material )
-{
- mMesh.mMesh = meshPtr;
- mMesh.mCustomMaterial = 0;
-
- std::size_t boneCount = bones.size();
-
- if ( boneCount > 0 )
- {
- // Copy bone names locally in order to perform actor binding later
-
- // Must keep names in same order (vertices reference into bone matrix array by index)
- for ( BoneContainer::const_iterator iter = bones.begin(); iter != bones.end(); ++iter )
- {
- const Bone& bone = (*iter);
- mMesh.mBoneNames.push_back( bone.GetName() );
- }
- }
-
- mMesh.mMaterial = material;
- const SceneGraph::Material* materialSceneObject = material->GetSceneObject();
-
- // sceneObject is being used in a separate thread; queue a message to set
- SetMeshMessage( mStage->GetUpdateInterface(), *mSceneObject, meshId, materialSceneObject, boneCount );
-}
-
-void MeshAttachment::SetMesh( const ResourceTicketPtr ticket,
- const BoneContainer& bones,
- const MaterialIPtr material )
-{
- SetMesh( 0, ticket->GetId(), bones, material );
-}
-
-void MeshAttachment::SetMaterial( MaterialIPtr material )
-{
- const SceneGraph::Material* materialSceneObject = NULL;
-
- if ( material )
- {
- // We have a new material.
- if ( OnStage() )
- {
- DisconnectMaterial();
-
- // connect the new material
- material->Connect();
- }
-
- mMesh.mCustomMaterial = material;
-
- materialSceneObject = material->GetSceneObject();
- DALI_ASSERT_DEBUG( materialSceneObject != NULL );
- }
- else
- {
- // We are unsetting the current material, and reverting to the original material
- if ( mMesh.mCustomMaterial )
- {
- if ( OnStage() )
- {
- mMesh.mCustomMaterial->Disconnect();
- }
- mMesh.mCustomMaterial = NULL;
- }
-
- // connect original material
- DALI_ASSERT_DEBUG( mMesh.mMaterial );
-
- if ( OnStage() )
- {
- mMesh.mMaterial->Connect();
- }
- materialSceneObject = mMesh.mMaterial->GetSceneObject();
- }
-
- if ( OnStage() )
- {
- // sceneObject is being used in a separate thread; queue a message to set
- SetMaterialMessage( mStage->GetUpdateInterface(), *mSceneObject, materialSceneObject );
- }
-}
-
-Internal::MaterialIPtr MeshAttachment::GetMaterial( ) const
-{
- Internal::MaterialIPtr material;
-
- if ( mMesh.mCustomMaterial )
- {
- material = mMesh.mCustomMaterial;
- }
- else if ( mMesh.mMaterial )
- {
- material = mMesh.mMaterial;
- }
- return material;
-}
-
-
-void MeshAttachment::DisconnectMaterial()
-{
- if ( mMesh.mCustomMaterial )
- {
- mMesh.mCustomMaterial->Disconnect();
- }
- else if ( mMesh.mMaterial )
- {
- mMesh.mMaterial->Disconnect();
- }
-}
-
-void MeshAttachment::BindBonesToMesh( Internal::ActorPtr rootActor )
-{
- size_t boneIdx = 0;
- size_t boneCount = mMesh.mBoneNames.size();
-
- if ( boneCount > 0 )
- {
- for ( BoneNamesIter boneIter=mMesh.mBoneNames.begin(); boneIter != mMesh.mBoneNames.end(); ++boneIter )
- {
- ActorPtr boneActor = rootActor->FindChildByName( *boneIter );
- if ( boneActor )
- {
- ConnectBoneActor( boneActor, boneIdx, boneCount );
- boneIdx++;
- }
- }
- }
-}
-
-void MeshAttachment::ConnectBoneActor( Internal::ActorPtr boneActor,
- size_t boneIdx,
- size_t boneCount )
-{
- Connector* connector = new Connector( boneActor, boneIdx, *this );
- mConnectors.PushBack( connector );
- connector->ConnectNode();
-}
-
-void MeshAttachment::OnStageConnection2()
-{
- // Ensure current materials are staged
- const SceneGraph::MeshAttachment& sceneObject = *mSceneObject;
-
- const SceneGraph::Material* materialSceneObject = NULL;
- if ( mMesh.mCustomMaterial )
- {
- mMesh.mCustomMaterial->Connect();
- materialSceneObject = mMesh.mCustomMaterial->GetSceneObject();
- }
- else if ( mMesh.mMaterial )
- {
- mMesh.mMaterial->Connect();
- materialSceneObject = mMesh.mMaterial->GetSceneObject();
- }
- DALI_ASSERT_DEBUG( materialSceneObject );
-
- // And that the scene object has a connection to each material
- SetMaterialMessage( mStage->GetUpdateInterface(), sceneObject, materialSceneObject );
-
- // Ensure all staged bones are reconnected
- for(ConnectorList::Iterator iter=mConnectors.Begin(); iter != mConnectors.End(); ++iter)
- {
- Connector* connector = (*iter);
- connector->ConnectNode();
- }
-}
-
-void MeshAttachment::OnStageDisconnection2()
-{
- DisconnectMaterial();
-}
-
-const SceneGraph::RenderableAttachment& MeshAttachment::GetSceneObject() const
-{
- DALI_ASSERT_DEBUG( mSceneObject != NULL );
- return *mSceneObject;
-}
-
-void MeshAttachment::SetBoneNode( SceneGraph::Node* node, size_t boneIdx )
-{
- size_t boneCount = mMesh.mBoneNames.size();
-
- SetBoneNodeMessage( mStage->GetUpdateInterface(), *mSceneObject, node, boneIdx, boneCount );
-}
-
-// Helper class for connecting Nodes to the scene-graph MeshAttachment
-MeshAttachment::Connector::Connector(
- Internal::ActorPtr boneActor,
- size_t boneIdx,
- MeshAttachment& meshAttachment)
-: mMeshAttachment(meshAttachment),
- mActor(boneActor.Get()),
- mBoneIdx(boneIdx)
-{
- if( mActor )
- {
- mActor->AddObserver( *this );
- ConnectNode();
- }
-}
-
-MeshAttachment::Connector::~Connector()
-{
- if( mActor)
- {
- mActor->RemoveObserver( *this );
- }
-}
-
-void MeshAttachment::Connector::SceneObjectAdded( Object& object )
-{
- ConnectNode();
-}
-
-void MeshAttachment::Connector::SceneObjectRemoved( Object& object )
-{
- ConnectNode();
-}
-
-void MeshAttachment::Connector::ObjectDestroyed( Object& object )
-{
- mActor = NULL;
-
- ConnectNode();
-}
-
-void MeshAttachment::Connector::ConnectNode()
-{
- SceneGraph::Node* theNode( NULL );
-
- if( mActor != NULL )
- {
- const SceneGraph::PropertyOwner* object = mActor->GetSceneObject();
- if ( NULL != object )
- {
- const SceneGraph::Node* aNode = dynamic_cast< const SceneGraph::Node* >( object );
- if( aNode != NULL )
- {
- theNode = const_cast< SceneGraph::Node* >( aNode );
- }
- }
- }
-
- mMeshAttachment.SetBoneNode( theNode, mBoneIdx );
-}
-
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_MESH_ATTACHMENT_H__
-#define __DALI_INTERNAL_MESH_ATTACHMENT_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/geometry/mesh.h>
-#include <dali/public-api/modeling/material.h>
-#include <dali/internal/common/owner-container.h>
-#include <dali/internal/event/actors/actor-declarations.h>
-#include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
-#include <dali/internal/event/actor-attachments/renderable-attachment-impl.h>
-#include <dali/internal/event/modeling/mesh-impl.h>
-#include <dali/internal/event/modeling/material-impl.h>
-#include <dali/internal/event/resources/resource-ticket.h>
-#include <dali/internal/event/common/object-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-class MeshAttachment;
-class Node;
-}
-
-typedef std::vector<std::string> BoneNames;
-typedef BoneNames::const_iterator BoneNamesIter;
-
-/**
- * An attachment for rendering a 3D mesh with a material.
- */
-class MeshAttachment : public RenderableAttachment
-{
-public:
-
- struct MeshAndCustomMaterial
- {
- Internal::MeshIPtr mMesh;
- Internal::MaterialIPtr mMaterial;
- Internal::MaterialIPtr mCustomMaterial;
- BoneNames mBoneNames;
- };
-
- /**
- * Create an initialised MeshAttachment.
- * @param[in] stage The stage to use for messaging
- * @param[in] parentNode The node to attach a scene-object to.
- * This will not be displayed until a mesh is added with SetMesh().
- * @return A handle to a newly allocated Dali resource.
- */
- static MeshAttachmentPtr New( Stage& stage, const SceneGraph::Node& parentNode );
-
- /**
- * Set the mesh to be rendererd by this attachment
- * @param[in] meshPtr A mesh impl (may be null)
- * @param[in] meshId The resource id of the mesh
- * @param[in] bones Container of bones for this mesh
- * @param[in] material The material
- */
- void SetMesh( const MeshIPtr meshPtr,
- ResourceId meshId,
- const BoneContainer& bones,
- const MaterialIPtr material );
-
- /**
- * Add a mesh to the collection of meshes being rendered by this attachment
- * @param [in] meshResource A mesh resource
- * @param[in] bones Container of bones for this mesh
- * @param [in] material Material
- */
- void SetMesh( const ResourceTicketPtr meshResource,
- const BoneContainer& bones,
- const MaterialIPtr material );
-
- /**
- * Set the material of the mesh
- * @param[in] materialPtr - a custom material to apply to this mesh
- */
- void SetMaterial( Internal::MaterialIPtr materialPtr );
-
- /**
- * Get the material of the mesh
- * @return The internal material pointer
- */
- Internal::MaterialIPtr GetMaterial( ) const;
-
- /**
- * Disconnect any connected material from the mesh
- */
- void DisconnectMaterial( );
-
- /**
- * Search the actor tree for all named bones in the mesh and connect them.
- * @param[in] rootActor - the root actor of the actor tree.
- */
- void BindBonesToMesh( Internal::ActorPtr rootActor );
-
- /**
- * Connects a boneActor to the mesh (allows the mesh renderer to do
- * skeletal animation by calculating the actor transforms)
- * @param[in] boneActor - the actor containing the bone's current position
- * @param[in] boneIdx - the index of the bone in this mesh
- * @param[in] boneCount - the bone count
- */
- void ConnectBoneActor( Internal::ActorPtr boneActor, size_t boneIdx, size_t boneCount );
-
- const MeshAndCustomMaterial& GetMesh() const
- {
- return mMesh;
- }
-
-protected:
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~MeshAttachment();
-
-private:
-
- /**
- * First stage construction of a MeshAttachment.
- * @param[in] stage Used to send messages to scene-graph.
- */
- MeshAttachment( Stage& stage );
-
- /**
- * @copydoc Dali::Internal::RenderableAttachment::OnStageConnection2()
- */
- virtual void OnStageConnection2();
-
- /**
- * @copydoc Dali::Internal::RenderableAttachment::OnStageDisconnection2()
- */
- virtual void OnStageDisconnection2();
-
- /**
- * @copydoc Dali::Internal::RenderableAttachment::GetSceneObject()
- */
- virtual const SceneGraph::RenderableAttachment& GetSceneObject() const;
-
-protected:
- /**
- * Set the node for given bone index in the scene graph object
- * @param[in] node The node to set
- * @param[in] boneIdx The bone index
- */
- void SetBoneNode( SceneGraph::Node* node, size_t boneIdx );
-
- /**
- * Helper class for connecting Nodes to the scene-graph MeshAttachment
- */
- class Connector : public Object::Observer
- {
- public:
- /**
- * Create the helper class
- */
- Connector( Internal::ActorPtr boneActor, size_t boneIdx, MeshAttachment& meshAttachment);
-
- /**
- * Copy constructor required for vector storage
- */
- Connector(const Connector&);
-
- /**
- * Assignment constructor required for vector storage
- */
- Connector& operator=(const Connector& rhs);
-
- /**
- * Destructor
- */
- ~Connector();
-
- /**
- * Update the scene-graph mesh attachment with this node
- */
- void ConnectNode();
-
- public: // From Object::Observer
-
- /**
- * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded
- */
- virtual void SceneObjectAdded( Object& object );
-
- /**
- * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded
- */
- virtual void SceneObjectRemoved( Object& object );
-
- /**
- * @copydoc Dali::Internal::Object::Observer::ObjectDestroyed
- */
- virtual void ObjectDestroyed( Object& object );
-
- public:
- MeshAttachment& mMeshAttachment; ///< Parent
- Actor* mActor; ///< Raw-pointer to the actor; not owned.
- size_t mBoneIdx; ///< Index of the bone with which this connecter is associated
- };
- typedef OwnerContainer< Connector* > ConnectorList;
-
-private:
-
- const SceneGraph::MeshAttachment* mSceneObject; ///< Not owned
-
- MeshAndCustomMaterial mMesh;
- ConnectorList mConnectors;
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_MESH_ATTACHMENT_H__
class CustomActor;
class ImageActor;
class Layer;
-class MeshActor;
class TextActor;
typedef IntrusivePtr<Actor> ActorPtr;
typedef IntrusivePtr<CustomActor> CustomActorPtr;
typedef IntrusivePtr<ImageActor> ImageActorPtr;
typedef IntrusivePtr<Layer> LayerPtr;
-typedef IntrusivePtr<MeshActor> MeshActorPtr;
typedef IntrusivePtr<TextActor> TextActorPtr;
} // namespace Internal
}
}
-void Actor::SetInitialVolume(const Vector3& volume)
-{
- if( NULL != mNode )
- {
- // mNode is being used in a separate thread; queue a message to set the value
- SetInitialVolumeMessage( mStage->GetUpdateInterface(), *mNode, volume );
- }
-}
-
-void Actor::SetTransmitGeometryScaling(bool transmitGeometryScaling)
-{
- if( NULL != mNode )
- {
- // mNode is being used in a separate thread; queue a message to set the value
- SetTransmitGeometryScalingMessage( mStage->GetUpdateInterface(), *mNode, transmitGeometryScaling );
- }
-}
-
-bool Actor::GetTransmitGeometryScaling() const
-{
- if( NULL != mNode )
- {
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode->GetTransmitGeometryScaling();
- }
-
- return false;
-}
-
void Actor::ScaleBy(const Vector3& relativeScale)
{
if( NULL != mNode )
bool IsOverlay() const;
/**
- * Sets whether an actor transmits geometry scaling to it's children.
- * The default value is for it not to transmit scaling.
- * @param[in] transmitGeometryScaling True to transmit scaling.
- */
- void SetTransmitGeometryScaling(bool transmitGeometryScaling);
-
- /**
- * Get the TransmitGeometryScaling property for this actor.
- * @return True if geometry scaling is applied to the inherited scale.
- */
- bool GetTransmitGeometryScaling() const;
-
- /**
- * Sets the initial volume of the actor. Used for scaling the
- * actor appropriately as the actor is sized when transmitGeometryScaling
- * is set to true.
- *
- * @param[in] volume the volume of the model and it's children
- */
- void SetInitialVolume(const Vector3& volume);
-
- /**
* Sets the actor's color. The final color of actor depends on its color mode.
* This final color is applied to the drawable elements of an actor.
* @param [in] color The new color.
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/actors/mesh-actor-impl.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/modeling/animatable-mesh-impl.h>
-#include <dali/internal/event/modeling/mesh-impl.h>
-
-namespace Dali
-{
-
-using Internal::MeshIter;
-using Internal::MeshIPtr;
-using Internal::MaterialIPtr;
-
-namespace Internal
-{
-
-namespace
-{
-
-BaseHandle Create()
-{
- return Dali::MeshActor::New();
-}
-
-TypeRegistration mType( typeid(Dali::MeshActor), typeid(Dali::RenderableActor), Create );
-
-}
-
-MeshActorPtr MeshActor::New()
-{
- MeshActorPtr actor(new MeshActor());
-
- // Second-phase construction
- actor->Initialize();
-
- // Create the attachment
- actor->mMeshAttachment = MeshAttachment::New( *actor->mStage, *actor->mNode );
- actor->Attach(*actor->mMeshAttachment);
- actor->SetCullFace( Dali::CullBack );
-
- return actor;
-}
-
-MeshActorPtr MeshActor::New(Dali::Mesh mesh)
-{
- MeshActorPtr actor = MeshActor::New();
-
- if(actor)
- {
- actor->SetMesh(mesh);
- }
-
- return actor;
-}
-
-MeshActorPtr MeshActor::New(Dali::AnimatableMesh mesh)
-{
- MeshActorPtr actor = MeshActor::New();
-
- if(actor)
- {
- actor->SetMesh(mesh);
- }
-
- return actor;
-}
-
-MeshActor::MeshActor()
-: RenderableActor()
-{
-}
-
-MeshActor::~MeshActor()
-{
-}
-
-void MeshActor::SetMesh(Dali::Mesh mesh)
-{
- SetMesh( &GetImplementation(mesh) );
-}
-
-void MeshActor::SetMesh(Dali::AnimatableMesh mesh)
-{
- mAnimatableMeshHandle = mesh;
- SetMesh( GetImplementation(mesh).GetMesh() );
-
- SetInitialVolume(Vector3(1.0f, 1.0f, 1.0f));
-}
-
-void MeshActor::SetMesh( MeshIPtr meshPtr )
-{
- mMeshAttachment->SetMesh( meshPtr, meshPtr->GetResourceId(), meshPtr->GetBones(), meshPtr->GetMaterial() );
-}
-
-void MeshActor::SetMaterial(const Dali::Material material)
-{
- MaterialIPtr materialPtr = const_cast<Internal::Material*>(&GetImplementation(material));
- mMeshAttachment->SetMaterial(materialPtr);
-}
-
-Dali::Material MeshActor::GetMaterial() const
-{
- Dali::Material material;
-
- Internal::MaterialIPtr internalPtr = mMeshAttachment->GetMaterial( );
-
- if(internalPtr)
- {
- material = Dali::Material(internalPtr.Get());
- }
-
- return material;
-}
-
-void MeshActor::BindBonesToMesh(Internal::ActorPtr rootActor)
-{
- mMeshAttachment->BindBonesToMesh(rootActor);
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_MESH_ACTOR_H__
-#define __DALI_INTERNAL_MESH_ACTOR_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <cstddef>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/handle.h>
-#include <dali/public-api/actors/mesh-actor.h>
-#include <dali/public-api/geometry/mesh.h>
-#include <dali/internal/event/actors/actor-impl.h>
-#include <dali/internal/event/actors/actor-declarations.h>
-#include <dali/internal/event/modeling/material-impl.h>
-#include <dali/internal/event/actor-attachments/mesh-attachment-impl.h>
-#include <dali/internal/event/actors/renderable-actor-impl.h>
-
-namespace Dali
-{
-class Mesh;
-
-
-namespace Internal
-{
-
-class MeshActor : public RenderableActor
-{
-public:
-
- /**
- * Create an un-intialised mesh actor
- * @return A smart-pointer to a newly allocated mesh actor
- */
- static MeshActorPtr New();
-
- /**
- * Create an intialised mesh actor from the given mesh
- * @param[in] mesh An object containing mesh data
- * @return A smart-pointer to a newly allocated mesh actor
- */
- static MeshActorPtr New(Dali::Mesh mesh);
-
- /**
- * Create an intialised mesh actor from the given mesh
- * @param[in] mesh An object containing mesh data
- * @return A smart-pointer to a newly allocated mesh actor
- */
- static MeshActorPtr New(Dali::AnimatableMesh mesh);
-
-public:
-
- /**
- * Add a mesh to this actor.
- * @param[in] mesh A mesh structure
- */
- void SetMesh(Dali::Mesh mesh);
-
- /**
- * Add an animated mesh to this actor
- * @param[in] mesh An animatable mesh
- */
- void SetMesh(Dali::AnimatableMesh mesh);
-
- /**
- * Add a mesh resource to this actor
- * @param[in] mesh A mesh resource
- */
- void SetMesh(MeshIPtr meshPtr);
-
- /**
- * @copydoc Dali::MeshActor::SetMaterial(Material material)
- */
- void SetMaterial(const Dali::Material material);
-
- /**
- * Get a material for a given mesh.
- * @return The material
- */
- Dali::Material GetMaterial() const;
-
- /**
- * Search the actor tree for all named bones in the mesh array and connect them.
- * @param[in] rootActor - the root actor of the actor tree.
- */
- void BindBonesToMesh(Internal::ActorPtr rootActor);
-
-private: // From RenderableActor
-
- /**
- * @copydoc RenderableActor::GetRenderableAttachment
- */
- virtual RenderableAttachment& GetRenderableAttachment() const
- {
- DALI_ASSERT_DEBUG( mMeshAttachment );
- return *mMeshAttachment;
- }
-
-protected:
- /**
- * Protected constructor; see also MeshActor::New()
- */
- MeshActor();
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~MeshActor();
-
-private:
- Internal::MeshAttachmentPtr mMeshAttachment;
- // To keep a reference to the AnimatableMesh so it would not be destroyed before the MeshActor object
- Dali::Handle mAnimatableMeshHandle;
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::MeshActor& GetImplementation(Dali::MeshActor& meshActor)
-{
- DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
-
- BaseObject& handle = meshActor.GetBaseObject();
-
- return static_cast<Internal::MeshActor&>(handle);
-}
-
-inline const Internal::MeshActor& GetImplementation(const Dali::MeshActor& meshActor)
-{
- DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
-
- const BaseObject& handle = meshActor.GetBaseObject();
-
- return static_cast<const Internal::MeshActor&>(handle);
-}
-
-} // namespace Internal
-
-#endif // __DALI_INTERNAL_MESH_ACTOR_H__
mShape = new DynamicsCylinderShape(dimensions.x, dimensions.y);
break;
}
+ @todo Remove cloth handling
case Dali::DynamicsShape::MESH:
{
- Dali::Cloth cloth = Dali::Cloth::New( dimensions.x, dimensions.y, dimensions.z, dimensions.z );
- mShape = new DynamicsMeshShape( GetImplementation(cloth) );
+ mShape = new DynamicsCubeShape(dimensions);
break;
}
case Dali::DynamicsShape::SPHERE:
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/dynamics/dynamics-mesh-shape-impl.h>
-
-// INTERNAL HEADERS
-#include <dali/integration-api/debug.h>
-#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/event/dynamics/dynamics-world-impl.h>
-#include <dali/internal/event/modeling/mesh-impl.h>
-#include <dali/internal/update/dynamics/scene-graph-dynamics-mesh-shape.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-DynamicsMeshShape::DynamicsMeshShape(Mesh& mesh)
-: DynamicsShape(Dali::DynamicsShape::MESH),
- mMesh( mesh )
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- StagePtr stage( Stage::GetCurrent() );
- DynamicsWorldPtr world( stage->GetDynamicsWorld() );
- DALI_ASSERT_ALWAYS( world && "No Dynamics World !");
- ResourceManager& resourceManager( ThreadLocalStorage::Get().GetResourceManager() );
-
- SceneGraph::DynamicsMeshShape* meshShape( new SceneGraph::DynamicsMeshShape( *world->GetSceneObject(), resourceManager, mMesh.GetResourceId()) );
- mDynamicsShape = meshShape;
-
- // Queue a message to ensure the underlying dynamics object is created in the update thread
- InitializeDynamicsMeshShapeMessage( stage->GetUpdateInterface(), *meshShape );
-}
-
-DynamicsMeshShape::~DynamicsMeshShape()
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__);
-}
-
-Vector3 DynamicsMeshShape::GetAABB() const
-{
- return Vector3();
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DYNAMICS_MESH_SHAPE_IMPL_H_
-#define __DYNAMICS_MESH_SHAPE_IMPL_H_
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// BASE CLASS HEADERS
-#include <dali/internal/event/dynamics/dynamics-shape-impl.h>
-
-// INTERNAL HEADERS
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/dynamics/dynamics-declarations.h>
-#include <dali/internal/event/modeling/modeling-declarations.h>
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class Mesh;
-
-/**
- * A triangular mesh
- */
-class DynamicsMeshShape : public DynamicsShape
-{
-public:
- /**
- * Constructor
- * @copydoc Dali::DynamicsShape::NewMesh
- */
- DynamicsMeshShape(Mesh& mesh);
-
-protected:
- /**
- * Destructor
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~DynamicsMeshShape();
-
-private:
- // unimplemented copy constructor and assignment operator
- DynamicsMeshShape(const DynamicsMeshShape&);
- DynamicsMeshShape& operator=(const DynamicsMeshShape&);
-
-public:
- /**
- * Get an axis aligned bounding box for this shape
- * @return An axis aligned bounding box for this shape
- */
- virtual Vector3 GetAABB() const;
-
- /**
- * Get the mesh
- */
- Mesh& GetMesh()
- {
- return mMesh;
- }
-
-private:
- Mesh& mMesh;
-}; // class DynamicsMeshShape
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif /* __DYNAMICS_MESH_SHAPE_IMPL_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/modeling/animatable-mesh-impl.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/common/property-helper.h>
-#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/modeling/material-impl.h>
-#include <dali/internal/event/modeling/mesh-impl.h>
-#include <dali/internal/update/manager/update-manager.h>
-#include <dali/internal/update/modeling/scene-graph-animatable-mesh.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace
-{
-
-// Properties
-
-// Name Type writable animatable constraint-input enum for index-checking
-DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "position", VECTOR3, true, true, true, Dali::AnimatableVertex::Property::Position )
-DALI_PROPERTY( "vertex-color", VECTOR4, true, true, true, Dali::AnimatableVertex::Property::Color )
-DALI_PROPERTY( "texture-coords", VECTOR2, true, true, true, Dali::AnimatableVertex::Property::TextureCoords )
-DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX )
-
-} // namespace
-
-AnimatableMesh::AnimatableMesh(
- SceneGraph::UpdateManager& updateManager,
- SceneGraph::AnimatableMesh* sceneObject,
- MeshIPtr mesh,
- int numberOfVertices )
-: mUpdateManager( updateManager ),
- mSceneObject( sceneObject ),
- mMesh( mesh ),
- mNumberOfVertices( numberOfVertices ),
- mPropertyCount( numberOfVertices * DEFAULT_PROPERTY_COUNT )
-{
- // Transfer animatable ownership to a scene message
- AddAnimatableMeshMessage( mUpdateManager, *mSceneObject );
-}
-
-AnimatableMeshPtr AnimatableMesh::New(
- unsigned int numVertices,
- const Dali::AnimatableMesh::Faces& faceIndices )
-{
- return New( numVertices, faceIndices, Dali::Material::New("dummy material"), true );
-}
-
-AnimatableMeshPtr AnimatableMesh::New(
- unsigned int numVertices,
- const Dali::AnimatableMesh::Faces& faceIndices,
- Dali::Material material)
-{
- return New( numVertices, faceIndices, material, false );
-}
-
-AnimatableMeshPtr AnimatableMesh::New(
- unsigned int numVertices,
- const Dali::AnimatableMesh::Faces& faceIndices,
- Dali::Material material,
- bool useVertexColor )
-{
- DALI_ASSERT_ALWAYS( numVertices > 0 && "Mesh has no vertices" );
- DALI_ASSERT_ALWAYS( ( numVertices * 3 ) < DEFAULT_PROPERTY_MAX_COUNT && "Mesh exceeds maximum supported vertices" );
- DALI_ASSERT_ALWAYS( faceIndices.size() > 0 && "Mesh has no faces" );
- for( Dali::AnimatableMesh::FacesConstIter faceIter=faceIndices.begin();
- faceIter != faceIndices.end();
- ++faceIter )
- {
- unsigned int faceIndex = *faceIter;
- DALI_ASSERT_ALWAYS( faceIndex < numVertices && "Face index out of range" );
- }
-
- ThreadLocalStorage& tls = ThreadLocalStorage::Get();
- SceneGraph::UpdateManager& updateManager = tls.GetUpdateManager();
- ResourceManager& resourceManager = tls.GetResourceManager();
-
- Dali::MeshData meshData;
-
- // We need a valid mesh data object to create the scene graph mesh
- Dali::MeshData::VertexContainer vertices( numVertices );
- BoneContainer bones;
- meshData.SetData(vertices, faceIndices, bones, material);
- bool useColor = false;
- if(useVertexColor)
- {
- useColor=true;
- }
- meshData.SetHasColor(useColor);
- meshData.SetHasNormals(false);
- meshData.SetHasTextureCoords(true);
-
- MeshIPtr mesh( Mesh::New( meshData, false /* not discardable, data is updated in the update thread */, true /* Scaling is required */ ) );
-
- // Create the scene object
- SceneGraph::AnimatableMesh* sceneObject = new SceneGraph::AnimatableMesh( resourceManager, mesh->GetResourceId(), meshData.GetVertices() );
-
- // Create the event object
- AnimatableMeshPtr animatableMeshPtr( new AnimatableMesh( updateManager, sceneObject, mesh, meshData.GetVertexCount() ) );
-
- return animatableMeshPtr;
-}
-
-AnimatableMesh::~AnimatableMesh()
-{
- // Guard to allow handle destruction after Core has been destroyed
- if ( Stage::IsInstalled() )
- {
- if( mSceneObject )
- {
- RemoveAnimatableMeshMessage( mUpdateManager, *mSceneObject );
- }
- }
-}
-
-unsigned int AnimatableMesh::GetNumberOfVertices() const
-{
- return mNumberOfVertices;
-}
-
-Property::Index AnimatableMesh::GetVertexPropertyIndex(
- unsigned int vertex,
- Property::Index property ) const
-{
- DALI_ASSERT_DEBUG(property < DEFAULT_PROPERTY_COUNT );
- return ( vertex * DEFAULT_PROPERTY_COUNT ) + property;
-}
-
-void AnimatableMesh::SetPosition( unsigned int vertexIndex, const Vector3& position)
-{
- StagePtr stage = Stage::GetCurrent();
- BakeVertexPositionMessage( stage->GetUpdateInterface(), *mSceneObject, vertexIndex, position );
-}
-
-void AnimatableMesh::SetColor( unsigned int vertexIndex, const Vector4& color)
-{
- StagePtr stage = Stage::GetCurrent();
- BakeVertexColorMessage( stage->GetUpdateInterface(), *mSceneObject, vertexIndex, color );
-}
-
-void AnimatableMesh::SetTextureCoords( unsigned int vertexIndex, const Vector2& coords)
-{
- StagePtr stage = Stage::GetCurrent();
- BakeVertexTextureCoordsMessage( stage->GetUpdateInterface(), *mSceneObject, vertexIndex, coords );
-}
-
-const Vector3& AnimatableMesh::GetCurrentPosition( unsigned int vertexIndex) const
-{
- StagePtr stage = Stage::GetCurrent();
- return mSceneObject->GetPosition(stage->GetEventBufferIndex(), vertexIndex);
-}
-
-const Vector4& AnimatableMesh::GetCurrentColor( unsigned int vertexIndex) const
-{
- StagePtr stage = Stage::GetCurrent();
- return mSceneObject->GetColor(stage->GetEventBufferIndex(), vertexIndex);
-}
-
-const Vector2& AnimatableMesh::GetCurrentTextureCoords( unsigned int vertexIndex) const
-{
- StagePtr stage = Stage::GetCurrent();
- return mSceneObject->GetTextureCoords(stage->GetEventBufferIndex(), vertexIndex);
-}
-
-MeshIPtr AnimatableMesh::GetMesh()
-{
- return mMesh;
-}
-
-/********************************************************************************
- ********************************************************************************
- ******************************** PROPERTY METHODS **************************
- ********************************************************************************
- ********************************************************************************/
-
-bool AnimatableMesh::Supports( Capability capability ) const
-{
- return false; // The scene object is permanently "on stage" whilst this object is alive
-}
-
-unsigned int AnimatableMesh::GetDefaultPropertyCount() const
-{
- return mPropertyCount;
-}
-
-void AnimatableMesh::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
- indices.reserve( mPropertyCount );
-
- for ( int i = 0; i < mPropertyCount; ++i )
- {
- indices.push_back( i );
- }
-}
-
-const char* AnimatableMesh::GetDefaultPropertyName( Property::Index index ) const
-{
- if ( ( index >= 0 ) && ( index < mPropertyCount ) )
- {
- return DEFAULT_PROPERTY_DETAILS[index % DEFAULT_PROPERTY_COUNT].name;
- }
- else
- {
- return NULL;
- }
-}
-
-Property::Index AnimatableMesh::GetDefaultPropertyIndex(const std::string& name) const
-{
- Property::Index index = Property::INVALID_INDEX;
-
- // Look for name in default properties
- for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
- {
- const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ];
- if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string
- {
- index = i;
- break;
- }
- }
- return index;
-}
-
-bool AnimatableMesh::IsDefaultPropertyWritable(Property::Index index) const
-{
- return DEFAULT_PROPERTY_DETAILS[ index % DEFAULT_PROPERTY_COUNT ].writable;
-}
-
-bool AnimatableMesh::IsDefaultPropertyAnimatable(Property::Index index) const
-{
- return DEFAULT_PROPERTY_DETAILS[ index % DEFAULT_PROPERTY_COUNT ].animatable;
-}
-
-bool AnimatableMesh::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
- return DEFAULT_PROPERTY_DETAILS[ index % DEFAULT_PROPERTY_COUNT ].constraintInput;
-}
-
-Property::Type AnimatableMesh::GetDefaultPropertyType(Property::Index index) const
-{
- if ( ( index >= 0 ) && ( index < mPropertyCount ) )
- {
- return DEFAULT_PROPERTY_DETAILS[ index % DEFAULT_PROPERTY_COUNT ].type;
- }
-
- // Index out-of-bounds
- return Property::NONE;
-}
-
-void AnimatableMesh::SetDefaultProperty( Property::Index index, const Property::Value& property )
-{
- DALI_ASSERT_ALWAYS( ( index < mPropertyCount ) && "Property index out of bounds" );
-
- int vertexProperty = index % DEFAULT_PROPERTY_COUNT;
- int vertexIndex = index / DEFAULT_PROPERTY_COUNT;
- switch ( vertexProperty )
- {
- case Dali::AnimatableVertex::Property::Position:
- {
- SetPosition( vertexIndex, property.Get<Vector3>() );
- break;
- }
- case Dali::AnimatableVertex::Property::Color:
- {
- SetColor( vertexIndex, property.Get<Vector4>() );
- break;
- }
- case Dali::AnimatableVertex::Property::TextureCoords:
- {
- SetTextureCoords( vertexIndex, property.Get<Vector2>() );
- break;
- }
- default:
- {
- // nothing to do
- break;
- }
- }
-}
-
-Property::Value AnimatableMesh::GetDefaultProperty(Property::Index index) const
-{
- Property::Value value;
- int vertexProperty = index % DEFAULT_PROPERTY_COUNT;
- int vertexIndex = index / DEFAULT_PROPERTY_COUNT;
-
- switch ( vertexProperty )
- {
- case Dali::AnimatableVertex::Property::Position:
- {
- value = GetCurrentPosition(vertexIndex);
- break;
- }
- case Dali::AnimatableVertex::Property::Color:
- {
- value = GetCurrentColor(vertexIndex);
- break;
- }
- case Dali::AnimatableVertex::Property::TextureCoords:
- {
- value = GetCurrentTextureCoords(vertexIndex);
- break;
- }
- default:
- {
- // nothing to do
- break;
- }
- }
-
- return value;
-}
-
-const SceneGraph::PropertyOwner* AnimatableMesh::GetSceneObject() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyBase* AnimatableMesh::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
-
- const SceneGraph::PropertyBase* property( NULL );
-
- // This method should only return a property which is part of the scene-graph
- if( mSceneObject != NULL )
- {
- int vertexProperty = index % DEFAULT_PROPERTY_COUNT;
- int vertexIndex = index / DEFAULT_PROPERTY_COUNT;
-
- switch ( vertexProperty )
- {
- case Dali::AnimatableVertex::Property::Position:
- property = &mSceneObject->mVertices[vertexIndex].position;
- break;
- case Dali::AnimatableVertex::Property::Color:
- property = &mSceneObject->mVertices[vertexIndex].color;
- break;
- case Dali::AnimatableVertex::Property::TextureCoords:
- property = &mSceneObject->mVertices[vertexIndex].textureCoords;
- break;
- }
- }
-
- return property;
-}
-
-const PropertyInputImpl* AnimatableMesh::GetSceneObjectInputProperty( Property::Index index ) const
-{
- const PropertyInputImpl* property( NULL );
- if( mSceneObject != NULL )
- {
- int vertexProperty = index % DEFAULT_PROPERTY_COUNT;
- int vertexIndex = index / DEFAULT_PROPERTY_COUNT;
-
- switch ( vertexProperty )
- {
- case Dali::AnimatableVertex::Property::Position:
- property = &mSceneObject->mVertices[vertexIndex].position;
- break;
- case Dali::AnimatableVertex::Property::Color:
- property = &mSceneObject->mVertices[vertexIndex].color;
- break;
- case Dali::AnimatableVertex::Property::TextureCoords:
- property = &mSceneObject->mVertices[vertexIndex].textureCoords;
- break;
- }
- }
-
- return property;
-}
-
-} // internal
-} // dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ANIMATABLE_MESH_EFFECT_H__
-#define __DALI_INTERNAL_ANIMATABLE_MESH_EFFECT_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/geometry/animatable-mesh.h>
-#include <dali/internal/event/common/object-impl.h>
-#include <dali/internal/event/modeling/modeling-declarations.h>
-
-namespace Dali
-{
-namespace Internal
-{
-class AnimatableMesh;
-typedef IntrusivePtr<AnimatableMesh> AnimatableMeshPtr;
-
-namespace SceneGraph
-{
-class UpdateManager;
-class AnimatableMesh;
-}
-
-
-class AnimatableMesh : public Object
-{
-public:
- /**
- * Constructor
- * @param[in] updateManager
- * @param[in] sceneObject - pointer to a newly created scene object
- * @param[in] mesh - pointer to a newly created Mesh object
- * @param[in] numberOfVertices - The number of vertices to create
- */
- AnimatableMesh( SceneGraph::UpdateManager& updateManager,
- SceneGraph::AnimatableMesh* sceneObject,
- MeshIPtr mesh,
- int numberOfVertices );
-
- /**
- * Construct an animated mesh. Uses vertex color
- */
- static AnimatableMeshPtr New( unsigned int numVertices,
- const Dali::AnimatableMesh::Faces& faceIndices );
-
- /**
- * Construct an animated mesh. Uses material
- */
- static AnimatableMeshPtr New( unsigned int numVertices,
- const Dali::AnimatableMesh::Faces& faceIndices,
- Dali::Material material);
-
- /**
- * Catch-all constructor. Performs all checks on input data
- */
- static AnimatableMeshPtr New( unsigned int numVertices,
- const Dali::AnimatableMesh::Faces& faceIndices,
- Dali::Material material,
- bool useColor );
-
- /**
- * Destructor
- */
- ~AnimatableMesh();
-
- /**
- * Return the number of vertices in the mesh
- * @return vertexNumber
- */
- unsigned int GetNumberOfVertices() const;
-
- /**
- * Get the property index from the vertex index and the vertex property enumeration
- */
- Property::Index GetVertexPropertyIndex( unsigned int vertex, Property::Index property ) const;
-
- /**
- * Set the given vertex position
- */
- void SetPosition( unsigned int vertexIndex, const Vector3& position);
-
- /**
- * Set the given vertex color. Note, alpha is ignored with current internal vertex format
- */
- void SetColor( unsigned int vertexIndex, const Vector4& color);
-
- /**
- * Set the given texture coords.
- */
- void SetTextureCoords( unsigned int vertexIndex, const Vector2& coords);
-
- /**
- * Get the current position of the vertex
- */
- const Vector3& GetCurrentPosition( unsigned int vertexIndex) const;
-
- /**
- * Get the current color of the vertex
- */
- const Vector4& GetCurrentColor( unsigned int vertexIndex) const;
-
- /**
- * Get the current texture coord of the vertex
- */
- const Vector2& GetCurrentTextureCoords( unsigned int vertexIndex) const;
-
- /**
- * Set whether the mesh should use the vertex color property or not.
- * If it uses the vertex colors, then the material is not used for rendering.
- */
- void SetUseColor(bool color);
-
- /**
- * Get whether the mesh should use the color property or not
- * @return true if the mesh is using vertex colors
- */
- bool GetUseColor();
-
- /**
- * Set whether the mesh should use the vertex TextureCoords property or not.
- * If it uses the vertex TextureCoords, then the material is not used for rendering.
- */
- void SetUseTextureCoords(bool TextureCoords);
-
- /**
- * Get whether the mesh should use the TextureCoords property or not
- * @return true if the mesh is using vertex texture coords
- */
- bool GetUseTextureCoords();
-
-
- // Intended for internal use only.
- MeshIPtr GetMesh();
-
-public: // Implementation of Object
- /**
- * @copydoc Dali::Internal::Object::Supports()
- */
- virtual bool Supports( Capability capability ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
- */
- virtual unsigned int GetDefaultPropertyCount() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
- */
- virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
- */
- virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
- */
- virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
- */
- virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
- */
- virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
- */
- virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
- */
- virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
-private:
- AnimatableMesh( const AnimatableMesh& );
- AnimatableMesh operator=(const AnimatableMesh& rhs);
-
-private:
- SceneGraph::UpdateManager& mUpdateManager; ///< The update manager
- SceneGraph::AnimatableMesh* mSceneObject; ///< The mesh property owner
- MeshIPtr mMesh; ///< The mesh ticket holder
-
- unsigned int mNumberOfVertices;
- int mPropertyCount;
-
-};
-
-}//Internal
-
-inline Internal::AnimatableMesh& GetImplementation(Dali::AnimatableMesh& animatableMesh)
-{
- DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
- BaseObject& handle = animatableMesh.GetBaseObject();
- return static_cast<Internal::AnimatableMesh&>(handle);
-}
-
-inline const Internal::AnimatableMesh& GetImplementation(const Dali::AnimatableMesh& animatableMesh)
-{
- DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
- const BaseObject& handle = animatableMesh.GetBaseObject();
- return static_cast<const Internal::AnimatableMesh&>(handle);
-}
-
-}//Dali
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/modeling/cloth-impl.h>
-
-// EXTERNAL INCLUDES
-#include <stdio.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/modeling/mesh-impl.h>
-
-namespace Dali
-{
-namespace Internal
-{
-
-ClothIPtr Cloth::New( const Dali::MeshData& meshData )
-{
- ClothIPtr cloth( new Cloth( meshData ) );
- return cloth;
-}
-
-Cloth::Cloth( const Dali::MeshData& publicMeshData )
-: Mesh( publicMeshData, false /* not discardable */, false /* not scalable */ )
-{
-}
-
-Cloth::~Cloth()
-{
-}
-
-} // namespace Internal
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_CLOTH_H__
-#define __DALI_INTERNAL_CLOTH_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/geometry/cloth.h>
-#include <dali/internal/event/modeling/mesh-impl.h>
-
-namespace Dali
-{
-class MeshData;
-
-namespace Internal
-{
-class Cloth;
-
-typedef IntrusivePtr<Cloth> ClothIPtr; ///< smart pointer to a Cloth
-
-/**
- * A single cloth in a 3D model
- */
-class Cloth : public Mesh
-{
-public: // construction, destruction and initialisation
-
- /**
- * Create a new cloth.
- * @param[in] clothData the mesh data
- * @return A smart-pointer to the newly allocated Cloth.
- */
- static ClothIPtr New( const Dali::MeshData& clothData );
-
- /**
- * Construct a new Cloth. This is not discardable or scalable.
- * @param[in] clothData the mesh data
- */
- Cloth( const Dali::MeshData& clothData );
-
-protected:
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Cloth();
-
-private:
- // Undefined
- Cloth(const Cloth&);
-
- // Undefined
- Cloth& operator=(const Cloth& rhs);
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Cloth& GetImplementation(Dali::Cloth& cloth)
-{
- DALI_ASSERT_ALWAYS( cloth && "Cloth handle is empty" );
-
- BaseObject& handle = cloth.GetBaseObject();
-
- return static_cast<Internal::Cloth&>(handle);
-}
-
-inline const Internal::Cloth& GetImplementation(const Dali::Cloth& cloth)
-{
- DALI_ASSERT_ALWAYS( cloth && "Cloth handle is empty" );
-
- const BaseObject& handle = cloth.GetBaseObject();
-
- return static_cast<const Internal::Cloth&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_CLOTH_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/modeling/material-impl.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/constants.h>
-#include <dali/internal/update/modeling/scene-graph-material.h>
-#include <dali/internal/common/event-to-update.h>
-#include <dali/internal/event/images/image-impl.h>
-#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-MaterialProperties::MaterialProperties()
- : mOpacity (Dali::Material::DEFAULT_OPACITY),
- mShininess (Dali::Material::DEFAULT_SHININESS),
- mAmbientColor (Dali::Material::DEFAULT_AMBIENT_COLOR),
- mDiffuseColor (Dali::Material::DEFAULT_DIFFUSE_COLOR),
- mSpecularColor (Dali::Material::DEFAULT_SPECULAR_COLOR),
- mEmissiveColor (Dali::Material::DEFAULT_EMISSIVE_COLOR),
- mMapU (Dali::Material::DEFAULT_MAPPING_MODE),
- mMapV (Dali::Material::DEFAULT_MAPPING_MODE),
- mDiffuseUVIndex (Dali::Material::DEFAULT_DIFFUSE_UV_INDEX),
- mOpacityUVIndex (Dali::Material::DEFAULT_OPACITY_UV_INDEX),
- mNormalUVIndex (Dali::Material::DEFAULT_NORMAL_UV_INDEX),
- mHasHeightMap (Dali::Material::DEFAULT_HAS_HEIGHT_MAP)
-{
-}
-
-MaterialProperties::MaterialProperties(const MaterialProperties& rhs)
- : mOpacity(rhs.mOpacity),
- mShininess(rhs.mShininess),
- mAmbientColor(rhs.mAmbientColor),
- mDiffuseColor(rhs.mDiffuseColor),
- mSpecularColor(rhs.mSpecularColor),
- mEmissiveColor(rhs.mEmissiveColor),
- mMapU(rhs.mMapU),
- mMapV(rhs.mMapV),
- mDiffuseUVIndex(rhs.mDiffuseUVIndex),
- mOpacityUVIndex(rhs.mOpacityUVIndex),
- mNormalUVIndex(rhs.mNormalUVIndex),
- mHasHeightMap(rhs.mHasHeightMap)
-{
-}
-
-MaterialProperties& MaterialProperties::operator=(const MaterialProperties& rhs)
-{
- mOpacity = rhs.mOpacity;
- mShininess = rhs.mShininess;
- mAmbientColor = rhs.mAmbientColor;
- mDiffuseColor = rhs.mDiffuseColor;
- mSpecularColor = rhs.mSpecularColor;
- mEmissiveColor = rhs.mEmissiveColor;
- mMapU = rhs.mMapU;
- mMapV = rhs.mMapV;
- mDiffuseUVIndex = rhs.mDiffuseUVIndex;
- mOpacityUVIndex = rhs.mOpacityUVIndex;
- mNormalUVIndex = rhs.mNormalUVIndex;
- mHasHeightMap = rhs.mHasHeightMap;
-
- return *this;
-}
-
-
-Material* Material::New(const std::string& name)
-{
- return new Material(name);
-}
-
-Material::Material(const std::string& name)
- : mName(name),
- mProperties(),
- mSceneObject(NULL),
- mEventToUpdate(NULL),
- mUpdateManager(NULL),
- mConnectionCount(0)
-{
-}
-
-Material::~Material()
-{
- if ( mSceneObject &&
- Stage::IsInstalled()/*Guard to allow handle destruction after Core has been destroyed*/ )
- {
- RemoveMaterialMessage( *mUpdateManager, mSceneObject );
- }
-}
-
-SceneGraph::Material* Material::CreateSceneObject()
-{
- DALI_ASSERT_DEBUG( mSceneObject == NULL );
-
- if(mEventToUpdate == NULL)
- {
- EventToUpdate& eventToUpdate = ThreadLocalStorage::Get().GetEventToUpdate();
- mEventToUpdate = &eventToUpdate;
- }
-
- if(mUpdateManager == NULL)
- {
- SceneGraph::UpdateManager& updateManager = ThreadLocalStorage::Get().GetUpdateManager();
- mUpdateManager = &updateManager;
- }
-
- mSceneObject = SceneGraph::Material::New(this);
- if( mDiffuseImage )
- {
- mSceneObject->SetDiffuseTextureId( GetImplementation(mDiffuseImage).GetResourceId() );
- }
- if( mOpacityImage )
- {
- mSceneObject->SetOpacityTextureId( GetImplementation(mOpacityImage).GetResourceId() );
- }
- if( mNormalMap )
- {
- mSceneObject->SetNormalMapId( GetImplementation(mNormalMap).GetResourceId() );
- }
- AddMaterialMessage( *mUpdateManager, mSceneObject );
-
- return mSceneObject;
-}
-
-// Used for staging material
-const SceneGraph::Material* Material::GetSceneObject()
-{
- if( mSceneObject == NULL )
- {
- mSceneObject = CreateSceneObject();
- }
- return mSceneObject;
-}
-
-void Material::Connect()
-{
- if(mConnectionCount == 0)
- {
- if( mSceneObject == NULL )
- {
- mSceneObject = CreateSceneObject();
- }
-
- if (mDiffuseImage)
- {
- GetImplementation(mDiffuseImage).Connect();
- SendDiffuseImageToSceneObject(mDiffuseImage);
- }
- if (mOpacityImage)
- {
- GetImplementation(mOpacityImage).Connect();
- SendOpacityImageToSceneObject(mOpacityImage);
- }
- if (mNormalMap)
- {
- GetImplementation(mNormalMap).Connect();
- SendNormalMapToSceneObject(mNormalMap);
- }
- }
- else
- {
- DALI_ASSERT_DEBUG(mSceneObject);
- }
- mConnectionCount++;
-}
-
-void Material::Disconnect()
-{
- if(mConnectionCount > 0)
- {
- DALI_ASSERT_DEBUG(mSceneObject);
- mConnectionCount--;
- }
-
- if(mConnectionCount <= 0)
- {
- if (mDiffuseImage)
- {
- GetImplementation(mDiffuseImage).Disconnect();
- }
- if (mOpacityImage)
- {
- GetImplementation(mOpacityImage).Disconnect();
- }
- if (mNormalMap)
- {
- GetImplementation(mNormalMap).Disconnect();
- }
- }
-}
-
-void Material::SendPropertiesToSceneObject()
-{
- if( mSceneObject != NULL )
- {
- DALI_ASSERT_DEBUG( mEventToUpdate != NULL );
- if( mEventToUpdate != NULL )
- {
- SetPropertiesMessage( *mEventToUpdate, *mSceneObject, mProperties );
- }
- }
-}
-
-void Material::SendDiffuseImageToSceneObject(Dali::Image image)
-{
- if( image && mSceneObject != NULL && mEventToUpdate != NULL )
- {
- ResourceId id = GetImplementation(image).GetResourceId();
- SetDiffuseTextureMessage( *mEventToUpdate, *mSceneObject, id );
- }
-}
-
-void Material::SendOpacityImageToSceneObject(Dali::Image image)
-{
- if( image && mSceneObject != NULL && mEventToUpdate != NULL )
- {
- ResourceId id = GetImplementation(image).GetResourceId();
- SetOpacityTextureMessage( *mEventToUpdate, *mSceneObject, id );
- }
-}
-
-void Material::SendNormalMapToSceneObject(Dali::Image image)
-{
- if( image && mSceneObject != NULL && mEventToUpdate != NULL )
- {
- ResourceId id = GetImplementation(image).GetResourceId();
- SetNormalMapMessage( *mEventToUpdate, *mSceneObject, id );
- }
-}
-
-void Material::SetOpacity(const float opacity)
-{
- mProperties.mOpacity = opacity;
- SendPropertiesToSceneObject();
-}
-
-float Material::GetOpacity() const
-{
- return mProperties.mOpacity;
-}
-
-void Material::SetShininess(const float shininess)
-{
- mProperties.mShininess = shininess;
- SendPropertiesToSceneObject();
-}
-
-float Material::GetShininess() const
-{
- return mProperties.mShininess;
-}
-
-void Material::SetAmbientColor(const Vector4& color)
-{
- mProperties.mAmbientColor = color;
- SendPropertiesToSceneObject();
-}
-
-const Vector4& Material::GetAmbientColor() const
-{
- return mProperties.mAmbientColor;
-}
-
-void Material::SetDiffuseColor(const Vector4& color)
-{
- mProperties.mDiffuseColor = color;
- SendPropertiesToSceneObject();
-}
-
-const Vector4& Material::GetDiffuseColor() const
-{
- return mProperties.mDiffuseColor;
-}
-
-void Material::SetSpecularColor(const Vector4& color)
-{
- mProperties.mSpecularColor = color;
- SendPropertiesToSceneObject();
-}
-
-const Vector4& Material::GetSpecularColor() const
-{
- return mProperties.mSpecularColor;
-}
-
-void Material::SetEmissiveColor(const Vector4& color)
-{
- mProperties.mEmissiveColor = color;
- SendPropertiesToSceneObject();
-}
-
-const Vector4& Material::GetEmissiveColor() const
-{
- return mProperties.mEmissiveColor;
-}
-
-void Material::SetDiffuseTexture(Dali::Image image)
-{
- if( mDiffuseImage == image )
- {
- return;
- }
-
- if( mDiffuseImage && mConnectionCount > 0 )
- {
- GetImplementation(mDiffuseImage).Disconnect();
- }
-
- mDiffuseImage = image;
-
- if( image && mConnectionCount > 0 )
- {
- GetImplementation(image).Connect();
- }
-
- /// @todo currently there is a bug in material rendering if image is not loaded at this point (Trac issue #475)
- SendDiffuseImageToSceneObject(image);
-}
-
-void Material::SetDiffuseTextureFileName(const std::string filename)
-{
- mDiffuseName = filename;
-}
-
-Dali::Image Material::GetDiffuseTexture() const
-{
- return mDiffuseImage;
-}
-
-const std::string& Material::GetDiffuseTextureFileName() const
-{
- return mDiffuseName;
-}
-
-void Material::SetOpacityTexture(Dali::Image image)
-{
- if (mOpacityImage == image)
- {
- return;
- }
-
- if (mOpacityImage && mConnectionCount > 0)
- {
- GetImplementation(mOpacityImage).Disconnect();
- }
-
- mOpacityImage = image;
-
- if (image && mConnectionCount > 0)
- {
- GetImplementation(image).Connect();
- }
-
- /// @todo currently there is a bug in material rendering if image is not loaded at this point (Trac issue #475)
- SendOpacityImageToSceneObject(image);
-}
-
-void Material::SetOpacityTextureFileName(const std::string filename)
-{
- mOpacityName = filename;
-}
-
-Dali::Image Material::GetOpacityTexture() const
-{
- return mOpacityImage;
-}
-
-const std::string& Material::GetOpacityTextureFileName() const
-{
- return mOpacityName;
-}
-
-void Material::SetNormalMap(Dali::Image image)
-{
- if (mNormalMap == image)
- {
- return;
- }
-
- if (mNormalMap && mConnectionCount > 0)
- {
- GetImplementation(mNormalMap).Disconnect();
- }
-
- mNormalMap = image;
-
- if (image && mConnectionCount > 0)
- {
- GetImplementation(image).Connect();
- }
-
- /// @todo currently there is a bug in material rendering if image is not loaded at this point (Trac issue #475)
- SendNormalMapToSceneObject(image);
-}
-
-void Material::SetNormalMapFileName(const std::string filename)
-{
- mNormalMapName = filename;
-}
-
-Dali::Image Material::GetNormalMap() const
-{
- return mNormalMap;
-}
-
-const std::string& Material::GetNormalMapFileName() const
-{
- return mNormalMapName;
-}
-
-void Material::SetMapU(const unsigned int map)
-{
- mProperties.mMapU = map;
- SendPropertiesToSceneObject();
-}
-
-unsigned int Material::GetMapU() const
-{
- return mProperties.mMapU;
-}
-
-void Material::SetMapV(const unsigned int map)
-{
- mProperties.mMapV = map;
- SendPropertiesToSceneObject();
-}
-
-unsigned int Material::GetMapV() const
-{
- return mProperties.mMapV;
-}
-
-void Material::SetDiffuseUVIndex(const int index)
-{
- mProperties.mDiffuseUVIndex = index;
- SendPropertiesToSceneObject();
-}
-
-unsigned int Material::GetDiffuseUVIndex() const
-{
- return mProperties.mDiffuseUVIndex;
-}
-
-void Material::SetOpacityUVIndex(const int index)
-{
- mProperties.mOpacityUVIndex = index;
- SendPropertiesToSceneObject();
-}
-
-unsigned int Material::GetOpacityUVIndex() const
-{
- return mProperties.mOpacityUVIndex;
-}
-
-void Material::SetNormalUVIndex(const int index)
-{
- mProperties.mNormalUVIndex = index;
- SendPropertiesToSceneObject();
-}
-
-unsigned int Material::GetNormalUVIndex() const
-{
- return mProperties.mNormalUVIndex;
-}
-
-void Material::SetHasHeightMap(const bool flag)
-{
- mProperties.mHasHeightMap = true;
- SendPropertiesToSceneObject();
-}
-
-bool Material::GetHasHeightMap() const
-{
- return mProperties.mHasHeightMap;
-}
-
-
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_MATERIAL_H__
-#define __DALI_INTERNAL_MATERIAL_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/common/constants.h>
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/images/image.h>
-#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/modeling/material.h>
-#include <dali/public-api/object/base-object.h>
-
-namespace Dali
-{
-class Image;
-
-namespace Internal
-{
-class Material;
-class EventToUpdate;
-
-typedef std::vector<Dali::Material> MaterialContainer;
-typedef MaterialContainer::iterator MaterialIter;
-typedef MaterialContainer::const_iterator MaterialConstIter;
-
-namespace SceneGraph
-{
-class Material;
-class UpdateManager;
-}
-
-
-struct MaterialProperties
-{
- float mOpacity; ///< opacity (0 = transparent, 1 = opaque [default: 1]
- float mShininess; ///< value between 0 and 128 [default: 0]
- Vector4 mAmbientColor; ///< Ambient color [default: 0.2 0.2 0.2 1.0]
- Vector4 mDiffuseColor; ///< Diffuse color [default: 0.8 0.8 0.8 1.0]
- Vector4 mSpecularColor; ///< Specular color [default: 0.0 0.0 0.0 1.0]
- Vector4 mEmissiveColor; ///< Emissive color [default: 0.0 0.0 0.0 1.0]
- unsigned int mMapU; ///< mapping mode for U texture coordinates
- unsigned int mMapV; ///< mapping mode for V texture coordinates
- unsigned int mDiffuseUVIndex; ///< Index into bound mesh's array of UV's for diffuse texture coordinates
- unsigned int mOpacityUVIndex; ///< Index into bound mesh's array of UV's for opacity texture coordinates
- unsigned int mNormalUVIndex; ///< Index into bound mesh's array of UV's for normal/height map texture coordinates
- bool mHasHeightMap; ///< Determines if the normal map (if supplied) contains normals or height information
-
- MaterialProperties();
-
- MaterialProperties(const MaterialProperties& rhs);
-
- MaterialProperties& operator=(const MaterialProperties& rhs);
-};
-
-/**
- * @copydoc Dali::Material
- *
- * A Material object can be created by the Adaptor when loading a model
- * resource, in which case it becomes part of the ModelData resource, or it can
- * be created directly by an application.
- *
- * An Internal::Material is tracked by an Internal::MeshAttachment. When the
- * mesh attachment puts its scene graph equivalent on the stage, the
- * Internal::Material is informed through the Connect method. If this is the
- * first connection, then this creates a SceneGraph::Material and passes
- * ownership to the UpdateManager, keeping a pointer to it, and also returning a
- * pointer to the MeshAttachment.
- */
-class Material : public BaseObject
-{
-public:
-
- enum SHADING_MODE
- {
- SHADING_FLAT = 0x1, ///< Flat (faceted) shading.
- SHADING_Gouraud = 0x2, ///< Simple gouraud shading.
- SHADING_Phong = 0x3, ///< Phong shading
- SHADING_Blinn = 0x4, ///< Phong-Blinn shading
- SHADING_Toon = 0x5, ///< Toon (comic) shading
- SHADING_OrenNayar = 0x6, ///< Extension to standard Lambertian shading, taking the roughness of the material into account
- SHADING_Minnaert = 0x7, ///< Extension to standard Lambertian shading, taking the "darkness" of the material into account
- SHADING_CookTorrance = 0x8, ///< Shader for metallic surfaces.
- SHADING_None = 0x9, ///< No shading, constant light influence of 1.0.
- SHADING_Fresnel = 0xa, ///< Fresnel shading
- };
-
- enum MAPPING_MODE
- {
- MAPPING_MODE_WRAP = 0x0, ///< A texture coordinate u|v is translated to u%1|v%1
- MAPPING_MODE_CLAMP = 0x1, ///< Texture coordinates outside [0...1] are clamped to the nearest valid value
- MAPPING_MODE_MIRROR = 0x2, ///< A texture coordinate u|v becomes u%1|v%1 if (u-(u%1))%2 is zero and 1-(u%1)|1-(v%1) otherwise
- MAPPING_MODE_DECAL = 0x3, ///< If the texture coordinates for a pixel are outside [0...1] the texture is not applied to that pixel
- };
-
- enum ImageType
- {
- DIFFUSE_TEXTURE,
- OPACITY_TEXTURE,
- NORMAL_MAP
- };
-
- static Material* New(const std::string& name);
-
- Material(const std::string& name);
-
-private:
- /**
- * Don't allow copy constructor
- */
- Material(const Material& rhs);
-
- /**
- * Don't allow use of copy operator
- */
- Material& operator=(const Material& rhs);
-
- virtual ~Material();
-
-public:
- /**
- * @copydoc Dali::Material::SetName
- */
- void SetName(const std::string& name)
- {
- mName = name;
- }
-
- /**
- * @copydoc Dali::Material::GetName
- */
- const std::string& GetName() const
- {
- return mName;
- }
-
- /**
- * @copydoc Dali::Material::SetOpacity
- */
- void SetOpacity(const float opacity);
-
- /**
- * @copydoc Dali::Material::GetOpacity
- */
- float GetOpacity() const;
-
- /**
- * @copydoc Dali::Material::SetShininess
- */
- void SetShininess(const float shininess);
-
- /**
- * @copydoc Dali::Material::GetShininess
- */
- float GetShininess() const;
-
- /**
- * @copydoc Dali::Material::SetAmbientColor
- */
- void SetAmbientColor(const Vector4& color);
-
- /**
- * @copydoc Dali::Material::GetAmbientColor
- */
- const Vector4& GetAmbientColor() const;
-
- /**
- * @copydoc Dali::Material::SetDiffuseColor
- */
- void SetDiffuseColor(const Vector4& color);
-
- /**
- * @copydoc Dali::Material::GetDiffuseColor
- */
- const Vector4& GetDiffuseColor() const;
-
- /**
- * @copydoc Dali::Material::SetSpecularColor
- */
- void SetSpecularColor(const Vector4& color);
-
- /**
- * @copydoc Dali::Material::GetSpecularColor
- */
- const Vector4& GetSpecularColor() const;
-
- /**
- * @copydoc Dali::Material::SetEmissiveColor
- */
- void SetEmissiveColor(const Vector4& color);
-
- /**
- * @copydoc Dali::Material::GetEmissiveColor
- */
- const Vector4& GetEmissiveColor() const;
-
- /**
- * @copydoc Dali::Material::SetDiffuseTexture(Dali::Image)
- */
- void SetDiffuseTexture(Dali::Image image);
-
- /**
- * @copydoc Dali::Material::SetDiffuseTextureFileName()
- */
- void SetDiffuseTextureFileName(const std::string filename);
-
- /**
- * @copydoc Dali::Material::GetDiffuseTexture
- */
- Dali::Image GetDiffuseTexture() const;
-
- /**
- * @copydoc Dali::Material::GetDiffuseFileName
- */
- const std::string& GetDiffuseTextureFileName() const;
-
- /**
- * @copydoc Dali::Material::SetOpacityTexture
- */
- void SetOpacityTexture(Dali::Image image);
- void SetOpacityTextureFileName(const std::string filename);
-
- /**
- * @copydoc Dali::Material::GetOpacityTexture
- */
- Dali::Image GetOpacityTexture() const;
- const std::string& GetOpacityTextureFileName() const;
-
- /**
- * @copydoc Dali::Material::SetNormalMap
- */
- void SetNormalMap(Dali::Image image);
- void SetNormalMapFileName(const std::string image);
-
- /**
- * @copydoc Dali::Material::GetNormalMap
- */
- Dali::Image GetNormalMap() const;
- const std::string& GetNormalMapFileName() const;
-
- /**
- * @copydoc Dali::Material::SetMapU
- */
- void SetMapU(const unsigned int map);
-
- /**
- * @copydoc Dali::Material::GetMapU
- */
- unsigned int GetMapU() const;
-
- /**
- * @copydoc Dali::Material::SetMapV
- */
- void SetMapV(const unsigned int map);
-
- /**
- * @copydoc Dali::Material::GetMapV
- */
- unsigned int GetMapV() const;
-
- /**
- * @copydoc Dali::Material::SetDiffuseUVIndex
- */
- void SetDiffuseUVIndex(const int index);
-
- /**
- * @copydoc Dali::Material::GetDiffuseUVIndex
- */
- unsigned int GetDiffuseUVIndex() const;
-
- /**
- * @copydoc Dali::Material::SetOpacityUVIndex
- */
- void SetOpacityUVIndex(const int index);
-
- /**
- * @copydoc Dali::Material::GetOpacityUVIndex
- */
- unsigned int GetOpacityUVIndex() const;
-
- /**
- * @copydoc Dali::Material::SetNormalUVIndex
- */
- void SetNormalUVIndex(const int index);
-
- /**
- * @copydoc Dali::Material::GetNormalUVIndex
- */
- unsigned int GetNormalUVIndex() const;
-
- /**
- * @copydoc Dali::Material::SetHasHeightMap
- */
- void SetHasHeightMap(const bool flag);
-
- /**
- * @copydoc Dali::Material::GetHasHeightMap
- */
- bool GetHasHeightMap() const;
-
- const MaterialProperties& GetProperties() const
- {
- return mProperties;
- }
-
- void SetProperties(const MaterialProperties& properties)
- {
- mProperties = properties;
- }
-
- /**
- * Returns an existing scene object, or if none exists, creates one and returns it.
- * Note, the existing scene object may already be staged.
- * @return The associated scene object
- */
- const SceneGraph::Material* GetSceneObject();
-
- /**
- * Connect scene graph object to stage if it isn't already.
- * Track number of connections (may have single material used by multiple meshes/attachments)
- */
- void Connect();
-
- /**
- * Disconnect scene graph object from mesh/attachment. Disconnect from stage when this count
- * reaches zero
- */
- void Disconnect();
-
- /**
- * Set or send message to set properties on the scene object
- */
- void SendPropertiesToSceneObject();
-
- /**
- * Set or send message to set diffuse texture image on the scene object
- */
- void SendDiffuseImageToSceneObject(Dali::Image image);
-
- /**
- * Set or send message to set opacity image on the scene object
- */
- void SendOpacityImageToSceneObject(Dali::Image image);
-
- /**
- * Set or send message to set normal map on the scene object
- */
- void SendNormalMapToSceneObject(Dali::Image image);
-
-
-private:
- /**
- * Create the scene object and return it.
- * @return the scene object
- */
- Internal::SceneGraph::Material* CreateSceneObject();
-
- // Attributes
-private:
- std::string mName; ///< Material's name
- MaterialProperties mProperties; ///< Material properties
- Dali::Image mDiffuseImage; ///< Diffuse image handle
- Dali::Image mOpacityImage; ///< opacity image handle
- Dali::Image mNormalMap; ///< Normal/Height map image handle
-
- std::string mDiffuseName; ///< Diffuse texture file name
- std::string mOpacityName; ///< Opacity Texture file name
- std::string mNormalMapName; ///< Normap map file name
-
-private:
- SceneGraph::Material* mSceneObject; ///< The associated scene graph object
- EventToUpdate* mEventToUpdate; ///< Used to send messages to update-thread
- SceneGraph::UpdateManager* mUpdateManager; ///< The Update manager
- unsigned int mConnectionCount; ///< Number of on-stage meshes connected to this material
-}; // class Material
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Material& GetImplementation(Dali::Material& object)
-{
- DALI_ASSERT_ALWAYS( object && "Material handle is empty" );
-
- BaseObject& handle = object.GetBaseObject();
-
- return static_cast<Internal::Material&>(handle);
-}
-
-inline const Internal::Material& GetImplementation(const Dali::Material& object)
-{
- DALI_ASSERT_ALWAYS( object && "Material handle is empty" );
-
- const BaseObject& handle = object.GetBaseObject();
-
- return static_cast<const Internal::Material&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_MATERIAL_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/modeling/mesh-impl.h>
-
-// EXTERNAL INCLUDES
-#include <stdio.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/math/matrix.h>
-#include <dali/public-api/geometry/mesh.h>
-#include <dali/integration-api/platform-abstraction.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/modeling/material-impl.h>
-#include <dali/internal/update/modeling/scene-graph-mesh.h>
-#include <dali/internal/update/manager/update-manager.h>
-#include <dali/internal/update/modeling/internal-mesh-data.h>
-
-namespace Dali
-{
-namespace Internal
-{
-
-MeshIPtr Mesh::New( const Dali::MeshData& meshData, bool discardable, bool scalingRequired )
-{
- MeshIPtr mesh( new Mesh( meshData, discardable, scalingRequired ) );
-
- return mesh;
-}
-
-Mesh::Mesh( const Dali::MeshData& publicMeshData, bool discardable, bool scalingRequired )
-: mBoneContainer( publicMeshData.GetBones() )
-{
- ThreadLocalStorage tls = ThreadLocalStorage::Get();
- ResourceClient& resourceClient = tls.GetResourceClient();
- ResourcePolicy::DataRetention dataRetentionPolicy = resourceClient.GetResourceDataRetentionPolicy();
-
- ResourcePolicy::Discardable discard = ResourcePolicy::DISCARD;
- if( ! (dataRetentionPolicy == ResourcePolicy::DALI_DISCARDS_ALL_DATA) ||
- ! discardable )
- {
- discard = ResourcePolicy::RETAIN;
- }
-
- // Copy the mesh-data into an internal structure, and pass ownership to the resourceClient
- OwnerPointer<MeshData> meshDataPtr( new MeshData( publicMeshData, discard, scalingRequired ) );
- const ResourceTicketPtr& ticket = resourceClient.AllocateMesh( meshDataPtr );
-
- mTicket = ticket.Get();
- mTicket->AddObserver( *this );
-
- Dali::Material materialHandle( publicMeshData.GetMaterial() );
- Material& material( GetImplementation( materialHandle ) );
- mMaterial = &material;
-}
-
-Mesh::~Mesh()
-{
- mTicket->RemoveObserver(*this);
-}
-
-ResourceId Mesh::GetResourceId() const
-{
- return mTicket->GetId();
-}
-
-MaterialIPtr Mesh::GetMaterial() const
-{
- return mMaterial;
-}
-
-const BoneContainer& Mesh::GetBones() const
-{
- return mBoneContainer;
-}
-
-void Mesh::UpdateMeshData( const Dali::MeshData& meshData )
-{
- DALI_ASSERT_DEBUG(meshData.GetFaceCount());
-
- ResourceClient &resourceClient = ThreadLocalStorage::Get().GetResourceClient();
- resourceClient.UpdateMesh( mTicket, meshData );
-}
-
-void Mesh::ResourceLoadingFailed(const ResourceTicket& ticket)
-{
- // This class is for programmatic meshes defined by the application
- // and is not currently used by the model resource loader
-}
-
-void Mesh::ResourceLoadingSucceeded(const ResourceTicket& ticket)
-{
- // This class is for programmatic meshes defined by the application
- // and is not currently used by the model resource loader
-}
-
-void Mesh::ResourceUploaded(const ResourceTicket& ticket)
-{
-}
-
-void Mesh::ResourceSavingSucceeded( const ResourceTicket& ticket )
-{
- // do nothing
-}
-
-void Mesh::ResourceSavingFailed( const ResourceTicket& ticket )
-{
- // do nothing
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_MESH_H__
-#define __DALI_INTERNAL_MESH_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/geometry/mesh.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/object/handle.h>
-#include <dali/internal/event/modeling/modeling-declarations.h>
-#include <dali/internal/event/resources/resource-ticket.h>
-#include <dali/internal/event/resources/resource-ticket-observer.h>
-#include <dali/internal/event/resources/resource-client.h>
-#include <dali/internal/update/modeling/scene-graph-mesh-declarations.h>
-
-namespace Dali
-{
-
-class Matrix;
-class MeshData;
-
-namespace Internal
-{
-
-class Mesh;
-
-namespace SceneGraph
-{
-class Mesh;
-}
-
-
-typedef std::vector<MeshIPtr> MeshContainer; ///< Container of Mesh pointers
-typedef MeshContainer::iterator MeshIter; ///< iterator for Mesh container
-typedef MeshContainer::const_iterator MeshConstIter; ///< const_iterator for Mesh container
-
-typedef Dali::MeshData::VertexContainer VertexContainer;
-typedef Dali::MeshData::FaceIndex FaceIndex;
-typedef Dali::MeshData::FaceIndices FaceIndices;
-
-
-/**
- * A single mesh in a 3D model
- */
-class Mesh : public BaseObject, public ResourceTicketObserver
-{
-public: // construction, destruction and initialisation
-
- /**
- * Create a new mesh.
- * @param[in] meshData - data provided from public API.
- * @param[in] discardable - If true mesh will be discardable after being uploaded to GL.
- * @param[in] scalingRequired - True if this Mesh should be scaled to fit actor size.
- * @return A smart-pointer to the newly allocated Mesh.
- */
- static MeshIPtr New( const Dali::MeshData& meshData, bool discardable, bool scalingRequired );
-
-protected:
-
- /**
- * Construct a new Mesh.
- * @param[in] meshData - data provided from public API.
- * @param[in] discardable - If true mesh will be discardable after being uploaded to GL.
- * @param[in] scalingRequired - True if this Mesh should be scaled to fit actor size.
- */
- Mesh( const Dali::MeshData& meshData, bool discardable, bool scalingRequired );
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Mesh();
-
-private:
-
- // Undefined
- Mesh(const Mesh&);
-
- // Undefined
- Mesh& operator=(const Mesh& rhs);
-
-public:
-
- /**
- * @copydoc Dali::Mesh::SetData()
- */
- void SetData( const Dali::MeshData& meshData );
-
- /**
- * If the application changes it's mesh data, ensure the GL vertex data is updated
- */
- void Update();
-
- /**
- * returns the Id used for lookups
- * @return the unique ID of the resource.
- */
- ResourceId GetResourceId() const;
-
- /**
- * Get the default material for this mesh.
- * @return the default material for this mesh.
- */
- MaterialIPtr GetMaterial() const;
-
- /**
- * Get the container of bones associated with this mesh.
- * @return the container of bones for the mesh.
- */
- const BoneContainer& GetBones() const;
-
- /**
- * @copydoc Dali::Mesh::UpdateMeshData()
- */
- void UpdateMeshData( const Dali::MeshData& meshData );
-
-public: // From ResourceTicketObserver
-
- /**
- * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingFailed()
- */
- virtual void ResourceLoadingFailed(const ResourceTicket& ticket);
-
- /**
- * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingSucceeded()
- */
- virtual void ResourceLoadingSucceeded(const ResourceTicket& ticket);
-
- /**
- * @copydoc Dali::Internal::ResourceTicketObserver::ResourceUploaded()
- */
- virtual void ResourceUploaded(const ResourceTicket& ticket);
-
- /**
- * @copydoc Dali::Internal::ResourceTicketObserver::ResourceSavingSucceeded()
- */
- virtual void ResourceSavingSucceeded( const ResourceTicket& ticket );
-
- /**
- * @copydoc Dali::Internal::ResourceTicketObserver::ResourceSavingFailed()
- */
- virtual void ResourceSavingFailed( const ResourceTicket& ticket );
-
-protected:
-
- ResourceTicketPtr mTicket;
-
- MaterialIPtr mMaterial; /// Default material for this mesh
- BoneContainer mBoneContainer; /// List of bones that affect this mesh
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Mesh& GetImplementation(Dali::Mesh& mesh)
-{
- DALI_ASSERT_ALWAYS( mesh && "Mesh handle is empty" );
-
- BaseObject& handle = mesh.GetBaseObject();
-
- return static_cast<Internal::Mesh&>(handle);
-}
-
-inline const Internal::Mesh& GetImplementation(const Dali::Mesh& mesh)
-{
- DALI_ASSERT_ALWAYS( mesh && "Mesh handle is empty" );
-
- const BaseObject& handle = mesh.GetBaseObject();
-
- return static_cast<const Internal::Mesh&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_MESH_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_MODELING_DECLARATIONS_H__
-#define __DALI_INTERNAL_MODELING_DECLARATIONS_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class Mesh;
-class Material;
-
-typedef IntrusivePtr<Mesh> MeshIPtr; ///< smart pointer to a Mesh
-typedef IntrusivePtr<Material> MaterialIPtr; ///< smart pointer to a Material
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_MODELING_DECLARATIONS_H__
}
case ResourceTargetImage:
case ResourceShader:
- case ResourceMesh:
case ResourceText:
{
newTicket = new ResourceTicket(*this, newId, typePath);
case ResourceNativeImage:
case ResourceTargetImage:
case ResourceShader:
- case ResourceMesh:
case ResourceText:
{
DALI_LOG_ERROR( "Unsupported resource type passed for decoding from a memory buffer." );
RequestUpdateTextureMessage( mUpdateManager.GetEventToUpdate(), mResourceManager, id, uploadArray );
}
-ResourceTicketPtr ResourceClient::AllocateMesh( OwnerPointer<MeshData>& meshData )
-{
- ResourceTicketPtr newTicket;
- const ResourceId newId = ++(mImpl->mNextId);
- MeshResourceType meshResourceType; // construct first as no copy ctor (needed to bind ref to object)
- ResourceTypePath typePath(meshResourceType, "");
- newTicket = new ResourceTicket(*this, newId, typePath);
- mImpl->mTickets.insert(TicketPair(newId, newTicket.Get()));
-
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: AllocateMesh() New id = %u\n", newId);
- RequestAllocateMeshMessage( mUpdateManager.GetEventToUpdate(), mResourceManager, newId, meshData );
-
- return newTicket;
-}
-
void ResourceClient::UpdateBitmapArea( ResourceTicketPtr ticket, RectArea& updateArea )
{
DALI_ASSERT_DEBUG( ticket );
yOffset );
}
-void ResourceClient::UpdateMesh( ResourceTicketPtr ticket, const Dali::MeshData& meshData )
-{
- DALI_ASSERT_DEBUG( ticket );
-
- ResourcePolicy::Discardable discardable = ResourcePolicy::RETAIN;
- if( mImpl->mDataRetentionPolicy == ResourcePolicy::DALI_DISCARDS_ALL_DATA )
- {
- discardable = ResourcePolicy::DISCARD;
- }
-
- RequestUpdateMeshMessage( mUpdateManager.GetEventToUpdate(),
- mResourceManager,
- ticket->GetId(),
- meshData,
- discardable );
-}
-
Bitmap* ResourceClient::GetBitmap(ResourceTicketPtr ticket)
{
DALI_ASSERT_DEBUG( ticket );
#include <dali/internal/event/resources/resource-ticket-lifetime-observer.h>
#include <dali/internal/common/bitmap-upload.h>
#include <dali/internal/common/message.h>
-#include <dali/internal/update/modeling/internal-mesh-data.h>
namespace Dali
{
BitmapUploadArray uploadArray );
/**
- * Requests allocation of a mesh resource
- * @param[in] meshData representing the mesh; ownership is taken.
- */
- ResourceTicketPtr AllocateMesh( OwnerPointer<MeshData>& meshData );
-
- /**
* Update bitmap area
* @param[in] ticket The ticket representing the bitmap
* @param[in] updateArea the area updated.
void UploadBitmap( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset );
/**
- * Update the mesh used by ticket
- * @note Should use same mechanism as update manager
- * @param[in] ticket The ticket holding the mesh data
- * @param[in] meshData The new mesh data
- */
- void UpdateMesh( ResourceTicketPtr ticket, const Dali::MeshData& meshData );
-
- /**
* Find Bitmap by ticket.
* @pre ticket has to identify a Bitmap
* @param[in] ticket The ticket returned from AllocateBitmapImage() or AddBitmapImage()
break;
}
- case ResourceMesh:
- {
- break; // result = 0
- }
}
}
$(internal_src_dir)/event/actor-attachments/actor-attachment-impl.cpp \
$(internal_src_dir)/event/actor-attachments/camera-attachment-impl.cpp \
$(internal_src_dir)/event/actor-attachments/image-attachment-impl.cpp \
- $(internal_src_dir)/event/actor-attachments/mesh-attachment-impl.cpp \
$(internal_src_dir)/event/actor-attachments/renderable-attachment-impl.cpp \
$(internal_src_dir)/event/actor-attachments/text-attachment-impl.cpp \
$(internal_src_dir)/event/actors/actor-impl.cpp \
$(internal_src_dir)/event/actors/layer-impl.cpp \
$(internal_src_dir)/event/actors/layer-list.cpp \
$(internal_src_dir)/event/actors/text-actor-impl.cpp \
- $(internal_src_dir)/event/actors/mesh-actor-impl.cpp \
$(internal_src_dir)/event/actors/camera-actor-impl.cpp \
$(internal_src_dir)/event/actors/renderable-actor-impl.cpp \
$(internal_src_dir)/event/animation/active-constraint-base.cpp \
$(internal_src_dir)/event/images/emoji-factory.cpp \
$(internal_src_dir)/event/images/resource-image-impl.cpp \
$(internal_src_dir)/event/images/native-image-impl.cpp \
- $(internal_src_dir)/event/modeling/animatable-mesh-impl.cpp \
- $(internal_src_dir)/event/modeling/cloth-impl.cpp \
- $(internal_src_dir)/event/modeling/material-impl.cpp \
- $(internal_src_dir)/event/modeling/mesh-impl.cpp \
$(internal_src_dir)/event/object/custom-object-internal.cpp \
$(internal_src_dir)/event/render-tasks/render-task-impl.cpp \
$(internal_src_dir)/event/render-tasks/render-task-list-impl.cpp \
$(internal_src_dir)/render/gl-resources/texture-factory.cpp \
$(internal_src_dir)/render/gl-resources/texture-cache.cpp \
$(internal_src_dir)/render/queue/render-queue.cpp \
- $(internal_src_dir)/render/renderers/render-material.cpp \
$(internal_src_dir)/render/renderers/scene-graph-image-renderer.cpp \
- $(internal_src_dir)/render/renderers/scene-graph-mesh-renderer.cpp \
$(internal_src_dir)/render/renderers/scene-graph-renderer.cpp \
$(internal_src_dir)/render/renderers/scene-graph-renderer-debug.cpp \
$(internal_src_dir)/render/renderers/scene-graph-text-renderer.cpp \
$(internal_src_dir)/update/common/scene-graph-property-notification.cpp \
$(internal_src_dir)/update/controllers/render-message-dispatcher.cpp \
$(internal_src_dir)/update/controllers/scene-controller-impl.cpp \
- $(internal_src_dir)/update/modeling/internal-mesh-data.cpp \
- $(internal_src_dir)/update/modeling/scene-graph-animatable-mesh.cpp \
$(internal_src_dir)/update/gestures/pan-gesture-profiling.cpp \
$(internal_src_dir)/update/gestures/scene-graph-pan-gesture.cpp \
- $(internal_src_dir)/update/modeling/scene-graph-material.cpp \
- $(internal_src_dir)/update/modeling/scene-graph-mesh.cpp \
$(internal_src_dir)/update/queue/update-message-queue.cpp \
$(internal_src_dir)/update/touch/touch-resampler.cpp \
$(internal_src_dir)/update/manager/prepare-render-algorithms.cpp \
$(internal_src_dir)/update/node-attachments/node-attachment.cpp \
$(internal_src_dir)/update/node-attachments/scene-graph-camera-attachment.cpp \
$(internal_src_dir)/update/node-attachments/scene-graph-image-attachment.cpp \
- $(internal_src_dir)/update/node-attachments/scene-graph-mesh-attachment.cpp \
$(internal_src_dir)/update/node-attachments/scene-graph-renderable-attachment.cpp \
$(internal_src_dir)/update/node-attachments/scene-graph-text-attachment.cpp \
$(internal_src_dir)/update/nodes/node.cpp \
$(internal_src_dir)/event/dynamics/dynamics-cylinder-shape-impl.cpp \
$(internal_src_dir)/event/dynamics/dynamics-joint-impl.cpp \
$(internal_src_dir)/event/dynamics/dynamics-notifier.cpp \
- $(internal_src_dir)/event/dynamics/dynamics-mesh-shape-impl.cpp \
$(internal_src_dir)/event/dynamics/dynamics-shape-impl.cpp \
$(internal_src_dir)/event/dynamics/dynamics-sphere-shape-impl.cpp \
$(internal_src_dir)/event/dynamics/dynamics-world-config-impl.cpp \
$(internal_src_dir)/update/dynamics/scene-graph-dynamics-cube-shape.cpp \
$(internal_src_dir)/update/dynamics/scene-graph-dynamics-cylinder-shape.cpp \
$(internal_src_dir)/update/dynamics/scene-graph-dynamics-joint.cpp \
- $(internal_src_dir)/update/dynamics/scene-graph-dynamics-mesh-shape.cpp \
$(internal_src_dir)/update/dynamics/scene-graph-dynamics-shape.cpp \
$(internal_src_dir)/update/dynamics/scene-graph-dynamics-sphere-shape.cpp \
$(internal_src_dir)/update/dynamics/scene-graph-dynamics-world.cpp
#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
#include <dali/internal/render/gl-resources/native-frame-buffer-texture.h>
#include <dali/internal/render/gl-resources/texture-cache.h>
-#include <dali/internal/render/renderers/render-material.h>
#include <dali/internal/render/renderers/scene-graph-renderer.h>
#include <dali/internal/render/shaders/program-controller.h>
typedef OwnerContainer< Renderer* > RendererOwnerContainer;
typedef RendererOwnerContainer::Iterator RendererOwnerIter;
-typedef OwnerContainer< RenderMaterial* > RenderMaterialContainer;
-typedef RenderMaterialContainer::Iterator RenderMaterialIter;
-typedef RenderMaterialContainer::ConstIterator RenderMaterialConstIter;
-
typedef OwnerContainer< RenderTracker* > RenderTrackerContainer;
typedef RenderTrackerContainer::Iterator RenderTrackerIter;
typedef RenderTrackerContainer::ConstIterator RenderTrackerConstIter;
renderBufferIndex( SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX ),
defaultSurfaceRect(),
rendererContainer(),
- materials(),
renderersAdded( false ),
firstRenderCompleted( false ),
defaultShader( NULL ),
Rect<int> defaultSurfaceRect; ///< Rectangle for the default surface we are rendering to
RendererOwnerContainer rendererContainer; ///< List of owned renderers
- RenderMaterialContainer materials; ///< List of owned render materials
bool renderersAdded;
}
}
-void RenderManager::AddRenderMaterial( RenderMaterial* renderMaterial )
-{
- DALI_ASSERT_DEBUG( NULL != renderMaterial );
-
- mImpl->materials.PushBack( renderMaterial );
- renderMaterial->Initialize( mImpl->textureCache );
-}
-
-void RenderManager::RemoveRenderMaterial( RenderMaterial* renderMaterial )
-{
- DALI_ASSERT_DEBUG( NULL != renderMaterial );
-
- RenderMaterialContainer& materials = mImpl->materials;
-
- // Find the render material and destroy it
- for ( RenderMaterialIter iter = materials.Begin(); iter != materials.End(); ++iter )
- {
- RenderMaterial& current = **iter;
- if ( ¤t == renderMaterial )
- {
- materials.Erase( iter );
- break;
- }
- }
-}
-
void RenderManager::AddRenderTracker( RenderTracker* renderTracker )
{
mImpl->AddRenderTracker(renderTracker);
{
class Renderer;
class RenderQueue;
-class RenderMaterial;
class TextureCache;
class RenderInstruction;
class RenderInstructionContainer;
void RemoveRenderer( Renderer* renderer );
/**
- * Adds a RenderMaterial to the render manager for MeshRenderers to use.
- * The RenderManager takes ownership of the material
- * @param[in] renderMaterial
- * @post renderMaterial is owned by RenderManager
- */
- void AddRenderMaterial( RenderMaterial* renderMaterial );
-
- /**
- * Removes a RenderMaterial from the RenderManager
- * RenderManager will destroy the material
- * @pre renderManager owns the materail
- * @param[in] renderMaterial
- * @post renderMaterial is destroyed
- */
- void RemoveRenderMaterial( RenderMaterial* renderMaterial );
-
- /**
* Adds a render tracker to the RenderManager. RenderManager takes ownership of the
* tracker. The lifetime of the tracker is related to the lifetime of the tracked
* object, usually an offscreen render task.
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/render/renderers/render-material.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/common/internal-constants.h>
-#include <dali/internal/render/gl-resources/texture.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
-#include <dali/internal/render/shaders/program.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-
-void RenderMaterialUniforms::ResetCustomUniforms()
-{
- for( unsigned int subType = SHADER_DEFAULT; subType < SHADER_SUBTYPE_LAST; ++subType )
- {
- for( unsigned int i = 0; i < mNumberOfCustomUniforms; ++i )
- {
- mCustomUniform[ subType ][ i ].Reset();
- }
- }
-}
-
-void RenderMaterialUniforms::SetUniforms( const RenderMaterial& material, Program& program, ShaderSubTypes shaderType )
-{
- GLint location = mCustomUniform[ shaderType ][ 0 ].GetUniformLocation( program, "uMaterial.mOpacity" );
- if( Program::UNIFORM_UNKNOWN != location )
- {
- program.SetUniform1f( location, material.mOpacity );
- }
-
- location = mCustomUniform[ shaderType ][ 1 ].GetUniformLocation( program, "uMaterial.mShininess" );
- if( Program::UNIFORM_UNKNOWN != location )
- {
- program.SetUniform1f( location, material.mShininess );
- }
-
- location = mCustomUniform[ shaderType ][ 2 ].GetUniformLocation( program, "uMaterial.mAmbient" );
- if( Program::UNIFORM_UNKNOWN != location )
- {
- const Vector4& color = material.mAmbientColor;
- program.SetUniform4f( location, color.r, color.g, color.b, color.a );
- }
-
- location = mCustomUniform[ shaderType ][ 3 ].GetUniformLocation( program, "uMaterial.mDiffuse" );
- if( Program::UNIFORM_UNKNOWN != location )
- {
- const Vector4& color = material.mDiffuseColor;
- program.SetUniform4f( location, color.r, color.g, color.b, color.a );
- }
-
- location = mCustomUniform[ shaderType ][ 4 ].GetUniformLocation( program, "uMaterial.mSpecular" );
- if( Program::UNIFORM_UNKNOWN != location )
- {
- const Vector4& color = material.mSpecularColor;
- program.SetUniform4f( location, color.r, color.g, color.b, color.a );
- }
-
- location = mCustomUniform[ shaderType ][ 5 ].GetUniformLocation( program, "uMaterial.mEmissive" );
- if( Program::UNIFORM_UNKNOWN != location )
- {
- const Vector4& color = material.mEmissiveColor;
- program.SetUniform4f( location, color.r, color.g, color.b, color.a );
- }
-}
-
-
-
-RenderMaterial::RenderMaterial()
-: mTextureCache(NULL),
-
- mDiffuseTextureId(0),
- mOpacityTextureId(0),
- mNormalMapTextureId(0),
-
- mDiffuseTexture(NULL),
- mOpacityTexture(NULL),
- mNormalMapTexture(NULL),
-
- mOpacity(1.0f),
- mShininess(0.5f),
-
- mAmbientColor(Vector4(0.2f, 0.2f, 0.2f, 1.0f)),
- mDiffuseColor(Vector4(0.8f, 0.8f, 0.8f, 1.0f)),
- mSpecularColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
- mEmissiveColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f))
-{
-}
-
-RenderMaterial::~RenderMaterial()
-{
- if(mDiffuseTextureId > 0)
- {
- mTextureCache->RemoveObserver( mDiffuseTextureId, this );
- }
-
- if(mOpacityTextureId > 0)
- {
- mTextureCache->RemoveObserver( mOpacityTextureId, this );
- }
-
- if(mNormalMapTextureId > 0)
- {
- mTextureCache->RemoveObserver( mNormalMapTextureId, this );
- }
-}
-
-void RenderMaterial::Initialize(TextureCache& textureCache)
-{
- mTextureCache = &textureCache;
-}
-
-void RenderMaterial::SetDiffuseTextureId( unsigned int textureId )
-{
- DALI_ASSERT_DEBUG( NULL != mTextureCache );
-
- if(mDiffuseTextureId > 0)
- {
- mTextureCache->RemoveObserver( mDiffuseTextureId, this );
- }
-
- mDiffuseTextureId = textureId;
- mDiffuseTexture = NULL;
-
- if(mDiffuseTextureId > 0)
- {
- mTextureCache->AddObserver( textureId, this );
- }
-}
-
-void RenderMaterial::SetOpacityTextureId( unsigned int textureId )
-{
- DALI_ASSERT_DEBUG( NULL != mTextureCache );
-
- if(mOpacityTextureId > 0)
- {
- mTextureCache->RemoveObserver( mOpacityTextureId, this );
- }
-
- mOpacityTextureId = textureId;
- mOpacityTexture = NULL;
-
- if(mOpacityTextureId > 0)
- {
- mTextureCache->AddObserver( textureId, this );
- }
-}
-
-void RenderMaterial::SetNormalMapTextureId( unsigned int textureId )
-{
- DALI_ASSERT_DEBUG( NULL != mTextureCache );
-
- if(mNormalMapTextureId > 0)
- {
- mTextureCache->RemoveObserver( mNormalMapTextureId, this );
- }
-
- mNormalMapTextureId = textureId;
- mNormalMapTexture = NULL;
-
- if(mNormalMapTextureId > 0)
- {
- mTextureCache->AddObserver( textureId, this );
- }
-}
-
-void RenderMaterial::SetOpacity(float opacity)
-{
- mOpacity = opacity;
-}
-
-void RenderMaterial::SetShininess(float shininess)
-{
- mShininess = shininess;
-}
-
-void RenderMaterial::SetAmbientColor( const Vector4& color )
-{
- mAmbientColor = color;
-}
-
-void RenderMaterial::SetDiffuseColor( const Vector4& color )
-{
- mDiffuseColor = color;
-}
-
-void RenderMaterial::SetSpecularColor( const Vector4& color )
-{
- mSpecularColor = color;
-}
-
-void RenderMaterial::SetEmissiveColor( const Vector4& color )
-{
- mEmissiveColor = color;
-}
-
-bool RenderMaterial::HasTexture() const
-{
- return( mDiffuseTextureId != 0 );
-}
-
-void RenderMaterial::SetUniforms( RenderMaterialUniforms& uniforms, Program& program, ShaderSubTypes shaderType ) const
-{
- uniforms.SetUniforms( *this, program, shaderType );
-}
-
-void RenderMaterial::BindTexture( Program& program, ResourceId id, Texture* texture, TextureUnit textureUnit, Program::UniformType samplerIndex ) const
-{
- DALI_ASSERT_DEBUG( NULL != mTextureCache );
-
- if( texture != NULL )
- {
- mTextureCache->BindTexture( texture, id, GL_TEXTURE_2D, textureUnit );
- // Set sampler uniforms for textures
- GLint samplerLoc = program.GetUniformLocation( samplerIndex );
- if( Program::UNIFORM_UNKNOWN != samplerLoc )
- {
- program.SetUniform1i( samplerLoc, textureUnit );
- }
-
- GLint location = program.GetUniformLocation(Program::UNIFORM_CUSTOM_TEXTURE_COORDS);
- if( Program::UNIFORM_UNKNOWN != location )
- {
- UvRect uvs;
- texture->GetTextureCoordinates(uvs);
-
- // Account for UV mapping on non power of 2 textures
- program.SetUniform4f(location, uvs.u0, uvs.v0, uvs.u2-uvs.u0, uvs.v2-uvs.v0);
- }
- }
-}
-
-void RenderMaterial::BindTextures( Program& program, unsigned int textureSampler )
-{
- DALI_ASSERT_DEBUG( NULL != mTextureCache );
-
- if( mDiffuseTexture == NULL )
- {
- if( mDiffuseTextureId > 0 )
- {
- mDiffuseTexture = mTextureCache->GetTexture( mDiffuseTextureId );
- }
- }
-
- if( mOpacityTexture == NULL )
- {
- if( mOpacityTextureId > 0 )
- {
- mOpacityTexture = mTextureCache->GetTexture( mOpacityTextureId );
- }
- }
-
- if( mNormalMapTexture == NULL )
- {
- if( mNormalMapTextureId > 0 )
- {
- mNormalMapTexture = mTextureCache->GetTexture( mNormalMapTextureId );
- }
- }
-
- BindTexture( program, mDiffuseTextureId, mDiffuseTexture, TEXTURE_UNIT_MATERIAL_DIFFUSE, Program::UNIFORM_SAMPLER );
-
- if( mDiffuseTexture )
- {
- mDiffuseTexture->ApplySampler( TEXTURE_UNIT_MATERIAL_DIFFUSE, textureSampler );
- }
-
- BindTexture( program, mOpacityTextureId, mOpacityTexture, TEXTURE_UNIT_MATERIAL_OPACITY, Program::UNIFORM_SAMPLER_OPACITY );
-
- if( mOpacityTexture )
- {
- mOpacityTexture->ApplySampler( TEXTURE_UNIT_MATERIAL_OPACITY, textureSampler );
- }
-
- BindTexture( program, mNormalMapTextureId, mNormalMapTexture, TEXTURE_UNIT_MATERIAL_NORMAL_MAP, Program::UNIFORM_SAMPLER_NORMAL_MAP );
-
- if( mNormalMapTexture )
- {
- mNormalMapTexture->ApplySampler( TEXTURE_UNIT_MATERIAL_NORMAL_MAP, textureSampler );
- }
-}
-
-void RenderMaterial::TextureDiscarded( unsigned int textureId )
-{
- if( mDiffuseTextureId == textureId )
- {
- mDiffuseTextureId = 0;
- mDiffuseTexture = NULL;
- }
-
- if( mOpacityTextureId == textureId )
- {
- mOpacityTextureId = 0;
- mOpacityTexture = NULL;
- }
-
- if( mNormalMapTextureId == textureId )
- {
- mNormalMapTextureId = 0;
- mNormalMapTexture = NULL;
- }
-}
-
-
-
-} // SceneGraph
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_MATERIAL_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_MATERIAL_H__
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/math/vector4.h>
-#include <dali/internal/common/message.h>
-#include <dali/internal/event/effects/shader-declarations.h>
-#include <dali/internal/render/shaders/custom-uniform.h>
-#include <dali/internal/render/gl-resources/texture-observer.h>
-#include <dali/internal/render/gl-resources/texture-units.h>
-#include <dali/internal/render/shaders/program.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class Texture;
-
-namespace SceneGraph
-{
-
-class TextureCache;
-class RenderMaterial;
-
-/**
- * Helper class to manage uniforms for RenderMaterial. There is a 1-1
- * correspondance between a helper object and a Renderer instance,
- * whereas there is a 1-many relationship between RenderMaterial and
- * Renderer instances.
- */
-class RenderMaterialUniforms
-{
-public:
- /**
- * If the owner's program changes, then this should be called to reset the uniform locations
- */
- void ResetCustomUniforms();
-
- /**
- * Set the uniform values from the renderMaterial onto the program
- * @param[in] renderMaterial The material from which to get the values
- * @param[in] program The program for which to set the values
- * @param[in] shaderType The sub type of shader program
- */
- void SetUniforms( const RenderMaterial& renderMaterial, Program& program, ShaderSubTypes shaderType );
-
-private:
- static const unsigned int mNumberOfCustomUniforms = 6; ///< Number of material uniforms
- mutable CustomUniform mCustomUniform[SHADER_SUBTYPE_LAST][ mNumberOfCustomUniforms ]; ///< The uniform locations
-};
-
-
-/**
- * Holds values to be stored into uniforms by the renderer
- * Holds texture pointers for binding by the renderer
- */
-class RenderMaterial : public TextureObserver
-{
-public:
- /**
- * Constructor
- */
- RenderMaterial();
-
- /**
- * Destructor
- */
- virtual ~RenderMaterial();
-
- /**
- * Secondary stage initialization
- * @param[in] textureCache The GL Texture cache
- */
- void Initialize(TextureCache& textureCache);
-
- // Message setters
-
- /**
- * Set the diffuse texture resource id
- * @param[in] textureId The resource id of the texture
- */
- void SetDiffuseTextureId( unsigned int textureId );
-
- /**
- * Set the opacity texture id
- * @param[in] textureId The resource id of the texture
- */
- void SetOpacityTextureId( unsigned int textureId );
-
- /**
- * Set the normal / height map texture id
- * @param[in] textureId The resource id of the texture
- */
- void SetNormalMapTextureId( unsigned int textureId );
-
- /**
- * Set the opacity
- * @param[in] opacity The opacity
- */
- void SetOpacity(float opacity);
-
- /**
- * Set the shininess
- * @param[in] shininess The shininess
- */
- void SetShininess(float shininess);
-
- /**
- * Set the ambient color
- * @param[in] color The color
- */
- void SetAmbientColor( const Vector4& color );
-
- /**
- * Set the diffuse color
- * @param[in] color The color
- */
- void SetDiffuseColor( const Vector4& color );
-
- /**
- * Set the specular color
- * @param[in] color The color
- */
- void SetSpecularColor( const Vector4& color );
-
- /**
- * Set the emissive color
- * @param[in] color The color
- */
- void SetEmissiveColor( const Vector4& color );
-
- /**
- * @return true if a texture has been set on this material, false otherwise
- */
- bool HasTexture() const;
-
- // Rendering
-
- /**
- * Set the uniform values for the locations defined in the uniforms structure.
- * @param[in] uniforms The material uniforms
- * @param[in] program The shader program for which to set the uniform values
- * @param[in] shaderType The shader type
- */
- void SetUniforms( RenderMaterialUniforms& uniforms, Program& program, ShaderSubTypes shaderType ) const;
-
- /**
- * Bind all the valid textures. Will also store valid texture pointer
- * @param[in] program The shader program with which to bind the textures
- * @param[in] textureSampler The texture sampling parameters for the diffuse, opacity and normal textures
- */
- void BindTextures( Program& program, unsigned int textureSampler );
-
-protected: // TextureObserver implementation
- /**
- * @copydoc Dali::Internal::TextureObserver::TextureDiscarded()
- */
- virtual void TextureDiscarded( unsigned int textureId );
-
-private:
- /**
- * Bind a texture.
- * @param[in] program The shader program with which to bind the texture
- * @param[in] textureId the texture id to bind
- * @param[in] texture The texture to bind
- * @param[in] textureUnit Texture unit ( should be a value between 0 and the max number of samplers - 1 )
- * @param[in] samplerIndex The index of the uniform to bind the texture sampler
- */
- void BindTexture( Program& program, unsigned int textureId, Texture* texture, TextureUnit textureUnit, Program::UniformType samplerIndex ) const;
-
-private:
- TextureCache* mTextureCache; ///< Texture cache of GL resources
-
- unsigned int mDiffuseTextureId; ///< Diffuse texture id
- unsigned int mOpacityTextureId; ///< opacity texture id
- unsigned int mNormalMapTextureId; ///< Normal/Height map texture id
-
- Texture* mDiffuseTexture; ///< Pointer to ready texture
- Texture* mOpacityTexture; ///< Pointer to ready texture
- Texture* mNormalMapTexture; ///< Pointer to ready texture
-
- float mOpacity; ///< opacity (0 = transparent, 1 = opaque)
- float mShininess; ///< value between 0 and 128
-
- Vector4 mAmbientColor; ///< Ambient color
- Vector4 mDiffuseColor; ///< Diffuse color
- Vector4 mSpecularColor; ///< Specular color
- Vector4 mEmissiveColor; ///< Emissive color
-
- friend class RenderMaterialUniforms;
-};
-
-} // SceneGraph
-
-} // Internal
-
-} // Dali
-
-#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MATERIAL_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/render/renderers/scene-graph-mesh-renderer.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/math/matrix3.h>
-#include <dali/public-api/math/matrix.h>
-#include <dali/internal/common/internal-constants.h>
-#include <dali/internal/update/modeling/scene-graph-mesh.h>
-#include <dali/internal/update/modeling/scene-graph-material.h>
-#include <dali/internal/update/controllers/scene-controller.h>
-#include <dali/internal/render/shaders/program.h>
-#include <dali/internal/render/shaders/shader.h>
-#include <dali/internal/render/renderers/render-material.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-
-MeshRenderer* MeshRenderer::New( RenderDataProvider& dataprovider )
-{
- MeshRenderer* meshRenderer = new MeshRenderer( dataprovider );
-
- return meshRenderer;
-}
-
-MeshRenderer::MeshRenderer( RenderDataProvider& dataprovider )
-: Renderer( dataprovider ),
- mGeometryType(GEOMETRY_TYPE_TEXTURED_MESH),
- mShaderType(SHADER_DEFAULT)
-{
-}
-
-void MeshRenderer::ResetCustomUniforms()
-{
- for( unsigned int subType = SHADER_DEFAULT; subType < SHADER_SUBTYPE_LAST; ++subType )
- {
- for( unsigned int i = 0; i < mNumberOfCustomUniforms; ++i )
- {
- mCustomUniform[ subType ][ i ].Reset();
- }
- }
-
- mRenderMaterialUniforms.ResetCustomUniforms();
-}
-
-MeshRenderer::~MeshRenderer()
-{
-}
-
-void MeshRenderer::GlContextDestroyed()
-{
- MeshInfo& meshInfo0 = mMeshInfo[ 0 ];
- Mesh* mesh = meshInfo0.mesh;
- if( mesh )
- {
- mesh->GlContextDestroyed();
- }
- MeshInfo& meshInfo1 = mMeshInfo[ 1 ];
- mesh = meshInfo1.mesh;
- if( mesh )
- {
- mesh->GlContextDestroyed();
- }
-}
-
-void MeshRenderer::GlCleanup()
-{
- // MeshRenderer does not own any GL resources
-}
-
-bool MeshRenderer::RequiresDepthTest() const
-{
- return true;
-}
-
-bool MeshRenderer::CheckResources()
-{
- return true;
-}
-
-void MeshRenderer::ResolveGeometryTypes( BufferIndex bufferIndex, GeometryType& outType, ShaderSubTypes& outSubType )
-{
- MeshInfo& meshInfo = mMeshInfo[bufferIndex];
- Mesh* mesh = meshInfo.mesh;
- RenderMaterial& material = *(meshInfo.material);
-
- outType = GEOMETRY_TYPE_TEXTURED_MESH;
- if( ! material.HasTexture() )
- {
- outType = GEOMETRY_TYPE_UNTEXTURED_MESH;
- }
- outSubType = SHADER_DEFAULT;
-
- if( mShader->AreSubtypesRequired( outType ) )
- {
- GLsizei numBoneMatrices = (GLsizei)mesh->GetMeshData(Mesh::RENDER_THREAD).GetBoneCount();
-
- if( numBoneMatrices )
- {
- if( mesh->GetMeshData(Mesh::RENDER_THREAD).HasColor() )
- {
- outSubType = SHADER_RIGGED_AND_VERTEX_COLOR;
- }
- else
- {
- outSubType = SHADER_RIGGED_AND_EVENLY_LIT;
- }
- }
- else
- {
- if( mesh->GetMeshData(Mesh::RENDER_THREAD).HasColor() )
- {
- outSubType = SHADER_VERTEX_COLOR;
- }
- outSubType = SHADER_EVENLY_LIT;
- }
- }
- if( outType != mGeometryType || outSubType != mShaderType )
- {
- mGeometryType = outType;
- mShaderType = outSubType;
- ResetCustomUniforms();
- }
-}
-
-bool MeshRenderer::IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix )
-{
- return false; // @todo add implementation
-}
-
-void MeshRenderer::DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
-{
- MeshInfo& meshInfo = mMeshInfo[bufferIndex];
- Mesh* mesh = meshInfo.mesh;
- RenderMaterial& material = *(meshInfo.material);
- BoneTransforms& boneTransforms = meshInfo.boneTransforms;
-
- if( ! meshInfo.boneTransforms.transforms.empty() )
- {
- ApplyViewToBoneTransforms( meshInfo.boneTransforms, viewMatrix );
- }
-
- const int stride = sizeof(Dali::MeshData::Vertex);
- Dali::MeshData::Vertex *v = 0;
-
- mesh->UploadVertexData( *mContext, bufferIndex );
- mesh->BindBuffers( *mContext );
-
- GLsizei numBoneMatrices = (GLsizei)mesh->GetMeshData(Mesh::RENDER_THREAD).GetBoneCount();
-
- GLint location = Program::UNIFORM_UNKNOWN;
- GLint positionLoc = program.GetAttribLocation(Program::ATTRIB_POSITION);
- GLint texCoordLoc = Program::ATTRIB_UNKNOWN;
- GLint boneWeightsLoc = Program::ATTRIB_UNKNOWN;
- GLint boneIndicesLoc = Program::ATTRIB_UNKNOWN;
- GLint normalLoc = Program::ATTRIB_UNKNOWN;
- GLint colorLoc = Program::ATTRIB_UNKNOWN;
-
- mContext->VertexAttribPointer( positionLoc, 3, GL_FLOAT, GL_FALSE, stride, &v->x );
- mContext->EnableVertexAttributeArray( positionLoc );
-
- if( numBoneMatrices > 0 )
- {
- location = mCustomUniform[ mShaderType ][ 0 ].GetUniformLocation( program, "uBoneCount" );
- if( Program::UNIFORM_UNKNOWN != location )
- {
- program.SetUniform1i(location, numBoneMatrices);
- }
-
- location = mCustomUniform[ mShaderType ][ 1 ].GetUniformLocation( program, "uBoneMatrices" );
- if( Program::UNIFORM_UNKNOWN != location )
- {
- program.SetUniformMatrix4fv(location, numBoneMatrices, boneTransforms.viewTransforms[0].AsFloat());
- }
- if( mesh->GetMeshData(Mesh::RENDER_THREAD).HasNormals() )
- {
- location = mCustomUniform[ mShaderType ][ 2 ].GetUniformLocation( program, "uBoneMatricesIT" );
- if( Program::UNIFORM_UNKNOWN != location )
- {
- program.SetUniformMatrix3fv( location, numBoneMatrices, boneTransforms.inverseTransforms[0].AsFloat() );
- }
- }
-
- boneWeightsLoc = program.GetAttribLocation( Program::ATTRIB_BONE_WEIGHTS );
- if( Program::ATTRIB_UNKNOWN != boneWeightsLoc )
- {
- mContext->VertexAttribPointer( boneWeightsLoc, 4, GL_FLOAT, GL_FALSE, stride, &v->boneWeights[0] );
- mContext->EnableVertexAttributeArray( boneWeightsLoc );
- }
-
- boneIndicesLoc = program.GetAttribLocation( Program::ATTRIB_BONE_INDICES );
- if( Program::ATTRIB_UNKNOWN != boneIndicesLoc )
- {
- mContext->VertexAttribPointer( boneIndicesLoc, 4, GL_UNSIGNED_BYTE, GL_FALSE, stride, &v->boneIndices[0] );
- mContext->EnableVertexAttributeArray( boneIndicesLoc );
- }
- }
-
- if( material.HasTexture() )
- {
- material.BindTextures( program, mSamplerBitfield );
- }
- // Always use UV's - may be being used for another purpose by a custom shader!
- texCoordLoc = program.GetAttribLocation(Program::ATTRIB_TEXCOORD);
- if( Program::ATTRIB_UNKNOWN != texCoordLoc )
- {
- mContext->VertexAttribPointer( texCoordLoc, 2, GL_FLOAT, GL_FALSE, stride, &v->u );
- mContext->EnableVertexAttributeArray( texCoordLoc );
- }
-
- if( mesh->GetMeshData(Mesh::RENDER_THREAD).HasNormals() )
- {
- normalLoc = program.GetAttribLocation(Program::ATTRIB_NORMAL);
- if( Program::ATTRIB_UNKNOWN != normalLoc )
- {
- mContext->VertexAttribPointer( normalLoc, 3, GL_FLOAT, GL_FALSE, stride, &v->nX );
- mContext->EnableVertexAttributeArray( normalLoc );
- }
- }
- else if( mesh->GetMeshData(Mesh::RENDER_THREAD).HasColor() ) // Normals & color are mutually exclusive
- {
- colorLoc = program.GetAttribLocation(Program::ATTRIB_COLOR);
- if( Program::ATTRIB_UNKNOWN != colorLoc)
- {
- mContext->VertexAttribPointer( colorLoc, 3, GL_FLOAT, GL_FALSE, stride, &v->vertexR );
- mContext->EnableVertexAttributeArray( colorLoc );
- }
- }
-
- material.SetUniforms( mRenderMaterialUniforms, program, mShaderType );
-
- Dali::MeshData::VertexGeometryType vertexGeometry = mesh->GetMeshData(Mesh::RENDER_THREAD).GetVertexGeometryType();
- switch( vertexGeometry )
- {
- case Dali::MeshData::TRIANGLES:
- {
- mContext->DrawElements(GL_TRIANGLES, mesh->GetFaceIndexCount(Mesh::RENDER_THREAD), GL_UNSIGNED_SHORT, 0);
- DRAW_ELEMENT_RECORD(mesh->GetFaceIndexCount());
- break;
- }
- case Dali::MeshData::LINES:
- {
- mContext->DrawElements(GL_LINES, mesh->GetFaceIndexCount(Mesh::RENDER_THREAD), GL_UNSIGNED_SHORT, 0);
- DRAW_ELEMENT_RECORD(mesh->GetFaceIndexCount());
- break;
- }
- case Dali::MeshData::POINTS:
- {
- mContext->DrawArrays(GL_POINTS, 0, mesh->GetFaceIndexCount(Mesh::RENDER_THREAD) );
- DRAW_ARRAY_RECORD(mesh->GetFaceIndexCount());
- break;
- }
- }
-
- if( normalLoc != Program::ATTRIB_UNKNOWN )
- {
- mContext->DisableVertexAttributeArray( normalLoc );
- }
-
- if( colorLoc != Program::ATTRIB_UNKNOWN )
- {
- mContext->DisableVertexAttributeArray( colorLoc );
- }
-
- mContext->DisableVertexAttributeArray( positionLoc );
-
- if( texCoordLoc != Program::ATTRIB_UNKNOWN )
- {
- mContext->DisableVertexAttributeArray( texCoordLoc );
- }
-
- if( boneWeightsLoc != Program::ATTRIB_UNKNOWN )
- {
- mContext->DisableVertexAttributeArray( boneWeightsLoc );
- }
-
- if( boneIndicesLoc != Program::ATTRIB_UNKNOWN )
- {
- mContext->DisableVertexAttributeArray( boneIndicesLoc );
- }
-
- return;
-}
-
-void MeshRenderer::ApplyViewToBoneTransforms( BoneTransforms& boneTransforms,
- const Matrix& viewMatrix )
-{
- size_t boneCount = boneTransforms.transforms.size();
-
- for( size_t boneIdx=0; boneIdx < boneCount; ++boneIdx )
- {
- Matrix& transform = boneTransforms.transforms[boneIdx];
- Matrix& viewTransform = boneTransforms.viewTransforms[boneIdx];
- Matrix::Multiply(viewTransform, transform, viewMatrix);
-
- boneTransforms.inverseTransforms[boneIdx] = viewTransform;
- boneTransforms.inverseTransforms[boneIdx].ScaledInverseTranspose();
- }
-}
-
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_MESH_RENDERER_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_MESH_RENDERER_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/internal/common/owner-pointer.h>
-#include <dali/internal/render/renderers/render-material.h>
-#include <dali/internal/render/renderers/scene-graph-renderer.h>
-#include <dali/internal/update/modeling/bone-transforms.h>
-#include <dali/internal/render/shaders/custom-uniform.h>
-#include <dali/internal/event/effects/shader-declarations.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-
-class RenderDataProvider;
-struct BoneTransforms;
-class LightController;
-class RenderMaterial;
-class Mesh;
-
-/**
- * An attachment for rendering a mesh with a material.
- */
-class MeshRenderer : public Renderer
-{
-public:
-
- /**
- * The information required to render a single mesh
- */
- struct MeshInfo
- {
- MeshInfo()
- : mesh(NULL),
- material(NULL),
- boneTransforms()
- {
- }
-
- Mesh* mesh;
- RenderMaterial* material;
- BoneTransforms boneTransforms; ///< Note, this is a std::vector. May be realloced in off-frame
- };
-
- /**
- * Construct a new MeshRenderer.
- * @param dataprovider to render
- * @param lightController to get the light information
- * @return The newly allocated MeshRenderer.
- */
- static MeshRenderer* New( RenderDataProvider& dataprovider);
-
- /**
- * Retrieve the mesh information for the next frame.
- * This should only be accessed from the update-thread, using the current update buffer.
- * @param[in] updateBufferIndex The current update buffer index.
- */
- MeshInfo& GetMeshInfo( BufferIndex updateBufferIndex )
- {
- return mMeshInfo[ updateBufferIndex ];
- }
-
- /**
- * Called when the shader has changed; mCustomUniform should be reset.
- */
- void ResetCustomUniforms();
-
- /**
- * Virtual destructor
- */
- virtual ~MeshRenderer();
-
-private:
-
- /**
- * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed()
- */
- virtual void GlContextDestroyed();
-
- /**
- * @copydoc Dali::Internal::GlResourceOwner::GlCleanup()
- */
- virtual void GlCleanup();
-
- /**
- * @copydoc Dali::Internal::SceneGraph::Renderer::RequiresDepthTest()
- */
- virtual bool RequiresDepthTest() const;
-
- /**
- * @copydoc Dali::Internal::SceneGraph::Renderer::CheckResources()
- */
- virtual bool CheckResources();
-
- /**
- * @copydoc Dali::Internal::SceneGraph::Renderer::ResolveGeometryTypes()
- */
- virtual void ResolveGeometryTypes( BufferIndex bufferIndex, GeometryType& outType, ShaderSubTypes& outSubType );
-
- /**
- * @copydoc Dali::Internal::SceneGraph::Renderer::IsOutsideClipSpace()
- */
- virtual bool IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix );
-
- /**
- * @copydoc Dali::Internal::SceneGraph::Renderer::DoRender()
- */
- virtual void DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix );
-
- /**
- * Apply the view matrix to the bone transforms, and generate inverse transforms (for normal
- * calculations)
- * @param[inout] boneTransforms The bone transform matrices to update
- * @param[in] viewMatrix The current view matrix
- */
- void ApplyViewToBoneTransforms( BoneTransforms& boneTransforms, const Matrix& viewMatrix );
-
- /**
- * Private constructor. See New()
- */
- MeshRenderer(RenderDataProvider& dataprovider);
-
- // Undefined
- MeshRenderer(const MeshRenderer&);
-
- // Undefined
- MeshRenderer& operator=(const MeshRenderer& rhs);
-
-private:
-
- MeshInfo mMeshInfo[2]; ///< Double-buffered for update/render in separate threads.
- GeometryType mGeometryType; ///< Records last geometry type
- ShaderSubTypes mShaderType; ///< Records last shader type
-
- static const unsigned int mNumberOfCustomUniforms = 13; // Number of uniforms needed for renderer
- CustomUniform mCustomUniform[SHADER_SUBTYPE_LAST][ mNumberOfCustomUniforms ];
- RenderMaterialUniforms mRenderMaterialUniforms; ///< Uniforms for render material
-
-};
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_SCENE_GRAPH_MESH_RENDERER_H__
#include <dali/internal/update/node-attachments/scene-graph-renderable-attachment.h>
#include <dali/internal/render/renderers/scene-graph-renderer.h>
#include <dali/internal/render/shaders/shader.h>
-#include <dali/internal/update/modeling/scene-graph-mesh.h>
namespace Dali
{
namespace SceneGraph
{
-namespace // unnamed namespace
-{
-
-static void DoGlCleanup( BufferIndex updateBufferIndex, GlResourceOwner& owner, RenderQueue& renderQueue )
-{
- typedef Message< GlResourceOwner > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &owner, &GlResourceOwner::GlCleanup );
-}
-
-} // unnamed namespace
-
DiscardQueue::DiscardQueue( RenderQueue& renderQueue )
: mRenderQueue( renderQueue )
{
}
}
-void DiscardQueue::Add( BufferIndex updateBufferIndex, Mesh* mesh )
-{
- DALI_ASSERT_DEBUG( mesh );
-
- // Send message to clean-up GL resources in the next Render
- DoGlCleanup( updateBufferIndex, *mesh, mRenderQueue );
-
- // The GL resources will now be freed in frame N
- // The Update for frame N+1 may occur in parallel with the rendering of frame N
- // Queue the node for destruction in frame N+2
- if ( 0u == updateBufferIndex )
- {
- mMeshQueue0.PushBack( mesh );
- }
- else
- {
- mMeshQueue1.PushBack( mesh );
- }
-}
-
void DiscardQueue::Add( BufferIndex updateBufferIndex, Shader* shader )
{
DALI_ASSERT_DEBUG( NULL != shader );
{
mNodeQueue0.Clear();
mAttachmentQueue0.Clear();
- mMeshQueue0.Clear();
mShaderQueue0.Clear();
}
else
{
mNodeQueue1.Clear();
mAttachmentQueue1.Clear();
- mMeshQueue1.Clear();
mShaderQueue1.Clear();
}
}
#include <dali/internal/common/owner-container.h>
#include <dali/internal/update/nodes/node-declarations.h>
#include <dali/internal/update/node-attachments/node-attachment-declarations.h>
-#include <dali/internal/update/modeling/scene-graph-mesh-declarations.h>
namespace Dali
{
void Add( BufferIndex updateBufferIndex, NodeAttachment* attachment );
/**
- * Adds an unwanted mesh resource to the discard queue.
- * A message will be sent to clean-up GL resources in the next Render.
- * @pre This method is not thread-safe, and should only be called from the update-thread.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] mesh The mesh to queue; DiscardQueue takes a reference.
- */
- void Add( BufferIndex updateBufferIndex, Mesh* mesh );
-
- /**
* Adds an unwanted shader to the discard queue.
* A message will be sent to clean-up GL resources in the next Render.
* @pre This method is not thread-safe, and should only be called from the update-thread.
// Messages are queued here when the update buffer index == 0
NodeOwnerContainer mNodeQueue0;
NodeAttachmentOwnerContainer mAttachmentQueue0;
- MeshOwnerContainer mMeshQueue0;
ShaderQueue mShaderQueue0;
// Messages are queued here when the update buffer index == 1
NodeOwnerContainer mNodeQueue1;
NodeAttachmentOwnerContainer mAttachmentQueue1;
- MeshOwnerContainer mMeshQueue1;
ShaderQueue mShaderQueue1;
-
};
} // namespace SceneGraph
if( Dali::DynamicsBodyConfig::SOFT == settings->type )
{
- Mesh* mesh( static_cast<DynamicsMeshShape&>(*shape).GetMesh() );
- DALI_ASSERT_DEBUG( mesh );
- mMesh = mesh;
+ // @todo Create a mesh from the dynamics body.
}
Vector3 position;
void DynamicsBody::RefreshMesh(BufferIndex updateBufferIndex)
{
- Internal::MeshData& meshData( mMesh->GetMeshData( Mesh::UPDATE_THREAD ) );
-
- mBody->GetSoftVertices( meshData.GetVertices() );
-
- mMesh->MeshDataUpdated( updateBufferIndex, Mesh::UPDATE_THREAD, NULL );
+ ///@todo Update the mesh from the dynamics body.
}
} // namespace SceneGraph
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/update/dynamics/scene-graph-dynamics-mesh-shape.h>
-
-// INTERNAL HEADERS
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/dynamics/dynamics-factory-intf.h>
-#include <dali/integration-api/dynamics/dynamics-shape-intf.h>
-#include <dali/internal/update/resources/resource-manager.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/update/dynamics/scene-graph-dynamics-world.h>
-#include <dali/internal/update/modeling/scene-graph-mesh.h>
-#include <dali/internal/update/modeling/internal-mesh-data.h>
-#include <dali/public-api/dynamics/dynamics-shape.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-
-DynamicsMeshShape::DynamicsMeshShape(DynamicsWorld& world, ResourceManager& resourceManager, const Integration::ResourceId meshId )
-: DynamicsShape(world),
- mResourceManager(resourceManager),
- mMeshId(meshId)
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - meshId:%d\n", __PRETTY_FUNCTION__, static_cast<int>(mMeshId));
-}
-
-
-DynamicsMeshShape::~DynamicsMeshShape()
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__);
-}
-
-void DynamicsMeshShape::Initialize()
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- mShape = mWorld.GetDynamicsFactory().CreateDynamicsShape();
-
- Mesh* mesh( GetMesh() );
- DALI_ASSERT_DEBUG( mesh );
-
- MeshData& meshData( mesh->GetMeshData(Mesh::UPDATE_THREAD ) );
- mShape->Initialize( Dali::DynamicsShape::MESH, meshData.GetVertices(), meshData.GetFaces() );
-
- DynamicsShape::Initialize();
-}
-
-Mesh* DynamicsMeshShape::GetMesh() const
-{
- return mResourceManager.GetMesh(mMeshId);
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __SCENE_GRAPH_DYNAMICS_MESH_SHAPE_H__
-#define __SCENE_GRAPH_DYNAMICS_MESH_SHAPE_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// BASE CLASS HEADERS
-#include <dali/internal/update/dynamics/scene-graph-dynamics-shape.h>
-
-// INTERNAL HEADERS
-#include <dali/integration-api/resource-declarations.h>
-#include <dali/internal/common/message.h>
-#include <dali/internal/common/event-to-update.h>
-#include <dali/internal/event/dynamics/dynamics-declarations.h>
-#include <dali/internal/update/modeling/scene-graph-mesh-declarations.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class ResourceManager;
-
-namespace SceneGraph
-{
-
-class DynamicsWorld;
-
-class DynamicsMeshShape : public DynamicsShape
-{
-public:
- /**
- * Constructor.
- * @param[in] world The dynamics world object
- * @param[in] resourceManager The resource manager
- * @param[in] meshId ID for the mesh resource
- */
- DynamicsMeshShape( DynamicsWorld& world, ResourceManager& resourceManager, const Integration::ResourceId meshId );
-
- /**
- * Destructor.
- */
- virtual ~DynamicsMeshShape();
-
- /**
- * Initialize the mesh.
- */
- void Initialize();
-
- Mesh* GetMesh() const;
-
-private:
- // unimplemented copy constructor and assignment operator
- DynamicsMeshShape(const DynamicsMeshShape&);
- DynamicsMeshShape& operator=(const DynamicsMeshShape&);
-
-private:
- ResourceManager& mResourceManager;
- Integration::ResourceId mMeshId;
-}; // class DynamicsMeshShape
-
-inline void InitializeDynamicsMeshShapeMessage( EventToUpdate& eventToUpdate, const DynamicsMeshShape& shape )
-{
- typedef Message< DynamicsMeshShape > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &shape, &DynamicsMeshShape::Initialize );
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __SCENE_GRAPH_DYNAMICS_MESH_SHAPE_H__
inline void SetOpaqueRenderFlags( RenderList& renderList, bool transparentRenderersExist, bool stencilRenderablesExist, bool depthTestDisabled )
{
// Special optimization if depth test is disabled or if only one opaque rendered in the layer (for example background image)
- // and this renderer does not need depth test against itself (for example a mesh actor)
- // if this layer has got exactly one opaque renderer
+ // and this renderer does not need depth test against itself (e.g. mesh)
+ // and if this layer has got exactly one opaque renderer
// and this renderer is not interested in depth testing
// (i.e. is an image and not a mesh)
if ( ( ( renderList.Count() == 1 ) &&
}
}
-inline void UpdateNodeGeometry( Node &node, int nodeDirtyFlags, BufferIndex updateBufferIndex )
-{
- if ( nodeDirtyFlags & SizeFlag )
- {
- Vector3 geometryScale( 1.0f, 1.0f, 1.0f );
-
- if ( node.GetTransmitGeometryScaling() )
- {
- const Vector3& requiredSize = node.GetSize( updateBufferIndex );
- geometryScale = FitKeepAspectRatio( requiredSize, node.GetInitialVolume() );
- }
-
- if ( node.GetGeometryScale() != geometryScale )
- {
- node.SetGeometryScale( geometryScale );
- }
- }
-}
-
inline void UpdateRootNodeTransformValues( Layer& rootNode, int nodeDirtyFlags, BufferIndex updateBufferIndex )
{
// If the transform values need to be reinherited
{
if( updatedRenderable.UsesGeometryScaling() )
{
- // scaling, i.e. Text or Mesh
Vector3 scaling;
updatedRenderable.GetScaleForSize( node.GetSize( updateBufferIndex ), scaling );
if( node.GetInhibitLocalTransform() )
UpdateNodeOpacity( node, nodeDirtyFlags, updateBufferIndex );
- UpdateNodeGeometry( node, nodeDirtyFlags, updateBufferIndex );
-
// Note: nodeDirtyFlags are passed in by reference and may be modified by the following function.
// It is important that the modified version of these flags are used by the RenderableAttachment.
UpdateNodeTransformValues( node, nodeDirtyFlags, updateBufferIndex );
#include <dali/internal/update/controllers/render-message-dispatcher.h>
#include <dali/internal/update/controllers/scene-controller-impl.h>
#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
-#include <dali/internal/update/modeling/scene-graph-material.h>
#include <dali/internal/update/node-attachments/scene-graph-camera-attachment.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/internal/render/queue/render-queue.h>
#include <dali/internal/render/common/performance-monitor.h>
#include <dali/internal/render/gl-resources/texture-cache.h>
-#include <dali/internal/render/renderers/render-material.h>
#include <dali/internal/render/shaders/shader.h>
#ifdef DYNAMICS_SUPPORT
typedef ShaderContainer::Iterator ShaderIter;
typedef ShaderContainer::ConstIterator ShaderConstIter;
-typedef AnimatableMeshContainer::Iterator AnimatableMeshIter;
-typedef AnimatableMeshContainer::ConstIterator AnimatableMeshConstIter;
-typedef MaterialContainer::Iterator MaterialIter;
-
typedef OwnerContainer<PanGesture*> GestureContainer;
typedef GestureContainer::Iterator GestureIter;
typedef GestureContainer::ConstIterator GestureConstIter;
PropertyNotificationContainer propertyNotifications; ///< A container of owner property notifications.
ShaderContainer shaders; ///< A container of owned shaders
- AnimatableMeshContainer animatableMeshes; ///< A container of owned animatable meshes
- MaterialContainer materials; ///< A container of owned materials
MessageQueue messageQueue; ///< The messages queued from the event-thread
}
}
-void UpdateManager::AddAnimatableMesh( AnimatableMesh* animatableMesh )
-{
- mImpl->animatableMeshes.PushBack(animatableMesh);
-}
-
-void UpdateManager::RemoveAnimatableMesh( AnimatableMesh* animatableMesh )
-{
- DALI_ASSERT_DEBUG(animatableMesh != NULL);
-
- AnimatableMeshContainer& animatableMeshes = mImpl->animatableMeshes;
-
- // Find the animatableMesh and destroy it
- for ( AnimatableMeshIter iter = animatableMeshes.Begin(); iter != animatableMeshes.End(); ++iter )
- {
- AnimatableMesh& current = **iter;
- if ( ¤t == animatableMesh )
- {
- animatableMeshes.Erase( iter );
- break;
- }
- }
-}
-
-void UpdateManager::AddMaterial( Material* material )
-{
- DALI_ASSERT_DEBUG( NULL != material );
-
- mImpl->materials.PushBack( material );
- RenderMaterial* renderMaterial = new RenderMaterial();
-
- typedef MessageValue1< RenderManager, RenderMaterial* > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddRenderMaterial, renderMaterial );
-
- material->SetRenderMaterial( renderMaterial );
- material->OnStageConnection( *mImpl->sceneController );
-}
-
-void UpdateManager::RemoveMaterial( Material* theMaterial )
-{
- // Caused by last reference to material being released (e.g. app or internal mesh-actor)
-
- for ( MaterialIter iter=mImpl->materials.Begin(), end=mImpl->materials.End() ; iter != end ; ++iter )
- {
- const Material* aMaterial = *iter;
-
- if( aMaterial == theMaterial )
- {
- typedef MessageValue1< RenderManager, RenderMaterial* > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveRenderMaterial, theMaterial->GetRenderMaterial() );
-
- mImpl->materials.Erase( iter );
- break;
- }
- }
-}
-
RenderTaskList* UpdateManager::GetRenderTaskList( bool systemLevel )
{
if ( !systemLevel )
(*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
}
- // Reset animatable mesh properties to base values
- for ( AnimatableMeshIter iter = mImpl->animatableMeshes.Begin(); iter != mImpl->animatableMeshes.End(); ++iter )
- {
- (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
- }
-
PERF_MONITOR_END(PerformanceMonitor::RESET_PROPERTIES);
}
mImpl->activeConstraints += ConstrainPropertyOwner( task, mSceneGraphBuffers.GetUpdateBufferIndex() );
}
- // constrain meshes (in construction order)
- AnimatableMeshContainer& meshes = mImpl->animatableMeshes;
- for ( AnimatableMeshIter iter = meshes.Begin(); iter != meshes.End(); ++iter )
- {
- AnimatableMesh& mesh = **iter;
- mImpl->activeConstraints += ConstrainPropertyOwner( mesh, mSceneGraphBuffers.GetUpdateBufferIndex() );
- }
-
// constrain shaders... (in construction order)
ShaderContainer& shaders = mImpl->shaders;
PERF_MONITOR_END( PerformanceMonitor::UPDATE_NODES );
}
-void UpdateManager::UpdateMeshes( BufferIndex updateBufferIndex, AnimatableMeshContainer& meshes )
-{
- for ( AnimatableMeshIter iter = meshes.Begin(); iter != meshes.End(); ++iter )
- {
- AnimatableMesh& current = **iter;
- current.UpdateMesh( updateBufferIndex );
- }
-}
-
-void UpdateManager::UpdateMaterials( BufferIndex updateBufferIndex, MaterialContainer& materials )
-{
- for( MaterialIter iter = materials.Begin(), end = materials.End(); iter != end; iter++ )
- {
- Material* material = *iter;
- material->PrepareResources( updateBufferIndex, mImpl->resourceManager );
- }
-}
-
-void UpdateManager::PrepareMaterials( BufferIndex updateBufferIndex, MaterialContainer& materials )
-{
- for( MaterialIter iter = materials.Begin(), end = materials.End(); iter != end; iter++ )
- {
- Material* material = *iter;
- material->PrepareRender( updateBufferIndex );
- }
-}
-
unsigned int UpdateManager::Update( float elapsedSeconds,
unsigned int lastVSyncTimeMilliseconds,
unsigned int nextVSyncTimeMilliseconds )
ClearRenderables( mImpl->sortedLayers );
ClearRenderables( mImpl->systemLevelSortedLayers );
- // 12) Update animated meshes
- UpdateMeshes( mSceneGraphBuffers.GetUpdateBufferIndex(), mImpl->animatableMeshes );
-
- // 13) Update materials. Prepares image resources
- UpdateMaterials( mSceneGraphBuffers.GetUpdateBufferIndex(), mImpl->materials );
-
- // 14) Update node hierarchy and perform sorting / culling.
+ // 12) Update node hierarchy and perform sorting / culling.
// This will populate each Layer with a list of renderers which are ready.
UpdateNodes();
- // 15) Prepare for the next render
+ // 13) Prepare for the next render
PERF_MONITOR_START(PerformanceMonitor::PREPARE_RENDERABLES);
- PrepareMaterials( mSceneGraphBuffers.GetUpdateBufferIndex(), mImpl->materials );
+
PrepareRenderables( mSceneGraphBuffers.GetUpdateBufferIndex(), mImpl->sortedLayers );
PrepareRenderables( mSceneGraphBuffers.GetUpdateBufferIndex(), mImpl->systemLevelSortedLayers );
PERF_MONITOR_END(PerformanceMonitor::PREPARE_RENDERABLES);
PERF_MONITOR_START(PerformanceMonitor::PROCESS_RENDER_TASKS);
- // 16) Process the RenderTasks; this creates the instructions for rendering the next frame.
+ // 14) Process the RenderTasks; this creates the instructions for rendering the next frame.
// reset the update buffer index and make sure there is enough room in the instruction container
mImpl->renderInstructions.ResetAndReserve( mSceneGraphBuffers.GetUpdateBufferIndex(),
mImpl->taskList.GetTasks().Count() + mImpl->systemLevelTaskList.GetTasks().Count() );
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/update/animation/scene-graph-animation.h>
#include <dali/internal/update/common/scene-graph-property-notification.h>
-#include <dali/internal/update/modeling/scene-graph-animatable-mesh.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/internal/common/type-abstraction-enums.h>
namespace SceneGraph
{
-class AnimatableMesh;
class Animation;
class DiscardQueue;
-class Material;
class PanGesture;
class RenderManager;
class RenderTaskList;
class RenderQueue;
class DynamicsWorld;
class TextureCache;
-typedef OwnerContainer< AnimatableMesh* > AnimatableMeshContainer;
-typedef OwnerContainer< Material* > MaterialContainer;
/**
* UpdateManager holds a scene graph i.e. a tree of nodes.
void SetShaderProgram( Shader* shader, GeometryType geometryType, ShaderSubTypes subType, Integration::ResourceId resourceId, size_t shaderHash, bool modifiesGeometry );
/**
- * Add an animatable mesh
- * @param[in] animatableMesh The animatable mesh to add.
- * @post the animatableMesh is owned by the UpdateManager.
- */
- void AddAnimatableMesh( AnimatableMesh* animatableMesh );
-
- /**
- * Remove an animatable mesh
- * @pre The animatable mesh has been added to the update manager
- * @param[in] animatableMesh The animatable mesh to add.
- */
- void RemoveAnimatableMesh( AnimatableMesh* animatableMesh );
-
- /**
- * Add a material
- * @param[in] material The material to add
- * @post the material remains owned by its event object
- */
- void AddMaterial(Material* material);
-
- /**
- * Remove a material
- * @pre The material has been added to the UpdateManager
- * @param[in] material The material to remove
- */
- void RemoveMaterial(Material* material);
-
- /**
* Add a newly created gesture.
* @param[in] gesture The gesture to add.
* @post The gesture is owned by the UpdateManager.
*/
void UpdateNodes();
- /**
- * Update animatable meshes
- */
- void UpdateMeshes( BufferIndex updateBufferIndex, AnimatableMeshContainer& meshes );
-
- /**
- * Update materials - Ensure all render materials are updated with texture pointers
- * when ready.
- */
- void UpdateMaterials( BufferIndex updateBufferIndex, MaterialContainer& materials );
-
- /**
- * PrepareMaterials - Ensure updated material properties are sent to render materials
- */
- void PrepareMaterials( BufferIndex updateBufferIndex, MaterialContainer& materials );
-
private:
// needs to be direct member so that getter for event buffer can be inlined
new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, geometryType, subType, resourceId, shaderHash, modifiesGeometry );
}
-// The render thread can safely change the AnimatableMesh
-inline void AddAnimatableMeshMessage( UpdateManager& manager, AnimatableMesh& animatableMesh )
-{
- typedef MessageValue1< UpdateManager, AnimatableMesh* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::AddAnimatableMesh, &animatableMesh );
-}
-
-// The render thread can safely change the AnimatableMesh
-inline void RemoveAnimatableMeshMessage( UpdateManager& manager, AnimatableMesh& animatableMesh )
-{
- typedef MessageValue1< UpdateManager, AnimatableMesh* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::RemoveAnimatableMesh, &animatableMesh );
-}
-
-
inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
{
typedef MessageValue1< UpdateManager, Vector4 > LocalType;
new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
}
-inline void AddMaterialMessage( UpdateManager& manager, Material* material )
-{
- typedef MessageValue1< UpdateManager, Material* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::AddMaterial, material );
-}
-
-inline void RemoveMaterialMessage( UpdateManager& manager, Material* material )
-{
- typedef MessageValue1< UpdateManager, Material* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::RemoveMaterial, material );
-}
-
inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
{
typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_BONE_TRANSFORMS_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_BONE_TRANSFORMS_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/math/matrix3.h>
-#include <dali/public-api/math/matrix.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-static const size_t MAX_NUMBER_OF_BONES_PER_MESH = 12;
-
-struct BoneTransforms
-{
- std::vector<Matrix> transforms; // Bone transform matrices, calculated once per update
- std::vector<Matrix> viewTransforms; // The transform matrices multiplied by current view, calculated once per render task
- std::vector<Matrix3> inverseTransforms; // inverse of the viewTransform matrix, calculated once per render task
-};
-
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_SCENE_GRAPH_BONE_TRANSFORMS_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/internal/update/modeling/internal-mesh-data.h>
-
-#include <dali/integration-api/platform-abstraction.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-MeshData::MeshData( const Dali::MeshData& meshData, ResourcePolicy::Discardable discardable, bool scalingRequired )
-: mVertices( meshData.GetVertices() ),
- mFaces( meshData.GetFaces() ),
- mBones( meshData.GetBones() ),
- mNumberOfVertices( mVertices.size() ),
- mNumberOfFaceIndices( mFaces.size() ),
- mGeometryType( meshData.GetVertexGeometryType() ),
- mHasNormals( meshData.HasNormals() ),
- mHasColor( meshData.HasColor() ),
- mDiscardable( discardable==ResourcePolicy::DISCARD ),
- mDiscarded( false ),
- mScalingRequired( scalingRequired )
-{
-}
-
-size_t MeshData::GetVertexCount() const
-{
- return mNumberOfVertices;
-}
-
-size_t MeshData::GetFaceCount() const
-{
- size_t faceCount = 0;
-
- switch( mGeometryType )
- {
- case Dali::MeshData::POINTS:
- faceCount = mNumberOfVertices;
- break;
- case Dali::MeshData::LINES:
- faceCount = mNumberOfFaceIndices / 2;
- break;
- case Dali::MeshData::TRIANGLES:
- faceCount = mNumberOfFaceIndices / 3;
- break;
- }
- return faceCount;
-}
-
-size_t MeshData::GetFaceIndexCount() const
-{
- return mNumberOfFaceIndices;
-}
-
-size_t MeshData::GetBoneCount() const
-{
- return mBones.size();
-}
-
-Dali::MeshData::VertexGeometryType MeshData::GetVertexGeometryType() const
-{
- return mGeometryType;
-}
-
-const MeshData::VertexContainer& MeshData::GetVertices() const
-{
- DALI_ASSERT_DEBUG( !mVertices.empty() );
- return mVertices;
-}
-
-MeshData::VertexContainer& MeshData::GetVertices()
-{
- DALI_ASSERT_DEBUG( !mVertices.empty() );
- return mVertices;
-}
-
-void MeshData::SetVertices( const MeshData::VertexContainer& vertices )
-{
- mVertices = vertices;
- mNumberOfVertices = vertices.size();
-}
-
-const MeshData::FaceIndices& MeshData::GetFaces() const
-{
- DALI_ASSERT_DEBUG( !mFaces.empty() );
- return mFaces;
-}
-
-const Dali::BoneContainer& MeshData::GetBones() const
-{
- return mBones;
-}
-
-bool MeshData::HasNormals() const
-{
- return mHasNormals;
-}
-
-bool MeshData::HasColor() const
-{
- return mHasColor;
-}
-
-void MeshData::Discard()
-{
- if( mDiscardable )
- {
- DALI_ASSERT_DEBUG( !mDiscarded );
- VertexContainer().swap(mVertices); // this will enforce releasing the memory
- FaceIndices().swap(mFaces); // this will enforce releasing the memory
- mDiscarded = true;
- }
-}
-
-bool MeshData::IsScalingRequired() const
-{
- return mScalingRequired;
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_MESH_DATA_H__
-#define __DALI_INTERNAL_MESH_DATA_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/public-api/geometry/mesh-data.h>
-#include <dali/integration-api/resource-policies.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-/**
- * Internal MeshData class to hold the data required to describe and
- * render a 3D mesh.
- *
- * This class is the internal equivalent of the public api MeshData.
- *
- * For more details about the data it holds look at Dali::MeshData.
- */
-
-class MeshData
-{
-public:
-
- // Reuse the types as Dali::MeshData
- typedef Dali::MeshData::Vertex Vertex;
- typedef Dali::MeshData::VertexContainer VertexContainer;
- typedef Dali::MeshData::FaceIndices FaceIndices;
- typedef Dali::BoneContainer BoneContainer;
-
- /**
- * Create a new MeshData from a Dali::MeshData object.
- * This constructor is explicit to prevent accidental copies.
- * @param[in] meshData object to copy
- * @param[in] discardable if true, the vertex and index data will be discarded after they are uploaded to gl
- * @param[in] scalingRequired - True if this Mesh should be scaled to fit actor size
- */
- explicit MeshData( const Dali::MeshData& meshData, ResourcePolicy::Discardable discardable, bool scalingRequired );
-
- /**
- * @copydoc Dali::MeshData::GetVertexCount
- */
- size_t GetVertexCount() const;
-
- /**
- * @copydoc Dali::MeshData::GetFaceCount
- */
- size_t GetFaceCount() const;
-
- /**
- * @copydoc Dali::MeshData::GetFaceIndexCount
- */
- size_t GetFaceIndexCount() const;
-
- /**
- * @copydoc Dali::MeshData::GetBoneCount
- */
- size_t GetBoneCount() const;
-
- /**
- * @copydoc Dali::MeshData::GetVertexGeometryType
- */
- Dali::MeshData::VertexGeometryType GetVertexGeometryType() const;
-
- /**
- * @copydoc Dali::MeshData::GetVertices
- */
- const VertexContainer& GetVertices() const;
-
- /**
- * @copydoc Dali::MeshData::GetVertices
- */
- VertexContainer& GetVertices();
-
- /**
- * @copydoc Dali::MeshData::GetVertices
- */
- void SetVertices( const VertexContainer& vertices );
-
- /**
- * @copydoc Dali::MeshData::GetFaces
- */
- const FaceIndices& GetFaces() const;
-
- /**
- * @copydoc Dali::MeshData::GetBones
- */
- const Dali::BoneContainer& GetBones() const;
-
- /**
- * @copydoc Dali::MeshData::HasNormals
- */
- bool HasNormals() const;
-
- /**
- * @copydoc Dali::MeshData::HasColor
- */
- bool HasColor() const;
-
- /**
- * Discard the geometrical data.
- */
- void Discard();
-
- /**
- * Query whether this Mesh should be scaled to fit actor size.
- * @return True if scaling is required.
- */
- bool IsScalingRequired() const;
-
-private:
- VertexContainer mVertices;
- FaceIndices mFaces;
- BoneContainer mBones;
-
- size_t mNumberOfVertices;
- size_t mNumberOfFaceIndices;
-
- Dali::MeshData::VertexGeometryType mGeometryType;
-
- bool mHasNormals : 1;
- bool mHasColor : 1;
-
- bool mDiscardable : 1;
- bool mDiscarded : 1;
-
- bool mScalingRequired : 1;
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_MESH_DATA_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/update/modeling/scene-graph-animatable-mesh.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/resources/resource-manager.h>
-#include <dali/internal/update/modeling/scene-graph-mesh.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-
-AnimatableMesh::AnimatableMesh( ResourceManager& resourceManager,
- ResourceId meshId,
- const MeshData::VertexContainer& vertices )
-: mResourceManager(resourceManager),
- mMeshId(meshId)
-{
- mNumVertices = vertices.size();
-
- // Allocate a single block of memory for all properties
- // (Can't use std::vector, as AnimatableProperties is a non-copyable type).
- mVertices = static_cast<VertexProperties*>( operator new [] (sizeof(VertexProperties) * mNumVertices) );
-
- for(unsigned int i=0; i<mNumVertices; i++)
- {
- // Use placement new to instantiate the vertex properties
- new ( &mVertices[i] ) VertexProperties( vertices[i] );
- }
-}
-
-AnimatableMesh::~AnimatableMesh()
-{
- for(unsigned int i=0; i<mNumVertices; i++)
- {
- // Used placement new to instantiate these objects, so have to directly call destructors
- mVertices[i].~VertexProperties();
- }
- operator delete [] (mVertices);
-}
-
-void AnimatableMesh::UpdateMesh( BufferIndex updateBufferIndex )
-{
- // Copy properties to associated scenegraph mesh
- SceneGraph::Mesh* mesh(mResourceManager.GetMesh(mMeshId));
-
- // TODO: Should be double buffered - pass in buffer index
- MeshData& meshData = mesh->GetMeshData(Mesh::UPDATE_THREAD);
-
- bool meshUpdated( false );
- MeshData::VertexContainer& oldVertices = meshData.GetVertices();
- DALI_ASSERT_DEBUG( oldVertices.size() == mNumVertices );
- DALI_ASSERT_DEBUG( oldVertices.size() > 0 );
-
- MeshData::Vertex* vertices = &oldVertices.at(0);
- for(std::size_t i=0; i<mNumVertices; i++)
- {
- if ( ! mVertices[i].position.IsClean() )
- {
- const Vector3& position = GetPosition(updateBufferIndex, i);
- vertices[i].x = position.x;
- vertices[i].y = position.y;
- vertices[i].z = position.z;
-
- meshUpdated = true;
- }
-
- if ( ! mVertices[i].color.IsClean() )
- {
- const Vector4& color = GetColor(updateBufferIndex, i);
- vertices[i].vertexR = color.r;
- vertices[i].vertexG = color.g;
- vertices[i].vertexB = color.b;
-
- meshUpdated = true;
- }
-
- if ( ! mVertices[i].textureCoords.IsClean() )
- {
- const Vector2& texcoords = GetTextureCoords(updateBufferIndex, i);
- vertices[i].u = texcoords.x;
- vertices[i].v = texcoords.y;
-
- meshUpdated = true;
- }
- }
-
- if ( meshUpdated )
- {
- mesh->MeshDataUpdated(updateBufferIndex, Mesh::UPDATE_THREAD, NULL);
- }
-}
-
-void AnimatableMesh::BakePosition( BufferIndex updateBufferIndex, unsigned int vertex, const Vector3& position )
-{
- mVertices[vertex].position.Bake( updateBufferIndex, position );
-}
-
-void AnimatableMesh::BakeColor( BufferIndex updateBufferIndex, unsigned int vertex, const Vector4& color )
-{
- mVertices[vertex].color.Bake( updateBufferIndex, color );
-}
-
-void AnimatableMesh::BakeTextureCoords( BufferIndex updateBufferIndex, unsigned int vertex, const Vector2& coords )
-{
- mVertices[vertex].textureCoords.Bake( updateBufferIndex, coords );
-}
-
-const Vector3& AnimatableMesh::GetPosition( BufferIndex bufferIndex, unsigned int vertexIndex )
-{
- return mVertices[vertexIndex].position.Get(bufferIndex);
-}
-
-const Vector4& AnimatableMesh::GetColor( BufferIndex bufferIndex, unsigned int vertexIndex )
-{
- return mVertices[vertexIndex].color.Get(bufferIndex);
-}
-
-const Vector2& AnimatableMesh::GetTextureCoords( BufferIndex bufferIndex, unsigned int vertexIndex )
-{
- return mVertices[vertexIndex].textureCoords.Get(bufferIndex);
-}
-
-void AnimatableMesh::ResetDefaultProperties( BufferIndex updateBufferIndex )
-{
- for( std::size_t i=0; i<mNumVertices; i++)
- {
- mVertices[i].position.ResetToBaseValue( updateBufferIndex );
- mVertices[i].color.ResetToBaseValue( updateBufferIndex );
- mVertices[i].textureCoords.ResetToBaseValue( updateBufferIndex );
- }
-}
-
-} // SceneGraph
-
-} // Internal
-
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_MESH_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_MESH_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/internal/common/buffer-index.h>
-#include <dali/internal/common/message.h>
-#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
-#include <dali/internal/update/modeling/internal-mesh-data.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class ResourceManager;
-
-namespace SceneGraph
-{
-
-class Mesh;
-
-/**
- * This manages a set of animatable vertex properties and the updating
- * of an associated SceneGraph::Mesh object.
- */
-class AnimatableMesh : public PropertyOwner
-{
-public:
- /**
- * Constructor
- */
- AnimatableMesh( ResourceManager& resourceManager,
- ResourceId meshId,
- const MeshData::VertexContainer& vertices );
-
- /**
- * Destructor
- */
- ~AnimatableMesh();
-
- /**
- * Update the associated scenegraph mesh from the current properties
- * @param[in] updateBufferIndex The current update buffer index.
- */
- void UpdateMesh( BufferIndex updateBufferIndex );
-
- /**
- * Set the vertex position
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] vertex The index of the vertex
- * @param[in] position The position.
- */
- void BakePosition( BufferIndex updateBufferIndex, unsigned int vertex, const Vector3& position );
-
- /**
- * Set the vertex color
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] vertex The index of the vertex
- * @param[in] color The color.
- */
- void BakeColor( BufferIndex updateBufferIndex, unsigned int vertex, const Vector4& color );
-
- /**
- * Set the vertex texture coordinates
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] vertex The index of the vertex
- * @param[in] coords The texture coordinates.
- */
- void BakeTextureCoords( BufferIndex updateBufferIndex, unsigned int vertex, const Vector2& coords );
-
- /**
- * Get the vertex position
- * @param[in] bufferIndex The buffer to read from
- * @param[in] vertexIndex The index of the vertex
- * @return The position.
- */
- const Vector3& GetPosition( BufferIndex bufferIndex, unsigned int vertexIndex );
-
- /**
- * Get the vertex color
- * @param[in] bufferIndex The buffer to read from
- * @param[in] vertex The index of the vertex
- * @return The color.
- */
- const Vector4& GetColor( BufferIndex bufferIndex, unsigned int vertexIndex );
-
- /**
- * Get the vertex texture coordinates
- * @param[in] bufferIndex The buffer to read from
- * @param[in] vertex The index of the vertex
- * @return coords The texture coordinates.
- */
- const Vector2& GetTextureCoords( BufferIndex bufferIndex, unsigned int vertex );
-
-private: // PropertyOwner
-
- /**
- * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
- */
- virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
-
-public:
-
- struct VertexProperties
- {
- VertexProperties( const Dali::Internal::MeshData::Vertex& v )
- : position( Vector3(v.x, v.y, v.z) ),
- color( Vector4(v.vertexR, v.vertexG, v.vertexB, 1.0f) ),
- textureCoords( Vector2(v.u, v.v) )
- {
- }
-
- VertexProperties(const VertexProperties& rhs)
- : position( rhs.position.Get(0) ),
- color( rhs.color.Get(0) ),
- textureCoords( rhs.textureCoords.Get(0) )
- {
- }
-
- AnimatableProperty<Vector3> position;
- AnimatableProperty<Vector4> color;
- AnimatableProperty<Vector2> textureCoords;
-
- private:
- VertexProperties& operator=(const VertexProperties& rhs);
- };
-
- VertexProperties* mVertices;
- std::size_t mNumVertices;
-
-private:
-
- ResourceManager& mResourceManager; ///< The resource manager object
- ResourceId mMeshId; ///< The resource id of the scene graph mesh
-};
-
-inline void BakeVertexPositionMessage( EventToUpdate& eventToUpdate, const SceneGraph::AnimatableMesh& mesh, unsigned int vertex, const Vector3& position )
-{
- typedef MessageDoubleBuffered2< SceneGraph::AnimatableMesh, unsigned int, Vector3 > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &mesh, &SceneGraph::AnimatableMesh::BakePosition, vertex, position );
-}
-
-inline void BakeVertexColorMessage( EventToUpdate& eventToUpdate, const SceneGraph::AnimatableMesh& mesh, unsigned int vertex, const Vector4& color )
-{
- typedef MessageDoubleBuffered2< SceneGraph::AnimatableMesh, unsigned int, Vector4 > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &mesh, &SceneGraph::AnimatableMesh::BakeColor, vertex, color );
-}
-
-inline void BakeVertexTextureCoordsMessage( EventToUpdate& eventToUpdate, const SceneGraph::AnimatableMesh& mesh, unsigned int vertex, const Vector2& coords )
-{
- typedef MessageDoubleBuffered2< SceneGraph::AnimatableMesh, unsigned int, Vector2 > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &mesh, &SceneGraph::AnimatableMesh::BakeTextureCoords, vertex, coords );
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
-
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/update/modeling/scene-graph-material.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/images/image.h>
-#include <dali/internal/common/internal-constants.h>
-#include <dali/internal/event/images/image-impl.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/update/resources/resource-manager.h>
-#include <dali/internal/update/controllers/scene-controller.h>
-#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/renderers/render-material.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-
-Material* Material::New()
-{
- ResourceManager& resourceManager = ThreadLocalStorage::Get().GetResourceManager();
- return new Material(resourceManager);
-}
-
-Material* Material::New(Internal::Material* material)
-{
- ResourceManager& resourceManager = ThreadLocalStorage::Get().GetResourceManager();
- return new Material(resourceManager, material);
-}
-
-Material::Material(ResourceManager& resourceManager)
- :
- mResourceManager(resourceManager),
- mSceneController(NULL),
- mRenderMaterial(NULL),
- mProperties(),
- mDiffuseResourceId(0),
- mOpacityResourceId(0),
- mNormalMapResourceId(0),
- mDiffuseTextureState(RESOURCE_NOT_USED),
- mOpacityTextureState(RESOURCE_NOT_USED),
- mNormalMapTextureState(RESOURCE_NOT_USED),
- mIsReady(false),
- mIsDirty(false)
-{
-}
-
-Material::Material(ResourceManager& resourceManager, Internal::Material* material)
- : mResourceManager(resourceManager),
- mSceneController(NULL),
- mRenderMaterial(NULL),
- mProperties(material->GetProperties()),
- mDiffuseResourceId(),
- mOpacityResourceId(0),
- mNormalMapResourceId(0),
- mDiffuseTextureState(RESOURCE_NOT_USED),
- mOpacityTextureState(RESOURCE_NOT_USED),
- mNormalMapTextureState(RESOURCE_NOT_USED),
- mIsReady(false),
- mIsDirty(true)
-{
- // Not on stage during construction, so OK to use Dali::Image directly.
-
- Dali::Image diffuseImage = material->GetDiffuseTexture();
- if (diffuseImage)
- {
- SetDiffuseTextureId(GetImplementation(diffuseImage).GetResourceId() );
- }
-
- Dali::Image opacityImage = material->GetOpacityTexture();
- if (opacityImage)
- {
- SetOpacityTextureId(GetImplementation(opacityImage).GetResourceId() );
- }
-
- Dali::Image normalMapImage = material->GetNormalMap();
- if (normalMapImage)
- {
- SetNormalMapId(GetImplementation(normalMapImage).GetResourceId() );
- }
-}
-
-Material::~Material()
-{
-}
-
-void Material::OnStageConnection(SceneController& sceneController)
-{
- mSceneController = &sceneController;
-
- // if we're added to the stage, force the re-sending of texture-id's to the renderer
- // this required if we are removed / then added back to the stage.
- if (mDiffuseTextureState != RESOURCE_NOT_USED)
- {
- mDiffuseTextureState = BITMAP_NOT_LOADED;
- }
- if (mOpacityTextureState != RESOURCE_NOT_USED)
- {
- mOpacityTextureState = BITMAP_NOT_LOADED;
- }
- if (mNormalMapTextureState != RESOURCE_NOT_USED)
- {
- mNormalMapTextureState = BITMAP_NOT_LOADED;
- }
-}
-
-void Material::PrepareResources( BufferIndex bufferIndex, ResourceManager& resourceManager )
-{
- RenderQueue& renderQueue = mSceneController->GetRenderQueue();
-
- if( mRenderMaterial != NULL )
- {
- mIsReady = UpdateTextureStates( renderQueue , bufferIndex );
- }
-}
-
-void Material::PrepareRender( BufferIndex bufferIndex )
-{
- DALI_ASSERT_DEBUG(mSceneController);
- RenderQueue& renderQueue = mSceneController->GetRenderQueue();
-
- if( mIsDirty && mRenderMaterial != NULL )
- {
- {
- typedef MessageValue1<RenderMaterial, float> DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( bufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderMaterial, &RenderMaterial::SetOpacity, mProperties.mOpacity );
- }
-
- {
- typedef MessageValue1<RenderMaterial, float> DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( bufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderMaterial, &RenderMaterial::SetShininess, mProperties.mShininess );
- }
-
- {
- typedef MessageValue1<RenderMaterial, Vector4> DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( bufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderMaterial, &RenderMaterial::SetAmbientColor, mProperties.mAmbientColor );
- }
-
- {
- typedef MessageValue1<RenderMaterial, Vector4> DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( bufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderMaterial, &RenderMaterial::SetDiffuseColor, mProperties.mDiffuseColor );
- }
-
- {
- typedef MessageValue1<RenderMaterial, Vector4> DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( bufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderMaterial, &RenderMaterial::SetSpecularColor, mProperties.mSpecularColor );
- }
-
- {
- typedef MessageValue1<RenderMaterial, Vector4> DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( bufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderMaterial, &RenderMaterial::SetEmissiveColor, mProperties.mEmissiveColor );
- }
-
- mIsDirty = false;
- }
-}
-
-bool Material::AreResourcesReady() const
-{
- return mIsReady;
-}
-
-void Material::SetDiffuseTextureId(ResourceId id)
-{
- mDiffuseResourceId = id;
-
- // if id == 0, then resource is not used
- mDiffuseTextureState = id ? BITMAP_NOT_LOADED : RESOURCE_NOT_USED;
-}
-
-void Material::SetOpacityTextureId(ResourceId id)
-{
- mOpacityResourceId = id;
-
- // if id == 0, then resource is not used
- mOpacityTextureState = id ? BITMAP_NOT_LOADED : RESOURCE_NOT_USED;
-}
-
-void Material::SetNormalMapId(ResourceId id)
-{
- mNormalMapResourceId = id;
-
- // if id == 0, then resource is not used
- mNormalMapTextureState = id ? BITMAP_NOT_LOADED : RESOURCE_NOT_USED;
-}
-
-bool Material::HasDiffuseTexture() const
-{
- return mDiffuseResourceId != 0;
-}
-
-bool Material::HasOpacityTexture() const
-{
- return mOpacityResourceId != 0;
-}
-
-bool Material::HasNormalMap() const
-{
- return mNormalMapResourceId != 0;
-}
-
-void Material::SetProperties( const MaterialProperties& properties )
-{
- mProperties = properties;
- mIsDirty = true;
-}
-
-MaterialProperties Material::GetProperties() const
-{
- return mProperties;
-}
-
-ResourceId Material::GetDiffuseTextureId() const
-{
- return mDiffuseResourceId;
-}
-
-ResourceId Material::GetOpacityTextureId() const
-{
- return mOpacityResourceId;
-}
-
-ResourceId Material::GetNormalMapId() const
-{
- return mNormalMapResourceId;
-}
-
-bool Material::IsOpaque() const
-{
- bool diffuseOpaqueness = true;
-
- if( mDiffuseResourceId > 0 )
- {
- BitmapMetadata bitmapMetadata = mResourceManager.GetBitmapMetadata( mDiffuseResourceId );
- diffuseOpaqueness = bitmapMetadata.IsFullyOpaque();
- }
-
- return ( diffuseOpaqueness &&
- GetProperties().mOpacity >= FULLY_OPAQUE &&
- GetProperties().mDiffuseColor.a >= FULLY_OPAQUE );
-}
-
-void Material::SetRenderMaterial( RenderMaterial* renderMaterial )
-{
- mRenderMaterial = renderMaterial;
-
- // When a new render material is added to the update material, ensure it's properties are set
- mIsDirty = true;
-
- // And that the scene object is made unready.
- mIsReady = false;
-}
-
-RenderMaterial* Material::GetRenderMaterial() const
-{
- return mRenderMaterial;
-}
-
-bool Material::ResourceReady(TextureState state)
-{
- return (( state == RESOURCE_NOT_USED ) || (state == BITMAP_LOADED ));
-}
-
-bool Material::UpdateTextureStates( RenderQueue& renderQueue, BufferIndex bufferIndex )
-{
- // Check if the state of all 3 texture resources
-
- if( mDiffuseTextureState == BITMAP_NOT_LOADED )
- {
- if( mResourceManager.IsResourceLoaded( mDiffuseResourceId ) )
- {
- mDiffuseTextureState = BITMAP_LOADED;
-
- typedef MessageValue1<RenderMaterial, unsigned int> DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( bufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderMaterial, &RenderMaterial::SetDiffuseTextureId, mDiffuseResourceId );
- }
- }
-
- if( mOpacityTextureState == BITMAP_NOT_LOADED )
- {
- if( mResourceManager.IsResourceLoaded( mOpacityResourceId ) )
- {
- mOpacityTextureState = BITMAP_LOADED;
-
- typedef MessageValue1<RenderMaterial, unsigned int> DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( bufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderMaterial, &RenderMaterial::SetOpacityTextureId, mOpacityResourceId );
- }
- }
-
- if( mNormalMapTextureState == BITMAP_NOT_LOADED )
- {
- if( mResourceManager.IsResourceLoaded( mNormalMapResourceId ) )
- {
- mNormalMapTextureState = BITMAP_LOADED;
-
- typedef MessageValue1<RenderMaterial, unsigned int> DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = renderQueue.ReserveMessageSlot( bufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderMaterial, &RenderMaterial::SetNormalMapTextureId, mNormalMapResourceId );
- }
- }
-
- // Check if all the resources are ready;
- if( ResourceReady( mDiffuseTextureState) &&
- ResourceReady( mOpacityTextureState) &&
- ResourceReady( mNormalMapTextureState) )
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/modeling/material-impl.h>
-#include <dali/internal/update/resources/resource-manager.h>
-#include <dali/internal/common/message.h>
-#include <dali/internal/common/event-to-update.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-class RenderMaterial;
-class SceneController;
-
-/**
- * This class represents an Internal::Material on the stage by storing ticket id's to each image.
- *
- * TODO: It will eventually inherit from PropertyOwner to manage properties properly.
- */
-class Material
-{
-public:
- /**
- * Create a new scene graph object
- * @return Material the scene graph object for this material
- */
- static Material* New();
-
- /**
- * Create a new scene graph object from the existing material implementation
- * @return Material the scene graph object for this material
- */
- static Material* New(Internal::Material* material);
-
- /**
- * Constructor
- * @param[in] resourceManager the resource manager object
- */
- Material(ResourceManager& resourceManager);
-
- /**
- * Constructor based on existing material implementation
- * @param[in] resourceManager the resource manager object
- * @param[in] material an existing material implementation to copy from
- */
- Material(ResourceManager& resourceManager, Internal::Material* material);
-
- /**
- * Destructor
- */
- ~Material();
-
- /**
- * Secondary initialization when added to the stage (UpdateManager)
- * @param[in] sceneController The scene controller
- */
- void OnStageConnection(SceneController& sceneController);
-
- /**
- * Prepare image resources.
- */
- void PrepareResources( BufferIndex bufferIndex, ResourceManager& resourceManager );
-
- /**
- * Return true if the images are ready
- * @return TRUE if all resources are ready, false otherwise
- */
- bool AreResourcesReady() const;
-
- /**
- * Prepare renderMaterial
- */
- void PrepareRender( BufferIndex bufferIndex );
-
- /**
- * Set the diffuse texture Id
- * @param[in] id the resource id of the diffuse texture
- */
- void SetDiffuseTextureId(Internal::ResourceId id);
-
- /**
- * Get a resource id of the diffuse texture.
- * @return zero if no diffuse texture set, otherwise valid resource id
- */
- Internal::ResourceId GetDiffuseTextureId() const;
-
- /**
- * Return true if the material has a valid diffuse texture id
- * @return true if valid, false if never set or set to zero.
- */
- bool HasDiffuseTexture() const;
-
- /**
- * Set the opacity texture Id
- * @param[in] id the resource id of the opacity texture
- */
- void SetOpacityTextureId(Internal::ResourceId id);
-
- /**
- * Get a resource id of the opacity texture.
- * @return zero if no opacity texture set, otherwise valid resource id
- */
- Internal::ResourceId GetOpacityTextureId() const;
-
- /**
- * Return true if the material has a valid opacity texture id
- * @return true if valid, false if never set or set to zero.
- */
- bool HasOpacityTexture() const;
-
- /**
- * Set the normal map texture Id
- * @param[in] id the resource id of the normal map
- */
- void SetNormalMapId(Internal::ResourceId id);
-
- /**
- * Get a texture pointer to the normal map or height map
- * @return texturePointer zero if no normal map set, otherwise points at valid texture
- */
- Internal::ResourceId GetNormalMapId() const;
-
- /**
- * Return true if the material has a valid normal map texture id
- * @return true if valid, false if never set or set to zero.
- */
- bool HasNormalMap() const;
-
- /**
- * Set the material properties
- * @param[in] properties the value properties to set
- */
- void SetProperties( const MaterialProperties& properties );
-
- /**
- * Get the material properties
- * @return a copy of the internal properties structure.
- */
- MaterialProperties GetProperties() const;
-
- /**
- * Query whether the material is opaque
- * @return True if the material is opaque.
- */
- bool IsOpaque() const;
-
- /**
- * Set the render material. Used for sending messages.
- * @param[in] renderMaterial A pointer to the render material
- */
- void SetRenderMaterial( RenderMaterial* renderMaterial );
-
- /**
- * Return the currently set render material
- * @return NULL or the render material if connected to stage
- */
- RenderMaterial* GetRenderMaterial() const;
-
-private:
-
- /**
- * Material texture state
- */
- enum TextureState
- {
- RESOURCE_NOT_USED, ///< The texture is not used
- BITMAP_NOT_LOADED, ///< bitmap is not loaded
- BITMAP_LOADED, ///< bitmap has been loaded
- };
-
- /**
- * Helper to see if a resource is ready, which
- * means it's either loaded, or not used
- * @param state texture state
- * @return true if the resource ready
- */
- bool ResourceReady(TextureState state);
-
- /**
- * Update the status of the texture resources.
- * The material can have up to 3 texture resources.
- * @param[in] renderQueue the render queue
- * @param[in] bufferIndex the update buffer index
- * @return true if all textures that need to be loaded are loaded, false if not
- */
- bool UpdateTextureStates( RenderQueue& renderQueue, BufferIndex bufferIndex );
-
-private:
- ResourceManager& mResourceManager;
- SceneController* mSceneController;
- RenderMaterial* mRenderMaterial;
-
- Internal::MaterialProperties mProperties;
-
- Internal::ResourceId mDiffuseResourceId;
- Internal::ResourceId mOpacityResourceId;
- Internal::ResourceId mNormalMapResourceId;
-
- TextureState mDiffuseTextureState;
- TextureState mOpacityTextureState;
- TextureState mNormalMapTextureState;
-
- bool mIsReady:1;
- bool mIsDirty:1;
-};
-
-// Messages for Material
-
-inline void SetPropertiesMessage( EventToUpdate& eventToUpdate, const Material& material, const MaterialProperties& properties )
-{
- typedef MessageValue1< Material, MaterialProperties > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &material, &Material::SetProperties, properties );
-}
-
-inline void SetDiffuseTextureMessage( EventToUpdate& eventToUpdate, const Material& material, ResourceId id )
-{
- typedef MessageValue1< Material, ResourceId > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &material, &Material::SetDiffuseTextureId, id );
-}
-
-inline void SetOpacityTextureMessage( EventToUpdate& eventToUpdate, const Material& material, ResourceId id )
-{
- typedef MessageValue1< Material, ResourceId > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &material, &Material::SetOpacityTextureId, id );
-}
-
-inline void SetNormalMapMessage( EventToUpdate& eventToUpdate, const Material& material, ResourceId id )
-{
- typedef MessageValue1< Material, ResourceId > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &material, &Material::SetNormalMapId, id );
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_MESH_DECLARATIONS_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_MESH_DECLARATIONS_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/math/matrix.h>
-#include <dali/internal/common/owner-container.h>
-#include <dali/internal/common/owner-pointer.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-
-class Mesh;
-
-typedef OwnerPointer<Mesh> MeshOwner;
-typedef OwnerContainer< Mesh* > MeshOwnerContainer;
-
-typedef std::vector< Mesh* > MeshContainer;
-typedef MeshContainer::iterator MeshIter;
-typedef MeshContainer::const_iterator MeshConstIter;
-
-typedef std::vector<Matrix> MatrixContainer;
-typedef MatrixContainer::const_iterator MatrixIter;
-
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_SCENE_GRAPH_MESH_DECLARATIONS_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/update/modeling/scene-graph-mesh.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/render/common/post-process-resource-dispatcher.h>
-#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/queue/render-queue.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-
-Mesh::Mesh( ResourceId id,
- PostProcessResourceDispatcher& postProcessResourceDispatcher,
- RenderQueue& renderQueue,
- MeshData* meshData )
-:
- mPostProcessResourceDispatcher(postProcessResourceDispatcher),
- mRenderQueue(renderQueue),
- mUpdateMeshData(meshData),
- mRenderMeshData(meshData),
- mVertexBuffer(NULL),
- mIndicesBuffer(NULL),
- mNumberOfVertices(0u),
- mNumberOfFaces(0u),
- mResourceId ( id ),
- mRefreshVertexBuffer(true)
-{
-}
-
-Mesh::~Mesh()
-{
-}
-
-void Mesh::SetMeshData(MeshData* meshData)
-{
- mUpdateMeshData = meshData;
-}
-
-MeshData& Mesh::GetMeshData( Mesh::ThreadBuffer threadBuffer )
-{
- return const_cast<MeshData&>(static_cast<const Mesh*>(this)->GetMeshData(threadBuffer));
-}
-
-const MeshData& Mesh::GetMeshData( Mesh::ThreadBuffer threadBuffer ) const
-{
- MeshData* meshDataPtr = NULL;
-
- switch(threadBuffer)
- {
- case Mesh::UPDATE_THREAD:
- {
-
- meshDataPtr = mUpdateMeshData;
- }
- break;
-
- case Mesh::RENDER_THREAD:
- {
- meshDataPtr = &(*mRenderMeshData);
- }
- break;
- }
-
- DALI_ASSERT_DEBUG( meshDataPtr );
- return *meshDataPtr;
-}
-
-void Mesh::RefreshVertexBuffer()
-{
- mRefreshVertexBuffer = true;
-}
-
-void Mesh::MeshDataUpdated( BufferIndex bufferIndex, Mesh::ThreadBuffer threadBuffer, MeshData* meshData )
-{
- if ( threadBuffer == Mesh::RENDER_THREAD )
- {
- // Called from a message, the old MeshData will be release and the new one is saved.
- mRenderMeshData = meshData;
- RefreshVertexBuffer();
- }
- else
- {
- // Dynamics and animatable meshes don't create new mesh data
- DALI_ASSERT_DEBUG( threadBuffer == Mesh::UPDATE_THREAD );
- DALI_ASSERT_DEBUG( meshData == NULL );
-
- // Send a message to self in render thread
- typedef Message< Mesh > LocalType;
- unsigned int* slot = mRenderQueue.ReserveMessageSlot( bufferIndex, sizeof( LocalType ) );
- new (slot) LocalType( this, &Mesh::RefreshVertexBuffer);
- }
-}
-
-void Mesh::UploadVertexData( Context& context, BufferIndex renderBufferIndex )
-{
- // Short-circuit if nothing has changed
- if ( !mRefreshVertexBuffer )
- {
- return;
- }
-
- DoUpload(context);
-
- // Note, dispatcher should only be used in Render Thread (as should the rest of this method!)
- ResourcePostProcessRequest ppRequest( mResourceId, ResourcePostProcessRequest::UPLOADED );
- mPostProcessResourceDispatcher.DispatchPostProcessRequest(ppRequest);
-
- mRenderMeshData->Discard();
- mRefreshVertexBuffer = false;
-}
-
-void Mesh::DoUpload( Context& context )
-{
- const MeshData::VertexContainer& vertices = mRenderMeshData->GetVertices();
-
- DALI_ASSERT_DEBUG( !vertices.empty() );
- if ( !mVertexBuffer )
- {
- mVertexBuffer = new GpuBuffer(context,GpuBuffer::ARRAY_BUFFER,GpuBuffer::STATIC_DRAW);
- }
- DALI_ASSERT_DEBUG(mVertexBuffer);
-
- mVertexBuffer->UpdateDataBuffer( vertices.size() * sizeof(MeshData::Vertex), &vertices.at(0) );
- mNumberOfVertices = mRenderMeshData->GetVertexCount();
-
- if ( size_t numberOfIndices = mRenderMeshData->GetFaceIndexCount() )
- {
- const MeshData::FaceIndices& faces = mRenderMeshData->GetFaces();
- DALI_ASSERT_DEBUG(!faces.empty());
-
- if ( !mIndicesBuffer )
- {
- mIndicesBuffer = new GpuBuffer(context,GpuBuffer::ELEMENT_ARRAY_BUFFER,GpuBuffer::STATIC_DRAW);
- }
-
- mIndicesBuffer->UpdateDataBuffer( numberOfIndices * sizeof(GLushort), &(faces.at(0)) );
- mNumberOfFaces = mRenderMeshData->GetFaceCount();
- }
-}
-
-void Mesh::BindBuffers(Context& context)
-{
- // Short-circuit if nothing has changed
- if ( !mVertexBuffer )
- {
- return;
- }
-
- DALI_ASSERT_DEBUG( mIndicesBuffer || mRenderMeshData->GetVertexGeometryType() == Dali::MeshData::POINTS );
-
- // Try and recover from context loss using retained data.
- if( ! mVertexBuffer->BufferIsValid() && ! mRenderMeshData->GetVertices().empty() )
- {
- DoUpload( context );
- }
-
- if( mVertexBuffer->BufferIsValid() )
- {
- mVertexBuffer->Bind();
- }
-
- if( mIndicesBuffer && mIndicesBuffer->BufferIsValid())
- {
- mIndicesBuffer->Bind();
- }
-}
-
-size_t Mesh::GetFaceIndexCount( ThreadBuffer threadBuffer ) const
-{
- DALI_ASSERT_DEBUG( threadBuffer == Mesh::RENDER_THREAD );
- size_t faceCount= 0;
- switch( GetMeshData(threadBuffer).GetVertexGeometryType() )
- {
- case Dali::MeshData::POINTS:
- faceCount = mNumberOfVertices;
- break;
- case Dali::MeshData::LINES:
- faceCount = mNumberOfFaces*2;
- break;
- case Dali::MeshData::TRIANGLES:
- faceCount = mNumberOfFaces*3;
- break;
- }
-
- return faceCount;
-}
-
-bool Mesh::HasGeometry( ThreadBuffer threadBuffer ) const
-{
- return GetMeshData(threadBuffer).GetVertexCount() > 0;
-}
-
-void Mesh::GlContextDestroyed()
-{
- if( mVertexBuffer )
- {
- mVertexBuffer->GlContextDestroyed();
- }
- if( mIndicesBuffer )
- {
- mIndicesBuffer->GlContextDestroyed();
- }
-}
-
-void Mesh::GlCleanup()
-{
- mVertexBuffer = NULL;
- mIndicesBuffer = NULL;
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_MESH_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_MESH_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/internal/common/buffer-index.h>
-#include <dali/internal/common/message.h>
-#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/modeling/internal-mesh-data.h>
-#include <dali/internal/render/gl-resources/gpu-buffer.h>
-#include <dali/internal/render/gl-resources/gl-resource-owner.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
-#include <dali/internal/update/modeling/scene-graph-mesh-declarations.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-class RenderQueue;
-class PostProcessResourceDispatcher;
-class Mesh;
-
-/**
- * Mesh resources consist of vertices, face indices and normals; they are shared (weakly referenced) by Nodes.
- */
-class Mesh : public GlResourceOwner
-{
-public:
-
- enum ThreadBuffer
- {
- UPDATE_THREAD,
- RENDER_THREAD
- };
-
- /**
- * Create a new scene graph mesh.
- * @param[in] id The resource ID of the mesh
- * @param[in] postProcessResourceDispatcher The dispatcher
- * @param[in] meshData The mesh data
- * @return A smart-pointer to the newly allocated Mesh.
- */
- static Mesh* New( ResourceId id,
- PostProcessResourceDispatcher& postProcessResourceDispatcher,
- RenderQueue& renderQueue,
- MeshData* meshData )
- {
- return new Mesh( id, postProcessResourceDispatcher, renderQueue, meshData );
- }
-
- /**
- * Virtual destructor
- */
- virtual ~Mesh();
-
- /**
- * Set the mesh data
- * @pre Should only be called in the update thread
- * @param[in] meshData The mesh data
- */
- void SetMeshData( MeshData* meshData );
-
- /**
- * Get the mesh data.
- * The caller can modify this data. If they do, they should call
- * MeshDataUpdated() when finished. This should only be done in the update thread.
- * @param[in] threadBuffer indicates what buffer should be returned
- * @return meshData.
- */
- MeshData& GetMeshData( ThreadBuffer threadBuffer );
-
- /**
- * Get the mesh data.
- * @param[in] threadBuffer indicates what buffer should be returned
- * @return meshData.
- */
- const MeshData& GetMeshData( ThreadBuffer threadBuffer ) const;
-
- /**
- * The mesh data has been updated. Allows the renderer to update
- * the vertex buffer objects the next time they are needed.
- * @param[in] bufferIndex to be used in double buffered values.
- * @param[in] threadBuffer indicates what buffer should be used
- * @param[in] meshData The mesh data ownership is passed in through a message, if threadBuffer is UPDATE it should be NULL
- */
- void MeshDataUpdated( BufferIndex bufferIndex, ThreadBuffer threadBuffer, MeshData* meshData );
-
- /**
- * Sends the vertex data to GL if it has been refreshed. Notify resource manager when it has finished.
- * @pre this function should only be called from the render thread
- * @param[in] context The GL context.
- * @param[in] renderBufferIndex The index that should be accessed in double buffered values.
- */
- void UploadVertexData( Context& context, BufferIndex renderBufferIndex );
-
- /**
- * Actually perform the vertex upload.
- * @param[in] context The GL context.
- */
- void DoUpload( Context& context );
-
- /**
- * Bind the vertex and index buffers.
- * @pre this function should only be called from the render thread
- * @param[in] context The GL context.
- */
- void BindBuffers( Context& context );
-
- /**
- * Get the number of face / line indices. (Note, this is not the number of faces)
- * @param[in] threadBuffer indicates what buffer should be used
- * @return the number of indices
- */
- size_t GetFaceIndexCount( ThreadBuffer threadBuffer ) const;
-
- /**
- * Returns a new
- * @param[in] threadBuffer indicates what buffer should be used
- * @return true if there is any geometry
- **/
- bool HasGeometry( ThreadBuffer threadBuffer ) const;
-
-public: // from GlResourceOwner
-
- /**
- * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed()
- */
- virtual void GlContextDestroyed();
-
- /**
- * @copydoc Dali::Internal::GlResourceOwner::GlCleanup()
- */
- virtual void GlCleanup();
-
-private:
- /**
- * Method to set if the vertex buffer should be refreshed in the render thread
- */
- void RefreshVertexBuffer();
-
- /**
- * Private constructor; see also Mesh::New()
- */
- Mesh( ResourceId id,
- PostProcessResourceDispatcher& postProcessResourceDispatcher,
- RenderQueue& renderQueue,
- MeshData* meshData );
-
- // Undefined
- Mesh(const Mesh&);
-
- // Undefined
- Mesh& operator=(const Mesh& rhs);
-
-protected:
- PostProcessResourceDispatcher& mPostProcessResourceDispatcher;
- SceneGraph::RenderQueue& mRenderQueue;
- /**
- * The mUpdateMeshData will point to a mesh data that was just received
- * or to the MeshData pointed by mRenderMeshData if it's more that one frame old
- */
- MeshData* mUpdateMeshData; ///< Pointer to MeshData object
- OwnerPointer<MeshData> mRenderMeshData; ///< Owner of the MeshData Object
- OwnerPointer<GpuBuffer> mVertexBuffer; ///< Vertex buffer
- OwnerPointer<GpuBuffer> mIndicesBuffer; ///< Index buffer
- size_t mNumberOfVertices; ///< Number of vertices
- size_t mNumberOfFaces; ///< Number of faces
- ResourceId mResourceId;
- bool mRefreshVertexBuffer; ///< True when GpuBuffers need updating
-};
-
-} // namespace SceneGraph
-
-// value types used by messages
-template <> struct ParameterType< SceneGraph::Mesh::ThreadBuffer >
-: public BasicType< SceneGraph::Mesh::ThreadBuffer > {};
-class Context;
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_SCENE_GRAPH_MESH_H__
/**
* Second-phase construction.
* This is called by the UpdateManager, when the attachment is attached to the scene-graph.
- * @param[in] sceneController Allows attachments to get light/camera controllers.
+ * @param[in] sceneController Allows attachments to get camera controllers.
* @param[in] updateBufferIndex The current update buffer index.
*/
virtual void ConnectToSceneGraph( SceneController& sceneController, BufferIndex updateBufferIndex ) = 0;
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/update/node-attachments/scene-graph-mesh-attachment.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/integration-api/debug.h>
-
-#include <dali/internal/common/internal-constants.h>
-
-#include <dali/internal/event/images/image-impl.h>
-#include <dali/internal/event/modeling/mesh-impl.h>
-#include <dali/internal/event/modeling/material-impl.h>
-
-#include <dali/internal/update/common/discard-queue.h>
-#include <dali/internal/update/resources/resource-manager.h>
-#include <dali/internal/update/controllers/render-message-dispatcher.h>
-#include <dali/internal/update/controllers/scene-controller.h>
-#include <dali/internal/update/modeling/scene-graph-mesh.h>
-#include <dali/internal/update/modeling/scene-graph-material.h>
-#include <dali/internal/update/nodes/node.h>
-
-#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/renderers/scene-graph-mesh-renderer.h>
-#include <dali/internal/render/shaders/program.h>
-#include <dali/internal/render/shaders/shader.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-
-class Material;
-
-MeshAttachment* MeshAttachment::New()
-{
- return new MeshAttachment();
-}
-
-MeshAttachment::MeshAttachment()
-: RenderableAttachment( true ), // scale enabled
- mRenderer( NULL )
-{
-}
-
-void MeshAttachment::PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
-{
- // Bone node has been disconnected.
-}
-
-void MeshAttachment::PropertyOwnerDestroyed( PropertyOwner& owner )
-{
- // Bone node has been destroyed.
-}
-
-void MeshAttachment::ConnectToSceneGraph2( BufferIndex updateBufferIndex )
-{
- DALI_ASSERT_DEBUG( NULL != mSceneController );
-
- // Create main renderer, passing ownership to the render-thread
- mRenderer = MeshRenderer::New( *mParent );
- mSceneController->GetRenderMessageDispatcher().AddRenderer( *mRenderer );
-}
-
-void MeshAttachment::OnDestroy2()
-{
- DALI_ASSERT_DEBUG( NULL != mSceneController );
-
- // Request deletion in the next Render
- mSceneController->GetRenderMessageDispatcher().RemoveRenderer( *mRenderer );
- mRenderer = NULL;
-}
-
-MeshAttachment::~MeshAttachment()
-{
- BoneNodeContainer& boneNodes = mMesh.boneNodes;
- for( BoneNodeContainer::iterator iter = boneNodes.begin(); iter != boneNodes.end(); ++iter )
- {
- Node* node = (*iter);
- if( node != NULL )
- {
- node->RemoveObserver( *this );
- }
- }
-
-}
-
-Renderer& MeshAttachment::GetRenderer()
-{
- return *mRenderer;
-}
-
-const Renderer& MeshAttachment::GetRenderer() const
-{
- return *mRenderer;
-}
-
-void MeshAttachment::ShaderChanged( BufferIndex updateBufferIndex )
-{
- DALI_ASSERT_DEBUG(mSceneController);
-
- typedef Message< MeshRenderer > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the mRenderer queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mRenderer, &MeshRenderer::ResetCustomUniforms );
-}
-
-void MeshAttachment::SizeChanged( BufferIndex updateBufferIndex )
-{
- SetRecalculateScaleForSize();
-}
-
-void MeshAttachment::SetMesh( ResourceId meshId, const SceneGraph::Material* material, std::size_t boneCount )
-{
- mMesh.meshResourceId = meshId;
- mMesh.material = material;
- mMesh.boneCount = boneCount;
-
- if( mMesh.boneCount > 0 )
- {
- mMesh.boneNodes.resize(mMesh.boneCount, NULL);
- }
-}
-
-void MeshAttachment::SetMaterial( const SceneGraph::Material* material )
-{
- mMesh.material = material;
-}
-
-void MeshAttachment::SetBoneNode( Node* node, size_t boneIdx, size_t boneCount )
-{
- DALI_ASSERT_DEBUG(boneIdx < mMesh.boneNodes.size());
-
- // Observe bone nodes (this ensures that their world matrix will be calculated)
- if(mMesh.boneNodes[boneIdx] != NULL)
- {
- mMesh.boneNodes[boneIdx]->RemoveObserver( *this );
- }
-
- mMesh.boneNodes[boneIdx] = node;
- if( node != NULL )
- {
- mMesh.boneNodes[boneIdx]->AddObserver( *this );
- }
-}
-
-void MeshAttachment::CalculateBoneTransforms( BufferIndex updateBufferIndex,
- const Mesh* mesh,
- const BoneNodeContainer& boneNodes,
- BoneTransforms& boneTransforms )
-{
- size_t boneCount = std::min( mesh->GetMeshData(Mesh::UPDATE_THREAD).GetBoneCount(), MAX_NUMBER_OF_BONES_PER_MESH );
-
- const BoneContainer& bones = mesh->GetMeshData(Mesh::UPDATE_THREAD).GetBones();
-
- for(size_t boneIdx=0; boneIdx < boneCount; ++boneIdx)
- {
- const Matrix& boneMatrix = bones.at(boneIdx).GetOffsetMatrix();
- const Node* boneNode = boneNodes[boneIdx];
-
- if ( boneNode != NULL )
- {
- Matrix& transform = boneTransforms.transforms[boneIdx];
- Matrix::Multiply(transform, boneMatrix, boneNode->GetWorldMatrix( updateBufferIndex ) );
- // These transform matrices are modified once per update per renderer.
- // The correct view matrix will be applied in the render thread to the viewTransforms
- // list once per renderer per render task
- }
- }
-}
-
-/*
- * Go through each mesh resource and material resource. If any of the resources aren't yet ready,
- * stop and return false.
- */
-bool MeshAttachment::DoPrepareResources( BufferIndex updateBufferIndex, ResourceManager& resourceManager )
-{
- bool ready = false;
- mFinishedResourceAcquisition = false;
-
- if ( !mMesh.mesh )
- {
- SceneGraph::Mesh* mesh(resourceManager.GetMesh(mMesh.meshResourceId));
- mMesh.mesh = mesh;
- }
-
- if ( mMesh.mesh && mMesh.mesh->HasGeometry( Mesh::UPDATE_THREAD ) )
- {
- const SceneGraph::Material* material = mMesh.material;
- ready = material->AreResourcesReady();
- mFinishedResourceAcquisition = ready;
- }
-
- return ready;
-}
-
-void MeshAttachment::DoPrepareRender( BufferIndex updateBufferIndex )
-{
- DALI_ASSERT_DEBUG(mSceneController);
-
- // Provide renderer with ModelIT matrix, mesh, material, and bone transforms for the next frame
- MeshRenderer::MeshInfo& meshInfo = mRenderer->GetMeshInfo( updateBufferIndex );
-
- Mesh* meshPtr = mMesh.mesh;
- RenderMaterial* material = mMesh.material->GetRenderMaterial();
-
- meshInfo.mesh = meshPtr;
- meshInfo.material = material;
-
- if ( material )
- {
- std::size_t boneCount = mMesh.boneNodes.size();
-
- if ( boneCount > 0 )
- {
- if( meshInfo.boneTransforms.transforms.size() != boneCount )
- {
- // Reallocate bone transforms if the number of bones has changed.
- // ( Prefer allocation in Update thread rather than in render thread )
- meshInfo.boneTransforms.transforms.resize( boneCount );
- meshInfo.boneTransforms.viewTransforms.resize( boneCount );
- meshInfo.boneTransforms.inverseTransforms.resize( boneCount );
- }
-
- CalculateBoneTransforms( updateBufferIndex, meshPtr, mMesh.boneNodes, meshInfo.boneTransforms );
- }
- }
-}
-
-bool MeshAttachment::IsFullyOpaque( BufferIndex updateBufferIndex )
-{
- bool fullyOpaque = true; // good default, since transparency is evil.
-
- /**
- * Fully opaque when:
- * 1) The material is opaque
- * 2) The inherited color is not transparent nor semi-transparent
- * 3) The inherited shader does not blend
- */
-
- const SceneGraph::Material* material = mMesh.material;
-
- if ( material && !material->IsOpaque() )
- {
- fullyOpaque = false;
- }
-
- if( mParent != NULL )
- {
- if( fullyOpaque )
- {
- fullyOpaque = ( mParent->GetWorldColor(updateBufferIndex).a >= FULLY_OPAQUE );
- }
-
- if ( fullyOpaque )
- {
- if( mShader != NULL )
- {
- fullyOpaque = (mShader->GetGeometryHints() != Dali::ShaderEffect::HINT_BLENDING );
- }
- }
- }
- return fullyOpaque;
-}
-
-void MeshAttachment::DoGetScaleForSize( const Vector3& nodeSize, Vector3& scaling )
-{
- scaling = Vector3::ONE;
- // Check whether mesh data should be scaled to requiredSize
- if( NULL != mMesh.mesh )
- {
- const MeshData& meshData = mMesh.mesh->GetMeshData( Mesh::UPDATE_THREAD );
-
- if( meshData.IsScalingRequired() )
- {
- scaling = nodeSize;
- }
- }
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_MESH_ATTACHMENT_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_MESH_ATTACHMENT_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/internal/common/buffer-index.h>
-#include <dali/internal/common/event-to-update.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/node-attachments/scene-graph-renderable-attachment.h>
-#include <dali/internal/update/modeling/bone-transforms.h>
-#include <dali/internal/event/actor-attachments/mesh-attachment-impl.h>
-#include <dali/internal/event/actors/mesh-actor-impl.h>
-#include <dali/public-api/geometry/mesh.h>
-#include <dali/public-api/math/matrix.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class ResourceManager;
-
-namespace SceneGraph
-{
-class Mesh;
-class MeshRenderer;
-class Material;
-class Shader;
-
-/**
- * An attachment for rendering a mesh with a material.
- */
-class MeshAttachment : public RenderableAttachment, public PropertyOwner::Observer
-{
-public:
-
- typedef std::vector<Node*> BoneNodeContainer;
-
- struct MeshMatBones
- {
- MeshMatBones()
- : meshResourceId( 0 ),
- mesh( NULL ),
- material( NULL ),
- boneCount( 0 )
- {
- }
-
- ResourceId meshResourceId;
- SceneGraph::Mesh* mesh;
- const SceneGraph::Material* material;
- std::size_t boneCount;
- BoneNodeContainer boneNodes;
- };
-
- /**
- * Construct a new MeshAttachment.
- * @return a new MeshAttachment
- */
- static MeshAttachment* New();
-
- /**
- * Virtual destructor
- */
- virtual ~MeshAttachment();
-
- /**
- * TODO: remove geometry scaling and this method can be gone
- * @copydoc RenderableAttachment::ResolveVisibility
- */
- virtual bool ResolveVisibility( BufferIndex updateBufferIndex )
- {
- mHasSizeAndColorFlag = false;
- const Vector4& color = mParent->GetWorldColor( updateBufferIndex );
- if( color.a > FULLY_TRANSPARENT ) // not fully transparent
- {
- mHasSizeAndColorFlag = true;
- }
- return mHasSizeAndColorFlag;
- }
-
- /**
- * @copydoc RenderableAttachment::GetRenderer().
- */
- virtual Renderer& GetRenderer();
-
- /**
- * @copydoc RenderableAttachment::GetRenderer().
- */
- virtual const Renderer& GetRenderer() const;
-
- /**
- * @copydoc Dali::Internal::SceneGraph::RenderableAttachment::ShaderChanged()
- */
- virtual void ShaderChanged( BufferIndex updateBufferIndex );
-
- /**
- * @copydoc RenderableAttachment::SizeChanged()
- */
- virtual void SizeChanged( BufferIndex updateBufferIndex );
-
- /**
- * @copydoc Dali::Internal::SceneGraph::RenderableAttachment::DoPrepareRender()
- */
- virtual void DoPrepareRender( BufferIndex updateBufferIndex );
-
- /**
- * @copydoc RenderableAttachment::IsFullyOpaque()
- */
- virtual bool IsFullyOpaque( BufferIndex updateBufferIndex );
-
- /**
- * @copydoc Dali::Internal::SceneGraph::RenderableAttachment::DoGetScaleForSize()
- */
- virtual void DoGetScaleForSize( const Vector3& nodeSize, Vector3& scaling );
-
- /**
- * Set the mesh to be rendererd by this attachment
- * @param[in] meshId The resource id of the mesh
- * @param[in] material The material
- * @param[in] boneCount The bone count
- */
- void SetMesh( ResourceId meshId, const SceneGraph::Material* material, std::size_t boneCount );
-
- /**
- * @copydoc Dali::Internal::MeshActor::SetMaterial(Material material)
- */
- void SetMaterial( const SceneGraph::Material* material );
-
- /**
- * Set the node for the given mesh index and bone index
- */
- void SetBoneNode( Node* boneNode, size_t boneIdx, size_t boneCount );
-
- /**
- * Calculate matrices for bones based on bone node transforms.
- */
- void CalculateBoneTransforms( BufferIndex updateBufferIndex,
- const Mesh* mesh,
- const BoneNodeContainer& boneNodes,
- BoneTransforms& boneTransforms );
-
-private:
-
- /**
- * @copydoc PropertyOwner::Observer::PropertyOwnerConnected()
- */
- virtual void PropertyOwnerConnected( PropertyOwner& owner ){}
-
- /**
- * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
- */
- virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner );
-
- /**
- * @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed()
- */
- virtual void PropertyOwnerDestroyed( PropertyOwner& owner );
-
- /**
- * @copydoc RenderableAttachment::ConnectToSceneGraph2()
- */
- virtual void ConnectToSceneGraph2( BufferIndex updateBufferIndex );
-
- /**
- * @copydoc RenderableAttachment::OnDestroy2()
- */
- virtual void OnDestroy2();
-
- /**
- * @copydoc Dali::Internal::SceneGraph::RenderableAttachment::DoPrepareResources()
- */
- virtual bool DoPrepareResources( BufferIndex updateBufferIndex, ResourceManager& resourceManager );
-
- /**
- * Protected constructor. See New()
- */
- MeshAttachment();
-
- // Undefined
- MeshAttachment(const MeshAttachment&);
-
- // Undefined
- MeshAttachment& operator=(const MeshAttachment& rhs);
-
-private:
-
- MeshRenderer* mRenderer; ///< Raw-pointer to renderer that is owned by RenderManager
-
- MeshMatBones mMesh; ///< The mesh used to prepare for rendering, with associated materials and bones
-};
-
-// Messages for MeshAttachment
-
-inline void SetMeshMessage( EventToUpdate& eventToUpdate, const MeshAttachment& attachment, ResourceId meshId, const Material* material, std::size_t boneCount )
-{
- typedef MessageValue3< MeshAttachment, ResourceId, const Material*, std::size_t > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &MeshAttachment::SetMesh, meshId, material, boneCount );
-}
-
-inline void SetMaterialMessage( EventToUpdate& eventToUpdate, const MeshAttachment& attachment, const Material* material )
-{
- typedef MessageValue1< MeshAttachment, const Material* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &MeshAttachment::SetMaterial, material );
-}
-
-inline void SetBoneNodeMessage( EventToUpdate& eventToUpdate, const MeshAttachment& attachment, Node* boneNode, size_t boneIdx, size_t boneCount )
-{
- typedef MessageValue3< MeshAttachment, Node*, size_t, size_t > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &MeshAttachment::SetBoneNode, boneNode, boneIdx, boneCount );
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_SCENE_GRAPH_MESH_ATTACHMENT_H__
public: // For use during in the update algorithm only
/**
- * TODO this method should not be virtual but because mesh attachment is a mess, it needs to be
- * considered visible regardless of its size... need to remove geometry scaling to fix this!!!
* @param[in] updateBufferIndex The current update buffer index.
* @return visible tells if this renderer can be potentially seen
*/
- virtual bool ResolveVisibility( BufferIndex updateBufferIndex );
+ bool ResolveVisibility( BufferIndex updateBufferIndex );
/**
* if this renderable actor has visible size and color
mExclusiveRenderTask( NULL ),
mAttachment( NULL ),
mChildren(),
- mGeometryScale( Vector3::ONE ),
- mInitialVolume( Vector3::ONE ),
mSizeModeFactor( Vector3::ONE ),
mDirtyFlags(AllFlags),
mIsRoot( false ),
mInheritRotation( true ),
mInheritScale( true ),
- mTransmitGeometryScaling( false ),
mInhibitLocalTransform( false ),
mIsActive( true ),
mDrawMode( DrawMode::NORMAL ),
localOffset *= mSize[updateBufferIndex];
Vector3 scale = mWorldScale[updateBufferIndex];
- if(GetTransmitGeometryScaling())
- {
- // Remove geometry scaling to get back to actor scale
- scale /= mGeometryScale;
- }
- // Also pick up sign of local scale
+
+ // Pick up sign of local scale
if (mScale[updateBufferIndex].x < 0.0f)
{
scale.x = -scale.x;
}
/**
- * Set the initial volume of the node. Used for calculating geometry scaling
- * as the node size is changed when transmitGeometryScaling is set to true.
- *
- * This property is not animatable.
- *
- * @param[in] volume The initial volume of this nodes meshes & children
- */
- void SetInitialVolume( const Vector3& volume )
- {
- mInitialVolume = volume;
- SetDirtyFlag(SizeFlag);
- }
-
- /**
- * Get the initial volume. Used for calculating geometry scaling
- * when TransmitGeometryScaling is true (i.e., the scaling is baked
- * into the node tranform)
- *
- * @return The initial volume of this node and children.
- */
- Vector3 GetInitialVolume()
- {
- return mInitialVolume;
- }
-
- /**
- * Sets whether the geometry scaling should be applied to the node
- * (In which case, set the initial scale using SetInitialVolume()).
- *
- * If it is applied to the node, then the attachments are not scaled,
- * as the scaling is then already baked into the node transform.
- *
- * @param[in] transmitGeometryScaling true if scaling is to be applied
- * to the node.
- */
- void SetTransmitGeometryScaling(bool transmitGeometryScaling)
- {
- mTransmitGeometryScaling = transmitGeometryScaling;
- SetDirtyFlag(SizeFlag);
- }
-
- /**
- * Find out whether the node allows geometry scaling to be transmitted to its children.
- * @return true if transmitted.
- */
- bool GetTransmitGeometryScaling() const
- {
- return mTransmitGeometryScaling;
- }
-
- /**
* Retrieve the local scale of the node, relative to its parent.
* @param[in] bufferIndex The buffer to read from.
* @return The local scale.
*/
void SetWorldScale(BufferIndex updateBufferIndex, const Vector3& scale)
{
- mWorldScale.Set( updateBufferIndex, mGeometryScale * scale );
+ mWorldScale.Set( updateBufferIndex, scale );
}
/**
{
DALI_ASSERT_DEBUG(mParent != NULL);
- mWorldScale.Set( updateBufferIndex, mParent->GetWorldScale(updateBufferIndex) * mGeometryScale * mScale[updateBufferIndex] );
+ mWorldScale.Set( updateBufferIndex, mParent->GetWorldScale(updateBufferIndex) * mScale[updateBufferIndex] );
}
/**
}
/**
- * Sets a geometry scale, calculated when TransmitGeometryScaling is true.
- * Must only be used from render thread.
- * @param[in] geometryScale The geometry scale value
- */
- void SetGeometryScale(Vector3 geometryScale)
- {
- mGeometryScale = geometryScale;
-
- SetDirtyFlag( TransformFlag );
- }
-
- /**
- * Retrieve the geometry scale, calculated when TransmitGeometryScaling is true.
- * @return The geometry scale value.
- */
- const Vector3& GetGeometryScale() const
- {
- return mGeometryScale;
- }
-
- /**
* Copies the previously used size, if this changed in the previous frame.
* @param[in] updateBufferIndex The current update buffer index.
*/
NodeAttachmentOwner mAttachment; ///< Optional owned attachment
NodeContainer mChildren; ///< Container of children; not owned
- Vector3 mGeometryScale; ///< Applied before calculating world transform.
- Vector3 mInitialVolume; ///< Initial volume... TODO - need a better name.
Vector3 mSizeModeFactor; ///< Factor of parent size. Used for certain SizeModes.
// flags, compressed to bitfield
bool mIsRoot:1; ///< True if the node cannot have a parent
bool mInheritRotation:1; ///< Whether the parent's rotation should be inherited.
bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
- bool mTransmitGeometryScaling:1; ///< Whether geometry scaling should be applied to world transform.
bool mInhibitLocalTransform:1; ///< whether local transform should be applied.
bool mIsActive:1; ///< When a Node is marked "active" it has been disconnected, and its properties have not been modified
new (slot) LocalType( &node, &Node::SetSizeModeFactor, factor );
}
-inline void SetInitialVolumeMessage( EventToUpdate& eventToUpdate, const Node& node, const Vector3& initialVolume )
-{
- typedef MessageValue1< Node, Vector3 > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetInitialVolume, initialVolume );
-}
-
-inline void SetTransmitGeometryScalingMessage( EventToUpdate& eventToUpdate, const Node& node, bool transmitGeometryScaling )
-{
- typedef MessageValue1< Node, bool > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetTransmitGeometryScaling, transmitGeometryScaling );
-}
-
inline void SetParentOriginMessage( EventToUpdate& eventToUpdate, const Node& node, const Vector3& origin )
{
typedef MessageValue1< Node, Vector3 > LocalType;
#include <dali/internal/event/text/font-impl.h>
#include <dali/internal/event/text/atlas/atlas-size.h>
-#include <dali/internal/update/modeling/scene-graph-mesh.h>
#include <dali/internal/update/common/discard-queue.h>
#include <dali/internal/update/resources/bitmap-metadata.h>
#include <dali/internal/update/resources/atlas-request-status.h>
typedef BitmapMetadataCache::iterator BitmapMetadataIter;
typedef std::pair<ResourceId, BitmapMetadata> BitmapMetadataPair;
-typedef std::map<ResourceId, SceneGraph::Mesh*> MeshCache;
-typedef MeshCache::iterator MeshCacheIter;
-typedef std::pair<ResourceId, SceneGraph::Mesh*> MeshDataPair;
-
typedef std::map<ResourceId, ShaderDataPtr> ShaderCache;
typedef ShaderCache::iterator ShaderCacheIter;
typedef ShaderCache::size_type ShaderCacheSize;
~ResourceManagerImpl()
{
- // Cleanup existing meshes
- for( MeshCacheIter it = mMeshes.begin();
- it != mMeshes.end();
- ++it )
- {
- delete it->second;
- }
}
PlatformAbstraction& mPlatformAbstraction;
* This is the resource cache. It's filled/emptied from within Core::Update()
*/
BitmapMetadataCache mBitmapMetadata;
- MeshCache mMeshes;
ShaderCache mShaders;
};
mImpl->mTextureCacheDispatcher.DispatchUploadBitmapArrayToTexture( id, uploadArray );
}
-void ResourceManager::HandleAllocateMeshRequest( ResourceId id, MeshData* meshData )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleAllocateMeshRequest(id:%u)\n", id);
-
- SceneGraph::Mesh* renderableMesh(SceneGraph::Mesh::New(id, mImpl->mPostProcessResourceDispatcher, mImpl->mRenderQueue, meshData));
-
- DALI_ASSERT_ALWAYS(renderableMesh && "renderableMesh not created");
-
- // Add the ID to the completed set, and store the resource
- mImpl->newCompleteRequests.insert(id);
- mImpl->mMeshes.insert(MeshDataPair(id, renderableMesh));
-
- // Let NotificationManager know that the resource manager needs to do some processing
- NotifyTickets();
-}
-
void ResourceManager::HandleLoadShaderRequest( ResourceId id, const ResourceTypePath& typePath )
{
DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleLoadShaderRequest(id:%u, path:%s)\n", id, typePath.path.c_str());
}
}
-void ResourceManager::HandleUpdateMeshRequest( BufferIndex updateBufferIndex, ResourceId id, MeshData* meshData )
-{
- DALI_ASSERT_DEBUG( mImpl->mResourceClient != NULL );
- SceneGraph::Mesh* mesh = GetMesh( id );
- DALI_ASSERT_DEBUG(mesh);
-
- // Update the mesh data
- mesh->SetMeshData( meshData );
-
- // Update the GL buffers in the next Render
- typedef MessageDoubleBuffered2< SceneGraph::Mesh, SceneGraph::Mesh::ThreadBuffer, OwnerPointer<MeshData> > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mImpl->mRenderQueue.ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the mRenderer queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( mesh, &SceneGraph::Mesh::MeshDataUpdated, SceneGraph::Mesh::RENDER_THREAD, meshData );
-}
-
void ResourceManager::HandleReloadResourceRequest( ResourceId id, const ResourceTypePath& typePath, LoadResourcePriority priority, bool resetFinishedStatus )
{
DALI_ASSERT_DEBUG( mImpl->mResourceClient != NULL );
resource = GetShaderData(id);
break;
}
- case ResourceMesh:
- {
- break;
- }
+
case ResourceText:
{
break;
mImpl->atlasStatus.Update(id, atlasId, loadStatus );
}
-
/********************************************************************************
******************** Update thread object direct interface ********************
********************************************************************************/
return metadata;
}
-Internal::SceneGraph::Mesh* ResourceManager::GetMesh(ResourceId id)
-{
- SceneGraph::Mesh* mesh = NULL;
- MeshCacheIter iter = mImpl->mMeshes.find(id);
-
- if (iter != mImpl->mMeshes.end())
- {
- mesh = iter->second;
- }
-
- return mesh;
-}
-
ShaderDataPtr ResourceManager::GetShaderData(ResourceId id)
{
ShaderDataPtr shaderData;
break;
}
- case ResourceMesh:
- {
- break;
- }
-
case ResourceText:
{
/* here we return a vector of Characters (glyph data + bitmap)*/
case ResourceTargetImage:
break;
- case ResourceMesh:
- {
- MeshCacheIter mesh = mImpl->mMeshes.find(iter->first);
- DALI_ASSERT_DEBUG( mImpl->mMeshes.end() != mesh );
- if( mImpl->mMeshes.end() != mesh )
- {
- mImpl->mDiscardQueue.Add( updateBufferIndex, mesh->second );
- mImpl->mMeshes.erase( mesh );
- }
- }
- break;
-
case ResourceText:
{
break;
#include <dali/internal/event/text/font-impl.h>
#include <dali/internal/event/resources/resource-client-declarations.h>
#include <dali/internal/event/effects/shader-factory.h>
-#include <dali/internal/update/modeling/internal-mesh-data.h>
-#include <dali/internal/update/modeling/scene-graph-mesh-declarations.h>
#include <dali/internal/update/resources/resource-manager-declarations.h>
#include <dali/internal/update/resources/bitmap-metadata.h>
void HandleUpdateTextureRequest( ResourceId id, const BitmapUploadArray& uploadArray );
/**
- * Requests allocation of a mesh resource
- * @param[in] id The resource id
- * @param[in] meshData The mesh data
- */
- void HandleAllocateMeshRequest (ResourceId id, MeshData* meshData);
-
- /**
* Requests allocation of a font resource
*/
void HandleAllocateFontRequest(ResourceId id, const std::string& familyNameAndStyle);
void HandleUploadBitmapRequest( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset );
/**
- * Upload mesh buffer changes.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] id The ID of a Mesh resource.
- * @param[in] meshData Newly allocated mesh data; ownership is taken.
- */
- void HandleUpdateMeshRequest( BufferIndex updateBufferIndex, ResourceId id, MeshData* meshData );
-
- /**
* Request reloading a resource from the native filesystem.
* @param[in] id The resource id
* @param[in] typePath The type & path of the resource
BitmapMetadata GetBitmapMetadata(ResourceId id);
/**
- * Get the mesh data.
- * @note Used by update thread objects (SceneGraph::Mesh) only
- * @param[in] id - the id of a MeshData resource.
- * @return the mesh data or NULL if this resource isn't valid
- */
- Internal::SceneGraph::Mesh* GetMesh(ResourceId id);
-
- /**
* Returns the shader resource corresponding to the Id
* @param[in] id - the id of a shader binary resource.
* @return the shader binary resource data or NULL if it has not been loaded.
new (slot) LocalType( &manager, &ResourceManager::HandleUpdateTextureRequest, id, uploadArray );
}
-inline void RequestAllocateMeshMessage( EventToUpdate& eventToUpdate,
- ResourceManager& manager,
- ResourceId id,
- OwnerPointer<MeshData>& meshData )
-{
- typedef MessageValue2< ResourceManager, ResourceId, OwnerPointer<MeshData> > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &ResourceManager::HandleAllocateMeshRequest, id, meshData.Release() );
-}
-
inline void RequestAllocateFontMessage( EventToUpdate& eventToUpdate,
ResourceManager& manager,
ResourceId id,
new (slot) LocalType( &manager, &ResourceManager::HandleUploadBitmapRequest, destId, srcId, xOffset, yOffset );
}
-inline void RequestUpdateMeshMessage( EventToUpdate& eventToUpdate,
- ResourceManager& manager,
- ResourceId id,
- const Dali::MeshData& meshData,
- ResourcePolicy::Discardable discardable )
-{
- typedef MessageDoubleBuffered2< ResourceManager, ResourceId, OwnerPointer< MeshData > > LocalType;
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- MeshData* internalMeshData = new MeshData( meshData, discardable, false );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &ResourceManager::HandleUpdateMeshRequest, id, internalMeshData );
-}
-
inline void RequestReloadResourceMessage( EventToUpdate& eventToUpdate,
ResourceManager& manager,
ResourceId id,
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/actors/mesh-actor.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/actors/mesh-actor-impl.h>
-#include <dali/internal/event/modeling/mesh-impl.h>
-#include <dali/internal/event/modeling/animatable-mesh-impl.h>
-
-namespace Dali
-{
-
-MeshActor::MeshActor()
-{
-}
-
-MeshActor MeshActor::New()
-{
- Internal::MeshActorPtr internal = Internal::MeshActor::New();
- return MeshActor(internal.Get());
-}
-
-MeshActor MeshActor::New( Mesh mesh)
-{
- Internal::MeshActorPtr internal = Internal::MeshActor::New(mesh);
- return MeshActor(internal.Get());
-}
-
-MeshActor MeshActor::New( AnimatableMesh mesh)
-{
- Internal::MeshActorPtr internal = Internal::MeshActor::New(mesh);
- return MeshActor(internal.Get());
-}
-
-MeshActor MeshActor::DownCast( BaseHandle handle )
-{
- return MeshActor( dynamic_cast<Dali::Internal::MeshActor*>(handle.GetObjectPtr()) );
-}
-
-MeshActor::~MeshActor()
-{
-}
-
-MeshActor::MeshActor(const MeshActor& copy)
-: RenderableActor(copy)
-{
-}
-
-MeshActor& MeshActor::operator=(const MeshActor& rhs)
-{
- BaseHandle::operator=(rhs);
- return *this;
-}
-
-void MeshActor::SetMaterial(
- Actor actor,
- const std::string& actorName,
- Material material)
-{
- Actor child = actor.FindChildByName(actorName);
- if(child)
- {
- Internal::MeshActor* meshActor = dynamic_cast<Internal::MeshActor*>(&GetImplementation(child));
- if(meshActor)
- {
- meshActor->SetMaterial(material);
- }
- }
- else
- {
- DALI_LOG_ERROR("MeshActor::SetMaterial() - Can't find mesh actor\n");
- }
-}
-
-void MeshActor::SetMaterial(Material material)
-{
- GetImplementation(*this).SetMaterial(material);
-}
-
-Material MeshActor::GetMaterial() const
-{
- return GetImplementation(*this).GetMaterial();
-}
-
-void MeshActor::BindBonesToMesh(Actor rootActor)
-{
- Internal::ActorPtr root(&GetImplementation(rootActor));
-
- GetImplementation(*this).BindBonesToMesh(root);
-}
-
-MeshActor::MeshActor(Internal::MeshActor* internal)
- : RenderableActor(internal)
-{
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_MESH_ACTOR_H__
-#define __DALI_MESH_ACTOR_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-// INTERNAL INCLUDES
-#include <dali/public-api/actors/renderable-actor.h>
-
-namespace Dali
-{
-class Material;
-class Mesh;
-class Model;
-class AnimatableMesh;
-
-namespace Internal DALI_INTERNAL
-{
-class MeshActor;
-}
-
-/**
- * @brief This actor is used to draw a mesh geometry with a material.
- *
- * It allows for a custom material to be drawn on the mesh.
- * By default CullFaceMode is set to CullBack to enable back face culling.
- */
-class DALI_IMPORT_API MeshActor : public RenderableActor
-{
-public:
-
- /**
- * @brief Create an uninitialized MeshActor handle.
- *
- * This can be initialised with MeshActor::New().
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- MeshActor();
-
- /**
- * @brief Create a MeshActor object.
- * @return the newly allocated MeshActor object
- */
- static MeshActor New();
-
- /**
- * @brief Create a MeshActor object.
- *
- * @param[in] mesh the Mesh the actor will use.
- * @return the newly allocated MeshActor object
- */
- static MeshActor New( Mesh mesh );
-
- /**
- * @brief Create a MeshActor object
- *
- * @param[in] mesh the Animated Mesh the actor will use.
- * @return the newly allocated MeshActor object
- */
- static MeshActor New( AnimatableMesh mesh );
-
- /**
- * @brief Downcast an Object handle to MeshActor.
- *
- * If handle points to a MeshActor the downcast produces a valid
- * handle. If not the returned handle is left uninitialized.
- * @param[in] handle to an object
- * @return handle to a MeshActor or an uninitialized handle
- */
- static MeshActor DownCast( BaseHandle handle );
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~MeshActor();
-
- /**
- * @brief Copy constructor
- *
- * @param [in] copy The actor to copy.
- */
- MeshActor(const MeshActor& copy);
-
- /**
- * @brief Assignment operator
- *
- * @param [in] rhs The actor to copy.
- */
- MeshActor& operator=(const MeshActor& rhs);
-
- /**
- * @brief Set a custom material on the given actor or one of it's children.
- *
- * @pre the mesh is loaded
- * @param[in] actor The first actor in the tree of model actors
- * @param[in] actorName The name of the actor to search for.
- * @param[in] material The custom material.<br>Pass NULL to revert to the
- * original material.
- */
- static void SetMaterial(Actor actor, const std::string& actorName, Material material);
-
- /**
- * @brief Set a custom material on this actor.
- *
- * @pre the mesh is loaded
- * @param[in] material The custom material.@n
- * Pass an uninitialised Material to revert to the original material.
- */
- void SetMaterial(Material material);
-
- /**
- * @brief Get the material for this mesh actor.
- *
- * @pre the mesh is loaded
- * @return The material
- */
- Material GetMaterial() const;
-
- /**
- * @brief Search the actor tree for all named bones in the mesh and connect them.
- *
- * @param[in] rootActor The root actor of the actor tree.
- */
- void BindBonesToMesh(Actor rootActor);
-
-public: // Not intended for application developers
-
- /**
- * @brief This constructor is used by Dali New() methods
- *
- * @param [in] actor A pointer to a newly allocated Dali resource
- */
- explicit DALI_INTERNAL MeshActor(Internal::MeshActor* actor);
-};
-
-} // namespace Dali
-
-#endif /* _MESH_ACTOR_H_ */
#include <dali/public-api/actors/draw-mode.h>
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/actors/layer.h>
-#include <dali/public-api/actors/mesh-actor.h>
#include <dali/public-api/actors/renderable-actor.h>
#include <dali/public-api/actors/text-actor.h>
#include <dali/public-api/actors/sampling.h>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/events/touch-point.h>
-#include <dali/public-api/geometry/animatable-mesh.h>
-#include <dali/public-api/geometry/animatable-vertex.h>
-#include <dali/public-api/geometry/cloth.h>
-#include <dali/public-api/geometry/mesh.h>
-#include <dali/public-api/geometry/mesh-factory.h>
#include <dali/public-api/geometry/spline.h>
#include <dali/public-api/images/atlas.h>
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/modeling/bone.h>
-#include <dali/public-api/modeling/material.h>
-
#include <dali/public-api/object/any.h>
#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/dynamics/dynamics-shape.h>
// INTERNAL HEADERS
-#include <dali/internal/event/modeling/mesh-impl.h>
#ifdef DYNAMICS_SUPPORT
#include <dali/internal/event/dynamics/dynamics-shape-impl.h>
#endif
}
-DynamicsShape DynamicsShape::NewMesh(Cloth cloth)
-{
-#ifdef DYNAMICS_SUPPORT
- Internal::DynamicsMeshShapePtr internal( new Internal::DynamicsMeshShape( GetImplementation(cloth) ) );
-
- return DynamicsShape(internal.Get());
-#else
- return DynamicsShape();
-#endif
-}
-
DynamicsShape DynamicsShape::NewSphere(const float radius)
{
#ifdef DYNAMICS_SUPPORT
// BASE CLASS INCLUDES
#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/geometry/cloth.h>
namespace Dali
{
static DynamicsShape NewCylinder(const float radius, const float length);
/**
- * @brief Creates a mesh.
- *
- * @param[in] mesh A mesh.
- * @return A handle to the new shape
- */
- static DynamicsShape NewMesh(Cloth mesh);
-
- /**
* @brief Creates a sphere.
*
* @param[in] radius The radius of the sphere.
$(public_api_src_dir)/actors/custom-actor-impl.cpp \
$(public_api_src_dir)/actors/image-actor.cpp \
$(public_api_src_dir)/actors/layer.cpp \
- $(public_api_src_dir)/actors/mesh-actor.cpp \
$(public_api_src_dir)/actors/text-actor.cpp \
$(public_api_src_dir)/actors/renderable-actor.cpp \
$(public_api_src_dir)/animation/active-constraint.cpp \
$(public_api_src_dir)/events/tap-gesture-detector.cpp \
$(public_api_src_dir)/events/touch-point.cpp \
$(public_api_src_dir)/events/touch-event.cpp \
- $(public_api_src_dir)/geometry/animatable-mesh.cpp \
- $(public_api_src_dir)/geometry/animatable-vertex.cpp \
- $(public_api_src_dir)/geometry/cloth.cpp \
- $(public_api_src_dir)/geometry/mesh-data.cpp \
- $(public_api_src_dir)/geometry/mesh-factory.cpp \
- $(public_api_src_dir)/geometry/mesh.cpp \
$(public_api_src_dir)/geometry/spline.cpp \
$(public_api_src_dir)/images/atlas.cpp \
$(public_api_src_dir)/images/distance-field.cpp \
$(public_api_src_dir)/math/vector2.cpp \
$(public_api_src_dir)/math/vector3.cpp \
$(public_api_src_dir)/math/vector4.cpp \
- $(public_api_src_dir)/modeling/bone.cpp \
- $(public_api_src_dir)/modeling/material.cpp \
$(public_api_src_dir)/object/any.cpp \
$(public_api_src_dir)/object/base-handle.cpp \
$(public_api_src_dir)/object/handle.cpp \
$(public_api_src_dir)/actors/draw-mode.h \
$(public_api_src_dir)/actors/image-actor.h \
$(public_api_src_dir)/actors/layer.h \
- $(public_api_src_dir)/actors/mesh-actor.h \
$(public_api_src_dir)/actors/text-actor.h \
$(public_api_src_dir)/actors/renderable-actor.h \
$(public_api_src_dir)/actors/sampling.h
$(public_api_src_dir)/events/touch-event.h
public_api_core_geometry_header_files = \
- $(public_api_src_dir)/geometry/animatable-mesh.h \
- $(public_api_src_dir)/geometry/animatable-vertex.h \
- $(public_api_src_dir)/geometry/cloth.h \
- $(public_api_src_dir)/geometry/mesh.h \
- $(public_api_src_dir)/geometry/mesh-data.h \
- $(public_api_src_dir)/geometry/mesh-factory.h \
$(public_api_src_dir)/geometry/spline.h
public_api_core_images_header_files = \
$(public_api_src_dir)/math/vector4.h \
$(public_api_src_dir)/math/viewport.h
-public_api_core_modeling_header_files = \
- $(public_api_src_dir)/modeling/bone.h \
- $(public_api_src_dir)/modeling/material.h
-
public_api_core_object_header_files = \
$(public_api_src_dir)/object/any.h \
$(public_api_src_dir)/object/base-handle.h \
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-#include <dali/public-api/geometry/animatable-mesh.h>
-#include <dali/internal/event/modeling/animatable-mesh-impl.h>
-
-namespace Dali
-{
-
-AnimatableMesh::AnimatableMesh()
-{
-}
-
-AnimatableMesh AnimatableMesh::New(
- unsigned int numVertices,
- const AnimatableMesh::Faces& faceIndices,
- Dali::Material material )
-{
- Internal::AnimatableMeshPtr internal = Internal::AnimatableMesh::New( numVertices,
- faceIndices,
- material );
- return AnimatableMesh(internal.Get());
-}
-
-AnimatableMesh AnimatableMesh::New( unsigned int numVertices,
- const Faces& faceIndices )
-{
-
- Internal::AnimatableMeshPtr internal = Internal::AnimatableMesh::New( numVertices, faceIndices );
- return AnimatableMesh(internal.Get());
-}
-
-AnimatableMesh AnimatableMesh::DownCast( BaseHandle handle )
-{
- return AnimatableMesh( dynamic_cast<Dali::Internal::AnimatableMesh*>(handle.GetObjectPtr()) );
-}
-
-AnimatableMesh::~AnimatableMesh()
-{
-}
-
-AnimatableMesh::AnimatableMesh(const AnimatableMesh& handle)
-: Handle(handle)
-{
-}
-
-AnimatableMesh& AnimatableMesh::operator=(const AnimatableMesh& rhs)
-{
- BaseHandle::operator=(rhs);
- return *this;
-}
-
-unsigned int AnimatableMesh::GetNumberOfVertices() const
-{
- return GetImplementation(*this).GetNumberOfVertices();
-}
-
-AnimatableVertex AnimatableMesh::operator[](const unsigned int index) const
-{
- DALI_ASSERT_ALWAYS( index < GetNumberOfVertices() && "Index out of bounds" );
-
- return AnimatableVertex(index, *this);
-}
-
-Property::Index AnimatableMesh::GetPropertyIndex(
- unsigned int index,
- Property::Index property ) const
-{
- DALI_ASSERT_ALWAYS( index < GetNumberOfVertices() && "Index out of bounds" );
-
- return GetImplementation(*this).GetVertexPropertyIndex( index, property );
-}
-
-Property AnimatableMesh::GetVertexProperty( unsigned int vertex, Property::Index property)
-{
- return Property( *this, GetPropertyIndex( vertex, property ) );
-}
-
-
-AnimatableMesh::AnimatableMesh( Internal::AnimatableMesh* internal )
-: Handle(internal)
-{
-}
-
-} // Dali
+++ /dev/null
-#ifndef __DALI_ANIMATABLE_MESH__H__
-#define __DALI_ANIMATABLE_MESH__H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/object/handle.h>
-#include <dali/public-api/geometry/animatable-vertex.h>
-#include <dali/public-api/modeling/material.h>
-
-namespace Dali
-{
-class AnimatableVertex;
-
-namespace Internal DALI_INTERNAL
-{
-class AnimatableMesh;
-}
-
-/**
- * @brief An animatable mesh can have any of its vertices animated using Dali's animation and
- * constraint systems.
- *
- * It is recommended that the vertices of the mesh remain in the bounds -0.5 - 0.5, which
- * will match the actor size boundaries. The origin of the mesh matches the actor's position.
- */
-class DALI_IMPORT_API AnimatableMesh : public Handle
-{
-public:
- /**
- * @brief Vector of face indices.
- */
- typedef std::vector<unsigned short> Faces;
- typedef Faces::iterator FacesIter; ///< Iterator for Dali::AnimatableMesh::Faces
- typedef Faces::const_iterator FacesConstIter; ///< Const Iterator for Dali::AnimatableMesh::Faces
-
- /**
- * @brief Create an uninitialized handle, this can be initialized with New().
- *
- * Calling member functions on an uninitialized handle will result
- * in an assertion
- */
- AnimatableMesh();
-
- /**
- * @brief Create a new animatable mesh with a given number of vertices and triangles.
- *
- * This will assert if any index is out of range.
- * Using this constructor enables the vertex color property.
- * AnimatableMesh does not take ownership of the faceIndices.
- * @param[in] numVertices The number of vertices in the mesh
- * @param[in] faceIndices A set of vertex indices, 3 per face.
- * @return an initialized handle to the animatable mesh
- * @note The maximum number of supported vertices is 3333333.
- */
- static AnimatableMesh New( unsigned int numVertices,
- const Faces& faceIndices );
-
- /**
- * @brief Create a new animatable mesh with a given number of vertices and triangles.
- *
- * This will assert if any index is out of range.
- * Using this constructor disables the vertex color property.
- * AnimatableMesh does not take ownership of the faceIndices.
- * @param[in] numVertices The number of vertices in the mesh
- * @param[in] faceIndices A set of vertex indices, 3 per face.
- * @param[in] material Material used to render mesh
- * @return an initialized handle to the animatable mesh
- * @note The maximum number of supported vertices is 3333333.
- */
- static AnimatableMesh New( unsigned int numVertices,
- const Faces& faceIndices,
- Dali::Material material );
-
- /**
- * @brief Downcast an Object handle to AnimatableMesh.
- *
- * If the handle points to an AnimatableMesh objec, the downcast
- * produces a valid handle. If not, the handle is left
- * uninitialized.
- *
- * @param[in] handle to an Object
- * @return handle to an AnimatableMesh or an uninitialized handle
- */
- static AnimatableMesh DownCast( BaseHandle handle );
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~AnimatableMesh();
-
- /**
- * @brief This copy constructor is required for (smart) pointer semantics.
- *
- * @param [in] handle A reference to the copied handle
- */
- AnimatableMesh(const AnimatableMesh& handle);
-
- /**
- * @brief This assignment operator is required for (smart) pointer semantics.
- *
- * @param [in] rhs A reference to the copied handle
- * @return A reference to this
- */
- AnimatableMesh& operator=(const AnimatableMesh& rhs);
-
- /**
- * @brief Get the number of vertices with which this mesh was created.
- *
- * @return number of vertices in this mesh
- */
- unsigned int GetNumberOfVertices() const;
-
- /**
- * @brief Array subscript operator overload.
- *
- * @pre The vertex index is in range
- * @param[in] index subscript
- * @return the vertex at the given index
- */
- AnimatableVertex operator[]( unsigned int index ) const;
-
- /**
- * @brief Get a property index for a given vertex.
- *
- * @pre The vertex index and property is in range
- * @param[in] vertex The vertex
- * @param[in] property The vertex attribute
- * @return A property index for use in constraints or animations
- */
- Property::Index GetPropertyIndex( unsigned int vertex, Property::Index property) const;
-
- /**
- * @brief Get the property for a given vertex.
- *
- * @pre The vertex index and property is in range
- * @param[in] vertex The vertex
- * @param[in] property The vertex attribute
- * @return A property index for use in constraints or animations
- */
- Property GetVertexProperty( unsigned int vertex, Property::Index property );
-
-public: // Not for use by application developer
-
- /**
- * @brief This constructor is used by Dali New() methods
- *
- * @param [in] mesh A pointer to a newly allocated Dali resource
- */
- explicit DALI_INTERNAL AnimatableMesh(Internal::AnimatableMesh* mesh);
-};
-
-}// Dali
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/public-api/geometry/animatable-vertex.h>
-#include <dali/public-api/geometry/animatable-mesh.h>
-#include <dali/internal/event/modeling/animatable-mesh-impl.h>
-
-namespace Dali
-{
-
-AnimatableVertex::AnimatableVertex( unsigned int vertex, AnimatableMesh mesh)
- : mVertex(vertex),
- mMesh(GetImplementation(mesh))
-{
- DALI_ASSERT_ALWAYS( mesh && "Mesh handle is empty" );
- DALI_ASSERT_ALWAYS( vertex < mesh.GetNumberOfVertices() && "vertex is out of bounds" );
-}
-
-AnimatableVertex::~AnimatableVertex()
-{
-}
-
-void AnimatableVertex::SetPosition(const Vector3& position)
-{
- mMesh.SetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::Position), Dali::Property::Value(position) );
-}
-
-void AnimatableVertex::SetColor(const Vector4& color)
-{
- mMesh.SetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::Color), Dali::Property::Value(color) );
-}
-
-void AnimatableVertex::SetTextureCoords(const Vector2& textureCoords)
-{
- mMesh.SetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::TextureCoords), Dali::Property::Value(textureCoords) );
-}
-
-Vector3 AnimatableVertex::GetCurrentPosition()
-{
- Vector3 position;
- mMesh.GetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::Position) ).Get(position);
- return position;
-}
-
-Vector4 AnimatableVertex::GetCurrentColor()
-{
- Vector4 color;
- mMesh.GetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::Color) ).Get(color);
- return color;
-}
-
-Vector2 AnimatableVertex::GetCurrentTextureCoords()
-{
- Vector2 textureCoords;
- mMesh.GetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::TextureCoords) ).Get(textureCoords);
- return textureCoords;
-}
-
-}//Dali
+++ /dev/null
-#ifndef __DALI_ANIMATABLE_VERTEX__H__
-#define __DALI_ANIMATABLE_VERTEX__H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/object/property.h>
-#include <dali/public-api/object/property-index-ranges.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/math/vector3.h>
-#include <dali/public-api/math/vector4.h>
-
-namespace Dali
-{
-class AnimatableMesh;
-
-namespace Internal DALI_INTERNAL
-{
-class AnimatableMesh;
-}
-
-/**
- * @brief Represents a vertex in an AnimatableMesh.
- *
- * It is used by AnimatableMesh to offer an array interface for
- * setting properties:
- *
- * @code
- * AnimatableMesh mesh = AnimatableMesh(numVerts, faces);
- * mesh[vertex].SetColor(color);
- * @endcode
- */
-class DALI_IMPORT_API AnimatableVertex
-{
-public:
-
- /**
- * @brief An enumeration of properties belonging to the AnimatableVertex class.
- * Note: These are used by animatable mesh also.
- */
- struct Property
- {
- enum
- {
- Position = DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX, ///< name prefix "position-", type VECTOR3
- Color, ///< name prefix "color-", type VECTOR4
- TextureCoords, ///< name prefix "texture-coords-", type VECTOR2
- };
- };
-
- /**
- * @brief Destructor
- */
- ~AnimatableVertex();
-
- /**
- * @brief Set the position of the vertex.
- *
- * @param[in] position (note, -0.5 - +0.5 are inside the actor's boundaries)
- */
- void SetPosition(const Vector3& position);
-
- /**
- * @brief Set the vertex color.
- * @param[in] color The vertex color
- */
- void SetColor(const Vector4& color);
-
- /**
- * @brief Set the texture coordinates.
- *
- * @param[in] textureCoords The texture coordinates
- */
- void SetTextureCoords(const Vector2& textureCoords);
-
- /**
- * @brief Get the current position of the vertex.
- *
- * @return position
- */
- Vector3 GetCurrentPosition();
-
- /**
- * @brief Get the current vertex color.
- *
- * @return The vertex color
- */
- Vector4 GetCurrentColor();
-
- /**
- * @brief Get the current texture coordinates.
- *
- * @return textureCoords The texture coordinates
- */
- Vector2 GetCurrentTextureCoords();
-
-private:
- // Only allow AnimatableMesh to construct this object.
- friend class Dali::AnimatableMesh;
-
- /**
- * @brief Constructor.
- *
- * @param[in] vertex The index of the vertex in the parent mesh
- * @param[in] mesh The parent mesh
- */
- AnimatableVertex( unsigned int vertex, AnimatableMesh mesh );
-
- /**
- * @brief Undefined Copy Constructor
- */
- AnimatableVertex(const AnimatableVertex& vertex);
-
- /**
- * @brief Undefined Assignment Operator
- */
- AnimatableVertex& operator=(const AnimatableVertex& vertex);
-
- int mVertex; ///< The index of this vertex in the parent mesh
- Internal::AnimatableMesh& mMesh; ///< The parent mesh
-};
-
-
-}//Dali
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/geometry/cloth.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/geometry/mesh-factory.h>
-#include <dali/internal/event/modeling/cloth-impl.h>
-
-namespace Dali
-{
-
-namespace
-{
-
-} // namespace
-
-Cloth::Cloth()
-{
-}
-
-Cloth::~Cloth()
-{
-}
-
-Cloth::Cloth(const Cloth& handle)
-: Mesh(handle)
-{
-}
-
-Cloth& Cloth::operator=(const Cloth& rhs)
-{
- BaseHandle::operator=(rhs);
- return *this;
-}
-
-Cloth Cloth::New( const float width, const float height, const int xSteps, const int ySteps, const Rect<float>& textureCoordinates )
-{
- MeshData meshData( MeshFactory::NewPlane(width, height, xSteps, ySteps, textureCoordinates) );
-
- Internal::ClothIPtr clothPtr = Internal::Cloth::New( meshData );
- return Cloth( clothPtr.Get() );
-}
-
-Cloth Cloth::DownCast( BaseHandle handle )
-{
- return Cloth( dynamic_cast<Dali::Internal::Cloth*>(handle.GetObjectPtr()) );
-}
-
-Cloth::Cloth(Internal::Cloth* internal)
-: Mesh(internal)
-{
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_CLOTH_H__
-#define __DALI_CLOTH_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-// INTERNAL INCLUDES
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/geometry/mesh.h>
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class Cloth;
-}
-
-/**
- * @brief A Cloth is a specialized mesh that can be used and modified
- * by the Dynamics engine.
- */
-class DALI_IMPORT_API Cloth : public Mesh
-{
-public:
-
- /**
- * @brief Create an initialized plane aligned on the XY axis.
- *
- * @param[in] width The width of the plane
- * @param[in] height The height of the plane
- * @param[in] xSteps The number of vertices along the X axis
- * @param[in] ySteps The number of vertices along the Y axis
- * @param[in] textureCoordinates UV coordinates.
- * @return A handle to a newly allocated Dali resource.
- */
- static Cloth New(const float width,
- const float height,
- const int xSteps,
- const int ySteps,
- const Rect<float>& textureCoordinates = Rect<float>(0.0f, 0.0f, 1.0f, 1.0f));
-
-
- /**
- * @brief Create an uninitialized Cloth; this can be initialized with Cloth::New().
- *
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- Cloth();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Cloth();
-
- /**
- * @brief This copy constructor is required for (smart) pointer semantics.
- *
- * @param [in] handle A reference to the copied handle
- */
- Cloth(const Cloth& handle);
-
- /**
- * @brief This assignment operator is required for (smart) pointer semantics.
- *
- * @param [in] rhs A reference to the copied handle
- * @return A reference to this
- */
- Cloth& operator=(const Cloth& rhs);
-
- /**
- * @brief Downcast an Object handle to a Cloth handle.
- *
- * If handle points to a Cloth object the downcast produces valid
- * handle. If not the returned handle is left uninitialized.
- *
- * @param[in] handle to an object
- * @return handle to a Cloth object or an uninitialized handle
- */
- static Cloth DownCast( BaseHandle handle );
-
-public: // Not intended for application developers
-
- /**
- * @brief This constructor is used by Dali New() methods.
- *
- * @param [in] cloth A pointer to a newly allocated Dali resource
- */
- explicit DALI_INTERNAL Cloth(Internal::Cloth* cloth);
-};
-
-} // namespace Dali
-
-#endif // __DALI_CLOTH_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// Class header
-#include <dali/public-api/geometry/mesh-data.h>
-
-// Internal headers
-#include <dali/public-api/math/matrix.h>
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace // unnamed namespace
-{
-const float kBoundsDefault = 1e10f;
-} // unnamed namespace
-
-using Dali::Vector4;
-
-
-MeshData::MeshData( )
-: mGeometryType(TRIANGLES),
- mUseTextureCoords(false),
- mUseNormals(false),
- mUseColor(false),
- mMin( kBoundsDefault, kBoundsDefault, kBoundsDefault, 0.0f),
- mMax(-kBoundsDefault, -kBoundsDefault, -kBoundsDefault, 0.0f)
-{
-}
-
-MeshData::MeshData( const MeshData& meshData )
-: mVertices( meshData.mVertices ),
- mFaces( meshData.mFaces ),
- mGeometryType( meshData.mGeometryType ),
- mUseTextureCoords( meshData.mUseTextureCoords ),
- mUseNormals( meshData.mUseNormals ),
- mUseColor( meshData.mUseColor ),
- mBones( meshData.mBones ),
- mMaterial( meshData.mMaterial ),
- mMin( meshData.mMin ),
- mMax( meshData.mMax )
-{
-}
-
-MeshData& MeshData::operator=(const MeshData& rhs)
-{
- mVertices = rhs.mVertices;
- mFaces = rhs.mFaces;
- mGeometryType = rhs.mGeometryType;
- mUseTextureCoords = rhs.mUseTextureCoords;
- mUseNormals = rhs.mUseNormals;
- mUseColor = rhs.mUseColor;
- mBones = rhs.mBones;
- mMaterial = rhs.mMaterial;
- mMin = rhs.mMin;
- mMax = rhs.mMax;
-
- return *this;
-}
-
-MeshData::~MeshData()
-{
-}
-
-void MeshData::SetData(
- const VertexContainer& vertices,
- const FaceIndices& faceIndices,
- const BoneContainer& bones,
- Material material )
-{
- DALI_ASSERT_ALWAYS( !vertices.empty() && "VertexContainer is empty" );
- DALI_ASSERT_ALWAYS( !faceIndices.empty() && "FaceIndices is empty" );
- DALI_ASSERT_ALWAYS( material && "Material handle is empty" );
-
- mGeometryType = TRIANGLES;
- mVertices = vertices;
- mFaces = faceIndices;
- mMaterial = material;
- mBones = bones;
-}
-
-void MeshData::SetLineData(
- const VertexContainer& vertices,
- const FaceIndices& lineIndices,
- Material material )
-{
- DALI_ASSERT_ALWAYS( !vertices.empty() && "VertexContainer is empty" );
- DALI_ASSERT_ALWAYS( !lineIndices.empty() && "FaceIndices is empty" );
- DALI_ASSERT_ALWAYS( material && "Material handle is empty" );
-
- mGeometryType = LINES;
- mVertices = vertices;
- mFaces = lineIndices;
- mMaterial = material;
-}
-
-void MeshData::SetPointData(
- const VertexContainer& vertices,
- Material material )
-{
- DALI_ASSERT_ALWAYS( !vertices.empty() && "VertexContainer is empty" );
- DALI_ASSERT_ALWAYS( material && "Material handle is empty" );
-
- mGeometryType = POINTS;
- mVertices = vertices;
- mMaterial = material;
-}
-
-void MeshData::SetVertices( const VertexContainer& vertices )
-{
- DALI_ASSERT_ALWAYS( !vertices.empty() && "VertexContainer is empty" );
-
- mVertices = vertices;
-}
-
-void MeshData::SetFaceIndices( const FaceIndices& faceIndices )
-{
- DALI_ASSERT_ALWAYS( !faceIndices.empty() && "FaceIndices is empty" );
-
- mFaces = faceIndices;
-}
-
-void MeshData::AddToBoundingVolume(Vector4& min, Vector4& max, const Dali::Matrix& transform)
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gModel);
-
- for (VertexConstIter iter = mVertices.begin(); iter != mVertices.end(); ++iter)
- {
- const Vertex& vertex = *iter;
- Vector4 point = Vector4(vertex.x, vertex.y, vertex.z, 0.0f);
-
- mMin = Min(mMin, point);
- mMax = Max(mMax, point);
- }
- // mMin/mMax are accessed through public API, so have chosen to set w to zero
- // ( They should really be Vector3's )
- mMin.w=0.0f;
- mMax.w=0.0f;
-
- // For the matrix multiplication below to work correctly, the w needs to be 1.
- Vector4 tmpMin(mMin);
- Vector4 tmpMax(mMax);
- tmpMin.w = 1.0f;
- tmpMax.w = 1.0f;
-
- min = Min(min, transform * tmpMin);
- max = Max(max, transform * tmpMax);
-
- // Ensure the bounding volume out parameters also have w=0. (They should also
- // be Vector3's )
- min.w = 0.0f;
- max.w = 0.0f;
-}
-
-MeshData::VertexGeometryType MeshData::GetVertexGeometryType() const
-{
- return mGeometryType;
-}
-
-size_t MeshData::GetVertexCount() const
-{
- return mVertices.size();
-}
-
-const MeshData::VertexContainer& MeshData::GetVertices() const
-{
- return mVertices;
-}
-
-size_t MeshData::GetFaceCount() const
-{
- size_t faceCount = 0;
-
- switch( mGeometryType )
- {
- case POINTS:
- faceCount = mVertices.size();
- break;
- case LINES:
- faceCount = mFaces.size() / 2;
- break;
- case TRIANGLES:
- faceCount = mFaces.size() / 3;
- break;
- }
- return faceCount;
-}
-
-const MeshData::FaceIndices& MeshData::GetFaces() const
-{
- return mFaces;
-}
-
-void MeshData::SetHasTextureCoords(bool hasTexCoords)
-{
- mUseTextureCoords = hasTexCoords;
-}
-
-bool MeshData::HasTextureCoords() const
-{
- return mUseTextureCoords;
-}
-
-void MeshData::SetHasNormals(bool hasNormals)
-{
- mUseNormals = hasNormals;
- if( hasNormals )
- {
- // Enforce mutual exclusivity
- mUseColor = false;
- }
-}
-
-bool MeshData::HasNormals() const
-{
- return mUseNormals;
-}
-
-void MeshData::SetHasColor(bool hasColor)
-{
- mUseColor = hasColor;
- if( hasColor )
- {
- // Enforce mutual exclusivity
- mUseNormals = false;
- }
-}
-
-bool MeshData::HasColor() const
-{
- return mUseColor;
-}
-
-Material MeshData::GetMaterial() const
-{
- return mMaterial;
-}
-
-void MeshData::SetMaterial(Material material)
-{
- mMaterial = material;
-}
-
-size_t MeshData::GetBoneCount() const
-{
- return mBones.size();
-}
-
-bool MeshData::HasBones() const
-{
- return mBones.size() > 0;
-}
-
-const BoneContainer& MeshData::GetBones() const
-{
- return mBones;
-}
-
-const Vector4& MeshData::GetBoundingBoxMin() const
-{
- return mMin;
-}
-
-void MeshData::SetBoundingBoxMin(const Vector4& bounds)
-{
- mMin = bounds;
-}
-
-const Vector4& MeshData::GetBoundingBoxMax() const
-{
- return mMax;
-}
-
-
-void MeshData::SetBoundingBoxMax(const Vector4& bounds)
-{
- mMax = bounds;
-}
-
-} // namespace Dali
-
+++ /dev/null
-#ifndef __DALI_MESH_DATA_H__
-#define __DALI_MESH_DATA_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/modeling/bone.h>
-#include <dali/public-api/modeling/material.h>
-
-
-// DECLARATION FILES
-
-
-namespace Dali
-{
-class Matrix;
-
-/**
- * @brief The MeshData class encompasses all the data required to describe and
- * render a 3D mesh.
- *
- * The mesh can have one of three geometry types: Points, Lines or Triangles.
- * The Point type draws each vertex. The shader can control the point size.
- * The Line type draws single pixel width lines between each specified vertex.
- * The Triangles type draws solid color or texture between each specified
- * vertex.
- *
- * When using the Points or Lines geometry type, normals aren't used.
- *
- * If the HasColor property is set, the vertex color is used to draw the points,
- * lines or triangles, otherwise the material's diffuse color or texture is
- * used. The material's diffuse alpha value is always used.
- *
- * When using the Triangles geometry type, the normals are mutually exclusive
- * with vertex color. This means that shading cannot be performed if vertex
- * color is being used.
- *
- * It is possible to deform the mesh using skeletal deformation. To acheive
- * this, a number of bones can be supplied during creation. These are named
- * actors that can be anywhere in the actor tree. Each bone has an offset
- * matrix. A vertex in the mesh can reference up to 4 bones in the bone
- * container with an associated weighting.
- *
- * When the mesh is added to the scene graph, the node for each named actor is
- * added to an internal container. Each Update frame after the node update pass,
- * the node's world matrix is multiplied by the associated bone's offset matrix.
- * When rendering the mesh, these transform matrices are multiplied by the view
- * matrix, their inverse transforms calculated and passed onto the shaders.
- *
- * The mesh vertex shader then applies up to 4 weighted transforms to each
- * vertex and vertex normal.
- */
-class DALI_IMPORT_API MeshData
-{
-public:
- static const unsigned int MAX_NUMBER_OF_BONES = 12; ///< Maximum number of bones that can affect this mesh.
-
- struct Vertex;
- typedef std::vector<Vertex> VertexContainer; ///< Collection of vertices
- typedef VertexContainer::iterator VertexIter; ///< Iterator for @ref Dali::MeshData::VertexContainer
- typedef VertexContainer::const_iterator VertexConstIter; ///< Const iterator for @ref Dali::MeshData::VertexContainer
-
- typedef unsigned short FaceIndex; ///< index of one point of a polygonal face
- typedef std::vector<FaceIndex> FaceIndices; ///< Collection of FaceIndex items ( The span should match the geometry type: Lines - span is 2; Triangles - span is 3 ).
- typedef FaceIndices::iterator FaceIndexIter; ///< Iterator for @ref Dali::MeshData::FaceIndices
- typedef FaceIndices::const_iterator FaceIndexConstIter; ///< Const iterator for @ref Dali::MeshData::FaceIndices
-
- /**
- * @brief The type of geometry to draw
- */
- enum VertexGeometryType
- {
- POINTS, ///< Draw only points at each vertex
- LINES, ///< Draw lines between specified vertices
- TRIANGLES ///< Draw filled triangles between specified vertices
- };
-
-public: // construction, destruction and initialisation
-
- /**
- * @brief Create a new mesh.
- */
- MeshData( );
-
- /**
- * @brief Copy constructor.
- *
- * @param[in] meshData object to copy
- */
- MeshData( const MeshData& meshData );
-
- /**
- * @brief Assignment operator.
- *
- * @param[in] rhs MeshData object to copy data from
- * @return A reference to this
- */
- MeshData& operator=(const MeshData& rhs);
-
- /**
- * @brief Sets the vertex coords, the face indices, the bones affecting this mesh and a default
- * material.
- *
- * @param[in] vertices The Vertex data (coordinates of each vertex)
- * @param[in] faceIndices The index into the vertices buffer for each corner of each triangular face.
- * @param[in] bones A container of Bones affecting this mesh.
- * @param[in] material A handle to a material object.
- */
- void SetData( const VertexContainer& vertices,
- const FaceIndices& faceIndices,
- const BoneContainer& bones,
- const Material material );
-
- /**
- * @brief Set the vertex coords and end points of each line.
- *
- * @param[in] vertices The vertex data (coords & color of each vertex)
- * @param[in] lineIndices A list of vertex indices for the start & end of each line.
- * @param[in] material A handle to a material object.
- */
- void SetLineData( const VertexContainer& vertices,
- const FaceIndices& lineIndices,
- const Material material );
-
- /**
- * @brief Set the vertex coords for each point.
- *
- * @param[in] vertices The vertex data (coords & color of each vertex)
- * @param[in] material A handle to a material object.
- */
- void SetPointData( const VertexContainer& vertices,
- const Material material );
-
- /**
- * @brief Set the vertex coords for each point.
- *
- * @param[in] vertices The vertex data (coords & color of each vertex)
- */
- void SetVertices( const VertexContainer& vertices );
-
- /**
- * @brief Sets the face indices.
- *
- * @param[in] faceIndices The index into the vertices buffer for each corner of each triangular face.or for the start and end of each line.
- */
- void SetFaceIndices( const FaceIndices& faceIndices );
-
- /**
- * @brief Add the mesh to the bounding volume.
- *
- * Expands a bounding volume to include the mesh
- * @param[in,out] min Lower bounds
- * @param[in,out] max Upper bounds
- * @param[in] transform transform the mesh vertices
- */
- void AddToBoundingVolume(Vector4& min, Vector4& max, const Matrix& transform);
-
- /**
- * @brief Get the geometry type.
- *
- * A mesh defaults to triangles if no data has been set.
- * @return the geometry type;
- */
- VertexGeometryType GetVertexGeometryType() const;
-
- /**
- * @brief Get the number of vertices.
- *
- * @return The number of vertices
- */
- size_t GetVertexCount() const;
-
- /**
- * @brief Get the vertex array.
- *
- * @return The vertex array
- */
- const VertexContainer& GetVertices() const;
-
- /**
- * @brief Get the number of points, lines or faces (note this is not the same as the number of face indices!).
- *
- * depending on the geometry type;
- * @return Number of points, lines or faces
- */
- size_t GetFaceCount() const;
-
- /**
- * @brief Get the face index array.
- *
- * @return The face index array
- */
- const FaceIndices& GetFaces() const;
-
- /**
- * @brief Sets if the mesh has texture coordinates.
- *
- * @param hasTexCoords - True if the mesh has texture coordinates.
- */
- void SetHasTextureCoords(bool hasTexCoords);
-
- /**
- * @brief Checks if the mesh is textured.
- *
- * @return true if the mesh is texture mapped.
- */
- bool HasTextureCoords() const;
-
- /**
- * @brief Sets if the mesh has normals.
- *
- * Mutually exclusive with HasColor. Setting this to true will force the
- * HasColor property to be set to false.
- * @param hasNormals - True if the mesh has normals
- */
- void SetHasNormals(bool hasNormals);
-
- /**
- * @brief Checks if the mesh has normals.
- *
- * @return true if the mesh contains normals.
- */
- bool HasNormals() const;
-
- /**
- * @brief Sets if the mesh vertices have color.
- *
- * Mutually exclusive with HasNormals. Setting this to true will force the
- * HasNormals property to be set to false.
- * @param hasColor - True if the mesh vertices have color.
- */
- void SetHasColor(bool hasColor);
-
- /**
- * @brief Checks if the mesh vertices have color.
- *
- * @return true if the mesh contains colored vertices.
- */
- bool HasColor() const;
-
- /**
- * @brief Get the original material associated with this mesh.
- *
- * @return Handle to the material
- */
- Material GetMaterial() const;
-
- /**
- * @brief Set the default material associated with this mesh.
- */
- void SetMaterial( Material material );
-
- /**
- * @brief Get the number of bones affecting this mesh.
- *
- * @return The number of bones affecting this mesh
- */
- size_t GetBoneCount() const;
-
- /**
- * @brief Does this mesh have bones?.
- *
- * @return true if this mesh has bones.
- */
- bool HasBones() const;
-
- /**
- * @brief Get the bone container.
- *
- * @return the bones
- */
- const BoneContainer& GetBones() const;
-
- /**
- * @brief Get the lower bounds of the bounding box containing the vertices.
- *
- * @return the lower bounds
- */
- const Vector4& GetBoundingBoxMin() const;
-
- /**
- * @brief Set the lower bounds of the bounding box containing the vertices.
- *
- * @param bounds The lower bounds
- */
- void SetBoundingBoxMin(const Vector4& bounds);
-
- /**
- * @brief Get the upper bounds of the bounding box containing the vertices.
- *
- * @return the upper bounds
- */
- const Vector4& GetBoundingBoxMax() const;
-
- /**
- * @brief Set the upper bounds of the bounding box containing the vertices.
- *
- * @param bounds The upper bounds
- */
- void SetBoundingBoxMax(const Vector4& bounds);
-
- /**
- * @brief Destructor.
- */
- ~MeshData();
-
-private:
- VertexContainer mVertices; ///< The vertex data
- FaceIndices mFaces; ///< Indices of triangle faces or line terminators
- VertexGeometryType mGeometryType; ///< The type of geometry to draw
- bool mUseTextureCoords; ///< Whether the vertex data contains texture coords
- bool mUseNormals; ///< Whether the vertex data contains normals
- bool mUseColor; ///< Whether the vertex data contains vertex color
- BoneContainer mBones; ///< Bones for skeletal deformation
-
- Material mMaterial; ///< Material of the mesh
-
- Vector4 mMin; ///< The lower bounds of the bounding box
- Vector4 mMax; ///< The upper bounds of the bounding box
-
-}; // class MeshData
-
-/**
- * @brief A vertex within a mesh, with the corresponding texture coordinate, normal and up to 4 bone influences.
- */
-struct MeshData::Vertex
-{
- static const unsigned int MAX_BONE_INFLUENCE = 4; ///< Maximum number of bones that can influence this particular vertex.
-
- Vertex()
- : x(0.0f), y(0.0f), z(0.0f),
- u(0.0f), v(0.0f),
- nX(0.0f), nY(0.0f), nZ(0.0f)
- {
- }
-
- /**
- * @brief Constructor.
- *
- * @param[in] position The vertex position
- * @param[in] textureCoordinates The texture coordinates
- * @param[in] normal The surface normal
- */
- Vertex( const Vector3& position, const Vector2& textureCoordinates, const Vector3& normal )
- : x(position.x), y(position.y), z(position.z),
- u(textureCoordinates.x), v(textureCoordinates.y),
- nX(normal.x), nY(normal.y), nZ(normal.z)
- {
- }
-
- // Vertices
- float x;
- float y;
- float z;
-
- // Texture coordinates
- float u;
- float v;
-
- // Normals / vertex colours
- union
- {
- float nX;
- float vertexR;
- };
- union
- {
- float nY;
- float vertexG;
- };
- union
- {
- float nZ;
- float vertexB;
- };
-
- /**
- * @brief Bone indices specify which bones have an influence over the vertex (if any).
- */
- unsigned char boneIndices[MAX_BONE_INFLUENCE];
-
- /**
- * @brief Bone weights determine the strength of the influence of each bone.
- */
- float boneWeights[MAX_BONE_INFLUENCE];
-};
-
-} // namespace Dali
-
-#endif // __DALI_MESH_DATA_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "mesh-factory.h"
-
-#include <dali/public-api/geometry/mesh-data.h>
-#include <dali/public-api/modeling/material.h>
-
-namespace Dali
-{
-namespace MeshFactory
-{
-
-Dali::MeshData NewPlane(const float width, const float height, const int xSteps, const int ySteps, const Rect<float>& textureCoordinates)
-{
- DALI_ASSERT_DEBUG( xSteps > 1 && ySteps > 1 );
-
- const int vertexCount = xSteps * ySteps;
-
- // vertices
- MeshData::VertexContainer vertices(vertexCount);
- const float xSpacing = width / ( xSteps - 1 );
- const float ySpacing = height / (ySteps - 1 );
- const float xOffset = -xSpacing * (0.5f * xSteps) + (0.5f * xSpacing); // origin at (width / 2, height / 2)
- const float yOffset = -ySpacing * (0.5f * ySteps) + (0.5f * ySpacing);
- const float xSpacingUV = textureCoordinates.width / (xSteps - 1);
- const float ySpacingUV = textureCoordinates.height / (ySteps - 1);
- int vertexIndex = 0;
- for( int y = 0; y < ySteps; ++y )
- {
- for( int x = 0; x < xSteps; ++x )
- {
- MeshData::Vertex& vertex = vertices[vertexIndex];
- vertex.x = xOffset + (xSpacing * x);
- vertex.y = yOffset + (ySpacing * y);
- vertex.z = 0.0f;
-
- vertex.nX = 0.0f;
- vertex.nY = 0.0f;
- vertex.nZ = 1.0f;
-
- vertex.u = textureCoordinates.x + (xSpacingUV * x);
- vertex.v = textureCoordinates.y + (ySpacingUV * y);
- ++vertexIndex;
- }
- }
-
- // faces
- const int faceCount = 2 * ((ySteps - 1) * (xSteps - 1));
- MeshData::FaceIndices faces( faceCount * 3 );
- unsigned short* pIndex = &(faces)[0];
- unsigned short index0 = 0;
- unsigned short index1 = 0;
- unsigned short index2 = 0;
-
- for( int y = 0; y < ySteps - 1; ++y )
- {
- for( int x = 0; x < xSteps - 1; ++x )
- {
- index0 = (y * xSteps) + x;
- index1 = ((y + 1) * xSteps) + x;
- index2 = ((y + 1) * xSteps) + (x + 1);
- *pIndex++ = index0;
- *pIndex++ = index1;
- *pIndex++ = index2;
-
- index0 = ((y + 1) * xSteps) + (x + 1);
- index1 = (y * xSteps) + (x + 1);
- index2 = (y * xSteps) + x;
- *pIndex++ = index0;
- *pIndex++ = index1;
- *pIndex++ = index2;
- }
- }
-
- BoneContainer bones;
-
- Dali::MeshData meshData;
-
- meshData.SetHasNormals(true);
- meshData.SetHasTextureCoords(true);
- meshData.SetData( vertices, faces, bones, Dali::Material::New("PlaneMat"));
-
- Vector4 vMin;
- Vector4 vMax;
- meshData.AddToBoundingVolume(vMin, vMax, Matrix::IDENTITY);
-
- meshData.SetBoundingBoxMin(vMin);
- meshData.SetBoundingBoxMax(vMax);
-
- return meshData;
-}
-
-Dali::MeshData NewPath( Dali::Path path, const unsigned int resolution )
-{
- MeshData meshData;
- meshData.SetHasNormals(false);
- meshData.SetHasTextureCoords(false);
-
- if( resolution != 0 )
- {
- size_t vertexCount(resolution+1);
- MeshData::VertexContainer vertex(vertexCount);
-
- float sampleDelta = 1.0f/(float)resolution;
- Vector3 tangent;
- for( size_t i(0); i!=vertexCount; ++i )
- {
- //Sample path to get the vertex position
- Vector3* vertexPosition = reinterpret_cast<Vector3*>(&vertex[i].x);
- path.Sample( i*sampleDelta, *vertexPosition, tangent );
- }
-
- //Generate indices. Each vertex is connected to the next
- size_t indexCount(resolution*2);
- MeshData::FaceIndices index(indexCount);
- unsigned int nIndex = 0;
- for( size_t i(0); i!=indexCount; i+=2 )
- {
- index[i] = nIndex;
- index[i+1] = ++nIndex;
- }
-
- meshData.SetLineData(vertex, index, Dali::Material::New("PathMat"));
- }
-
- return meshData;
-}
-
-} // MeshFactory
-} // Dali
+++ /dev/null
-#ifndef __DALI_MESH_FACTORY_H__
-#define __DALI_MESH_FACTORY_H__
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/animation/path.h>
-
-namespace Dali
-{
-class MeshData;
-
-namespace MeshFactory
-{
-
-/**
- * @brief Create an initialized plane aligned on the XY axis.
- *
- * @param[in] width The width of the plane
- * @param[in] height The height of the plane
- * @param[in] xSteps The number of vertices along the X axis
- * @param[in] ySteps The number of vertices along the Y axis
- * @param[in] textureCoordinates UV coordinates.
- * @return A mesh data structure containing the plane mesh
- */
-DALI_IMPORT_API Dali::MeshData NewPlane( const float width,
- const float height,
- const int xSteps,
- const int ySteps,
- const Rect<float>& textureCoordinates = Rect<float>(0.0f, 0.0f, 1.0f, 1.0f) );
-
-/**
- * @brief Create a mesh from a given path.
- * The mesh generated will be a set of lines, each one connecting a point sampled from the path to the next sampled point.
- *
- * @param[in] path The path used to generate the mesh
- * @param[in] resolution The number of vertices to generate
- * @return A mesh data structure containing the path mesh
- */
-DALI_IMPORT_API Dali::MeshData NewPath( Dali::Path path, const unsigned int resolution );
-
-} // MeshFactory
-} // Dali
-
-#endif // __DALI_MESH_FACTORY_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/geometry/mesh.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/modeling/mesh-impl.h>
-#include <dali/internal/event/modeling/material-impl.h>
-#include <dali/public-api/geometry/mesh-factory.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/math/vector3.h>
-
-namespace Dali
-{
-
-namespace
-{
-
-} // namespace
-
-Mesh::Mesh()
-{
-}
-
-Mesh::~Mesh()
-{
-}
-
-Mesh::Mesh(const Mesh& handle)
-: BaseHandle(handle)
-{
-}
-
-Mesh& Mesh::operator=(const Mesh& rhs)
-{
- BaseHandle::operator=(rhs);
- return *this;
-}
-
-Mesh Mesh::New( const MeshData& meshData )
-{
- // Convert material handle to intrusive pointer
- Dali::Material material( meshData.GetMaterial() );
- Internal::MaterialIPtr materialPtr( &GetImplementation( material ) );
-
- Internal::MeshIPtr meshPtr = Internal::Mesh::New( meshData, true /* discardable */, false /* scaling not required */ );
- return Mesh( meshPtr.Get() );
-}
-
-Mesh Mesh::NewPlane(const float width, const float height, const int xSteps, const int ySteps, const Rect<float>& textureCoordinates)
-{
- MeshData meshData( MeshFactory::NewPlane(width, height, xSteps, ySteps, textureCoordinates) );
- return New(meshData);
-}
-
-Mesh Mesh::DownCast( BaseHandle handle )
-{
- return Mesh( dynamic_cast<Dali::Internal::Mesh*>(handle.GetObjectPtr()) );
-}
-
-void Mesh::UpdateMeshData( const MeshData& meshData )
-{
- GetImplementation(*this).UpdateMeshData( meshData );
-}
-
-Mesh::Mesh(Internal::Mesh* internal)
-: BaseHandle(internal)
-{
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_MESH_H__
-#define __DALI_MESH_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-// INTERNAL INCLUDES
-#include <dali/public-api/geometry/mesh-data.h>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/object/base-handle.h>
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class Mesh;
-}
-
-/**
- * @brief A Mesh holds a MeshData object supplied by the application writer.
- *
- * It is used to tell the Scene Graph if the mesh data has changed.
- */
-class DALI_IMPORT_API Mesh : public BaseHandle
-{
-public:
-
- /**
- * @brief Create an initialized Mesh.
- *
- * @param[in] meshData The mesh data with which to initialize the handle
- * @return A handle to a newly allocated Dali resource.
- */
- static Mesh New( const MeshData& meshData );
-
- /**
- * @brief Create an uninitialized Mesh; this can be initialized with Mesh::New().
- *
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- Mesh();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Mesh();
-
- /**
- * @brief This copy constructor is required for (smart) pointer semantics.
- *
- * @param [in] handle A reference to the copied handle
- */
- Mesh(const Mesh& handle);
-
- /**
- * @brief This assignment operator is required for (smart) pointer semantics.
- *
- * @param [in] rhs A reference to the copied handle
- * @return A reference to this
- */
- Mesh& operator=(const Mesh& rhs);
-
- /**
- * @brief Create an initialized plane aligned on the XY axis.
- *
- * @param[in] width The width of the plane
- * @param[in] height The height of the plane
- * @param[in] xSteps The number of vertices along the X axis
- * @param[in] ySteps The number of vertices along the Y axis
- * @param[in] textureCoordinates UV coordinates.
- * @return A handle to a newly allocated Dali resource.
- */
- static Mesh NewPlane(const float width,
- const float height,
- const int xSteps,
- const int ySteps,
- const Rect<float>& textureCoordinates = Rect<float>(0.0f, 0.0f, 1.0f, 1.0f));
-
- /**
- * @brief Downcast an Object handle to Mesh handle.
- *
- * If handle points to a Mesh object the downcast produces valid
- * handle. If not the returned handle is left uninitialized.
- *
- * @param[in] handle to An object
- * @return handle to an Mesh object or an uninitialized handle
- */
- static Mesh DownCast( BaseHandle handle );
-
- /**
- * @brief Tell Dali to update it's internal meshes from the changed mesh data.
- *
- * @param[in] meshData
- */
- void UpdateMeshData( const MeshData& meshData );
-
-public: // Not intended for application developers
-
- /**
- * @brief This constructor is used by Dali New() methods.
- *
- * @param [in] mesh A pointer to a newly allocated Dali resource
- */
- explicit DALI_INTERNAL Mesh(Internal::Mesh* mesh);
-};
-
-} // namespace Dali
-
-#endif // __DALI_MESH_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/modeling/bone.h>
-
-namespace Dali
-{
-
-Bone::Bone ()
-{
-}
-
-Bone::Bone( const std::string& name, const Matrix& offsetMatrix )
-: mName( name ),
- mOffsetMatrix( offsetMatrix )
-{
-}
-
-Bone::~Bone()
-{
-}
-
-Bone::Bone( const Bone& rhs )
-: mName(rhs.mName),
- mOffsetMatrix(rhs.mOffsetMatrix)
-{
-}
-
-Bone& Bone::operator=(const Bone& rhs)
-{
- if (this != &rhs)
- {
- mName = rhs.mName;
- mOffsetMatrix = rhs.mOffsetMatrix;
- }
- return *this;
-}
-
-const std::string& Bone::GetName() const
-{
- return mName;
-}
-
-const Matrix& Bone::GetOffsetMatrix() const
-{
- return mOffsetMatrix;
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_BONE_H__
-#define __DALI_BONE_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/math/matrix.h>
-
-namespace Dali
-{
-
-class Matrix;
-
-class Bone;
-typedef std::vector< Bone > BoneContainer; ///< Container for bones
-typedef BoneContainer::iterator BoneIter; ///< @ref Dali::BoneContainer iterator
-typedef BoneContainer::const_iterator BoneConstIter; ///< @ref Dali::BoneContainer const iterator
-
-/**
- * @brief A single bone in a mesh.
- *
- * A Bone is a named actor that can be used to deform a mesh. @see Dali::MeshData for more
- * information.
- */
-class DALI_IMPORT_API Bone
-{
-public:
- /**
- * @brief Default constructor.
- */
- Bone ();
-
- /**
- * @brief Constructor.
- *
- * @param name of the bone
- * @param offsetMatrix for the bone
- */
- Bone( const std::string& name, const Matrix& offsetMatrix );
-
- /**
- * @brief Destructor.
- */
- ~Bone();
-
- /**
- * @brief Copy constructor.
- */
- Bone( const Bone& rhs );
-
- /**
- * @brief Assignment operator.
- */
- Bone& operator=(const Bone& rhs);
-
- /**
- * @brief Get name.
- *
- * @return returns the name of the bone
- */
- const std::string& GetName() const;
-
- /**
- * @brief Get offset matrix.
- *
- * @return returns the offset matrix for this bone
- */
- const Matrix& GetOffsetMatrix() const;
-
-private:
- // Attributes
- std::string mName; ///< Name of bone
- Matrix mOffsetMatrix; ///< Transform from mesh space to bone space in bind pose.
-
-}; // struct Bone
-
-} // namespace Dali
-
-#endif // __DALI_BONE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/modeling/material.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/modeling/material-impl.h>
-
-namespace Dali
-{
-
-const float Material::DEFAULT_OPACITY = 1.0f;
-const float Material::DEFAULT_SHININESS = 0.5f;
-const Vector4 Material::DEFAULT_AMBIENT_COLOR(0.2f, 0.2f, 0.2f, 1.0f);
-const Vector4 Material::DEFAULT_DIFFUSE_COLOR (0.8f, 0.8f, 0.8f, 1.0f);
-const Vector4 Material::DEFAULT_SPECULAR_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
-const Vector4 Material::DEFAULT_EMISSIVE_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
-const Material::MappingMode Material::DEFAULT_MAPPING_MODE = Material::MAPPING_MODE_WRAP;
-const size_t Material::DEFAULT_DIFFUSE_UV_INDEX = 0;
-const size_t Material::DEFAULT_OPACITY_UV_INDEX = 0;
-const size_t Material::DEFAULT_NORMAL_UV_INDEX = 0;
-const bool Material::DEFAULT_HAS_HEIGHT_MAP = false;
-
-
-Material Material::New(const std::string& name)
-{
- Internal::Material* internal = Internal::Material::New(name);
-
- return Material(internal);
-}
-
-Material Material::DownCast( BaseHandle handle )
-{
- return Material( dynamic_cast<Dali::Internal::Material*>(handle.GetObjectPtr()) );
-}
-
-Material::Material(Internal::Material* internal)
-: BaseHandle(internal)
-{
-}
-
-Material::Material()
-{
-}
-
-Material::~Material()
-{
-}
-
-Material::Material(const Material& handle)
-: BaseHandle(handle)
-{
-}
-
-Material& Material::operator=(const Material& rhs)
-{
- BaseHandle::operator=(rhs);
- return *this;
-}
-
-void Material::SetName(const std::string& name)
-{
- GetImplementation(*this).SetName(name);
-}
-
-const std::string& Material::GetName() const
-{
- return GetImplementation(*this).GetName();
-}
-
-void Material::SetOpacity(const float opacity)
-{
- GetImplementation(*this).SetOpacity(opacity);
-}
-
-float Material::GetOpacity() const
-{
- return GetImplementation(*this).GetOpacity();
-}
-
-void Material::SetShininess(const float shininess)
-{
- GetImplementation(*this).SetShininess(shininess);
-}
-
-float Material::GetShininess() const
-{
- return GetImplementation(*this).GetShininess();
-}
-
-void Material::SetAmbientColor(const Vector4& color)
-{
- GetImplementation(*this).SetAmbientColor(color);
-}
-
-const Vector4& Material::GetAmbientColor() const
-{
- return GetImplementation(*this).GetAmbientColor();
-}
-
-void Material::SetDiffuseColor(const Vector4& color)
-{
- GetImplementation(*this).SetDiffuseColor(color);
-}
-
-const Vector4& Material::GetDiffuseColor() const
-{
- return GetImplementation(*this).GetDiffuseColor();
-}
-
-void Material::SetSpecularColor(const Vector4& color)
-{
- GetImplementation(*this).SetSpecularColor(color);
-}
-
-const Vector4& Material::GetSpecularColor() const
-{
- return GetImplementation(*this).GetSpecularColor();
-}
-
-void Material::SetEmissiveColor(const Vector4& color)
-{
- GetImplementation(*this).SetEmissiveColor(color);
-}
-
-const Vector4& Material::GetEmissiveColor() const
-{
- return GetImplementation(*this).GetEmissiveColor();
-}
-
-void Material::SetDiffuseTexture(Image image)
-{
- GetImplementation(*this).SetDiffuseTexture(image);
-}
-
-Image Material::GetDiffuseTexture() const
-{
- return GetImplementation(*this).GetDiffuseTexture();
-}
-
-void Material::SetOpacityTexture(Image image)
-{
- GetImplementation(*this).SetOpacityTexture(image);
-}
-
-Image Material::GetOpacityTexture() const
-{
- return GetImplementation(*this).GetOpacityTexture();
-}
-
-void Material::SetNormalMap(Image image)
-{
- GetImplementation(*this).SetNormalMap(image);
-}
-
-Image Material::GetNormalMap() const
-{
- return GetImplementation(*this).GetNormalMap();
-}
-
-void Material::SetMapU(const unsigned int map)
-{
- GetImplementation(*this).SetMapU(map);
-}
-
-unsigned int Material::GetMapU() const
-{
- return GetImplementation(*this).GetMapU();
-}
-
-void Material::SetMapV(const unsigned int map)
-{
- GetImplementation(*this).SetMapV(map);
-}
-
-unsigned int Material::GetMapV() const
-{
- return GetImplementation(*this).GetMapV();
-}
-
-void Material::SetDiffuseUVIndex(const int index)
-{
- GetImplementation(*this).SetDiffuseUVIndex(index);
-}
-
-unsigned int Material::GetDiffuseUVIndex() const
-{
- return GetImplementation(*this).GetDiffuseUVIndex();
-}
-
-void Material::SetOpacityUVIndex(const int index)
-{
- GetImplementation(*this).SetOpacityUVIndex(index);
-}
-
-unsigned int Material::GetOpacityUVIndex() const
-{
- return GetImplementation(*this).GetOpacityUVIndex();
-}
-
-void Material::SetNormalUVIndex(const int index)
-{
- GetImplementation(*this).SetNormalUVIndex(index);
-}
-
-unsigned int Material::GetNormalUVIndex() const
-{
- return GetImplementation(*this).GetNormalUVIndex();
-}
-
-void Material::SetHasHeightMap(const bool flag)
-{
- GetImplementation(*this).SetHasHeightMap(flag);
-}
-
-bool Material::GetHasHeightMap() const
-{
- return GetImplementation(*this).GetHasHeightMap();
-}
-
-
-void Material::SetDiffuseTextureFileName(const std::string filename)
-{
- GetImplementation(*this).SetDiffuseTextureFileName(filename);
-}
-const std::string& Material::GetDiffuseFileName() const
-{
- return GetImplementation(*this).GetDiffuseTextureFileName();
-}
-void Material::SetOpacityTextureFileName(const std::string filename)
-{
- GetImplementation(*this).SetOpacityTextureFileName(filename);
-}
-const std::string& Material::GetOpacityTextureFileName() const
-{
- return GetImplementation(*this).GetOpacityTextureFileName();
-}
-void Material::SetNormalMapFileName(const std::string filename)
-{
- GetImplementation(*this).SetNormalMapFileName(filename);
-}
-const std::string& Material::GetNormalMapFileName() const
-{
- return GetImplementation(*this).GetNormalMapFileName();
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_MATERIAL_H__
-#define __DALI_MATERIAL_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/images/image.h>
-#include <dali/public-api/common/constants.h>
-
-namespace Dali
-{
-
-struct Vector4;
-
-namespace Internal DALI_INTERNAL
-{
-class Material;
-}
-
-
-class Material;
-typedef std::vector<Material> MaterialContainer; ///< Container for Dali::Material
-typedef MaterialContainer::iterator MaterialIter; ///< Iterator for Dali::MaterialContainer
-typedef MaterialContainer::const_iterator MaterialConstIter; ///< Const iterator for Dali::MaterialContainer
-
-/**
- * @brief Encapsulates the data describing a material.
- *
- * Color, opacity, shininess, shading mode, texture/normal/height mapping...
- */
-class DALI_IMPORT_API Material : public BaseHandle
-{
-public:
- /**
- * @brief How the material's texture is sampled outside the range 0..1
- */
- enum MappingMode
- {
- MAPPING_MODE_WRAP = 0x0, ///< A texture coordinate u|v is translated to u%1|v%1
- MAPPING_MODE_CLAMP = 0x1, ///< Texture coordinates outside [0...1] are clamped to the nearest valid value
- MAPPING_MODE_MIRROR = 0x2, ///< A texture coordinate u|v becomes u%1|v%1 if (u-(u%1))%2 is zero and 1-(u%1)|1-(v%1) otherwise
- MAPPING_MODE_DECAL = 0x3, ///< If the texture coordinates for a pixel are outside [0...1] the texture is not applied to that pixel
- };
-
- static const float DEFAULT_OPACITY; ///< 1.0f
- static const float DEFAULT_SHININESS; ///< 0.5f
- static const Vector4 DEFAULT_AMBIENT_COLOR; ///< (0.2f, 0.2f, 0.2f, 1.0f)
- static const Vector4 DEFAULT_DIFFUSE_COLOR; ///< (0.8f, 0.8f, 0.8f, 1.0f)
- static const Vector4 DEFAULT_SPECULAR_COLOR; ///< (0.0f, 0.0f, 0.0f, 1.0f)
- static const Vector4 DEFAULT_EMISSIVE_COLOR; ///< (0.0f, 0.0f, 0.0f, 1.0f)
- static const MappingMode DEFAULT_MAPPING_MODE; ///< Material::MAPPING_MODE_WRAP
- static const size_t DEFAULT_DIFFUSE_UV_INDEX; ///< 0
- static const size_t DEFAULT_OPACITY_UV_INDEX; ///< 0
- static const size_t DEFAULT_NORMAL_UV_INDEX; ///< 0
- static const bool DEFAULT_HAS_HEIGHT_MAP; ///< false
-
- /**
- * @brief Create an initialized Material.
- *
- * @param[in] name The material's name
- * @return A handle to a newly allocated Dali resource.
- */
- static Material New(const std::string& name);
-
- /**
- * @brief Downcast an Object handle to Material handle.
- *
- * If handle points to a Material object the
- * downcast produces valid handle. If not the returned handle is left uninitialized.
- * @param[in] handle to An object
- * @return handle to a Material object or an uninitialized handle
- */
- static Material DownCast( BaseHandle handle );
-
- /**
- * @brief Create an uninitialized material; this can be initialized with Material::New().
- *
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- Material();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Material();
-
- /**
- * @brief This copy constructor is required for (smart) pointer semantics.
- *
- * @param [in] handle A reference to the copied handle
- */
- Material(const Material& handle);
-
- /**
- * @brief This assignment operator is required for (smart) pointer semantics.
- *
- * @param [in] rhs A reference to the copied handle
- * @return A reference to this
- */
- Material& operator=(const Material& rhs);
-
- /**
- * @brief Set the material's name.
- *
- * @param[in] name The material's name
- */
- void SetName(const std::string& name);
-
- /**
- * @brief Get the material's name.
- */
- const std::string& GetName() const;
-
- /**
- * @brief Set the material's opacity.
- *
- * @param[in] opacity The new opacity value
- */
- void SetOpacity(const float opacity);
-
- /**
- * @brief Get the material's opacity.
- *
- * @return The opacity.
- */
- float GetOpacity() const;
-
- /**
- * @brief Set the material's shininess (used for specular highlighting).
- *
- * @param[in] shininess The new shininess value
- */
- void SetShininess(const float shininess);
-
- /**
- * @brief Get the material's shininess.
- *
- * @return The shininess.
- */
- float GetShininess() const;
-
- /**
- * @brief Set the material's ambient color.
- *
- * @param[in] color The new color value
- */
- void SetAmbientColor(const Vector4& color);
-
- /**
- * @brief Get the material's ambient color.
- *
- * @return The color value
- */
- const Vector4& GetAmbientColor() const;
-
- /**
- * @brief Set the material's diffuse color.
- *
- * @param[in] color The new color value
- */
- void SetDiffuseColor(const Vector4& color);
-
- /**
- * @brief Get the material's diffuse color.
- *
- * @return The color value
- */
- const Vector4& GetDiffuseColor() const;
-
- /**
- * @brief Set the material's specular color.
- *
- * @param[in] color The new color value
- */
- void SetSpecularColor(const Vector4& color);
-
- /**
- * @brief Get the material's specular color.
- *
- * @return The color value
- */
- const Vector4& GetSpecularColor() const;
-
- /**
- * @brief Set the material's emissive color.
- *
- * @param[in] color The new color value
- */
- void SetEmissiveColor(const Vector4& color);
-
- /**
- * @brief Get the material's emissive color.
- *
- * @return The color value
- */
- const Vector4& GetEmissiveColor() const;
-
- /**
- * @brief Set the diffuse texture image.
- *
- * @param[in] image The new texture image
- */
- void SetDiffuseTexture(Image image);
-
- /**
- * @brief Set the diffuse texture image.
- *
- * @param[in] filename The name of the image file
- */
- void SetDiffuseTextureFileName(const std::string filename);
-
- /**
- * @brief Get the diffuse texture image.
- *
- * @return The texture image
- */
- Image GetDiffuseTexture() const;
-
- /**
- * @brief Get the diffuse texture image filename.
- *
- * @return the filename
- */
- const std::string& GetDiffuseFileName() const;
-
- /**
- * @brief Set the opacity texture image.
- *
- * @param[in] image The new texture image
- */
- void SetOpacityTexture(Image image);
-
- /**
- * @brief Set the opacity texture image.
- *
- * @param[in] filename The opacity texture image filename
- */
- void SetOpacityTextureFileName(const std::string filename);
-
- /**
- * @brief Get the opacity texture image.
- *
- * @return The texture image
- */
- Image GetOpacityTexture() const;
-
- /**
- * @brief Get the opacity texture image filename.
- *
- * @return The texture image's filename
- */
- const std::string& GetOpacityTextureFileName() const;
-
-
- /**
- * @brief Set the normal/height map texture image.
- *
- * @param[in] image The new texture image
- */
- void SetNormalMap(Image image);
-
- /**
- * @brief Set the normal/height map texture image filename.
- *
- * @param[in] filename The new texture image filename
- */
- void SetNormalMapFileName(const std::string filename);
-
- /**
- * @brief Get the normal/height map texture image.
- *
- * @return The texture image
- */
- Image GetNormalMap() const;
-
- /**
- * @brief Get the normal/height map texture image filename.
- *
- * @return The texture image filename
- */
- const std::string& GetNormalMapFileName() const;
-
- /**
- * @brief Set the U mapping mode.
- *
- * @param[in] map The mapping mode
- */
- void SetMapU(const unsigned int map);
-
- /**
- * @brief Get the U mapping mode.
- *
- * @return The mapping mode
- */
- unsigned int GetMapU() const;
-
- /**
- * @brief Set the V mapping mode.
- *
- * @param[in] map The mapping mode
- */
- void SetMapV(const unsigned int map);
-
- /**
- * @brief Get the U mapping mode.
- *
- * @return The mapping mode
- */
- unsigned int GetMapV() const;
-
- /**
- * @brief Set the index into the bound mesh's array of UV's for the diffuse texture coordinates.
- *
- * @param[in] index The diffuse uv index
- */
- void SetDiffuseUVIndex(const int index);
-
- /**
- * @brief Get the index into the bound mesh's array of UV's for the diffuse texture coordinates.
- *
- * @return The uv index
- */
- unsigned int GetDiffuseUVIndex() const;
-
- /**
- * @brief Set the index into the bound mesh's array of UV's for the opacity texture coordinates.
- *
- * @param[in] index The opacity uv index
- */
- void SetOpacityUVIndex(const int index);
-
- /**
- * @brief Get the index into the bound mesh's array of UV's for the opacity texture coordinates.
- *
- * @return The uv index
- */
- unsigned int GetOpacityUVIndex() const;
-
- /**
- * @brief Set the index into the bound mesh's array of UV's for the normal/height map texture coordinates.
- *
- * @param[in] index The normal/height map uv index
- */
- void SetNormalUVIndex(const int index);
-
- /**
- * @brief Get the index into the bound mesh's array of UV's for the normal/height map texture coordinates.
- *
- * @return The uv index
- */
- unsigned int GetNormalUVIndex() const;
-
- /**
- * @brief Set whether the normal texture contains a normal or height map.
- *
- * @param[in] flag true if the normal map contains a height map
- */
- void SetHasHeightMap(const bool flag);
-
- /**
- * @brief Get whether the normal texture contains a normal or height map.
- *
- * @return true if the normal map contains a height map, false otherwise
- */
- bool GetHasHeightMap() const;
-
-public: // Not intended for application developers
-
- /**
- * @brief This constructor is used by Dali New() methods.
- *
- * @param [in] material A pointer to an internal material resource
- */
- explicit DALI_INTERNAL Material(Internal::Material* material);
-}; // class Material
-
-} // namespace Dali
-
-#endif // __DALI_MATERIAL_H__