#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali/devel-api/actors/mesh-actor.h>
+#include <dali/devel-api/modeling/material.h>
+#include <dali/devel-api/geometry/mesh.h>
+
#include "shared/view.h"
#include <fstream>
#include <sstream>
+#include <limits>
using namespace Dali;
{
}
- Vector2 operator()( const Vector2& current, const PropertyInput& spinAngleProperty)
+ void operator()( Vector2& current, const PropertyInputContainer& inputs )
{
- float spinAngle = spinAngleProperty.GetFloat();
- return Vector2( cos(spinAngle ), sin( spinAngle ) ) * mRadius;
+ float spinAngle = inputs[0]->GetFloat();
+ current.x = cos( spinAngle );
+ current.y = sin( spinAngle );
+
+ current *= mRadius;
}
float mRadius;
};
+/**
+ * @brief Load an image, scaled-down to no more than the stage dimensions.
+ *
+ * Uses image scaling mode SCALE_TO_FILL to resize the image at
+ * load time to cover the entire stage with pixels with no borders,
+ * and filter mode BOX_THEN_LINEAR to sample the image with maximum quality.
+ */
+ResourceImage LoadStageFillingImage( const char * const imagePath )
+{
+ Size stageSize = Stage::GetCurrent().GetSize();
+ return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
+}
+
} // namespace
/************************************************************************************************
handle.SetUniform( "uLightIntensity", 2.5f );
Dali::Property::Index index = handle.RegisterProperty( "uSpinAngle", 0.f );
- Constraint constraint = Constraint::New<Vector2>( handle.GetPropertyIndex("uLightSpinOffset"),
- LocalSource(index),
- LightOffsetConstraint(stageSize.x*0.1f));
- handle.ApplyConstraint( constraint );
+ Constraint constraint = Constraint::New<Vector2>( handle, handle.GetPropertyIndex("uLightSpinOffset"), LightOffsetConstraint(stageSize.x*0.1f) );
+ constraint.AddSource( LocalSource(index) );
+ constraint.Apply();
return handle;
}
// Creates a default view with a default tool bar.
// The view is added to the stage.
Toolkit::ToolBar toolBar;
- Toolkit::View view;
+ Toolkit::Control view;
mContent = DemoHelper::CreateView( application,
view,
toolBar,
mNoEffect = NoEffect::New(); // used in the other situations, basic render shader
// Create the mesh from the obj file and add to stage
mMaterial = Material::New( "Material" ) ;
- mMaterial.SetDiffuseTexture(ResourceImage::New(TEXTURE_IMAGES[mCurrentTextureId]));
+ mMaterial.SetDiffuseTexture( LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] ) );
CreateSurface( MESH_FILES[mCurrentMeshId] );
// Connect the callback to the touch signal on the mesh actor
bool OnChangeTexture( Toolkit::Button button )
{
mCurrentTextureId = ( mCurrentTextureId + 1 ) % NUM_TEXTURE_IMAGES;
- mMaterial.SetDiffuseTexture(ResourceImage::New(TEXTURE_IMAGES[mCurrentTextureId]));
+ mMaterial.SetDiffuseTexture( LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] ) );
return true;
}
int
main(int argc, char **argv)
{
- Application app = Application::New(&argc, &argv);
+ Application app = Application::New(&argc, &argv, DALI_DEMO_THEME_PATH);
RunTest(app);