Discussion:
using papervision to depth sort
Sean Thompson
2010-08-31 10:00:28 UTC
Permalink
I'm trying to use papervision to sort the depth for a number of items. It
can be assumed that no two items will intersect each other, that all items
are cuboid, but that some items will be massivly longer than other items.

It already does a great job of this, but in this instance I'll be using the
information to control some graphics external to papervision. For this, I
need a definite idea of 'item a is in front of item b' (if that's the case).

My two train of thought is to get papervision to render items one at a time.
that is, it will fail to make cuboids intersect correctly but the front item
will appear in front. obviously, any other way of getting this information
would be greatly received.

Ta. Sean.
Sean Thompson
2010-08-31 10:47:36 UTC
Permalink
update:

I've moved everything from the same viewportlayer, to each having their own
viewportlayers. The now no longer intersect. Unfortunately, it's
not accurately calculating what is in front of what. It's fine with two
cubes, but a cube next to a long cuboid can be wrong. It looks as though
it's basing its decision on a single point (ie, the center of the cube is
further back than the center of the cuboid, therefore the cube must be
behind the cuboid).

Is there anything I can do to make it more accurate?

Ta. Sean.
Post by Sean Thompson
I'm trying to use papervision to sort the depth for a number of items. It
can be assumed that no two items will intersect each other, that all items
are cuboid, but that some items will be massivly longer than other items.
It already does a great job of this, but in this instance I'll be using the
information to control some graphics external to papervision. For this, I
need a definite idea of 'item a is in front of item b' (if that's the case).
My two train of thought is to get papervision to render items one at a
time. that is, it will fail to make cuboids intersect correctly but the
front item will appear in front. obviously, any other way of getting this
information would be greatly received.
Ta. Sean.
--
Sean Thompson | Production Manager | Dubit Limited
Andy Zupko
2010-08-31 12:27:22 UTC
Permalink
viewport layers use the average of the faces drawn to them to calculate their depth, making them susceptible to the same draw order problem as regular faces. You can fix this by using a indexSort on the main viewportLayer, which will sort all the layers by their layerIndex. You can set this value manually based on whatever criteria you want (z position of the object for instance). This can present some other problems but it really depends on your application.
I've moved everything from the same viewportlayer, to each having their own viewportlayers. The now no longer intersect. Unfortunately, it's not accurately calculating what is in front of what. It's fine with two cubes, but a cube next to a long cuboid can be wrong. It looks as though it's basing its decision on a single point (ie, the center of the cube is further back than the center of the cuboid, therefore the cube must be behind the cuboid).
Is there anything I can do to make it more accurate?
Ta. Sean.
I'm trying to use papervision to sort the depth for a number of items. It can be assumed that no two items will intersect each other, that all items are cuboid, but that some items will be massivly longer than other items.
It already does a great job of this, but in this instance I'll be using the information to control some graphics external to papervision. For this, I need a definite idea of 'item a is in front of item b' (if that's the case).
My two train of thought is to get papervision to render items one at a time. that is, it will fail to make cuboids intersect correctly but the front item will appear in front. obviously, any other way of getting this information would be greatly received.
Ta. Sean.
--
Sean Thompson | Production Manager | Dubit Limited
_______________________________________________
Papervision3D mailing list
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
Sean Thompson
2010-08-31 12:46:07 UTC
Permalink
I found that thanks Andy. Unfortunately, I don't know what index to give
each layer. I was hoping to use papervision to work that out!

