KiCad PCB EDA Suite
Loading...
Searching...
No Matches
scenegraph.cpp
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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#define GLM_FORCE_RADIANS
22
23#include <iostream>
24#include <sstream>
25#include <glm/glm.hpp>
26#include <glm/ext.hpp>
27#include <wx/log.h>
28
32
33
34SCENEGRAPH::SCENEGRAPH( SGNODE* aParent ) : SGNODE( aParent )
35{
37 rotation_angle = 0.0;
38 scale_angle = 0.0;
39
40 scale.x = 1.0;
41 scale.y = 1.0;
42 scale.z = 1.0;
43
44 if( nullptr != aParent && S3D::SGTYPE_TRANSFORM != aParent->GetNodeType() )
45 {
46 m_Parent = nullptr;
47
48 wxLogTrace( MASK_3D_SG,
49 wxT( "%s:%s:%d * [BUG] inappropriate parent to SCENEGRAPH (type %d)" ),
50 __FILE__, __FUNCTION__, __LINE__,
51 aParent->GetNodeType() );
52 }
53 else if( nullptr != aParent && S3D::SGTYPE_TRANSFORM == aParent->GetNodeType() )
54 {
55 m_Parent->AddChildNode( this );
56 }
57}
58
59
61{
62 // drop references
65
66 // delete owned objects
69}
70
71
72bool SCENEGRAPH::SetParent( SGNODE* aParent, bool notify )
73{
74 if( nullptr != m_Parent )
75 {
76 if( aParent == m_Parent )
77 return true;
78
79 // handle the change in parents
80 if( notify )
81 m_Parent->unlinkChildNode( this );
82
83 m_Parent = nullptr;
84
85 if( nullptr == aParent )
86 return true;
87 }
88
89 // only a transform may be parent to a transform
90 if( nullptr != aParent && S3D::SGTYPE_TRANSFORM != aParent->GetNodeType() )
91 return false;
92
93 m_Parent = aParent;
94
95 if( m_Parent )
96 m_Parent->AddChildNode( this );
97
98 return true;
99}
100
101
102SGNODE* SCENEGRAPH::FindNode(const char *aNodeName, const SGNODE *aCaller)
103{
104 if( nullptr == aNodeName || 0 == aNodeName[0] )
105 return nullptr;
106
107 if( !m_Name.compare( aNodeName ) )
108 return this;
109
110 FIND_NODE( SCENEGRAPH, aNodeName, m_Transforms, aCaller );
111 FIND_NODE( SGSHAPE, aNodeName, m_Shape, aCaller );
112
113 // query the parent if appropriate
114 if( aCaller == m_Parent || nullptr == m_Parent )
115 return nullptr;
116
117 return m_Parent->FindNode( aNodeName, this );
118}
119
120
121void SCENEGRAPH::unlinkNode( const SGNODE* aNode, bool isChild )
122{
123 if( nullptr == aNode )
124 return;
125
126 switch( aNode->GetNodeType() )
127 {
130 isChild );
131 break;
132
135 break;
136
137 default:
138 break;
139 }
140
141 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] unlinkNode() did not find its target" ),
142 __FILE__, __FUNCTION__, __LINE__ );
143}
144
145
147{
148 unlinkNode( aNode, true );
149 return;
150}
151
152
154{
155 unlinkNode( aNode, false );
156 return;
157}
158
159
160bool SCENEGRAPH::addNode( SGNODE* aNode, bool isChild )
161{
162 wxCHECK( aNode, false );
163
165 ADD_NODE( S3D::SGTYPE_SHAPE, SGSHAPE, aNode, m_Shape, m_RShape, isChild );
166
167 wxLogTrace( MASK_3D_SG,
168 wxT( "%s:%s:%d * [BUG] object '%s' is not a valid type for this object (%d)" ),
169 __FILE__, __FUNCTION__, __LINE__,
170 aNode->GetName(),
171 aNode->GetNodeType() );
172
173 return false;
174}
175
176
178{
179 return addNode( aNode, false );
180}
181
182
184{
185 return addNode( aNode, true );
186}
187
188
190{
191 m_written = false;
192
193 // rename this node
194 m_Name.clear();
195 GetName();
196
197 // rename all shapes
198 do
199 {
200 std::vector< SGSHAPE* >::iterator sL = m_Shape.begin();
201 std::vector< SGSHAPE* >::iterator eL = m_Shape.end();
202
203 while( sL != eL )
204 {
205 (*sL)->ReNameNodes();
206 ++sL;
207 }
208
209 } while( 0 );
210
211 // rename all transforms
212 do
213 {
214 std::vector< SCENEGRAPH* >::iterator sL = m_Transforms.begin();
215 std::vector< SCENEGRAPH* >::iterator eL = m_Transforms.end();
216
217 while( sL != eL )
218 {
219 (*sL)->ReNameNodes();
220 ++sL;
221 }
222
223 } while( 0 );
224}
225
226
227bool SCENEGRAPH::WriteVRML( std::ostream& aFile, bool aReuseFlag )
228{
229 if( m_Transforms.empty() && m_RTransforms.empty() && m_Shape.empty() && m_RShape.empty() )
230 {
231 return false;
232 }
233
234 std::string tmp;
235
236 if( aReuseFlag )
237 {
238 if( !m_written )
239 {
240 aFile << "DEF " << GetName() << " Transform {\n";
241 m_written = true;
242 }
243 else
244 {
245 aFile << "USE " << GetName() << "\n";
246 return true;
247 }
248 }
249 else
250 {
251 aFile << " Transform {\n";
252 }
253
254 // convert center to 1VRML unit = 0.1 inch
255 SGPOINT pt = center;
256 pt.x /= 2.54;
257 pt.y /= 2.54;
258 pt.z /= 2.54;
259
260 S3D::FormatPoint( tmp, pt );
261 aFile << " center " << tmp << "\n";
263 aFile << " rotation " << tmp << "\n";
264 S3D::FormatPoint( tmp, scale );
265 aFile << " scale " << tmp << "\n";
267 aFile << " scaleOrientation " << tmp << "\n";
268
269 // convert translation to 1VRML unit = 0.1 inch
270 pt = translation;
271 pt.x /= 2.54;
272 pt.y /= 2.54;
273 pt.z /= 2.54;
274 S3D::FormatPoint( tmp, pt );
275 aFile << " translation " << tmp << "\n";
276
277 aFile << " children [\n";
278
279 if( !m_Transforms.empty() )
280 {
281 std::vector< SCENEGRAPH* >::iterator sL = m_Transforms.begin();
282 std::vector< SCENEGRAPH* >::iterator eL = m_Transforms.end();
283
284 while( sL != eL )
285 {
286 (*sL)->WriteVRML( aFile, aReuseFlag );
287 ++sL;
288 }
289 }
290
291 if( !m_RTransforms.empty() )
292 {
293 std::vector< SCENEGRAPH* >::iterator sL = m_RTransforms.begin();
294 std::vector< SCENEGRAPH* >::iterator eL = m_RTransforms.end();
295
296 while( sL != eL )
297 {
298 (*sL)->WriteVRML( aFile, aReuseFlag );
299 ++sL;
300 }
301 }
302
303 if( !m_Shape.empty() )
304 {
305 std::vector< SGSHAPE* >::iterator sL = m_Shape.begin();
306 std::vector< SGSHAPE* >::iterator eL = m_Shape.end();
307
308 while( sL != eL )
309 {
310 (*sL)->WriteVRML( aFile, aReuseFlag );
311 ++sL;
312 }
313 }
314
315 if( !m_RShape.empty() )
316 {
317 std::vector< SGSHAPE* >::iterator sL = m_RShape.begin();
318 std::vector< SGSHAPE* >::iterator eL = m_RShape.end();
319
320 while( sL != eL )
321 {
322 (*sL)->WriteVRML( aFile, aReuseFlag );
323 ++sL;
324 }
325 }
326
327 aFile << "] }\n";
328
329 return true;
330}
331
332
333bool SCENEGRAPH::WriteCache( std::ostream& aFile, SGNODE* parentNode )
334{
335 if( nullptr == parentNode && nullptr != m_Parent )
336 {
337 SGNODE* np = m_Parent;
338
339 while( nullptr != np->GetParent() )
340 np = np->GetParent();
341
342 if( np->WriteCache( aFile, nullptr ) )
343 {
344 m_written = true;
345 return true;
346 }
347
348 return false;
349 }
350
351 wxCHECK( parentNode == m_Parent, false );
352
353 if( nullptr == m_Parent )
354 {
355 // ensure unique node names
357 ReNameNodes();
358 }
359
360 if( aFile.fail() )
361 {
362 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] bad stream" ),
363 __FILE__, __FUNCTION__, __LINE__ );
364
365 return false;
366 }
367
368 aFile << "[" << GetName() << "]";
369 S3D::WritePoint( aFile, center );
372 aFile.write( (char*)&rotation_angle, sizeof( rotation_angle ) );
373 S3D::WritePoint( aFile, scale );
375 aFile.write( (char*)&scale_angle, sizeof( scale_angle ) );
376
377 // Transfer ownership of any Transform references which hadn't been written
378 size_t asize = m_RTransforms.size();
379 size_t i;
380
381 for( i = 0; i < asize; ++i )
382 {
383 if( !m_RTransforms[i]->isWritten() )
384 {
385 m_RTransforms[i]->SwapParent( this );
386 --asize;
387 --i;
388 }
389 }
390
391 // Transfer ownership of any Shape references which hadn't been written
392 asize = m_RShape.size();
393
394 for( i = 0; i < asize; ++i )
395 {
396 if( !m_RShape[i]->isWritten() )
397 {
398 m_RShape[i]->SwapParent( this );
399 --asize;
400 --i;
401 }
402 }
403
404 asize = m_Transforms.size();
405 aFile.write( (char*)&asize, sizeof( size_t ) );
406 asize = m_RTransforms.size();
407 aFile.write( (char*)&asize, sizeof( size_t ) );
408 asize = m_Shape.size();
409 aFile.write( (char*)&asize, sizeof( size_t ) );
410 asize = m_RShape.size();
411 aFile.write( (char*)&asize, sizeof( size_t ) );
412 asize = m_Transforms.size();
413
414 // write child transforms
415 for( i = 0; i < asize; ++i )
416 {
417 if( !m_Transforms[i]->WriteCache( aFile, this ) )
418 {
419 wxLogTrace( MASK_3D_SG,
420 wxT( "%s:%s:%d * [INFO] bad stream while writing child transforms" ),
421 __FILE__, __FUNCTION__, __LINE__ );
422
423 return false;
424 }
425 }
426
427 // write referenced transform names
428 asize = m_RTransforms.size();
429
430 for( i = 0; i < asize; ++i )
431 aFile << "[" << m_RTransforms[i]->GetName() << "]";
432
433 // write child shapes
434 asize = m_Shape.size();
435
436 for( i = 0; i < asize; ++i )
437 {
438 if( !m_Shape[i]->WriteCache( aFile, this ) )
439 {
440 wxLogTrace( MASK_3D_SG,
441 wxT( "%s:%s:%d * [INFO] bad stream while writing child shapes" ),
442 __FILE__, __FUNCTION__, __LINE__ );
443
444 return false;
445 }
446 }
447
448 // write referenced transform names
449 asize = m_RShape.size();
450
451 for( i = 0; i < asize; ++i )
452 aFile << "[" << m_RShape[i]->GetName() << "]";
453
454 if( aFile.fail() )
455 return false;
456
457 m_written = true;
458 return true;
459}
460
461
462bool SCENEGRAPH::ReadCache( std::istream& aFile, SGNODE* parentNode )
463{
464 wxCHECK( m_Transforms.empty() && m_RTransforms.empty() && m_Shape.empty() && m_RShape.empty(),
465 false );
466
467 std::string name; // name of the node
468
469 if( nullptr == parentNode )
470 {
471 // we need to read the tag and verify its type
472 if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
473 {
474 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; tag mismatch at position "
475 "%ul" ),
476 __FILE__, __FUNCTION__, __LINE__,
477 static_cast<unsigned long>( aFile.tellg() ) );
478
479 return false;
480 }
481
482 m_Name = name;
483 }
484
485 // read fixed member data
486 S3D::ReadPoint( aFile, center );
487 S3D::ReadPoint( aFile, translation );
489 aFile.read( (char*)&rotation_angle, sizeof( rotation_angle ) );
490 S3D::ReadPoint( aFile, scale );
491 S3D::ReadVector( aFile, scale_axis );
492 aFile.read( (char*)&scale_angle, sizeof( scale_angle ) );
493
494 size_t sizeCT = 0; // child transforms
495 size_t sizeRT = 0; // referenced transforms
496 size_t sizeCS = 0; // child shapes
497 size_t sizeRS = 0; // referenced shapes
498
499 aFile.read( (char*)&sizeCT, sizeof( size_t ) );
500 aFile.read( (char*)&sizeRT, sizeof( size_t ) );
501 aFile.read( (char*)&sizeCS, sizeof( size_t ) );
502 aFile.read( (char*)&sizeRS, sizeof( size_t ) );
503
504 size_t i;
505
506 // read child transforms
507 for( i = 0; i < sizeCT; ++i )
508 {
509 if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
510 {
511 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad child transform tag "
512 "at position %ul" ),
513 __FILE__, __FUNCTION__, __LINE__,
514 static_cast<unsigned long>( aFile.tellg() ) );
515
516 return false;
517 }
518
519 SCENEGRAPH* sp = new SCENEGRAPH( this );
520 sp->SetName( name.c_str() );
521
522 if( !sp->ReadCache( aFile, this ) )
523 {
524 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data while reading transform "
525 "%ul" ),
526 __FILE__, __FUNCTION__, __LINE__,
527 static_cast<unsigned long>( aFile.tellg() ) );
528
529 return false;
530 }
531 }
532
533 // read referenced transforms
534 for( i = 0; i < sizeRT; ++i )
535 {
536 if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
537 {
538 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad ref transform tag at "
539 "position %ul" ),
540 __FILE__, __FUNCTION__, __LINE__,
541 static_cast<unsigned long>( aFile.tellg() ) );
542
543 return false;
544 }
545
546 SGNODE* sp = FindNode( name.c_str(), this );
547
548 if( !sp )
549 {
550 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: cannot find ref "
551 "transform at position %ul" ),
552 __FILE__, __FUNCTION__, __LINE__,
553 static_cast<unsigned long>( aFile.tellg() ) );
554
555 return false;
556 }
557
559 {
560 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: type is not TRANSFORM "
561 "at position %ul" ),
562 __FILE__, __FUNCTION__, __LINE__,
563 static_cast<unsigned long>( aFile.tellg() ) );
564
565 return false;
566 }
567
568 AddRefNode( sp );
569 }
570
571 // read child shapes
572 for( i = 0; i < sizeCS; ++i )
573 {
574 if( S3D::SGTYPE_SHAPE != S3D::ReadTag( aFile, name ) )
575 {
576 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad child shape tag at "
577 "position %ul" ),
578 __FILE__, __FUNCTION__, __LINE__,
579 static_cast<unsigned long>( aFile.tellg() ) );
580
581 return false;
582 }
583
584 SGSHAPE* sp = new SGSHAPE( this );
585 sp->SetName( name.c_str() );
586
587 if( !sp->ReadCache( aFile, this ) )
588 {
589 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; corrupt data while "
590 "reading shape at position %ul" ),
591 __FILE__, __FUNCTION__, __LINE__,
592 static_cast<unsigned long>( aFile.tellg() ) );
593
594 return false;
595 }
596 }
597
598 // read referenced shapes
599 for( i = 0; i < sizeRS; ++i )
600 {
601 if( S3D::SGTYPE_SHAPE != S3D::ReadTag( aFile, name ) )
602 {
603 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data; bad ref shape tag at "
604 "position %ul" ),
605 __FILE__, __FUNCTION__, __LINE__,
606 static_cast<unsigned long>( aFile.tellg() ) );
607
608 return false;
609 }
610
611 SGNODE* sp = FindNode( name.c_str(), this );
612
613 if( !sp )
614 {
615 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: cannot find ref shape "
616 "at position %ul" ),
617 __FILE__, __FUNCTION__, __LINE__,
618 static_cast<unsigned long>( aFile.tellg() ) );
619
620 return false;
621 }
622
623 if( S3D::SGTYPE_SHAPE != sp->GetNodeType() )
624 {
625 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] corrupt data: type is not SGSHAPE at "
626 "position %ul" ),
627 __FILE__, __FUNCTION__, __LINE__,
628 static_cast<unsigned long>( aFile.tellg() ) );
629
630 return false;
631 }
632
633 AddRefNode( sp );
634 }
635
636 if( aFile.fail() )
637 return false;
638
639 return true;
640}
641
642
643bool SCENEGRAPH::Prepare( const glm::dmat4* aTransform, S3D::MATLIST& materials,
644 std::vector< SMESH >& meshes )
645{
646 // calculate the accumulated transform
647 double rX, rY, rZ;
648
649 // rotation
650 rotation_axis.GetVector( rX, rY, rZ );
651 glm::dmat4 rM = glm::rotate( glm::dmat4( 1.0 ), rotation_angle, glm::dvec3( rX, rY, rZ ) );
652
653 // translation
654 glm::dmat4 tM = glm::translate( glm::dmat4( 1.0 ), glm::dvec3( translation.x, translation.y,
655 translation.z ) );
656 // center
657 glm::dmat4 cM = glm::translate( glm::dmat4( 1.0 ), glm::dvec3( center.x, center.y, center.z ) );
658 glm::dmat4 ncM = glm::translate( glm::dmat4( 1.0 ), glm::dvec3( -center.x, -center.y,
659 -center.z ) );
660
661 // scale
662 glm::dmat4 sM = glm::scale( glm::dmat4( 1.0 ), glm::dvec3( scale.x, scale.y, scale.z ) );
663
664 // scaleOrientation
665 scale_axis.GetVector( rX, rY, rZ );
666 glm::dmat4 srM = glm::rotate( glm::dmat4( 1.0 ), scale_angle, glm::dvec3( rX, rY, rZ ) );
667 glm::dmat4 nsrM = glm::rotate( glm::dmat4( 1.0 ), -scale_angle, glm::dvec3( rX, rY, rZ ) );
668
669 // resultant point:
670 // P' = T x C x R x SR x S x -SR x -C x P
671 // resultant transform:
672 // tx0 = tM * cM * rM * srM * sM * nsrM * ncM
673 glm::dmat4 tx0;
674
675 if( nullptr != aTransform )
676 tx0 = (*aTransform) * tM * cM * rM * srM * sM * nsrM * ncM;
677 else
678 tx0 = tM * cM * rM * srM * sM * nsrM * ncM;
679
680 bool ok = true;
681
682 // prepare all shapes
683 do
684 {
685 std::vector< SGSHAPE* >::iterator sL = m_Shape.begin();
686 std::vector< SGSHAPE* >::iterator eL = m_Shape.end();
687
688 while( sL != eL && ok )
689 {
690 ok = (*sL)->Prepare( &tx0, materials, meshes );
691 ++sL;
692 }
693
694 sL = m_RShape.begin();
695 eL = m_RShape.end();
696
697 while( sL != eL && ok )
698 {
699 ok = (*sL)->Prepare( &tx0, materials, meshes );
700 ++sL;
701 }
702
703 } while( 0 );
704
705 // prepare all transforms
706 do
707 {
708 std::vector< SCENEGRAPH* >::iterator sL = m_Transforms.begin();
709 std::vector< SCENEGRAPH* >::iterator eL = m_Transforms.end();
710
711 while( sL != eL && ok )
712 {
713 ok = (*sL)->Prepare( &tx0, materials, meshes );
714 ++sL;
715 }
716
717 sL = m_RTransforms.begin();
718 eL = m_RTransforms.end();
719
720 while( sL != eL && ok )
721 {
722 ok = (*sL)->Prepare( &tx0, materials, meshes );
723 ++sL;
724 }
725
726 } while( 0 );
727
728 return ok;
729}
const char * name
void unlinkChildNode(const SGNODE *aNode) override
Remove references to an owned child.
bool Prepare(const glm::dmat4 *aTransform, S3D::MATLIST &materials, std::vector< SMESH > &meshes)
bool AddChildNode(SGNODE *aNode) override
std::vector< SGSHAPE * > m_RShape
Definition scenegraph.h:88
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
void unlinkNode(const SGNODE *aNode, bool isChild)
SCENEGRAPH(SGNODE *aParent)
std::vector< SCENEGRAPH * > m_RTransforms
Definition scenegraph.h:87
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
std::vector< SGSHAPE * > m_Shape
Definition scenegraph.h:85
SGVECTOR scale_axis
Definition scenegraph.h:74
SGPOINT center
Definition scenegraph.h:69
std::vector< SCENEGRAPH * > m_Transforms
Definition scenegraph.h:84
SGVECTOR rotation_axis
Definition scenegraph.h:71
double rotation_angle
Definition scenegraph.h:72
bool addNode(SGNODE *aNode, bool isChild)
virtual ~SCENEGRAPH()
double scale_angle
Definition scenegraph.h:75
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.
SGPOINT translation
Definition scenegraph.h:70
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
bool AddRefNode(SGNODE *aNode) override
SGPOINT scale
Definition scenegraph.h:73
void unlinkRefNode(const SGNODE *aNode) override
Remove pointers to a referenced node.
void SetName(const char *aName)
Definition sg_node.cpp:151
void ResetNodeIndex(void) noexcept
Reset the global SG* node indices in preparation for write operations.
Definition sg_node.cpp:234
virtual bool WriteCache(std::ostream &aFile, SGNODE *parentNode)=0
Write this node's data to a binary cache file.
const char * GetName(void)
Definition sg_node.cpp:142
bool isWritten(void) noexcept
Return true if the object had already been written to a cache file or VRML file.
Definition sg_node.h:216
SGNODE * GetParent(void) const noexcept
Returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
Definition sg_node.cpp:106
S3D::SGTYPES GetNodeType(void) const noexcept
Return the type of this node instance.
Definition sg_node.cpp:100
SGNODE * m_Parent
Pointer to parent node; may be NULL for top level transform.
Definition sg_node.h:223
SGNODE(SGNODE *aParent)
Definition sg_node.cpp:72
std::string m_Name
name to use for referencing the entity by name.
Definition sg_node.h:225
bool m_written
Set to true when the object has been written after a ReNameNodes().
Definition sg_node.h:226
S3D::SGTYPES m_SGtype
Type of Scene Graph node.
Definition sg_node.h:224
double z
Definition sg_base.h:68
double x
Definition sg_base.h:66
double y
Definition sg_base.h:67
Define a complex 3D shape for a scenegraph object.
Definition sg_shape.h:39
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
Definition sg_shape.cpp:443
bool ReadVector(std::istream &aFile, SGVECTOR &aVector)
bool ReadPoint(std::istream &aFile, SGPOINT &aPoint)
bool WritePoint(std::ostream &aFile, const SGPOINT &aPoint)
S3D::SGTYPES ReadTag(std::istream &aFile, std::string &aName)
Read the text tag of a binary cache file which is the NodeTag and unique ID number combined.
bool WriteVector(std::ostream &aFile, const SGVECTOR &aVector)
void FormatPoint(std::string &result, const SGPOINT &point)
@ SGTYPE_SHAPE
Definition sg_types.h:41
@ SGTYPE_TRANSFORM
Definition sg_types.h:33
void FormatOrientation(std::string &result, const SGVECTOR &axis, double rotation)
Define a number of macros to aid in repetitious code which is probably best expressed as a preprocess...
#define DEL_OBJS(aType, aList)
Definition sg_helpers.h:65
#define ADD_NODE(aNodeID, aType, aNode, aOwnedList, aRefList, isChild)
Definition sg_helpers.h:128
#define DROP_REFS(aType, aList)
Definition sg_helpers.h:48
#define FIND_NODE(aType, aName, aNodeList, aCallingNode)
Definition sg_helpers.h:169
#define UNLINK_NODE(aNodeID, aType, aNode, aOwnedList, aRefList, isChild)
Definition sg_helpers.h:82