-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
// CLASS HEADER
#include <dali/internal/event/common/projection.h>
#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/matrix.h>
#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/viewport.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/math/math-utils.h>
namespace Dali
{
return true;
}
+bool ProjectFull( const Vector4& position,
+ const Matrix& modelView,
+ const Matrix& projection,
+ float viewportX,
+ float viewportY,
+ float viewportWidth,
+ float viewportHeight,
+ Vector4& windowPos )
+{
+ bool ok = false;
+
+ Matrix Mvp( false ); // Don't initialize.
+ Matrix::Multiply( Mvp, modelView, projection );
+
+ Vector4 p = Mvp * position;
+
+ Vector2 depthRange(0,1);
+
+ if( !EqualsZero( p.w ) )
+ {
+ float div = 1.0 / p.w;
+
+ windowPos = Vector4( (1 + p.x * div) * viewportWidth / 2 + viewportX,
+ (1 - p.y * div) * viewportHeight / 2 + viewportY,
+ (p.z * div) * (depthRange.y - depthRange.x) + depthRange.x,
+ div);
+ ok = true;
+ }
+
+ return ok;
+}
+
+
} // namespace Internal
} // namespace Dali