0

Lessons 07 tended to give me the idea that we can load one object in many renderers to see it from different views. However I've many issues with it : the property dirty is a property of the object and its attributes and is not a function of the renderer : so when the first renderer is finished he puts all the properties to true and the following renderers have nothing to do.

For example if my object (root) is an empty object with 2 children (child1,child2) which contains not empty objects : - the first renderer works fine (i.e. it adds root, child1 and child2), but the others only add the empty objects because root.dirty==false (see renderer3D.hs, line 591) - the first renderer computes a bounding box fitting the scene, the other don't because root/child1/child2.points.dirty==false (see renderer3D.js at line 793)

So my question is : is it possible to have 1 complex object and manage it in different renderers (while every object has a property which depends of the renderer : dirty) ? Or should I copy it and link events so the transformations in 1 render are reported in the other ones ? Or should I do more modifications ?

Ricola3D
  • 2,402
  • 17
  • 16
  • My current solution is : var initObj = new X.object(); For each renderer { var newObj = new X.object(initObj); initObj = newObj; } – Ricola3D May 28 '12 at 09:37

1 Answers1

1

I just created a jsfiddle to create a scenario like you said

http://jsfiddle.net/haehn/ZdzeR/

It all works fine:

scene is an X.object which holds a mesh and a cube. adding it to all the 3 renderers works fine and shows both objects.

haehn
  • 967
  • 1
  • 6
  • 19
  • Yes, it works if you use firstrenderer.onShowtime to add the object in the two other renderers (but it doesn't without it, if you change to renderer1/2/3.add(scene) and then renderer1/2/3.render(), the first renderer shows the whole scene, but the following only the red cube). But thanks I'll do as you shew and I'll pray than that changing an object's transform will effects all the renderers ! – Ricola3D May 29 '12 at 08:14
  • Furthermore, if you remove your renderer.camera.position = [...], you see that the views are not centered the same way at all. And I think the problem will remain while the dirty property of objects will be independant of the renderer which renders it ^^ – Ricola3D May 29 '12 at 08:16
  • I created an issue for not properly re-calculating the bounding box: https://github.com/xtk/X/issues/43 – haehn May 30 '12 at 12:50
  • regarding the transform: this should work and also don't worry about the dirty flag attached to an object rather than let the renderer observe it since it just creates the gl buffers. if you update the points/transforms etc. the renderer still picks it up without needing to recreate the gl buffers in the update_ function. – haehn May 30 '12 at 12:51