mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 05:49:19 +02:00
Merge branch 'tmj-dev' into lua
This commit is contained in:
223
scenenode.h
223
scenenode.h
@@ -22,6 +22,13 @@ struct lighting_data {
|
||||
glm::vec4 diffuse { 0.8f, 0.8f, 0.8f, 1.0f };
|
||||
glm::vec4 ambient { 0.2f, 0.2f, 0.2f, 1.0f };
|
||||
glm::vec4 specular { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
// stores content of the struct in provided output stream
|
||||
void
|
||||
serialize( std::ostream &Output ) const;
|
||||
// restores content of the struct from provided input stream
|
||||
void
|
||||
deserialize( std::istream &Input );
|
||||
};
|
||||
|
||||
inline
|
||||
@@ -29,12 +36,14 @@ bool
|
||||
operator==( lighting_data const &Left, lighting_data const &Right ) {
|
||||
return ( ( Left.diffuse == Right.diffuse )
|
||||
&& ( Left.ambient == Right.ambient )
|
||||
&& ( Left.specular == Right.specular ) ); }
|
||||
&& ( Left.specular == Right.specular ) );
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
operator!=( lighting_data const &Left, lighting_data const &Right ) {
|
||||
return !( Left == Right ); }
|
||||
return !( Left == Right );
|
||||
}
|
||||
|
||||
namespace scene {
|
||||
|
||||
@@ -48,27 +57,13 @@ struct bounding_area {
|
||||
center( Center ),
|
||||
radius( Radius )
|
||||
{}
|
||||
// stores content of the struct in provided output stream
|
||||
void
|
||||
serialize( std::ostream &Output ) const;
|
||||
// restores content of the struct from provided input stream
|
||||
void
|
||||
deserialize( std::istream &Input );
|
||||
};
|
||||
/*
|
||||
enum nodetype {
|
||||
|
||||
unknown,
|
||||
model,
|
||||
triangles,
|
||||
lines,
|
||||
dynamic,
|
||||
track,
|
||||
traction,
|
||||
powersource,
|
||||
sound,
|
||||
memorycell,
|
||||
eventlauncher
|
||||
};
|
||||
|
||||
class node_manager {
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
struct node_data {
|
||||
|
||||
@@ -86,23 +81,37 @@ class shape_node {
|
||||
public:
|
||||
// types
|
||||
struct shapenode_data {
|
||||
// members:
|
||||
// placement and visibility
|
||||
scene::bounding_area area; // bounding area, in world coordinates
|
||||
bool visible { true }; // visibility flag
|
||||
double rangesquared_min { 0.0 }; // visibility range, min
|
||||
double rangesquared_max { 0.0 }; // visibility range, max
|
||||
bool visible { true }; // visibility flag
|
||||
// material data
|
||||
material_handle material { 0 };
|
||||
lighting_data lighting;
|
||||
bool translucent { false }; // whether opaque or translucent
|
||||
material_handle material { null_handle };
|
||||
lighting_data lighting;
|
||||
// geometry data
|
||||
std::vector<world_vertex> vertices; // world space source data of the geometry
|
||||
glm::dvec3 origin; // world position of the relative coordinate system origin
|
||||
geometry_handle geometry { 0, 0 }; // relative origin-centered chunk of geometry held by gfx renderer
|
||||
std::vector<world_vertex> vertices; // world space source data of the geometry
|
||||
// methods:
|
||||
// sends content of the struct to provided stream
|
||||
void
|
||||
serialize( std::ostream &Output ) const;
|
||||
// restores content of the struct from provided input stream
|
||||
void
|
||||
deserialize( std::istream &Input );
|
||||
};
|
||||
|
||||
// methods
|
||||
// restores content of the node from provded input stream
|
||||
// sends content of the class to provided stream
|
||||
void
|
||||
serialize( std::ostream &Output ) const;
|
||||
// restores content of the node from provided input stream
|
||||
shape_node &
|
||||
deserialize( std::istream &Input );
|
||||
// restores content of the node from provided input stream
|
||||
shape_node &
|
||||
deserialize( cParser &Input, scene::node_data const &Nodedata );
|
||||
// imports data from provided submodel
|
||||
@@ -119,16 +128,13 @@ public:
|
||||
compute_radius();
|
||||
// set visibility
|
||||
void
|
||||
visible( bool State ) {
|
||||
m_data.visible = State; }
|
||||
visible( bool State );
|
||||
// set origin point
|
||||
void
|
||||
origin( glm::dvec3 Origin ) {
|
||||
m_data.origin = Origin; }
|
||||
origin( glm::dvec3 Origin );
|
||||
// data access
|
||||
shapenode_data const &
|
||||
data() const {
|
||||
return m_data; }
|
||||
data() const;
|
||||
|
||||
private:
|
||||
// members
|
||||
@@ -136,6 +142,27 @@ private:
|
||||
shapenode_data m_data;
|
||||
};
|
||||
|
||||
// set visibility
|
||||
inline
|
||||
void
|
||||
shape_node::visible( bool State ) {
|
||||
m_data.visible = State;
|
||||
}
|
||||
// set origin point
|
||||
inline
|
||||
void
|
||||
shape_node::origin( glm::dvec3 Origin ) {
|
||||
m_data.origin = Origin;
|
||||
}
|
||||
// data access
|
||||
inline
|
||||
shape_node::shapenode_data const &
|
||||
shape_node::data() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// holds a group of untextured lines
|
||||
class lines_node {
|
||||
|
||||
@@ -144,22 +171,36 @@ class lines_node {
|
||||
public:
|
||||
// types
|
||||
struct linesnode_data {
|
||||
// members:
|
||||
// placement and visibility
|
||||
scene::bounding_area area; // bounding area, in world coordinates
|
||||
bool visible { true }; // visibility flag
|
||||
double rangesquared_min { 0.0 }; // visibility range, min
|
||||
double rangesquared_max { 0.0 }; // visibility range, max
|
||||
bool visible { true }; // visibility flag
|
||||
// material data
|
||||
float line_width { 1.f }; // thickness of stored lines
|
||||
lighting_data lighting;
|
||||
float line_width; // thickness of stored lines
|
||||
// geometry data
|
||||
std::vector<world_vertex> vertices; // world space source data of the geometry
|
||||
glm::dvec3 origin; // world position of the relative coordinate system origin
|
||||
geometry_handle geometry { 0, 0 }; // relative origin-centered chunk of geometry held by gfx renderer
|
||||
std::vector<world_vertex> vertices; // world space source data of the geometry
|
||||
// methods:
|
||||
// sends content of the struct to provided stream
|
||||
void
|
||||
serialize( std::ostream &Output ) const;
|
||||
// restores content of the struct from provided input stream
|
||||
void
|
||||
deserialize( std::istream &Input );
|
||||
};
|
||||
|
||||
// methods
|
||||
// restores content of the node from provded input stream
|
||||
// sends content of the class to provided stream
|
||||
void
|
||||
serialize( std::ostream &Output ) const;
|
||||
// restores content of the node from provided input stream
|
||||
lines_node &
|
||||
deserialize( std::istream &Input );
|
||||
// restores content of the node from provided input stream
|
||||
lines_node &
|
||||
deserialize( cParser &Input, scene::node_data const &Nodedata );
|
||||
// adds content of provided node to already enclosed geometry. returns: true if merge could be performed
|
||||
@@ -173,16 +214,13 @@ public:
|
||||
compute_radius();
|
||||
// set visibility
|
||||
void
|
||||
visible( bool State ) {
|
||||
m_data.visible = State; }
|
||||
visible( bool State );
|
||||
// set origin point
|
||||
void
|
||||
origin( glm::dvec3 Origin ) {
|
||||
m_data.origin = Origin; }
|
||||
origin( glm::dvec3 Origin );
|
||||
// data access
|
||||
linesnode_data const &
|
||||
data() const {
|
||||
return m_data; }
|
||||
data() const;
|
||||
|
||||
private:
|
||||
// members
|
||||
@@ -190,6 +228,26 @@ private:
|
||||
linesnode_data m_data;
|
||||
};
|
||||
|
||||
// set visibility
|
||||
inline
|
||||
void
|
||||
lines_node::visible( bool State ) {
|
||||
m_data.visible = State;
|
||||
}
|
||||
// set origin point
|
||||
inline
|
||||
void
|
||||
lines_node::origin( glm::dvec3 Origin ) {
|
||||
m_data.origin = Origin;
|
||||
}
|
||||
// data access
|
||||
inline
|
||||
lines_node::linesnode_data const &
|
||||
lines_node::data() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// holds geometry for specific piece of track/road/waterway
|
||||
class path_node {
|
||||
@@ -238,39 +296,10 @@ private:
|
||||
TTrack * m_path;
|
||||
};
|
||||
*/
|
||||
/*
|
||||
// holds reference to memory cell
|
||||
class memorycell_node {
|
||||
|
||||
friend class basic_region; // region might want to modify node content when it's being inserted
|
||||
|
||||
public:
|
||||
// types
|
||||
struct memorynode_data {
|
||||
// placement and visibility
|
||||
bounding_area area; // bounding area, in world coordinates
|
||||
bool visible { false }; // visibility flag
|
||||
};
|
||||
// methods
|
||||
// restores content of the node from provded input stream
|
||||
// TODO: implement
|
||||
memory_node &
|
||||
deserialize( cParser &Input, node_data const &Nodedata );
|
||||
void
|
||||
cell( TMemCell *Cell ) {
|
||||
m_memorycell = Cell; }
|
||||
TMemCell *
|
||||
cell() {
|
||||
return m_memorycell; }
|
||||
|
||||
private:
|
||||
// members
|
||||
memorynode_data m_data;
|
||||
TMemCell * m_memorycell;
|
||||
};
|
||||
*/
|
||||
} // scene
|
||||
|
||||
|
||||
|
||||
namespace editor {
|
||||
|
||||
// base interface for nodes which can be actvated in scenario editor
|
||||
@@ -278,28 +307,22 @@ struct basic_node {
|
||||
|
||||
public:
|
||||
// constructor
|
||||
basic_node() = default; // TODO: remove after refactor
|
||||
basic_node( scene::node_data const &Nodedata );
|
||||
// destructor
|
||||
virtual ~basic_node() = default;
|
||||
// methods
|
||||
std::string const &
|
||||
name() const {
|
||||
return m_name; }
|
||||
name() const;
|
||||
void
|
||||
location( glm::dvec3 const Location ) {
|
||||
m_area.center = Location; }
|
||||
location( glm::dvec3 const Location );
|
||||
glm::dvec3 const &
|
||||
location() const {
|
||||
return m_area.center; };
|
||||
location() const;
|
||||
float const &
|
||||
radius();
|
||||
void
|
||||
visible( bool const Visible ) {
|
||||
m_visible = Visible; }
|
||||
visible( bool const Visible );
|
||||
bool
|
||||
visible() const {
|
||||
return m_visible; }
|
||||
visible() const;
|
||||
|
||||
protected:
|
||||
// methods
|
||||
@@ -313,6 +336,36 @@ protected:
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
inline
|
||||
std::string const &
|
||||
basic_node::name() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
basic_node::location( glm::dvec3 const Location ) {
|
||||
m_area.center = Location;
|
||||
}
|
||||
|
||||
inline
|
||||
glm::dvec3 const &
|
||||
basic_node::location() const {
|
||||
return m_area.center;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
basic_node::visible( bool const Visible ) {
|
||||
m_visible = Visible;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
basic_node::visible() const {
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
} // editor
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user