Sean.
Post by Andy Zupko
viewport layers use the average of the faces drawn to them to calculate
their depth, making them susceptible to the same draw order problem as
regular faces. You can fix this by using a indexSort on the main
viewportLayer, which will sort all the layers by their layerIndex. You can
set this value manually based on whatever criteria you want (z position of
the object for instance). This can present some other problems but it
really depends on your application.
I've moved everything from the same viewportlayer, to each having their own
viewportlayers. The now no longer intersect. Unfortunately, it's
not accurately calculating what is in front of what. It's fine with two
cubes, but a cube next to a long cuboid can be wrong. It looks as though
it's basing its decision on a single point (ie, the center of the cube is
further back than the center of the cuboid, therefore the cube must be
behind the cuboid).
Is there anything I can do to make it more accurate?
Ta. Sean.
Post by Sean Thompson
I'm trying to use papervision to sort the depth for a number of items. It
can be assumed that no two items will intersect each other, that all items
are cuboid, but that some items will be massivly longer than other items.
It already does a great job of this, but in this instance I'll be using
the information to control some graphics external to papervision. For this,
I need a definite idea of 'item a is in front of item b' (if that's the
case).
My two train of thought is to get papervision to render items one at a
time. that is, it will fail to make cuboids intersect correctly but the
front item will appear in front. obviously, any other way of getting this
information would be greatly received.
Ta. Sean.
--
Sean Thompson | Production Manager | Dubit Limited
_______________________________________________
Papervision3D mailing list
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
--
Sean Thompson | Production Manager | Dubit Limited
Andy Zupko
2010-08-31 14:06:25 UTC
Permalink
you can base it off whatever criteria you want. Do a for loop over each object before each render, and assign it a value that will make the most sense for your application. For instance, if you camera isn't moving on z axis, and you want to simply sort by that, you can just say : layer.layerIndex = object.z; Bigger numbers will be sorted farther away. If you can explain what your trying to do (and maybe some SS) it would help.

-andy
I found that thanks Andy. Unfortunately, I don't know what index to give each layer. I was hoping to use papervision to work that out!
Sean.
viewport layers use the average of the faces drawn to them to calculate their depth, making them susceptible to the same draw order problem as regular faces. You can fix this by using a indexSort on the main viewportLayer, which will sort all the layers by their layerIndex. You can set this value manually based on whatever criteria you want (z position of the object for instance). This can present some other problems but it really depends on your application.
I've moved everything from the same viewportlayer, to each having their own viewportlayers. The now no longer intersect. Unfortunately, it's not accurately calculating what is in front of what. It's fine with two cubes, but a cube next to a long cuboid can be wrong. It looks as though it's basing its decision on a single point (ie, the center of the cube is further back than the center of the cuboid, therefore the cube must be behind the cuboid).
Is there anything I can do to make it more accurate?
Ta. Sean.
I'm trying to use papervision to sort the depth for a number of items. It can be assumed that no two items will intersect each other, that all items are cuboid, but that some items will be massivly longer than other items.
It already does a great job of this, but in this instance I'll be using the information to control some graphics external to papervision. For this, I need a definite idea of 'item a is in front of item b' (if that's the case).
My two train of thought is to get papervision to render items one at a time. that is, it will fail to make cuboids intersect correctly but the front item will appear in front. obviously, any other way of getting this information would be greatly received.
Ta. Sean.
--
Sean Thompson | Production Manager | Dubit Limited
_______________________________________________
Papervision3D mailing list
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
--
Sean Thompson | Production Manager | Dubit Limited
Fábio Burkard
2010-08-31 14:21:29 UTC
Permalink
Try putting more segments in the large cuboids; it works for me, when I have
viewport layers issues...
Post by Andy Zupko
viewport layers use the average of the faces drawn to them to calculate
their depth, making them susceptible to the same draw order problem as
regular faces. You can fix this by using a indexSort on the main
viewportLayer, which will sort all the layers by their layerIndex. You can
set this value manually based on whatever criteria you want (z position of
the object for instance). This can present some other problems but it
really depends on your application.
Sean Thompson
2010-08-31 15:01:52 UTC
Permalink
Andy,

Thanks, but I'm afraid it's not a case of putting whatever numbers I want on
it. I'm hoping to find a way for papervision to define what order things
should be in, not me tell papervision. I'm not going to gain anything by
telling apervision to put things in a certain order, then asking papervision
what order that is.


Fabio,

Cheers, but that's not going to work either. I can make all the objects
appear in the correct order simply by putting them in the same viewport. I'm
not trying to get papervision to produce a 3d world that looks right. I'm
trying to use some of the classes from it to report the depth a number of
cuboids appear at.
Post by Fábio Burkard
Try putting more segments in the large cuboids; it works for me, when I
have viewport layers issues...
Post by Andy Zupko
viewport layers use the average of the faces drawn to them to calculate
their depth, making them susceptible to the same draw order problem as
regular faces. You can fix this by using a indexSort on the main
viewportLayer, which will sort all the layers by their layerIndex. You can
set this value manually based on whatever criteria you want (z position of
the object for instance). This can present some other problems but it
really depends on your application.
_______________________________________________
Papervision3D mailing list
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
--
Sean Thompson | Production Manager | Dubit Limited
Loading...