/**
* Get light type.
*
- * @since 2.0
+ * @since 3.0
*
* @return Type of the light.
* @see SetType().
/**
* Sets light type.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] lightType Type of the light.
* @see GetLightType().
/**
* Get light diffuse.
*
- * @since 2.0
+ * @since 3.0
*
* @return Diffuse of the light.
* @see SetDiffuse().
/**
* Sets light diffuse color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] diffuse Diffuse color of the light.
* @see GetDiffuse().
/**
* Get light specular.
*
- * @since 2.0
+ * @since 3.0
*
* @return Specular of the light.
* @see SetSpecular().
/**
* Sets light specular.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] specular Type of the light.
* @see GetSpecular().
/**
* Get light ambient.
*
- * @since 2.0
+ * @since 3.0
*
* @return Ambient of the light.
* @see SetAmbient().
/**
* Sets light ambient.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] ambient Ambient of the light.
* @see GetAmbient().
/**
* Get light position.
*
- * @since 2.0
+ * @since 3.0
*
* @return Position of the light.
* @see SetPosition().
/**
* Sets light position.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] position Position of the light.
* @see GetPosition().
/**
* Get light direction.
*
- * @since 2.0
+ * @since 3.0
*
* @return Direction of the light.
* @see SetDirection().
/**
* Sets light direction.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] lightType Direction of the light.
* @see GetDirection().
/**
* Get light exponent.
*
- * @since 2.0
+ * @since 3.0
*
* @return Exponent of the light.
* @see SetExponent().
/**
* Sets light exponent.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] exponent Exponent of the light.
* @see SetExponent().
/**
* Get light cut off.
*
- * @since 2.0
+ * @since 3.0
*
* @return CutOff of the light.
* @see SetCutOff().
/**
* Sets light cut off.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] cutOff Cut off of the light.
* @see GetCutOff().
/**
* Get light position.
*
- * @since 2.0
+ * @since 3.0
*
* @return Position of the light.
* @see SetConstantAttenuation().
/**
* Sets light constant attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] attenuation Constant attenuation of the light.
* @see GetConstantAttenuation().
/**
* Get light linear attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @return Linear attenuation of the light.
* @see SetLinearAttenuation().
/**
* Sets light linear attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] attenuation Linear attenuation of the light.
* @see GetLinearAttenuation().
/**
* Get light linear attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @return Quadratic attenuation of the light.
* @see SetQuadraticAttenuation().
/**
* Sets light quadratic attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] attenuation Quadratic attenuation of the light.
* @see GetQuadraticAttenuation().
/**
* Get light name.
*
- * @since 2.0
+ * @since 3.0
*
* @return Name of the light.
* @see SetName().
/**
* Sets light name.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] name Name of the light.
* @see GetName().
/**
* Get light enabled status.
*
- * @since 2.0
+ * @since 3.0
*
* @return true if light is enabled, false - otherwise.
* @see SetEnabled().
/**
* Sets light enable.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] enables Enable status of the light.
* @see IsEnabled().
/**
* Sets light color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] color Color of the light.
* @see GetColor().
/**
* Get light color.
*
- * @since 2.0
+ * @since 3.0
*
* @return COlor of the light.
* @see SetColor().
/**
* Sets light intencity.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] intencity Intencity of the light.
* @see GetIntencity().
/**
* Get light intencity.
*
- * @since 2.0
+ * @since 3.0
*
* @return Intencity of the light.
* @see SetIntensity().
/**
* Sets light radius.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] radius Radius of the light.
* @see GetRadius().
/**
* Get light radius.
*
- * @since 2.0
+ * @since 3.0
*
* @return Radius attenuation of the light.
* @see SetRadius().
/**
* Sets light radius of the spot.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] spotlightRadius Radius of the light spot.
* @see GetSpotlightRadius().
/**
* Get light linear attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @return Linear attenuation of the light.
* @see SetSpotlightRaduis().
/**
* Get material diffuse color.
*
- * @since 2.0
+ * @since 3.0
*
* @return Diffuse color of the material.
* @see SetDiffuse().
/**
* Sets material diffuse color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] diffuse Diffuse color of the material.
* @see GetDiffuse().
/**
* Get material specular color.
*
- * @since 2.0
+ * @since 3.0
*
* @return specular color of the material.
* @see SetSpecular().
/**
* Sets material specular color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] specular Specular color of the material.
* @see GetSpecular().
/**
* Sets material ambient color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] ambient Ambient color of the material.
* @see GetAmbient().
/**
* Get material emissive color.
*
- * @since 2.0
+ * @since 3.0
*
* @return Emissive color of the material.
* @see SetEmissive().
/**
* Sets material emissive color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] emissive Emissive color of the material.
* @see GetEmissive().
/**
* Get emissive power.
*
- * @since 2.0
+ * @since 3.0
*
* @return emissive power of the material.
* @see SetEmissivePower().
/**
* Sets material emissive power.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] value Emissive power of the material.
* @see GetEmissivePower().
/**
* Get material shininess.
*
- * @since 2.0
+ * @since 3.0
*
* @return shininess of the material.
* @see SetShininess().
/**
* Sets material name.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] shininess Shininess of the material.
* @see GetShininess().
/**
* Get material name.
*
- * @since 2.0
+ * @since 3.0
*
* @return Name of the material.
* @see SetName().
/**
* Sets material name.
*
- * @since 2.0
+ * @since 3.0
*
* @param[] name Name of the material.
* @see GetName().
Scene(void);
virtual ~Scene(void);
+ result Construct();
+
/**
* Returns pointer to the root element of the scene tree
*
namespace Tizen { namespace Ui { namespace Animations
{
-//class VisualElementSurface;
class _ShaderProgramImpl;
{
public:
ShaderProgram(void);
+ ShaderProgram(const ShaderProgram& shaderProgram);
virtual ~ShaderProgram(void);
/**
result Construct(Shader& vertexShader, Shader& fragmentShader);
/**
+ * Constructs the ShaderProgram using vertexShader and fragmentShader.
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ *
+ * @param[in] vertexShader source code of vertex shader
+ * @param[in] fragmentShader source code of fragment shader
+ *
+ * @exception E_SUCCESS
+ * @exception E_OUT_OF_MEMORY
+ * @exception E_SYSTEM if shader was not constructed or compiled with an error
+ */
+ result Construct(const Tizen::Base::String& vertexShader, const Tizen::Base::String& fragmentShader);
+
+ /**
* Gets the value of uniform by name of the current instance of %ShaderProgram
*
* @since 3.0
*/
result SetUniform(const Tizen::Base::String& name, const Tizen::Ui::Variant& value);
- /**
- * Binds an attribute to the ShaderProgram.
- *
- * @since 3.0
- *
- * @return An error code
- *
- * @param[in] location possibly program locations
- * @param[in] name attribute name in shader program
- *
- * @exception E_SUCCESS
- * @exception E_INVALID_ARG if name was not found in shader program
- * @see ProgramLocation
- */
- //result BindAttribute(ProgramLocation location, const Tizen::Base::String &name);
-
- /**
- * Binds the uniform to the ShaderProgram.
- *
- * @since 3.0
- *
- * @return An error code
- *
- * @param[in] location possibly location
- * @param[in] name uniform name in shader program
- *
- * @exception E_SUCCESS
- * @exception E_INVALID_ARG if name was not found in shader program
- * @see ProgramLocation
- */
- //result BindUniform(ProgramLocation location, const Tizen::Base::String &name);
-
- /**
- * Checks the program location for been bind with uniform or attribute in shader program
- *
- * @since 3.0
- *
- * @return true, if location is bind, false otherwise
- *
- * @param[in] location requested location
- * @see ProgramLocation
- */
- //bool IsParameterAvailable(const ProgramLocation location) const;
-
- /**
- * Checks for the uniform or attribute by name in shader program been bind with program location
- *
- * @since 3.0
- *
- * @return true, if name is bind, false otherwise
- *
- * @param[in] name Tizen::Base::String name of the uniform or attribute in shader program
- */
- //bool IsParameterAvailable(const Tizen::Base::String& name) const;
-
- /**
- * Unbind an attribute from the ShaderProgram.
- *
- * @since 3.0
- *
- * @return An error code
- *
- * @param[in] name attribute name in shader program
- *
- * @exception E_SUCCESS
- * @exception E_INVALID_ARG if name was not found in shader program
- */
- //result UnbindUniform(const Tizen::Base::String &name);
-
- /**
- * Unbind an uniform from the ShaderProgram.
- *
- * @since 3.0
- *
- * @return An error code
- *
- * @param[in] name attribute name in shader program
- *
- * @exception E_SUCCESS
- * @exception E_INVALID_ARG if name was not found in shader program
- */
- //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);
class _ShaderProgramImpl* __pShaderProgramImpl;
#include <FUiAnimIVisualElementAnimationProvider.h>
#include <FUiAnimIVisualElementContentProvider.h>
#include <FUiAnimIVisualElementEventListener.h>
+#include "FUiAnimBoundingVolume.h"
namespace Tizen { namespace Graphics {
class Canvas;
* @remarks If an exception occurs, this method returns @c null.
* @see SetMesh()
*/
- Mesh* GetMeshN(const Tizen::Base::String& name) const;
+ Mesh* GetMeshN(void) const;
/**
* Sets the contents of this instance with the specified Material. @n
* @remarks If an exception occurs, this method returns @c null.
* @see SetMaterial()
*/
- Material* GetMaterialN(const Tizen::Base::String& name) const;
+ Material* GetMaterialN(void) const;
/**
* Sets the contents of this instance with the specified Light. @n
* @remarks If an exception occurs, this method returns @c null.
* @see SetLight()
*/
- Light* GetLightN(const Tizen::Base::String& name) const;
+ Light* GetLightN(void) const;
result SetShaderProgram(ShaderProgram* pShaderProgram);
*/
static result Flush(void);
+ //Visual Element Bounding volume related
+ /**
+ * Re adjust %VisualElement's BoundingVolume
+ *
+ * @since 3.0
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @remarks Bounding volume automatically adjusts when call SetMesh(), AttachChild() DeattachCild() and InsertChild() methods of VisualElement
+ * @see GetBoundingVolume()
+ */
+ result AdjustBoundingVolume();
+ /**
+ * Get %VisualElement's BoundingVolume, Bounding Volume that build merging Visual Element mesh and children Bounding Volumes
+ *
+ * @since 3.0
+ *
+ * @return BoundingVolume reference
+ * @see AdjustBoundingVolume()
+ */
+ BoundingVolume& GetBoundingVolume();
+
+
protected:
/**
_pSceneImpl = null;
}
+result
+Scene::Construct()
+{
+ return _pSceneImpl->Construct();
+}
+
VisualElement*
Scene::GetRootVisualElement(void) const
{
: __pShaderProgramImpl(null)
{
}
+ShaderProgram::ShaderProgram(const ShaderProgram& shaderProgram)
+ : __pShaderProgramImpl(null)
+{
+ SysAssertf(shaderProgram.__pShaderProgramImpl != null, "Not yet constructed.");
+
+ __pShaderProgramImpl = shaderProgram.__pShaderProgramImpl;
+ if(__pShaderProgramImpl != null)
+ {
+ __pShaderProgramImpl->AddRef();
+ }
+}
ShaderProgram::~ShaderProgram(void)
{
if (__pShaderProgramImpl)
{
- delete __pShaderProgramImpl;
+ __pShaderProgramImpl->Release();
__pShaderProgramImpl = null;
}
}
return E_SUCCESS;
}
+result
+ShaderProgram::Construct(const Tizen::Base::String& vertexShader, const Tizen::Base::String& fragmentShader)
+{
+ ClearLastResult();
+ SysAssertf(__pShaderProgramImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+ __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);
}
-/*
-result
-ShaderProgram::BindAttribute(ProgramLocation location, const Tizen::Base::String &name)
-{
- SysAssertf(__pShaderProgramImpl != null,
- "Not yet constructed. Construct() should be called before use.");
-
- return __pShaderProgramImpl->BindAttribute(location, name);
-}*/
-/*
-result
-ShaderProgram::BindUniform(ProgramLocation location, const Tizen::Base::String &name)
-{
- SysAssertf(__pShaderProgramImpl != null,
- "Not yet constructed. Construct() should be called before use.");
-
- return __pShaderProgramImpl->BindUniform(location, name);
-}
-*/
result
ShaderProgram::SetUniform(const Tizen::Base::String& name, const Tizen::Ui::Variant& value)
return __pShaderProgramImpl->SetUniform(name, value);
}
-/*
-bool
-ShaderProgram::IsParameterAvailable(const ProgramLocation location) const
-{
- return __pShaderProgramImpl->IsParameterAvailable(location);
-}
-
-
-bool
-ShaderProgram::IsParameterAvailable(const Tizen::Base::String& name) const
-{
- return __pShaderProgramImpl->IsParameterAvailable(name);
-}
-
-result
-ShaderProgram::UnbindAttribute(const Tizen::Base::String &name)
-{
- return __pShaderProgramImpl->UnbindAttribute(name);
-}
-
-result
-ShaderProgram::UnbindUniform(const Tizen::Base::String &name)
-{
- 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
return _pVisualElementImpl->SetMesh(pMesh);
}
Mesh*
-VisualElement::GetMeshN(const String& name) const
+VisualElement::GetMeshN(void) const
{
CHECK_CONSTRUCTED;
- return _pVisualElementImpl->GetMeshN(name);
+ return _pVisualElementImpl->GetMeshN();
}
result
}
Material*
-VisualElement::GetMaterialN(const Tizen::Base::String& name) const
+VisualElement::GetMaterialN(void) const
{
CHECK_CONSTRUCTED;
- return _pVisualElementImpl->GetMaterialN(name);
+ return _pVisualElementImpl->GetMaterialN();
}
result
}
Light*
-VisualElement::GetLightN(const Tizen::Base::String& name) const
+VisualElement::GetLightN(void) const
{
CHECK_CONSTRUCTED;
- return _pVisualElementImpl->GetLightN(name);
+ return _pVisualElementImpl->GetLightN();
}
result
return _pVisualElementImpl->CreateAnimationForPropertyI(property);
}
+result
+VisualElement::AdjustBoundingVolume()
+{
+ CHECK_CONSTRUCTED;
+
+ return _pVisualElementImpl->AdjustBoundingVolume();
+}
+
+BoundingVolume&
+VisualElement::GetBoundingVolume()
+{
+ CHECK_CONSTRUCTED;
+
+ return _pVisualElementImpl->GetBoundingVolume();
+}
}}} // Tizen::Ui::Animations
delete __pLight;
__pLight = null;
}
+ if (__pShaderProgram != null)
+ {
+ delete __pShaderProgram;
+ __pShaderProgram = null;
+ }
}
void
if (program <= 0)
{
- __pShaderProgram = null;
-
+ //__pShaderProgram = null;
+ if (__pShaderProgram != null)
+ {
+ delete __pShaderProgram;
+ __pShaderProgram = null;
+ }
SysLog(NID_UI_ANIM, "[E_INVALID_ARG] Invalid argument is used. programId = %d", program);
return E_INVALID_ARG;
}
}
+ if (pShaderProgram != null)
+ {
+
+ if (__pShaderProgram)
+ {
+ delete __pShaderProgram;
+ __pShaderProgram = new (std::nothrow) ShaderProgram(*pShaderProgram);
+ }
+ else
+ {
+ __pShaderProgram = new (std::nothrow) ShaderProgram(*pShaderProgram);
+ }
+ }
+ else
+ {
+ if (__pShaderProgram != null)
+ {
+ delete __pShaderProgram;
+ __pShaderProgram = null;
+ }
+ }
- __pShaderProgram = pShaderProgram;
+ //__pShaderProgram = pShaderProgram;
__isShaderProgramUpdated = true;
return E_SUCCESS;
case UNIFORM_FLOAT_LIGHT_EXPONENT:
case UNIFORM_FLOAT_LIGHT_STRUCT_EXPONENT:
SysTryLog(NID_UI_ANIM,__pRenderQueue[i].__pLight != null, "Light is null");
- glUniform1f((*it).second, pLightImpl->GetSpotExponent());
+ if(__pRenderQueue[i].__pLight)
+ {
+ glUniform1f((*it).second, pLightImpl->GetSpotExponent());
+ }
break;
case UNIFORM_FLOAT_LIGHT_CUTOFF:
case UNIFORM_FLOAT_LIGHT_STRUCT_CUTOFF:
delete [] name;
}
-
+//
+void
+_GlRenderManager::CommandHandlerUniformInformation(LocationInfo* pLocationInfo)
+{
+ pLocationInfo->result = __pGlContext->GetUniformLocation(pLocationInfo->program, pLocationInfo->name);
+}
+void
+_GlRenderManager::CommandHandlerAttribInformation(LocationInfo* pLocationInfo)
+{
+ pLocationInfo->result = __pGlContext->GetAttribLocation(pLocationInfo->program, pLocationInfo->name);
+}
+//
void
_GlRenderManager::CommandHandlerGetAttribLocation(_ShaderProgramImpl* pShaderProgram)
{
return (__commandResult == E_SUCCESS);
}
+//
+bool
+_GlRenderManager::GetUniformInfo(LocationInfo* pLocationInfo)
+{
+ if (unlikely(IsInRenderThread()))
+ {
+ pLocationInfo->result = __pGlContext->GetUniformLocation(pLocationInfo->program, pLocationInfo->name);
+ return true;
+ }
+ _AutoMutex commandTransactionLock(__commandTransaction);
+ _AutoMutex commandLock(__commandLock);
+ __commandId = COMMAND_GET_UNIFORM;
+ __commandArg.__pCommandUniformInfo = pLocationInfo;
+ __commandRequest.SendSignal();
+ __commandReply.WaitForSignal(&__commandLock);
+
+ return (__commandResult == E_SUCCESS);
+}
+bool
+_GlRenderManager::GetAttribInfo(LocationInfo* pLocationInfo)
+{
+ if (unlikely(IsInRenderThread()))
+ {
+ pLocationInfo->result = __pGlContext->GetAttribLocation(pLocationInfo->program, pLocationInfo->name);
+ return true;
+ }
+ _AutoMutex commandTransactionLock(__commandTransaction);
+ _AutoMutex commandLock(__commandLock);
+
+ __commandId = COMMAND_GET_ATTRIB;
+ __commandArg.__pCommandUniformInfo = pLocationInfo;
+ __commandRequest.SendSignal();
+ __commandReply.WaitForSignal(&__commandLock);
+
+ return (__commandResult == E_SUCCESS);
+}
+//
//temp
unsigned int
_GlRenderManager::BuildShader(int type, const char* pShaderSource)
case COMMAND_DELETE_SHADER:
pThis->CommandHandlerDeleteShader(commandArg.__pCommandShader);
break;
+ case COMMAND_GET_UNIFORM:
+ pThis->CommandHandlerUniformInformation(commandArg.__pCommandUniformInfo);
+ break;
+ case COMMAND_GET_ATTRIB:
+ pThis->CommandHandlerAttribInformation(commandArg.__pCommandUniformInfo);
+ break;
case COMMAND_COMPOSITE:
PRINT(">> CommandHandlerComposite() COMMAND_COMPOSITE - start \n");
if (pThis->Animate())
class _ShaderImpl;
class _ShaderProgramImpl;
class _GlShaderProgram;
-//class _GlColorShaderProgram;
-//class _GlUniformColorShaderProgram;
-//class _GlTextureShaderProgram;
-//class _GlTextureOpacityShaderProgram;
-//class _GlLightShaderProgram;
-
+// temp
class Light;
class Material;
struct TextureInfo;
+typedef struct LocationInfo
+{
+ unsigned int program;
+ int result;
+ const char* name;
+};
class _GlRenderManager
{
public:
COMMAND_BUILD_SHADER,
COMMAND_DELETE_SHADER,
COMMAND_BUILD_SHADER_PROGRAM,
- COMMAND_DELETE_SHADER_PROGRAM
+ COMMAND_DELETE_SHADER_PROGRAM,
+ COMMAND_GET_UNIFORM,
+ COMMAND_GET_ATTRIB
};
static _GlRenderManager* GetInstance(void)
bool DeleteShader(_ShaderImpl* pShader);
bool BuildShaderProgram(_ShaderProgramImpl* pShaderProgram);
bool DeleteShaderProgram(_ShaderProgramImpl* pShaderProgram);
-
+ bool GetUniformInfo(LocationInfo* pUniformInfo);
+ bool GetAttribInfo(LocationInfo* pUniformInfo);
unsigned int BuildShader(int type, const char* pShaderSource);
bool DeleteShader(unsigned int shaderId);
unsigned int BuildShaderProgram(unsigned int vertexShader, unsigned int fragmentShader);
// Shader
void CommandHandlerBuildShader(_ShaderImpl* pShader);
void CommandHandlerDeleteShader(_ShaderImpl* pShader);
-
+ void CommandHandlerUniformInformation(LocationInfo* pUniformInfo);
+ void CommandHandlerAttribInformation(LocationInfo* pUniformInfo);
void CommandHandlerBuildShaderProgram(_ShaderProgramImpl* pShaderProgram);
void CommandHandlerDeleteShaderProgram(_ShaderProgramImpl* pShaderProgram);
void CommandHandlerGetUniformLocation(_ShaderProgramImpl* pShaderProgram);
TextureInfo* __pCommandTextureInfo;
_ShaderImpl* __pCommandShader;
_ShaderProgramImpl* __pCommandShaderProgram;
+ LocationInfo* __pCommandUniformInfo;
} CommandArg;
class _RenderObject : public Tizen::Base::Object
,__hasGlUniforms(false)
{
locationVec = new std::vector<std::pair<ProgramLocation, int> >();
- //__shaderVariableList.clear();
}
_GlShaderProgram::~_GlShaderProgram(void)
locationVec->clear();
delete locationVec;
}
- //__shaderVariableList.clear();
-
-// _GlRenderManager::GetInstance()->DeleteShader(__vertexShader);
-// _GlRenderManager::GetInstance()->DeleteShader(__fragmentShader);
-// _GlRenderManager::GetInstance()->DeleteShaderProgram(__program);
}
Variant
{
return "Undefined ProgramLocation";
}
- static char *Errors[PROGRAM_LOCATION_MAX] = {
+ static char Errors[PROGRAM_LOCATION_MAX][64] = {
"UNIFORM_MAT4_MVP",
"UNIFORM_VEC4_COLOR",
"UNIFORM_SAMPLER2D_TEXTURE",
void
_GlShaderProgram::BindAttributes()
{
- static char *attributes[PROGRAM_LOCATION_MAX-1] = {
+ static char attributes[PROGRAM_LOCATION_MAX-1][64] = {
"u_mvp",
"u_color",
"u_tex2d",
};
int glAttribute = -1;
+ LocationInfo info;
+ info.program = __program;
+ info.result = -1;
+
for (int i = 0; i < PROGRAM_LOCATION_MAX-1; ++i)
{
- if ((glAttribute = glGetAttribLocation(__program, attributes[i])) != -1)
+ info.name = attributes[i];
+ _GlRenderManager::GetInstance()->GetAttribInfo(&info);
+ if ((glAttribute = info.result) != -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));
+ info.result = -1;
+ continue;
}
- if ((glAttribute = glGetUniformLocation(__program, attributes[i])) != -1)
+ _GlRenderManager::GetInstance()->GetUniformInfo(&info);
+ if ((glAttribute = info.result) != -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));
+ info.result = -1;
+ continue;
}
}
return;
std::wstring wStr(name.GetPointer());
std::string locationName(wStr.begin(), wStr.end());
- int glAttribute;
+ int glAttribute = -1;
containerLocations::iterator it;
containerLocations::iterator itEnd;
SysTryReturnResult(NID_UI_ANIM, String::Compare((it->first).second, name) != 0, E_INVALID_ARG, "\"%s\" is already binded",locationName.c_str());
}
- glAttribute = glGetUniformLocation(__program, locationName.c_str());
+ LocationInfo info;
+ info.program = __program;
+ info.name = locationName.c_str();
+ info.result = -1;
+
+ _GlRenderManager::GetInstance()->GetUniformInfo(&info);
+
+ glAttribute = info.result;
SysTryReturnResult(NID_UI_ANIM, glAttribute != -1, E_INVALID_ARG, "Can't bind a \"%s\" uniform", locationName.c_str());
glUniforms.push_back(data);
}
- //__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;
}
-/*
-void
-_GlShaderProgram::SetProgram(unsigned int program)
-{
-__program = program;
-}
-*/
-/*
-bool
-_GlShaderProgram::LoadShader(const char* pVertexShaderBin, int vertexLength, const char* pFragmentShaderBin, int fragmentLength)
-{
- return true;
-}
-*/
-/*
-int
-_GlShaderProgram::GetAttribLocation(const char* name)
-{
- 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);
-
- if (shaderVariable.value == -1)
- {
- PRINT("_GlShaderProgram::GetAttribLocation: Invalid location! [%s]\n", name);
- }
-
- __shaderVariableList.push_back(shaderVariable);
-
- return shaderVariable.value;
- }
- else
- {
- return (unsigned int)(*iter).value;
- }
-}
-*/
-/*
-int
-_GlShaderProgram::GetUniformLocation(const char* name)
-{
- int location = glGetUniformLocation(__program, name);
-
- if (location == -1)
- {
- PRINT("_GlShaderProgram::GetUniformLocation: Invalid location! [%s]\n", name);
- }
-
- return location;
-}
-*/
}}} // Tizen::Ui::Animations
namespace Tizen { namespace Ui { namespace Animations
{
class _GlContext;
-/*
-class ShaderVariable
-{
-public:
- ShaderVariable(void)
- : value(0)
- , name(null)
- {
- }
- ~ShaderVariable(void) {}
-
- bool operator==(const char* name)
- {
- if (strcmp(this->name, name) == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-public:
- int value;
- char* name;
-};
-*/
/**
* @enum ProgramLocation
*
_GlShaderProgram(unsigned int program = -1);
virtual ~_GlShaderProgram(void);
- //bool LoadShader(const char* pVertexShaderBin, int vertexLength, const char* pFragmentShaderBin, int fragmentLength);
int GetProgram(void) const { return __program; }
Variant GetUniform(const Tizen::Base::String& name) const;
int GetParameter(const ProgramLocation location) const; // Need it ?
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
+protected:
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;
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)
#include "FUiAnimShader.h" //tempo
#include <FGrpFloatMatrix4.h> //tempo
+#include <map>
+#include <list>
+
namespace Tizen { namespace Ui { namespace Animations {
using namespace _ImportCollada;
"}\n";
static const char fs_Test[] =
"precision mediump float;\n"
- "uniform vec4 u_materialambient;\n"
- //"uniform vec4 u_materialdiffuse;\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"
+ " vec3 col = u_materialdiffuse.xyz * max(0, dot(normalize(v_normal.xyz), vec3(0, 0, 1)));\n"
" gl_FragColor = vec4(col, 1);\n"
"}\n";
+static const char vs_TestTexture[] =
+ "uniform mat4 u_mvp;\n"
+ "uniform mat4 u_inv_modelview;\n"
+ "attribute vec4 a_position;\n"
+ "attribute vec4 a_normal;\n"
+ "attribute vec2 a_texcoord;\n"
+
+ "varying vec4 v_normal;\n"
+ "varying vec2 v_texcoord;\n"
+ "void main()\n"
+ "{\n"
+ " v_texcoord = a_texcoord;\n"
+ " v_normal = normalize(u_inv_modelview * a_normal);\n"
+ " gl_Position = u_mvp * a_position;\n"
+ "}\n";
+static const char fs_TestTexture[] =
+ "precision mediump float;\n"
+ "uniform sampler2D u_tex2d;\n"
+ "varying vec4 v_normal;\n"
+ "varying vec2 v_texcoord;\n"
+ "void main()\n"
+ "{\n"
+ " vec3 col = texture2D(u_tex2d, v_texcoord).xyz * max(0, dot(normalize(v_normal.xyz), vec3(0, 0, 1)));\n"
+ " gl_FragColor = vec4(col.zyx, 1);\n"
+ "}\n";
+
+struct Vertex{
+ FloatPoint3 pos;
+ FloatPoint3 norm;
+ FloatPoint texc;
+};
+
_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)
GeometryMesh::Indexes& curSurfaceTexCoordsIndices = surfaceInds->texCoordsInds;
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.");
+ pMesh->SetName(Tizen::Base::String(modelName.c_str()));
pMesh->SetGeometryType(Mesh::GEO_TYPE_TRIANGLES);
- pMesh->ReserveVertices(geometryMesh->GetVertexCount());
- pMesh->ReserveIndices(curSurfaceVertexIndices.size());
if (normals != null)
{
- pMesh->ReserveNormals();
- }
+ typedef std::map<unsigned int, unsigned int> UsedNormals;
+ typedef std::map<unsigned int, UsedNormals> UsedVertices;
+ UsedVertices used;
- if (texCoords != null)
- {
- pMesh->ReserveTextureCoordinates();
- }
+ std::list<Vertex> lVertices;
+ std::list<unsigned short> lIndices;
- 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)
+ for (unsigned int i = 0; i < curSurfaceVertexIndices.size(); i++)
{
- y = -y;
+ unsigned int vertIndex = curSurfaceVertexIndices[i];
+ unsigned int normIndex = curSurfaceNormalIndices[i];
+ unsigned int textIndex = 0;
+ if (texCoords != null)
+ {
+ textIndex = curSurfaceTexCoordsIndices[i];
+ }
+
+ UsedVertices::iterator usedVertex = used.find(vertIndex);
+ if ( usedVertex != used.end() )
+ {
+ UsedNormals::iterator usedNormal = usedVertex->second.find(normIndex);
+ if ( usedNormal != usedVertex->second.end() )
+ {
+ lIndices.push_back(usedNormal->second);
+ }
+ else
+ {
+ unsigned short newIndex = lVertices.size();
+ usedVertex->second.insert(std::make_pair(normIndex, newIndex));
+
+ Vertex vert;
+ vert.pos.x = vertices[vertIndex].x;
+ vert.pos.y = vertices[vertIndex].y;
+ vert.pos.z = vertices[vertIndex].z;
+
+ normals[normIndex].Normalize();
+ vert.norm.x = normals[normIndex].x;
+ vert.norm.y = normals[normIndex].y;
+ vert.norm.z = normals[normIndex].z;
+
+ if (texCoords != null)
+ {
+ vert.texc.x = texCoords[textIndex].x;
+ vert.texc.y = texCoords[textIndex].y;
+ }
+
+ lVertices.push_back(vert);
+ lIndices.push_back(newIndex);
+ }
+ }
+ else
+ {
+ UsedNormals usedNormals;
+ unsigned short newIndex = lVertices.size();
+ usedNormals.insert(std::make_pair(normIndex, newIndex));
+
+ used.insert(std::make_pair(vertIndex, usedNormals));
+
+ Vertex vert;
+ vert.pos.x = vertices[vertIndex].x;
+ vert.pos.y = vertices[vertIndex].y;
+ vert.pos.z = vertices[vertIndex].z;
+
+ normals[normIndex].Normalize();
+ vert.norm.x = normals[normIndex].x;
+ vert.norm.y = normals[normIndex].y;
+ vert.norm.z = normals[normIndex].z;
+
+ if (texCoords != null)
+ {
+ vert.texc.x = texCoords[textIndex].x;
+ vert.texc.y = texCoords[textIndex].y;
+ }
+
+ lVertices.push_back(vert);
+ lIndices.push_back(newIndex);
+ }
+
}
- pMesh->SetVertex(i, FloatPoint3(x, y, z));
- }
- // INDEX
+ pMesh->ReserveVertices(lVertices.size());
+ pMesh->ReserveIndices(lIndices.size());
+ pMesh->ReserveNormals();
+ if (texCoords != null)
+ {
+ pMesh->ReserveTextureCoordinates();
+ }
- for (unsigned int i = 0; i < curSurfaceVertexIndices.size(); i++)
- {
- unsigned int vertIndex = curSurfaceVertexIndices[i];
- pMesh->SetIndex(i, vertIndex);
- if (normals != null)
+ unsigned int index = 0;
+ for (std::list<Vertex>::iterator i = lVertices.begin(); i != lVertices.end(); i++)
{
- 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);
+ Vertex vert = *i;
+
+ if (inverseY)
+ {
+ vert.pos.y = -vert.pos.y;
+ }
+
+ pMesh->SetVertex(index, vert.pos);
+ pMesh->SetNormal(index, vert.norm);
+ if (texCoords != null)
+ {
+ pMesh->SetTextureCoord(index, vert.texc);
+ }
+ index++;
}
- if (texCoords != null)
+ index = 0;
+ for (std::list<unsigned short>::iterator i = lIndices.begin(); i != lIndices.end(); i++)
{
- unsigned int textIndex = curSurfaceTexCoordsIndices[i];
- float x = texCoords[textIndex].x;
- float y = texCoords[textIndex].y;
- pMesh->SetTextureCoord(vertIndex, FloatPoint(x, y));
+ unsigned short vertexIndex= *i;
+
+ pMesh->SetIndex(index, vertexIndex);
+ index++;
}
}
-
- for (int i = 0; i < pMesh->GetVertexCount(); i++)
+ else
{
- FloatPoint3 normal = pMesh->GetNormal(i);
- float d = sqrt(normal.x * normal.x + normal.y * normal.y + normal.z * normal.z);
- if (d > 0)
+ pMesh->ReserveVertices(geometryMesh->GetVertexCount());
+ pMesh->ReserveIndices(curSurfaceVertexIndices.size());
+
+ if (texCoords != null)
{
- normal = normal / d;
- pMesh->SetNormal(i, normal);
+ pMesh->ReserveTextureCoordinates();
+ }
+
+ 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));
+ }
+
+ // INDEX
+ for (unsigned int i = 0; i < curSurfaceVertexIndices.size(); i++)
+ {
+ unsigned int vertIndex = curSurfaceVertexIndices[i];
+ pMesh->SetIndex(i, vertIndex);
+
+ if (texCoords != null)
+ {
+ unsigned int textIndex = curSurfaceTexCoordsIndices[i];
+ float x = texCoords[textIndex].x;
+ float y = texCoords[textIndex].y;
+ pMesh->SetTextureCoord(vertIndex, FloatPoint(x, y));
+ }
}
}
+
return pMesh;
}
SysTryReturn(NID_UI_ANIM, pVisScene != null, null, E_OBJ_NOT_FOUND, "Scene '%s' not found.", sceneId.c_str());
Scene* pScene = new (std::nothrow) Scene();
+ pScene->Construct();
LibraryVisualScenes::Node* pNode = pVisScene->GetFirstNode();
WalkingTheTree(pNode, pScene, inverseY);
}
//===================================================================================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);
+ //if (textureId.compare("") == 0)
+ //{
+ // 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);
+ //}
+ //else
+ //{
+ // Shader vert;
+ // vert.Construct(Shader::SHADER_VERTEX, vs_TestTexture);
+ // Shader frag;
+ // frag.Construct(Shader::SHADER_FRAGMENT, fs_TestTexture);
+
+ // ShaderProgram *pProgram = new ShaderProgram();
+ // pProgram->Construct(vert,frag);
+ // pVisElem->SetShaderProgram(pProgram);
+ //}
pScene->AddMesh(pMesh);
#include "FUiAnim_VisualElementSharedData.h"
#include "FUiAnim_TransformMatrix3Df.h"
#include "FUiAnim_VisualElementCoordinateSystem.h"
+#include "FUiAnim_GlNode.h"
+#include "FGrpFloatMatrix4.h"
+#include "FGrpFloatPoint3.h"
+using namespace Tizen::Graphics;
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::MakeRayLocal(const _Ray globalRay, const _VisualElementImpl* pVEImpl)
+_Ray::MakeRayLocal(const _Ray globalRay, const FloatMatrix4& toTop)
{
//make from top matrix
- _Math::Matrix4 fromTop( &(pVEImpl->GetMatrixToTop().matrix[0][0]) );
-
+ //_Math::Matrix4 fromTop( &(pVEImpl->GetMatrixToTop().matrix[0][0]) );
+ _Math::Matrix4 fromTop(&(toTop.matrix[0][0]));
fromTop.Transpose();
fromTop.Inverse();
+ //_Math::Matrix4 fromTop( &(pVEImpl->GetMatrixFromTop().matrix[0][0]) );
+
+ //Transpose to convert into Matrix4
+ //fromTop.Transpose();
+ //Invert to convert from toTop to FfromTop
+ //fromTop.Inverse();
+
Position = fromTop * globalRay.Position;
//because Mat4 * vec3 treats vec3 as point
//make gloabl ray
Tizen::Graphics::FloatRectangle frame;
_Math::Matrix4 pvInv;
- _VisualElementImpl* pRootVe = pVEImpl->GetRoot();
+ //_VisualElementImpl* pRootVe = pVEImpl->GetRoot();
+ _VisualElementImpl* pRootVe = pVEImpl->GetRoot(); //test
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
_Math::Vector3 screenFar = ConvertScreenToWorld(_Math::Vector3(absPoint.x, absPoint.y, 1.0f), pvInv, frame);
Set(screenNear, screenFar - screenNear);
+
+ return *this;
}
bool
void print();
- _Ray& MakeRayLocal(const _Ray globalRay, const _VisualElementImpl* pVEImpl); //any VE in a tree
+ _Ray& MakeRayLocal(const _Ray globalRay, const Tizen::Graphics::FloatMatrix4& toTop);
_Ray& MakeRayGlobal(const _VisualElementImpl* pVEImpl, Tizen::Graphics::FloatPoint point);
bool CreatePVInv(const _VisualElementImpl* pRootVe, _Math::Matrix4& pvInv, Tizen::Graphics::FloatRectangle& frame);
, __meshes()
, __materials()
{
+}
+
+result
+_SceneImpl::Construct()
+{
__pRootVisualElement = new (std::nothrow) VisualElement();
__pRootVisualElement->Construct();
__pRootVisualElement->SetBounds(Tizen::Graphics::FloatRectangle(5, 5, 1, 1));
__pRootVisualElement->SetShowState(true);
__pRootVisualElement->SetImplicitAnimationEnabled(false);
+
+ return E_SUCCESS;
}
_SceneImpl::~_SceneImpl(void)
#include "FUiAnim_GlRenderManager.h"
#include "FUiAnim_TemplateUtil.h"
-
+#include <string>
+using namespace std;
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);
-
- //static _StringHashProvider stringHashProvider;
- //static _StringComparer stringComparer;
-
- //__locations.Construct(0, 0.f, stringHashProvider, stringComparer);
}
_ShaderProgramImpl::~_ShaderProgramImpl(void)
{
if (__program > 0)
{
- _GlRenderManager::GetInstance()->DeleteShaderProgram(this); // Need it ???
+ _GlRenderManager::GetInstance()->DeleteShaderProgram(this);
}
-
- //__locations.RemoveAll();
delete __pCustomShader;
}
return E_SUCCESS;
}
+result
+_ShaderProgramImpl::Construct(const Tizen::Base::String&vertexShader, const Tizen::Base::String& fragmentShader)
+{
+ std::wstring wStr(vertexShader.GetPointer());
+ std::string vertexShaderStr(wStr.begin(), wStr.end());
+
+ std::wstring wStr1(fragmentShader.GetPointer());
+ std::string fragmentShaderStr(wStr1.begin(), wStr1.end());
+ Shader vert;
+ vert.Construct(Shader::SHADER_VERTEX,vertexShaderStr.c_str());
+ Shader frag;
+ frag.Construct(Shader::SHADER_FRAGMENT,fragmentShaderStr.c_str());
+ __vertexShader = _ShaderImpl::GetInstance(vert)->__shaderId;
+ __fragmentShader = _ShaderImpl::GetInstance(frag)->__shaderId;
+ _GlRenderManager::GetInstance()->BuildShaderProgram(this);
+
+ SysTryReturnResult(NID_UI_ANIM, __program > 0, E_SYSTEM, "Failed to build shader 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 __pCustomShader->SetUniform(name, value);
}
+
_GlShaderProgram*
_ShaderProgramImpl::GetCusomShader()
{
return __pCustomShader;
}
-/*
-int
-_ShaderProgramImpl::GetAttribute(const ProgramLocation location)
-{
- return __pCustomShader->GetAttributes(location);
-}
-int
-_ShaderProgramImpl::GetUniform(const ProgramLocation location)
-{
- return __pCustomShader->GetUniforms(location);
-}
-
-
-result
-_ShaderProgramImpl::BindAttribute(ProgramLocation location, const Tizen::Base::String &name)
-{
- return __pCustomShader->BindAttribute(location,name);
-}
-
-
-result
-_ShaderProgramImpl::BindUniform(ProgramLocation location, const Tizen::Base::String &name)
-{
- return __pCustomShader->BindUniform(location,name);
-}
-
-bool
-_ShaderProgramImpl::IsParameterAvailable(const ProgramLocation location) const
-{
- return __pCustomShader->IsParameterAvailable(location);
-}
-
-bool
-_ShaderProgramImpl::IsParameterAvailable(const Tizen::Base::String& name) const
-{
- 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)
-{
- if (name == UniformMVP)
- {
- return __locationId[UNIFORM_MAT4_MVP];
- }
- else if (name == UniformColor)
- {
- return __locationId[ATTRIBUTE_VEC4_COLOR];
- }
-
- return 0;//GetLocation(UNIFORM_TYPE, name);
-}
-
-int
-_ShaderProgramImpl::GetAttribLocation(const Tizen::Base::String& name)
-{
- if (name == AttributePosition)
- {
- return __locationId[ATTRIBUTE_VEC4_POSITION];
- }
- else if (name == AttributeTexCoord)
- {
- return __locationId[ATTRIBUTE_VEC2_TEXTURE_COORD];
- }
- else if (name == AttributeColor)
- {
- return __locationId[ATTRIBUTE_VEC4_COLOR];
- }
-
- return 0;//GetLocation(ATTRIBUTE_TYPE, name);
-}
-*/
_ShaderProgramImpl*
_ShaderProgramImpl::GetInstance(ShaderProgram& program)
{
#include <FBaseString.h>
#include <FUiVariant.h>
#include <FBaseColHashMapT.h>
-//#include "FUiAnim_CustomShader.h"
#include "FUiAnim_GlShaderProgram.h"
#include <FUiAnimShaderProgram.h>
-
+#include "FUiAnim_RefObject.h"
namespace Tizen { namespace Ui { namespace Animations
{
class _ShaderProgramImpl
: public Tizen::Base::Object
+ , public RefObject
{
public:
- /*enum PROGRAM_LOCATION
- {
- UNIFORM_MVP = 0,
- UNIFORM_COLOR,
-// UNIFORM_TEXTURE,
- ATTRIBUTE_TEXTURE_COORD,
- ATTRIBUTE_POSITION,
- ATTRIBUTE_COLOR,
- // LIGHT_COLOR,
- PROGRAM_LOCATION_MAX
- };*/
-
-public:
_ShaderProgramImpl(void);
virtual ~_ShaderProgramImpl(void);
result Construct(Shader& vertexShader, Shader& fragmentShader);
+ result Construct(const Tizen::Base::String& vertexShader, const Tizen::Base::String& fragmentShader);
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);
_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;
-/*
- class LocationMapT : public Tizen::Base::Collection::HashMapT<Tizen::Base::String, int>
- {
- public:
- int GetLocation(const Tizen::Base::String& name) const
- {
- int location = 0;
-
- GetValue(name, location);
-
- return location;
- }
- };
-
- LocationMapT __locations;
-*/
- // request
struct _RequestItem // Need it ?
{
Tizen::Base::String name;
_GlShaderProgram* __pCustomShader;
_ShaderProgramImpl(const _ShaderProgramImpl& shader);
_ShaderProgramImpl& operator =(const _ShaderProgramImpl& rhs);
- //friend class _CustomShader;
};
bool CompareDistanceVA(const _VisualElementImpl::DistanceVA& dve1, const _VisualElementImpl::DistanceVA& dve2);
bool CompareIntersections(const DistToPoint& dp0, const DistToPoint& dp1);
+void
+printMatrix(const char* message, const float* m, bool isColumnOrder)
+{
+ AppLog("%s", message);
+ if (isColumnOrder)
+ for (int i = 0; i < 4; ++i)
+ AppLog("%.5f %.5f %.5f %.5f", m[i], m[4 + i], m[8 + i], m[12 + i]);
+ else
+ for (int i = 0; i < 4; ++i)
+ AppLog("%.5f %.5f %.5f %.5f", m[4 * i], m[4 * i + 1], m[4 * i + 2], m[4 * i + 3]);
+}
+
class _PlaneTriangle
{
public:
_VisualElementImpl::_VisualElementImpl(VisualElement& element)
: _zOrderGroup(Z_ORDER_GROUP_NORMAL)
, __globalRay(_Math::Vector3(0.0f),_Math::Vector3(0.0f))
+ , __boundingVolume()
, __hasGlobalRay(false)
, __nearestDistance(std::numeric_limits<float>::infinity())
, __pNearestVEImpl(null)
_VisualElementImpl::_VisualElementImpl(VisualElement& presentation, _VisualElementImpl& modelImpl)
: _zOrderGroup(modelImpl._zOrderGroup)
+ , __boundingVolume()
, __globalRay(_Math::Vector3(0.0f),_Math::Vector3(0.0f))
, __hasGlobalRay(false)
, __nearestDistance(std::numeric_limits<float>::infinity())
SysTryReturnResult(NID_UI_ANIM, child.__pSharedData, E_INVALID_ARG, "Child VisualElement is not constructed.");
SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
- return ChangeZOrder(child, null, true, child._zOrderGroup);
+ result r = ChangeZOrder(child, null, true, child._zOrderGroup);
+
+ //merge this and parent with new BV
+ static BoundingVolume converted;
+ converted = child.GetBoundingVolume();
+ converted.Transform(child.GetMatrixToSuper());
+ GetBoundingVolume().Merge(converted);
+ __MergeParentsBV();
+
+ return r;
}
int
zOrderGroup = pReference->_zOrderGroup;
}
- return ChangeZOrder(child, pReference, above, zOrderGroup);
+ result r = ChangeZOrder(child, pReference, above, zOrderGroup);
+
+ //merge this and parent with new BV
+ static BoundingVolume converted = child.GetBoundingVolume();
+ converted.Transform(child.GetMatrixToSuper());
+ GetBoundingVolume().Merge(converted);
+ __MergeParentsBV();
+
+ return r;
}
result
}
}
+ //minus element - rebuild Bounding Volume
+ AdjustBoundingVolume();
+
// TODO:
// DEALLOCATE !!!
//
{
//make gloabl ray
__globalRay.MakeRayGlobal(this,point);
+ __hasGlobalRay = true;
}
//hit VE mesh box?
//get toTop matrix
static BoundingVolume globalVolume;//(pMesh->GetBoundingVolume());
globalVolume = pMesh->GetBoundingVolume();
- globalVolume.Transform(GetMatrixToTop());
+
+ //GLNode - dravable so has an actual animated coordinates of drawed conext
+ _GlNode* pNode = dynamic_cast< _GlNode* >(this->GetNativeNode());
+ if(pNode != null)
+ {
+ globalVolume.Transform(pNode->__transform);
+ }
+ else
+ {
+ globalVolume.Transform(GetMatrixToTop());
+ }
+
+
+ //if(this->getaniaIsA)
+// if(this->GetName() == L"VE10")
+// {
+// printMatrix("GetTransformMatrix VEImpl", &(this->GetTransformMatrix().matrix[0][0]), true);
+// printMatrix("GetTransformMatrix VEImpl presentation", &(this->GetPresentation()->GetTransformMatrix().matrix[0][0]), true);
+// printMatrix("GetTransformMatrix VEImpl model", &(this->GetModel()->GetTransformMatrix().matrix[0][0]), true);
+//
+// printMatrix("GetMatrixToTop VEImpl", &(this->GetMatrixToTop().matrix[0][0]), true);
+// printMatrix("GetMatrixToTop VEImpl presentation", &(this->GetPresentation()->GetMatrixToTop().matrix[0][0]), true);
+// printMatrix("GetMatrixToTop VEImpl model", &(this->GetModel()->GetMatrixToTop().matrix[0][0]), true);
+//
+// _GlNode* pNode = dynamic_cast< _GlNode* >(this->GetNativeNode());
+// if (pNode != null)
+// {
+// printMatrix("pNode __transform VEImpl", &(pNode->__transform.matrix[0][0]), true);
+// }
+// pNode = dynamic_cast< _GlNode* >(this->GetPresentation()->GetNativeNode());
+// if (pNode != null)
+// {
+// printMatrix("pNode __transform VEImpl presentation", &(pNode->__transform.matrix[0][0]), true);
+// }
+// pNode = dynamic_cast< _GlNode* >(this->GetModel()->GetNativeNode());
+// if (pNode != null)
+// {
+// printMatrix("pNode __transform VEImpl model", &(pNode->__transform.matrix[0][0]), true);
+// }
+// }
+ //GetPresentation()->GetMatrixToTop()
+
+ //globalVolume.Transform(GetPresentation()->GetMatrixToTop()); //test
+
// _Math::Matrix4 toTop(&(GetMatrixToTop().matrix[0][0]));
//create local ray to intersect triangles in mesh
_Ray localRay;
- localRay.MakeRayLocal(__globalRay, this); //make local ray for mesh
+ localRay.MakeRayLocal(__globalRay, (pNode != null)?pNode->__transform:GetMatrixToTop()); //make local ray for mesh
if (!__SearchTriangleIntersection(localRay, pMesh, intesections, true)) //get all intersected triangle
{
FloatPoint hitPoint = point;
int hitTest;
+ //do not investigate this and children HitTests if does not hit into bounding volume of this VEImpl
+ //but animations can be provided so do not do this
+ if(false)
+ {
+ if(__hasGlobalRay == false) //VE have no local ray, create
+ {
+ //make gloabl ray
+ __globalRay.MakeRayGlobal(this,point);
+ __hasGlobalRay = true;
+ }
+
+ //hit VE mesh box?
+
+ //create global BoundingVolume
+ //get toTop matrix
+ static BoundingVolume globalVolume;//(pMesh->GetBoundingVolume());
+ globalVolume = GetBoundingVolume();
+
+ //GLNode - dravable so has an actual animated coordinates of drawed conext
+ _GlNode* pNode = dynamic_cast< _GlNode* >(this->GetNativeNode());
+ if(pNode != null)
+ {
+ globalVolume.Transform(pNode->__transform);
+ }
+ else
+ {
+ globalVolume.Transform(GetMatrixToTop());
+ }
+
+ std::pair<bool, float> intersect = __globalRay.Intersect(globalVolume);
+
+ if (!intersect.first) // box not intersected
+ {
+ return null;
+ }
+ }
+
+
hitTest = VE_DELEGATE(this, InvokeHitTest, point);
if ((hitTest & HITTEST_MATCH) != 0)
{
{
pMesh->AdjustBoundingVolume();
+ Mesh* pOldMesh = GetSharedData().geometry.GetMesh();
+
GetSharedData().geometry.SetMesh(pMesh);
+ //merge BV
+ if(pOldMesh != null)
+ {
+ //whole adjust if Mesh changes
+ AdjustBoundingVolume();
+ }
+ else
+ {
+ if(pMesh != null)
+ {
+ //Only merge new mesh if it is first
+ GetBoundingVolume().Merge(pMesh->GetBoundingVolume());
+ __MergeParentsBV();
+ }
+ }
+
+
return E_SUCCESS;
}
Mesh*
-_VisualElementImpl::GetMeshN(const String& name) const
+_VisualElementImpl::GetMeshN(void) const
{
Mesh* pMesh = GetSharedData().geometry.GetMesh();
}
Light*
-_VisualElementImpl::GetLightN(const Tizen::Base::String& name) const
+_VisualElementImpl::GetLightN(void) const
{
Light* pLight = GetSharedData().geometry.GetLight();
}
Material*
-_VisualElementImpl::GetMaterialN(const Tizen::Base::String& name) const
+_VisualElementImpl::GetMaterialN(void) const
{
Material* pMaterial = GetSharedData().geometry.GetMaterial();
return dve1.first < dve2.first;
}
-
-void
-printMatrix(const char* message, const float* m, bool isColumnOrder)
-{
- AppLog("%s", message);
- if (isColumnOrder)
- for (int i = 0; i < 4; ++i)
- AppLog("%.5f %.5f %.5f %.5f", m[i], m[4 + i], m[8 + i], m[12 + i]);
- else
- for (int i = 0; i < 4; ++i)
- AppLog("%.5f %.5f %.5f %.5f", m[4 * i], m[4 * i + 1], m[4 * i + 2], m[4 * i + 3]);
-}
-
//used for algorithm description
//remove when all Picking methods implementing
/*
return (!intersections.empty());
}
+
+void
+_VisualElementImpl::__AdjustBVWithChildren()
+{
+ GetBoundingVolume().Reset();
+
+ int count = __children.GetCount();
+ _VisualElementImpl* pChild;
+ static BoundingVolume converted;
+ //Mesh BV add
+ Mesh* pMesh = GetSharedData().geometry.GetMesh();
+ if(pMesh != null)
+ {
+ GetBoundingVolume().Merge(pMesh->GetBoundingVolume());
+ }
+ //children BV add
+ for (int i = 0 ; i < count ; i++)
+ {
+ pChild = __children.GetChildAt(i);
+ if(pChild)// if(pChild && (pChild->__invalidatedProps || pChild->__updatedProperties)
+ {
+ converted = pChild->GetBoundingVolume();
+ converted.Transform(pChild->GetMatrixToSuper());
+ GetBoundingVolume().Merge(converted);
+ }
+ }
+}
+
+void
+_VisualElementImpl::__AdjustParentsBV()
+{
+ _VisualElementImpl* pVEImplParent = this->GetParent();
+ _VisualElementImpl* pVEImplChild = this;
+ static BoundingVolume converted;
+
+ while(pVEImplParent != null && pVEImplParent != pVEImplChild)
+ {
+ pVEImplParent->GetBoundingVolume().Reset();
+ //Mesh BV add
+ Mesh* pMesh = pVEImplParent->GetSharedData().geometry.GetMesh();
+ if(pMesh != null)
+ {
+ pVEImplParent->GetBoundingVolume().Merge(pMesh->GetBoundingVolume());
+ }
+ //Children BV add
+ int count = pVEImplParent->__children.GetCount();
+ _VisualElementImpl* pChild;
+ for (int i = 0 ; i < count ; i++)
+ {
+ pChild = pVEImplParent->__children.GetChildAt(i);
+ if(pChild)// if(pChild && (pChild->__invalidatedProps || pChild->__updatedProperties)
+ {
+ converted = pChild->GetBoundingVolume();
+ converted.Transform(pChild->GetMatrixToSuper());
+ pVEImplParent->GetBoundingVolume().Merge(converted);
+ }
+ }
+
+ pVEImplChild = pVEImplParent;
+ pVEImplParent = this->GetParent();
+ }
+}
+
+void
+_VisualElementImpl::__MergeParentsBV()
+{
+ _VisualElementImpl* pVEImplParent = this->GetParent();
+ _VisualElementImpl* pVEImplChild = this;
+ static BoundingVolume converted;
+ while(pVEImplParent != null && pVEImplParent != pVEImplChild)
+ {
+ converted = pVEImplChild->GetBoundingVolume();
+ converted.Transform(pVEImplChild->GetMatrixToSuper());
+ pVEImplParent->GetBoundingVolume().Merge(converted);
+
+ pVEImplChild = pVEImplParent;
+ pVEImplParent = this->GetParent();
+ }
+}
+
+result
+_VisualElementImpl::AdjustBoundingVolume()
+{
+ result r = E_SUCCESS;
+
+ __AdjustBVWithChildren();
+ __AdjustParentsBV();
+
+ return r;
+}
+
+BoundingVolume&
+_VisualElementImpl::GetBoundingVolume()
+{
+ return __boundingVolume;
+}
// delegate---------------------------------------------------------------------------------
void
static const float t0(0.0f);
float s = Determinant();
- //if(Equal(s, t0))
- if(s == 0) //do not work othervise
+ //if (Equal(s, t0, 0.0f))
+ if(s == 0.0f)
{
return *this;
}
static const float t0(0.0f);
float s = Determinant();
- if(Equal(s, t0))
+ //if(Equal(s, t0))
+ if(s == 0.0f)
{
return *this;
}
/**
* Constructs instance of Light
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] name of constructed light
*/
/**
* Destructs instance of Scene
*
- * @since 2.0
+ * @since 3.0
*/
virtual ~_LightImpl(void);
/**
* Sets light type.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] lightType New light type.
* @see GetLightType().
/**
* Gets light type.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light type.
* @see SetLightType().
/**
* Sets light color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] color New light color.
* @see GetColor().
/**
* Sets light color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] r Color red component.
* @param[in] g Color green component.
/**
* Sets light color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] colour New light color.
* @see GetColour().
/**
* Gets light color.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light color.
* @see SetColour().
/**
* Sets light ambient color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] color New light ambient color.
* @see GetAmbient().
/**
* Gets light ambient.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light ambient.
* @see SetAmbient().
/**
* Sets light diffuse color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] color New light diffuse color.
* @see GetDiffuse().
/**
* Gets light diffuse.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light diffuse.
* @see SetDiffuse().
/**
* Sets light specular color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] color New light specular color.
* @see GetSpecular().
/**
* Sets light intensity color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] color New light intensity color.
* @see GetIntensity().
/**
* Gets light intensity.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light intensity.
* @see SetIntensity().
/**
* Sets light spot exponent.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] exponent New light spot exponent.
* @see GetSpotExponent().
/**
* Gets light spot exponent.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light spot exponent.
* @see SetSpotExponent().
/**
* Sets light constant attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] attenuation New light constant attenuation.
* @see GetConstantAttenuation().
/**
* Gets light constant attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light constant attenuation.
* @see SetConstantAttenuation().
/**
* Sets light linear attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] attenuation New light linear attenuation.
* @see GetLinearAttenuation().
/**
* Gets light linear attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light linear attenuation.
* @see SetLinearAttenuation().
/**
* Sets light quadratic attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] attenuation New light quadratic attenuation.
* @see GetQuadraticAttenuation().
/**
* Gets light quadratic attenuation.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light quadratic attenuation.
* @see SetQuadraticAttenuation().
/**
* Sets light direction.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] direction New light direction.
* @see GetDirection().
/**
* Sets light direction.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] x Direction x component.
* @param[in] y Direction y component.
/**
* Gets light direction.
*
- * @since 2.0
+ * @since 3.0
*
* @return light direction.
* @see SetDirection().
/**
* Sets light radius.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] radius New light radius.
* @see GetRadius().
/**
* Gets light radius.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light radius.
* @see SetQuadraticAttenuation().
/**
* Sets light position.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] pos New light position.
* @see GetPosition().
/**
* Sets light position.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] x Light position x component.
* @param[in] y Light position y component.
/**
* Gets light position.
*
- * @since 2.0
+ * @since 3.0
*
* @return Light position.
* @see SetPosition().
/**
* Get material name.
*
- * @since 2.0
+ * @since 3.0
*
* @return Name of the material.
* @see SetName().
/**
* Set Material name.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] name Material new name.
* @see GetName().
/**
* Get material ambient color.
*
- * @since 2.0
+ * @since 3.0
*
* @return Ambient color of the material.
* @see SetAmbient().
/**
* Set Material ambient color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value Material new ambient color value.
* @see GetAmbient().
/**
* Get material diffuse color.
*
- * @since 2.0
+ * @since 3.0
*
* @return Diffuse color of the material.
* @see SetDiffuse().
/**
* Set Material diffuse color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value MateMaterialDescriptionrial new diffuse color value.
* @see GetDiffuse().
/**
* Get material specular color.
*
- * @since 2.0
+ * @since 3.0
*
* @return Specular color of the material.
* @see SetSpecular().
/**
* Set Material specular color
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value MateriaMaterialDescriptionl new specular color value.
* @see GetSpecular().
/**
* Get material emissive color.
*
- * @since 2.0
+ * @since 3.0
*
* @return Emmisive color of the material.
* @see SetEmissive().
/**
* Set material emissive color.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value Material new emissive color value.
* @see GetEmissive().
/**
* Get material emissive power
*
- * @since 2.0
+ * @since 3.0
*
* @return Emissive power of the material.
* @see SetEmissivePower().
/**
* Set material specular power
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value Material new specular power value.
* @see GetSpecularPower().
/**
* Get material alpha test ref.
*
- * @since 2.0
+ * @since 3.0
*
* @return Alpha test ref of the material.
* @see SetAlphaTestRef().
/**
* Set material alpha test ref.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value Material new alpha test ref value.
* @see GetAlphaTestRef().
/**
* Get material transparent
*
- * @since 2.0
+ * @since 3.0
*
* @return Transparent of the material.
* @see SetTransparent().
/**
* Set material transparent
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value Material new transparent value.
* @see GetTransparent().
/**
* Get material ZWrite.
*
- * @since 2.0
+ * @since 3.0
*
* @return ZWrite of the material.
* @see SetZWrite
/**
* Set material ZWrite.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value Material new ZWrite value.
* @see GetZWrite
/**
* Get material alpha test.
*
- * @since 2.0
+ * @since 3.0
*
* @return Alpha test of the material.
* @see SetAlphaTest().
/**
* Set material alpha test.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value Material new alpha test value.
* @see GetAlphaTest().
/**
* Get material ZBuffer.
*
- * @since 2.0
+ * @since 3.0
*
* @return ZBuffer of the material,
* @see SetZBuffer().
/**
* Set material ZBuffer.
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value Material new ZBuffer value.
* @see GetZBuffer().
/**
* Get material opacity.
*
- * @since 2.0
+ * @since 3.0
*
* @return Opacity of the material.
* @see SetOpacity().
/**
* Set material opacity
*
- * @since 2.0
+ * @since 3.0
*
* @param[in] value Material new opacity value.
* @see GetOpacity().
{
return (__pNormals)?true:false;
}
- bool IsSurfaceClosed();
+
void SetName(std::string name)
_SceneImpl(void);
virtual ~_SceneImpl(void);
+ result Construct();
VisualElement* GetRootVisualElement(void) const;
_IVisualElementCaptureProvider* GetCaptureProvider(void) const;
result SetMesh(Mesh* pMesh);
- Mesh* GetMeshN(const Tizen::Base::String& name) const;
+ Mesh* GetMeshN(void) const;
result SetLight(Light* pLight);
- Light* GetLightN(const Tizen::Base::String& name) const;
+ Light* GetLightN(void) const;
result SetMaterial(Material* pMaterial);
- Material* GetMaterialN(const Tizen::Base::String& name) const;
+ Material* GetMaterialN(void) const;
result SetShaderProgram(ShaderProgram* pShaderProgram);
ShaderProgram* GetShaderProgram(void) const;
bool CreateImplicitAnimationForShowState(float newState, float currentState, bool bImplicitAnimation);
bool CreateImplicitAnimationIfNeeded(const Tizen::Base::String& property, const Variant& newValue, const Variant& currentPresntationValue, const Tizen::Base::String** pSubProperties, bool isCustomProperty = false);
+ //Visual Element Bounding volume related
+ result AdjustBoundingVolume();
+ BoundingVolume& GetBoundingVolume();
+
public:
enum
{
typedef DistanceVAs::iterator DistanceVAsIt;
//_VisualElementImpl* PickVA(int screenX, int screenY); //until all picking interface implementing, algorithm description related
-
private:
+ //Visual Element Bounding volume related
+ void __AdjustBVWithChildren();
+ void __AdjustParentsBV();
+ void __MergeParentsBV();
+
+
//picking related methods and variables
//void __MakeRayIntersection(const _Ray& ray, DistanceVAs& intersected); //until all picking interface implementing,algorithm description related
bool __SearchTriangleIntersection(const _Ray& localRay, const Mesh* mesh, Intersections& intersections, bool seachAllIntersections);
_Math::Vector3 __ConvertScreenToWorld(const _Math::Vector3& screen, const _Math::Matrix4& pvInv, const Tizen::Graphics::FloatRectangle& frame);
+ //Visual Element Bounding volume related
+ BoundingVolume __boundingVolume;
+
_Ray __globalRay;
bool __hasGlobalRay;
float __nearestDistance;