Hi Miguel,

your code is pretty close, but you're missing one thing: When you start
the new thread, changes that you made in the original aspect are not
automatically copied into the new one (as other threads could already be
using it). Therefore when you add a child to the scene in the animation
thread, it doesn't know about the old child, and replaces it with the
new one. The error message comes because you don't use the FieldMask,
which simulates changing everything in the scene Node, including its
core (which is unset, i.e. Null), which is then copied back into the
original aspect. 

You need to initialize the animation thread's aspect with the original
data first, and then things will work.

Here's the diff (the line numbers will be a little off):

*** 74parCreate.cpp     2005-08-23 16:28:15.630011085 -0500
--- 74parCreate.cpp.orig        2005-08-23 16:14:40.000000000 -0500
--- 12,17 ----
***************
*** 44,55 ****

  //this function will run in a thread and simply will
  //rotate the cube by setting a new transformation matrix
  void rotate(void *args){
!     Thread *caller = static_cast<Thread*>(args);
!
!     caller->getChangeList()->apply();
!
          // we won't stop calculating new matrices....
          while(true){
                  Matrix m;
--- 40,46 ----

  //this function will run in a thread and simply will
  //rotate the cube by setting a new transformation matrix
  void rotate(void *args){
          // we won't stop calculating new matrices....
          while(true){
                  Matrix m;

***************
*** 99,111 ****
      mgr->setWindow(gwin );
      mgr->setRoot  (scene);
      mgr->showAll();

          animationThread = dynamic_cast<Thread 
*>(ThreadManager::the()->getThread("anim"));
 
!         animationThread->runFunction(rotate, 1, Thread::getCurrent());

      glutMainLoop();

--- 90,99 ----
      mgr->setWindow(gwin );
      mgr->setRoot  (scene);
      mgr->showAll();

          animationThread = dynamic_cast<Thread 
*>(ThreadManager::the()->getThread("anim"));
 
!         animationThread->runFunction(rotate, 1, NULL);

      glutMainLoop();

Hope it helps

        Dirk




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to