This removes a lot of code and will make it easier to migrate into a new library with Java bindings, etc. - The clipping planes and projection matrix were unused, removed them. - In split view mode, our demos were using only 2 of the 3 manipulators, removed one. - Instead of callbacks and update methods, users can simply ask for the current matrix at every frame. - The manipulator's job is to consume mouse events and maintain an "look at" basis, there is no need to store a reference to a Filament Camera.
50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
/*
|
|
* Copyright (C) 2015 The Android Open Source Project
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef TNT_FILAMENT_SAMPLE_CAMERA_MANIPULATOR_H
|
|
#define TNT_FILAMENT_SAMPLE_CAMERA_MANIPULATOR_H
|
|
|
|
#include <math/vec2.h>
|
|
#include <math/vec3.h>
|
|
#include <math/vec4.h>
|
|
#include <math/mat4.h>
|
|
|
|
class CameraManipulator {
|
|
public:
|
|
CameraManipulator();
|
|
CameraManipulator(size_t width, size_t height);
|
|
|
|
void setViewport(size_t w, size_t h);
|
|
|
|
void lookAt(const filament::math::double3& eye, const filament::math::double3& at);
|
|
void track(const filament::math::double2& delta);
|
|
void dolly(double delta, double dollySpeed = 5.0);
|
|
void rotate(const filament::math::double2& delta, double rotateSpeed = 7.0);
|
|
|
|
filament::math::mat4f getCameraTransform() const;
|
|
|
|
private:
|
|
filament::math::double3 mRotation;
|
|
filament::math::double3 mTranslation;
|
|
|
|
double mCenterOfInterest = 10.0;
|
|
double mFovx = 65.0;
|
|
size_t mWidth;
|
|
size_t mHeight;
|
|
};
|
|
|
|
#endif // TNT_FILAMENT_SAMPLE_CAMERA_MANIPULATOR_H
|