Author Topic: hiding part of a merged object  (Read 7067 times)

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
hiding part of a merged object
« on: August 03, 2010, 09:41:42 pm »
is it possible to make some part of an object invisible ? if we somehow now the polyon ids..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: hiding part of a merged object
« Reply #1 on: August 03, 2010, 10:10:42 pm »
Not really...you can try to attach a vertex controller to it and move the vertices of the polygons that should be invisible out of sight. But that's pretty crude IMHO.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: hiding part of a merged object
« Reply #2 on: August 03, 2010, 10:29:41 pm »
i guess so. besides that, to hide 12 polygons, all merged structure's polygons will be uploaded again.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: hiding part of a merged object
« Reply #3 on: August 03, 2010, 10:37:23 pm »
Yes, that's another issue....

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: hiding part of a merged object
« Reply #4 on: August 04, 2010, 03:26:06 pm »
i've noticed, when merging objects polygons orders and count are preserved. for example, merging 10 poly + 15 poly + 25 poly results in an object with 50 polygons. and first 10 polygons come from first object, second 15 from second and so on. is this always the case, can we count on this ?

provided this is true (at least for some kind of objects), -if possible- adding a method to PolygonManager not to render some polygons can be extremely useful. for example, consumable level items can be merged into level and can be hidden after consumed.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: hiding part of a merged object
« Reply #5 on: August 04, 2010, 09:07:23 pm »
You can't really do this for compiled objects. They compile down into several batches of geometry optimized by different criteria. Those batches could be rendered individually, but you don't have control about which geometry is in which batch. And splitting the batches by object doesn't do any good, because it destroys the advantages of merging.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: hiding part of a merged object
« Reply #6 on: August 04, 2010, 09:37:43 pm »
just for curiosity, how does dynamically compiled objects work then ? when some of their vertices are modified by a vertex controller, doesn't that require some of that vertices move among batches ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: hiding part of a merged object
« Reply #7 on: August 04, 2010, 09:49:51 pm »
No. Batching is done based on texture and blending modes, not on position in space. For simpler objects, the mapping is 1-to-1, for more complex ones, there's an additional index list that maps from the mesh to the compiled data. jPCT will print some messages about the mode it's using when compiling an animated object IIRC.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: hiding part of a merged object
« Reply #8 on: August 04, 2010, 09:57:57 pm »
i see. but doesn't changing texture or texture mode via PolygonManager requires batch change in this case ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: hiding part of a merged object
« Reply #9 on: August 04, 2010, 11:00:18 pm »
Yes, it would....but it's simply ignored for compiled objects. You can do that before the actual compilation happens, which is why AE's PolygonManager still has these methods. But after compilation, it will be ignored.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: hiding part of a merged object
« Reply #10 on: August 05, 2010, 04:13:40 am »
i see. so there isn't much option left to handle many objects. i wanna try that crude option, at least for fun ;)

so, what are the steps i should take ?
* i need to make the merged object compiled dynamically, but there is no such option in AE. (this works for Bones but i cant remember how)
* i need the polygons ids. see below
* move vertices out of sight via VertexController and call touch on object
* anything else ?

Quote from: raft
i've noticed, when merging objects polygons orders and count are preserved. for example, merging 10 poly + 15 poly + 25 poly results in an object with 50 polygons. and first 10 polygons come from first object, second 15 from second and so on. is this always the case, can we count on this ?
can i count on this ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: hiding part of a merged object
« Reply #11 on: August 05, 2010, 07:16:22 am »
Yes, counts will be preserved. Dynamic compilation in AE happens on the fact that the object has an IVertexController (or an Animation) attached to it.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: hiding part of a merged object
« Reply #12 on: August 05, 2010, 10:29:45 pm »
yeap, the crude way is the way to go ;)

here is a screenshot of an experimental large scene. ~750 objects are merged into two. it runs at more than 30fps ;D


i was planning to merge consumable items in 50 or so batches to reduce vertex uploads but seems as it's not necessary. no noticable hickups when some vertices are pushed away. afterall it's not done every frame.

i've a few questions:
* how can i determine how many vertices an object will occupy when merged. Mesh().getUniqueVertexCount() does not give the correct number. for example, for a box created by primitives, this methods return 18. but it occupies only 10 vertices when merged.
* is there a best location to push unwanted vertices ? for example, does it matter to push them to same place or is it better to spread them ? besides this, i guess it's always better to push them somewhere behind Config.farPlane

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: hiding part of a merged object
« Reply #13 on: August 05, 2010, 10:56:44 pm »
Cool...

uniqueVertexCount should actually be giving you the correct number...it just adds the vertices of the bounding box to the mix, which is why you get 18 and not 10. Just subtract 8 from the returned value and it should be correct.

About the location...i think it's fine to push them all to one secret place. I don't see why this should be a problem.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: hiding part of a merged object
« Reply #14 on: August 05, 2010, 11:29:30 pm »
cool, thanks :D

indeed, i've found this technique so powerful that, you may want to add hide/ShowSubObject and/or translateSubObject methods to Object3D.