forked from Hartmut/paradiso
75 lines
No EOL
2.6 KiB
C++
75 lines
No EOL
2.6 KiB
C++
/*
|
|
* Copyright 2023 Hartmut Seichter
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
*/
|
|
#ifndef PARADISO_SPRITE_HPP
|
|
#define PARADISO_SPRITE_HPP
|
|
|
|
#include <paradiso/bitmap.hpp>
|
|
#include <paradiso/globals.hpp>
|
|
#include <paradiso/matrix.hpp>
|
|
#include <paradiso/vector.hpp>
|
|
|
|
namespace paradiso {
|
|
|
|
/**
|
|
* @brief simple sprite handler
|
|
*/
|
|
struct Sprite final {
|
|
using ChangeCountType = std::uint64_t;
|
|
|
|
Bitmap bitmap{}; //!< associated bitmap
|
|
|
|
Vector2<float> pivot{Vector2<float>::zero()}; //!< center point
|
|
Vector2<float> scale{Vector2<float>::all(1)}; //!< scale
|
|
float rotation{0.0f}; //!< rotation
|
|
|
|
// 0 3 | y
|
|
// +------+ | ^
|
|
// | \ | | -- + - > x
|
|
// | \ | | / |
|
|
// +------+ | z
|
|
// 1 2 |
|
|
|
|
std::array<std::uint32_t, 6> indices{0, 1, 2, 0, 2, 3}; //!< topology
|
|
|
|
std::array<Vector3<float>, 4> vertices{
|
|
//!< geometry
|
|
Vector3<float>::make(-1.0f, +1.0f, 0.0f),
|
|
Vector3<float>::make(-1.0f, -1.0f, 0.0f),
|
|
Vector3<float>::make(+1.0f, -1.0f, 0.0f),
|
|
Vector3<float>::make(+1.0f, +1.0f, 0.0f)};
|
|
|
|
std::array<Vector3<float>, 4> normals{
|
|
//!< normals
|
|
Vector3<float>::z_axis(), Vector3<float>::z_axis(),
|
|
Vector3<float>::z_axis(), Vector3<float>::z_axis()};
|
|
|
|
std::array<Vector2<float>, 4> texture_coordinates{
|
|
//!< UV coordinates
|
|
Vector2<float>::make(0.0f, 0.0f), Vector2<float>::make(1.0f, 0.0f),
|
|
Vector2<float>::make(1.0f, 1.0f), Vector2<float>::make(0.0f, 1.0f)};
|
|
|
|
ChangeCountType change_count{}; //!< cookie to track changes
|
|
};
|
|
} // namespace paradiso
|
|
|
|
#endif |