KiCad PCB EDA Suite
Loading...
Searching...
No Matches
scenegraph.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015 Cirilo Bernardo <[email protected]>
5 * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
30#ifndef SCENE_GRAPH_H
31#define SCENE_GRAPH_H
32
33#include <vector>
34#include "3d_cache/sg/sg_node.h"
35
36class SGSHAPE;
37
44class SCENEGRAPH : public SGNODE
45{
46public:
47 void unlinkChildNode( const SGNODE* aNode ) override;
48 void unlinkRefNode( const SGNODE* aNode ) override;
49
50 SCENEGRAPH( SGNODE* aParent );
51 virtual ~SCENEGRAPH();
52
53 virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
54 SGNODE* FindNode(const char *aNodeName, const SGNODE *aCaller) override;
55 bool AddRefNode( SGNODE* aNode ) override;
56 bool AddChildNode( SGNODE* aNode ) override;
57
58 void ReNameNodes( void ) override;
59 bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
60
61 bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
62 bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
63
64 bool Prepare( const glm::dmat4* aTransform, S3D::MATLIST& materials,
65 std::vector< SMESH >& meshes );
66
67private:
68 void unlinkNode( const SGNODE* aNode, bool isChild );
69 bool addNode( SGNODE* aNode, bool isChild );
70
71public:
72 // note: order of transformation is Translate, Rotate, Offset
76 double rotation_angle; // radians
79 double scale_angle; // radians
80
81private:
82 // The following are items which may be defined for reuse
83 // in a VRML output file. They do not necessarily correspond
84 // to the use of DEF within a VRML input file; it is the
85 // responsibility of the plugin to perform any necessary
86 // conversions to comply with the restrictions imposed by
87 // this scene graph structure
88 std::vector< SCENEGRAPH* > m_Transforms; // local Transform nodes
89 std::vector< SGSHAPE* > m_Shape; // local Shape nodes
90
91 std::vector< SCENEGRAPH* > m_RTransforms; // referenced Transform nodes
92 std::vector< SGSHAPE* > m_RShape; // referenced Shape nodes
93};
94
95/*
96 p.120
97 Transform {
98 center 0 0 0
99 children []
100 rotation 0 0 1 0
101 scale 1 1 1
102 scaleOrientation 0 0 1 0
103 translation 0 0 0
104 bboxCenter 0 0 0
105 bboxSize -1 -1 -1
106 }
107*/
108
109#endif // SCENE_GRAPH_H
Define the basic data set required to represent a 3D model.
Definition: scenegraph.h:45
void unlinkChildNode(const SGNODE *aNode) override
Remove references to an owned child.
Definition: scenegraph.cpp:150
bool Prepare(const glm::dmat4 *aTransform, S3D::MATLIST &materials, std::vector< SMESH > &meshes)
Definition: scenegraph.cpp:647
bool AddChildNode(SGNODE *aNode) override
Definition: scenegraph.cpp:187
std::vector< SGSHAPE * > m_RShape
Definition: scenegraph.h:92
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
Definition: scenegraph.cpp:231
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
Definition: scenegraph.cpp:76
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
Definition: scenegraph.cpp:466
void unlinkNode(const SGNODE *aNode, bool isChild)
Definition: scenegraph.cpp:125
std::vector< SCENEGRAPH * > m_RTransforms
Definition: scenegraph.h:91
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
Definition: scenegraph.cpp:193
std::vector< SGSHAPE * > m_Shape
Definition: scenegraph.h:89
SGVECTOR scale_axis
Definition: scenegraph.h:78
SGPOINT center
Definition: scenegraph.h:73
std::vector< SCENEGRAPH * > m_Transforms
Definition: scenegraph.h:88
SGVECTOR rotation_axis
Definition: scenegraph.h:75
double rotation_angle
Definition: scenegraph.h:76
bool addNode(SGNODE *aNode, bool isChild)
Definition: scenegraph.cpp:164
virtual ~SCENEGRAPH()
Definition: scenegraph.cpp:64
double scale_angle
Definition: scenegraph.h:79
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) override
Search the tree of linked nodes and return a reference to the first node found with the given name.
Definition: scenegraph.cpp:106
SGPOINT translation
Definition: scenegraph.h:74
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
Definition: scenegraph.cpp:337
bool AddRefNode(SGNODE *aNode) override
Definition: scenegraph.cpp:181
SGPOINT scale
Definition: scenegraph.h:77
void unlinkRefNode(const SGNODE *aNode) override
Remove pointers to a referenced node.
Definition: scenegraph.cpp:157
The base class of all Scene Graph nodes.
Definition: sg_node.h:75
Define a complex 3D shape for a scenegraph object.
Definition: sg_shape.h:43