jPCT - a 3d engine for Java > Bugs

child --> parent

(1/3) > >>

eye1:
Hello

I'm using this code to retrieve current position of Object in world


--- Code: ---   private SimpleVector getParentTrans(Object3D model)
   {
      Object3D[] parents = model.getParents();
      SimpleVector sv=new SimpleVector();
      for (int i = 0; i < parents.length; i++) {
         if (parents[i] != null) {
            sv.add(parents[i].getTranslation());
            sv.add(getParentTrans(parents[i]));
         }
      }
      return sv;
   }

   public SimpleVector getCurrPosition()
   {
      SimpleVector sv = model.getOrigin();
      sv.add(model.getTranslation());
      SimpleVector par = getParentTrans(model);
      System.out.println("PAR: "+par);
      sv.add(par);
      return sv;
   }
--- End code ---


it looks like it works fine!!!


But when I unlink child from parent it look like it is not removed from array which is returned by method Object3D.getParents(). Is that a bug, or i made a mistake??

Regards

EgonOlsen:
A little bit both. It's described that way (albeit not very cleary, i have to admit) in the docs but it makes no sense, does it? So i've uploaded a version that should only return the actually used parents here: http://www.jpct.net/download/beta/jpct.jar

Hope this helps.

eye1:
I found a workaround, and now i translate objects seperatlly.
Thanks 4 help!

eye1:

--- Quote from: "eye1" ---Hello

I'm using this code to retrieve current position of Object in world


--- Code: ---   private SimpleVector getParentTrans(Object3D model)
   {
      Object3D[] parents = model.getParents();
      SimpleVector sv=new SimpleVector();
      for (int i = 0; i < parents.length; i++) {
         if (parents[i] != null) {
            sv.add(parents[i].getTranslation());
            sv.add(getParentTrans(parents[i]));
         }
      }
      return sv;
   }

   public SimpleVector getCurrPosition()
   {
      SimpleVector sv = model.getOrigin();
      sv.add(model.getTranslation());
      SimpleVector par = getParentTrans(model);
      System.out.println("PAR: "+par);
      sv.add(par);
      return sv;
   }
--- End code ---


it looks like it works fine!!!


But when I unlink child from parent it look like it is not removed from array which is returned by method Object3D.getParents(). Is that a bug, or i made a mistake??

Regards
--- End quote ---


Hello again.

Should above code work also when objects are rotated?

I'm thinking of going back to my previus child-->parent translations.

eye1:
I'm pretty shure it doesn't

Is it possible to get an absolute position of child object in world.

Navigation

[0] Message Index

[#] Next page

Go to full version