--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2013-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.
+
+/*
+ * FUiAnimBoundingVolume.h
+ *
+ * Created on: Sep 20, 2013
+ * Author: youri
+ */
+
+/**
+ * @file FUiAnimBoundingVolume.h
+ * @brief This is the header file for the BoundingVolume class.
+ *
+ * This header file contains the declarations of the BoundingVolume class.
+ */
+
+#ifndef _FUI_ANIM_BOUNDING_VOLUME_H_
+#define _FUI_ANIM_BOUNDING_VOLUME_H_
+
+#include "FGrpFloatPoint3.h"
+#include "FGrpFloatMatrix4.h"
+#include <FBaseColArrayListT.h>
+
+namespace Tizen { namespace Graphics {
+class FloatPoint;
+}}
+
+//namespace Tizen { namespace Base {
+//class Object;
+//
+////namespace Collection {
+////class ArrayListT<Tizen::Graphics::FloatPoint3>;
+////}
+//}}
+
+
+namespace Tizen { namespace Ui { namespace Animations
+{
+
+/** @enum BoundingVolumeState
+ *
+ * Defines possible states of BoundingVolume
+ *
+ * @since 3.0
+ * @see BoundingVolume::GetState()
+ */
+enum BoundingVolumeState
+{
+ BOUNDING_VOLUME_STATE_EMPTY, /**< No points merged in BoundingVolume - Empty*/
+ BOUNDING_VOLUME_STATE_ONE_POINT, /**< One merged - one point*/
+ BOUNDING_VOLUME_STATE_VALID /**< Two and more - valid */
+};
+
+/** @enum BoundingVolumeType
+ *
+ * Defines possible types of Bounding Volume
+ *
+ * @since 3.0
+ * @see BoundingVolume::SetType()
+ * @see BoundingVolume::GetType()
+ * @see BoundingVolume::Construct()
+ */
+enum BoundingVolumeType
+{
+ BOUNDING_VOLUME_TYPE_AABB, /**< Type Axis Aligned Bounding Box */
+ BOUNDING_VOLUME_TYPE_SPHERE /**< Type Sphere */
+};
+
+/**
+ * @class BoundingVolume
+ * @brief This class describes bounding volume of 3D object like Mesh or VisualElement
+ *
+ * @since 3.0
+ *
+ * @final This class is not intended for extension.
+ * @see Mesh
+ * @see VisualElement
+ *
+ * The %BoundingVolume describes bounding volume and intersection operations
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/animations/BoundingBox.htm">Animating UI Controls</a>.
+ *
+ */
+
+class _BoundingVolumeImpl;
+
+class _OSP_EXPORT_ BoundingVolume
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor of this class
+ *
+ * @since 3.0
+ *
+ * @remarks Supplies different types of bounding volume, default is AABB
+ */
+ BoundingVolume();
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 3.0
+ */
+ virtual ~BoundingVolume(void);
+
+ /**
+ * Initializes this instance of %BoundingVolume of AABB type with the specified parameters.
+ *
+ * @since 3.0
+ *
+ * @param[in] min minimum point of this box
+ * @param[in] max maximum point of this box
+ * @exception E_INVALID_ARG any min component bigger then max component
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ BoundingVolume(const Tizen::Graphics::FloatPoint3& min, const Tizen::Graphics::FloatPoint3& max);
+ /**
+ * Initializes this instance of %BoundingVolume of SPHERE type with the specified parameters.
+ *
+ * @since 3.0
+ *
+ * @param[in] min center of bounding sphere
+ * @param[in] max radius of bounding sphere
+ * @exception E_INVALID_ARG radius lower cant be lower than zero
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ BoundingVolume(const Tizen::Graphics::FloatPoint3& center, float radius);
+
+ /**
+ * Reinitializes this instance of %BoundingVolume of AABB type with the specified parameters.
+ *
+ * @since 3.0
+ *
+ * @param[in] min minimum point of this box
+ * @param[in] max maximum point of this box
+ * @exception E_INVALID_ARG any min component bigger then max component
+ * @return self reference
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ BoundingVolume& Set(const Tizen::Graphics::FloatPoint3& min, const Tizen::Graphics::FloatPoint3& max);
+ /**
+ * Reinitializes this instance of %BoundingVolume of SPHERE type with the specified parameters.
+ *
+ * @since 3.0
+ *
+ * @param[in] center center of bounding sphere
+ * @param[in] radius radius of bounding sphere
+ * @exception E_INVALID_ARG radius lower cant be lower than zero
+ * @return self reference
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ BoundingVolume& Set(const Tizen::Graphics::FloatPoint3& center, float radius);
+
+ /**
+ * Returns center point of BoundingVolume
+ *
+ * @since 3.0
+ *
+ * @return center point of BoundingVolume
+ */
+ Tizen::Graphics::FloatPoint3 GetCenter() const;
+
+ /**
+ * Returns vector, specifying half size of this _BoundingVolumeImpl
+ *
+ * @since 3.0
+ *
+ * @return vector of 3 coordinates, specifying half size of this _BoundingVolumeImpl
+ */
+ Tizen::Graphics::FloatPoint3 GetHalfSize() const;
+
+ /**
+ * Gets minimum and maximum point of AABB bounding volume
+ *
+ * @since 3.0
+ *
+ * @param[out] min minimum point of this box
+ * @param[out] max maximum point of this box
+ * @exception E_INVALID_ARG wrong bounding volume type
+ * @return an result code
+ */
+ result Get(Tizen::Graphics::FloatPoint3& min, Tizen::Graphics::FloatPoint3& max) const;
+
+ /**
+ * Gets center and radius of SPHERE bounding volume
+ *
+ * @since 3.0
+ *
+ * @param[in] center center of bounding sphere
+ * @param[in] radius radius of bounding sphere
+ * @exception E_INVALID_ARG wrong bounding volume type
+ * @return an result code
+ */
+ result Get(Tizen::Graphics::FloatPoint3& center, float& radius) const;
+
+ /**
+ * Adds volume of specified BoundingVolume to this BoundingVolume
+ *
+ * @since 3.0
+ *
+ * @return result code
+ * @param[in] box box to merge to this box
+ * @exception E_INVALID_ARG given box state is not valid
+ */
+ result Merge(const BoundingVolume& volume);
+
+ /**
+ * Adds specified point to this BoundingVolume
+ *
+ * @since 3.0
+ *
+ * @param[in] point point to merge this volume to
+ */
+ result Merge(const Tizen::Graphics::FloatPoint3& point);
+
+ /** Adds specified vector of points to this BoundingVolume
+ *
+ * @since 3.0
+ *
+ * @return result code
+ * @param[in] Vertex coordinates of points in ArrayListT<FloatPoint3> to merge to this volume,
+ * @exception E_INVALID_ARG Vertex size == 0
+ */
+ result Merge(const Tizen::Base::Collection::ArrayListT<Tizen::Graphics::FloatPoint3>& vertexes);
+
+ /**
+ * Translates this BoundingVolume by specified transformation (extracts translation)
+ *
+ * @since 3.0
+ *
+ * @return result code
+ * @param[in] world translation to apply to this box
+ * @exception E_FAILURE box state is not valid
+ */
+ result Translate(const Tizen::Graphics::FloatMatrix4& translateMatrix);
+
+ /**
+ * Transforms this BoundingVolume by specified transformation
+ *
+ * @since 3.0
+ *
+ * @param[in] world transformation to apply to this box
+ * @remarks Rotates Bounding Volume and counts a new one containing rotated one
+ */
+ result Transform(const Tizen::Graphics::FloatMatrix4& transformMatrix);
+
+
+ /**
+ * Returns this BoundingVolume to empty state
+ *
+ * @since 3.0
+ *
+ * @remarks Clear all parameters except type of BoundingVolumeType
+ */
+ void Reset();
+
+ /**
+ * Checks is supplied volume twice less then this
+ *
+ * @since 3.0
+ *
+ * @return result code
+ * @param[in] volume box to check
+ * @param[in] is is supplied box twice less then this
+ * @exception E_INVALID_ARG given volume state is not valid or of another type
+ */
+ result IsBoxTwiceLess(const BoundingVolume& volume, bool& is);
+
+ /**
+ * Get the bounding volume state _BoundingVolumeImpl
+ *
+ * @since 3.0
+ *
+ * @return bounding volume state as in BoundingVolumeState
+ */
+ BoundingVolumeState GetState() const;
+
+ /**
+ * Get the bounding volume type
+ *
+ * @since 3.0
+ *
+ * @return bounding volume type as in BoundingVolumeType
+ */
+ BoundingVolumeType GetType() const;
+
+ /**
+ * Set the bounding volume type
+ *
+ * @since 3.0
+ *
+ * @param[in] type type to convert in
+ * @return result code
+ * @remark Converts a bounding volume type basic on its contents.
+ * To get more accurate bounding volume, refresh it through the owning mesh
+ * or reset values and merge again with an specific points
+ * @see Mesh::AdjustBoundingVolume()
+ * @see Reset()
+ * @see Merge()
+ */
+ result SetType(BoundingVolumeType type);
+
+ /**
+ * Assigns the value of the specified instance to the current instance of %BoundingVolume.
+ *
+ * @since 3.0
+ *
+ * @param[in] rhs An instance of %BoundingVolume
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ BoundingVolume& operator =(const BoundingVolume& rhs);
+
+
+ /**
+ * Checks whether the specified instance and current instance of %BoundingVolume have equal values.
+ *
+ * @since 3.0
+ *
+ * @return @c true if the Bounding Volume of the two instances of %BoundingVolume are equal, @n
+ * else @c false
+ * @param[in] rhs An instance of %FloatAnimation
+ */
+ bool operator ==(const BoundingVolume& rhs) const;
+
+
+ /**
+ * Checks whether the specified instance and current instance of %BoundingVolume have different values.
+ *
+ * @since 3.0
+ *
+ * @return @c true if the values of the two instances of %BoundingVolume are not equal, @n
+ * else @c false
+ * @param[in] rhs An instance of %BoundingVolume
+ */
+ bool operator !=(const BoundingVolume& rhs) const;
+
+
+ /**
+ * Checks whether the value of the current instance of %BoundingVolume equals the value of the specified instance.
+ *
+ * @since 3.0
+ *
+ * @return @c true if the value of the current instance equals the value of the specified instance, @n
+ * else @c false
+ * @param[in] obj An instance of %BoundingVolume
+ * @remarks The %BoundingVolume class has a semantic value. @n
+ * This means that this method checks whether the two instances have the same values.
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @since 3.0
+ *
+ * @return The hash value of the current instance
+ * @remarks The two equal instances must return the same hash value. For better performance, the used hash function must generate a random distribution
+ * for all inputs.
+ */
+ virtual int GetHashCode(void) const;
+
+protected:
+ // impl pointer
+ _BoundingVolumeImpl* _pBoundingVolumeImpl;
+
+ friend class _BoundingVolumeImpl;
+ friend class _Ray;
+}; // BoundingVolume
+
+
+}}} //Tizen::Ui::Animations
+
+#endif /* _FUI_ANIM_BOUNDING_VOLUME_H_ */
#include <FBaseObject.h>
#include <FBaseColArrayListT.h>
-#include "FGrpFloatPoint.h"
-#include "FGrpFloatPoint3.h"
-#include "FGrpColor.h"
-
+namespace Tizen { namespace Graphics{
+class FloatPoint;
+class FloatPoint3;
+class Color;
+}}
namespace Tizen { namespace Ui { namespace Animations{
+class BoundingVolume;
+
class _OSP_EXPORT_ Mesh : public Tizen::Base::Object
{
public:
* @see SetVertex()
*/
Tizen::Graphics::FloatPoint3 GetVertex(int arrayIndex) const;
+
/**
* Gets the count of vertex used
*
*/
int GetVertexCount() const;
+
/**
* Replaces the texture coordinate at the specified @c index with the specified value.
*
* @see SetIndex()
*/
int GetIndex(int arrayIndex) const;
+
/**
* Gets the count of index used
*
* @return An error code
* @param[in] rebuild rebuild flag @n
* @exception E_SUCCESS The method is successful.
- * @see GetBoundingBoxPosition()
- * @see GetBoundingBoxVolume()
- * @see GetBoundingBoxWidth()
- * @see GetBoundingBoxHeight()
+ * @see BoundingVolume
*
*/
- result AdjustBoundingBox(bool rebuild = false);
+ result AdjustBoundingVolume(bool rebuild = false);
/**
*
*/
void Clear();
+ /**
+ * Get bounding volume of this mesh instance.
+ *
+ * @since 3.0
+ *
+ * @return BoundingVolume
+ * @exception E_SUCCESS The method is successful.
+ * @see BoundingVolume
+ */
+ BoundingVolume& GetBoundingVolume();
- Tizen::Graphics::FloatPoint3 GetBoundingBoxPosition() const;
- float GetBoundingBoxLength() const;
- float GetBoundingBoxWidth() const;
- float GetBoundingBoxHeight() const;
+// Tizen::Graphics::FloatPoint3 GetBoundingBoxPosition() const;
+// float GetBoundingBoxLength() const;
+// float GetBoundingBoxWidth() const;
+// float GetBoundingBoxHeight() const;
// 임시 함수
result ReserveVertices(int count);
result ReserveTextureCoordinates();
result ReserveNormals();
result ReserveColors();
+ result SaveMesh(const Tizen::Base::String& fileName);
bool IsIndexEnabled() const;
bool IsTextureCoordinateEnabled() const;
void SetName(Tizen::Base::String name);
Tizen::Base::String GetName();
+
private:
class _MeshImpl* __pMeshImpl;
+//
+// 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 FUiAnimModelImporter.h
+ * @brief This is the header file for the ModelImporter class.
+ *
+ * This header file contains the declarations of the ModelImporter class.
+ */
+
#ifndef _FUI_ANIM_MODEL_IMPORTER_H_
#define _FUI_ANIM_MODEL_IMPORTER_H_
BIN
};
- static Mesh* LoadMeshN(MODEL_FORMAT modelFormat, const Tizen::Base::String& fileName, const Tizen::Base::String& modelName, bool tcoords, bool norms);
+ /**
+ * Load mesh from file.
+ *
+ * @since 3.0
+ *
+ * @return New mesh object
+ * @param[in] modelFormat Format of file(COLLADA or Binary)
+ * @param[in] fileName Name of file
+ * @param[in] modelName Id of geometry in COLLADA file
+ * @param[in] inverseY Flip model vertically
+ *
+ */
+ static Mesh* LoadMeshN(MODEL_FORMAT modelFormat, const Tizen::Base::String& fileName, const Tizen::Base::String& modelName, bool inverseY = true);
+
+ /**
+ * Load material from file.
+ *
+ * @since 3.0
+ *
+ * @return New Material object
+ * @param[in] fileName Name of file
+ * @param[in] modelName Id of material in COLLADA file
+ * @param[out] textureName Name of the image file that is used as a texture(if it exist)
+ */
static Material* LoadMaterialN(const Tizen::Base::String& fileName, const Tizen::Base::String& materialName, Tizen::Base::String* textureName);
- static Scene* LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base::String& sceneName);
+
+ /**
+ * Load scene from file.
+ *
+ * @since 3.0
+ *
+ * @return Scene object
+ * @param[in] fileName Name of file
+ * @param[in] sceneName Id of scene in COLLADA file
+ * @param[in] inverseY Flip model vertically
+ */
+ static Scene* LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base::String& sceneName, bool inverseY = true);
private:
- ModelImporter();
- virtual ~ModelImporter();
+ ModelImporter(void);
+ virtual ~ModelImporter(void);
};
}}}
+//
+// 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 FUiAnimScene.h
+ * @brief This is the header file for the Scene class.
+ *
+ * This header file contains the declarations of the Scene class.
+ */
+
#ifndef _FUI_ANIM_SCENE_H_
#define _FUI_ANIM_SCENE_H_
: public Tizen::Base::Object
{
public:
- Scene();
- virtual ~Scene();
+ Scene(void);
+ virtual ~Scene(void);
+ /**
+ * Returns pointer to the root element of the scene tree
+ *
+ * @since 3.0
+ *
+ * @return Pointer to root VisualElement
+ */
VisualElement* GetRootVisualElement(void) const;
+ /**
+ * Adding a new mesh object to the scene
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @param[in] pMesh Pointer to mesh object
+ */
result AddMesh(Mesh* pMesh);
+
+ /**
+ * Deleting a mesh object from the scene
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @param[in] meshName Name of mesh object
+ */
result RemoveMesh(Tizen::Base::String meshName);
- Mesh* GetMesh(Tizen::Base::String meshName) const;
- Tizen::Base::Collection::ArrayList* GetMeshNamesN() const;
+ /**
+ * Gets a pointer to the mesh in scene
+ *
+ * @since 3.0
+ *
+ * @return Pointer to the mesh object
+ * @param[in] meshName Name of mesh object
+ */
+ Mesh* GetMeshN(Tizen::Base::String meshName) const;
+
+ /**
+ * Gets a list of names of all meshes in scene
+ *
+ * @since 3.0
+ *
+ * @return Pointer to the ArrayList
+ */
+ Tizen::Base::Collection::ArrayList* GetMeshNamesN(void) const;
+
+ /**
+ * Adding a new material object to the scene
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @param[in] pMaterial Pointer to material object
+ */
result AddMaterial(Material* pMaterial);
+
+ /**
+ * Deleting a material object from the scene
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @param[in] materialName Name of material object
+ */
result RemoveMaterial(Tizen::Base::String materialName);
- Material* GetMaterial(Tizen::Base::String materialName) const;
- Tizen::Base::Collection::ArrayList* GetMaterialNamesN() const;
+ /**
+ * Gets a pointer to the material in scene
+ *
+ * @since 3.0
+ *
+ * @return Pointer to the material object
+ * @param[in] materialName Name of material object
+ */
+ Material* GetMaterialN(Tizen::Base::String materialName) const;
+
+ /**
+ * Gets a list of names of all materials in scene
+ *
+ * @since 3.0
+ *
+ * @return Pointer to the ArrayList
+ */
+ Tizen::Base::Collection::ArrayList* GetMaterialNamesN(void) const;
+
+ /**
+ * Adding a texture file name
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @param[in] textureFileName Name of texture file
+ */
result AddTextureFileName(Tizen::Base::String textureFileName);
- Tizen::Base::Collection::ArrayList* GetTextureFileNamesN() const;
+
+ /**
+ * Gets a list of texture file names
+ *
+ * @since 3.0
+ *
+ * @return Pointer to the ArrayList
+ */
+ Tizen::Base::Collection::ArrayList* GetTextureFileNamesN(void) const;
protected:
_SceneImpl* _pSceneImpl;
-
- friend class __SceneImpl;
};
}}} //Tizen::Ui::Animations
namespace Tizen { namespace Ui { namespace Animations
{
-
-class _ShaderImpl;
-
class _OSP_EXPORT_ Shader
: public Tizen::Base::Object
{
Shader& operator =(const Shader& rhs);
// need it?
- _ShaderImpl* _pShaderImpl;
+ class _ShaderImpl* __pShaderImpl;
friend class _ShaderImpl;
};
* @file FUiAnimShaderProgram.h
* @brief This is the header file for the ShaderProgram class.
*
+ * List of predefined attributes and uniforms names:
+ *
+ * "u_mvp",
+ * "u_color",
+ * "u_tex2d",
+ * "u_opacity",
+ * "u_modelview",
+ * "u_inv_modelview",
+ * "u_lighttype",
+ * "u_light.type",
+ * "u_lightambient",
+ * "u_light.ambient",
+ * "u_lightdiffuse",
+ * "u_light.diffuse",
+ * "u_lightspecular",
+ * "u_light.specular",
+ * "u_lightposition",
+ * "u_light.position",
+ * "u_lightdirectional",
+ * "u_light.directional",
+ * "u_lightexponent",
+ * "u_light.exponent",
+ * "u_lightcutoff",
+ * "u_light.cutoff",
+ * "u_lightattenuation",
+ * "u_light.attenuation",
+ * "u_materialambient",
+ * "u_material.ambient",
+ * "u_materialdiffuse",
+ * "u_material.diffuse",
+ * "u_materialspecular",
+ * "u_material.specular",
+ * "u_materialemissive",
+ * "u_material.emissive",
+ * "u_materialshininess",
+ * "u_material.shininess",
+ * "a_texcoord",
+ * "a_position",
+ * "a_color",
+ * "a_normal",
+ *
* This header file contains the declarations of the ShaderProgram class.
*/
#include <FBaseObject.h>
-namespace Tizen { namespace Base {
-class String;
-}}
+#include <FUiVariant.h>
-namespace Tizen { namespace Ui {
-class Variant;
-}}
+#include <FUiAnimShader.h>
namespace Tizen { namespace Ui { namespace Animations
{
-class Shader;
-/**
- * @enum ProgramLocation
- *
- * Defines the basic types for program location in shader program.
- *
- * @since 3.0
- */
-enum ProgramLocation
- {
- UNIFORM_MAT4_MVP = 0, /**< Uniform for matrix view projection*/
- UNIFORM_VEC4_COLOR, /**< Uniform for color*/
- UNIFORM_SAMPLER2D_TEXTURE, /**< Uniform for texture*/
- UNIFORM_FLOAT_OPACITY, /**< Uniform for opacity*/
- UNIFORM_MAT4_MODEL_VIEW, /**< Uniform for model view matrix*/
- UNIFORM_MAT4_INV_MODEL_VIEW, /**< Uniform for inverted model view*/
- UNIFORM_INT_LIGHT_TYPE, /**< Uniform for light type*/
- UNIFORM_INT_LIGHT_STRUCT_TYPE, /**< Uniform for light type defined in struct*/
- UNIFORM_VEC4_LIGHT_AMBIENT, /**< Uniform for light ambient*/
- UNIFORM_VEC4_LIGHT_STRUCT_AMBIENT, /**< Uniform for light ambient defined in struct*/
- UNIFORM_VEC4_LIGHT_DIFFUSE, /**< Uniform for light diffuse*/
- UNIFORM_VEC4_LIGHT_STRUCT_DIFFUSE, /**< Uniform for light diffuse defined in struct*/
- UNIFORM_VEC4_LIGHT_SPECULAR, /**< Uniform for light specular*/
- UNIFORM_VEC4_LIGHT_STRUCT_SPECULAR, /**< Uniform for light specular defined in struct*/
- UNIFORM_VEC4_LIGHT_POSITION, /**< Uniform for light position*/
- UNIFORM_VEC4_LIGHT_STRUCT_POSITION, /**< Uniform for light position defined in struct*/
- UNIFORM_VEC3_LIGHT_DIRECTION, /**< Uniform for light direction*/
- UNIFORM_VEC3_LIGHT_STRUCT_DIRECTION, /**< Uniform for light direction defined in struct */
- UNIFORM_FLOAT_LIGHT_EXPONENT, /**< Uniform for light exponent*/
- UNIFORM_FLOAT_LIGHT_STRUCT_EXPONENT, /**< Uniform for light exponent defined in struct*/
- UNIFORM_FLOAT_LIGHT_CUTOFF, /**< Uniform for light cutoff*/
- UNIFORM_FLOAT_LIGHT_STRUCT_CUTOFF, /**< Uniform for light cutoff defined in struct*/
- UNIFORM_VEC3_LIGHT_ATTENUATION, /**< Uniform for light attenuation*/
- UNIFORM_VEC3_LIGHT_STRUCT_ATTENUATION, /**< Uniform for light attenuation defined in struct*/
- UNIFORM_VEC4_MATERIAL_AMBIENT, /**< Uniform for material ambient*/
- UNIFORM_VEC4_MATERIAL_STRUCT_AMBIENT, /**< Uniform for material ambient defined in struct*/
- UNIFORM_VEC4_MATERIAL_DIFFUSE, /**< Uniform for material diffuse*/
- UNIFORM_VEC4_MATERIAL_STRUCT_DIFFUSE, /**< Uniform for material diffuse defined in struct*/
- UNIFORM_VEC4_MATERIAL_SPECULAR, /**< Uniform for material specular*/
- UNIFORM_VEC4_MATERIAL_STRUCT_SPECULAR, /**< Uniform for material specular defined in struct*/
- UNIFORM_VEC4_MATERIAL_EMISSIVE, /**< Uniform for material emissive*/
- UNIFORM_VEC4_MATERIAL_STRUCT_EMISSIVE, /**< Uniform for material emissive defined in struct*/
- UNIFORM_FLOAT_MATERIAL_SHININESS, /**< Uniform for material shininess*/
- UNIFORM_FLOAT_MATERIAL_STRUCT_SHININESS, /**< Uniform for material shininess defined in struct*/
- ATTRIBUTE_VEC2_TEXTURE_COORD, /**< Attribute for texture coordinate*/
- ATTRIBUTE_VEC4_POSITION, /**< Attribute for position*/
- ATTRIBUTE_VEC4_COLOR, /**< Attribute for color*/
- ATTRIBUTE_VEC3_NORMAL, /**< Attribute for normal*/
- PROGRAM_LOCATION_MAX /**< Maximum of program location*/
- };
+//class VisualElementSurface;
+
class _ShaderProgramImpl;
class _OSP_EXPORT_ ShaderProgram
*/
result Construct(Shader& vertexShader, Shader& fragmentShader);
+ /**
+ * Gets the value of uniform by name of the current instance of %ShaderProgram
+ *
+ * @since 3.0
+ *
+ * @return Current value of requested uniform or empty Variant
+ *
+ * @param[in] name uniform name in shader program
+ *
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG if name of uniform was not found in shader program
+ */
Variant GetUniform(const Tizen::Base::String& name) const;
+
+ /**
+ * Sets the value for uniform by name of the current instance of %ShaderProgram
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ *
+ * @param[in] name uniform name in ShaderProgram
+ * @param[in] value data for this uniform
+ *
+ * @exception E_SUCCESS
+ * @exception E_INVALID_ARG if name of uniform was not found in shader program or it is a predefined name
+ * @see List of predefined attributes and uniform names.
+ */
result SetUniform(const Tizen::Base::String& name, const Tizen::Ui::Variant& value);
/**
* @exception E_INVALID_ARG if name was not found in shader program
* @see ProgramLocation
*/
- result BindAttribute(ProgramLocation location, const Tizen::Base::String &name);
+ //result BindAttribute(ProgramLocation location, const Tizen::Base::String &name);
/**
* Binds the uniform to the ShaderProgram.
* @exception E_INVALID_ARG if name was not found in shader program
* @see ProgramLocation
*/
- result BindUniform(ProgramLocation location, const Tizen::Base::String &name);
+ //result BindUniform(ProgramLocation location, const Tizen::Base::String &name);
/**
* Checks the program location for been bind with uniform or attribute in shader program
* @param[in] location requested location
* @see ProgramLocation
*/
- bool IsParameterAvailable(const ProgramLocation location) const;
+ //bool IsParameterAvailable(const ProgramLocation location) const;
/**
* Checks for the uniform or attribute by name in shader program been bind with program location
*
* @param[in] name Tizen::Base::String name of the uniform or attribute in shader program
*/
- bool IsParameterAvailable(const Tizen::Base::String& name) const;
+ //bool IsParameterAvailable(const Tizen::Base::String& name) const;
/**
* Unbind an attribute from the ShaderProgram.
* @exception E_SUCCESS
* @exception E_INVALID_ARG if name was not found in shader program
*/
- result UnbindUniform(const Tizen::Base::String &name);
+ //result UnbindUniform(const Tizen::Base::String &name);
/**
* Unbind an uniform from the ShaderProgram.
* @exception E_SUCCESS
* @exception E_INVALID_ARG if name was not found in shader program
*/
- result UnbindAttribute(const Tizen::Base::String &name);
+ //result UnbindAttribute(const Tizen::Base::String &name);
+
+ //void SetUserData(const Tizen::Base::String& name, const Tizen::Ui::Variant& value);
+ //void SetUserSampler(const Tizen::Base::String& name, Tizen::Ui::Animations::VisualElementSurface* pSurface);
private:
+
ShaderProgram(const ShaderProgram& program);
ShaderProgram& operator =(const ShaderProgram& rhs);
- _ShaderProgramImpl* _pShaderProgramImpl;
+ class _ShaderProgramImpl* __pShaderProgramImpl;
friend class _ShaderProgramImpl;
};
/usr/include/osp/security
/usr/include/osp/system
/usr/include/osp/uix
+
+ ./animations/math/mesh/mesh-simplification
)
SET (${this_target}_SOURCE_FILES
# effects/physics-engine/FUiEffects_PeRodSurfaceNURBS.cpp
# effects/physics-engine/FUiEffects_PePointSurface.cpp
-## TouchEffect
- FUiTouchEffect.cpp
- FUi_TouchEffectImpl.cpp
-## End of TouchEffect
+#####################################################################################
+###########################Material & Light##########################################
+ animations/FUiAnimMaterial.cpp
+ animations/FUiAnimLight.cpp
+ animations/FUiAnim_MaterialImpl.cpp
+ animations/FUiAnim_LightImpl.cpp
+#####################################################################################
+#=====================================================
## IMPORT COLLADA
animations/import-collada/library-images/FUiAnim_ImportColladaLibImgLibraryImages.cpp
animations/import-collada/library-images/FUiAnim_ImportColladaLibImgImage.cpp
animations/FUiAnimModelImporter.cpp
#=====================================================
animations/FUiAnim_SceneImpl.cpp
- animations/FUiAnimScene.cpp
+ animations/FUiAnimScene.cpp
#=====================================================
animations/math/FUiAnim_MathAdapterFunctions.cpp
animations/math/FUiAnim_MathCommon.cpp
animations/math/FUiAnim_MathVector2.cpp
animations/math/FUiAnim_MathVector3.cpp
animations/math/FUiAnim_MathVector4.cpp
+
#=====================================================
- animations/FUiAnim_CustomShader.cpp
- animations/FUiAnim_GlDefaultShaderProgram.cpp
+#===================CustomShader======================
+# animations/FUiAnim_CustomShader.cpp #
+ animations/FUiAnim_GlDefaultShaderProgram.cpp #
#=====================================================
- animations/FUiAnimMaterial.cpp
- animations/FUiAnimLight.cpp
- animations/FUiAnim_MaterialImpl.cpp
- animations/FUiAnim_LightImpl.cpp
+#===================End CustomShader==================
+
+# animations/FUiAnimMeshGenerator.cpp
+#=====================================================
+# animations/FUiAnim_MeshGeneratorImpl.cpp
+# animations/FUiAnim_MeshGeneratorSquare.cpp
+# animations/FUiAnim_MeshGeneratorTriangle.cpp
+# animations/FUiAnim_MeshGeneratorCube.cpp
+# animations/FUiAnim_MeshGeneratorPyramid.cpp
+# animations/FUiAnim_MeshGeneratorCylinder.cpp
+# animations/FUiAnim_MeshGeneratorConiform.cpp
+# animations/FUiAnim_MeshGeneratorTruncatedPyramid.cpp
+# animations/FUiAnim_MeshGeneratorTorus.cpp
+# animations/FUiAnim_MeshGeneratorSphere.cpp
#=====================================================
- animations/FUiAnim_BoundingVolume.cpp
- animations/FUiAnim_Ray.cpp
+# animations/math/mesh/mesh-simplification/FUiAnim_MathMeshMeshSimplHalfEdge.cpp
+# animations/math/mesh/mesh-simplification/FUiAnim_MathMeshMeshSimplFaceHe.cpp
+# animations/math/mesh/mesh-simplification/FUiAnim_MathMeshMeshSimplVertexHe.cpp
+# animations/math/mesh/mesh-simplification/FUiAnim_MathMeshMeshSimplMeshSimplification.cpp
+# animations/math/mesh/mesh-simplification/FUiAnim_MathMeshMeshSimplMeshSimplifier.cpp
+#=====================================================
+ animations/FUiAnim_BoundingVolumeImpl.cpp
+ animations/FUiAnimBoundingVolume.cpp
+ animations/FUiAnim_Ray.cpp
+## TouchEffect
+ FUiTouchEffect.cpp
+ FUi_TouchEffectImpl.cpp
+## End of TouchEffect
)
INCLUDE(FindPkgConfig)
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2013-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.
+//
+/*
+ * FUiAnimBoundingVolume.cpp
+ *
+ * Created on: Sep 20, 2013
+ * Author: youri
+ */
+
+/**
+ * @file FUiAnimBoundingVolume.cpp
+ * @brief This file contains implementation of BoundingVolume class
+ *
+ * This file contains implementation BoundingVolume class.
+ */
+#include "FBaseErrors.h"
+#include "FBaseSysLog.h"
+#include "FUiAnimBoundingVolume.h"
+#include "FUiAnim_BoundingVolumeImpl.h"
+
+#include "math/FUiAnim_MathVector3.h"
+#include "math/FUiAnim_MathMatrix4.h"
+
+using namespace Tizen::Graphics;
+using namespace Tizen::Ui::Animations;
+
+namespace Tizen { namespace Ui { namespace Animations
+{
+
+BoundingVolume::BoundingVolume()
+ : _pBoundingVolumeImpl(null)
+{
+ _pBoundingVolumeImpl = new (std::nothrow) _BoundingVolumeImpl();
+
+ SysTryLog(NID_UI_ANIM, _pBoundingVolumeImpl != null, "[E_OUT_OF_MEMORY] Memory allocation failed while creating _BoundingVolumeImpl.");
+ SetLastResult(E_OUT_OF_MEMORY);
+ //SysTryLogExeption(NID_UI_ANIM, _pBoundingVolumeImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed while creating _BoundingVolumeImpl.");
+}
+
+BoundingVolume::~BoundingVolume(void)
+{
+ if(_pBoundingVolumeImpl != null)
+ {
+ delete _pBoundingVolumeImpl;
+ }
+}
+
+BoundingVolume::BoundingVolume(const Tizen::Graphics::FloatPoint3& min, const Tizen::Graphics::FloatPoint3& max)
+ : _pBoundingVolumeImpl(null)
+{
+ _Math::Vector3 minInternal(min.x,min.y,min.z);
+ _Math::Vector3 maxInternal(max.x,max.y,max.z);
+
+ _pBoundingVolumeImpl = new (std::nothrow) _BoundingVolumeImpl(minInternal,minInternal);
+
+ SysTryReturnVoidResult(NID_UI_ANIM, _pBoundingVolumeImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed while creating _BoundingVolumeImpl.");
+}
+
+BoundingVolume::BoundingVolume(const Tizen::Graphics::FloatPoint3& center, float radius)
+ : _pBoundingVolumeImpl(null)
+{
+ _Math::Vector3 centerInternal(center.x,center.y,center.z);
+
+ _pBoundingVolumeImpl = new (std::nothrow) _BoundingVolumeImpl(centerInternal,radius);
+
+ SysTryReturnVoidResult(NID_UI_ANIM, _pBoundingVolumeImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed while creating _BoundingVolumeImpl.");
+}
+
+BoundingVolume&
+BoundingVolume::Set(const Tizen::Graphics::FloatPoint3& min, const Tizen::Graphics::FloatPoint3& max)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _pBoundingVolumeImpl->Set(_Math::Vector3(min.x,min.y,min.z),_Math::Vector3(max.x,max.y,max.z));
+
+ return *this;
+}
+
+BoundingVolume&
+BoundingVolume::Set(const Tizen::Graphics::FloatPoint3& center, float radius)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _pBoundingVolumeImpl->Set(_Math::Vector3(center.x,center.y,center.z),radius);
+
+ return *this;
+}
+
+
+FloatPoint3
+BoundingVolume::GetCenter() const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _Math::Vector3 center = _pBoundingVolumeImpl->GetCenter();
+
+ return FloatPoint3(center.x,center.y,center.z);
+}
+
+FloatPoint3
+BoundingVolume::GetHalfSize() const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _Math::Vector3 halfSize = _pBoundingVolumeImpl->GetHalfSize();
+
+ return FloatPoint3(halfSize.x,halfSize.y,halfSize.z);
+}
+
+result
+BoundingVolume::Get(Tizen::Graphics::FloatPoint3& min, Tizen::Graphics::FloatPoint3& max) const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _Math::Vector3 _min, _max;
+ result r = _pBoundingVolumeImpl->Get(_min,_max);
+
+ if(r == E_SUCCESS)
+ {
+ min.x = _min.x; min.y = _min.y; min.z = _min.z;
+ max.x = _max.x; max.y = _max.y; max.z = _max.z;
+ }
+
+ return r;
+}
+
+result
+BoundingVolume::Get(Tizen::Graphics::FloatPoint3& center, float& radius) const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _Math::Vector3 _center;
+ float _radius;
+ result r = _pBoundingVolumeImpl->Get(_center,_radius);
+
+ if(r == E_SUCCESS)
+ {
+ center.x = _center.x; center.y = _center.y; center.z = _center.z;
+ radius = _radius;
+ }
+
+ return r;
+}
+
+result
+BoundingVolume::Merge(const BoundingVolume& volume)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+ SysTryReturn(NID_UI_ANIM, (_BoundingVolumeImpl::GetInstance(&volume)) != null, false, E_OBJ_NOT_FOUND, "Received Bounding volume has not been created properly Impl not found");
+
+ return _pBoundingVolumeImpl->Merge(*(_BoundingVolumeImpl::GetInstance(&volume)));
+}
+
+result
+BoundingVolume::Merge(const Tizen::Graphics::FloatPoint3& point)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _Math::Vector3 v(point.x,point.y,point.z);
+ return _pBoundingVolumeImpl->Merge(v);
+}
+
+result
+BoundingVolume::Merge(const Tizen::Base::Collection::ArrayListT<FloatPoint3>& vertexes)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ Tizen::Graphics::FloatPoint3 v;
+ for(int i = 0; i < vertexes.GetCount(); i++)
+ {
+ vertexes.GetAt(i,v);
+ _pBoundingVolumeImpl->Merge(_Math::Vector3(v.x,v.y,v.z));
+ }
+
+ return E_SUCCESS;
+}
+
+result
+BoundingVolume::Translate(const Tizen::Graphics::FloatMatrix4& translateMatrix)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _Math::Matrix4 translate(translateMatrix.matrix[0][0]);
+ translate.Transpose();
+
+ return _pBoundingVolumeImpl->Translate(translate);
+}
+
+result
+BoundingVolume::Transform(const Tizen::Graphics::FloatMatrix4& transformMatrix)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _Math::Matrix4 transform(&transformMatrix.matrix[0][0]);
+ transform.Transpose();
+
+ return _pBoundingVolumeImpl->Transform(transform);
+}
+
+void
+BoundingVolume::Reset()
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ _pBoundingVolumeImpl->Reset();
+}
+
+result
+BoundingVolume::IsBoxTwiceLess(const BoundingVolume& volume, bool& is)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+ SysTryReturnResult(NID_UI_ANIM, (_BoundingVolumeImpl::GetInstance(&volume)) != null, E_OBJ_NOT_FOUND, "Received Bounding volume has not been created properly Impl not found");
+ return _pBoundingVolumeImpl->IsBoxTwiceLess(*(_BoundingVolumeImpl::GetInstance(&volume)), is);
+}
+
+BoundingVolumeState
+BoundingVolume::GetState() const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ return _pBoundingVolumeImpl->GetState();
+}
+
+BoundingVolumeType
+BoundingVolume::GetType() const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ return _pBoundingVolumeImpl->GetType();
+}
+
+result
+BoundingVolume::SetType(BoundingVolumeType type)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ return _pBoundingVolumeImpl->SetType(type);
+}
+
+BoundingVolume&
+BoundingVolume::operator =(const BoundingVolume& rhs)
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+ SysTryReturn(NID_UI_ANIM, _BoundingVolumeImpl::GetInstance(&rhs) != null, *this, E_OBJ_NOT_FOUND, "Received Bounding volume has not been created properly Impl not found");
+
+ _pBoundingVolumeImpl->operator=( * (_BoundingVolumeImpl::GetInstance(&rhs)) );
+
+ return *this;
+}
+
+bool
+BoundingVolume::operator ==(const BoundingVolume& rhs) const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+ SysTryReturn(NID_UI_ANIM, (_BoundingVolumeImpl::GetInstance(&rhs)) != null, false, E_OBJ_NOT_FOUND, "Received Bounding volume has not been created properly Impl not found");
+
+ return _pBoundingVolumeImpl->operator==(*(_BoundingVolumeImpl::GetInstance(&rhs)));
+}
+
+bool
+BoundingVolume::operator !=(const BoundingVolume& rhs) const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+ SysTryReturn(NID_UI_ANIM, (_BoundingVolumeImpl::GetInstance(&rhs)) != null, false, E_OBJ_NOT_FOUND, "Received Bounding volume has not been created properly Impl not found");
+
+ return _pBoundingVolumeImpl->operator!=(*(_BoundingVolumeImpl::GetInstance(&rhs)));
+}
+
+bool
+BoundingVolume::Equals(const Tizen::Base::Object& obj) const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+
+ const BoundingVolume* pBoundingVolume = static_cast<const BoundingVolume*>(&obj);
+
+ SysTryReturn(NID_UI_ANIM, (_BoundingVolumeImpl::GetInstance(pBoundingVolume)) != null, false, E_OBJ_NOT_FOUND, "Received Bounding volume has not been created properly Impl not found");
+
+ return _pBoundingVolumeImpl->Equals(obj);
+}
+
+int
+BoundingVolume::GetHashCode(void) const
+{
+ SysAssertf(_pBoundingVolumeImpl != null, "Failed to create BoundingVolume Impl instance. Not enough memory.");
+ return _pBoundingVolumeImpl->GetHashCode();
+}
+
+}}} //Tizen::Ui::Animations
Light::Light(const Light& light)
: __pLightImpl(null)
{
- SysAssertf(light.__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(light.__pLightImpl != null, "Not yet constructed.");
- __pLightImpl = new (std::nothrow)_LightImpl(*light.__pLightImpl);
- SysTryReturnVoidResult(NID_UI_ANIM, __pLightImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+ __pLightImpl = light.__pLightImpl;
+
+ if(__pLightImpl != null)
+ {
+ __pLightImpl->AddRef();
+ }
}
Light::~Light(void)
Light&
Light::operator =(const Light& rhs)
{
- SysAssertf(rhs.__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
if (__pLightImpl != null)
{
Light::LightType
Light::GetType(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->GetLightType();
}
void
Light::SetType(LightType lightType)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetLightType(lightType);
}
Tizen::Graphics::FloatVector4
Light::GetDiffuse(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector4 coroEx = __pLightImpl->GetDiffuse().GetVector4();
Tizen::Graphics::FloatVector4 floatVec4(coroEx.x, coroEx.y, coroEx.z, coroEx.w);
void
Light::SetDiffuse(const Tizen::Graphics::FloatVector4& diffuse)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector4 colorEx(diffuse.x, diffuse.y, diffuse.z, diffuse.w);
__pLightImpl->SetDiffuse(colorEx);
Tizen::Graphics::FloatVector4
Light::GetSpecular(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector4 coroEx = __pLightImpl->GetSpecular().GetVector4();
Tizen::Graphics::FloatVector4 floatVec4(coroEx.x, coroEx.y, coroEx.z, coroEx.w);
void
Light::SetSpecular(const Tizen::Graphics::FloatVector4& specular)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector4 colorEx(specular.x, specular.y, specular.z, specular.w);
__pLightImpl->SetSpecular(colorEx);
Tizen::Graphics::FloatVector4
Light::GetAmbient(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector4 coroEx = __pLightImpl->GetAmbient().GetVector4();
Tizen::Graphics::FloatVector4 floatVec4(coroEx.x, coroEx.y, coroEx.z, coroEx.w);
void
Light::SetAmbient(const Tizen::Graphics::FloatVector4& ambient)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector4 colorEx(ambient.x, ambient.y, ambient.z, ambient.w);
__pLightImpl->SetAmbient(colorEx);
Tizen::Graphics::FloatPoint3
Light::GetPosition(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector3 position = __pLightImpl->GetPosition();
Tizen::Graphics::FloatPoint3 floatPointPos(position.x, position.y, position.z);
void
Light::SetPosition(const Tizen::Graphics::FloatPoint3& position)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector3 positionVec3(position.x, position.y, position.z);
__pLightImpl->SetPosition(positionVec3);
Tizen::Graphics::FloatPoint3
Light::GetDirection(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector3 direction = __pLightImpl->GetDirection();
Tizen::Graphics::FloatPoint3 floatPointDirection(direction.x, direction.y, direction.z);
void
Light::SetDirection(const Tizen::Graphics::FloatPoint3& direction)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
Vector3 directionVec3(direction.x, direction.y, direction.z);
__pLightImpl->SetDirection(directionVec3);
float
Light::GetExponent(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->GetSpotExponent();
}
void
Light::SetExponent(float exponent)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetSpotExponent(exponent);
}
float
Light::GetCutOff(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->GetCutOff();
}
void
Light::SetCutOff(float cutOff)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetCutOff(cutOff);
}
float
Light::GetConstantAttenuation(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->GetConstantAttenuation();
}
void
Light::SetConstantAttenuation(float attenuation)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetConstantAttenuation(attenuation);
}
float
Light::GetLinearAttenuation(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->GetLinearAttenuation();
}
void
Light::SetLinearAttenuation(float attenuation)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetLinearAttenuation(attenuation);
}
float
Light::GetQuadraticAttenuation(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->GetQuadraticAttenuation();
}
void
Light::SetQuadraticAttenuation(float attenuation)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetQuadraticAttenuation(attenuation);
}
Tizen::Base::String
Light::GetName(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return Tizen::Base::String(__pLightImpl->GetName().c_str());
}
result
Light::SetName(const Tizen::Base::String& name)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
std::wstring wName(name.GetPointer());
std::string sName(wName.begin(), wName.end());
bool
Light::IsEnabled(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->IsEnabled();
}
void
Light::SetEnabled(bool enabled)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetEnabled(enabled);
}
void
Light::SetColor(const Tizen::Graphics::FloatPoint3& color)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
//TODO check is color order correct.
ColorEx colorEx(color.x, color.y, color.z, 255);
Tizen::Graphics::FloatPoint3
Light::GetColor(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
ColorEx color = __pLightImpl->GetColor();
//TODO check is colors order correct.
void
Light::SetIntensity(float intensity)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetIntensity(intensity);
}
float
Light::GetIntensity(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->GetIntensity();
}
void
Light::SetRadius(float radius)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetRadius(radius);
}
float
Light::GetRadius(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->GetRadius();
}
void
Light::SetSpotlightRadius(float spotlightRadius)
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
__pLightImpl->SetSpotlightRadius(spotlightRadius);
}
float
Light::GetSpotlightRaduis(void) const
{
- SysAssertf(__pLightImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pLightImpl != null, "Not yet constructed.");
return __pLightImpl->GetSpotlightRaduis();
}
Material::Material(const Material& material)
: __pMaterialImpl(null)
{
- SysAssertf(material.__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(material.__pMaterialImpl != null, "Not yet constructed.");
- __pMaterialImpl = new (std::nothrow)_MaterialImpl(*material.__pMaterialImpl);
- SysTryReturnVoidResult(NID_UI_ANIM, __pMaterialImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+ __pMaterialImpl = material.__pMaterialImpl;
+
+ if(__pMaterialImpl != null)
+ {
+ __pMaterialImpl->AddRef();
+ }
}
Material::Material(const FloatVector4& diffuse, const FloatVector4& specular, const FloatVector4& ambient, const FloatVector4& emissive, float shininess)
Material&
Material::operator =(const Material& rhs)
{
- SysAssertf(rhs.__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(rhs.__pMaterialImpl != null, "Not yet constructed.");
if (__pMaterialImpl != null)
{
FloatVector4
Material::GetDiffuse(void) const
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
Vector4 diffuse = __pMaterialImpl->GetDiffuse().GetVector4();
FloatVector4 result(diffuse.x, diffuse.y, diffuse.z, diffuse.w);
void
Material::SetDiffuse(const Tizen::Graphics::FloatVector4& diffuse)
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
ColorEx colorexDiffuse(diffuse.x, diffuse.y, diffuse.z, diffuse.w);
__pMaterialImpl->SetDiffuse(colorexDiffuse);
Tizen::Graphics::FloatVector4
Material::GetSpecular(void) const
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
Vector4 specular = __pMaterialImpl->GetSpecular().GetVector4();
FloatVector4 result(specular.x, specular.y, specular.z, specular.w);
void
Material::SetSpecular(const Tizen::Graphics::FloatVector4& specular)
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
ColorEx colorexSpecular(specular.x, specular.y, specular.z, specular.w);
__pMaterialImpl->SetSpecular(colorexSpecular);
Tizen::Graphics::FloatVector4
Material::GetAmbient(void) const
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
Vector4 ambient = __pMaterialImpl->GetAmbient().GetVector4();
FloatVector4 result(ambient.x, ambient.y, ambient.z, ambient.w);
void
Material::SetAmbient(const Tizen::Graphics::FloatVector4& ambient)
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
ColorEx colorexAmbient(ambient.x, ambient.y, ambient.z, ambient.w);
__pMaterialImpl->SetAmbient(colorexAmbient);
Tizen::Graphics::FloatVector4
Material::GetEmissive(void) const
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
Vector4 emissive = __pMaterialImpl->GetEmissive().GetVector4();
FloatVector4 result(emissive.x, emissive.y, emissive.z, emissive.w);
void
Material::SetEmissive(const Tizen::Graphics::FloatVector4& emissive)
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
ColorEx colorexEmissiv(emissive.x, emissive.y, emissive.z, emissive.w);
__pMaterialImpl->SetEmissive(colorexEmissiv);
float
Material::GetEmissivePower(void) const
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
return __pMaterialImpl->GetEmissivePower();
}
void
Material::SetEmissivePower(const float& value)
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
__pMaterialImpl->SetEmissivePower(value);
}
float
Material::GetShininess(void) const
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
return __pMaterialImpl->GetShininess();
}
void
Material::SetShininess(float shiness)
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
__pMaterialImpl->SetShininess(shiness);
}
Tizen::Base::String
Material::GetName(void) const
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
Tizen::Base::String result(__pMaterialImpl->GetName().c_str());
return result;
result
Material::SetName(const Tizen::Base::String& name)
{
- SysAssertf(__pMaterialImpl != null,
- "Not yet constructed. Construct() should be called before use.");
+ SysAssertf(__pMaterialImpl != null, "Not yet constructed.");
std::wstring ws(name.GetPointer());
std::string stringName (ws.begin(), ws.end());
#include "FUiAnim_MeshImpl.h"
#include "FUiAnimMesh.h"
+#include "FGrpFloatPoint.h"
+#include "FGrpFloatPoint3.h"
+#include "FGrpColor.h"
+
+//#include "stdint.h"
+
+
using namespace Tizen::Graphics;
}
result
-Mesh::AdjustBoundingBox(bool rebuild)
+Mesh::AdjustBoundingVolume(bool rebuild)
{
CHECK_CONSTRUCTED;
- return __pMeshImpl->AdjustBoundingBox(rebuild);
+ return __pMeshImpl->AdjustBoundingVolume(rebuild);
}
void
__pMeshImpl->Clear();
}
-FloatPoint3
-Mesh::GetBoundingBoxPosition() const
-{
- CHECK_CONSTRUCTED;
- return __pMeshImpl->GetBoundingBoxPosition();
-}
-
-float
-Mesh::GetBoundingBoxLength() const
-{
- CHECK_CONSTRUCTED;
- return __pMeshImpl->GetBoundingBoxVolume();
-}
-float
-Mesh::GetBoundingBoxWidth() const
+BoundingVolume&
+Mesh::GetBoundingVolume()
{
- CHECK_CONSTRUCTED;
- return __pMeshImpl->GetBoundingBoxWidth();
-}
-
-float
-Mesh::GetBoundingBoxHeight() const
-{
- CHECK_CONSTRUCTED;
- return __pMeshImpl->GetBoundingBoxHeight();
-}
+ CHECK_CONSTRUCTED;
+ return __pMeshImpl->GetBoundingVolume();
+}
+
+//FloatPoint3
+//Mesh::GetBoundingBoxPosition() const
+//{
+// CHECK_CONSTRUCTED;
+// return __pMeshImpl->GetBoundingBoxPosition();
+//}
+//
+//float
+//Mesh::GetBoundingBoxLength() const
+//{
+// CHECK_CONSTRUCTED;
+// return __pMeshImpl->GetBoundingBoxVolume();
+//}
+//float
+//Mesh::GetBoundingBoxWidth() const
+//{
+// CHECK_CONSTRUCTED;
+// return __pMeshImpl->GetBoundingBoxWidth();
+//}
+//
+//float
+//Mesh::GetBoundingBoxHeight() const
+//{
+// CHECK_CONSTRUCTED;
+// return __pMeshImpl->GetBoundingBoxHeight();
+//}
// 임시 함수
result
return __pMeshImpl->GetCountOfIndices();
}
+result
+Mesh::SaveMesh(const Tizen::Base::String& fileName)
+{
+ CHECK_CONSTRUCTED;
+ return __pMeshImpl->SaveMesh(fileName);
+}
+
void
Mesh::SetName(Tizen::Base::String name)
{
return Tizen::Base::String(__pMeshImpl->GetName().c_str());
}
+
}}}//namespace Tizen { namespace Ui { namespace Animations{
+//
+// 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 FUiAnimModelImporter.cpp
+ * @brief This file contains implementation of ModelImporter class
+ *
+ * This file contains implementation ModelImporter class.
+ */
+
#include "FUiAnimModelImporter.h"
#include "FUiAnim_ModelImporterImpl.h"
+#include "library-effects/FUiAnim_ImportColladaLibEffEffect.h"
namespace Tizen { namespace Ui { namespace Animations {
return str;
}
-ModelImporter::ModelImporter()
+ModelImporter::ModelImporter(void)
{
+ return;
}
-ModelImporter::~ModelImporter()
+ModelImporter::~ModelImporter(void)
{
-
+ return;
}
Mesh*
-ModelImporter::LoadMeshN(MODEL_FORMAT modelFormat, const Tizen::Base::String& fileName, const Tizen::Base::String& modelName, bool tcoords, bool norms)
+ModelImporter::LoadMeshN(MODEL_FORMAT modelFormat, const Tizen::Base::String& fileName, const Tizen::Base::String& modelName, bool inverseY)
{
Mesh* pMesh = null;
std::string strFileName = WToStd(fileName);
switch(modelFormat){
case COLLADA:{
- AppLog("ModelImporter::LoadMesh::COLLADA");
_ModelImporterImpl modelImporter(strFileName, false, true, false, false, false, false, false, false, false); //true: Geometries
- pMesh = modelImporter.LoadMeshCollada(strModelName, tcoords, norms);
- //return null;
+ std::string materialId;
+ pMesh = modelImporter.LoadMeshCollada(strModelName, materialId, inverseY);
}break;
case BIN:{
-// AppLog("ModelImporter::LoadMesh::BIN");
-// pMesh = _ModelImporterImpl::LoadMeshBinN(strFileName);
- //return null;
+ AppLog("ModelImporter::LoadMesh::BIN");
+ pMesh = _ModelImporterImpl::LoadMeshBinN(strFileName, strModelName);
}break;
}
return pMesh;
Material* pMaterial = null;
std::string textureId;
+ _ImportCollada::LibraryEffects::Effect::ShaderType shaderType;
_ModelImporterImpl modelImporter(WToStd(fileName), false, false, false, false, true, true, true, false, false); //true:Materials, Effects, Images
- pMaterial = modelImporter.LoadMaterial(WToStd(materialName), textureId);
+ pMaterial = modelImporter.LoadMaterial(WToStd(materialName), textureId, shaderType);
if (pTextureName != null)
{
}
Scene*
-ModelImporter::LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base::String& sceneName)
+ModelImporter::LoadSceneN(const Tizen::Base::String& fileName, const Tizen::Base::String& sceneName, bool inverseY)
{
_ModelImporterImpl modelImporter(WToStd(fileName), true, true, false, false, true, true, true, false, false); //true: VisualScene, Geometries, Materials, Effects, Images
- return modelImporter.LoadScene(WToStd(sceneName));
+ return modelImporter.LoadScene(WToStd(sceneName), inverseY);
}
-
}}}
+//
+// Open Service Platform
+// Copyright (c) 2012-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 FUiAnimScene.cpp
+ * @brief This file contains implementation of Scene class
+ *
+ * This file contains implementation Scene class.
+ */
+
#include "FUiAnimScene.h"
#include "FUiAnim_SceneImpl.h"
namespace Tizen { namespace Ui { namespace Animations {
-Scene::Scene()
+Scene::Scene(void)
{
_pSceneImpl = new (std::nothrow) _SceneImpl();
}
-Scene::~Scene()
+Scene::~Scene(void)
{
delete _pSceneImpl;
_pSceneImpl = null;
}
Mesh*
-Scene::GetMesh(Tizen::Base::String meshName) const
+Scene::GetMeshN(Tizen::Base::String meshName) const
{
SetLastResult(E_SUCCESS);
std::wstring wStr(meshName.GetPointer());
std::string str(wStr.begin(), wStr.end());
- return _pSceneImpl->GetMesh(str);
+ return _pSceneImpl->GetMeshN(str);
}
Tizen::Base::Collection::ArrayList*
-Scene::GetMeshNamesN() const
+Scene::GetMeshNamesN(void) const
{
SetLastResult(E_SUCCESS);
return _pSceneImpl->GetMeshNamesN();
}
Material*
-Scene::GetMaterial(Tizen::Base::String materialName) const
+Scene::GetMaterialN(Tizen::Base::String materialName) const
{
SetLastResult(E_SUCCESS);
std::wstring wStr(materialName.GetPointer());
std::string str(wStr.begin(), wStr.end());
- return _pSceneImpl->GetMaterial(str);
+ return _pSceneImpl->GetMaterialN(str);
}
Tizen::Base::Collection::ArrayList*
-Scene::GetMaterialNamesN() const
+Scene::GetMaterialNamesN(void) const
{
SetLastResult(E_SUCCESS);
return _pSceneImpl->GetMaterialNamesN();
}
Tizen::Base::Collection::ArrayList*
-Scene::GetTextureFileNamesN() const
+Scene::GetTextureFileNamesN(void) const
{
SetLastResult(E_SUCCESS);
return _pSceneImpl->GetTextureFileNamesN();
{
Shader::Shader(void)
+ : __pShaderImpl(null)
{
- ClearLastResult();
-
- _pShaderImpl = new (std::nothrow) _ShaderImpl();
-
- if (_pShaderImpl == null)
- {
- SetLastResult(E_OUT_OF_MEMORY);
- }
}
Shader::~Shader(void)
{
- if (_pShaderImpl)
+ if (__pShaderImpl)
{
- delete _pShaderImpl;
- _pShaderImpl = null;
+ delete __pShaderImpl;
+ __pShaderImpl = null;
}
}
result
Shader::Construct(ShaderType type, const char* pShaderSource)
{
- SysTryReturnResult(NID_UI_ANIM, _pShaderImpl, E_OUT_OF_MEMORY, "Memory allocation failed.");
+ ClearLastResult();
+
+ SysAssertf(__pShaderImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+
+ __pShaderImpl = new (std::nothrow) _ShaderImpl();
+ SysTryReturnResult(NID_UI_ANIM, __pShaderImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
SysTryReturnResult(NID_UI_ANIM, type == SHADER_VERTEX || type == SHADER_FRAGMENT, E_INVALID_ARG, "Invalid argument is used. Shader type = %d.", type);
- SysTryReturnResult(NID_UI_ANIM, pShaderSource, E_INVALID_ARG, "Invalid argument is used. ShaderSource is null.");
+ SysTryReturnResult(NID_UI_ANIM, pShaderSource != null, E_INVALID_ARG, "Invalid argument is used. ShaderSource is null.");
- result r = _pShaderImpl->Construct(type, pShaderSource);
+ result r = __pShaderImpl->Construct(type, pShaderSource);
SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Propagating.");
return E_SUCCESS;
{
+
ShaderProgram::ShaderProgram(void)
+ : __pShaderProgramImpl(null)
{
- ClearLastResult();
-
- _pShaderProgramImpl = new (std::nothrow) _ShaderProgramImpl();
-
- if (_pShaderProgramImpl == null)
- {
- SetLastResult(E_OUT_OF_MEMORY);
- }
}
ShaderProgram::~ShaderProgram(void)
{
- if (_pShaderProgramImpl)
+ if (__pShaderProgramImpl)
{
- delete _pShaderProgramImpl;
- _pShaderProgramImpl = null;
+ delete __pShaderProgramImpl;
+ __pShaderProgramImpl = null;
}
}
result
ShaderProgram::Construct(Shader& vertexShader, Shader& fragmentShader)
{
- SysTryReturnResult(NID_UI_ANIM, _pShaderProgramImpl, E_OUT_OF_MEMORY, "Memory allocation failed.");
+ ClearLastResult();
+ SysAssertf(__pShaderProgramImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
- result r = _pShaderProgramImpl->Construct(vertexShader, fragmentShader);
- SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Propagating.");
+ __pShaderProgramImpl = new (std::nothrow) _ShaderProgramImpl();
+ SysTryReturnResult(NID_UI_ANIM, __pShaderProgramImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+ result r = __pShaderProgramImpl->Construct(vertexShader, fragmentShader);
+ SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Propagating.");
return E_SUCCESS;
}
Variant
ShaderProgram::GetUniform(const Tizen::Base::String& name) const
{
- return _pShaderProgramImpl->GetUniform(name);
-}
+ ClearLastResult();
+ SysAssertf(__pShaderProgramImpl != null,
+ "Not yet constructed. Construct() should be called before use.");
-result
-ShaderProgram::SetUniform(const Tizen::Base::String& name, const Tizen::Ui::Variant& value)
-{
- return _pShaderProgramImpl->SetUniform(name, value);
+ return __pShaderProgramImpl->GetUniform(name);
}
-
-
+/*
result
ShaderProgram::BindAttribute(ProgramLocation location, const Tizen::Base::String &name)
{
- SysAssertf(_pShaderProgramImpl != null,
+ SysAssertf(__pShaderProgramImpl != null,
"Not yet constructed. Construct() should be called before use.");
- return _pShaderProgramImpl->BindAttribute(location, name);
-}
-
+ return __pShaderProgramImpl->BindAttribute(location, name);
+}*/
+/*
result
ShaderProgram::BindUniform(ProgramLocation location, const Tizen::Base::String &name)
{
- SysAssertf(_pShaderProgramImpl != null,
+ SysAssertf(__pShaderProgramImpl != null,
"Not yet constructed. Construct() should be called before use.");
- return _pShaderProgramImpl->BindUniform(location, name);
+ return __pShaderProgramImpl->BindUniform(location, name);
}
+*/
+
+result
+ShaderProgram::SetUniform(const Tizen::Base::String& name, const Tizen::Ui::Variant& value)
+{
+ ClearLastResult();
+ SysAssertf(__pShaderProgramImpl != null,
+ "Not yet constructed. Construct() should be called before use.");
+ return __pShaderProgramImpl->SetUniform(name, value);
+}
+/*
bool
ShaderProgram::IsParameterAvailable(const ProgramLocation location) const
{
- return _pShaderProgramImpl->IsParameterAvailable(location);
+ return __pShaderProgramImpl->IsParameterAvailable(location);
}
bool
ShaderProgram::IsParameterAvailable(const Tizen::Base::String& name) const
{
- return _pShaderProgramImpl->IsParameterAvailable(name);
+ return __pShaderProgramImpl->IsParameterAvailable(name);
}
result
ShaderProgram::UnbindAttribute(const Tizen::Base::String &name)
{
- return E_SUCCESS;
+ return __pShaderProgramImpl->UnbindAttribute(name);
}
result
ShaderProgram::UnbindUniform(const Tizen::Base::String &name)
{
- return E_SUCCESS;
+ return __pShaderProgramImpl->UnbindUniform(name);
}
+void
+ShaderProgram::SetUserData(const Tizen::Base::String& name, const Tizen::Ui::Variant& value)
+{
+ __pShaderProgramImpl->SetUserData(name, value);
+}
+void
+ShaderProgram::SetUserSampler(const Tizen::Base::String& name, Tizen::Ui::Animations::VisualElementSurface* pSurface)
+{
+ __pShaderProgramImpl->SetUserSampler(name, pSurface);
+}*/
}}} // Tizen::Ui::Animations
+++ /dev/null
-#include <stddef.h>
-#include "FUiAnim_BoundingVolume.h"
-
-#include "FUiAnim_MathVector3.h"
-#include "FUiAnim_MathMatrix4.h"
-
-#include "FBaseErrors.h"
-
-namespace Tizen{ namespace Ui{ namespace Animations
-{
-
-BoundingVolume::BoundingVolume()
-: State(AAB_Empty)
-{
-
-}
-
-
-result BoundingVolume::Construct(const _Math::Vector3& min, const _Math::Vector3& max)
-{
- State = AAB_Empty;
- return SetExtents(min, max);
-}
-
-
-_Math::Vector3 BoundingVolume::GetCenter() const
-{
- return _Math::Vector3(
- (Min.x + Max.x) * 0.5f,
- (Min.y + Max.y) * 0.5f,
- (Min.z + Max.z) * 0.5f);
-}
-
-
-_Math::Vector3 BoundingVolume::GetHalfSize() const
-{
- return (Max - Min) * 0.5f;
-}
-
-
-result BoundingVolume::Merge(const BoundingVolume& box)
-{
- if (box.State != AAB_Valid)
- return E_INVALID_ARG;
-
- if (State == AAB_Valid)
- {
- Merge(box.Min);
- Merge(box.Max);
- }
- else if (State == AAB_OnePoint)
- {
- _Math::Vector3 onePoint = Min;
- SetExtents(box.Min, box.Max);
- Merge(onePoint);
- }
- else
- {
- SetExtents(box.Min, box.Max);
- }
-
- return E_SUCCESS;
-}
-
-
-void BoundingVolume::Merge(const _Math::Vector3& point)
-{
- if (State == AAB_Valid)
- {
- Min.SetMin(point);
- Max.SetMax(point);
- }
- else if (State == AAB_OnePoint)
- {
- Max = point;
- _Math::Vector3 oldMin = Min;
-
- Min.SetMin(point);
- Max.SetMax(oldMin);
-
- State = AAB_Valid;
- }
- else
- {
- Min = point;
- State = AAB_OnePoint;
- }
-}
-
-
-result BoundingVolume::Merge(const float* vertexes, int vertexesLen)
-{
- if (vertexes == 0 || vertexesLen < 0)
- return E_INVALID_ARG;
-
- for (int i = 0; i < vertexesLen; ++i)
- {
- _Math::Vector3 v(vertexes[3 * i], vertexes[3 * i + 1], vertexes[3 * i + 2]);
-
- Merge(v);
- }
-
- return E_SUCCESS;
-}
-
-
-result BoundingVolume::Merge(const std::vector<_Math::Vector3> &Vertex)
-{
- std::vector<_Math::Vector3>::const_iterator it;
-
- if (Vertex.size() == 0)
- return E_INVALID_ARG;
-
- for (it = Vertex.begin(); it != Vertex.end(); ++it)
- {
- Merge(*it);
- }
-
- return E_SUCCESS;
-}
-
-
-result BoundingVolume::Translate(const _Math::Matrix4& world)
-{
- if (State == AAB_Valid)
- {
- _Math::Vector3 translate(world.GetTranslation());
- Min += translate;
- Max += translate;
- }
- else
- {
- AppLog("AxisAlignedBox::transform: box state no valid");
- return E_FAILURE;
- }
-
- return E_SUCCESS;
-}
-
-
-void BoundingVolume::Transform(const _Math::Matrix4& world)
-{
- _Math::Vector3 v[] =
- {
- //far
- _Math::Vector3(Min.x, Max.y, Min.z),
- _Math::Vector3(Max.x, Max.y, Min.z),
- _Math::Vector3(Max.x, Min.y, Min.z),
- _Math::Vector3(Min.x, Min.y, Min.z),
-
- //near
- _Math::Vector3(Min.x, Max.y, Max.z),
- _Math::Vector3(Max.x, Max.y, Max.z),
- _Math::Vector3(Max.x, Min.y, Max.z),
- _Math::Vector3(Min.x, Min.y, Max.z)
- };
-
-
- Reset();
-
- for (size_t i = 0; i < sizeof(v) / sizeof(v[0]); ++i)
- {
- v[i] = world * v[i];
- Merge(v[i]);
- }
-
- //TODO already in Matri4 * Vector3 translated
- //translate(world);
-}
-
-
-void BoundingVolume::Reset()
-{
- Min = _Math::Vector3();
- Max = _Math::Vector3();
- State = AAB_Empty;
-}
-
-
-result BoundingVolume::IsBoxTwiceLess(const BoundingVolume& box, bool& is)
-{
- if (box.State != AAB_Valid)
- return E_INVALID_ARG;
-
- const _Math::Vector3 boxHalf = box.GetHalfSize();
- const _Math::Vector3 myQuart = GetHalfSize() / 2.0f;
-
- is = boxHalf.x <= myQuart.x &&
- boxHalf.y <= myQuart.y &&
- boxHalf.z <= myQuart.z;
-
- return E_SUCCESS;
-}
-
-
-void BoundingVolume::print() const
-{
- AppLog("min %.3f %.3f %.3f", Min.x, Min.y, Min.z);
- AppLog("max %.3f %.3f %.3f", Max.x, Max.y, Max.z);
-}
-
-
-result BoundingVolume::SetExtents(const _Math::Vector3& min, const _Math::Vector3& max)
-{
- if (min.x > max.x || min.y > max.y || min.z > max.z)
- {
- AppLog("AxisAlignedBox::setExtents: min should be less-equal to max: min = (%.2f, %.2f, %.2f) max = (%.2f, %.2f, %.2f)",
- min.x, min.y, min.z,
- max.x, max.y, max.z);
- return E_INVALID_ARG;
- }
-
- Min = min;
- Max = max;
- State = AAB_Valid;
-
- return E_SUCCESS;
-}
-
-
-}}} //namespace Tizen{ namespace Ui{ namespace Animations
+++ /dev/null
-#ifndef _FUI_ANIM_BOUNDING_VOLUME_H_
-#define _FUI_ANIM_BOUNDING_VOLUME_H_
-
-#include <vector>
-
-#include "FBaseDataType.h"
-#include "math/FUiAnim_MathVector3.h"
-
-namespace Tizen{ namespace Ui{ namespace Animations
-{
-namespace _Math
-{
-class Matrix4;
-}
-
-class BoundingVolume
-{
-public:
- /**
- * Constructs Axis Aligned Box with empty state
- */
- BoundingVolume();
-
- /**
- * Constructs Axis Aligned Box and inits with supplied points
- *
- * @since 2.0
- *
- * @return result code
- * @param[in] min minimum point of this box
- * @param[in] max maximum point of this box
- * @exception E_INVALID_ARG any min component bigger then max component
- */
- result Construct(const _Math::Vector3& min, const _Math::Vector3& max);
-
- /**
- * Returns center point of Axis Aligned Box
- *
- * @since 2.0
- *
- * @return center point of Axis Aligned Box
- */
- _Math::Vector3 GetCenter() const;
-
- /**
- * Returns vector, specifying half size of this Axis Aligned Box
- *
- * @since 2.0
- *
- * @return vector, specifying half size of this Axis Aligned Box
- */
- _Math::Vector3 GetHalfSize() const;
-
- /**
- * Adds volume of specified box to this Axis Aligned Box
- *
- * @since 2.0
- *
- * @return result code
- * @param[in] box box to merge to this box
- * @exception E_INVALID_ARG given box state is not valid
- */
- result Merge(const BoundingVolume& box);
-
- /**
- * Adds specified point to this Axis Aligned Box
- *
- * @since 2.0
- *
- * @param point point to merge to this box
- */
- void Merge(const _Math::Vector3& point);
-
- /**
- * Adds specified points to this Axis Aligned Box
- *
- * @since 2.0
- *
- * @return result code
- * @param[in] vertexes coordinates of points in form "xyzxyz..." to merge to this box,
- * @param[in] vertexesLen points count provided
- * @exception E_INVALID_ARG vertexes == 0 or vertexesLen < 0
- */
- result Merge(const float* vertexes, int vertexesLen);
-
- /**
- * Adds specified points to this Axis Aligned Box
- *
- * @since 2.0
- *
- * @return result code
- * @param[in] Vertex coordinates of points in std::vector<Vector3> to merge to this box,
- * @exception E_INVALID_ARG Vertex size == 0
- */
- result Merge(const std::vector<_Math::Vector3> &Vertex);
-
- /**
- * Translates this Axis Aligned Box by specified transformation
- *
- * @since 2.0
- *
- * @return result code
- * @param[in] world translation to apply to this box
- * @exception E_FAILURE box state is not valid
- */
-
-
- result Translate(const _Math::Matrix4& world);
-
- /**
- * Transforms this Axis Aligned Box by specified transformation
- *
- * @since 2.0
- *
- * @param[in] world transformation to apply to this box
- */
- void Transform(const _Math::Matrix4& world);
-
-
- /**
- * Returns this Axis Aligned Box to empty state
- */
- void Reset();
-
- /**
- * Checks is supplied box twice less then this
- *
- * @since 2.0
- *
- * @return result code
- * @param[in] box box to check
- * @param[in] is is supplied box twice less then this
- * @exception E_INVALID_ARG given box state is not valid
- */
- result IsBoxTwiceLess(const BoundingVolume& box, bool& is);
-
- /**
- * Minimum point of this Axis Aligned Box
- */
- _Math::Vector3 Min;
-
- /**
- * Maximum point of this Axis Aligned Box
- */
- _Math::Vector3 Max;
-
- /**
- * Possible states of Axis Aligned Box
- *
- * No points merged in AAB - Empty
- * One merged - one point
- * Two and more - valid
- */
- enum AAB_State
- {
- AAB_Empty,
- AAB_OnePoint,
- AAB_Valid
- };
-
- /**
- * Holds current state of this Axis Aligned Box
- */
- AAB_State State;
-
- void print() const;
-
-private:
- /**
- * Sets extents of this Axis Aligned Box
- *
- * @since 2.0
- *
- * @return result code
- * @param[in] min minimum point to set extents
- * @param[in] max maximum point to set extents
- * @exception E_INVALID_ARG any min component bigger then max component
- */
- result SetExtents(const _Math::Vector3& min, const _Math::Vector3& max);
-};
-
-
-}}} //namespace Tizen{ namespace Ui{ namespace Animations
-#endif // _FUI_ANIM_BOUNDING_VOLUME_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2013-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.
+//
+
+/**
+ * @file FUiAnim_BoundingVolumeImpl.cpp
+ * @brief This file contains implementation of _BoundingVolumeImpl class
+ *
+ * This file contains implementation _BoundingVolumeImpl class.
+ */
+
+
+#include "FUiAnim_BoundingVolumeImpl.h"
+
+#include "FUiAnim_MathVector3.h"
+#include "FUiAnim_MathMatrix4.h"
+
+
+//sphere coordinates are saved in declared _BoundingVolumeImpl->Min as a center, Max.x as radius
+#define CENTER Min
+#define RADIUS Max.x
+
+namespace Tizen{ namespace Ui{ namespace Animations
+{
+
+_BoundingVolumeImpl::_BoundingVolumeImpl()
+ : State(BOUNDING_VOLUME_STATE_EMPTY)
+ , Type(BOUNDING_VOLUME_TYPE_AABB)
+ , Min(0.0f)
+ , Max(0.0f)
+{
+
+}
+
+_BoundingVolumeImpl::~_BoundingVolumeImpl()
+{
+
+}
+
+_BoundingVolumeImpl::_BoundingVolumeImpl(const _Math::Vector3& min, const _Math::Vector3& max)
+ : State(BOUNDING_VOLUME_STATE_EMPTY)
+ , Type(BOUNDING_VOLUME_TYPE_AABB)
+ , Min(0.0f)
+ , Max(0.0f)
+{
+ SysTryReturnVoidResult(NID_UI_ANIM, (min.x <= max.x && min.y <= max.y && min.z <= max.z), E_INVALID_ARG, "Invalid arguments while initializing Bounding Volume Impl max must be higher than min");
+ //SysTryCatch(NID_UI_ANIM, (min.x <= max.x && min.y <= max.y && min.z <= max.z), , E_INVALID_ARG, "Invalid arguments while initializing Bounding Volume Impl max must be higher than min");
+
+ State = BOUNDING_VOLUME_STATE_VALID;
+ Min = min;
+ Max = max;
+
+ if(Min == Max)
+ {
+ State = BOUNDING_VOLUME_STATE_ONE_POINT;
+ }
+
+//CATCH:
+// return;
+}
+
+_BoundingVolumeImpl::_BoundingVolumeImpl(const _Math::Vector3& center, const float radius)
+ : State(BOUNDING_VOLUME_STATE_EMPTY)
+ , Type(BOUNDING_VOLUME_TYPE_SPHERE)
+ , Min(0.0f)
+ , Max(0.0f)
+{
+ SysTryReturnVoidResult(NID_UI_ANIM, (radius >= 0), E_INVALID_ARG, "Invalid arguments while initializing Bounding Volume Impl radius must be greater than 0");
+ //SysTryCatch(NID_UI_ANIM, (radius >= 0), , E_INVALID_ARG, "Invalid arguments while initializing Bounding Volume Impl max must be higher than min");
+
+
+ CENTER = center;
+ RADIUS = radius;
+
+ State = BOUNDING_VOLUME_STATE_VALID;
+ if(RADIUS == 0)
+ {
+ State = BOUNDING_VOLUME_STATE_ONE_POINT;
+ }
+
+//CATCH:
+// return;
+}
+
+const _BoundingVolumeImpl*
+_BoundingVolumeImpl::GetInstance(const BoundingVolume* pPublic)
+{
+ SysTryReturn(NID_UI_ANIM, pPublic != null, null, E_OBJ_NOT_FOUND, "Wrong public BoundingVolume instance.");
+ SysTryReturn(NID_UI_ANIM, pPublic->_pBoundingVolumeImpl != null, null, E_OBJ_NOT_FOUND, "Public BoundingVolume instance created incorrectly, Impl not found.");
+
+ return pPublic->_pBoundingVolumeImpl;
+}
+
+_BoundingVolumeImpl*
+_BoundingVolumeImpl::GetInstance(BoundingVolume* pPublic)
+{
+ SysTryReturn(NID_UI_ANIM, pPublic != null, null, E_OBJ_NOT_FOUND, "Wrong public BoundingVolume instance.");
+ SysTryReturn(NID_UI_ANIM, pPublic->_pBoundingVolumeImpl != null, null, E_OBJ_NOT_FOUND, "Public BoundingVolume instance created incorrectly, Impl not found.");
+
+ return pPublic->_pBoundingVolumeImpl;
+}
+
+_Math::Vector3
+_BoundingVolumeImpl::GetCenter() const
+{
+ switch(Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ return _Math::Vector3(
+ (Min.x + Max.x) * 0.5f,
+ (Min.y + Max.y) * 0.5f,
+ (Min.z + Max.z) * 0.5f);
+ break;
+
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ return _Math::Vector3(Min);
+ break;
+
+ default:
+ break;
+ }
+
+ SetLastResult(E_INVALID_ARG);
+ AppLog("Bounding Volume Impl is of unknown type");
+ return _Math::Vector3(0.0f);
+}
+
+result
+_BoundingVolumeImpl::Set(const _Math::Vector3& min, const _Math::Vector3& max)
+{
+ SysTryReturnResult(NID_UI_ANIM, (min.x <= max.x && min.y <= max.y && min.z <= max.z), E_INVALID_ARG, "Invalid arguments while initializing Bounding Volume Impl max must be higher than min");
+
+ State = BOUNDING_VOLUME_STATE_VALID;
+ Min = min;
+ Max = max;
+
+ if(Min == Max)
+ {
+ State = BOUNDING_VOLUME_STATE_ONE_POINT;
+ }
+
+ return E_SUCCESS;
+}
+
+result
+_BoundingVolumeImpl::Set(const _Math::Vector3& center, const float radius)
+{
+ SysTryReturnResult(NID_UI_ANIM, (radius >= 0), E_INVALID_ARG, "Invalid arguments while initializing Bounding Volume Impl radius must be greater than 0");
+
+ CENTER = center;
+ RADIUS = radius;
+
+ State = BOUNDING_VOLUME_STATE_VALID;
+ if(RADIUS == 0)
+ {
+ State = BOUNDING_VOLUME_STATE_ONE_POINT;
+ }
+
+ return E_SUCCESS;
+}
+
+result
+_BoundingVolumeImpl::Get(_Math::Vector3& min, _Math::Vector3& max)
+{
+ SysTryReturnResult(NID_UI_ANIM, Type == BOUNDING_VOLUME_TYPE_AABB, E_INVALID_ARG, "Invalid arguments while get values of Bounding Volume Impl, type is not BOUNDING_VOLUME_TYPE_AABB");
+
+ min = Min;
+ max = Max;
+
+ return E_SUCCESS;
+}
+
+result
+_BoundingVolumeImpl::Get(_Math::Vector3& center, float& radius)
+{
+ SysTryReturnResult(NID_UI_ANIM, Type == BOUNDING_VOLUME_TYPE_SPHERE, E_INVALID_ARG, "Invalid arguments while get values of Bounding Volume Impl, type is not BOUNDING_VOLUME_TYPE_AABB");
+
+ center = CENTER;
+ radius = RADIUS;
+
+ return E_SUCCESS;
+}
+
+
+_Math::Vector3
+_BoundingVolumeImpl::GetHalfSize() const
+{
+ switch(Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ return _Math::Vector3((Max - Min) * 0.5f);
+ break;
+
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ return _Math::Vector3(RADIUS);
+ break;
+
+ default:
+ break;
+ }
+
+ SetLastResult(E_INVALID_ARG);
+ AppLog("Bounding Volume Impl is of unknown type");
+ return _Math::Vector3(0.0f);
+}
+
+result
+_BoundingVolumeImpl::Merge(const _BoundingVolumeImpl& volume)
+{
+ _Math::Vector3 onePoint;
+ const float sqrt3 = sqrt(3);
+
+ switch(Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+
+ if (volume.State != BOUNDING_VOLUME_STATE_VALID)
+ return E_INVALID_ARG;
+
+ if (State == BOUNDING_VOLUME_STATE_VALID)
+ {
+ switch(volume.Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ //this - aabb, state valid merge with rhs - aabb
+ Merge(volume.Min);
+ Merge(volume.Max);
+ break;
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ //this - aabb, state valid merge with rhs - sphere
+ Merge(volume.CENTER + volume.RADIUS * sqrt3);
+ Merge(volume.CENTER - volume.RADIUS * sqrt3);
+ break;
+ default:
+ AppLog("Argument Bounding Volume Impl is of unknown type");
+ SetLastResult(E_INVALID_ARG);
+ return E_INVALID_ARG;
+ break;
+ }
+ }
+ else if (State == BOUNDING_VOLUME_STATE_ONE_POINT)
+ {
+ switch(volume.Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ //this - aabb, state one point merge with rhs - aabb
+ onePoint = Min;
+ Set(volume.Min, volume.Max);
+ Merge(onePoint);
+ break;
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ //this - aabb, state one point merge with rhs - sphere
+ onePoint = Min;
+ Set(volume.CENTER - volume.RADIUS * sqrt3, volume.CENTER + volume.RADIUS * sqrt3);
+ Merge(onePoint);
+ break;
+ default:
+ AppLog("Argument Bounding Volume Impl is of unknown type");
+ SetLastResult(E_INVALID_ARG);
+ return E_INVALID_ARG;
+ break;
+ }
+ }
+ else
+ {
+ switch(volume.Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ //this - aabb, state empty merge with rhs - aabb
+ Set(volume.Min, volume.Max);
+ break;
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ //this - aabb, state empty merge with rhs - sphere
+ Set(volume.CENTER - volume.RADIUS * sqrt3, volume.CENTER + volume.RADIUS * sqrt3);
+ break;
+ default:
+ AppLog("Argument Bounding Volume Impl is of unknown type");
+ SetLastResult(E_INVALID_ARG);
+ return E_INVALID_ARG;
+ break;
+ }
+ }
+ return E_SUCCESS;
+
+ break;
+
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ if (volume.State != BOUNDING_VOLUME_STATE_VALID)
+ return E_INVALID_ARG;
+
+ if (State == BOUNDING_VOLUME_STATE_VALID)
+ {
+ switch(volume.Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ //this - sphere, state valid merge with rhs - aabb
+ Merge(volume.Min);
+ Merge(volume.Max);
+ break;
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ //this - sphere, state valid merge with rhs - sphere
+ onePoint = (CENTER - volume.CENTER);
+ if(RADIUS < (onePoint.Length() + volume.RADIUS))
+ {
+ RADIUS = (onePoint.Length() + volume.RADIUS);
+ }
+ break;
+ default:
+ AppLog("Argument Bounding Volume Impl is of unknown type");
+ SetLastResult(E_INVALID_ARG);
+ return E_INVALID_ARG;
+ break;
+ }
+ }
+ else if (State == BOUNDING_VOLUME_STATE_ONE_POINT)
+ {
+ switch(volume.Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ //this - sphere, state one point merge with rhs - aabb
+ Merge(volume.Min);
+ Merge(volume.Max);
+ break;
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ //this - sphere, state one point merge with rhs - sphere
+ onePoint = (CENTER - volume.CENTER);
+ if(RADIUS < (onePoint.Length() + volume.RADIUS))
+ {
+ RADIUS = (onePoint.Length() + volume.RADIUS);
+ }
+ break;
+ default:
+ AppLog("Argument Bounding Volume Impl is of unknown type");
+ SetLastResult(E_INVALID_ARG);
+ return E_INVALID_ARG;
+ break;
+ }
+ }
+ else
+ {
+ switch(volume.Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ //this - sphere, state empty merge with rhs - aabb
+ onePoint = volume.Max - volume.Min;
+ Set(volume.Min + onePoint/2, onePoint.Length()/2);
+ break;
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ //this - sphere, state empty merge with rhs - sphere
+ Set(volume.CENTER, volume.RADIUS);
+ break;
+ default:
+ AppLog("Argument Bounding Volume Impl is of unknown type");
+ SetLastResult(E_INVALID_ARG);
+ return E_INVALID_ARG;
+ break;
+ }
+ }
+ return E_SUCCESS;
+
+ break;
+
+ default:
+ break;
+ }
+
+ AppLog("Bounding Volume Impl is of unknown type");
+ SetLastResult(E_INVALID_ARG);
+ return E_INVALID_ARG;
+}
+
+result
+_BoundingVolumeImpl::Merge(const _Math::Vector3& point)
+{
+ _Math::Vector3 oldMin;
+
+ switch(Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ if (State == BOUNDING_VOLUME_STATE_VALID)
+ {
+ Min.SetMin(point);
+ Max.SetMax(point);
+ }
+ else if (State == BOUNDING_VOLUME_STATE_ONE_POINT)
+ {
+ Max = point;
+ oldMin = Min;
+
+ Min.SetMin(point);
+ Max.SetMax(oldMin);
+
+ State = BOUNDING_VOLUME_STATE_VALID;
+ }
+ else
+ {
+ Min = point;
+ State = BOUNDING_VOLUME_STATE_ONE_POINT;
+ }
+ return E_SUCCESS;
+ break;
+
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ if (State == BOUNDING_VOLUME_STATE_VALID)
+ {
+ oldMin = point - CENTER;
+ if(RADIUS < oldMin.Length())
+ {
+ RADIUS = oldMin.Length();
+ }
+ }
+ else if (State == BOUNDING_VOLUME_STATE_ONE_POINT)
+ {
+ oldMin = point - CENTER;
+ if(RADIUS < oldMin.Length())
+ {
+ RADIUS = oldMin.Length();
+ }
+
+ State = BOUNDING_VOLUME_STATE_VALID;
+ }
+ else
+ {
+ CENTER = point;
+ State = BOUNDING_VOLUME_STATE_ONE_POINT;
+ }
+ return E_SUCCESS;
+ break;
+
+ default:
+ break;
+ }
+
+ SetLastResult(E_INVALID_ARG);
+ AppLog("Bounding Volume Impl is of unknown type");
+ return E_INVALID_ARG;
+}
+
+
+result
+_BoundingVolumeImpl::Merge(const float* vertexes, int vertexesLen)
+{
+ SysTryReturnResult(NID_UI_ANIM, vertexes != 0 && vertexesLen >= 0, E_INVALID_ARG, "Vertex count or vertex pointer are invalid");
+
+ for (int i = 0; i < vertexesLen; ++i)
+ {
+ _Math::Vector3 v(vertexes[3 * i], vertexes[3 * i + 1], vertexes[3 * i + 2]);
+
+ Merge(v);
+ }
+
+ return E_SUCCESS;
+}
+
+result
+_BoundingVolumeImpl::Translate(const _Math::Matrix4& world)
+{
+ _Math::Vector3 translate(world.GetTranslation());
+
+ SysTryReturnResult(NID_UI_ANIM, State == BOUNDING_VOLUME_STATE_VALID, E_FAILURE, "Bounding box state is not invalid");
+
+ switch(Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ Min += translate;
+ Max += translate;
+ return E_SUCCESS;
+ break;
+
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ CENTER += translate;
+ return E_SUCCESS;
+ break;
+
+ default:
+ break;
+ }
+
+ SetLastResult(E_INVALID_ARG);
+ AppLog("Bounding Volume Impl is of unknown type");
+ return E_INVALID_ARG;
+}
+
+result
+_BoundingVolumeImpl::Transform(const _Math::Matrix4& world)
+{
+ SysTryReturnResult(NID_UI_ANIM, State == BOUNDING_VOLUME_STATE_VALID, E_FAILURE, "Bounding volume state is invalid");
+
+ //for AABB, to allocate variables
+ if(Type == BOUNDING_VOLUME_TYPE_AABB)
+ {
+ _Math::Vector3 v[] =
+ {
+ //far
+ _Math::Vector3(Min.x, Max.y, Min.z),
+ _Math::Vector3(Max.x, Max.y, Min.z),
+ _Math::Vector3(Max.x, Min.y, Min.z),
+ _Math::Vector3(Min.x, Min.y, Min.z),
+
+ //near
+ _Math::Vector3(Min.x, Max.y, Max.z),
+ _Math::Vector3(Max.x, Max.y, Max.z),
+ _Math::Vector3(Max.x, Min.y, Max.z),
+ _Math::Vector3(Min.x, Min.y, Max.z)
+ };
+
+ Reset();
+ size_t count = sizeof(v) / sizeof(v[0]);
+ for (size_t i = 0; i < count; ++i)
+ {
+ v[i] = world * v[i];
+ Merge(v[i]);
+ }
+ }
+
+ switch(Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ return E_SUCCESS;
+ break;
+
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ CENTER = world * CENTER;
+ return E_SUCCESS;
+ break;
+
+ default:
+ break;
+ }
+
+ SetLastResult(E_INVALID_ARG);
+ AppLog("Bounding Volume Impl is of unknown type");
+ return E_INVALID_ARG;
+}
+
+
+void _BoundingVolumeImpl::Reset()
+{
+ Min = _Math::Vector3();
+ Max = _Math::Vector3();
+ State = BOUNDING_VOLUME_STATE_EMPTY;
+}
+
+
+result _BoundingVolumeImpl::IsBoxTwiceLess(const _BoundingVolumeImpl& box, bool& is)
+{
+ SysTryReturnResult(NID_UI_ANIM, Type == BOUNDING_VOLUME_TYPE_AABB, E_FAILURE, "Bounding volume type is not invalid (not AABB)");
+ SysTryReturnResult(NID_UI_ANIM, box.Type == BOUNDING_VOLUME_TYPE_AABB, E_FAILURE, "Received bounding volume type is not invalid (not AABB)");
+ SysTryReturnResult(NID_UI_ANIM, State == BOUNDING_VOLUME_STATE_VALID, E_FAILURE, "Bounding volume state is not invalid");
+ SysTryReturnResult(NID_UI_ANIM, box.State == BOUNDING_VOLUME_STATE_VALID, E_FAILURE, "Received bounding volume state is not invalid");
+
+ const _Math::Vector3 boxHalf = box.GetHalfSize();
+ const _Math::Vector3 myQuart = GetHalfSize() / 2.0f;
+
+ is = boxHalf.x <= myQuart.x &&
+ boxHalf.y <= myQuart.y &&
+ boxHalf.z <= myQuart.z;
+
+ return E_SUCCESS;
+}
+
+
+void _BoundingVolumeImpl::print() const
+{
+ switch(Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ AppLog("min %.3f %.3f %.3f", Min.x, Min.y, Min.z);
+ AppLog("max %.3f %.3f %.3f", Max.x, Max.y, Max.z);
+ break;
+
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ AppLog("Center %.3f %.3f %.3f, radius %.3f", Min.x, Min.y, Min.z, Max.x);
+ break;
+
+ default:
+ AppLog("Bounding Volume Impl is of unknown type");
+ break;
+ }
+ return;
+}
+
+BoundingVolumeState
+_BoundingVolumeImpl::GetState() const
+{
+ return State;
+}
+
+BoundingVolumeType
+_BoundingVolumeImpl::GetType() const
+{
+ return Type;
+}
+
+result
+_BoundingVolumeImpl::SetType(BoundingVolumeType newType)
+{
+ if(Type == newType)
+ {
+ return E_SUCCESS;
+ }
+
+ const float sqrt3 = sqrt(3);
+ _Math::Vector3 min,max;
+ float r;
+
+ switch(Type)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ switch(newType)
+ {
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ //convert aabb to sphere
+ min = Min;
+ max = Max;
+ Min = GetCenter();
+ Max.Set(0.0f);
+ min = (min - max)/2;
+ Max.x = min.Length();
+ Type = BOUNDING_VOLUME_TYPE_SPHERE;
+ break;
+
+ default:
+ SetLastResult(E_INVALID_ARG);
+ AppLog("Bounding Volume is tried to set in unknown type");
+ return E_INVALID_ARG;
+ break;
+ }
+ break;
+
+ case BOUNDING_VOLUME_TYPE_SPHERE:
+ switch(newType)
+ {
+ case BOUNDING_VOLUME_TYPE_AABB:
+ r = RADIUS;
+ Min = GetCenter() - r * sqrt3;
+ Max = Min + 2 * r * sqrt3;
+ Type = BOUNDING_VOLUME_TYPE_AABB;
+ break;
+
+ default:
+ SetLastResult(E_INVALID_ARG);
+ AppLog("Bounding Volume is tried to set in unknown type");
+ return E_INVALID_ARG;
+ break;
+ }
+ break;
+
+ default:
+ SetLastResult(E_INVALID_ARG);
+ AppLog("Bounding Volume Impl is of unknown type");
+ return E_INVALID_ARG;
+ break;
+ }
+
+ return E_SUCCESS;
+}
+
+_BoundingVolumeImpl&
+_BoundingVolumeImpl::operator =(const _BoundingVolumeImpl& rhs)
+{
+ Type = rhs.Type;
+ State = rhs.State;
+ Min = rhs.Min;
+ Max = rhs.Max;
+
+ return *this;
+}
+
+bool
+_BoundingVolumeImpl::operator ==(const _BoundingVolumeImpl& rhs) const
+{
+ if(Type == rhs.Type && State == rhs.State)
+ {
+ if(Min == rhs.Min && Max == rhs.Max)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool
+_BoundingVolumeImpl::operator !=(const _BoundingVolumeImpl& rhs) const
+{
+ return !(this->operator ==(rhs));
+}
+
+bool
+_BoundingVolumeImpl::Equals(const Tizen::Base::Object& obj) const
+{
+ const BoundingVolume* pBoundingVolume = static_cast<const BoundingVolume*>(&obj);
+
+ if(_BoundingVolumeImpl::GetInstance(pBoundingVolume) == this)
+ {
+ return true;
+ }
+ else
+ {
+ return this->operator ==(*(_BoundingVolumeImpl::GetInstance(pBoundingVolume)));
+ }
+}
+
+int
+_BoundingVolumeImpl::GetHashCode(void) const
+{
+ return (int)Type * 10000000 + (int)State * 1000000 + Min.x * 100000 + Min.y * 10000 + Min.z * 1000 + Max.x * 100 + Max.y * 10 + Max.z;
+}
+
+}}} //namespace Tizen{ namespace Ui{ namespace Animations
+++ /dev/null
-//
-// 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 FUiAnim_CustomShader.cpp
- * @brief This file contains implementation of _CustomShader class
- *
- * This file contains implementation _CustomShader class.
- */
-
-#include <FBaseString.h>
-#include <FBaseErrors.h>
-#include "FUiAnim_CustomShader.h"
-#include "FUiAnim_GlShaderProgram.h"
-
-using namespace Tizen::Base;
-using std::pair;
-
-namespace Tizen { namespace Ui { namespace Animations
-{
-_CustomShader::_CustomShader(void):locationVec(null)
-{
- locationVec = new std::vector<std::pair<ProgramLocation, int> >();
-}
-_CustomShader::_CustomShader(unsigned int program):locationVec(null)
-{
- locationVec = new std::vector<std::pair<ProgramLocation, int> >();
- SetProgram(program);
-}
-
-_CustomShader::~_CustomShader(void)
-{
- __attributeLocations.clear();
- __uniformLocations.clear();
- if (locationVec)
- {
- locationVec->clear();
- delete locationVec;
- }
-}
-
-
-bool
-_CustomShader::IsParameterAvailable(const ProgramLocation location) const
-{
- containerLocations::const_iterator it;
- containerLocations::const_iterator itEnd;
-
- itEnd = __attributeLocations.end();
- for (it = __attributeLocations.begin(); it != itEnd; ++it)
- {
- if ((it->first).first == location)
- {
- return true;
- }
- }
-
- itEnd = __uniformLocations.end();
- for (it = __uniformLocations.begin(); it != itEnd; ++it)
- {
- if ((it->first).first == location)
- {
- return true;
- }
- }
-
- return false;
-}
-
- int
- _CustomShader::GetParameter(const ProgramLocation location) const
- {
-
- int res = -1;
- res = GetAttributes(location);
- if (res == -1)
- {
- res = GetUniforms(location);
- }
- return res;
- }
-
-
-bool
-_CustomShader::IsParameterAvailable(const Tizen::Base::String& name) const
-{
- containerLocations::const_iterator it;
- containerLocations::const_iterator itEnd;
- itEnd = __attributeLocations.end();
- for (it = __attributeLocations.begin(); it != itEnd; ++it)
- {
- if (String::Compare((it->first).second, name) == 0)
- {
- return true;
- }
- }
-
- itEnd = __uniformLocations.end();
- for (it = __uniformLocations.begin(); it != itEnd; ++it)
- {
- if (String::Compare((it->first).second, name) == 0)
- {
- return true;
- }
- }
- return false;
-}
-
-char *
-PrintError(const ProgramLocation location)
-{
- char *Errors[PROGRAM_LOCATION_MAX] = {
- "UNIFORM_MAT4_MVP",
- "UNIFORM_VEC4_COLOR",
- "UNIFORM_SAMPLER2D_TEXTURE",
- "UNIFORM_FLOAT_OPACITY",
- "UNIFORM_MAT4_MODEL_VIEW",
- "UNIFORM_MAT4_INV_MODEL_VIEW",
- "UNIFORM_INT_LIGHT_TYPE",
- "UNIFORM_INT_LIGHT_STRUCT_TYPE",
- "UNIFORM_VEC4_LIGHT_AMBIENT",
- "UNIFORM_VEC4_LIGHT_STRUCT_AMBIENT",
- "UNIFORM_VEC4_LIGHT_DIFFUSE",
- "UNIFORM_VEC4_LIGHT_STRUCT_DIFFUSE",
- "UNIFORM_VEC4_LIGHT_SPECULAR",
- "UNIFORM_VEC4_LIGHT_STRUCT_SPECULAR",
- "UNIFORM_VEC4_LIGHT_POSITION",
- "UNIFORM_VEC4_LIGHT_STRUCT_POSITION",
- "UNIFORM_VEC3_LIGHT_DIRECTION",
- "UNIFORM_VEC3_LIGHT_STRUCT_DIRECTION",
- "UNIFORM_FLOAT_LIGHT_EXPONENT",
- "UNIFORM_FLOAT_LIGHT_STRUCT_EXPONENT",
- "UNIFORM_FLOAT_LIGHT_CUTOFF",
- "UNIFORM_FLOAT_LIGHT_STRUCT_CUTOFF",
- "UNIFORM_VEC3_LIGHT_ATTENUATION",
- "UNIFORM_VEC3_LIGHT_STRUCT_ATTENUATION",
- "UNIFORM_VEC4_MATERIAL_AMBIENT",
- "UNIFORM_VEC4_MATERIAL_STRUCT_AMBIENT",
- "UNIFORM_VEC4_MATERIAL_DIFFUSE",
- "UNIFORM_VEC4_MATERIAL_STRUCT_DIFFUSE",
- "UNIFORM_VEC4_MATERIAL_SPECULAR",
- "UNIFORM_VEC4_MATERIAL_STRUCT_SPECULAR",
- "UNIFORM_VEC4_MATERIAL_EMISSIVE",
- "UNIFORM_VEC4_MATERIAL_STRUCT_EMISSIVE",
- "UNIFORM_FLOAT_MATERIAL_SHININESS",
- "UNIFORM_FLOAT_MATERIAL_STRUCT_SHININESS",
- "ATTRIBUTE_VEC2_TEXTURE_COORD",
- "ATTRIBUTE_VEC4_POSITION",
- "ATTRIBUTE_VEC4_COLOR",
- "ATTRIBUTE_VEC3_NORMAL",
- };
- return Errors[location];
-}
-void
-_CustomShader::BindAttributes()
-{
- //const int numOfAttributes = PROGRAM_LOCATION_MAX;
-
- char *attributes[PROGRAM_LOCATION_MAX] = {
- "u_mvp",
- "u_color",
- "u_tex2d",
- "u_opacity",
- "u_modelview",
- "u_inv_modelview",
- "u_lighttype",
- "u_light.type",
- "u_lightambient",
- "u_light.ambient",
- "u_lightdiffuse",
- "u_light.diffuse",
- "u_lightspecular",
- "u_light.specular",
- "u_lightposition",
- "u_light.position",
- "u_lightdirectional",
- "u_light.directional",
- "u_lightexponent",
- "u_light.exponent",
- "u_lightcutoff",
- "u_light.cutoff",
- "u_lightattenuation",
- "u_light.attenuation",
- "u_materialambient",
- "u_material.ambient",
- "u_materialdiffuse",
- "u_material.diffuse",
- "u_materialspecular",
- "u_material.specular",
- "u_materialemissive",
- "u_material.emissive",
- "u_materialshininess",
- "u_material.shininess",
- "a_texcoord",
- "a_position",
- "a_color",
- "a_normal"
- };
-
- int glAttribute = -1;
- int program = GetProgram();
- for (int i = 0; i < PROGRAM_LOCATION_MAX; ++i)
- {
- if ((glAttribute = glGetAttribLocation(program, attributes[i])) != -1)
- {
- String locationName(attributes[i]);
- __attributeLocations.push_back(pair <pair<ProgramLocation, String>, int>(pair<ProgramLocation, String>((ProgramLocation)i, locationName), glAttribute));
- locationVec->push_back(pair<ProgramLocation, int>((ProgramLocation)i, glAttribute));
- }
- if ((glAttribute = glGetUniformLocation(program, attributes[i])) != -1)
- {
- String locationName(attributes[i]);
- __uniformLocations.push_back(pair <pair<ProgramLocation, String>, int>(pair<ProgramLocation, String>((ProgramLocation)i, locationName), glAttribute));
- locationVec->push_back(pair<ProgramLocation, int>((ProgramLocation)i, glAttribute));
- }
- }
- return;
-}
-
-std::vector< std::pair<ProgramLocation, int> >*
-_CustomShader::ParameterList()
-{
- return locationVec;
-}
-
-int
-_CustomShader::GetAttributes(const ProgramLocation location) const
-{
- containerLocations::const_iterator it;
- containerLocations::const_iterator itEnd;
-
- itEnd = __attributeLocations.end();
- for (it = __attributeLocations.begin(); it != itEnd; ++it)
- {
- if ((it->first).first == location)
- {
- return it->second;
- }
- }
- return -1;
-}
-
-
-int
-_CustomShader::GetUniforms(const ProgramLocation location) const
-{
- containerLocations::const_iterator it;
- containerLocations::const_iterator itEnd;
-
- itEnd = __uniformLocations.end();
- for (it = __uniformLocations.begin(); it != itEnd; ++it)
- {
- if ((it->first).first == location)
- {
- return it->second;
- }
- }
- return -1;
-}
-
-
-
-void
-_CustomShader::OnProgramReferenced(void)
-{
- containerLocations::iterator it;
- containerLocations::iterator itEnd;
-
- itEnd = __attributeLocations.end();
- for (it = __attributeLocations.begin(); it != itEnd; ++it)
- {
- glEnableVertexAttribArray(it->second);
- }
- return;
-}
-
-void
-_CustomShader::OnProgramDereferenced(void)
-{
- containerLocations::iterator it;
- containerLocations::iterator itEnd;
-
- itEnd = __attributeLocations.end();
- for (it = __attributeLocations.begin(); it != itEnd; ++it)
- {
- glDisableVertexAttribArray(it->second);
- }
- return;
-}
-
-result
-_CustomShader::BindAttribute(const ProgramLocation location,const Tizen::Base::String &name)
-{
- std::wstring wStr(name.GetPointer());
- std::string locationName(wStr.begin(), wStr.end());
- int glAttribute;
- containerLocations::iterator it;
- containerLocations::iterator itEnd;
-
- itEnd = __attributeLocations.end();
- for (it = __attributeLocations.begin(); it != itEnd; ++it)
- {
- SysTryReturnResult(NID_UI_ANIM, (*it).first.first != location, E_INVALID_ARG, "\"%s\" is already binded",PrintError(location));
- SysTryReturnResult(NID_UI_ANIM, String::Compare((it->first).second, name) != 0, E_INVALID_ARG, "\"%s\" is already binded",locationName.c_str());
- }
-
- glAttribute = glGetAttribLocation(GetProgram(), locationName.c_str());
-
- SysTryReturnResult(NID_UI_ANIM, glAttribute != -1, E_INVALID_ARG, "Can't bind a \"%s\" attribute", locationName.c_str());
-
- __attributeLocations.push_back(pair< pair<ProgramLocation, String>, int>(pair<ProgramLocation, String>(location, name), glAttribute));
- locationVec->push_back(pair<ProgramLocation, int>(location, glAttribute));
-
- return E_SUCCESS;
-}
-
-
-result
-_CustomShader::BindUniform(const ProgramLocation location,const Tizen::Base::String &name)
-{
- std::wstring wStr(name.GetPointer());
- std::string locationName(wStr.begin(), wStr.end());
- int glAttribute;
- containerLocations::iterator it;
- containerLocations::iterator itEnd;
-
- itEnd = __uniformLocations.end();
- for (it = __uniformLocations.begin(); it != itEnd; ++it)
- {
- SysTryReturnResult(NID_UI_ANIM, (*it).first.first != location, E_INVALID_ARG, "\"%s\" is already binded",PrintError(location));
- SysTryReturnResult(NID_UI_ANIM, String::Compare((it->first).second, name) != 0, E_INVALID_ARG, "\"%s\" is already binded",locationName.c_str());
- }
-
- glAttribute = glGetUniformLocation(GetProgram(), locationName.c_str());
-
- SysTryReturnResult(NID_UI_ANIM, glAttribute != -1, E_INVALID_ARG, "Can't bind a \"%s\" uniform", locationName.c_str());
-
- __uniformLocations.push_back(pair< pair<ProgramLocation, String>, int>(pair<ProgramLocation, String>(location, name), glAttribute));
- locationVec->push_back(pair<ProgramLocation, int>(location, glAttribute));
-
- return E_SUCCESS;
-}
-
-result
-_CustomShader::UnbindAttribute(const Tizen::Base::String& name)
-{
- containerLocations::iterator it;
- containerLocations::iterator itEnd;
- itEnd = __attributeLocations.end();
- for (it = __attributeLocations.begin(); it != itEnd; ++it)
- {
- if (String::Compare((it->first).second, name) == 0)
- {
- __attributeLocations.erase(it);
-
- return E_SUCCESS;
- }
- }
- return E_FAILURE;
-}
-
-result
-_CustomShader::UnbindUniform(const Tizen::Base::String& name)
-{
- containerLocations::iterator it;
- containerLocations::iterator itEnd;
- itEnd = __uniformLocations.end();
- for (it = __uniformLocations.begin(); it != itEnd; ++it)
- {
- if (String::Compare((it->first).second, name) == 0)
- {
- __uniformLocations.erase(it);
- return E_SUCCESS;
- }
- }
- return E_FAILURE;
-}
-
-}}} //Tizen::Ui::Animations
+++ /dev/null
-//
-// 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 FUiAnim_CustomShader.h
- * @brief This is the header file for the _CustomShader class.
- *
- * This header file contains the declarations of the _CustomShader class.
- */
-
-
-#ifndef _FUI_ANIM_CUSTOM_SHADER_
-#define _FUI_ANIM_CUSTOM_SHADER_
-
-#include "FUiAnim_GlShaderProgram.h"
-#include "FUiAnimShaderProgram.h"
-#include <FBaseSysLog.h>
-#include <string>
-#include <GLES2/gl2.h>
-#include <vector>
-#include <utility>
-namespace Tizen { namespace Ui { namespace Animations
-{
-
-class _CustomShader
- : public _GlShaderProgram
-{
-public:
- _CustomShader(void);
- _CustomShader(unsigned int program);
- virtual ~_CustomShader(void);
- virtual void OnProgramReferenced(void);
- virtual void OnProgramDereferenced(void);
- virtual int GetParameter(const ProgramLocation location) const;
- virtual std::vector< std::pair<ProgramLocation, int> > *ParameterList();
- void BindAttributes();
- bool IsParameterAvailable(const ProgramLocation location) const;
- bool IsParameterAvailable(const Tizen::Base::String& name) const;
- int GetAttributes(const ProgramLocation location) const;
- int GetUniforms(const ProgramLocation location) const;
- result BindAttribute(const ProgramLocation location, const Tizen::Base::String& name);
- result BindUniform(const ProgramLocation location, const Tizen::Base::String& name);
- result UnbindAttribute(const Tizen::Base::String& name);
- result UnbindUniform(const Tizen::Base::String& name);
-private:
- typedef std::vector<std::pair< std::pair<ProgramLocation, Tizen::Base::String>, int> > containerLocations;
- std::vector<std::pair<ProgramLocation, int> > *locationVec;
- containerLocations __attributeLocations;
- containerLocations __uniformLocations;
-};
-
-}}} //Tizen::Ui::Animations
-
-#endif //_FUI_ANIM_CUSTOM_SHADER_
__pMaterial = null;
}
- if (__pMaterial != null)
+ if (__pLight != null)
{
- delete __pMaterial;
- __pMaterial = null;
+ delete __pLight;
+ __pLight = null;
}
}
}
else
{
- if (__pMesh)
+ if (__pMesh != null)
{
delete __pMesh;
__pMesh = null;
#include "FUiAnim_GlDefaultShaderProgram.h"
#include "FUiAnim_GlRenderManager.h"
#include <FBaseSysLog.h>
+#include <GLES2/gl2.h>
namespace Tizen { namespace Ui { namespace Animations
{
-_GlDefaultShaderProgram::_GlDefaultShaderProgram(void):_CustomShader()
+_GlDefaultShaderProgram::_GlDefaultShaderProgram(void):_GlShaderProgram()
{
}
_GlDefaultShaderProgram::~_GlDefaultShaderProgram(void)
{
-
+ _GlRenderManager::GetInstance()->DeleteShader(__vertexShader);
+ _GlRenderManager::GetInstance()->DeleteShader(__fragmentShader);
+ _GlRenderManager::GetInstance()->DeleteShaderProgram(__program);
}
bool
#ifndef FUI_ANIM_GL_DEFAULT_SHADER_PROGRAM_
#define FUI_ANIM_GL_DEFAULT_SHADER_PROGRAM_
-#include "FUiAnim_CustomShader.h"
+//#include "FUiAnim_CustomShader.h"
+#include "FUiAnim_GlShaderProgram.h"
namespace Tizen { namespace Ui { namespace Animations
{
class _GlDefaultShaderProgram
- : public _CustomShader
+ : public _GlShaderProgram
{
public:
_GlDefaultShaderProgram(void);
#include <FBaseErrors.h>
#include <FBaseSysLog.h>
#include <FUiAnimShader.h>
+
#include <FUiAnimShaderProgram.h>
#include "FBase_StringConverter.h"
#include "FGrpFloatRectangle.h"
#include "FUiAnim_VisualElementSurfaceManager.h"
#include "FUiAnim_MeshImpl.h"
-#include "FUiAnim_LightImpl.h"
-#include "FUiAnim_MaterialImpl.h"
#include "FUiAnim_ShaderImpl.h"
#include "FUiAnim_ShaderProgramImpl.h"
+#include "FUiAnimLight.h"
+#include "FUiAnimMaterial.h"
+#include "FUiAnim_LightImpl.h"
+#include "FUiAnim_MaterialImpl.h"
+
#include "FUiAnim_Debug.h"
__mvp = mvp;
__objectColor = pNode->__objectColor;
+
__opacity = pNode->__opacity;
__colorMask = colorMask;
if (_FloatCompare(pNode->__opacity, 1.0f))
{
__pProgram = _GlRenderManager::GetInstance()->__pTextureShader;
+
}
else
{
__invModelview.Assign(__modelview);
__invModelview.Invert();
__invModelview.Transpose(); // TODO: optimize
-
__pProgram = _GlRenderManager::GetInstance()->__pLightShader;
+
}
+
if (pNode->__pShaderProgram != null)
{
_ShaderProgramImpl* pShaderProgramImpl = _ShaderProgramImpl::GetInstance(*pNode->__pShaderProgram);
__pProgram = pShaderProgramImpl->GetCusomShader();
}
- /*else
- {
- // Set program info
- __uMVP = __pProgram->GetMVPUniformLocation();
- __uOpacity = __pProgram->GetOpacityUniformLocation();
- __uColor = __pProgram->GetColorUniformLocation();
-
- __aPosition = __pProgram->GetPositionAttributeLocation();
- __aTexCoord = __pProgram->GetTextureCoordinatesAttributeLocation();
- __aColor = __pProgram->GetColorAttributeLocation();
- __aNormal = __pProgram->GetNormalAttributeLocation();
- }*/
- __uMVP = __pProgram->GetParameter(UNIFORM_MAT4_MVP);
- __uOpacity = __pProgram->GetParameter(UNIFORM_FLOAT_OPACITY);
- __uColor = __pProgram->GetParameter(UNIFORM_VEC4_COLOR);
- __aPosition = __pProgram->GetParameter(ATTRIBUTE_VEC4_POSITION);
- __aTexCoord = __pProgram->GetParameter(ATTRIBUTE_VEC2_TEXTURE_COORD);
- __aColor = __pProgram->GetParameter(ATTRIBUTE_VEC4_COLOR);
- __aNormal = __pProgram->GetParameter(ATTRIBUTE_VEC3_NORMAL);
+ __uMVP = __pProgram->GetParameter(UNIFORM_MAT4_MVP);
+ __uOpacity = __pProgram->GetParameter(UNIFORM_FLOAT_OPACITY);
+ __uColor = __pProgram->GetParameter(UNIFORM_VEC4_COLOR);
+ __aPosition = __pProgram->GetParameter(ATTRIBUTE_VEC4_POSITION);
+ __aTexCoord = __pProgram->GetParameter(ATTRIBUTE_VEC2_TEXTURE_COORD);
+ __aColor = __pProgram->GetParameter(ATTRIBUTE_VEC4_COLOR);
+ __aNormal = __pProgram->GetParameter(ATTRIBUTE_VEC3_NORMAL);
+
+
return;
}
, __pLightShader(null)
{
memset(&__threadInfo, 0x00, sizeof(pthread_t));
-
if (pthread_create(&__threadInfo, NULL, _GlRenderManager::RenderProc, this) != 0)
+ {
SysAssertf(false, "Creating render-thread failed");
+ }
ClearLastResult();
pthread_join(__threadInfo, NULL);
delete [] __pRenderQueue;
-
delete __pColorShader;
delete __pUniformColorShader;
delete __pTextureShader;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
__needClear = false;
}
-
for (int i = 0; i < __queueCount; i++)
{
+
__pGlContext->UseShaderProgram(__pRenderQueue[i].__pProgram);
- // Set uniform
- // TODO: need to check location -1?
- /*glUniformMatrix4fv(__pRenderQueue[i].__uMVP, 1, GL_FALSE, __pRenderQueue[i].__mvp.GetItems());
- glUniform1f(__pRenderQueue[i].__uOpacity, __pRenderQueue[i].__opacity);
- glUniform4f(__pRenderQueue[i].__uColor, __pRenderQueue[i].__objectColor.Red(), __pRenderQueue[i].__objectColor.Green(),
- __pRenderQueue[i].__objectColor.Blue(), __pRenderQueue[i].__objectColor.Alpha());
-
- // Set attribute
- // TODO: need to check location -1?
- glVertexAttribPointer(__pRenderQueue[i].__aPosition, 3, GL_FLOAT, GL_FALSE, VERTEX_BUFFER_STRIDE * sizeof(float), __pRenderQueue[i].__pVertices);
- glVertexAttribPointer(__pRenderQueue[i].__aTexCoord, 2, GL_FLOAT, GL_FALSE, TEX_COORD_BUFFER_STRIDE * sizeof(float), __pRenderQueue[i].__pTexCoords);
- glVertexAttribPointer(__pRenderQueue[i].__aColor, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), __pRenderQueue[i].__pColors);
- glVertexAttribPointer(__pRenderQueue[i].__aNormal, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), __pRenderQueue[i].__pNormals);
-
- if (__pRenderQueue[i].__pLight)
- {
- glUniformMatrix4fv(__pLightShader->__uniformLocModelView, 1, GL_FALSE, __pRenderQueue[i].__modelview.GetItems());
- glUniformMatrix4fv(__pLightShader->__uniformLocInvModelView, 1, GL_FALSE, __pRenderQueue[i].__invModelview.GetItems());
-
- _LightImpl* pLightImpl = _LightImpl::GetInstance(*__pRenderQueue[i].__pLight);
-
- glUniform1i(__pLightShader->__uniformLocLightType, pLightImpl->GetLightType());
- glUniform4fv(__pLightShader->__uniformLocLightAmbient, 1, pLightImpl->GetAmbient().GetVector4().GetPointer());
- glUniform4fv(__pLightShader->__uniformLocLightDiffuse, 1, pLightImpl->GetDiffuse().GetVector4().GetPointer());
- glUniform4fv(__pLightShader->__uniformLocLightSpecular, 1, pLightImpl->GetSpecular().GetVector4().GetPointer());
- glUniform4fv(__pLightShader->__uniformLocLightPosition, 1, pLightImpl->GetPosition().GetPointer());
- glUniform3fv(__pLightShader->__uniformLocLightDirection, 1, pLightImpl->GetDirection().GetPointer());
- glUniform1f(__pLightShader->__uniformLocLightExponent, pLightImpl->GetSpotExponent());
- glUniform1f(__pLightShader->__uniformLocLightCutOff, pLightImpl->GetCutOff());
- _Math::Vector3 attenuation(pLightImpl->GetConstantAttenuation(), pLightImpl->GetLinearAttenuation(), pLightImpl->GetQuadraticAttenuation());
- glUniform3fv(__pLightShader->__uniformLocLightAttenuation, 1, attenuation.GetPointer());
-
- _MaterialImpl* pMaterialImpl = _MaterialImpl::GetInstance(*__pRenderQueue[i].__pMaterial);
- glUniform4fv(__pLightShader->__uniformLocMaterialAmbient, 1, pMaterialImpl->GetAmbient().GetVector4().GetPointer());
- glUniform4fv(__pLightShader->__uniformLocMaterialDiffuse, 1, pMaterialImpl->GetDiffuse().GetVector4().GetPointer());
- glUniform4fv(__pLightShader->__uniformLocMaterialSpecular, 1, pMaterialImpl->GetSpecular().GetVector4().GetPointer());
- glUniform4fv(__pLightShader->__uniformLocMaterialEmissive, 1, pMaterialImpl->GetEmissive().GetVector4().GetPointer());
- glUniform1f(__pLightShader->__uniformLocMaterialShiness, pMaterialImpl->GetShininess());
- }*/
static _LightImpl* pLightImpl = null;
static _MaterialImpl* pMaterialImpl = null;
if(__pRenderQueue[i].__pLight)
SysTryLog(NID_UI_ANIM,__pRenderQueue[i].__pLight != null, "Light is null");
if(__pRenderQueue[i].__pLight)
{
- _Math::Vector3 attenuation(pLightImpl->GetConstantAttenuation(), pLightImpl->GetLinearAttenuation(), pLightImpl->GetQuadraticAttenuation());
+ _Math::Vector3 attenuation;
+ attenuation.x = pLightImpl->GetConstantAttenuation();
+ attenuation.y = pLightImpl->GetLinearAttenuation();
+ attenuation.z = pLightImpl->GetQuadraticAttenuation();
glUniform3fv((*it).second, 1, attenuation.GetPointer());
}
break;
}
//TODO default
}
+ __pRenderQueue[i].__pProgram->BindGlUniforms(); // TODO
+
if (__pRenderQueue[i].__textureId > 0)
{
__pGlContext->BindTexture(__pRenderQueue[i].__textureId);
__pGlContext->__useBlend = __pRenderQueue[i].__useBlend;
}
-
+// glDisable(GL_BLEND);
if (__pGlContext->__useDepthTest != __pRenderQueue[i].__useDepthTest)
{
if (__pRenderQueue[i].__useDepthTest)
}
else
{
+
if (__pGlContext->__useStencil)
{
- glDisable(GL_STENCIL_TEST);
+ glDisable(GL_STENCIL_TEST);
__pGlContext->__useStencil = false;
}
if (__pRenderQueue[i].__pIndices)
{
+ //AppLog("glDrawElements vi = %d", __pRenderQueue[i].__indexCount);
glDrawElements(__pRenderQueue[i].__geoType, __pRenderQueue[i].__indexCount, GL_UNSIGNED_SHORT, __pRenderQueue[i].__pIndices);
}
else
{
+ //AppLog("vertex count %d", __pRenderQueue[i].__vertexCount);
glDrawArrays(__pRenderQueue[i].__geoType, 0, __pRenderQueue[i].__vertexCount);
}
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);
-
CompositeNode(pVeRoot, viewport, false, 0);
#ifdef VE_USE_RENDER_QUEUE
#ifdef VE_USE_GL_MULTI_CONTEXT
pGlLayer->__pContext = _GlContext::CreateN((Handle)_NativeWindow::GetDisplay(), (EGLNativeWindowType)pGlLayer->GetNativeWindow());
+ PRINT("[DEBUG]-003a _GlRenderManager::CommandHandlerInitializeGLLayer: Create surf... \n" );
+
__pGlContext = pGlLayer->__pContext;
PrepareShaders();
SysAssertf(!pGlLayer->__surface, "");
+ PRINT("[DEBUG]-003 _GlRenderManager::CommandHandlerInitializeGLLayer: Create surf... \n" );
+
// TODO: jinstar
- pGlLayer->__surface = __pGlContext->CreateWindowSurface((EGLNativeWindowType)pGlLayer->GetNativeWindow());
+ //////////pGlLayer->__surface = __pGlContext->CreateWindowSurface( (EGLNativeWindowType)pGlLayer->GetNativeWindow() );
+ pGlLayer->__surface = __pGlContext->CreateWindowSurface( (EGLNativeWindowType)pGlLayer->GetHandle() );
PRINT(">> CommandHandlerInitializeGLLayer() surface %p \n", pGlLayer->__surface);
#endif
__commandArg.__pCommandShader = pShader;
__commandRequest.SendSignal();
__commandReply.WaitForSignal(&__commandLock);
-
return (__commandResult == E_SUCCESS);
}
case COMMAND_BUILD_SHADER:
pThis->CommandHandlerBuildShader(commandArg.__pCommandShader);
break;
+ case COMMAND_DELETE_SHADER_PROGRAM:
+ pThis->CommandHandlerDeleteShaderProgram(commandArg.__pCommandShaderProgram);
+ break;
+ case COMMAND_DELETE_SHADER:
+ pThis->CommandHandlerDeleteShader(commandArg.__pCommandShader);
+ break;
case COMMAND_COMPOSITE:
PRINT(">> CommandHandlerComposite() COMMAND_COMPOSITE - start \n");
-
if (pThis->Animate())
{
pThis->CommandHandlerComposite(null);
#include "FUiAnim_GlRenderManager.h"
#include "FUiAnim_GlShaderProgram.h"
+#include "FGrpFloatMatrix4.h"
+#include "FGrpColor.h"
+#include <FGrpFloatPoint3.h>
+#include <FGrpFloatVector4.h>
using namespace std;
using namespace Tizen::Graphics;
using namespace Tizen::Ui::Animations;
-
+using namespace Tizen::Base;
+using std::pair;
//#define PRINT(...) fprintf(stderr, __VA_ARGS__)
#define PRINT(...)
namespace Tizen { namespace Ui { namespace Animations
{
-_GlShaderProgram::_GlShaderProgram(void)
+_GlShaderProgram::_GlShaderProgram(unsigned int program)
+ :__program(program)
+ ,__hasGlUniforms(false)
{
+ locationVec = new std::vector<std::pair<ProgramLocation, int> >();
//__shaderVariableList.clear();
}
_GlShaderProgram::~_GlShaderProgram(void)
{
+ __attributeLocations.clear();
+ __uniformLocations.clear();
+ glUniforms.clear();
+ if (locationVec)
+ {
+ locationVec->clear();
+ delete locationVec;
+ }
//__shaderVariableList.clear();
- //_GlRenderManager::GetInstance()->DeleteShader(__vertexShader);
- //_GlRenderManager::GetInstance()->DeleteShader(__fragmentShader);
- _GlRenderManager::GetInstance()->DeleteShaderProgram(__program);
- AppLog("_GLSP destructor");
-}
-/*
-bool
-_GlShaderProgram::LoadShader(const char* pVertexShaderSrc, const char* pFragmentShaderSrc)
-{
- // temp
- // doesn't use return type
- __vertexShader = _GlRenderManager::GetInstance()->BuildShader(GL_VERTEX_SHADER, pVertexShaderSrc);
- SysTryReturn(NID_UI_ANIM, __vertexShader > 0, false, E_SYSTEM, "Failed to build vertex shader.");
-
- __fragmentShader = _GlRenderManager::GetInstance()->BuildShader(GL_FRAGMENT_SHADER, pFragmentShaderSrc);
- SysTryReturn(NID_UI_ANIM, __fragmentShader > 0, false, E_SYSTEM, "Failed to build vertex shader.");
-
- __program = _GlRenderManager::GetInstance()->BuildShaderProgram(__vertexShader, __fragmentShader);
- SysTryReturn(NID_UI_ANIM, __program > 0, false, E_SYSTEM, "Failed to build vertex shader.");
-
- OnProgramCreated();
-
- return true;
+// _GlRenderManager::GetInstance()->DeleteShader(__vertexShader);
+// _GlRenderManager::GetInstance()->DeleteShader(__fragmentShader);
+// _GlRenderManager::GetInstance()->DeleteShaderProgram(__program);
}
-*/
-void
-_GlShaderProgram::SetProgram(unsigned int program)
+Variant
+_GlShaderProgram::GetUniform(const Tizen::Base::String& name) const
{
-__program = program;
-}
+ Variant result;
+ SysTryReturn(NID_UI_ANIM,__hasGlUniforms, result, E_INVALID_ARG, "GlUniforms list is empty");
-/*
-bool
-_GlShaderProgram::LoadShader(const char* pVertexShaderBin, int vertexLength, const char* pFragmentShaderBin, int fragmentLength)
-{
- return true;
+ std::vector<GlUniformStruct >::const_iterator it;
+ std::vector<GlUniformStruct >::const_iterator itend;
+ itend = glUniforms.end();
+ for (it = glUniforms.begin(); it != itend; ++it)
+ {
+ if (String::Compare(it->name, name) == 0)
+ {
+ result = Variant(it->data);
+ break;
+ }
+ }
+ SysTryReturn(NID_UI_ANIM, result.GetType() != VARIANT_TYPE_NONE, result, E_INVALID_ARG, "uniform name was not found");
+ return result;
}
-int
-_GlShaderProgram::GetAttribLocation(const char* name)
+bool
+_GlShaderProgram::IsParameterAvailable(const ProgramLocation location) const
{
- vector<ShaderVariable>::iterator iter = find(__shaderVariableList.begin(), __shaderVariableList.end(), name);
-
- if (iter == __shaderVariableList.end())
- {
- ShaderVariable shaderVariable;
-
- shaderVariable.name = new char[strlen(name) + 1];
- strncpy(shaderVariable.name, name, strlen(name));
-
- shaderVariable.value = glGetAttribLocation(__program, name);
+ containerLocations::const_iterator it;
+ containerLocations::const_iterator itEnd;
- if (shaderVariable.value == -1)
+ itEnd = __attributeLocations.end();
+ for (it = __attributeLocations.begin(); it != itEnd; ++it)
{
- PRINT("_GlShaderProgram::GetAttribLocation: Invalid location! [%s]\n", name);
+ if ((it->first).first == location)
+ {
+ return true;
+ }
}
- __shaderVariableList.push_back(shaderVariable);
+ itEnd = __uniformLocations.end();
+ for (it = __uniformLocations.begin(); it != itEnd; ++it)
+ {
+ if ((it->first).first == location)
+ {
+ return true;
+ }
+ }
- return shaderVariable.value;
- }
- else
- {
- return (unsigned int)(*iter).value;
- }
+ return false;
}
-int
-_GlShaderProgram::GetUniformLocation(const char* name)
-{
- int location = glGetUniformLocation(__program, name);
-
- if (location == -1)
- {
- PRINT("_GlShaderProgram::GetUniformLocation: Invalid location! [%s]\n", name);
- }
+ int
+ _GlShaderProgram::GetParameter(const ProgramLocation location) const
+ {
- return location;
-}
+ int result = -1;
+ result = GetAttributes(location);
+ if (-1 == result)
+ {
+ result = GetUniforms(location);
+ }
+ return result;
+ }
-//================================================================================================================
-_GlColorShaderProgram::_GlColorShaderProgram(void)
- : __attrLocationPosition(-1)
- , __attrLocationColor(-1)
- , __uniformLocationMVP(-1)
+bool
+_GlShaderProgram::IsParameterAvailable(const Tizen::Base::String& name) const
{
+ containerLocations::const_iterator it;
+ containerLocations::const_iterator itEnd;
+ itEnd = __attributeLocations.end();
+ for (it = __attributeLocations.begin(); it != itEnd; ++it)
+ {
+ if (String::Compare((it->first).second, name) == 0)
+ {
+ return true;
+ }
+ }
+
+ itEnd = __uniformLocations.end();
+ for (it = __uniformLocations.begin(); it != itEnd; ++it)
+ {
+ if (String::Compare((it->first).second, name) == 0)
+ {
+ return true;
+ }
+ }
+ return false;
}
-_GlColorShaderProgram::~_GlColorShaderProgram(void)
+char *
+PrintError(const ProgramLocation location)
{
+ if (location < 0 | location >= PROGRAM_LOCATION_MAX-1)
+ {
+ return "Undefined ProgramLocation";
+ }
+ static char *Errors[PROGRAM_LOCATION_MAX] = {
+ "UNIFORM_MAT4_MVP",
+ "UNIFORM_VEC4_COLOR",
+ "UNIFORM_SAMPLER2D_TEXTURE",
+ "UNIFORM_FLOAT_OPACITY",
+ "UNIFORM_MAT4_MODEL_VIEW",
+ "UNIFORM_MAT4_INV_MODEL_VIEW",
+ "UNIFORM_INT_LIGHT_TYPE",
+ "UNIFORM_INT_LIGHT_STRUCT_TYPE",
+ "UNIFORM_VEC4_LIGHT_AMBIENT",
+ "UNIFORM_VEC4_LIGHT_STRUCT_AMBIENT",
+ "UNIFORM_VEC4_LIGHT_DIFFUSE",
+ "UNIFORM_VEC4_LIGHT_STRUCT_DIFFUSE",
+ "UNIFORM_VEC4_LIGHT_SPECULAR",
+ "UNIFORM_VEC4_LIGHT_STRUCT_SPECULAR",
+ "UNIFORM_VEC4_LIGHT_POSITION",
+ "UNIFORM_VEC4_LIGHT_STRUCT_POSITION",
+ "UNIFORM_VEC3_LIGHT_DIRECTION",
+ "UNIFORM_VEC3_LIGHT_STRUCT_DIRECTION",
+ "UNIFORM_FLOAT_LIGHT_EXPONENT",
+ "UNIFORM_FLOAT_LIGHT_STRUCT_EXPONENT",
+ "UNIFORM_FLOAT_LIGHT_CUTOFF",
+ "UNIFORM_FLOAT_LIGHT_STRUCT_CUTOFF",
+ "UNIFORM_VEC3_LIGHT_ATTENUATION",
+ "UNIFORM_VEC3_LIGHT_STRUCT_ATTENUATION",
+ "UNIFORM_VEC4_MATERIAL_AMBIENT",
+ "UNIFORM_VEC4_MATERIAL_STRUCT_AMBIENT",
+ "UNIFORM_VEC4_MATERIAL_DIFFUSE",
+ "UNIFORM_VEC4_MATERIAL_STRUCT_DIFFUSE",
+ "UNIFORM_VEC4_MATERIAL_SPECULAR",
+ "UNIFORM_VEC4_MATERIAL_STRUCT_SPECULAR",
+ "UNIFORM_VEC4_MATERIAL_EMISSIVE",
+ "UNIFORM_VEC4_MATERIAL_STRUCT_EMISSIVE",
+ "UNIFORM_FLOAT_MATERIAL_SHININESS",
+ "UNIFORM_FLOAT_MATERIAL_STRUCT_SHININESS",
+ "ATTRIBUTE_VEC2_TEXTURE_COORD",
+ "ATTRIBUTE_VEC4_POSITION",
+ "ATTRIBUTE_VEC4_COLOR",
+ "ATTRIBUTE_VEC3_NORMAL",
+ };
+ return Errors[location];
}
-
void
-_GlColorShaderProgram::OnProgramCreated(void)
-{
- _GlShaderProgram::OnProgramCreated();
-
- __attrLocationPosition = GetAttribLocation("a_position");
- __attrLocationColor = GetAttribLocation("a_color");
- __uniformLocationMVP = GetUniformLocation("u_mvp");
+_GlShaderProgram::BindAttributes()
+{
+ static char *attributes[PROGRAM_LOCATION_MAX-1] = {
+ "u_mvp",
+ "u_color",
+ "u_tex2d",
+ "u_opacity",
+ "u_modelview",
+ "u_inv_modelview",
+ "u_lighttype",
+ "u_light.type",
+ "u_lightambient",
+ "u_light.ambient",
+ "u_lightdiffuse",
+ "u_light.diffuse",
+ "u_lightspecular",
+ "u_light.specular",
+ "u_lightposition",
+ "u_light.position",
+ "u_lightdirectional",
+ "u_light.directional",
+ "u_lightexponent",
+ "u_light.exponent",
+ "u_lightcutoff",
+ "u_light.cutoff",
+ "u_lightattenuation",
+ "u_light.attenuation",
+ "u_materialambient",
+ "u_material.ambient",
+ "u_materialdiffuse",
+ "u_material.diffuse",
+ "u_materialspecular",
+ "u_material.specular",
+ "u_materialemissive",
+ "u_material.emissive",
+ "u_materialshininess",
+ "u_material.shininess",
+ "a_texcoord",
+ "a_position",
+ "a_color",
+ "a_normal",
+ };
+
+ int glAttribute = -1;
+ for (int i = 0; i < PROGRAM_LOCATION_MAX-1; ++i)
+ {
+ if ((glAttribute = glGetAttribLocation(__program, attributes[i])) != -1)
+ {
+ String locationName(attributes[i]);
+ __attributeLocations.push_back(pair <pair<ProgramLocation, String>, int>(pair<ProgramLocation, String>((ProgramLocation)i, locationName), glAttribute));
+ locationVec->push_back(pair<ProgramLocation, int>((ProgramLocation)i, glAttribute));
+ }
+ if ((glAttribute = glGetUniformLocation(__program, attributes[i])) != -1)
+ {
+ String locationName(attributes[i]);
+ __uniformLocations.push_back(pair <pair<ProgramLocation, String>, int>(pair<ProgramLocation, String>((ProgramLocation)i, locationName), glAttribute));
+ locationVec->push_back(pair<ProgramLocation, int>((ProgramLocation)i, glAttribute));
+ }
+ }
+ return;
}
-void
-_GlColorShaderProgram::OnProgramReferenced(void)
+result
+_GlShaderProgram::SetUniform(const Tizen::Base::String& name, const Tizen::Ui::Variant& value)
{
- _GlShaderProgram::OnProgramReferenced();
+ std::vector<GlUniformStruct >::iterator it;
+ std::vector<GlUniformStruct >::iterator itend;
+ itend = glUniforms.end();
+ for (it = glUniforms.begin(); it != itend; ++it)
+ {
+ if (String::Compare(it->name, name) == 0)
+ {
+ it->data = value;
+ return E_SUCCESS;
+ }
+ }
- glEnableVertexAttribArray(__attrLocationPosition);
- glEnableVertexAttribArray(__attrLocationColor);
+ return BindUniform(UNIFORM_USER_DATA, name, value);
}
void
-_GlColorShaderProgram::OnProgramDereferenced(void)
+_GlShaderProgram::BindGlUniforms(void)
{
- _GlShaderProgram::OnProgramDereferenced();
-
- glDisableVertexAttribArray(__attrLocationPosition);
- glDisableVertexAttribArray(__attrLocationColor);
+ if (!__hasGlUniforms)
+ {
+ return;
+ }
+ std::vector<GlUniformStruct >::iterator it;
+ std::vector<GlUniformStruct >::iterator itend;
+ itend = glUniforms.end();
+ for (it = glUniforms.begin(); it != itend; ++it)
+ {
+ //if (it->location == UNIFORM_USER_DATA)
+ //{
+ switch ((*it).data.GetType())
+ {
+ case VARIANT_TYPE_FLOAT:
+ glUniform1f((*it).glLocation, (*it).data.ToFloat());
+ break;
+ case VARIANT_TYPE_INT:
+ glUniform1i((*it).glLocation, (*it).data.ToInt());
+ break;
+ case VARIANT_TYPE_FLOAT_MATRIX4:
+ glUniformMatrix4fv((*it).glLocation, 1, GL_FALSE, (GLfloat*)(*it).data.ToFloatMatrix4().matrix);
+ break;
+ case VARIANT_TYPE_COLOR:
+ glUniform4f((*it).glLocation, (*it).data.ToColor().GetRed()/255.0, (*it).data.ToColor().GetGreen()/255.0,
+ (*it).data.ToColor().GetBlue()/255.0, (*it).data.ToColor().GetAlpha()/255.0);
+ break;
+ case VARIANT_TYPE_FLOAT_POINT3:
+ glUniform3fv((*it).glLocation, 1, &(*it).data.ToFloatPoint3().x);
+ break;
+ case VARIANT_TYPE_FLOAT_VECTOR4:
+ glUniform4fv((*it).glLocation, 1, &(*it).data.ToFloatVector4().x);
+ break;
+ default:
+ return;
+ }
+ //}
+ }
}
-//================================================================================================================
-_GlUniformColorShaderProgram::_GlUniformColorShaderProgram(void)
- : __attrLocationPosition(-1)
- , __uniformLocationMVP(-1)
- , __uniformLocationColor(-1)
+std::vector< std::pair<ProgramLocation, int> >*
+_GlShaderProgram::ParameterList(void)
{
+ return locationVec;
}
-_GlUniformColorShaderProgram::~_GlUniformColorShaderProgram(void)
+int
+_GlShaderProgram::GetAttributes(const ProgramLocation location) const
{
+ containerLocations::const_iterator it;
+ containerLocations::const_iterator itEnd;
+ int result = -1;
+ itEnd = __attributeLocations.end();
+ for (it = __attributeLocations.begin(); it != itEnd; ++it)
+ {
+ if ((it->first).first == location)
+ {
+ result = it->second;
+ break;
+ }
+ }
+ return result;
}
-void
-_GlUniformColorShaderProgram::OnProgramCreated(void)
-{
- _GlShaderProgram::OnProgramCreated();
- __attrLocationPosition = GetAttribLocation("a_position");
- __uniformLocationMVP = GetUniformLocation("u_mvp");
- __uniformLocationColor = GetUniformLocation("u_color");
+int
+_GlShaderProgram::GetUniforms(const ProgramLocation location) const
+{
+ containerLocations::const_iterator it;
+ containerLocations::const_iterator itEnd;
+ int result = -1;
+ itEnd = __uniformLocations.end();
+ for (it = __uniformLocations.begin(); it != itEnd; ++it)
+ {
+ if ((it->first).first == location)
+ {
+ result = it->second;
+ break;
+ }
+ }
+ return result;
}
-void
-_GlUniformColorShaderProgram::OnProgramReferenced(void)
-{
- _GlShaderProgram::OnProgramReferenced();
- glEnableVertexAttribArray(__attrLocationPosition);
-}
void
-_GlUniformColorShaderProgram::OnProgramDereferenced(void)
+_GlShaderProgram::OnProgramReferenced(void)
{
- _GlShaderProgram::OnProgramDereferenced();
+ containerLocations::iterator it;
+ containerLocations::iterator itEnd;
- glDisableVertexAttribArray(__attrLocationPosition);
+ itEnd = __attributeLocations.end();
+ for (it = __attributeLocations.begin(); it != itEnd; ++it)
+ {
+ glEnableVertexAttribArray(it->second);
+ }
+ return;
}
-//================================================================================================================
-
-_GlTextureShaderProgram::_GlTextureShaderProgram(void)
- : __attrLocationPosition(-1)
- , __attrLocationTextureCoordinates(-1)
- , __uniformLocationMVP(-1)
- , __uniformLocationTexture2D(-1)
+void
+_GlShaderProgram::OnProgramDereferenced(void)
{
-}
+ containerLocations::iterator it;
+ containerLocations::iterator itEnd;
-_GlTextureShaderProgram::~_GlTextureShaderProgram(void)
-{
+ itEnd = __attributeLocations.end();
+ for (it = __attributeLocations.begin(); it != itEnd; ++it)
+ {
+ glDisableVertexAttribArray(it->second);
+ }
+ return;
}
-void
-_GlTextureShaderProgram::OnProgramCreated(void)
+result
+_GlShaderProgram::BindAttribute(const ProgramLocation location,const Tizen::Base::String &name)
{
- _GlShaderProgram::OnProgramCreated();
+ SysTryReturnResult(NID_UI_ANIM, location > 0 & location < PROGRAM_LOCATION_MAX, E_INVALID_ARG, "Undefined ProgramLocation");
+ std::wstring wStr(name.GetPointer());
+ std::string locationName(wStr.begin(), wStr.end());
+ int glAttribute;
+ containerLocations::iterator it;
+ containerLocations::iterator itEnd;
- __attrLocationPosition = GetAttribLocation("a_position");
- __uniformLocationMVP = GetUniformLocation("u_mvp");
-
- __attrLocationTextureCoordinates = GetAttribLocation("a_texcoord");
- __uniformLocationTexture2D = GetUniformLocation("u_tex2d");
+ itEnd = __attributeLocations.end();
+ for (it = __attributeLocations.begin(); it != itEnd; ++it)
+ {
+ SysTryReturnResult(NID_UI_ANIM, (*it).first.first != location, E_INVALID_ARG, "\"%s\" is already binded",PrintError(location));
+ SysTryReturnResult(NID_UI_ANIM, String::Compare((it->first).second, name) != 0, E_INVALID_ARG, "\"%s\" is already binded",locationName.c_str());
+ }
- glUseProgram(GetProgram());
+ glAttribute = glGetAttribLocation(__program, locationName.c_str());
- glUniform1i(GetTexture2DUniformLocation(), 0);
-}
+ SysTryReturnResult(NID_UI_ANIM, glAttribute != -1, E_INVALID_ARG, "Can't bind a \"%s\" attribute", locationName.c_str());
-void
-_GlTextureShaderProgram::OnProgramReferenced(void)
-{
- _GlShaderProgram::OnProgramReferenced();
+ __attributeLocations.push_back(pair< pair<ProgramLocation, String>, int>(pair<ProgramLocation, String>(location, name), glAttribute));
+ locationVec->push_back(pair<ProgramLocation, int>(location, glAttribute));
- glEnableVertexAttribArray(__attrLocationPosition);
- glEnableVertexAttribArray(__attrLocationTextureCoordinates);
+ return E_SUCCESS;
}
-void
-_GlTextureShaderProgram::OnProgramDereferenced(void)
+result
+_GlShaderProgram::BindUniform(const ProgramLocation location, const Tizen::Base::String &name, const Tizen::Ui::Variant& value)
{
- _GlShaderProgram::OnProgramDereferenced();
+ SysTryReturnResult(NID_UI_ANIM, location > 0 & location < PROGRAM_LOCATION_MAX, E_INVALID_ARG, "Undefined ProgramLocation");
- glDisableVertexAttribArray(__attrLocationPosition);
- glDisableVertexAttribArray(__attrLocationTextureCoordinates);
-}
+ std::wstring wStr(name.GetPointer());
+ std::string locationName(wStr.begin(), wStr.end());
-//================================================================================================================
+ int glAttribute;
-_GlTextureOpacityShaderProgram::_GlTextureOpacityShaderProgram(void)
- : __attrLocationPosition(-1)
- , __attrLocationTextureCoordinates(-1)
- , __uniformLocationMVP(-1)
- , __uniformLocationOpacity(-1)
- , __uniformLocationTexture2D(-1)
-{
-}
+ containerLocations::iterator it;
+ containerLocations::iterator itEnd;
+ itEnd = __uniformLocations.end();
-_GlTextureOpacityShaderProgram::~_GlTextureOpacityShaderProgram(void)
-{
-}
+ for (it = __uniformLocations.begin(); it != itEnd; ++it)
+ {
+ SysTryReturnResult(NID_UI_ANIM, String::Compare((it->first).second, name) != 0, E_INVALID_ARG, "\"%s\" is already binded",locationName.c_str());
+ }
-void
-_GlTextureOpacityShaderProgram::OnProgramCreated(void)
-{
- _GlShaderProgram::OnProgramCreated();
+ glAttribute = glGetUniformLocation(__program, locationName.c_str());
- __attrLocationPosition = GetAttribLocation("a_position");
- __uniformLocationMVP = GetUniformLocation("u_mvp");
+ SysTryReturnResult(NID_UI_ANIM, glAttribute != -1, E_INVALID_ARG, "Can't bind a \"%s\" uniform", locationName.c_str());
- __attrLocationTextureCoordinates = GetAttribLocation("a_texcoord");
- __uniformLocationOpacity = GetUniformLocation("u_opacity");
- __uniformLocationTexture2D = GetUniformLocation("u_tex2d");
+ if (location == UNIFORM_USER_DATA)
+ {
+ __hasGlUniforms = true;
+ GlUniformStruct data;
+ data.data = value;
+ data.name = name;
+ data.location = location;
+ data.glLocation = glAttribute;
+ glUniforms.push_back(data);
+ }
- glUseProgram(GetProgram());
+ //__uniformLocations.push_back(pair< pair<ProgramLocation, String>, int>(pair<ProgramLocation, String>(location, name), glAttribute));
+ //locationVec->push_back(pair<ProgramLocation, int>(location, glAttribute));
- glUniform1i(GetTexture2DUniformLocation(), 0);
+ return E_SUCCESS;
}
+/*
void
-_GlTextureOpacityShaderProgram::OnProgramReferenced(void)
+_GlShaderProgram::SetProgram(unsigned int program)
{
- _GlShaderProgram::OnProgramReferenced();
-
- glEnableVertexAttribArray(__attrLocationPosition);
- glEnableVertexAttribArray(__attrLocationTextureCoordinates);
+__program = program;
}
-
-void
-_GlTextureOpacityShaderProgram::OnProgramDereferenced(void)
+*/
+/*
+bool
+_GlShaderProgram::LoadShader(const char* pVertexShaderBin, int vertexLength, const char* pFragmentShaderBin, int fragmentLength)
{
- _GlShaderProgram::OnProgramDereferenced();
-
- glDisableVertexAttribArray(__attrLocationPosition);
- glDisableVertexAttribArray(__attrLocationTextureCoordinates);
+ return true;
}
-
-//================================================================================================================
-
-_GlLightShaderProgram::_GlLightShaderProgram(void)
- : __attrLocationPosition(-1)
- , __attrLocationTextureCoordinates(-1)
- , __attrLocationColor(-1)
- , __attrLocationNormal(-1)
- , __uniformLocationMVP(-1)
- , __uniformLocationTexture2D(-1)
- , __uniformLocModelView(-1)
- , __uniformLocInvModelView(-1)
- , __uniformLocLightType(-1)
- , __uniformLocLightAmbient(-1)
- , __uniformLocLightDiffuse(-1)
- , __uniformLocLightSpecular(-1)
- , __uniformLocLightPosition(-1)
- , __uniformLocLightDirection(-1)
- , __uniformLocLightExponent(-1)
- , __uniformLocLightCutOff(-1)
- , __uniformLocLightAttenuation(-1)
- , __uniformLocMaterialAmbient(-1)
- , __uniformLocMaterialDiffuse(-1)
- , __uniformLocMaterialSpecular(-1)
- , __uniformLocMaterialEmissive(-1)
- , __uniformLocMaterialShiness(-1)
+*/
+/*
+int
+_GlShaderProgram::GetAttribLocation(const char* name)
{
-}
+ vector<ShaderVariable>::iterator iter = find(__shaderVariableList.begin(), __shaderVariableList.end(), name);
-_GlLightShaderProgram::~_GlLightShaderProgram(void)
-{
-}
+ if (iter == __shaderVariableList.end())
+ {
+ ShaderVariable shaderVariable;
-void
-_GlLightShaderProgram::OnProgramCreated(void)
-{
- _GlShaderProgram::OnProgramCreated();
-
- __attrLocationPosition = GetAttribLocation("a_position");
- __attrLocationTextureCoordinates = GetAttribLocation("a_texcoord");
- __attrLocationColor = GetAttribLocation("a_color");
- __attrLocationNormal = GetAttribLocation("a_normal");
-
- __uniformLocationMVP = GetUniformLocation("u_mvp");
- __uniformLocationTexture2D = GetUniformLocation("u_tex2d");
-
- __uniformLocModelView = GetUniformLocation("u_modelview");
- __uniformLocInvModelView = GetUniformLocation("u_inv_modelview");
-
- __uniformLocLightType = GetUniformLocation("u_light.type");
- __uniformLocLightAmbient = GetUniformLocation("u_light.ambient");
- __uniformLocLightDiffuse = GetUniformLocation("u_light.diffuse");
- __uniformLocLightSpecular = GetUniformLocation("u_light.specular");
- __uniformLocLightPosition = GetUniformLocation("u_light.position");
- __uniformLocLightDirection = GetUniformLocation("u_light.direction");
- __uniformLocLightExponent = GetUniformLocation("u_light.exponent");
- __uniformLocLightCutOff = GetUniformLocation("u_light.cutoff");
- __uniformLocLightAttenuation = GetUniformLocation("u_light.attenuation");
-
- __uniformLocMaterialAmbient = GetUniformLocation("u_material.ambient");
- __uniformLocMaterialDiffuse = GetUniformLocation("u_material.diffuse");
- __uniformLocMaterialSpecular = GetUniformLocation("u_material.specular");
- __uniformLocMaterialEmissive = GetUniformLocation("u_material.emissive");
- __uniformLocMaterialShiness = GetUniformLocation("u_material.shiness");
-
- glUseProgram(GetProgram());
-
- glUniform1i(GetTexture2DUniformLocation(), 0);
-}
+ shaderVariable.name = new char[strlen(name) + 1];
+ strncpy(shaderVariable.name, name, strlen(name));
+
+ shaderVariable.value = glGetAttribLocation(__program, name);
-void
-_GlLightShaderProgram::OnProgramReferenced(void)
-{
- _GlShaderProgram::OnProgramReferenced();
+ if (shaderVariable.value == -1)
+ {
+ PRINT("_GlShaderProgram::GetAttribLocation: Invalid location! [%s]\n", name);
+ }
- glEnableVertexAttribArray(__attrLocationPosition);
- glEnableVertexAttribArray(__attrLocationTextureCoordinates);
- glEnableVertexAttribArray(__attrLocationColor);
- glEnableVertexAttribArray(__attrLocationNormal);
-}
+ __shaderVariableList.push_back(shaderVariable);
-void
-_GlLightShaderProgram::OnProgramDereferenced(void)
+ return shaderVariable.value;
+ }
+ else
+ {
+ return (unsigned int)(*iter).value;
+ }
+}
+*/
+/*
+int
+_GlShaderProgram::GetUniformLocation(const char* name)
{
- _GlShaderProgram::OnProgramDereferenced();
+ int location = glGetUniformLocation(__program, name);
- glDisableVertexAttribArray(__attrLocationPosition);
- glDisableVertexAttribArray(__attrLocationTextureCoordinates);
- glDisableVertexAttribArray(__attrLocationColor);
- glDisableVertexAttribArray(__attrLocationNormal);
+ if (location == -1)
+ {
+ PRINT("_GlShaderProgram::GetUniformLocation: Invalid location! [%s]\n", name);
+ }
+
+ return location;
}
*/
}}} // Tizen::Ui::Animations
#include <FBaseErrorDefine.h>
#include <FBaseDataType.h>
-#include "FUiAnimShaderProgram.h"
+#include "FUiVariant.h"
+#include <FBaseObject.h>
+#include <FBaseString.h>
namespace Tizen { namespace Ui { namespace Animations
{
+class _GlContext;
/*
class ShaderVariable
{
char* name;
};
*/
+/**
+ * @enum ProgramLocation
+ *
+ * Defines the basic types for program location in shader program.
+ *
+ *
+ * @since 3.0
+ */
+enum ProgramLocation
+ {
+ UNIFORM_MAT4_MVP = 0, /**< Uniform for matrix view projection*/
+ UNIFORM_VEC4_COLOR, /**< Uniform for color*/
+ UNIFORM_SAMPLER2D_TEXTURE, /**< Uniform for texture*/
+ UNIFORM_FLOAT_OPACITY, /**< Uniform for opacity*/
+ UNIFORM_MAT4_MODEL_VIEW, /**< Uniform for model view matrix*/
+ UNIFORM_MAT4_INV_MODEL_VIEW, /**< Uniform for inverted model view*/
+ UNIFORM_INT_LIGHT_TYPE, /**< Uniform for light type*/
+ UNIFORM_INT_LIGHT_STRUCT_TYPE, /**< Uniform for light type defined in struct*/
+ UNIFORM_VEC4_LIGHT_AMBIENT, /**< Uniform for light ambient*/
+ UNIFORM_VEC4_LIGHT_STRUCT_AMBIENT, /**< Uniform for light ambient defined in struct*/
+ UNIFORM_VEC4_LIGHT_DIFFUSE, /**< Uniform for light diffuse*/
+ UNIFORM_VEC4_LIGHT_STRUCT_DIFFUSE, /**< Uniform for light diffuse defined in struct*/
+ UNIFORM_VEC4_LIGHT_SPECULAR, /**< Uniform for light specular*/
+ UNIFORM_VEC4_LIGHT_STRUCT_SPECULAR, /**< Uniform for light specular defined in struct*/
+ UNIFORM_VEC4_LIGHT_POSITION, /**< Uniform for light position*/
+ UNIFORM_VEC4_LIGHT_STRUCT_POSITION, /**< Uniform for light position defined in struct*/
+ UNIFORM_VEC3_LIGHT_DIRECTION, /**< Uniform for light direction*/
+ UNIFORM_VEC3_LIGHT_STRUCT_DIRECTION, /**< Uniform for light direction defined in struct */
+ UNIFORM_FLOAT_LIGHT_EXPONENT, /**< Uniform for light exponent*/
+ UNIFORM_FLOAT_LIGHT_STRUCT_EXPONENT, /**< Uniform for light exponent defined in struct*/
+ UNIFORM_FLOAT_LIGHT_CUTOFF, /**< Uniform for light cutoff*/
+ UNIFORM_FLOAT_LIGHT_STRUCT_CUTOFF, /**< Uniform for light cutoff defined in struct*/
+ UNIFORM_VEC3_LIGHT_ATTENUATION, /**< Uniform for light attenuation*/
+ UNIFORM_VEC3_LIGHT_STRUCT_ATTENUATION, /**< Uniform for light attenuation defined in struct*/
+ UNIFORM_VEC4_MATERIAL_AMBIENT, /**< Uniform for material ambient*/
+ UNIFORM_VEC4_MATERIAL_STRUCT_AMBIENT, /**< Uniform for material ambient defined in struct*/
+ UNIFORM_VEC4_MATERIAL_DIFFUSE, /**< Uniform for material diffuse*/
+ UNIFORM_VEC4_MATERIAL_STRUCT_DIFFUSE, /**< Uniform for material diffuse defined in struct*/
+ UNIFORM_VEC4_MATERIAL_SPECULAR, /**< Uniform for material specular*/
+ UNIFORM_VEC4_MATERIAL_STRUCT_SPECULAR, /**< Uniform for material specular defined in struct*/
+ UNIFORM_VEC4_MATERIAL_EMISSIVE, /**< Uniform for material emissive*/
+ UNIFORM_VEC4_MATERIAL_STRUCT_EMISSIVE, /**< Uniform for material emissive defined in struct*/
+ UNIFORM_FLOAT_MATERIAL_SHININESS, /**< Uniform for material shininess*/
+ UNIFORM_FLOAT_MATERIAL_STRUCT_SHININESS, /**< Uniform for material shininess defined in struct*/
+ ATTRIBUTE_VEC2_TEXTURE_COORD, /**< Attribute for texture coordinate*/
+ ATTRIBUTE_VEC4_POSITION, /**< Attribute for position*/
+ ATTRIBUTE_VEC4_COLOR, /**< Attribute for color*/
+ ATTRIBUTE_VEC3_NORMAL, /**< Attribute for normal*/
+ UNIFORM_USER_DATA, /**< Test Uniform*/
+ PROGRAM_LOCATION_MAX /**< Maximum of program location*/
+ };
class _GlShaderProgram
{
public:
- _GlShaderProgram(void);
- virtual ~_GlShaderProgram(void);
+ typedef struct GlUniformStruct
+ {
+ ProgramLocation location;
+ unsigned int glLocation;
+ Tizen::Base::String name;
+ Tizen::Ui::Variant data;
+ };
- //bool LoadShader(const char* pVertexShaderSrc, const char* pFragmentShaderSrc);
+ _GlShaderProgram(unsigned int program = -1);
+ virtual ~_GlShaderProgram(void);
//bool LoadShader(const char* pVertexShaderBin, int vertexLength, const char* pFragmentShaderBin, int fragmentLength);
- void SetProgram(unsigned int program);
int GetProgram(void) const { return __program; }
- //int GetAttribLocation(const char* name);
- //int GetUniformLocation(const char* name);
- virtual std::vector< std::pair<ProgramLocation, int> > *ParameterList() = 0;
- virtual int GetParameter(const ProgramLocation location) const {return -1;}
-
-// virtual int GetMVPUniformLocation(void) const { return -1; }
-// virtual int GetColorUniformLocation(void) const { return -1; }
-// virtual int GetOpacityUniformLocation(void) const { return -1; }
-// virtual int GetTexture2DUniformLocation(void) const { return -1; }
-//
-// virtual int GetPositionAttributeLocation(void) const { return -1; }
-// virtual int GetTextureCoordinatesAttributeLocation(void) const { return -1; }
-// virtual int GetColorAttributeLocation(void) const { return -1; }
-// virtual int GetNormalAttributeLocation(void) const { return -1; }
-
-public:
- //virtual void OnProgramCreated(void) {}
- virtual void OnProgramReferenced(void) {}
- virtual void OnProgramDereferenced(void) {}
-
+ Variant GetUniform(const Tizen::Base::String& name) const;
+ int GetParameter(const ProgramLocation location) const; // Need it ?
+ std::vector< std::pair<ProgramLocation, int> > *ParameterList();
+ void BindAttributes(void);
+ bool IsParameterAvailable(const ProgramLocation location) const; // Need it ?
+ bool IsParameterAvailable(const Tizen::Base::String& name) const; // Need it ?
+ int GetAttributes(const ProgramLocation location) const;
+ int GetUniforms(const ProgramLocation location) const;
+ result BindAttribute(const ProgramLocation location, const Tizen::Base::String& name); // Need it ?
+ result BindUniform(const ProgramLocation location, const Tizen::Base::String& name, const Tizen::Ui::Variant& value);
+ result SetUniform(const Tizen::Base::String& name, const Tizen::Ui::Variant& value);
+ void BindGlUniforms(void);
protected:
+ //virtual void OnProgramCreated(void) {} // Need it ?
+ void OnProgramReferenced(void);
+ void OnProgramDereferenced(void);
+protected: //TODO private
int __program;
int __vertexShader;
int __fragmentShader;
-
//std::vector<ShaderVariable> __shaderVariableList;
private:
+ typedef std::vector<std::pair< std::pair<ProgramLocation, Tizen::Base::String>, int> > containerLocations;
+ std::vector<std::pair<ProgramLocation, int> > *locationVec;
+ containerLocations __attributeLocations;
+ containerLocations __uniformLocations;
+ std::vector<GlUniformStruct> glUniforms;
+ bool __hasGlUniforms;
friend class _GlContext;
friend class _Egl;
friend class _Wgl;
};
-
-class _GlColorShaderProgram
- : public _GlShaderProgram
-{
-public:
- _GlColorShaderProgram(void);
- virtual ~_GlColorShaderProgram(void);
-
- virtual void OnProgramCreated(void);
- virtual void OnProgramReferenced(void);
- virtual void OnProgramDereferenced(void);
-
- virtual int GetMVPUniformLocation(void) const { return __uniformLocationMVP; }
-
- virtual int GetPositionAttributeLocation(void) const { return __attrLocationPosition; }
- virtual int GetColorAttributeLocation(void) const { return __attrLocationColor; }
-
-private:
- int __attrLocationPosition;
- int __attrLocationColor;
- int __uniformLocationMVP;
-};
-
-class _GlUniformColorShaderProgram
- : public _GlShaderProgram
-{
-public:
- _GlUniformColorShaderProgram(void);
- virtual ~_GlUniformColorShaderProgram(void);
-
- virtual void OnProgramCreated(void);
- virtual void OnProgramReferenced(void);
- virtual void OnProgramDereferenced(void);
-
- virtual int GetMVPUniformLocation(void) const { return __uniformLocationMVP; }
- virtual int GetColorUniformLocation(void) const { return __uniformLocationColor; }
-
- virtual int GetPositionAttributeLocation(void) const { return __attrLocationPosition; }
-
-private:
- int __attrLocationPosition;
- int __uniformLocationMVP;
- int __uniformLocationColor;
-};
-
-class _GlTextureShaderProgram
- : public _GlShaderProgram
-{
-public:
- _GlTextureShaderProgram(void);
- virtual ~_GlTextureShaderProgram(void);
-
- virtual void OnProgramCreated(void);
- virtual void OnProgramReferenced(void);
- virtual void OnProgramDereferenced(void);
-
- virtual int GetMVPUniformLocation(void) const { return __uniformLocationMVP; }
- virtual int GetTexture2DUniformLocation(void) const { return __uniformLocationTexture2D; }
-
- virtual int GetPositionAttributeLocation(void) const { return __attrLocationPosition; }
- virtual int GetTextureCoordinatesAttributeLocation(void) const { return __attrLocationTextureCoordinates; }
-
-private:
- int __attrLocationPosition;
- int __attrLocationTextureCoordinates;
- int __uniformLocationMVP;
- int __uniformLocationTexture2D;
-};
-
-class _GlTextureOpacityShaderProgram
- : public _GlShaderProgram
-{
-public:
- _GlTextureOpacityShaderProgram(void);
- virtual ~_GlTextureOpacityShaderProgram(void);
-
- virtual void OnProgramCreated(void);
- virtual void OnProgramReferenced(void);
- virtual void OnProgramDereferenced(void);
-
- virtual int GetMVPUniformLocation(void) const { return __uniformLocationMVP; }
- virtual int GetOpacityUniformLocation(void) const { return __uniformLocationOpacity; }
- virtual int GetTexture2DUniformLocation(void) const { return __uniformLocationTexture2D; }
-
- virtual int GetPositionAttributeLocation(void) const { return __attrLocationPosition; }
- virtual int GetTextureCoordinatesAttributeLocation(void) const { return __attrLocationTextureCoordinates; }
-
-private:
- int __attrLocationPosition;
- int __attrLocationTextureCoordinates;
- int __uniformLocationMVP;
- int __uniformLocationOpacity;
- int __uniformLocationTexture2D;
-};
-
-class _GlLightShaderProgram
- : public _GlShaderProgram
-{
-public:
- _GlLightShaderProgram(void);
- virtual ~_GlLightShaderProgram(void);
-
- virtual void OnProgramCreated(void);
- virtual void OnProgramReferenced(void);
- virtual void OnProgramDereferenced(void);
-
- virtual int GetMVPUniformLocation(void) const { return __uniformLocationMVP; }
- virtual int GetTexture2DUniformLocation(void) const { return __uniformLocationTexture2D; }
-
- virtual int GetPositionAttributeLocation(void) const { return __attrLocationPosition; }
- virtual int GetTextureCoordinatesAttributeLocation(void) const { return __attrLocationTextureCoordinates; }
- virtual int GetColorAttributeLocation(void) const { return __attrLocationColor; }
- virtual int GetNormalAttributeLocation(void) const { return __attrLocationNormal; }
-
-private:
- int __attrLocationPosition;
- int __attrLocationTextureCoordinates;
- int __attrLocationColor;
- int __attrLocationNormal;
-
- int __uniformLocationMVP;
- int __uniformLocationTexture2D;
-
-public:
- int __uniformLocModelView;
- int __uniformLocInvModelView;
-
- int __uniformLocLightType;
- int __uniformLocLightAmbient;
- int __uniformLocLightDiffuse;
- int __uniformLocLightSpecular;
- int __uniformLocLightPosition;
- int __uniformLocLightDirection;
- int __uniformLocLightExponent;
- int __uniformLocLightCutOff;
- int __uniformLocLightAttenuation;
-
- int __uniformLocMaterialAmbient;
- int __uniformLocMaterialDiffuse;
- int __uniformLocMaterialSpecular;
- int __uniformLocMaterialEmissive;
- int __uniformLocMaterialShiness;
-};
-
}}} //Tizen::Ui::Animations
#endif //_FUI_ANIM_INTERNAL_GL_SHADER_PROGRAM_H_
// See the License for the specific language governing permissions and
// limitations under the License.
//
-#include <libxml/tree.h>
#include "FUiAnim_MaterialImpl.h"
#include <FUiAnimMaterial.h>
#include "FUiAnim_Mutex.h"
#include "FUiAnim_VisualElementImpl.h"
#include "FUiAnim_MeshImpl.h"
-
+#include <stdint.h>
+#include <string>
using namespace Tizen::Graphics;
using namespace Tizen::Ui::Animations::_Math;
#define MESH_LOCK() _AutoMutex meshLock(*__pLock)
+//Header capacity =
+//{
+//};
+
+void
+Header::SetMeshArrays(const _MeshImpl& rhs)
+{
+ isVerticesEnabled = rhs.IsVerticesEnabled();
+ isIndexEnabled = rhs.IsIndexEnabled();
+ isTextureCoordinateEnabled = rhs.IsTextureCoordinateEnabled();
+ isColorEnabled = rhs.IsColorEnabled();
+ isNormalEnabled = rhs.IsNormalEnabled();
+}
+
_MeshImpl*
_MeshImpl::GetInstance(Mesh& mesh)
{
, __countOfAllocatedVertex(0)
, __countOfIndex(0)
, __countOfAllocatedIndex(0)
- , __hasBoundingBox(false)
- , __pPublic(null)
+ , __hasBoundingVolume(false)
+ , __boundingVolume()
{
__pLock = new _Mutex(true);
-
__pPublic = const_cast<Mesh*>(&mesh);
}
__countOfAllocatedIndex = 0;
__boundingVolume.Reset();
- __hasBoundingBox = false;
+ __hasBoundingVolume = false;
return ;
}
__countOfAllocatedVertex = count;
- __pVertices = new (std::nothrow) float[count*3];
+ __pVertices = new (std::nothrow) float[count * APPROPRIATE_COUNT_VERTICES];
if(!__pVertices)
return E_OUT_OF_MEMORY;
- for(int i = 0 ; i < __countOfAllocatedVertex * 3 ; i++)
+ for(int i = 0 ; i < __countOfAllocatedVertex * APPROPRIATE_COUNT_VERTICES; i++)
{
__pVertices[i] = 0.0f;
}
if(__countOfAllocatedVertex <= 0)
return E_INVALID_STATE;
- int count = __countOfAllocatedVertex * 2;
+ int count = __countOfAllocatedVertex * APPROPRIATE_COUNT_TEXTCOORDINATES;
__pTexCoordinates = new (std::nothrow) float[count];
if(!__pTexCoordinates)
return E_OUT_OF_MEMORY;
if(__countOfAllocatedVertex <= 0)
return E_INVALID_STATE;
- int count = __countOfAllocatedVertex * 3;
+ int count = __countOfAllocatedVertex * APPROPRIATE_COUNT_NORMALS;
__pNormals = new (std::nothrow) float[count];
if(!__pNormals)
return E_OUT_OF_MEMORY;
if(__countOfAllocatedVertex <= 0)
return E_INVALID_STATE;
- int count = __countOfAllocatedVertex * 4;
+ int count = __countOfAllocatedVertex * APPROPRIATE_COUNT_COLORS;
__pColors = new (std::nothrow) float[count];
if(!__pColors)
return E_OUT_OF_MEMORY;
return E_SUCCESS;
}
+bool
+_MeshImpl::IsSurfaceClosed()
+{
+ TriangleIndex* pIndxBuf=(TriangleIndex*)__pIndices;
+ if (__countOfIndex != 0)
+ {
+ int iNum = __countOfIndex;
+ std::vector<EdgeIndex> edges(iNum);
+
+ //fill the Edge buffer from Triangles buffer
+
+ for (int cnt = 0; cnt < iNum / 3; cnt++)
+ {
+ int cntt = cnt * 3;
+ edges[cntt].ownerID=cnt;
+ if (pIndxBuf[cnt].v0 <= pIndxBuf[cnt].v1)
+ {
+ edges[cntt].from = pIndxBuf[cnt].v0;
+ edges[cntt].to = pIndxBuf[cnt].v1;
+ edges[cntt].swaped=false;
+ }
+ else
+ {
+ edges[cntt].from = pIndxBuf[cnt].v1;
+ edges[cntt].to = pIndxBuf[cnt].v0;
+ edges[cntt].swaped=true;
+ }
+
+ edges[cntt+1].ownerID=cnt;
+ if (pIndxBuf[cnt].v1 <= pIndxBuf[cnt].v2)
+ {
+ edges[cntt+1].from = pIndxBuf[cnt].v1;
+ edges[cntt+1].to = pIndxBuf[cnt].v2;
+ edges[cntt+1].swaped=false;
+ }
+ else
+ {
+ edges[cntt+1].from = pIndxBuf[cnt].v2;
+ edges[cntt+1].to = pIndxBuf[cnt].v1;
+ edges[cntt+1].swaped=true;
+ }
+
+ edges[cntt+2].ownerID=cnt;
+ if (pIndxBuf[cnt].v2 <= pIndxBuf[cnt].v0)
+ {
+ edges[cntt+2].from = pIndxBuf[cnt].v2;
+ edges[cntt+2].to = pIndxBuf[cnt].v0;
+ edges[cntt+2].swaped=false;
+ }
+ else
+ {
+ edges[cntt+2].from = pIndxBuf[cnt].v0;
+ edges[cntt+2].to = pIndxBuf[cnt].v2;
+ edges[cntt+2].swaped=true;
+ }
+ }
+
+ // sort the Edge buffer
+ std::sort(edges.begin(), edges.end(), _MeshImpl::SortFunc);
+ // analysis the Edge buffer
+ // int ecnt =0;
+ for (int cnt = 1; cnt < iNum; cnt++)
+ {
+ // if (cnt<100){AppLog("->%i %i : %i swaped*%i",edges[cnt].from,edges[cnt].to,edges[cnt].ownerID,edges[cnt].swaped);}
+ if (!(((edges[cnt].to == edges[cnt - 1].to) && (edges[cnt].from == edges[cnt - 1].from)) ||
+ ((edges[cnt].to == edges[cnt + 1].to) && (edges[cnt].from == edges[cnt + 1].from))))
+ {
+ // AppLog("NOT EQUAL! %i",cnt );
+ // if (cnt>=2) {AppLog("%i %i : %i",edges[cnt-2].from,edges[cnt-2].to,edges[cnt-2].ownerID);} // for debug mode
+ // AppLog("%i %i : %i",edges[cnt-1].from,edges[cnt-1].to,edges[cnt-1].ownerID);
+ // AppLog("->%i %i : %i",edges[cnt].from,edges[cnt].to,edges[cnt].ownerID);
+ // AppLog("%i %i : %i",edges[cnt+1].from,edges[cnt+1].to,edges[cnt+1].ownerID);
+ // AppLog("%i %i : %i",edges[cnt+2].from,edges[cnt+2].to,edges[cnt+2].ownerID);
+ // // ecnt++;
+ return false;
+ }
+ }
+ // AppLog("%i edges open",ecnt);
+ return true;
+ }
+ return false;
+
+
+
+}
result
_MeshImpl::SetVertex(int arrayIndex, const FloatPoint3& vertex)
int i = arrayIndex * 3;
- if ( __hasBoundingBox )
+ if ( __hasBoundingVolume )
{
__pVertices[i] = vertex.x - __boundingVolume.GetCenter().x; //x
__pVertices[i+1] = vertex.y - __boundingVolume.GetCenter().y; //y
__pVertices[i+2] = vertex.z; //z
}
- __boundingVolume.Merge(Vector3(vertex.x, vertex.y, vertex.z));
+ __boundingVolume.Merge(vertex);
+
if(__countOfVertex <= arrayIndex )
{
}
result
-_MeshImpl::AdjustBoundingBox(bool rebuild)
+_MeshImpl::AdjustBoundingVolume(bool rebuild)
{
MESH_LOCK();
if(__pVertices)
{
__boundingVolume.Reset();
- __boundingVolume.Merge(__pVertices,__countOfVertex);
- __hasBoundingBox = true;
+
+ FloatPoint3 v;
+ for(int i = 0; i < __countOfVertex; i++)
+ {
+ v.x = __pVertices[i * 3];
+ v.y = __pVertices[i * 3 + 1];
+ v.z = __pVertices[i * 3 + 2];
+ __boundingVolume.Merge(v);
+ }
+
+ __hasBoundingVolume = true;
}
return E_SUCCESS;
}
-FloatPoint3
-_MeshImpl::GetBoundingBoxPosition() const
+BoundingVolume&
+_MeshImpl::GetBoundingVolume()
{
- Vector3 v = __boundingVolume.GetCenter();
- return FloatPoint3(v.x, v.y, v.z);
+ return __boundingVolume;
}
-float
-_MeshImpl::GetBoundingBoxVolume() const
-{
- return __boundingVolume.GetHalfSize().z * 2;
-}
+//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::LoadFromBinaryN(const std::string& fileName, const std::string& modelName)
+ {
+ result r;
+ int quantityReadFromFile;
+ int32_t intsData;
+ char* charNameMesh;
+
+ FILE* pFile;
+ pFile = fopen((fileName + modelName).c_str(), "r");
+ SysTryReturn(NID_UI_ANIM, pFile != null, null, E_INVALID_ARG, "%s Error occurred while opening file for reading: %s", GetErrorMessage(E_INVALID_ARG), (fileName + modelName).c_str());
+
+ _MeshImpl* pMeshImpl;
+ Mesh* pMesh = new (std::nothrow) Mesh();
+ SysTryCatch(NID_UI_ANIM, pMesh != null, , E_OUT_OF_MEMORY, "%s Memory allocation failed while creating Mesh.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ pMeshImpl = pMesh->__pMeshImpl;
+ AppLog("Loading Mesh");
+
+ Header localCapacity;
+
+ quantityReadFromFile = fread(&localCapacity, sizeof(localCapacity), 1, pFile);
+
+ quantityReadFromFile += fread(&pMeshImpl->__countOfAllocatedVertex, sizeof(int32_t), 1, pFile);
+
+ 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)
+ {
+ r = pMeshImpl->AllocVertices(pMeshImpl->__countOfAllocatedVertex);
+ SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
+ intsData = (pMeshImpl->__countOfAllocatedVertex * APPROPRIATE_COUNT_VERTICES);
+ quantityReadFromFile += fread(&pMeshImpl->__pVertices[0], sizeof(float), intsData, pFile);
+ }
+ else
+ {
+ r = E_INVALID_DATA;
+ SysTryCatch(NID_UI_ANIM, localCapacity.isVerticesEnabled, , r, "%s. Propagating", GetErrorMessage(r));
+ }
-float
-_MeshImpl::GetBoundingBoxWidth() const
-{
- return __boundingVolume.GetHalfSize().x * 2;
+ if (localCapacity.isColorEnabled)
+ {
+ r = pMeshImpl->AllocColors();
+ SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
+ intsData = (pMeshImpl->__countOfAllocatedVertex * APPROPRIATE_COUNT_COLORS);
+ quantityReadFromFile += fread(&pMeshImpl->__pColors[0], sizeof(float), intsData, pFile);
+ }
+
+ if (localCapacity.isNormalEnabled)
+ {
+ r = pMeshImpl->AllocNormals();
+ SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
+ intsData = (pMeshImpl->__countOfAllocatedVertex * APPROPRIATE_COUNT_NORMALS);
+ quantityReadFromFile += fread(&pMeshImpl->__pNormals[0], sizeof(float), intsData, pFile);
+ }
+
+ if (localCapacity.isTextureCoordinateEnabled)
+ {
+ r = pMeshImpl->AllocTextureCoordinates();
+ SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
+ intsData = pMeshImpl->__countOfAllocatedVertex * APPROPRIATE_COUNT_TEXTCOORDINATES;
+ quantityReadFromFile += fread(&pMeshImpl->__pTexCoordinates[0], sizeof(float), intsData, pFile);
+ }
+
+ quantityReadFromFile += fread(&pMeshImpl->__countOfIndex, sizeof(int32_t), 1, pFile);
+
+ if (localCapacity.isIndexEnabled)
+ {
+ r = pMeshImpl->AllocIndices(pMeshImpl->__countOfAllocatedIndex);
+ SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "%s. Propagating", GetErrorMessage(r));
+ intsData = pMeshImpl->__countOfAllocatedVertex;
+ quantityReadFromFile += fread(&pMeshImpl->__pIndices[0], sizeof(uint16_t), intsData, pFile);
+ }
+
+ quantityReadFromFile += fread(&pMeshImpl->__countOfVertex, sizeof(int32_t), 1, pFile);
+
+ quantityReadFromFile += fread (&intsData, sizeof(int32_t), 1, pFile);
+ charNameMesh = new (std::nothrow) char[intsData + 1];
+ SysTryCatch(NID_UI_ANIM, charNameMesh != null, , E_OUT_OF_MEMORY, "%s Memory allocation failed while reading Mesh name: %s", GetErrorMessage(E_OUT_OF_MEMORY), (fileName + modelName).c_str());
+ quantityReadFromFile += fread (charNameMesh, 1, intsData, pFile);
+ charNameMesh[intsData] = '\0';
+ pMeshImpl->__name.assign(charNameMesh, intsData);
+ delete[] charNameMesh;
+ charNameMesh = null;
+
+ fclose(pFile);
+ return pMesh;
+
+ CATCH:
+ delete pMesh;
+ pMesh = null;
+ fclose(pFile);
+ return null;
+
}
-float
-_MeshImpl::GetBoundingBoxHeight() const
+result
+_MeshImpl::SaveMesh(const Tizen::Base::String& fileName)
{
- return __boundingVolume.GetHalfSize().y * 2;
-}
+ AppLog("SaveMesh debug");
+ int quantityWriteToFile;
+ result r;
+ int32_t intsData;
+
+ FILE* pFile;
+ SetLastResult(E_SUCCESS);
+ //SysAssert(__pMeshImpl != null);
+
+ std::wstring wStr(fileName.GetPointer());
+ std::string str(wStr.begin(), wStr.end());
+
+ pFile = fopen(str.c_str(), "w");
+ r = E_OPERATION_FAILED;
+ SysTryReturn(NID_UI_ANIM, pFile != null, r, r, "%s Error occurred while saving Mesh to file: %s", GetErrorMessage(r), str.c_str());
+ AppLog("SaveMesh debug");
+
+ Header capacity;
+ capacity.SetMeshArrays(*this);
+
+ quantityWriteToFile = fwrite(&capacity, sizeof(capacity), 1, pFile);
+
+ intsData = __countOfAllocatedVertex;
+ quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
+
+ intsData = __countOfAllocatedIndex;
+ quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
+
+
+ intsData = static_cast<int>(__hasBoundingVolume);
+ quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
+
+ AppLog("SaveMesh debug");
+
+ intsData = static_cast<int>(__geoType);
+ quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
+
+ AppLog("SaveMesh debug");
+ r = E_INVALID_DATA;
+ SysTryCatch(NID_UI_ANIM, capacity.isVerticesEnabled, , r, "%s. Propagating", GetErrorMessage(r));
+ intsData = (__countOfAllocatedVertex * APPROPRIATE_COUNT_VERTICES);
+ quantityWriteToFile += fwrite(&__pVertices[0], sizeof(float), intsData, pFile);
+ AppLog("SaveMesh debug");
+ if (capacity.isColorEnabled)
+ {
+ intsData = (__countOfAllocatedVertex * APPROPRIATE_COUNT_COLORS);
+ quantityWriteToFile += fwrite(&__pColors[0], sizeof(float), intsData, pFile);
+ }
+
+ if (capacity.isNormalEnabled)
+ {
+ intsData = (__countOfAllocatedVertex * APPROPRIATE_COUNT_NORMALS);
+ quantityWriteToFile += fwrite(&__pNormals[0], sizeof(float), intsData, pFile);
+ }
+
+ AppLog("SaveMesh debug");
+ if (capacity.isTextureCoordinateEnabled)
+ {
+ intsData = (__countOfAllocatedVertex * APPROPRIATE_COUNT_TEXTCOORDINATES);
+ quantityWriteToFile += fwrite(&__pTexCoordinates[0], sizeof(float), intsData, pFile);
+ }
+
+ AppLog("SaveMesh debug");
+ intsData = __countOfIndex;
+ quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
+
+ if (capacity.isIndexEnabled)
+ {
+ intsData = (__countOfAllocatedVertex);
+ quantityWriteToFile += fwrite(&__pIndices[0], sizeof(uint16_t), intsData, pFile);
+ }
+
+ intsData = __countOfVertex;
+ quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
+
+ intsData = __name.size();
+ quantityWriteToFile += fwrite(&intsData, sizeof(int32_t), 1, pFile);
+ quantityWriteToFile += fwrite(__name.c_str(), sizeof(int32_t), 1, pFile);
+
+ fclose(pFile);
+ AppLog("SaveMesh debug");
+ return E_SUCCESS;
+
+ CATCH:
+ fclose(pFile);
+ AppLog("SaveMesh debug");
+ return r;
+}
}}} //namespace Tizen { namespace Ui { namespace Animations {
if(pMesh)
{
// not yet apply
- pMesh->AdjustBoundingBox();
+ pMesh->AdjustBoundingVolume();
__meshList.Add(pMesh);
}
}
#include "FUiAnim_ModelImporterImpl.h"
+#include "FUiAnimVisualElement.h"
#include "library-geometries/FUiAnim_ImportColladaLibGeomGeometryMesh.h"
-#include "library-effects/FUiAnim_ImportColladaLibEffEffect.h"
#include "library-effects/FUiAnim_ImportColladaLibEffCommonShaderData.h"
#include "library-images/FUiAnim_ImportColladaLibImgImage.h"
+#include "library-visual-scenes/FUiAnim_ImportColladaLibVisScenVisualScene.h"
+#include "library-visual-scenes/FUiAnim_ImportColladaLibVisScenInstanceGeometry.h"
#include "FGrpFloatPoint.h"
#include "FGrpFloatPoint3.h"
#include "FUiAnim_MeshImpl.h"
#include "FUiAnim_MathVector3.h"
+#include "FUiAnim_MathMatrix4.h"
#include "FUiAnim_MaterialImpl.h"
+#include "FUiAnimShaderProgram.h" //tempo
+#include "FUiAnimShader.h" //tempo
+#include <FGrpFloatMatrix4.h> //tempo
+
namespace Tizen { namespace Ui { namespace Animations {
using namespace _ImportCollada;
using namespace _ImportCollada::LibraryImages;
using namespace Graphics;
+static const char vs_Test[] =
+ "uniform mat4 u_mvp;\n"
+ "uniform mat4 u_inv_modelview;\n"
+ "attribute vec4 a_position;\n"
+ "attribute vec4 a_normal;\n"
+ "varying vec4 v_normal;\n"
+ "void main()\n"
+ "{\n"
+ " v_normal = normalize(u_inv_modelview * a_normal);\n"
+ " gl_Position = u_mvp * a_position;\n"
+ "}\n";
+static const char fs_Test[] =
+ "precision mediump float;\n"
+ "uniform vec4 u_materialambient;\n"
+ //"uniform vec4 u_materialdiffuse;\n"
+ "varying vec4 v_normal;\n"
+ "void main()\n"
+ "{\n"
+ " vec3 col = u_materialambient.xyz * max(0, dot(normalize(v_normal.xyz), vec3(0, 0, 1)));\n"
+ //" vec3 col = vec3(0.3, 0.3, 1.0) * max(0, dot(normalize(v_normal.xyz), vec3(0, 0, 1)));\n"
+ " gl_FragColor = vec4(col, 1);\n"
+ "}\n";
+
+
_ModelImporterImpl::_ModelImporterImpl(const std::string& fileName, bool visualScenes, bool geometries, bool controllers, bool anmations, bool materials, bool effects, bool images, bool lights, bool cameras)
: colladaAssets(null)
{
+ colladaAssets = new (std::nothrow) ColladaAssets();
ColladaAssets::LibsForParsing libsForParsing;
if (visualScenes) libsForParsing.insert(ColladaAssets::VISUALSCENES);
if (materials) libsForParsing.insert(ColladaAssets::MATERIALS);
if (images) libsForParsing.insert(ColladaAssets::IMAGES);
if (effects) libsForParsing.insert(ColladaAssets::EFFECTS);
+ colladaAssets->Construct(fileName, libsForParsing);
- colladaAssets = new (std::nothrow) ColladaAssets(fileName, libsForParsing);
-
+ return;
}
-_ModelImporterImpl::~_ModelImporterImpl() {
+_ModelImporterImpl::~_ModelImporterImpl(void) {
if (colladaAssets != null)
{
delete colladaAssets;
colladaAssets = null;
}
+ return;
}
Mesh*
-_ModelImporterImpl::LoadMeshCollada(const std::string& modelName, bool norms, bool tcoords)
+_ModelImporterImpl::LoadMeshCollada(const std::string& modelName, std::string& materialId, bool inverseY)
{
- if (colladaAssets->pLibraryGeometries != null)
+ SysTryReturn(NID_UI_ANIM, colladaAssets->pLibraryGeometries != null, null, E_INVALID_DATA, "LibraryGeometries: not parsed.");
+
+ GeometryMesh* geometryMesh = null;
+ if (modelName.size() <= 0)
{
- Mesh* pMesh = new (std::nothrow) Mesh();
- pMesh->SetName(Tizen::Base::String(modelName.c_str()));
- SysTryReturn(NID_UI_ANIM, pMesh != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ geometryMesh = (GeometryMesh*)colladaAssets->pLibraryGeometries->GetGeometryByNumber(0);
+ }
+ else
+ {
+ geometryMesh = (GeometryMesh*)colladaAssets->pLibraryGeometries->GetGeometryById(modelName);
+ }
+ SysTryReturn(NID_UI_ANIM, geometryMesh != null, null, E_INVALID_DATA, "Geometry %s not found.", modelName.c_str());
+ SysTryReturn(NID_UI_ANIM, geometryMesh->GetSurfaceCount() == 1, null, E_INVALID_DATA, "Geometry %s: count of surfaces != 1.", modelName.c_str());
- GeometryMesh* geometryMesh = null;
- if (modelName.size() <= 0)
- {
- geometryMesh = (GeometryMesh*)colladaAssets->pLibraryGeometries->GetGeometryByNumber(0);
- }
- else
- {
- geometryMesh = (GeometryMesh*)colladaAssets->pLibraryGeometries->GetGeometryById(modelName);
- }
+ GeometryMesh::SurfaceInds* surfaceInds = geometryMesh->GetSurfaceInds(0);
+ SysTryReturn(NID_UI_ANIM, surfaceInds != null, null, E_INVALID_DATA, "Geometry %s: Surface not found.", modelName.c_str());
- if (geometryMesh)
- {
- GeometryMesh::SurfaceInds* surfaceInds = geometryMesh->GetSurfaceInds(0);
- if (surfaceInds)
- {
- _Math::Vector3* vertices = geometryMesh->GetPointerToVertices();
- _Math::Vector3* normals = geometryMesh->GetPointerToNormals();
- _Math::Vector2* texCoords = geometryMesh->GetPointerToTextureCoordinates();
+ materialId = surfaceInds->material;
- GeometryMesh::Indexes& curSurfaceVertexIndices = surfaceInds->vertexInds;
- GeometryMesh::Indexes& curSurfaceNormalIndices = surfaceInds->normalsInds;
- GeometryMesh::Indexes& curSurfaceTexCoordsIndices = surfaceInds->texCoordsInds;
+ _Math::Vector3* vertices = geometryMesh->GetPointerToVertices();
+ _Math::Vector3* normals = geometryMesh->GetPointerToNormals();
+ _Math::Vector2* texCoords = geometryMesh->GetPointerToTextureCoordinates();
+ GeometryMesh::Indexes& curSurfaceVertexIndices = surfaceInds->vertexInds;
+ GeometryMesh::Indexes& curSurfaceNormalIndices = surfaceInds->normalsInds;
+ GeometryMesh::Indexes& curSurfaceTexCoordsIndices = surfaceInds->texCoordsInds;
- pMesh->SetGeometryType(Mesh::GEO_TYPE_TRIANGLES);
- pMesh->ReserveVertices(geometryMesh->GetVertexCount());
- pMesh->ReserveIndices(curSurfaceVertexIndices.size());
+ Mesh* pMesh = new (std::nothrow) Mesh();
+ pMesh->SetName(Tizen::Base::String(modelName.c_str()));
+ SysTryReturn(NID_UI_ANIM, pMesh != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
- if ((normals != null) && norms)
- {
- pMesh->ReserveNormals();
- for (unsigned int i = 0; i < geometryMesh->GetVertexCount(); i++)
- {
- pMesh->SetNormal(i, FloatPoint3(0.0f, 0.0f, 0.0f));
- }
- }
+ pMesh->SetGeometryType(Mesh::GEO_TYPE_TRIANGLES);
+ pMesh->ReserveVertices(geometryMesh->GetVertexCount());
+ pMesh->ReserveIndices(curSurfaceVertexIndices.size());
- if ((texCoords != null) && tcoords)
- {
- pMesh->ReserveTextureCoordinates();
- for (unsigned int i = 0; i < geometryMesh->GetVertexCount(); i++)
- {
- pMesh->SetTextureCoord(i, FloatPoint(0.0f, 0.0f));
- }
- }
+ if (normals != null)
+ {
+ pMesh->ReserveNormals();
+ }
- for (unsigned int i = 0; i < geometryMesh->GetVertexCount(); i++)
- {
- float x = vertices[i].x;
- float y = vertices[i].y;
- float z = vertices[i].z;
- pMesh->SetVertex(i, FloatPoint3(x, y, z));
- }
+ if (texCoords != null)
+ {
+ pMesh->ReserveTextureCoordinates();
+ }
- // INDEX
+ for (unsigned int i = 0; i < geometryMesh->GetVertexCount(); i++)
+ {
+ float x = vertices[i].x;
+ float y = vertices[i].y;
+ float z = vertices[i].z;
+ if (inverseY)
+ {
+ y = -y;
+ }
+ pMesh->SetVertex(i, FloatPoint3(x, y, z));
+ }
- for (unsigned int i = 0; i < curSurfaceVertexIndices.size(); i++)
- {
- unsigned int vertIndex = curSurfaceVertexIndices[i];
-
- pMesh->SetIndex(i, vertIndex);
-
- if ((normals != null) && norms)
- {
- unsigned int normIndex = curSurfaceNormalIndices[i];
- normals[normIndex].Normalize();
- float x = normals[normIndex].x;
- float y = normals[normIndex].y;
- float z = normals[normIndex].z;
- pMesh->SetNormal(vertIndex, FloatPoint3(x, y, z));
- }
-
- if ((texCoords != null) && tcoords)
- {
- unsigned int textIndex = curSurfaceTexCoordsIndices[i];
- float x = texCoords[textIndex].x;
- float y = texCoords[textIndex].y;
- pMesh->SetTextureCoord(vertIndex, FloatPoint(x, y));
- }
- }
+ // INDEX
- return pMesh;
- }
- }
- else
+ for (unsigned int i = 0; i < curSurfaceVertexIndices.size(); i++)
+ {
+ unsigned int vertIndex = curSurfaceVertexIndices[i];
+
+ pMesh->SetIndex(i, vertIndex);
+
+ if (normals != null)
{
- AppLog("Error: Mesh not found");
+ unsigned int normIndex = curSurfaceNormalIndices[i];
+ normals[normIndex].Normalize();
+ float x = normals[normIndex].x;
+ float y = normals[normIndex].y;
+ float z = normals[normIndex].z;
+ FloatPoint3 norm(x, y, z);
+ FloatPoint3 normal = pMesh->GetNormal(vertIndex) + norm;
+ pMesh->SetNormal(vertIndex, normal);
}
- delete pMesh;
+ if (texCoords != null)
+ {
+ unsigned int textIndex = curSurfaceTexCoordsIndices[i];
+ float x = texCoords[textIndex].x;
+ float y = texCoords[textIndex].y;
+ pMesh->SetTextureCoord(vertIndex, FloatPoint(x, y));
+ }
}
- else
+
+ for (int i = 0; i < pMesh->GetVertexCount(); i++)
{
- AppLog("Error: pLibraryGeometries == null");
+ FloatPoint3 normal = pMesh->GetNormal(i);
+ float d = sqrt(normal.x * normal.x + normal.y * normal.y + normal.z * normal.z);
+ if (d > 0)
+ {
+ normal = normal / d;
+ pMesh->SetNormal(i, normal);
+ }
}
- return null;
-
+ return pMesh;
}
-//Mesh*
-//_ModelImporterImpl::LoadMeshBinN(const std::string& fileName)
-//{
-// AppLog("LoadBin...");
-// Mesh* pMesh = _MeshImpl::LoadFromBinaryN(fileName);
-// AppLog("Return mesh!!!!");
-//
-// return pMesh;
-//
-//}
+Mesh*
+_ModelImporterImpl::LoadMeshBinN(const std::string& fileName, const std::string& modelName)
+{
+ AppLog("LoadBin...");
+ Mesh* pMesh = _MeshImpl::LoadFromBinaryN(fileName, modelName);
+ AppLog("Return mesh!!!!");
+ return pMesh;
+}
Material*
-_ModelImporterImpl::LoadMaterial(const std::string& materialId, std::string& texureId)
+_ModelImporterImpl::LoadMaterial(const std::string& materialId, std::string& texureId, LibraryEffects::Effect::ShaderType& shaderType)
{
Material* pMaterial = new (std::nothrow) Material();
SysTryReturn(NID_UI_ANIM, pMaterial != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
std::string effectName = pColladaMaterial->GetEffectName();
- _ImportCollada::LibraryEffects::Effect* pColladaEffect = colladaAssets->pLibraryEffects->GetEffectById(effectName.c_str() + 1);
+ LibraryEffects::Effect* pColladaEffect = colladaAssets->pLibraryEffects->GetEffectById(effectName.c_str() + 1);
SysTryReturn(NID_UI_ANIM, pColladaEffect != null, null, E_INVALID_DATA, "Effect '%s' not found.", effectName.c_str() + 1);
//set data
texureId = LoadTextureName(pColladaEffect->GetDiffuseImageId());
+ shaderType = pColladaEffect->shaderType;
+
return pMaterial;
}
}
Scene*
-_ModelImporterImpl::LoadScene(const std::string& sceneId)
-{
+_ModelImporterImpl::LoadScene(const std::string& sceneId, bool inverseY){
+ LibraryVisualScenes::LibraryVisualScenes* pLibVisScene = colladaAssets->pLibraryVisualScenes;
+ LibraryGeometries::LibraryGeometries* pLibGeoms = colladaAssets->pLibraryGeometries;
+
+ SysTryReturn(NID_UI_ANIM, pLibVisScene != null, null, E_INVALID_DATA, "Library of visual scenes was not parsed.");
+ SysTryReturn(NID_UI_ANIM, pLibGeoms != null, null, E_INVALID_DATA, "Library of geometries was not parsed.");
+
+ LibraryVisualScenes::VisualScene* pVisScene = pLibVisScene->GetSceneByID(sceneId);
+ SysTryReturn(NID_UI_ANIM, pVisScene != null, null, E_OBJ_NOT_FOUND, "Scene '%s' not found.", sceneId.c_str());
+
Scene* pScene = new (std::nothrow) Scene();
- if (colladaAssets->pLibraryGeometries != null)
- {
- LibraryGeometries::LibraryGeometries* pLibGeoms = colladaAssets->pLibraryGeometries;
+ LibraryVisualScenes::Node* pNode = pVisScene->GetFirstNode();
+ WalkingTheTree(pNode, pScene, inverseY);
- unsigned int geomCount = pLibGeoms->GetGeometriesCount();
- for (unsigned int i = 0; i < geomCount; i++)
- {
- std::string geomId = pLibGeoms->GetGeometryByNumber(i)->GetId();
- Mesh* pMesh = LoadMeshCollada(geomId, true, true);
- pScene->AddMesh(pMesh);
- }
+ return pScene;
+}
+
+void
+_ModelImporterImpl::WalkingTheTree(LibraryVisualScenes::Node* pNode, Scene* pScene, bool inverseY)
+{
+ if (pNode == null)
+ {
+ return;
}
- if (colladaAssets->pLibraryMaterials != null)
+ unsigned int instancesCount = pNode->GetInstancesCount();
+
+ if (instancesCount > 0)
{
- LibraryMaterials::LibraryMaterials* pLibMats = colladaAssets->pLibraryMaterials;
+ _Math::Matrix4 globalMatrix;
+ globalMatrix.Identity();
- unsigned int matCount = pLibMats->GetMaterialCount();
- for (unsigned int i = 0; i < matCount; i++)
+ LibraryVisualScenes::Node* parentNode = pNode;
+ while (parentNode != NULL)
{
- std::string matId = pLibMats->GetMaterialByNumber(i)->GetId();
- std::string textureId = "";
- Material* pMaterial = LoadMaterial(matId, textureId);
- pScene->AddMaterial(pMaterial);
+ globalMatrix = parentNode->GetLocalMatrix() * globalMatrix;
+ parentNode = parentNode->Parent();
+ }
+ globalMatrix.Transpose();
+
+ for (unsigned int i = 0; i < instancesCount; i++)
+ {
+ LibraryVisualScenes::Instance* pInstance = pNode->GetInstanceByIndex(i);
+ if (pInstance->GetType() == LibraryVisualScenes::Instance::GEOMETRY)
+ {
+ LibraryVisualScenes::InstanceGeometry* pInstanceGeometry = static_cast<LibraryVisualScenes::InstanceGeometry*>(pInstance);
+
+ VisualElement* pVisElem = new (std::nothrow) VisualElement();
+ pVisElem->Construct();
+ pVisElem->SetName(pNode->GetID().c_str());
+ pVisElem->SetShowState(true);
+ pVisElem->SetImplicitAnimationEnabled(false);
+ pScene->GetRootVisualElement()->AttachChild(pVisElem);
+
+ //===================================================================================Set global matrix
+ FloatMatrix4 floatMatrix4;
+ if (inverseY){
+ globalMatrix.m[13] = - globalMatrix.m[13];
+ }
- pScene->AddTextureFileName(Tizen::Base::String(textureId.c_str()));
+ memcpy(floatMatrix4.matrix, globalMatrix.m, sizeof(float) * 16);
+ pVisElem->SetTransformMatrix(floatMatrix4);
+
+ //===================================================================================Set mesh
+ std::string geomId(pInstanceGeometry->GetUrl().c_str() + 1);
+ std::string matId;
+ Mesh* pMesh = LoadMeshCollada(geomId, matId, inverseY);
+ pVisElem->SetMesh(pMesh);
+
+ //===================================================================================SetMaterial
+ matId = pInstanceGeometry->pBindMaterial->GetTargetBySymbol(matId);
+ std::string textureId;
+ LibraryEffects::Effect::ShaderType shaderType;
+ Material* pMaterial = LoadMaterial(matId.c_str() + 1, textureId, shaderType);
+ if (pMaterial != null)
+ {
+ pVisElem->SetMaterial(pMaterial);
+ }
+
+ //===================================================================================Set shader
+ Shader vert;
+ vert.Construct(Shader::SHADER_VERTEX, vs_Test);
+ Shader frag;
+ frag.Construct(Shader::SHADER_FRAGMENT, fs_Test);
+
+ ShaderProgram *pProgram = new ShaderProgram();
+ pProgram->Construct(vert,frag);
+ pVisElem->SetShaderProgram(pProgram);
+
+
+ pScene->AddMesh(pMesh);
+ delete pMesh;
+ delete pMaterial;
+ }
}
}
- return pScene;
+ WalkingTheTree(pNode->Children(), pScene, inverseY);
+ WalkingTheTree(pNode->Next(), pScene, inverseY);
+
+ return;
}
}}}
-#include "FUiAnim_Ray.h"
+#include "FUiAnim_Ray.h"
+
#include <limits>
+#include <cmath>
#include <cstdlib>
-#include "FUiAnim_BoundingVolume.h"
+
+#include "FUiAnimBoundingVolume.h"
+#include "FUiAnim_BoundingVolumeImpl.h"
+#include "FUiAnim_VisualElementImpl.h"
#include "FBaseLog.h"
+#include "FUi_Matrix3Df.h"
+#include "FUiAnim_NativeLayer.h"
+#include "FUiAnim_RootVisualElement.h"
+#include "FUiAnim_VisualElementSharedData.h"
+#include "FUiAnim_TransformMatrix3Df.h"
+#include "FUiAnim_VisualElementCoordinateSystem.h"
+
+
namespace Tizen{ namespace Ui{ namespace Animations
{
+using namespace Tizen::Graphics;
+
+float DotProduct(_Math::Vector3 v1, _Math::Vector3 v2)
+{
+ return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
+}
+
_Ray::_Ray()
: Position(0.0)
, Direction(0.0)
const int axisCount = 3;
float tMin = -std::numeric_limits<float>::infinity();
float tMax = std::numeric_limits<float>::infinity();
- _Math::Vector3 center = boundingVolume.GetCenter();
- _Math::Vector3 centerOrigin = center - Position;
- _Math::Vector3 halfSize = boundingVolume.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)
+ if(boundingVolume.GetType() == BOUNDING_VOLUME_TYPE_AABB)
{
- float e = normals[i].Dot(centerOrigin);
- float f = normals[i].Dot(Direction);
+ _Math::Vector3 center = boundingVolume._pBoundingVolumeImpl->GetCenter();
+ _Math::Vector3 centerOrigin = center - Position;
+ _Math::Vector3 halfSize = boundingVolume._pBoundingVolumeImpl->GetHalfSize();
- if (abs(f) > std::numeric_limits<float>::epsilon())
+ _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 t1 = (e + halfSize.GetPointer()[i]) / f;
- float t2 = (e - halfSize.GetPointer()[i]) / f;
+ float e = normals[i].Dot(centerOrigin);
+ float f = normals[i].Dot(Direction);
- if (t1 > t2)
+ if (abs(f) > std::numeric_limits<float>::epsilon())
{
- std::swap(t1, t2);
+ float t1 = (e + halfSize.GetPointer()[i]) / f;
+ float t2 = (e - halfSize.GetPointer()[i]) / f;
+
+ if (t1 > t2)
+ {
+ std::swap(t1, t2);
+ }
+ tMin = std::max(tMin, t1);
+ tMax = std::min(tMax, t2);
+
+ if (tMin > tMax || tMax < 0.0f)
+ {
+ return std::make_pair(false, 0.0f);
+ }
}
- tMin = std::max(tMin, t1);
- tMax = std::min(tMax, t2);
-
- if (tMin > tMax || tMax < 0.0f)
+ else
{
- return std::make_pair(false, 0.0f);
+ if (e < -halfSize.GetPointer()[i] || e > halfSize.GetPointer()[i])
+ {
+ return std::make_pair(false, 0.0f);
+ }
}
}
- else
+
+ return tMin > 0.0f ? std::make_pair(true, tMin) : std::make_pair(true, tMax);
+ }
+ else if(boundingVolume.GetType() == BOUNDING_VOLUME_TYPE_SPHERE)
+ {
+ /*
+ * d = -(l(o-c)) -+ sqrt2((l(o-c))^2 - l^2*(o-c)^2 - r^2) / l^2; //l^2 == 1, l - unit vector
+ *
+ * d - dictance from starting point of line
+ * l - direction of line (unit)
+ * o - origin of line
+ * c - sphere center
+ * r - radius
+ */
+
+ float underRoot = -1.0f;
+ float r;
+ _Math::Vector3 c,tmp;
+ FloatPoint3 center;
+
+ boundingVolume.Get(center,r);
+
+ c.Set(center.x, center.y, center.z);
+
+ c = Position - c;
+
+ underRoot = DotProduct(Direction,c) * DotProduct(Direction,c) - DotProduct(c,c) - r * r;
+
+ if(underRoot < 0.0f)
{
- if (e < -halfSize.GetPointer()[i] || e > halfSize.GetPointer()[i])
- {
- return std::make_pair(false, 0.0f);
- }
+ return std::make_pair(false, tMax);
}
+
+ tMax = -DotProduct(Direction,c) - sqrt(underRoot);
+
+ return std::make_pair(true, tMax);
}
- return tMin > 0.0f ? std::make_pair(true, tMin) : std::make_pair(true, tMax);
+ return std::make_pair(false, tMax);
}
AppLog("Dir %.3f %.3f %.3f", Direction.x, Direction.y, Direction.z);
}
+_Math::Vector3
+_Ray::ConvertScreenToWorld(const _Math::Vector3& screen, const _Math::Matrix4& pvInv, const FloatRectangle& frame)
+{
+ float screenY = frame.height - screen.y;
+
+ _Math::Vector4 normalDevice((screen.x - frame.x) / frame.width,
+ (screenY - frame.y) / frame.height,
+ screen.z,
+ 1.0f);
+
+ //[-1; 1]
+ normalDevice.x *= 2;
+ normalDevice.y *= 2;
+ normalDevice.z *= 2;
+
+ normalDevice.x -= 1;
+ normalDevice.y -= 1;
+ normalDevice.z -= 1;
+
+ _Math::Vector4 world = pvInv * normalDevice;
+ world.x /= world.w;
+ world.y /= world.w;
+ world.z /= world.w;
+ world.w = 1.0f;
+
+ return _Math::Vector3(world.x, world.y, world.z);
+}
+
+
+
+_Ray&
+_Ray::MakeRayLocal(const _Ray globalRay, const _VisualElementImpl* pVEImpl)
+{
+ //make from top matrix
+ _Math::Matrix4 fromTop( &(pVEImpl->GetMatrixToTop().matrix[0][0]) );
+
+ fromTop.Transpose();
+ 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);
+
+ return *this;
+}
+
+_Ray&
+_Ray::MakeRayGlobal(const _VisualElementImpl* pVEImpl, FloatPoint point)
+{
+ //make gloabl ray
+ Tizen::Graphics::FloatRectangle frame;
+ _Math::Matrix4 pvInv;
+ _VisualElementImpl* pRootVe = pVEImpl->GetRoot();
+ SysTryReturn(NID_UI_ANIM, CreatePVInv(pRootVe,pvInv,frame), *this, E_OBJ_NOT_FOUND, "Ray cannot Projection View for this VisualElement (check VE to be connected to main tree, frame layer and other adjustments)");
+
+ //make absolute coordinate
+ FloatPoint absPoint(point);
+ pRootVe->ConvertCoordinates(absPoint, pVEImpl);
+
+ _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);
+
+ Set(screenNear, screenFar - screenNear);
+}
+
+bool
+_Ray::CreatePVInv(const _VisualElementImpl* pRootVe, _Math::Matrix4& pvInv, FloatRectangle& frame)
+{
+ _RootVisualElement* pRoot = dynamic_cast<_RootVisualElement*>(pRootVe->GetPublic());
+ _NativeLayer* pLayer = pRoot->GetNativeLayer();
+ Tizen::Graphics::FloatRectangle bounds = pLayer->GetBounds();
+
+ frame = bounds;
+ frame.x = 0.0f;
+ frame.y = 0.0f;
+
+ _Matrix3Df 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();
+
+ return true;
+}
+
}}} //namespace Tizen{ namespace Ui{ namespace Animations
#include <utility>
+#include <FGrpFloatMatrix4.h>
+#include <FGrpFloatPoint.h>
+#include <FGrpFloatDimension.h>
+#include <FGrpFloatRectangle.h>
+
#include "math/FUiAnim_MathVector3.h"
+#include "math/FUiAnim_MathMatrix4.h"
+
+
+#include "FUiAnimVisualElement.h"
namespace Tizen{ namespace Ui{ namespace Animations
{
+class _VisualElementImpl;
class BoundingVolume;
class _Ray
void print();
+ _Ray& MakeRayLocal(const _Ray globalRay, const _VisualElementImpl* pVEImpl); //any VE in a tree
+ _Ray& MakeRayGlobal(const _VisualElementImpl* pVEImpl, Tizen::Graphics::FloatPoint point);
+
+ 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;
};
#include "FUiAnim_SceneImpl.h"
#include "FBaseLog.h"
#include "FBaseSysLog.h"
+#include <FGraphics.h>
namespace Tizen { namespace Ui { namespace Animations {
using namespace Tizen::Base::Collection;
-_SceneImpl::_SceneImpl()
+_SceneImpl::_SceneImpl(void)
: Tizen::Base::Object()
, __meshes()
, __materials()
__pRootVisualElement->Construct();
// A ce vzagali treba????
-// __pRootVisualElement->SetName(L"Node");
-// __pRootVisualElement->SetBounds(FloatRectangle(clientRect.width / 2, clientRect.height / 2, 1, 1));
-// __pRootVisualElement->SetShowState(true);
-// __pRootVisualElement->SetImplicitAnimationEnabled(false);
+ __pRootVisualElement->SetName(L"Node");
+ __pRootVisualElement->SetBounds(Tizen::Graphics::FloatRectangle(5, 5, 1, 1));
+ __pRootVisualElement->SetShowState(true);
+ __pRootVisualElement->SetImplicitAnimationEnabled(false);
}
-_SceneImpl::~_SceneImpl()
+_SceneImpl::~_SceneImpl(void)
{
}
return __pRootVisualElement;
}
-//==========================================================================================
+//==========================================================================================MESH
result
_SceneImpl::AddMesh(Mesh* pMesh)
{
if (pMesh != null)
{
- __meshes.push_back(pMesh);
+ Mesh* pMeshCopy = new (std::nothrow) Mesh(*pMesh);
+ SysTryReturnResult(NID_UI, pMeshCopy != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ __meshes.push_back(pMeshCopy);
}
return E_SUCCESS;
}
result
_SceneImpl::RemoveMesh(const std::string& meshName)
{
- for (unsigned int i = 0; i < __meshes.size(); i++)
+ for (Meshes::iterator i = __meshes.begin(); i != __meshes.end(); i++)
{
- Mesh* pMesh = __meshes[i];
+ Mesh* pMesh = *i;
if (pMesh->GetName().Equals(Tizen::Base::String(meshName.c_str())))
{
- __meshes.erase(__meshes.begin() + i);
+ __meshes.erase(i);
+ delete pMesh;
+ pMesh = null;
return E_SUCCESS;
}
}
}
Mesh*
-_SceneImpl::GetMesh(const std::string& meshName) const
+_SceneImpl::GetMeshN(const std::string& meshName) const
{
- for (unsigned int i = 0; i < __meshes.size(); i++)
+ for (Meshes::const_iterator i = __meshes.begin(); i != __meshes.end(); i++)
{
- Mesh* pMesh = __meshes[i];
+ Mesh* pMesh = *i;
if (pMesh->GetName().Equals(Tizen::Base::String(meshName.c_str())))
{
- return pMesh;
+ Mesh* pMeshCopy = new (std::nothrow) Mesh(*pMesh);
+ SysTryReturn(NID_UI, pMeshCopy != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ return pMeshCopy;
}
}
}
Tizen::Base::Collection::ArrayList*
-_SceneImpl::GetMeshNamesN() const
+_SceneImpl::GetMeshNamesN(void) const
{
ArrayList* meshNames = new ArrayList(SingleObjectDeleter);
- for (unsigned int i = 0; i < __meshes.size(); i++)
+ for (Meshes::const_iterator i = __meshes.begin(); i != __meshes.end(); i++)
{
- Tizen::Base::String* meshName = new Tizen::Base::String(__meshes[i]->GetName());
+
+ Tizen::Base::String* meshName = new Tizen::Base::String((*i)->GetName());
meshNames->Add(meshName);
}
return meshNames;
}
-//==========================================================================================
+//==========================================================================================MATERIAL
result
_SceneImpl::AddMaterial(Material* pMaterial)
{
if (pMaterial != null)
{
- __materials.push_back(pMaterial);
+ Material* pMaterialCopy = new (std::nothrow) Material(*pMaterial);
+ SysTryReturnResult(NID_UI, pMaterialCopy != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ __materials.push_back(pMaterialCopy);
}
return E_SUCCESS;
}
result
_SceneImpl::RemoveMaterial(const std::string& materialName)
{
- for (unsigned int i = 0; i < __materials.size(); i++)
+ for (Materials::iterator i = __materials.begin(); i != __materials.end(); i++)
{
- Material* pMaterial = __materials[i];
+ Material* pMaterial = *i;
if (pMaterial->GetName().Equals(Tizen::Base::String(materialName.c_str())))
{
- __materials.erase(__materials.begin() + i);
+ __materials.erase(i);
+ delete pMaterial;
+ pMaterial = null;
return E_SUCCESS;
}
}
}
Material*
-_SceneImpl::GetMaterial(const std::string& materialName) const
+_SceneImpl::GetMaterialN(const std::string& materialName) const
{
- for (unsigned int i = 0; i < __materials.size(); i++)
+ for (Materials::const_iterator i = __materials.begin(); i != __materials.end(); i++)
{
- Material* pMaterial = __materials[i];
+ Material* pMaterial = *i;
if (pMaterial->GetName().Equals(Tizen::Base::String(materialName.c_str())))
{
- return pMaterial;
+ Material* pMaterialCopy = new (std::nothrow) Material(*pMaterial);
+ SysTryReturn(NID_UI, pMaterialCopy != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ return pMaterialCopy;
}
}
}
Tizen::Base::Collection::ArrayList*
-_SceneImpl::GetMaterialNamesN() const
+_SceneImpl::GetMaterialNamesN(void) const
{
ArrayList* materialNames = new ArrayList(SingleObjectDeleter);
- for (unsigned int i = 0; i < __materials.size(); i++)
+ for (Materials::const_iterator i = __materials.begin(); i != __materials.end(); i++)
{
- Tizen::Base::String* materialName = new Tizen::Base::String(__materials[i]->GetName());
+ Tizen::Base::String* materialName = new Tizen::Base::String((*i)->GetName());
materialNames->Add(materialName);
}
return materialNames;
}
-//==========================================================================================
+//==========================================================================================TEXTURE
result
_SceneImpl::AddTextureFileName(std::string textureFileName)
}
Tizen::Base::Collection::ArrayList*
-_SceneImpl::GetTextureFileNamesN() const
+_SceneImpl::GetTextureFileNamesN(void) const
{
ArrayList* textureFileNames = new ArrayList(SingleObjectDeleter);
- for (unsigned int i = 0; i < __textureFileNames.size(); i++)
+ for (TextureFileNames::const_iterator i = __textureFileNames.begin(); i != __textureFileNames.end(); i++)
{
- Tizen::Base::String* textureFileName = new Tizen::Base::String(__textureFileNames[i].c_str());
+ Tizen::Base::String* textureFileName = new Tizen::Base::String((*i).c_str());
textureFileNames->Add(textureFileName);
}
return textureFileNames;
_ShaderImpl*
_ShaderImpl::GetInstance(Shader& shader)
{
- return shader._pShaderImpl;
+ return shader.__pShaderImpl;
}
const _ShaderImpl*
_ShaderImpl::GetInstance(const Shader& shader)
{
- return static_cast<const _ShaderImpl*>(shader._pShaderImpl);
+ return static_cast<const _ShaderImpl*>(shader.__pShaderImpl);
}
}}} // Tizen::Ui::Animations
namespace Tizen { namespace Ui { namespace Animations
{
-
+/*
const wchar_t* UniformMVP = L"u_mvp";
const wchar_t* UniformColor = L"u_color";
const wchar_t* AttributePosition = L"a_position";
const wchar_t* AttributeTexCoord = L"a_texcoord";
const wchar_t* AttributeColor = L"a_color";
-
+*/
_ShaderProgramImpl::_ShaderProgramImpl(void)
: __program(0)
, __fragmentShader(0)
, __pCustomShader(null)
{
- memset(__locationId, 0, sizeof(unsigned int) * PROGRAM_LOCATION_MAX);
+ //memset(__locationId, 0, sizeof(unsigned int) * PROGRAM_LOCATION_MAX);
- static _StringHashProvider _stringHashProvider;
- static _StringComparer _stringComparer;
+ //static _StringHashProvider stringHashProvider;
+ //static _StringComparer stringComparer;
- __locations.Construct(0, 0.f, _stringHashProvider, _stringComparer);
+ //__locations.Construct(0, 0.f, stringHashProvider, stringComparer);
}
_ShaderProgramImpl::~_ShaderProgramImpl(void)
{
if (__program > 0)
{
- _GlRenderManager::GetInstance()->DeleteShaderProgram(this);
-
-
+ _GlRenderManager::GetInstance()->DeleteShaderProgram(this); // Need it ???
}
+
+ //__locations.RemoveAll();
delete __pCustomShader;
- __locations.RemoveAll();
}
result
{
__vertexShader = _ShaderImpl::GetInstance(vertexShader)->__shaderId;
__fragmentShader = _ShaderImpl::GetInstance(fragmentShader)->__shaderId;
-
_GlRenderManager::GetInstance()->BuildShaderProgram(this);
SysTryReturnResult(NID_UI_ANIM, __program > 0, E_SYSTEM, "Failed to build shader program.");
-
- __pCustomShader = new (std::nothrow) _CustomShader(__program);
+ __pCustomShader = new (std::nothrow) _GlShaderProgram(__program);
SysTryReturnResult(NID_UI_ANIM, __pCustomShader, E_OUT_OF_MEMORY, "Memory allocation failed.");
__pCustomShader->BindAttributes();
return E_SUCCESS;
Variant
_ShaderProgramImpl::GetUniform(const Tizen::Base::String& name) const
{
- return Variant();
+ return __pCustomShader->GetUniform(name);
}
result
_ShaderProgramImpl::SetUniform(const Tizen::Base::String& name, const Tizen::Ui::Variant& value)
{
-
- return E_SUCCESS;
+ return __pCustomShader->SetUniform(name, value);
}
-
-_CustomShader*
+_GlShaderProgram*
_ShaderProgramImpl::GetCusomShader()
{
return __pCustomShader;
}
-
+/*
int
_ShaderProgramImpl::GetAttribute(const ProgramLocation location)
{
return __pCustomShader->IsParameterAvailable(name);
}
+result
+_ShaderProgramImpl::UnbindUniform(const Tizen::Base::String &name)
+{
+ return __pCustomShader->UnbindUniform(name);
+}
+
+result
+_ShaderProgramImpl::UnbindAttribute(const Tizen::Base::String &name)
+{
+ return __pCustomShader->UnbindAttribute(name);
+}
+
+void
+_ShaderProgramImpl::SetUserData(const Tizen::Base::String& name, const Tizen::Ui::Variant& value)
+{
+ //
+}
+void
+_ShaderProgramImpl::SetUserSampler(const Tizen::Base::String& name, Tizen::Ui::Animations::VisualElementSurface* pSurface)
+{
+ __pCustomShader->SetUserSampler(name, pSurface);
+}
int
_ShaderProgramImpl::GetUniformLocation(const Tizen::Base::String& name)
return 0;//GetLocation(ATTRIBUTE_TYPE, name);
}
-
+*/
_ShaderProgramImpl*
_ShaderProgramImpl::GetInstance(ShaderProgram& program)
{
- return program._pShaderProgramImpl;
+ return program.__pShaderProgramImpl;
}
const _ShaderProgramImpl*
_ShaderProgramImpl::GetInstance(const ShaderProgram& program)
{
- return static_cast<const _ShaderProgramImpl*>(program._pShaderProgramImpl);
+ return static_cast<const _ShaderProgramImpl*>(program.__pShaderProgramImpl);
}
}}} // Tizen::Ui::Animations
#include <FBaseObject.h>
#include <FBaseString.h>
-#include <FBaseColHashMapT.h>
#include <FUiVariant.h>
-#include "FUiAnim_CustomShader.h"
+#include <FBaseColHashMapT.h>
+//#include "FUiAnim_CustomShader.h"
+#include "FUiAnim_GlShaderProgram.h"
#include <FUiAnimShaderProgram.h>
+
namespace Tizen { namespace Ui { namespace Animations
{
Variant GetUniform(const Tizen::Base::String& name) const;
result SetUniform(const Tizen::Base::String& name, const Tizen::Ui::Variant& value);
- int GetUniformLocation(const Tizen::Base::String& name);
- int GetAttribLocation(const Tizen::Base::String& name);
-
- result BindAttribute(ProgramLocation location, const Tizen::Base::String &name);
- result BindUniform(ProgramLocation location, const Tizen::Base::String &name);
- _CustomShader* GetCusomShader();
- int GetAttribute(const ProgramLocation location);
- int GetUniform(const ProgramLocation location);
- bool IsParameterAvailable(const ProgramLocation location) const;
- bool IsParameterAvailable(const Tizen::Base::String& name) const;
-
+ //int GetUniformLocation(const Tizen::Base::String& name);
+ //int GetAttribLocation(const Tizen::Base::String& name);
+ //result BindAttribute(ProgramLocation location, const Tizen::Base::String &name);
+// //result BindUniform(ProgramLocation location, const Tizen::Base::String &name);
+ _GlShaderProgram* GetCusomShader();
+ //int GetAttribute(const ProgramLocation location);
+ //int GetUniform(const ProgramLocation location);
+ //bool IsParameterAvailable(const ProgramLocation location) const;
+ //bool IsParameterAvailable(const Tizen::Base::String& name) const;
+ //void SetUserData(const Tizen::Base::String& name, const Tizen::Ui::Variant& value);
+ //void SetUserSampler(const Tizen::Base::String& name, Tizen::Ui::Animations::VisualElementSurface* pSurface);
+ //result UnbindUniform(const Tizen::Base::String &name);
+ //result UnbindAttribute(const Tizen::Base::String &name);
static _ShaderProgramImpl* GetInstance(ShaderProgram& program);
static const _ShaderProgramImpl* GetInstance(const ShaderProgram& program);
unsigned int __vertexShader; //TODO:need to save Shader???
unsigned int __fragmentShader;
- int __locationId[PROGRAM_LOCATION_MAX];
-
- typedef Tizen::Base::Collection::IMapEnumeratorT<Tizen::Base::String, int> LocationMapEnumeratorT;
+ //int __locationId[PROGRAM_LOCATION_MAX];
+ //typedef Tizen::Base::Collection::IMapEnumeratorT<Tizen::Base::String, int> LocationMapEnumeratorT;
+/*
class LocationMapT : public Tizen::Base::Collection::HashMapT<Tizen::Base::String, int>
{
public:
};
LocationMapT __locations;
-
+*/
// request
- struct _RequestItem
+ struct _RequestItem // Need it ?
{
Tizen::Base::String name;
int location;
_RequestItem __request;
private:
- _CustomShader* __pCustomShader;
+ _GlShaderProgram* __pCustomShader;
_ShaderProgramImpl(const _ShaderProgramImpl& shader);
_ShaderProgramImpl& operator =(const _ShaderProgramImpl& rhs);
+ //friend class _CustomShader;
};
//3D feature
#include <algorithm>
+#include <limits>
#include "FUiAnimMesh.h"
#include "FUiAnim_MeshImpl.h"
#include "FUiAnim_VisualElementSharedData.h"
#include "FUiAnim_VisualElementEnvironment.h"
#endif
+#include <algorithm>
+#include "math/FUiAnim_MathVector3.h"
+#include "math/FUiAnim_MathVector4.h"
+#include "math/FUiAnim_MathMatrix4.h"
+
+#include "FUiAnim_Ray.h"
+#include "FUiAnimBoundingVolume.h"
+#include "FUi_Matrix3Df.h"
+#include "FGrpFloatRectangle.h"
+#include "FUiAnim_NativeLayer.h"
+
using namespace std;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
{ // remove sub property
for(int i = 0 ; pSubProperties[i] != NULL ; i++)
{
- pAnimationManager->RemoveAnimationByProperty(*pTarget, *pSubProperties[i]);
+ pAnimationManager->RemoveAnimationByProperty(*pTarget, *pSubProperties[i]);
}
}
r = false;
{ // remove sub property
for(int i = 0 ; pSubProperties[i] != NULL ; i++)
{
- pAnimationManager->RemoveAnimationByProperty(*pTarget, *pSubProperties[i]);
+ pAnimationManager->RemoveAnimationByProperty(*pTarget, *pSubProperties[i]);
}
}
r = false;
if(__hasGlobalRay == false) //VE have no local ray, create
{
//make gloabl ray
- _Math::Matrix4 pvInv;
- FloatRectangle frame;
- SysTryReturn(NID_UI_ANIM, __CreatePVInv(pvInv,frame), HITTEST_NOWHERE, E_OBJ_NOT_FOUND, "Visual Element 3D HitTest cannot create Projection View (check VE to be connected to main tree)");
-
- //make absolute coordinate
- FloatPoint absPoint(point);
- _VisualElementImpl* pRootVEImpl = this->GetRoot();
- pRootVEImpl->ConvertCoordinates(absPoint, 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);
-
- __globalRay.Set(screenNear, screenFar - screenNear);
+ __globalRay.MakeRayGlobal(this,point);
}
//hit VE mesh box?
//create global BoundingVolume
//get toTop matrix
- _Math::Matrix4 toTop(&(GetMatrixToTop().matrix[0][0]));
- toTop.Transpose();
+ static BoundingVolume globalVolume;//(pMesh->GetBoundingVolume());
+ globalVolume = pMesh->GetBoundingVolume();
+ globalVolume.Transform(GetMatrixToTop());
- BoundingVolume box(pMesh->__pMeshImpl->__boundingVolume);
- //create global BoundingVolume
- box.Transform(toTop);
- std::pair<bool, float> intersect = __globalRay.Intersect(box);
+// _Math::Matrix4 toTop(&(GetMatrixToTop().matrix[0][0]));
+// toTop.Transpose();
+//
+// BoundingVolume box(pMesh->__pMeshImpl->__boundingVolume);
+// //create global BoundingVolume
+// box.Transform(toTop);
+
+ std::pair<bool, float> intersect = __globalRay.Intersect(globalVolume);
if (intersect.first) // box intersected
{
Intersections intesections;
//create local ray to intersect triangles in mesh
- _Ray localRay = __MakeLocalRay(__globalRay, this); //make local ray for mesh
+ _Ray localRay;
+ localRay.MakeRayLocal(__globalRay, this); //make local ray for mesh
if (!__SearchTriangleIntersection(localRay, pMesh, intesections, true)) //get all intersected triangle
{
}
}
}
+ }
+ if(__pNearestVEImpl != null)
+ {
pHitTarget = __pNearestVEImpl; //set the nearest from this and childs to return value
+ return pHitTarget;
}
-
- if (pHitTarget)
+ if (pHitTarget != null)
{
// point = hitPoint;
return pHitTarget;
_VisualElementImpl::GetChildAt(const FloatPoint& point)
{
//make gloabl ray
- _Math::Matrix4 pvInv;
- FloatRectangle frame;
- SysTryReturn(NID_UI_ANIM, __CreatePVInv(pvInv,frame), null, E_OBJ_NOT_FOUND, "Visual Element 3D HitTest cannot create Projection View (check VE to be connected to main tree)");
-
- //make absolute coordinate
- FloatPoint absPoint(point);
- _VisualElementImpl* pRootVEImpl = this->GetRoot();
- pRootVEImpl->ConvertCoordinates(absPoint, this);
+ __globalRay.MakeRayGlobal(this,point);
- _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);
-
- __globalRay.Set(screenNear, screenFar - screenNear);
-
- //Clear nearest searching parameters for root
+ //Clear nearest-searching parameters for root
__pNearestVEImpl = null;
__nearestDistance = std::numeric_limits<float>::infinity();
__hasGlobalRay = true;
result
_VisualElementImpl::SetMesh(Mesh* pMesh)
{
+ pMesh->AdjustBoundingVolume();
+
GetSharedData().geometry.SetMesh(pMesh);
return E_SUCCESS;
}*/
-_Ray
-_VisualElementImpl::__MakeLocalRay(const _Ray& ray, const _VisualElementImpl* ve)
-{
-
- _Math::Matrix4 toTop(&(ve->GetMatrixToTop().matrix[0][0]));
-
- toTop.Transpose();
- toTop.Inverse();
-
- _Math::Vector3 Position = toTop * ray.Position;
-
- //because Mat4 * vec3 treats vec3 as point
- _Math::Vector4 direction(ray.Direction.x, ray.Direction.y, ray.Direction.z, 0.0f);
- _Math::Vector4 directionT = toTop * direction;
-
- return _Ray(Position,_Math::Vector3(directionT.x, directionT.y, directionT.z));
-}
-
void
_VisualElementImpl::__SearchTriangleListIntersection(const _Ray& localRay, const Mesh* mesh, Intersections& intersections,bool seachAllIntersections)
{
return (!intersections.empty());
}
-
-_Math::Vector3
-_VisualElementImpl::__ConvertScreenToWorld(const _Math::Vector3& screen, const _Math::Matrix4& pvInv, const FloatRectangle& frame)
-{
- float screenY = frame.height - screen.y;
-
- _Math::Vector4 normalDevice((screen.x - frame.x) / frame.width,
- (screenY - frame.y) / frame.height,
- screen.z,
- 1.0f);
-
- //[-1; 1]
- normalDevice.x *= 2;
- normalDevice.y *= 2;
- normalDevice.z *= 2;
-
- normalDevice.x -= 1;
- normalDevice.y -= 1;
- normalDevice.z -= 1;
-
- _Math::Vector4 world = pvInv * normalDevice;
- world.x /= world.w;
- world.y /= world.w;
- world.z /= world.w;
- world.w = 1.0f;
-
- return _Math::Vector3(world.x, world.y, world.z);
-}
-
-bool
-_VisualElementImpl::__CreatePVInv(_Math::Matrix4& pvInv, FloatRectangle& frame)
-{
- _VisualElementImpl* root = GetRoot();
- if (root == null)
- {
- return false;
- }
-
- _RootVisualElement* pRoot = dynamic_cast<_RootVisualElement*>(root->GetPublic());
- _NativeLayer* pLayer = pRoot->GetNativeLayer();
- Tizen::Graphics::FloatRectangle bounds = pLayer->GetBounds();
-
- frame = bounds;
- frame.x = 0.0f;
- frame.y = 0.0f;
-
- _Matrix3Df 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();
-
- return true;
-}
-
-//an pick debugging function - common algorithm description
-//remove when finish picking all implementation <youri>
-/*_VisualElementImpl*
-_VisualElementImpl::PickVA(int screenX, int screenY)
-{
-
-// AppLog("PickVA begin");
-
- _Math::Matrix4 pvInv;
- if (! CreatePVInv(pvInv)) //Projection View like renderer do <youri>
- {
-
-// AppLog("fail to create projection view inverse");
-
- return 0;
- }
-
- _RenderFrame frame;
- if (! CreateFrame(frame))
- {
-
-// AppLog("fail to create frame");
-
- return 0;
- }
-
- _Math::Vector3 screenNear = ConvertScreenToWorld(_Math::Vector3(screenX, screenY, 0.0f), pvInv, frame);
- _Math::Vector3 screenFar = ConvertScreenToWorld(_Math::Vector3(screenX, screenY, 1.0f), pvInv, frame);
- Ray ray(screenNear, screenFar - screenNear);
-
-// AppLog("sNear %.3f %.3f %.3f", screenNear.x, screenNear.y, screenNear.z);
-// AppLog("sFar %.3f %.3f %.3f", screenFar.x, screenFar.y, screenFar.z);
-// ray.print();
-
-
- DistanceVAs intersected;
- MakeRayIntersection(ray, intersected); //go through boxes <youri>
- if (intersected.empty())
- {
-
-// AppLog("no boxes intersected");
- return 0;
- }
-// AppLog("boxes intersected %d",intersected.size());
-
- _VisualElementImpl* ve = null;
- _VisualElementImpl* nearestVE = null;
- Intersections intesections;
- float nearestTriangle = 0.0; //TODO:limits maximum and without is first
- bool isFirstBox = true;
-
- //std::sort(intersected.begin(), intersected.end(), CompareDistanceVA);
- DistanceVAsIt itEnd = intersected.end();
- for (DistanceVAsIt it = intersected.begin(); it != itEnd; ++it)
- {
- ve = it->second;
- Ray localRay = MakeLocalRay(ray, ve);
-
-// AppLog("Local ray"); localRay.print();
-
-
-
- Mesh* mesh = ve->GetSharedData().geometry.GetMesh();
- if (intersectTris(localRay, mesh, intesections,true)) //get intersected triangles list, but for hittest onlu first hit "true" needed <youri>
- {
- std::sort(intesections.begin(), intesections.end(), CompareIntersections);
- if(nearestTriangle > intesections[0].first || isFirstBox == true)
- {
- nearestTriangle = intesections[0].first;
- nearestVE = ve;
- isFirstBox = false;
- }
-
-// AppLog("PickVA intersected Mesh of VE %ls count %d",ve->GetName().GetPointer(),intesections.size());
-
- //std::sort(intesections.begin(), intesections.end(), CompareIntersections);
- //intersectPoint = ns->GetDerivedTransform() * intesections[0].second; //nearest point in mesh intersected with ray
- //return ve;
- intesections.clear();
- }
- }
-
- return nearestVE;
-
-// AppLog("no meshes intersected");
-// AppLog("PickVA end");
-
- //return 0;
-}*/
-
// delegate---------------------------------------------------------------------------------
void
namespace Tizen { namespace Ui { namespace Animations { namespace _ImportCollada {
-ColladaAssets::ColladaAssets(const std::string& fileName, LibsForParsing libsForParsing)
+ColladaAssets::ColladaAssets()
: pLibraryVisualScenes(null)
, pLibraryGeometries(null)
, pLibraryControllers(null)
, root(null)
{
+}
+result
+ColladaAssets::Construct(const std::string& fileName, LibsForParsing libsForParsing)
+{
doc = xmlParseFile(fileName.c_str());
- if (doc)
- {
- root = xmlDocGetRootElement(doc);
- if (root)
- {
- Parse(root, libsForParsing);
- }
- else
- {
- AppLog("Root not found");
- }
- }
- else
- {
- AppLog("Parsing error");
- }
+ SysTryReturnResult(NID_UI, doc != null, E_OPERATION_FAILED, "Xml file parsing error.");
+ root = xmlDocGetRootElement(doc);
+ SysTryCatch(NID_UI, root != null, xmlFreeDoc(doc), E_INVALID_DATA, "Root element not found.");
+
+ Parse(root, libsForParsing);
xmlFreeDoc(doc);
- return;
+ doc = null;
+ return E_SUCCESS;
+
+CATCH:
+ return E_INVALID_DATA;
}
ColladaAssets::~ColladaAssets(void)
{
+ if (doc)
+ {
+ xmlFreeDoc(doc);
+ doc = null;
+ }
+
if (pLibraryVisualScenes)
{
delete pLibraryVisualScenes;
void
ColladaAssets::Parse(xmlNodePtr root, LibsForParsing libsForParsing)
{
- std::unique_ptr<LibraryVisualScenes::LibraryVisualScenes> pLibVisualScenes;
- std::unique_ptr<LibraryGeometries::LibraryGeometries> pLibGeometries;
- std::unique_ptr<LibraryControllers::LibraryControllers> pLibControllers;
- std::unique_ptr<LibraryAnimations::LibraryAnimations> pLibAnimations;
- std::unique_ptr<LibraryLights::LibraryLights> pLibLights;
- std::unique_ptr<LibraryCameras::LibraryCameras> pLibCameras;
- std::unique_ptr<LibraryMaterials::LibraryMaterials> pLibMaterials;
- std::unique_ptr<LibraryImages::LibraryImages> pLibImages;
- std::unique_ptr<LibraryEffects::LibraryEffects> pLibEffects;
-
-
if (libsForParsing.find(VISUALSCENES) != libsForParsing.end())
{
xmlNodePtr libraryVisualScenes = Tools::FindFirst(root->children, "library_visual_scenes", false);
- SysTryReturnVoidResult(NID_UI, libraryVisualScenes != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_visual_scenes> not found.");
- pLibVisualScenes = std::unique_ptr<LibraryVisualScenes::LibraryVisualScenes>(new (std::nothrow) LibraryVisualScenes::LibraryVisualScenes(libraryVisualScenes));
- SysTryReturnVoidResult(NID_UI, pLibVisualScenes.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ if (libraryVisualScenes != null)
+ {
+ pLibraryVisualScenes = new (std::nothrow) LibraryVisualScenes::LibraryVisualScenes(libraryVisualScenes);
+ SysTryReturnVoidResult(NID_UI, pLibraryVisualScenes != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ }
+ else
+ {
+ SysLog(NID_UI, "Tag <library_visual_scenes> not found.");
+ }
//AppLog("VS");
}
if (libsForParsing.find(GEOMETRIES) != libsForParsing.end())
{
xmlNodePtr libraryGeometries = Tools::FindFirst(root->children, "library_geometries", false);
- SysTryReturnVoidResult(NID_UI, libraryGeometries != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_geometries> not found.");
-
- pLibGeometries = std::unique_ptr<LibraryGeometries::LibraryGeometries>(new (std::nothrow) LibraryGeometries::LibraryGeometries(libraryGeometries));
- SysTryReturnVoidResult(NID_UI, pLibGeometries.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ if (libraryGeometries != null)
+ {
+ pLibraryGeometries = new (std::nothrow) LibraryGeometries::LibraryGeometries(libraryGeometries);
+ SysTryReturnVoidResult(NID_UI, pLibraryGeometries != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ }
+ else
+ {
+ SysLog(NID_UI, "Tag <library_geometries> not found.");
+ }
//AppLog("G");
}
if (libsForParsing.find(CONTROLLERS) != libsForParsing.end())
{
xmlNodePtr libraryControllers = Tools::FindFirst(root->children, "library_controllers", false);
- SysTryReturnVoidResult(NID_UI, libraryControllers != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_controllers> not found.");
-
- pLibControllers = std::unique_ptr<LibraryControllers::LibraryControllers> (new (std::nothrow) LibraryControllers::LibraryControllers(libraryControllers));
- SysTryReturnVoidResult(NID_UI, pLibControllers.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ if (libraryControllers != null)
+ {
+ pLibraryControllers = new (std::nothrow) LibraryControllers::LibraryControllers(libraryControllers);
+ SysTryReturnVoidResult(NID_UI, pLibraryControllers != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ }
+ else
+ {
+ SysLog(NID_UI, "Tag <library_controllers> not found.");
+ }
//AppLog("C");
}
if (libsForParsing.find(ANIMATIONS) != libsForParsing.end())
{
xmlNodePtr libraryAnimations = Tools::FindFirst(root->children, "library_animations", false);
- SysTryReturnVoidResult(NID_UI, libraryAnimations != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_animations> not found.");
-
- pLibAnimations = std::unique_ptr<LibraryAnimations::LibraryAnimations>(new (std::nothrow) LibraryAnimations::LibraryAnimations(libraryAnimations));
- SysTryReturnVoidResult(NID_UI, pLibAnimations.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ if (libraryAnimations != null)
+ {
+ pLibraryAnimations = new (std::nothrow) LibraryAnimations::LibraryAnimations(libraryAnimations);
+ SysTryReturnVoidResult(NID_UI, pLibraryAnimations != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ }
+ else
+ {
+ SysLog(NID_UI, "Tag <library_animations> not found.");
+ }
//AppLog("A");
}
if (libsForParsing.find(LIGHTS) != libsForParsing.end())
{
xmlNodePtr libraryLights = Tools::FindFirst(root->children, "library_lights", false);
- SysTryReturnVoidResult(NID_UI, libraryLights != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_lights> not found.");
-
- pLibLights = std::unique_ptr<LibraryLights::LibraryLights>(new (std::nothrow) LibraryLights::LibraryLights(libraryLights));
- SysTryReturnVoidResult(NID_UI, pLibLights.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ if (libraryLights != null)
+ {
+ pLibraryLights = new (std::nothrow) LibraryLights::LibraryLights(libraryLights);
+ SysTryReturnVoidResult(NID_UI, pLibraryLights != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ }
+ else
+ {
+ SysLog(NID_UI, "Tag <library_lights> not found.");
+ }
//AppLog("L");
}
if (libsForParsing.find(CAMERAS) != libsForParsing.end())
{
xmlNodePtr libraryCameras = Tools::FindFirst(root->children, "library_cameras", false);
- SysTryReturnVoidResult(NID_UI, libraryCameras != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_cameras> not found.");
-
- pLibCameras = std::unique_ptr<LibraryCameras::LibraryCameras>(new (std::nothrow) LibraryCameras::LibraryCameras(libraryCameras));
- SysTryReturnVoidResult(NID_UI, pLibCameras.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ if (libraryCameras != null)
+ {
+ pLibraryCameras = new (std::nothrow) LibraryCameras::LibraryCameras(libraryCameras);
+ SysTryReturnVoidResult(NID_UI, pLibraryCameras != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ }
+ else
+ {
+ SysLog(NID_UI, "Tag <library_cameras> not found.");
+ }
//AppLog("CAa");
}
if (libsForParsing.find(MATERIALS) != libsForParsing.end())
{
xmlNodePtr libraryMaterials = Tools::FindFirst(root->children, "library_materials", false);
- SysTryReturnVoidResult(NID_UI, libraryMaterials != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_materials> not found.");
-
- pLibMaterials = std::unique_ptr<LibraryMaterials::LibraryMaterials>(new (std::nothrow) LibraryMaterials::LibraryMaterials(libraryMaterials));
- SysTryReturnVoidResult(NID_UI, pLibMaterials.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ if (libraryMaterials != null)
+ {
+ pLibraryMaterials = new (std::nothrow) LibraryMaterials::LibraryMaterials(libraryMaterials);
+ SysTryReturnVoidResult(NID_UI, pLibraryMaterials != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ }
+ else
+ {
+ SysLog(NID_UI, "Tag <library_materials> not found.");
+ }
//AppLog("M");
}
if (libsForParsing.find(IMAGES) != libsForParsing.end())
{
xmlNodePtr libraryImages = Tools::FindFirst(root->children, "library_images", false);
- SysTryReturnVoidResult(NID_UI, libraryImages != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_images> not found.");
-
- pLibImages = std::unique_ptr<LibraryImages::LibraryImages>(new (std::nothrow) LibraryImages::LibraryImages(libraryImages));
- SysTryReturnVoidResult(NID_UI, pLibImages.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ if (libraryImages != null)
+ {
+ pLibraryImages = new (std::nothrow) LibraryImages::LibraryImages(libraryImages);
+ SysTryReturnVoidResult(NID_UI, pLibraryImages != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ }
+ else
+ {
+ SysLog(NID_UI, "Tag <library_images> not found.");
+ }
//AppLog("I");
}
if (libsForParsing.find(EFFECTS) != libsForParsing.end())
{
xmlNodePtr libraryEffects = Tools::FindFirst(root->children, "library_effects", false);
- SysTryReturnVoidResult(NID_UI, libraryEffects != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_effects> not found.");
-
- pLibEffects = std::unique_ptr<LibraryEffects::LibraryEffects> (new (std::nothrow) LibraryEffects::LibraryEffects(libraryEffects));
- SysTryReturnVoidResult(NID_UI, pLibEffects.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ if (libraryEffects != null)
+ {
+ pLibraryEffects = new (std::nothrow) LibraryEffects::LibraryEffects(libraryEffects);
+ SysTryReturnVoidResult(NID_UI, pLibraryEffects != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+ }
+ else
+ {
+ SysLog(NID_UI, "Tag <library_effects> not found.");
+ }
//AppLog("E");
}
- if (libsForParsing.find(VISUALSCENES) != libsForParsing.end())
- {
- pLibraryVisualScenes = pLibVisualScenes.release();
- }
-
- if (libsForParsing.find(GEOMETRIES) != libsForParsing.end())
- {
- pLibraryGeometries = pLibGeometries.release();
- }
-
- if (libsForParsing.find(CONTROLLERS) != libsForParsing.end())
- {
- pLibraryControllers = pLibControllers.release();
- }
-
- if (libsForParsing.find(ANIMATIONS) != libsForParsing.end())
- {
- pLibraryAnimations = pLibAnimations.release();
- }
-
- if (libsForParsing.find(LIGHTS) != libsForParsing.end())
- {
- pLibraryLights = pLibLights.release();
- }
-
- if (libsForParsing.find(CAMERAS) != libsForParsing.end())
- {
- pLibraryCameras = pLibCameras.release();
- }
-
- if (libsForParsing.find(MATERIALS) != libsForParsing.end())
- {
- pLibraryMaterials = pLibMaterials.release();
- }
-
- if (libsForParsing.find(IMAGES) != libsForParsing.end())
- {
- pLibraryImages = pLibImages.release();
- }
-
- if (libsForParsing.find(EFFECTS) != libsForParsing.end())
- {
- pLibraryEffects = pLibEffects.release();
- }
-
-// pLibraryVisualScenes = pLibVisualScenes.release();
-// pLibraryGeometries = pLibGeometries.release();
-// pLibraryControllers = pLibControllers.release();
-// pLibraryAnimations = pLibAnimations.release();
-// pLibraryLights = pLibLights.release();
-// pLibraryCameras = pLibCameras.release();
-// pLibraryMaterials = pLibMaterials.release();
-// pLibraryImages = pLibImages.release();
-// pLibraryEffects = pLibEffects.release();
-
return;
}
+//void
+//ColladaAssets::Parse(xmlNodePtr root, LibsForParsing libsForParsing)
+//{
+// std::unique_ptr<LibraryVisualScenes::LibraryVisualScenes> pLibVisualScenes;
+// std::unique_ptr<LibraryGeometries::LibraryGeometries> pLibGeometries;
+// std::unique_ptr<LibraryControllers::LibraryControllers> pLibControllers;
+// std::unique_ptr<LibraryAnimations::LibraryAnimations> pLibAnimations;
+// std::unique_ptr<LibraryLights::LibraryLights> pLibLights;
+// std::unique_ptr<LibraryCameras::LibraryCameras> pLibCameras;
+// std::unique_ptr<LibraryMaterials::LibraryMaterials> pLibMaterials;
+// std::unique_ptr<LibraryImages::LibraryImages> pLibImages;
+// std::unique_ptr<LibraryEffects::LibraryEffects> pLibEffects;
+//
+//
+// if (libsForParsing.find(VISUALSCENES) != libsForParsing.end())
+// {
+// xmlNodePtr libraryVisualScenes = Tools::FindFirst(root->children, "library_visual_scenes", false);
+// SysTryReturnVoidResult(NID_UI, libraryVisualScenes != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_visual_scenes> not found.");
+//
+// pLibVisualScenes = std::unique_ptr<LibraryVisualScenes::LibraryVisualScenes>(new (std::nothrow) LibraryVisualScenes::LibraryVisualScenes(libraryVisualScenes));
+// SysTryReturnVoidResult(NID_UI, pLibVisualScenes.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+// //AppLog("VS");
+// }
+//
+// if (libsForParsing.find(GEOMETRIES) != libsForParsing.end())
+// {
+// xmlNodePtr libraryGeometries = Tools::FindFirst(root->children, "library_geometries", false);
+// SysTryReturnVoidResult(NID_UI, libraryGeometries != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_geometries> not found.");
+//
+// pLibGeometries = std::unique_ptr<LibraryGeometries::LibraryGeometries>(new (std::nothrow) LibraryGeometries::LibraryGeometries(libraryGeometries));
+// SysTryReturnVoidResult(NID_UI, pLibGeometries.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+// //AppLog("G");
+// }
+//
+// if (libsForParsing.find(CONTROLLERS) != libsForParsing.end())
+// {
+// xmlNodePtr libraryControllers = Tools::FindFirst(root->children, "library_controllers", false);
+// SysTryReturnVoidResult(NID_UI, libraryControllers != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_controllers> not found.");
+//
+// pLibControllers = std::unique_ptr<LibraryControllers::LibraryControllers> (new (std::nothrow) LibraryControllers::LibraryControllers(libraryControllers));
+// SysTryReturnVoidResult(NID_UI, pLibControllers.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+// //AppLog("C");
+// }
+//
+// if (libsForParsing.find(ANIMATIONS) != libsForParsing.end())
+// {
+// xmlNodePtr libraryAnimations = Tools::FindFirst(root->children, "library_animations", false);
+// SysTryReturnVoidResult(NID_UI, libraryAnimations != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_animations> not found.");
+//
+// pLibAnimations = std::unique_ptr<LibraryAnimations::LibraryAnimations>(new (std::nothrow) LibraryAnimations::LibraryAnimations(libraryAnimations));
+// SysTryReturnVoidResult(NID_UI, pLibAnimations.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+// //AppLog("A");
+// }
+//
+// if (libsForParsing.find(LIGHTS) != libsForParsing.end())
+// {
+// xmlNodePtr libraryLights = Tools::FindFirst(root->children, "library_lights", false);
+// SysTryReturnVoidResult(NID_UI, libraryLights != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_lights> not found.");
+//
+// pLibLights = std::unique_ptr<LibraryLights::LibraryLights>(new (std::nothrow) LibraryLights::LibraryLights(libraryLights));
+// SysTryReturnVoidResult(NID_UI, pLibLights.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+// //AppLog("L");
+// }
+//
+// if (libsForParsing.find(CAMERAS) != libsForParsing.end())
+// {
+// xmlNodePtr libraryCameras = Tools::FindFirst(root->children, "library_cameras", false);
+// SysTryReturnVoidResult(NID_UI, libraryCameras != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_cameras> not found.");
+//
+// pLibCameras = std::unique_ptr<LibraryCameras::LibraryCameras>(new (std::nothrow) LibraryCameras::LibraryCameras(libraryCameras));
+// SysTryReturnVoidResult(NID_UI, pLibCameras.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+// //AppLog("CAa");
+// }
+//
+// if (libsForParsing.find(MATERIALS) != libsForParsing.end())
+// {
+// xmlNodePtr libraryMaterials = Tools::FindFirst(root->children, "library_materials", false);
+// SysTryReturnVoidResult(NID_UI, libraryMaterials != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_materials> not found.");
+//
+// pLibMaterials = std::unique_ptr<LibraryMaterials::LibraryMaterials>(new (std::nothrow) LibraryMaterials::LibraryMaterials(libraryMaterials));
+// SysTryReturnVoidResult(NID_UI, pLibMaterials.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+// //AppLog("M");
+// }
+//
+// if (libsForParsing.find(IMAGES) != libsForParsing.end())
+// {
+// xmlNodePtr libraryImages = Tools::FindFirst(root->children, "library_images", false);
+// SysTryReturnVoidResult(NID_UI, libraryImages != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_images> not found.");
+//
+// pLibImages = std::unique_ptr<LibraryImages::LibraryImages>(new (std::nothrow) LibraryImages::LibraryImages(libraryImages));
+// SysTryReturnVoidResult(NID_UI, pLibImages.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+// //AppLog("I");
+// }
+//
+// if (libsForParsing.find(EFFECTS) != libsForParsing.end())
+// {
+// xmlNodePtr libraryEffects = Tools::FindFirst(root->children, "library_effects", false);
+// SysTryReturnVoidResult(NID_UI, libraryEffects != null, E_INVALID_FORMAT, "[E_INVALID_FORMAT] tag <library_effects> not found.");
+//
+// pLibEffects = std::unique_ptr<LibraryEffects::LibraryEffects> (new (std::nothrow) LibraryEffects::LibraryEffects(libraryEffects));
+// SysTryReturnVoidResult(NID_UI, pLibEffects.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+// //AppLog("E");
+// }
+//
+// if (libsForParsing.find(VISUALSCENES) != libsForParsing.end())
+// {
+// pLibraryVisualScenes = pLibVisualScenes.release();
+// }
+//
+// if (libsForParsing.find(GEOMETRIES) != libsForParsing.end())
+// {
+// pLibraryGeometries = pLibGeometries.release();
+// }
+//
+// if (libsForParsing.find(CONTROLLERS) != libsForParsing.end())
+// {
+// pLibraryControllers = pLibControllers.release();
+// }
+//
+// if (libsForParsing.find(ANIMATIONS) != libsForParsing.end())
+// {
+// pLibraryAnimations = pLibAnimations.release();
+// }
+//
+// if (libsForParsing.find(LIGHTS) != libsForParsing.end())
+// {
+// pLibraryLights = pLibLights.release();
+// }
+//
+// if (libsForParsing.find(CAMERAS) != libsForParsing.end())
+// {
+// pLibraryCameras = pLibCameras.release();
+// }
+//
+// if (libsForParsing.find(MATERIALS) != libsForParsing.end())
+// {
+// pLibraryMaterials = pLibMaterials.release();
+// }
+//
+// if (libsForParsing.find(IMAGES) != libsForParsing.end())
+// {
+// pLibraryImages = pLibImages.release();
+// }
+//
+// if (libsForParsing.find(EFFECTS) != libsForParsing.end())
+// {
+// pLibraryEffects = pLibEffects.release();
+// }
+//
+//// pLibraryVisualScenes = pLibVisualScenes.release();
+//// pLibraryGeometries = pLibGeometries.release();
+//// pLibraryControllers = pLibControllers.release();
+//// pLibraryAnimations = pLibAnimations.release();
+//// pLibraryLights = pLibLights.release();
+//// pLibraryCameras = pLibCameras.release();
+//// pLibraryMaterials = pLibMaterials.release();
+//// pLibraryImages = pLibImages.release();
+//// pLibraryEffects = pLibEffects.release();
+//
+// return;
+//}
+
}}}} // Tizen::Ui::Animations::_ImportCollada
typedef std::set<LIBSFORPARSING> LibsForParsing;
- ColladaAssets(const std::string& fileName, LibsForParsing libsForParsing);
+ ColladaAssets();
virtual ~ColladaAssets(void);
+ result Construct(const std::string& fileName, LibsForParsing libsForParsing);
public:
LibraryVisualScenes::LibraryVisualScenes* pLibraryVisualScenes;
LibraryEffects::LibraryEffects* pLibraryEffects;
private:
-
void Parse(xmlNodePtr root, LibsForParsing libsForParsing);
+private:
xmlDocPtr doc;
xmlNodePtr root;
-
-
};
}}}} // Tizen::Ui::Animations::_ImportCollada
return null;
}
+unsigned int
+GeometryMesh::GetSurfaceCount()
+{
+ return __surfacesInds.size();
+}
+
void
GeometryMesh::ParseVerticesNormalsTexcoords(const xmlNodePtr root)
{
};
typedef std::vector<SurfaceInds*> SurfacesInds;
SurfaceInds* GetSurfaceInds(unsigned int index);
+ unsigned int GetSurfaceCount();
private:
void ParseVerticesNormalsTexcoords(const xmlNodePtr root);
}
+unsigned int
+Node::GetInstancesCount()
+{
+ return __instances.size();
+}
+
+Instance*
+Node::GetInstanceByIndex(unsigned int index)
+{
+ if (index < __instances.size())
+ {
+ return __instances[index];
+ }
+ return null;
+}
+
+
}}}}} // Tizen::Ui::Animations::_ImportCollada::LibraryVisualScenes
_Math::Matrix4 GetLocalMatrix(void);
Node* FindNode(std::string nodeName);
+ unsigned int GetInstancesCount();
+ Instance* GetInstanceByIndex(unsigned int index);
+
private:
typedef std::vector<Transform*> Transformations;
Node* __pChild;
Instance::Instances __instances;
+
+ friend class _ModelImporterImpl;
};
}}}}} // Tizen::Ui::Animations::_ImportCollada::LibraryVisualScenes
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2013-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.
+
+/**
+ * @file FUiAnim_BoundingVolumeImpl.h
+ * @brief This is the header file for the _BoundingVolumeImpl class.
+ *
+ * This header file contains the declarations of the _BoundingVolumeImpl class.
+ */
+
+#ifndef _FUI_ANIM_INTERNAL_BOUNDING_VOLUME_H_
+#define _FUI_ANIM_INTERNAL_BOUNDING_VOLUME_H_
+
+#include <vector>
+
+#include "FBaseDataType.h"
+#include "FBaseSysLog.h"
+#include "FBaseErrors.h"
+
+#include "FUiAnimBoundingVolume.h"
+#include "math/FUiAnim_MathVector3.h"
+#include "math/FUiAnim_MathVector4.h"
+#include "math/FUiAnim_MathMatrix4.h"
+
+namespace Tizen{ namespace Ui{ namespace Animations
+{
+
+namespace _Math
+{
+class Matrix4;
+class Vector4;
+class Vector3;
+}
+
+class _OSP_EXPORT_ _BoundingVolumeImpl
+ : public Tizen::Base::Object
+{
+public:
+
+
+ /**
+ * Constructs _BoundingVolumeImpl with empty state
+ */
+ _BoundingVolumeImpl();
+ /**
+ * Destroys _BoundingVolumeImpl with empty state
+ */
+ ~_BoundingVolumeImpl();
+
+ static _BoundingVolumeImpl* GetInstance(BoundingVolume* pPublic);
+
+ static const _BoundingVolumeImpl* GetInstance(const BoundingVolume* pPublic);
+
+ /**
+ * Constructs _BoundingVolumeImpl and inits with supplied points
+ *
+ * @since 2.0
+ *
+ * @return result code
+ * @param[in] min minimum point of this box
+ * @param[in] max maximum point of this box
+ * @exception E_INVALID_ARG any min component bigger then max component
+ */
+ _BoundingVolumeImpl(const _Math::Vector3& min, const _Math::Vector3& max);
+
+ _BoundingVolumeImpl(const _Math::Vector3& center, const float radius);
+
+ result Set(const _Math::Vector3& min, const _Math::Vector3& max);
+
+ result Set(const _Math::Vector3& center, const float radius);
+
+ result Get(_Math::Vector3& min, _Math::Vector3& max);
+
+ result Get(_Math::Vector3& center, float& radius);
+
+ /**
+ * Returns center point of _BoundingVolumeImpl
+ *
+ * @since 2.0
+ *
+ * @return center point of _BoundingVolumeImpl
+ */
+ _Math::Vector3 GetCenter() const;
+
+ /**
+ * Returns vector, specifying half size of this _BoundingVolumeImpl
+ *
+ * @since 2.0
+ *
+ * @return vector, specifying half size of this _BoundingVolumeImpl
+ */
+ _Math::Vector3 GetHalfSize() const;
+
+ /**
+ * Adds volume of specified box to this _BoundingVolumeImpl
+ *
+ * @since 2.0
+ *
+ * @return result code
+ * @param[in] box box to merge to this box
+ * @exception E_INVALID_ARG given box state is not valid
+ */
+ result Merge(const _BoundingVolumeImpl& volume);
+
+ /**
+ * Adds specified point to this _BoundingVolumeImpl
+ *
+ * @since 2.0
+ *
+ * @param point point to merge to this box
+ */
+ result Merge(const _Math::Vector3& point);
+
+ /**
+ * Adds specified points to this _BoundingVolumeImpl
+ *
+ * @since 2.0
+ *
+ * @return result code
+ * @param[in] vertexes coordinates of points in form "xyzxyz..." to merge to this box,
+ * @param[in] vertexesLen points count provided
+ * @exception E_INVALID_ARG vertexes == 0 or vertexesLen < 0
+ */
+ result Merge(const float* vertexes, int vertexesLen);
+
+ /**
+ * Translates this _BoundingVolumeImpl by specified transformation
+ *
+ * @since 2.0
+ *
+ * @return result code
+ * @param[in] world translation to apply to this box
+ * @exception E_FAILURE box state is not valid
+ */
+
+
+ result Translate(const _Math::Matrix4& world);
+
+ /**
+ * Transforms this _BoundingVolumeImpl by specified transformation
+ *
+ * @since 2.0
+ *
+ * @param[in] world transformation to apply to this box
+ */
+ result Transform(const _Math::Matrix4& world);
+
+
+ /**
+ * Returns this _BoundingVolumeImpl to empty state
+ */
+ void Reset();
+
+ /**
+ * Checks is supplied box twice less then this
+ *
+ * @since 2.0
+ *
+ * @return result code
+ * @param[in] box box to check
+ * @param[in] is is supplied box twice less then this
+ * @exception E_INVALID_ARG given box state is not valid
+ */
+ result IsBoxTwiceLess(const _BoundingVolumeImpl& volume, bool& is);
+ /**
+ * Get the bounding volume state _BoundingVolumeImpl
+ *
+ * @since 3.0
+ *
+ * @return bounding volume state as in BoundingVolumeState
+ */
+ BoundingVolumeState GetState() const;
+
+ /**
+ * Get the bounding volume type _BoundingVolumeImpl
+ *
+ * @since 3.0
+ *
+ * @return bounding volume type as in BoundingVolumeType
+ */
+ BoundingVolumeType GetType() const;
+
+ /**
+ * Set the bounding volume type _BoundingVolumeImpl
+ *
+ * @since 3.0
+ *
+ * @param[in] type bounding volume type as in BoundingVolumeType
+ */
+ result SetType(BoundingVolumeType);
+
+ _BoundingVolumeImpl& operator =(const _BoundingVolumeImpl& rhs);
+ bool operator ==(const _BoundingVolumeImpl& rhs) const;
+ bool operator !=(const _BoundingVolumeImpl& rhs) const;
+ bool Equals(const Tizen::Base::Object& obj) const;
+ int GetHashCode() const;
+
+ /**
+ * Holds current state of this BoundingVolume
+ */
+ BoundingVolumeState State;
+ /**
+ * Holds current type of this BoundingVolume
+ */
+ BoundingVolumeType Type;
+
+ /**
+ * Minimum point of this BoundingVolume if AABB
+ * or Center if SPHERE
+ */
+ _Math::Vector3 Min;
+
+ /**
+ * Minimum point of this BoundingVolume if AABB
+ * or Radius in x coordinate if SPHERE
+ */
+ _Math::Vector3 Max;
+
+
+ void print() const;
+
+private:
+
+};
+
+
+}}} //namespace Tizen{ namespace Ui{ namespace Animations
+#endif // _FUI_ANIM_INTERNAL_BOUNDING_VOLUME_H_
//#include "FGrpFloatPoint3.h"
//#include "FGrpColor.h"
-#include <string>
-
#include "FUiAnimMesh.h"
+#include "FUiAnimBoundingVolume.h"
#include "FUiAnim_RefObject.h"
-#include "FUiAnim_BoundingVolume.h"
+#include <string>
+#include <algorithm>
+
namespace Tizen { namespace Ui { namespace Animations {
+
+#define APPROPRIATE_COUNT_VERTICES 3
+#define APPROPRIATE_COUNT_NORMALS 3
+#define APPROPRIATE_COUNT_COLORS 4
+#define APPROPRIATE_COUNT_TEXTCOORDINATES 2
+
class _Mutex;
-class _OSP_EXPORT_ _MeshImpl : public RefObject
+
+class _OSP_EXPORT_ _MeshImpl
+ : public RefObject
{
public:
explicit _MeshImpl(const Mesh& mesh);
public:
static _MeshImpl* GetInstance(Mesh& mesh);
static const _MeshImpl* GetInstance(const Mesh& mesh);
+ static Mesh* LoadFromBinaryN(const std::string& fileName, const std::string& modelName);
result SetVertex(int arrayIndex, const Tizen::Graphics::FloatPoint3& point);
result SetTextureCoord(int arrayIndex, const Tizen::Graphics::FloatPoint& textureCoord);
result SetGeometryType(Mesh::GeometryType type);
Mesh::GeometryType GetGeometryType() const;
- result AdjustBoundingBox(bool rebuild);
-
void Clear();
- Tizen::Graphics::FloatPoint3 GetBoundingBoxPosition() const;
- float GetBoundingBoxVolume() const;
- float GetBoundingBoxWidth() const;
- float GetBoundingBoxHeight() const;
+ result AdjustBoundingVolume(bool rebuild);
+ BoundingVolume& GetBoundingVolume();
+// Tizen::Graphics::FloatPoint3 GetBoundingBoxPosition() const;
+// float GetBoundingBoxVolume() const;
+// float GetBoundingBoxWidth() const;
+// float GetBoundingBoxHeight() const;
// 임시 함수
result AllocVertices(int count);
return __countOfIndex;
}
-
+ bool IsVerticesEnabled() const
+ {
+ return (__pVertices)?true:false;
+ }
bool IsIndexEnabled() const
{
return (__pIndices)?true:false;
{
return (__pNormals)?true:false;
}
+ bool IsSurfaceClosed();
+
+
void SetName(std::string name)
{
__name = name;
{
return __name;
}
+
+ result SaveMesh(const Tizen::Base::String& fileName);
+
protected:
virtual ~_MeshImpl();
+ //result GatherBoundingPosition(const Tizen::Graphics::FloatPoint3& pt);
private:
result AllocTextureCoordinates();
result AllocNormals();
int __countOfAllocatedIndex;
// bounding box
- bool __hasBoundingBox;
+// Tizen::Graphics::FloatPoint3 __boundingBox;
+// float __boundingBoxVolume;
+// float __boundingBoxWidth;
+// float __boundingBoxHeight;
+//
+ bool __hasBoundingVolume;
BoundingVolume __boundingVolume;
+ // temp pos
+// float __minPos[3];//x,y,z
+// float __maxPos[3];//x,y,z
+
Mesh* __pPublic;
friend class Mesh;
- friend class _VisualElementImpl;
friend class _MeshImportSample;
friend class _GlRenderManager;
+ friend class _VisualElementImpl;
+ friend struct Header;
+ struct TriangleIndex
+ {
+ unsigned short int v0, v1, v2;
+ };
+ struct EdgeIndex
+ {
+ int from, to;
+ int ownerID;
+ bool swaped;
+ };
+static bool SortFunc(EdgeIndex i, EdgeIndex j)
+ {
+ return ((i.from < j.from) ||
+ ((i.from == j.from) && (i.to < j.to)));
+ };
};
-
+struct Header
+ {
+ bool isVerticesEnabled;
+ bool isIndexEnabled;
+ bool isTextureCoordinateEnabled;
+ bool isColorEnabled;
+ bool isNormalEnabled;
+ void SetMeshArrays(const _MeshImpl& rhs);
+ };
+//static Header capacity;
}}} //namespace Tizen { namespace Ui { namespace Animations {
#endif // _FUI_ANIM_MESH_IMPL_H_
#include "FUiAnimScene.h"
#include "FUiAnim_ImportColladaColladaAssets.h"
+#include "library-visual-scenes/FUiAnim_ImportColladaLibVisScenNode.h"
+#include "library-effects/FUiAnim_ImportColladaLibEffEffect.h"
namespace Tizen { namespace Ui { namespace Animations {
+
class _OSP_EXPORT_ _ModelImporterImpl
: Tizen::Base::Object
{
public:
+
_ModelImporterImpl(const std::string& fileName, bool visualScenes, bool geometries, bool controllers, bool anmations, bool materials, bool effects, bool images, bool lights, bool cameras);
- virtual ~_ModelImporterImpl();
+ virtual ~_ModelImporterImpl(void);
- Mesh* LoadMeshCollada(const std::string& modelName, bool norms, bool tcoords);
- static Mesh* LoadMeshBinN(const std::string& fileName);
+ Mesh* LoadMeshCollada(const std::string& modelName, std::string& materialId, bool inverseY);
+ static Mesh* LoadMeshBinN(const std::string& fileName, const std::string& modelName);
- Material* LoadMaterial(const std::string& materialId, std::string& texureId);
+ Material* LoadMaterial(const std::string& materialId, std::string& texureId, _ImportCollada::LibraryEffects::Effect::ShaderType& shaderType);
std::string LoadTextureName(const std::string& imageId);
- Scene* LoadScene(const std::string& sceneId);
+ Scene* LoadScene(const std::string& sceneId, bool inverseY);
+
+
+private:
+ void WalkingTheTree(_ImportCollada::LibraryVisualScenes::Node* pNode, Scene* pScene, bool inverseY);
+
private:
_ImportCollada::ColladaAssets* colladaAssets;
//
// Open Service Platform
-// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+// 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.
#include "FUiAnimMaterial.h"
#include "FUiAnimVisualElement.h"
-//#include <list>
-#include <vector>
+#include <list>
#include <string>
namespace Tizen { namespace Ui { namespace Animations {
: public Tizen::Base::Object
{
public:
- _SceneImpl();
- virtual ~_SceneImpl();
+ _SceneImpl(void);
+ virtual ~_SceneImpl(void);
+
VisualElement* GetRootVisualElement(void) const;
result AddMesh(Mesh* pMesh);
result RemoveMesh(const std::string& meshName);
- Mesh* GetMesh(const std::string& meshName) const;
- Tizen::Base::Collection::ArrayList* GetMeshNamesN() const;
+ Mesh* GetMeshN(const std::string& meshName) const;
+ Tizen::Base::Collection::ArrayList* GetMeshNamesN(void) const;
result AddMaterial(Material* pMaterial);
result RemoveMaterial(const std::string& materialName);
- Material* GetMaterial(const std::string& materialName) const;
- Tizen::Base::Collection::ArrayList* GetMaterialNamesN() const;
+ Material* GetMaterialN(const std::string& materialName) const;
+ Tizen::Base::Collection::ArrayList* GetMaterialNamesN(void) const;
result AddTextureFileName(std::string textureFileName);
- Tizen::Base::Collection::ArrayList* GetTextureFileNamesN() const;
+ Tizen::Base::Collection::ArrayList* GetTextureFileNamesN(void) const;
private:
VisualElement* __pRootVisualElement;
- //typedef std::list<Mesh*> Meshes;
- typedef std::vector<Mesh*> Meshes;
- typedef std::vector<Material*> Materials;
- typedef std::vector<std::string> TextureFileNames;
+ typedef std::list<Mesh*> Meshes;
+ typedef std::list<Material*> Materials;
+ typedef std::list<std::string> TextureFileNames;
Meshes __meshes;
Materials __materials;
TextureFileNames __textureFileNames;
#include "FUi_PropertyBase.h"
+#include "FUiAnimBoundingVolume.h"
+
+#include "FUiAnim_Ray.h"
+#include "FUiAnim_VisualElementCoordinateSystem.h"
+#include "FUiAnim_NativeLayer.h"
#include "FUiAnim_RootVisualElement.h"
#include "FUiAnim_VisualElementSharedData.h"
#include "FUiAnim_TransformMatrix3Df.h"
-#include "FUiAnim_VisualElementCoordinateSystem.h"
-#include "FUiAnim_BoundingVolume.h"
-#include "FUiAnim_Ray.h"
-#include <algorithm>
-#include <limits>
+#include <vector>
#define SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION
+namespace Tizen { namespace Ui { namespace Animations { namespace _Math {
+class Vector3;
+class Matrix4;
+}}}}
+
namespace Tizen { namespace Ui
{
class _ControlImpl;
//picking related methods and variables
//void __MakeRayIntersection(const _Ray& ray, DistanceVAs& intersected); //until all picking interface implementing,algorithm description related
- _Ray __MakeLocalRay(const _Ray& ray, const _VisualElementImpl* ve);
-
- bool __CreatePVInv(_Math::Matrix4& pvInv, Tizen::Graphics::FloatRectangle& frame);
void __SearchTriangleListIntersection(const _Ray& localRay, const Mesh* mesh, Intersections& intersections, bool seachAllIntersections);
void __SearchTriangleStripIntersection(const _Ray& localRay, const Mesh* mesh, Intersections& intersections, bool seachAllIntersections);
friend class _NativeLayer;
friend class _TransactionNode;
friend class _GlNode;
+ friend class _Ray;
}; // _VisualElementImpl
}}} // Tizen::Ui::Animations