+//
+// Open Service Platform
+// Copyright (c) 2013 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.
+//
+
+
+/**
+ * @file FUiAnimMesh.h
+ * @brief This is the header file for the Mesh class.
+ *
+ * This header file contains the declarations of the Mesh class.
+ */
+
#ifndef _FUI_ANIM_MESH_H_
#define _FUI_ANIM_MESH_H_
class _OSP_EXPORT_ Mesh : public Tizen::Base::Object
{
public:
- Mesh(void);
- Mesh(const Mesh& mesh); // not deep copy
-
- virtual ~Mesh(void);
-public:
+ /**
+ * @enum GeometryType
+ * Defines the Geometric Primitive Types for Mesh.
+ * The contents of Mesh will be rendered using this operation.
+ */
enum GeometryType
{
- GEO_TYPE_NONE,
- GEO_TYPE_POINTS,
- GEO_TYPE_LINES,
- GEO_TYPE_LINE_STRIP,
- GEO_TYPE_TRIANGLES,
- GEO_TYPE_TRIANGLE_STRIP
+ GEO_TYPE_NONE = 0, /* Non specified Geometry Type */
+ GEO_TYPE_POINTS, /* Every Vertex specified is a Point */
+ GEO_TYPE_LINES, /* Every two Vertices specified forms a Line */
+ GEO_TYPE_LINE_STRIP, /* Every Vertex specified after first two forms a Line */
+ GEO_TYPE_TRIANGLES, /* Every three Vertices specified compose a Triangle */
+ GEO_TYPE_TRIANGLE_STRIP /* Every three Vertices specified after first three vertices composes a Triangle */
};
/**
+ * This is the default constructor for this class.
+ *
+ * @since 3.0
+ */
+ Mesh(void);
+
+ /**
+ * This is copy constructor for the Mesh class.
+ *
+ * @since 3.0
+ *
+ * @param[in] rhs An instance of Mesh
+ * @remarks Not deep copy
+ */
+ Mesh(const Mesh& mesh);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 3.0
+ */
+ virtual ~Mesh(void);
+
+ /**
* Replaces the vertex at the specified @c index with the specified value.
*
* @since 3.0
*
* @return An error code
- * @param[in] pMesh The pointer to Mesh @n
- * @exception E_SUCCESS The method is successful.
- ** @exception E_OUT_OF_RANGE
- * @see GetVertex()
+ * @param[in] arrayIndex The index in the vertices array
+ * @param[in] point The specified value
+ * @exception E_SUCCESS The method is successful
+ * @exception E_INVALID_STATE Vertices haven't been allocated yet
+ * @exception E_OUT_OF_RANGE Invalid position of the vertices array. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated vertices;
+ * - The arrayIndex is minus value.
+ * @remarks Can only increase bounding volume size, call AdjustBoundingVolume() to readjust.
+ * @see GetVertex(), AdjustBoundingVolume()
*/
result SetVertex(int arrayIndex, const Tizen::Graphics::FloatPoint3& point);
*
* @since 3.0
*
- * @return A FloatPoint3
- * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @return Vertex position
+ * @param[in] arrayIndex The index in the vertices array
+ * @exception E_INVALID_STATE Vertices haven't been allocated yet
+ * @exception E_INVALID_ARG Invalid position of the vertices array. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated vertices;
+ * - The arrayIndex is minus value.
* @see SetVertex()
*/
Tizen::Graphics::FloatPoint3 GetVertex(int arrayIndex) const;
/**
- * Gets the count of vertex used
+ * Gets the current count of the vertices
*
* @since 3.0
*
- * @return A vertex count int
- * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @return Vertex count
* @see SetVertex()
* @see GetVertex()
*/
int GetVertexCount(void) const;
-
/**
* Replaces the texture coordinate at the specified @c index with the specified value.
*
* @since 3.0
*
* @return An error code
- * @param[in] pMesh The pointer to Mesh @n
- * @exception E_SUCCESS The method is successful.
- * @exception E_OUT_OF_RANGE
+ * @param[in] arrayIndex The index in the texture coordinates array
+ * @param[in] textureCoord The specified value
+ * @exception E_SUCCESS The method is successful
+ * @exception E_OUT_OF_MEMORY Insufficient memory for allocating texture coordinates
+ * @exception E_INVALID_STATE Texture coordinates haven't been allocated
+ * @exception E_OUT_OF_RANGE Invalid position of the texture coordinates array. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated vertices;
+ * - The arrayIndex is minus value.
* @see GetTextureCoord()
*/
result SetTextureCoord(int arrayIndex, const Tizen::Graphics::FloatPoint& textureCoord);
-
/**
* Gets the texture coordinate at the specified @c arrayIndex of the texture coordinates array.
*
* @since 3.0
*
- * @return A FloatPoint
- * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @return Texture coordinate
+ * @param[in] arrayIndex The index in the texture coordinates array
+ * @exception E_INVALID_STATE Texture coordinates haven't been allocated
+ * @exception E_INVALID_ARG Invalid position of the texture coordinates array. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated vertices;
+ * - The arrayIndex is minus value.
* @see SetTextureCoord()
*/
Tizen::Graphics::FloatPoint GetTextureCoord(int arrayIndex) const;
-
/**
* Replaces the normal vector at the specified @c index with the specified value.
*
* @since 3.0
*
* @return An error code
- * @param[in] pMesh The pointer to Mesh @n
- * @exception E_SUCCESS The method is successful.
- * @exception E_OUT_OF_RANGE
+ * @param[in] arrayIndex The index in the normals array
+ * @param[in] normal The specified value
+ * @exception E_SUCCESS The method is successful
+ * @exception E_OUT_OF_MEMORY Insufficient memory for allocating normals
+ * @exception E_OUT_OF_RANGE Invalid position of the normals array. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated vertices;
+ * - The arrayIndex is minus value.
* @see GetNormal()
*/
result SetNormal(int arrayIndex, const Tizen::Graphics::FloatPoint3& normal);
-
/**
* Gets the normal vector at the specified @c arrayIndex of the normal vectors array.
*
* @since 3.0
*
- * @return A FloatPoint3
- * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @return Normal vector
+ * @param[in] arrayIndex The index in the normals array
+ * @exception E_INVALID_STATE Normals haven't been allocated
+ * @exception E_INVALID_ARG Invalid position of the normals array. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated vertices;
+ * - The arrayIndex is minus value.
* @see SetTextureCoord()
*/
Tizen::Graphics::FloatPoint3 GetNormal(int arrayIndex) const;
-
/**
* Replaces the color at the specified @c index with the specified value.
*
* @since 3.0
*
* @return An error code
- * @param[in] pMesh The pointer to Mesh @n
- * @exception E_SUCCESS The method is successful.
- * @exception E_OUT_OF_RANGE
+ * @param[in] arrayIndex The index in the colors array
+ * @param[in] color The specified value
+ * @exception E_SUCCESS The method is successful
+ * @exception E_OUT_OF_MEMORY Insufficient memory for allocating colors
+ * @exception E_OUT_OF_RANGE Invalid position of the colors. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated vertices;
+ * - The arrayIndex is minus value.
* @see GetColor()
*/
result SetColor(int arrayIndex, const Tizen::Graphics::Color& color);
-
/**
* Gets the color at the specified @c arrayIndex of the colors array.
*
* @since 3.0
*
* @return A Color
- * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @param[in] arrayIndex The index in the colors array
+ * @exception E_INVALID_STATE Colors haven't been allocated
+ * @exception E_INVALID_ARG Invalid position of the colors array. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated vertices;
+ * - The arrayIndex is minus value.
* @see SetColor()
*/
Tizen::Graphics::Color GetColor(int arrayIndex) const;
-
/**
* Replaces the vertexIndex at the specified @c index with the specified value.
*
* @since 3.0
*
* @return An error code
- * @param[in] pMesh The pointer to Mesh @n
- * @exception E_SUCCESS The method is successful.
- * @exception E_OUT_OF_RANGE
+ * @param[in] arrayIndex The index in the vertexIndex array
+ * @param[in] vertexIndex The specified value
+ * @exception E_SUCCESS The method is successful
+ * @exception E_INVALID_STATE Indices haven't been allocated
+ * @exception E_OUT_OF_RANGE Invalid position of the indices. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated vertices;
+ * - The arrayIndex is minus value.
* @see GetIndex()
*/
result SetIndex(int arrayIndex, int vertexIndex);
-
/**
* Gets the index at the specified @c arrayIndex of the indices array.
*
* @since 3.0
*
- * @return A int
- * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @return An index
+ * @param[in] arrayIndex The index in the vertexIndex array
+ * @exception E_INVALID_STATE Indices haven't been allocated
+ * @exception E_INVALID_ARG Invalid position of the indices array. Either of the following conditions has occurred:
+ * - The arrayIndex is bigger then count of allocated indices;
+ * - The arrayIndex is minus value.
* @see SetIndex()
*/
int GetIndex(int arrayIndex) const;
*
* @since 3.0
*
- * @return A index count int
+ * @return An index count
* @remarks The specific error code can be accessed using the GetLastResult() method.
* @see SetIndex()
* @see GetIndex()
*/
int GetIndexCount(void) const;
-
/**
* Set the geometry type with the specified value.
*
* @since 3.0
*
* @return An error code
- * @param[in] type The GeometryType value @n
+ * @param[in] type The GeometryType value
* @exception E_SUCCESS The method is successful.
* @see GetGeometryType()
*/
result SetGeometryType(GeometryType type);
-
/**
* Gets the geometry type.
*
* @since 3.0
*
- * @return A int
+ * @return Geometry type
* @remarks The specific error code can be accessed using the GetLastResult() method.
- * @see SetIndex()
*/
GeometryType GetGeometryType(void) const;
-
/**
* Calculate bounding box of this mesh instance.
*
* @since 3.0
*
* @return An error code
- * @param[in] rebuild rebuild flag @n
* @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_STATE Vertices haven't been allocated
+ * @remarks If an exception occurs, this method returns E_INVALID_ARG. Calling Reset() method for bounding Volume and set hasBoundingVolume to false.
+ * @remarks Additional exceptions can occur according to the behavior of subclasses.
+ * @remarks Readjusts bounding volume size according to current vertices.
* @see BoundingVolume
*
*/
- result AdjustBoundingVolume(bool rebuild = false);
-
+ result AdjustBoundingVolume(void);
/**
* Clear all instance data.
* @exception E_SUCCESS The method is successful.
* @see BoundingVolume
*/
- BoundingVolume& GetBoundingVolume(void);
+ const BoundingVolume& GetBoundingVolume(void) const;
-// Tizen::Graphics::FloatPoint3 GetBoundingBoxPosition(void) const;
-// float GetBoundingBoxLength(void) const;
-// float GetBoundingBoxWidth(void) const;
-// float GetBoundingBoxHeight(void) const;
-
- // 임시 함수
+ /**
+ * Allocating vertices of the mesh.
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @param[in] count Quantity of allocated vertices
+ * @exception E_SUCCESS The method is successful
+ * @exception E_ALREADY_SET Vertices have already been allocated
+ * @exception E_INVALID_ARG Incorrect count for allocating vertices. Either of the following conditions has occurred:
+ * - The count is zero;
+ * - The count is minus value.
+ * @exception E_OUT_OF_MEMORY Insufficient memory for allocating vertices
+ */
result ReserveVertices(int count);
+
+ /**
+ * Allocating indices of the mesh.
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @param[in] count Quantity of allocated indices
+ * @exception E_SUCCESS The method is successful
+ * @exception E_ALREADY_SET Indices have already been allocated
+ * @exception E_INVALID_ARG Incorrect count for allocating indices. Either of the following conditions has occurred:
+ * - The count is zero;
+ * - The count is minus value.
+ * @exception E_OUT_OF_MEMORY Insufficient memory for allocating indices
+ */
result ReserveIndices(int count);
- result ReserveTextureCoordinates(void);
- result ReserveNormals(void);
- result ReserveColors(void);
- result SaveMeshToBin(const Tizen::Base::String& fileName);
+ /**
+ * Allocating texture coordinates of the mesh.
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful
+ * @exception E_ALREADY_SET Texture coordinates have already been allocated
+ * @exception E_INVALID_STATE Incorrect count of allocated vertex. Either of the following conditions has occurred:
+ * - The count of allocated vertices is zero;
+ * - The count of allocated vertices is minus value.
+ * @exception E_OUT_OF_MEMORY Insufficient memory for allocating texture coordinates
+ * @remarks This method depends from count of allocated vertices
+ */
+ result ReserveTextureCoordinates(void);
+
+ /**
+ * Allocating normals of the mesh.
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful
+ * @exception E_ALREADY_SET Normals have already been allocated
+ * @exception E_INVALID_STATE Incorrect count of allocated vertex. Either of the following conditions has occurred:
+ * - The count of allocated vertices is zero;
+ * - The count of allocated vertices is minus value.
+ * @exception E_OUT_OF_MEMORY Insufficient memory for allocating normals
+ * @remarks This method depends from count of allocated vertices
+ */
+ result ReserveNormals(void);
+
+ /**
+ * Allocating colors of the mesh.
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_ALREADY_SET Colors have already been allocated
+ * @exception E_INVALID_STATE Incorrect count of allocated vertex. Either of the following conditions has occurred:
+ * - The count of allocated vertices is zero;
+ * - The count of allocated vertices is minus value.
+ * @exception E_OUT_OF_MEMORY Insufficient memory for allocating colors
+ * @remarks This method depends from count of allocated vertices
+ */
+ result ReserveColors(void);
+
+ /**
+ * Saving mesh to binary file.
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @param[in] fileName Saving Mesh's name
+ * @exception E_SUCCESS The method is successful
+ * @exception E_OPERATION_FAILED File for saving didn't open
+ * @exception E_INVALID_DATA Mesh without vertices
+ */
+ result SaveMeshToBinary(const Tizen::Base::String& fileName);
+
+ /**
+ * Checking for indexing enabling
+ *
+ * @since 3.0
+ *
+ * @return True if indexing is enabled
+ * @see ReserveIndices()
+ */
bool IsIndexEnabled(void) const;
+
+ /**
+ * Checking for texture coordinate enabling
+ *
+ * @since 3.0
+ *
+ * @return True if texture coordinate is enabled
+ * @see ReserveTextureCoordinates()
+ */
bool IsTextureCoordinateEnabled(void) const;
+
+ /**
+ * Checking for colors enabling
+ *
+ * @since 3.0
+ *
+ * @return True if coloring is enabled
+ * @see ReserveColors()
+ */
bool IsColorEnabled(void) const;
+
+ /**
+ * Checking for normals are enabled or not
+ *
+ * @since 3.0
+ *
+ * @return True if normals are enabled
+ * @see ReserveNormals()
+ */
bool IsNormalEnabled(void) const;
+ /**
+ * Setting mesh's name
+ *
+ * @since 3.0
+ *
+ * @param[in] name Setting mesh's name
+ */
void SetName(Tizen::Base::String name);
- Tizen::Base::String GetName(void) const;
+ /**
+ * Getting mesh's name
+ *
+ * @since 3.0
+ *
+ * @return Mesh's name
+ */
+ Tizen::Base::String GetName(void);
+ Tizen::Base::String GetName() const;
+
+ //--------------------------------------------------TEMP
MeshController* GetMeshController(void);
+ //--------------------------------------------------
result SetProperty(const Tizen::Base::String& name, const Tizen::Ui::Variant& value);
Variant GetProperty(const Tizen::Base::String& name) const;
+ /**
+ * Gets the hash value of the current instance of %Mesh.
+ *
+ * @since 3.0
+ *
+ * @return An integer value indicating the hash value of the current instance of %Mesh
+ * @remarks Two equal instances must return the same hash value. For better performance,
+ * the used hash function must generate a random distribution for all inputs. @n
+ * The default implementation of this method returns the address of the current instance.
+ * Returns Mesh unique code (not depended of public instance) like mesh id
+ */
+ virtual int GetHashCode(void) const;
+
private:
class _MeshImpl* __pMeshImpl;
*/
Light* GetLightN(void) const;
+ /**
+ * Sets the contents of this instance with the specified ShaderProgram. @n
+ * The contents of the @c pShaderProgram is not copied by the %SetShaderProgram() method, but shared with this instance.
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @param[in] pShaderProgram The pointer to ShaderProgram @n
+ * @exception E_SUCCESS The method is successful.
+ * @remarks If applications modify the contents of @c pShaderProgram, the modifications will be applied to all
+ * the %VisualElements which share same ShaderProgram. But in this case, applications need to call
+ * the SetFlushNeeded() method for those %VisualElements because the modifications of the @c pShaderProgram will not be applied on the screen automatically.
+ * @see GetShaderProgramN()
+ */
result SetShaderProgram(ShaderProgram* pShaderProgram);
/**
+ * Gets the ShaderProgram data this instance uses for its contents.
+ *
+ * @since 3.0
+ *
+ * @return A pointer to ShaderProgram
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @remarks If an exception occurs, this method returns @c null.
+ * @see SetShaderProgram()
+ */
+ ShaderProgram* GetShaderProgramN(void) const;
+
+ /**
* Flushes %VisualElements on screen.
*
* @since 2.0
* @return BoundingVolume reference
* @see AdjustBoundingVolume()
*/
- BoundingVolume& GetBoundingVolume(void);
+ const BoundingVolume& GetBoundingVolume(void) const;
/**
* Build list of intersected VisualElements in the intersection order, starting from nearest
*
namespace Tizen { namespace Ui { namespace Animations
{
-BoundingVolume::BoundingVolume()
+BoundingVolume::BoundingVolume(void)
: _pBoundingVolumeImpl(null)
{
ClearLastResult();
FloatPoint3
-BoundingVolume::GetCenter() const
+BoundingVolume::GetCenter(void) const
{
SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
}
FloatPoint3
-BoundingVolume::GetHalfSize() const
+BoundingVolume::GetHalfSize(void) const
{
SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
}
void
-BoundingVolume::Reset()
+BoundingVolume::Reset(void)
{
SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
}
BoundingVolumeState
-BoundingVolume::GetState() const
+BoundingVolume::GetState(void) const
{
SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
}
BoundingVolumeType
-BoundingVolume::GetType() const
+BoundingVolume::GetType(void) const
{
SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
}
Mesh::GeometryType
-Mesh::GetGeometryType() const
+Mesh::GetGeometryType(void) const
{
CHECK_CONSTRUCTED;
return __pMeshImpl->GetGeometryType();
}
result
-Mesh::AdjustBoundingVolume(bool rebuild)
+Mesh::AdjustBoundingVolume(void)
{
+ SetLastResult(E_SUCCESS);
CHECK_CONSTRUCTED;
- return __pMeshImpl->AdjustBoundingVolume(rebuild);
+ return __pMeshImpl->AdjustBoundingVolume();
}
void
-Mesh::Clear()
+Mesh::Clear(void)
{
CHECK_CONSTRUCTED;
__pMeshImpl->Clear();
}
-BoundingVolume&
-Mesh::GetBoundingVolume()
+const BoundingVolume&
+Mesh::GetBoundingVolume(void) const
{
+ SetLastResult(E_SUCCESS);
CHECK_CONSTRUCTED;
return __pMeshImpl->GetBoundingVolume();
}
}
result
-Mesh::ReserveTextureCoordinates()
+Mesh::ReserveTextureCoordinates(void)
{
CHECK_CONSTRUCTED;
return __pMeshImpl->AllocTextureCoordinates();
}
result
-Mesh::ReserveNormals()
+Mesh::ReserveNormals(void)
{
CHECK_CONSTRUCTED;
return __pMeshImpl->AllocNormals();
}
result
-Mesh::ReserveColors()
+Mesh::ReserveColors(void)
{
CHECK_CONSTRUCTED;
return __pMeshImpl->AllocColors();
}
bool
-Mesh::IsIndexEnabled() const
+Mesh::IsIndexEnabled(void) const
{
CHECK_CONSTRUCTED;
return __pMeshImpl->IsIndexEnabled();
}
bool
-Mesh::IsTextureCoordinateEnabled() const
+Mesh::IsTextureCoordinateEnabled(void) const
{
CHECK_CONSTRUCTED;
return __pMeshImpl->IsTextureCoordinateEnabled();
}
bool
-Mesh::IsColorEnabled() const
+Mesh::IsColorEnabled(void) const
{
CHECK_CONSTRUCTED;
return __pMeshImpl->IsColorEnabled();
}
bool
-Mesh::IsNormalEnabled() const
+Mesh::IsNormalEnabled(void) const
{
CHECK_CONSTRUCTED;
return __pMeshImpl->IsNormalEnabled();
}
int
-Mesh::GetVertexCount() const
+Mesh::GetVertexCount(void) const
{
CHECK_CONSTRUCTED;
return __pMeshImpl->GetCountOfVertices();
}
int
-Mesh::GetIndexCount() const
+Mesh::GetIndexCount(void) const
{
CHECK_CONSTRUCTED;
return __pMeshImpl->GetCountOfIndices();
}
result
-Mesh::SaveMeshToBin(const Tizen::Base::String& fileName)
+Mesh::SaveMeshToBinary(const Tizen::Base::String& fileName)
{
CHECK_CONSTRUCTED;
- return __pMeshImpl->SaveMeshToBin(fileName);
+ return __pMeshImpl->SaveMeshToBinary(fileName);
}
void
}
Tizen::Base::String
+Mesh::GetName(void)
+{
+ SetLastResult(E_SUCCESS);
+ return Tizen::Base::String(__pMeshImpl->GetName().c_str());
+}
+
+Tizen::Base::String
Mesh::GetName() const
{
return Tizen::Base::String(__pMeshImpl->GetName().c_str());
}
+int
+Mesh::GetHashCode(void) const
+{
+ CHECK_CONSTRUCTED;
+ return (int) __pMeshImpl;
+}
+//--------------------------------------------------TEMP
+
MeshController*
Mesh::GetMeshController(void)
{
return _pVisualElementImpl->SetShaderProgram(pShaderProgram);
}
+ShaderProgram*
+VisualElement::GetShaderProgramN(void) const
+{
+ CHECK_CONSTRUCTED;
+ return _pVisualElementImpl->GetShaderProgramN();
+}
+
void
VisualElement::SetImplicitAnimationEnabled(bool enable)
{
}
result
-VisualElement::AdjustBoundingVolume()
+VisualElement::AdjustBoundingVolume(void)
{
CHECK_CONSTRUCTED;
return _pVisualElementImpl->AdjustBoundingVolume();
}
-BoundingVolume&
-VisualElement::GetBoundingVolume()
+const BoundingVolume&
+VisualElement::GetBoundingVolume(void) const
{
CHECK_CONSTRUCTED;
namespace Tizen{ namespace Ui{ namespace Animations
{
-_BoundingVolumeImpl::_BoundingVolumeImpl()
+_BoundingVolumeImpl::_BoundingVolumeImpl(void)
: __state(BOUNDING_VOLUME_STATE_EMPTY)
, __type(BOUNDING_VOLUME_TYPE_AABB)
, __min(0.0f)
}
-_BoundingVolumeImpl::~_BoundingVolumeImpl()
+_BoundingVolumeImpl::~_BoundingVolumeImpl(void)
{
}
}
_Math::Vector3
-_BoundingVolumeImpl::GetCenter() const
+_BoundingVolumeImpl::GetCenter(void) const
{
switch(__type)
{
}
-void _BoundingVolumeImpl::Reset()
+void _BoundingVolumeImpl::Reset(void)
{
__min = _Math::Vector3();
__max = _Math::Vector3();
}
-void _BoundingVolumeImpl::print() const
+void _BoundingVolumeImpl::print(void) const
{
switch(__type)
{
}
void
+_MatrixUtilTransformDirection(const Tizen::Graphics::FloatMatrix4& m, float* pX, float* pY, float* pZ)
+{
+ float x = 0.f, y = 0.f, z = 0.f, w = 0.0f;
+
+ x = (m.matrix[0][0] * *pX) + (m.matrix[1][0] * *pY) + (m.matrix[2][0] * *pZ) + (m.matrix[3][0] * 0.0f);
+ y = (m.matrix[0][1] * *pX) + (m.matrix[1][1] * *pY) + (m.matrix[2][1] * *pZ) + (m.matrix[3][1] * 0.0f);
+ z = (m.matrix[0][2] * *pX) + (m.matrix[1][2] * *pY) + (m.matrix[2][2] * *pZ) + (m.matrix[3][2] * 0.0f);
+// w = (m.matrix[0][3] * *pX) + (m.matrix[1][3] * *pY) + (m.matrix[2][3] * *pZ) + (m.matrix[3][3] * 0.0f);
+
+// if (w != 1.0f && w != 0.0f)
+// {
+ *pX = x;
+ *pY = y;
+ *pZ = z;
+// }
+// else
+// {
+// *pX = x;
+// *pY = y;
+// *pZ = z;
+// }
+}
+
+void
_MatrixUtilTranslate(Tizen::Graphics::FloatMatrix4& m, float tx, float ty, float tz)
{
m.matrix[3][0] += (m.matrix[0][0] * tx + m.matrix[1][0] * ty + m.matrix[2][0] * tz);
bool _MatrixUtilIsEqual(const Tizen::Graphics::FloatMatrix4& m1, const Tizen::Graphics::FloatMatrix4& m2);
void _MatrixUtilSetTranslation(Tizen::Graphics::FloatMatrix4& m, float tx, float ty, float tz);
void _MatrixUtilTransform(const Tizen::Graphics::FloatMatrix4& m, float* pX, float* pY, float* pZ);
+void _MatrixUtilTransformDirection(const Tizen::Graphics::FloatMatrix4& m, float* pX, float* pY, float* pZ);
void _MatrixUtilTranslate(Tizen::Graphics::FloatMatrix4& m, float tx, float ty, float tz);
bool _MatrixUtilIsTranslation(const Tizen::Graphics::FloatMatrix4& m);
void _MatrixUtilScale(Tizen::Graphics::FloatMatrix4& m, float sx, float sy, float sz);
, __countOfAllocatedVertex(0)
, __countOfIndex(0)
, __countOfAllocatedIndex(0)
- , __hasBoundingVolume(false)
, __boundingVolume()
, __pMeshController(null)
{
__countOfAllocatedIndex = 0;
__boundingVolume.Reset();
- __hasBoundingVolume = false;
if(__pMeshController)
{
__pVertices[i + 1] = vertex.y;// - __boundingVolume.GetCenter().y; //y
__pVertices[i + 2] = vertex.z;// - __boundingVolume.GetCenter().z; //z
- if (__hasBoundingVolume)
- {
- __boundingVolume.Merge(vertex);
- }
+ __boundingVolume.Merge(vertex);
if (__countOfVertex <= arrayIndex)
{
}
result
-_MeshImpl::AdjustBoundingVolume(bool rebuild)
+_MeshImpl::AdjustBoundingVolume(void)
{
MESH_LOCK();
result r;
SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s Adds volume of specified BoundingVolume to this BoundingVolume is failed.", GetErrorMessage(r));
}
- __hasBoundingVolume = true;
-
return E_SUCCESS;
CATCH:
__boundingVolume.Reset();
- __hasBoundingVolume = false;
return r;
}
-BoundingVolume&
-_MeshImpl::GetBoundingVolume()
+const BoundingVolume&
+_MeshImpl::GetBoundingVolume(void) const
{
return __boundingVolume;
}
-//FloatPoint3
-//_MeshImpl::GetBoundingBoxPosition() const
-//{
-// Vector3 v = __boundingVolume.GetCenter();
-// return FloatPoint3(v.x, v.y, v.z);
-//}
-//
-//float
-//_MeshImpl::GetBoundingBoxVolume() const
-//{
-// return __boundingVolume.GetHalfSize().z * 2;
-//}
-//
-//
-//float
-//_MeshImpl::GetBoundingBoxWidth() const
-//{
-// return __boundingVolume.GetHalfSize().x * 2;
-//}
-//
-//float
-//_MeshImpl::GetBoundingBoxHeight() const
-//{
-// return __boundingVolume.GetHalfSize().y * 2;
-//}
-
Mesh*
_MeshImpl::LoadMeshFromBinaryN(const std::string& fileName, const std::string& modelName)
{
quantityReadFromFile += fread(&pMeshImpl->__countOfAllocatedIndex, sizeof(int32_t), 1, pFile);
quantityReadFromFile += fread(&intsData, sizeof(int32_t), 1, pFile);
- pMeshImpl->__hasBoundingVolume = static_cast<bool>(intsData);
-
- quantityReadFromFile += fread(&intsData, sizeof(int32_t), 1, pFile);
pMeshImpl->__geoType = static_cast<Mesh::GeometryType> (intsData);
if (localCapacity.isVerticesEnabled)
}
result
-_MeshImpl::SaveMeshToBin(const Tizen::Base::String& fileName)
+_MeshImpl::SaveMeshToBinary(const Tizen::Base::String& fileName)
{
int quantityWriteToFile;
result r;
intsData = __countOfAllocatedIndex;
quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
-
- intsData = static_cast<int>(__hasBoundingVolume);
- quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
-
intsData = static_cast<int>(__geoType);
quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
}
PlaneIntersectionResult
-_Plane::Intersect(Tizen::Ui::Animations::_Plane& other) const
+_Plane::Intersect(const Tizen::Ui::Animations::_Plane& other) const
{
if (_a == other._a && _b == other._b && _c == other._c)
{
}
PlaneIntersectionResult
-_Plane::Intersect(Tizen::Graphics::FloatPoint3& v) const
+_Plane::Intersect(const Tizen::Graphics::FloatPoint3& v) const
{
float d = (_a * v.x + _b * v.y + _c * v.z + _d);
}
PlaneIntersectionResult
-_Plane::Intersect(Tizen::Ui::Animations::BoundingVolume& volume) const
+_Plane::Intersect(const Tizen::Ui::Animations::BoundingVolume& volume) const
{
switch(volume.GetType())
{
}
PlaneIntersectionResult
-_Plane::Intersect(Tizen::Ui::Animations::Mesh* pMesh) const
+_Plane::Intersect(const Tizen::Ui::Animations::Mesh* pMesh) const
{
FloatPoint3 v;
bool pos = false;
}
float
-_Plane::GetDistance(Tizen::Graphics::FloatPoint3& v) const
+_Plane::GetDistance(const Tizen::Graphics::FloatPoint3& v) const
{
return Abs(_a * v.x + _b * v.y + _c * v.z + _d);//normilized / Sqrt(_a * _a + _b * _b + _c * _c);
}
}
-_Selection::_Selection(_Plane& plane1,_Plane& plane2,_Plane& plane3,_Plane& plane4)
+_Selection::_Selection(const _Plane& plane1, const _Plane& plane2, const _Plane& plane3, const _Plane& plane4)
{
_plane[0] = plane1;
_plane[1] = plane2;
}
result
-_Selection::Set(_Plane& plane1, _Plane& plane2, _Plane& plane3, _Plane& plane4)
+_Selection::Set(const _Plane& plane1, const _Plane& plane2, const _Plane& plane3, const _Plane& plane4)
{
_plane[0] = plane1;
_plane[1] = plane2;
}
result
-_Selection::Set(int index, _Plane& plane)
+_Selection::Set(int index, const _Plane& plane)
{
if (index >= 0 && index < 4)
{
}
result
-_Selection::Set(int index, Tizen::Graphics::FloatPoint3& v1, Tizen::Graphics::FloatPoint3& v2, Tizen::Graphics::FloatPoint3& v3)
+_Selection::Set(int index, const Tizen::Graphics::FloatPoint3& v1, const Tizen::Graphics::FloatPoint3& v2, const Tizen::Graphics::FloatPoint3& v3)
{
if (index >= 0 && index < 4)
{
}
bool
-_Selection::FindIncludedPoints(Tizen::Graphics::FloatPoint3& v) const
+_Selection::FindIncludedPoints(const Tizen::Graphics::FloatPoint3& v) const
{
bool pos = false;
bool neg = false;
}
bool
-_Selection::FindExcludedPoints(Tizen::Graphics::FloatPoint3& v) const
+_Selection::FindExcludedPoints(const Tizen::Graphics::FloatPoint3& v) const
{
bool pos = false;
bool neg = false;
}
bool
-_Selection::FindIncludedPoints(Tizen::Ui::Animations::BoundingVolume& volume) const
+_Selection::FindIncludedPoints(const Tizen::Ui::Animations::BoundingVolume& volume) const
{
bool pos = false;
bool neg = false;
}
bool
-_Selection::FindExcludedPoints(Tizen::Ui::Animations::BoundingVolume& volume) const
+_Selection::FindExcludedPoints(const Tizen::Ui::Animations::BoundingVolume& volume) const
{
bool pos = false;
bool neg = false;
}
bool
-_Selection::FindIncludedPoints(Tizen::Ui::Animations::Mesh* pMesh) const
+_Selection::FindIncludedPoints(const Tizen::Ui::Animations::Mesh* pMesh) const
{
if (pMesh != null)
{
}
bool
-_Selection::FindExcludedPoints(Tizen::Ui::Animations::Mesh* pMesh) const
+_Selection::FindExcludedPoints(const Tizen::Ui::Animations::Mesh* pMesh) const
{
if (pMesh != null)
{
}
result
-_Selection::FindIncludedExcludedPoints(Tizen::Ui::Animations::Mesh* pMesh, bool& hasIncluded, bool& hasExcluded) const
+_Selection::FindIncludedExcludedPoints(const Tizen::Ui::Animations::Mesh* pMesh, bool& hasIncluded, bool& hasExcluded) const
{
hasIncluded = false;
hasExcluded = false;
}
bool
-_Selection::FindIncludedEdgeIntersections(Tizen::Graphics::FloatPoint3& v1, Tizen::Graphics::FloatPoint3& v2) const
+_Selection::FindIncludedEdgeIntersections(const Tizen::Graphics::FloatPoint3& v1, const Tizen::Graphics::FloatPoint3& v2) const
{
FloatPoint3 v1v2(v2 - v1);
FloatPoint3 n, intersectPoint;
}
bool
-_Selection::FindIncludedMeshIntersections(Tizen::Ui::Animations::Mesh* pMesh) const
+_Selection::FindIncludedMeshIntersections(const Tizen::Ui::Animations::Mesh* pMesh) const
{
if (pMesh != null)
{
result Get(float& a,float& b, float& c, float& d) const;
result Get(Tizen::Graphics::FloatPoint3& v1, Tizen::Graphics::FloatPoint3& v2, Tizen::Graphics::FloatPoint3& v3) const;
- PlaneIntersectionResult Intersect(Tizen::Ui::Animations::_Plane& other) const;
- PlaneIntersectionResult Intersect(Tizen::Graphics::FloatPoint3& v) const;
- PlaneIntersectionResult Intersect(Tizen::Ui::Animations::BoundingVolume& volume) const;
- PlaneIntersectionResult Intersect(Tizen::Ui::Animations::Mesh* pMesh) const;
+ PlaneIntersectionResult Intersect(const Tizen::Ui::Animations::_Plane& other) const;
+ PlaneIntersectionResult Intersect(const Tizen::Graphics::FloatPoint3& v) const;
+ PlaneIntersectionResult Intersect(const Tizen::Ui::Animations::BoundingVolume& volume) const;
+ PlaneIntersectionResult Intersect(const Tizen::Ui::Animations::Mesh* pMesh) const;
- float GetDistance(Tizen::Graphics::FloatPoint3& v) const; //distance to point
- Tizen::Graphics::FloatPoint3 GetNormal(void) const; //distance to point
+ float GetDistance(const Tizen::Graphics::FloatPoint3& v) const; //distance to point
+ Tizen::Graphics::FloatPoint3 GetNormal() const; //distance to point
result Transform(const Tizen::Graphics::FloatMatrix4& transformMatrix);
{
public:
_Selection(void);
- _Selection(_Plane& plane1,_Plane& plane2,_Plane& plane3,_Plane& plane4);
+ _Selection(const _Plane& plane1, const _Plane& plane2, const _Plane& plane3, const _Plane& plane4);
~_Selection(void);
_Selection& operator = (const _Selection& rhs);
- result Set(_Plane& plane1, _Plane& plane2, _Plane& plane3, _Plane& plane4);
- result Set(int index, _Plane& plane);
- result Set(int index, Tizen::Graphics::FloatPoint3& v1, Tizen::Graphics::FloatPoint3& v2, Tizen::Graphics::FloatPoint3& v3);
+ result Set(const _Plane& plane1, const _Plane& plane2, const _Plane& plane3, const _Plane& plane4);
+ result Set(int index, const _Plane& plane);
+ result Set(int index, const Tizen::Graphics::FloatPoint3& v1, const Tizen::Graphics::FloatPoint3& v2, const Tizen::Graphics::FloatPoint3& v3);
_Plane& Get(int index);
result Transform(const Tizen::Graphics::FloatMatrix4& transformMatrix);
- bool FindIncludedPoints(Tizen::Graphics::FloatPoint3& v) const;
- bool FindExcludedPoints(Tizen::Graphics::FloatPoint3& v) const;
+ bool FindIncludedPoints(const Tizen::Graphics::FloatPoint3& v) const;
+ bool FindExcludedPoints(const Tizen::Graphics::FloatPoint3& v) const;
- bool FindIncludedPoints(Tizen::Ui::Animations::BoundingVolume& volume) const;
- bool FindExcludedPoints(Tizen::Ui::Animations::BoundingVolume& volume) const;
+ bool FindIncludedPoints(const Tizen::Ui::Animations::BoundingVolume& volume) const;
+ bool FindExcludedPoints(const Tizen::Ui::Animations::BoundingVolume& volume) const;
- bool FindIncludedPoints(Tizen::Ui::Animations::Mesh* pMesh) const;
- bool FindExcludedPoints(Tizen::Ui::Animations::Mesh* pMesh) const;
- result FindIncludedExcludedPoints(Tizen::Ui::Animations::Mesh* pMesh, bool& hasIncluded, bool& hasExcluded) const;
+ bool FindIncludedPoints(const Tizen::Ui::Animations::Mesh* pMesh) const;
+ bool FindExcludedPoints(const Tizen::Ui::Animations::Mesh* pMesh) const;
+ result FindIncludedExcludedPoints(const Tizen::Ui::Animations::Mesh* pMesh, bool& hasIncluded, bool& hasExcluded) const;
- bool FindIncludedMeshIntersections(Tizen::Ui::Animations::Mesh* pMesh) const;
- bool FindIncludedEdgeIntersections(Tizen::Graphics::FloatPoint3& v1, Tizen::Graphics::FloatPoint3& v2) const;
+ bool FindIncludedMeshIntersections(const Tizen::Ui::Animations::Mesh* pMesh) const;
+ bool FindIncludedEdgeIntersections(const Tizen::Graphics::FloatPoint3& v1, const Tizen::Graphics::FloatPoint3& v2) const;
protected:
_Plane _plane[4];
#include <FGrpFloatPoint.h>
#include <FGrpFloatDimension.h>
#include <FGrpFloatRectangle.h>
+#include "FUiAnim_MatrixUtil.h"
#include "math/FUiAnim_MathVector3.h"
#include "math/FUiAnim_MathMatrix4.h"
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
}
-_Ray::_Ray()
- : Position(0.0)
- , Direction(0.0)
+_Ray::_Ray(void)
+ : position(0.0)
+ , direction(0.0)
{
}
-_Ray::_Ray(const _Math::Vector3& position, const _Math::Vector3& direction)
- : Position(position)
- , Direction(direction)
+_Ray::_Ray(const _Math::Vector3& positionInput, const _Math::Vector3& directionInput)
+ : position(positionInput)
+ , direction(directionInput)
{
- Direction.Normalize();
+ direction.Normalize();
}
_Ray&
_Ray&
_Ray::Set(const _Ray& rhs)
{
- Position = rhs.Position;
- Direction = rhs.Direction;
+ position = rhs.position;
+ direction = rhs.direction;
return *this;
}
_Ray&
-_Ray::Set(const _Math::Vector3& position, const _Math::Vector3& direction)
+_Ray::Set(const _Math::Vector3& positionInput, const _Math::Vector3& directionInput)
{
- Position = position;
- Direction = direction;
+ position = positionInput;
+ direction = directionInput;
return *this;
}
if(boundingVolume.GetType() == BOUNDING_VOLUME_TYPE_AABB)
{
_Math::Vector3 center = boundingVolume._pBoundingVolumeImpl->GetCenter();
- _Math::Vector3 centerOrigin = center - Position;
+ _Math::Vector3 centerOrigin = center - position;
_Math::Vector3 halfSize = boundingVolume._pBoundingVolumeImpl->GetHalfSize();
_Math::Vector3 normals[axisCount] = {_Math::Vector3(1.0f, 0.0f, 0.0f), _Math::Vector3(0.0f, 1.0f, 0.0f), _Math::Vector3(0.0f, 0.0f, 1.0f)};
for(int i = 0; i < axisCount; ++i)
{
float e = normals[i].Dot(centerOrigin);
- float f = normals[i].Dot(Direction);
+ float f = normals[i].Dot(direction);
if (abs(f) > std::numeric_limits<float>::epsilon())
{
c.Set(center.x, center.y, center.z);
- c = Position - c;
+ c = position - c;
- underRoot = DotProduct(Direction,c) * DotProduct(Direction,c) - DotProduct(c,c) - r * r;
+ underRoot = DotProduct(direction,c) * DotProduct(direction,c) - DotProduct(c,c) - r * r;
if(underRoot < 0.0f)
{
return std::make_pair(false, tMax);
}
- tMax = -DotProduct(Direction,c) - sqrt(underRoot);
+ tMax = -DotProduct(direction,c) - sqrt(underRoot);
return std::make_pair(true, tMax);
}
void
-_Ray::print()
+_Ray::print(void)
{
- AppLog("Pos %.3f %.3f %.3f", Position.x, Position.y, Position.z);
- AppLog("Dir %.3f %.3f %.3f", Direction.x, Direction.y, Direction.z);
+ AppLog("Pos %.3f %.3f %.3f", position.x, position.y, position.z);
+ AppLog("Dir %.3f %.3f %.3f", direction.x, direction.y, direction.z);
}
_Math::Vector3
{
//make from top matrix
//_Math::Matrix4 fromTop( &(pVEImpl->GetMatrixToTop().matrix[0][0]) );
- _Math::Matrix4 fromTop(&(toTop.matrix[0][0]));
- fromTop.Transpose();
- fromTop.Inverse();
-
- //_Math::Matrix4 fromTop( &(pVEImpl->GetMatrixFromTop().matrix[0][0]) );
-
- //Transpose to convert into Matrix4
- //fromTop.Transpose();
- //Invert to convert from toTop to FfromTop
- //fromTop.Inverse();
-
- Position = fromTop * globalRay.Position;
-
- //because Mat4 * vec3 treats vec3 as point
- _Math::Vector4 direction(globalRay.Direction.x, globalRay.Direction.y, globalRay.Direction.z, 0.0f);
- _Math::Vector4 directionT = fromTop * direction;
-
- Direction.Set(directionT.x, directionT.y, directionT.z);
+// _Math::Matrix4 fromTop(&(toTop.matrix[0][0]));
+// fromTop.Transpose();
+// fromTop.Inverse();
+//
+// //_Math::Matrix4 fromTop( &(pVEImpl->GetMatrixFromTop().matrix[0][0]) );
+//
+// //Transpose to convert into Matrix4
+// //fromTop.Transpose();
+// //Invert to convert from toTop to FfromTop
+// //fromTop.Inverse();
+//
+// Position = fromTop * globalRay.Position;
+//
+// //because Mat4 * vec3 treats vec3 as point
+// _Math::Vector4 direction(globalRay.Direction.x, globalRay.Direction.y, globalRay.Direction.z, 0.0f);
+// _Math::Vector4 directionT = fromTop * direction;
+//
+// Direction.Set(directionT.x, directionT.y, directionT.z);
+
+ FloatMatrix4 fromTop(toTop);
+ _MatrixUtilInvert(fromTop);
+
+ position = globalRay.position;
+ direction = globalRay.direction;
+
+ _MatrixUtilTransform(fromTop, &position.x, &position.y, &position.z);
+ _MatrixUtilTransformDirection(fromTop, &direction.x, &direction.y, &direction.z);
return *this;
}
_Math::Vector3 screenNear = ConvertScreenToWorld(_Math::Vector3(absPoint.x, absPoint.y, 0.0f), pvInv, frame);
_Math::Vector3 screenFar = ConvertScreenToWorld(_Math::Vector3(absPoint.x, absPoint.y, 1.0f), pvInv, frame);
+// _Math::Vector3 screenNear = ConvertScreenToWorld(_Math::Vector3(point.x, point.y, 0.0f), pvInv, frame);
+// _Math::Vector3 screenFar = ConvertScreenToWorld(_Math::Vector3(point.x, point.y, 1.0f), pvInv, frame);
Set(screenNear, screenFar - screenNear);
Tizen::Graphics::FloatRectangle bounds = pLayer->GetBounds();
frame = bounds;
- frame.x = 0.0f;
- frame.y = 0.0f;
-
- _Matrix4f viewport;
- viewport.MakeOrthogonal(0.0f, bounds.width, 0.0f, bounds.height, -bounds.height, bounds.height);
- viewport.Translate(0.0f, bounds.height, 0.0f);
- viewport.Scale(1.0f, -1.0f, 1.0f);
-
- pvInv.Set(viewport.GetItems());
- pvInv.Inverse();
+// frame.x = 0.0f;
+// frame.y = 0.0f;
+
+// _Matrix4f viewport;
+// viewport.MakeOrthogonal(0.0f, bounds.width, 0.0f, bounds.height, -bounds.height, bounds.height);
+// viewport.Translate(0.0f, bounds.height, 0.0f);
+// viewport.Scale(1.0f, -1.0f, 1.0f);
+//
+// pvInv.Set(viewport.GetItems());
+// pvInv.Inverse();
+// pvInv.Transpose();
+
+ _Matrix4f view = pRoot->GetViewMatrix();
+
+ _Matrix4f viewProjection = pRoot->GetProjectionMatrix();
+ viewProjection.MultiplyMatrix(view);
+ viewProjection.Translate(0.0f, bounds.height, 0.0f);
+ viewProjection.Scale(1.0f, -1.0f, 1.0f);
+
+ FloatMatrix4 pvTizenInv;
+ viewProjection.CopyTo(pvTizenInv);
+ _MatrixUtilInvert(pvTizenInv);
+ pvInv.Set(&pvTizenInv.matrix[0][0]);
pvInv.Transpose();
return true;
bool CreatePVInv(const _VisualElementImpl* pRootVe, _Math::Matrix4& pvInv, Tizen::Graphics::FloatRectangle& frame);
_Math::Vector3 ConvertScreenToWorld(const _Math::Vector3& screen, const _Math::Matrix4& pvInv, const Tizen::Graphics::FloatRectangle& frame);
- _Math::Vector3 Position;
- _Math::Vector3 Direction;
+ _Math::Vector3 position;
+ _Math::Vector3 direction;
};
std::pair<bool, float> IntersectsPlane()
{
- float rayOnNormal = Normal.Dot(Ray.Direction);
+ float rayOnNormal = Normal.Dot(Ray.direction);
if (_Abs(rayOnNormal) < std::numeric_limits<float>::epsilon())
{
return make_pair(false, 0.0f);
}
- T = (Distance - Normal.Dot(Ray.Position)) / (Normal.Dot(Ray.Direction));
+ T = (Distance - Normal.Dot(Ray.position)) / (Normal.Dot(Ray.direction));
return make_pair(true, T);
}
std::pair<bool, _Math::Vector3> IntersectsTriangle()
{
- _Math::Vector3 pP = Ray.Position + Ray.Direction * T;
+ _Math::Vector3 pP = Ray.position + Ray.direction * T;
_Math::Vector3 normalAbs(_Abs(Normal.x), _Abs(Normal.y), _Abs(Normal.z));
maxInd = 0;
_VisualElementImpl::_VisualElementImpl(VisualElement& element)
: _zOrderGroup(Z_ORDER_GROUP_NORMAL)
, __boundingVolume()
- , __globalRay(_Math::Vector3(0.0f),_Math::Vector3(0.0f))
- , __hasGlobalRay(false)
+// , __globalRay(_Math::Vector3(0.0f),_Math::Vector3(0.0f))
+// , __hasGlobalRay(false)
, __nearestDistance(std::numeric_limits<float>::infinity())
, __pNearestVEImpl(null)
, __pSharedData(null)
_VisualElementImpl::_VisualElementImpl(VisualElement& presentation, _VisualElementImpl& modelImpl)
: _zOrderGroup(modelImpl._zOrderGroup)
, __boundingVolume()
- , __globalRay(_Math::Vector3(0.0f),_Math::Vector3(0.0f))
- , __hasGlobalRay(false)
+// , __globalRay(_Math::Vector3(0.0f),_Math::Vector3(0.0f))
+// , __hasGlobalRay(false)
, __nearestDistance(std::numeric_limits<float>::infinity())
, __pNearestVEImpl(null)
, __pSharedData(null)
if (converted.GetState() == BOUNDING_VOLUME_STATE_VALID)
{
converted.Transform(child.GetMatrixToSuper());
- GetBoundingVolume().Merge(converted);
+ __boundingVolume.Merge(converted);
__MergeParentsBV();
}
if (converted.GetState() == BOUNDING_VOLUME_STATE_VALID)
{
converted.Transform(child.GetMatrixToSuper());
- GetBoundingVolume().Merge(converted);
+ __boundingVolume.Merge(converted);
__MergeParentsBV();
}
bounds.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height);
}
-
float
_VisualElementImpl::GetOpacityFromRoot(void) const
{
return Variant();
}
-
int
_VisualElementImpl::HitTestI(const FloatPoint& point)
{
+ //make gloabl ray
+ _Ray globalRay;
+ globalRay.MakeRayGlobal(this,point);
+
+ return HitTestI(point, globalRay);
+}
+
+int
+_VisualElementImpl::HitTestI(const FloatPoint& point, const _Ray& globalRay)
+{
if (!IsVisibleI())
{
return HITTEST_NOWHERE;
}
else // mesh is assigned - do 3D HitTest
{
- if (__hasGlobalRay == false) //VE have no local ray, create
- {
- //make gloabl ray
- __globalRay.MakeRayGlobal(this,point);
- //__hasGlobalRay = true;
- }
-
- //hit VE mesh box?
-
- //create global BoundingVolume
- //get toTop matrix
- static BoundingVolume globalVolume;//(pMesh->GetBoundingVolume());
- if (pMesh->GetBoundingVolume().GetState() != BOUNDING_VOLUME_STATE_VALID)
- {
- pMesh->AdjustBoundingVolume(true);
- }
- globalVolume = pMesh->GetBoundingVolume();
-
- //GLNode - dravable so has an actual animated coordinates of drawed conext
- _GlNode* pNode = dynamic_cast< _GlNode* >(this->GetNativeNode());
- if (pNode != null)
- {
- globalVolume.Transform(pNode->__transform);
- }
- else
- {
- globalVolume.Transform(GetMatrixToTop());
- }
- //hope presentation works
- //globalVolume.Transform(GetPresentation()->GetMatrixToTop());
+ _Ray localRay;
+ localRay.MakeRayLocal(globalRay, this->GetRenderObject()->GetMatrixToTop()); //make local ray for mesh
-
- std::pair<bool, float> intersect = __globalRay.Intersect(globalVolume);
+ std::pair<bool, float> intersect = localRay.Intersect(pMesh->GetBoundingVolume());
if (intersect.first) // box intersected
{
//hit VE mesh triangles?
Intersections intesections;
- //create local ray to intersect triangles in mesh
- _Ray localRay;
- localRay.MakeRayLocal(__globalRay, (pNode != null)?pNode->__transform:GetMatrixToTop()); //make local ray for mesh
- //hope presentation works
- //localRay.MakeRayLocal(__globalRay,GetPresentation()->GetMatrixToTop()); //make local ray for mesh
-
if (!__SearchTriangleIntersection(localRay, pMesh, intesections, true)) //get all intersected triangle
{
//no triangles intercected
return HITTEST_NOWHERE;
}
-
- if (__hasGlobalRay == true)
+ //find nearest intersection
+ DistToPoint nearestIntersection = *intesections.begin();
+ for (Intersections::iterator it = ++intesections.begin(); it != intesections.end(); it++)
{
- //find nearest intersection
- DistToPoint nearestIntersection = *intesections.begin();
- for (Intersections::iterator it = ++intesections.begin(); it != intesections.end(); it++)
- {
- if (it->first < nearestIntersection.first)
- {
- nearestIntersection = *it;
- }
- }
- //test if nearest intersection in this mesh are closer than previously founded
- if (__nearestDistance > nearestIntersection.first)
+ if (it->first < nearestIntersection.first)
{
- __nearestDistance = nearestIntersection.first;
- __pNearestVEImpl = this;
+ nearestIntersection = *it;
}
}
-
+ //test if nearest intersection in this mesh are closer than previously founded
+ if (__nearestDistance > nearestIntersection.first)
+ {
+ __nearestDistance = nearestIntersection.first;
+ __pNearestVEImpl = this;
+ }
}
else // box not intersected
{
}
_VisualElementImpl*
-_VisualElementImpl::GetChildAtPointI(const FloatPoint& point, int parentHitTest)
+_VisualElementImpl::GetChildAtPointI(const FloatPoint& point, const _Ray& globalRay, int parentHitTest)
{
_VisualElementImpl* pHitTarget = null;
FloatPoint hitPoint = point;
//but animations can be provided so do not do this
if (false)
{
- if (__hasGlobalRay == false) //VE have no local ray, create
- {
- //make gloabl ray
- __globalRay.MakeRayGlobal(this,point);
- __hasGlobalRay = true;
- }
-
//hit VE mesh box?
- //create global BoundingVolume
- //get toTop matrix
- static BoundingVolume globalVolume;//(pMesh->GetBoundingVolume());
- globalVolume = GetBoundingVolume();
-
- //GLNode - dravable so has an actual animated coordinates of drawed conext
- _GlNode* pNode = dynamic_cast< _GlNode* >(this->GetNativeNode());
- if (pNode != null)
- {
- globalVolume.Transform(pNode->__transform);
- }
- else
- {
- globalVolume.Transform(GetMatrixToTop());
- }
+ _Ray localRay;
+ localRay.MakeRayLocal(globalRay, this->GetRenderObject()->GetTransformMatrix());
- std::pair<bool, float> intersect = __globalRay.Intersect(globalVolume);
+ std::pair<bool, float> intersect = localRay.Intersect(GetBoundingVolume());
if (!intersect.first) // box not intersected
{
}
- hitTest = VE_DELEGATE(this, InvokeHitTest, point);
+ hitTest = VE_DELEGATE(this, InvokeHitTest, point, globalRay);
if ((hitTest & HITTEST_MATCH) != 0)
{
// passed hittest
FloatPoint childHitPoint = point;
pChild->ConvertCoordinates(childHitPoint, this);
- //make local ray for child
- if (__hasGlobalRay)
- {
- pChild->__globalRay.Set(__globalRay);
- pChild->__hasGlobalRay = true;
- }
-
//Clear nearest searching parameters for child
pChild->__pNearestVEImpl = null;
pChild->__nearestDistance = std::numeric_limits<float>::infinity();
- _VisualElementImpl* pChildHitTarget = pChild->GetChildAtPointI(childHitPoint, hitTest);
- //remove local ray for child
- if (__hasGlobalRay)
- {
- pChild->__hasGlobalRay = false;
- }
+ _VisualElementImpl* pChildHitTarget = pChild->GetChildAtPointI(childHitPoint, globalRay, hitTest);
// if (pChildHitTarget)
// {
_VisualElementImpl::GetChildAt(const FloatPoint& point)
{
//make gloabl ray
- __globalRay.MakeRayGlobal(this,point);
+ _Ray globalRay;
+ globalRay.MakeRayGlobal(this,point);
//Clear nearest-searching parameters for root
__pNearestVEImpl = null;
__nearestDistance = std::numeric_limits<float>::infinity();
- __hasGlobalRay = true;
- _VisualElementImpl* pHitTarget = GetChildAtPointI(point, HITTEST_MATCH);
+ _VisualElementImpl* pHitTarget = GetChildAtPointI(point, globalRay, HITTEST_MATCH);
- //remove local ray
- __hasGlobalRay = false;
if (unlikely(!pHitTarget))
{
result
_VisualElementImpl::SetMesh(Mesh* pMesh)
{
- pMesh->AdjustBoundingVolume();
-
Mesh* pOldMesh = GetSharedData().geometry.GetMesh();
GetSharedData().geometry.SetMesh(pMesh);
+
+ if (pMesh != null)
+ {
+ pMesh->AdjustBoundingVolume();
+ }
//merge BV
if (pOldMesh != null)
{
if (pMesh != null)
{
//Only merge new mesh if it is first
- GetBoundingVolume().Merge(pMesh->GetBoundingVolume());
+ __boundingVolume.Merge(pMesh->GetBoundingVolume());
__MergeParentsBV();
}
}
return GetSharedData().geometry.SetShaderProgram(pShaderProgram);
}
+ShaderProgram*
+_VisualElementImpl::GetShaderProgramN(void) const
+{
+ ShaderProgram* pShaderProgram = GetSharedData().geometry.GetShaderProgram();
+
+ if (pShaderProgram != null)
+ {
+ return new (std::nothrow) ShaderProgram(*pShaderProgram);
+ }
+
+ return null;
+}
+
bool
CompareIntersections(const DistToPoint& dp0, const DistToPoint& dp1)
{
void
_VisualElementImpl::__AdjustBVWithChildren()
{
- GetBoundingVolume().Reset();
+ __boundingVolume.Reset();
int count = __children.GetCount();
_VisualElementImpl* pChild;
Mesh* pMesh = GetSharedData().geometry.GetMesh();
if (pMesh != null)
{
- GetBoundingVolume().Merge(pMesh->GetBoundingVolume());
+ __boundingVolume.Merge(pMesh->GetBoundingVolume());
}
//children BV add
for (int i = 0; i < count; i++)
if (converted.GetState() == BOUNDING_VOLUME_STATE_VALID)
{
converted.Transform(pChild->GetMatrixToSuper());
- GetBoundingVolume().Merge(converted);
+ __boundingVolume.Merge(converted);
}
}
}
while(pVEImplParent != null && pVEImplParent != pVEImplChild)
{
- pVEImplParent->GetBoundingVolume().Reset();
+ pVEImplParent->__boundingVolume.Reset();
//Mesh BV add
Mesh* pMesh = pVEImplParent->GetSharedData().geometry.GetMesh();
if (pMesh != null)
{
- pVEImplParent->GetBoundingVolume().Merge(pMesh->GetBoundingVolume());
+ pVEImplParent->__boundingVolume.Merge(pMesh->GetBoundingVolume());
}
//Children BV add
int count = pVEImplParent->__children.GetCount();
if (converted.GetState() == BOUNDING_VOLUME_STATE_VALID)
{
converted.Transform(pChild->GetMatrixToSuper());
- pVEImplParent->GetBoundingVolume().Merge(converted);
+ pVEImplParent->__boundingVolume.Merge(converted);
}
}
}
if (converted.GetState() == BOUNDING_VOLUME_STATE_VALID)
{
converted.Transform(pVEImplChild->GetMatrixToSuper());
- pVEImplParent->GetBoundingVolume().Merge(converted);
+ pVEImplParent->__boundingVolume.Merge(converted);
}
pVEImplChild = pVEImplParent;
}
result
-_VisualElementImpl::AdjustBoundingVolume()
+_VisualElementImpl::AdjustBoundingVolume(void)
{
result r = E_SUCCESS;
return r;
}
-BoundingVolume&
-_VisualElementImpl::GetBoundingVolume()
+const BoundingVolume&
+_VisualElementImpl::GetBoundingVolume(void) const
{
return __boundingVolume;
}
pairList.Construct();
pairList.RemoveAll();
- GetChildListAtI(point, pairList);
+ _Ray globalRay;
+ globalRay.MakeRayGlobal(this, point);
+
+ GetChildListAtI(point, globalRay, pairList);
//sort by float
Tizen::Base::Collection::IComparerT< Tizen::Base::Collection::MapEntryT< float, VisualElement* > >* pPairComparer = new IntersectedPairComparer();
}
result
-_VisualElementImpl::GetChildListAtI(const Tizen::Graphics::FloatPoint point, Tizen::Base::Collection::ArrayListT < Tizen::Base::Collection::MapEntryT < float, VisualElement* > >& pairList)
+_VisualElementImpl::GetChildListAtI(const Tizen::Graphics::FloatPoint point, const _Ray& globalRay, Tizen::Base::Collection::ArrayListT < Tizen::Base::Collection::MapEntryT < float, VisualElement* > >& pairList)
{
int count = __children.GetCount();
_VisualElementImpl* pChild = null;
pChild->__pNearestVEImpl = null;
pChild->__nearestDistance = std::numeric_limits<float>::infinity();
- if (pChild->HitTestI(localPoint) == HITTEST_MATCH)
+ if (pChild->HitTestI(localPoint, globalRay) == HITTEST_MATCH)
{
pairList.Add(Tizen::Base::Collection::MapEntryT < float, VisualElement* >(pChild->__nearestDistance, pChild->GetPublic()) );
}
- pChild->GetChildListAtI(localPoint, pairList);
+ pChild->GetChildListAtI(localPoint, globalRay, pairList);
}
}
Tizen::Base::Collection::IList*
_VisualElementImpl::GetChildListAtN(const Tizen::Graphics::FloatRectangle& selection, VisualElement::SelectionMode mode)
{
-
+ if (selection.width <= 0.0f || selection.height <= 0.0f)
+ return null;
int j;
//make global selection
}
int
+_VisualElementImpl::InvokeHitTest(const Tizen::Graphics::FloatPoint& point, const _Ray& globalRay)
+{
+ return HitTestI(point, globalRay);
+}
+
+int
_VisualElementImpl::InvokeHitTest(const Tizen::Graphics::FloatPoint& point)
{
int hitTest = _VisualElementImpl::HITTEST_NOWHERE;
result AdjustBoundingVolume(bool rebuild);
BoundingVolume& GetBoundingVolume(void);
-// Tizen::Graphics::FloatPoint3 GetBoundingBoxPosition(void) const;
-// float GetBoundingBoxVolume(void) const;
-// float GetBoundingBoxWidth(void) const;
-// float GetBoundingBoxHeight(void) const;
+
// 임시 함수
result AllocVertices(int count);
virtual result SetProperty(const Tizen::Base::String& name, const Variant& value);
virtual Variant GetProperty(const Tizen::Base::String& name) const;
+ std::string GetName(void) const
+ {
+ return __name;
+ }
- result SaveMeshToBin(const Tizen::Base::String& fileName);
+ result SaveMeshToBinary(const Tizen::Base::String& fileName);
MeshController* CreateMeshController(_JointImpl* pRootJoint, const Tizen::Graphics::FloatMatrix4& bindShapeMatrix);
int __countOfIndex;
int __countOfAllocatedIndex;
- // bounding box
-// Tizen::Graphics::FloatPoint3 __boundingBox;
-// float __boundingBoxVolume;
-// float __boundingBoxWidth;
-// float __boundingBoxHeight;
-//
- bool __hasBoundingVolume;
BoundingVolume __boundingVolume;
// temp pos
*/
int HitTestI(const Tizen::Graphics::FloatPoint& point);
+ /**
+ * The hit testing by 3D meshes and 2D controls by bounds.
+ *
+ * @since 3.0
+ * @return hit test result.
+ * @param[in] point hit test position.
+ * @see InvokeHitTest()
+ */
+ int HitTestI(const Tizen::Graphics::FloatPoint& point, const _Ray& globalRay);
+
/**
* The creating animation for the property.
Material* GetMaterialN(void) const;
result SetShaderProgram(ShaderProgram* pShaderProgram);
- ShaderProgram* GetShaderProgram(void) const;
+ ShaderProgram* GetShaderProgramN(void) const;
protected:
void InvokeOnBoundsChanged(const Tizen::Graphics::FloatRectangle& oldBounds);
/**
+ * For checking that point is in the VisualElement region or in region of it's meshes.
+ *
+ * @since 3.0
+ * @param[in] point the point to check in self coordinate system.
+ *
+ */
+ int InvokeHitTest(const Tizen::Graphics::FloatPoint& point, const _Ray& globalRay);
+
+ /**
* For checking that point is in the VisualElement region.
*
* @since 2.0
void GetDrawableRect(Tizen::Graphics::FloatRectangle& bounds) const;
const Tizen::Graphics::FloatRectangle& GetBoundingBoxI(void) const;
+public:
const Tizen::Graphics::FloatMatrix4& GetMatrixToSuper(void) const;
const Tizen::Graphics::FloatMatrix4& GetMatrixToTop(void) const;
const Tizen::Graphics::FloatMatrix4& GetMatrixFromTop(void) const;
+private:
Tizen::Graphics::FloatMatrix4 CalcMatrixToBase(const _VisualElementImpl& base) const;
const Tizen::Graphics::FloatMatrix4& GetMatrixToClipSource(void) const;
int GetZOrderGroupIndex(int orderGroup, int& begin, int& end) const;
result ChangeZOrder(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above, int zorderGroup);
- _VisualElementImpl* GetChildAtPointI(const Tizen::Graphics::FloatPoint& point, int parentHitTest);
+ _VisualElementImpl* GetChildAtPointI(const Tizen::Graphics::FloatPoint& point, const _Ray& globalRay, int parentHitTest);
result AddAnimationI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation);
result AddAnimationGroupI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation);
//Visual Element Bounding volume related
result AdjustBoundingVolume(void);
- BoundingVolume& GetBoundingVolume(void);
+ const BoundingVolume& GetBoundingVolume(void) const;
//Picking instruments
Tizen::Base::Collection::IList* GetChildListAtN(const Tizen::Graphics::FloatPoint& point);
- result GetChildListAtI(const Tizen::Graphics::FloatPoint point, Tizen::Base::Collection::ArrayListT<Tizen::Base::Collection::MapEntryT < float, VisualElement* > >& pairList);
+ result GetChildListAtI(const Tizen::Graphics::FloatPoint point, const _Ray& globalRay, Tizen::Base::Collection::ArrayListT<Tizen::Base::Collection::MapEntryT < float, VisualElement* > >& pairList);
Tizen::Base::Collection::IList* GetChildListAtN(const Tizen::Graphics::FloatRectangle& selection, VisualElement::SelectionMode mode);
result GetSelectedI(const Tizen::Ui::Animations::_Selection& selection, VisualElement::SelectionMode mode, Tizen::Base::Collection::IList& list);
//Visual Element Bounding volume related
BoundingVolume __boundingVolume;
- _Ray __globalRay;
- bool __hasGlobalRay;
+// _Ray __globalRay;
+// bool __hasGlobalRay;
float __nearestDistance;
_VisualElementImpl* __pNearestVEImpl;