mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 01:19:19 +02:00
build 180708. model instance position and rotation adjustment in scenery editor, support for event launcher activation with mouse click, minor refactoring
This commit is contained in:
73
sceneeditor.h
Normal file
73
sceneeditor.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "scenenode.h"
|
||||
|
||||
namespace scene {
|
||||
|
||||
class basic_editor {
|
||||
|
||||
public:
|
||||
// methods
|
||||
bool
|
||||
on_mouse_button( int const Button, int const Action );
|
||||
bool
|
||||
on_mouse_move( double const Mousex, double const Mousey );
|
||||
scene::basic_node const *
|
||||
node() const {
|
||||
return m_node; }
|
||||
private:
|
||||
// types
|
||||
struct node_snapshot {
|
||||
|
||||
scene::basic_node *node;
|
||||
std::string data;
|
||||
|
||||
node_snapshot( scene::basic_node *Node ) :
|
||||
node( Node ) {
|
||||
if( Node != nullptr ) {
|
||||
Node->export_as_text( data ); } };
|
||||
};
|
||||
friend bool operator==( basic_editor::node_snapshot const &Left, basic_editor::node_snapshot const &Right );
|
||||
friend bool operator!=( basic_editor::node_snapshot const &Left, basic_editor::node_snapshot const &Right );
|
||||
// methods
|
||||
bool
|
||||
mode_translation() const;
|
||||
bool
|
||||
mode_translation_vertical() const;
|
||||
void
|
||||
translate( glm::dvec3 const &Location );
|
||||
void
|
||||
translate( float const Offset );
|
||||
void
|
||||
translate_instance( TAnimModel *Instance, glm::dvec3 const &Location );
|
||||
void
|
||||
translate_instance( TAnimModel *Instance, float const Offset );
|
||||
void
|
||||
rotate( glm::vec3 const &Angle );
|
||||
void
|
||||
rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle );
|
||||
// members
|
||||
scene::basic_node *m_node; // temporary helper, currently selected scene node
|
||||
node_snapshot m_nodesnapshot { nullptr }; // currently selected scene node in its pre-modified state
|
||||
glm::dvec2 m_mouseposition { 0.0 };
|
||||
bool m_mouseleftbuttondown { false };
|
||||
|
||||
};
|
||||
|
||||
inline bool operator==( basic_editor::node_snapshot const &Left, basic_editor::node_snapshot const &Right ) { return ( ( Left.node == Right.node ) && ( Left.data == Right.data ) ); }
|
||||
inline bool operator!=( basic_editor::node_snapshot const &Left, basic_editor::node_snapshot const &Right ) { return ( !( Left == Right ) ); }
|
||||
|
||||
extern basic_editor Editor;
|
||||
|
||||
} // scene
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user