BPS/VPS Building

3 views
Skip to first unread message

le_unam

unread,
Aug 25, 2010, 10:40:19 AM8/25/10
to Away3D.dev
When trying to create my building for Prefab BSP/VPS something goes
wrong everytime. An easy room existing from only one cube with
invertedfaces is no problem. Problems come when i try to add walls
into this room. Fabrice showed me a link from derschmale with the
"rules" and its okay i think i understand them, but problems are
coming although i was following these rules. Shell i create the walls
inside with cubes or with planes? I tried both and nothing works with
collision detection. They are shown but i can walk trhough. Hmm maybe
someone can give me some more guidelines.

Thank you!

bebensiganteng

unread,
Aug 26, 2010, 1:56:30 AM8/26/10
to Away3D.dev
i have the same problem

http://labs.bebensiganteng.com/flash/prefab/

if you see the environment i can walk through the buildings, anybody
knows why?

le_unam

unread,
Aug 26, 2010, 2:54:19 AM8/26/10
to Away3D.dev
hmmm i guess the bsp/vps doesnt recognize oter walls of a cube ...
only the inner ones, so that we have to build our terrain in many
cubes where we walk in ... you know what i mean? maybe it is wrong but
its a guess ^^

bebensiganteng

unread,
Aug 26, 2010, 3:02:24 AM8/26/10
to Away3D.dev
i think i see what u mean, but on the hacienda sample, the chair had a
perfect collision detection how did they do that?

le_unam

unread,
Aug 26, 2010, 3:33:34 AM8/26/10
to Away3D.dev
thats a very good question ... now i have tried my guess mentioned
below ... and it works ... still remaining the chair thing ... i dont
know how they did it ... maybe fabrice can answer this question

bebensiganteng

unread,
Aug 26, 2010, 4:53:11 AM8/26/10
to Away3D.dev
yes please fabrice :)

Fabrice3D

unread,
Aug 26, 2010, 4:59:52 AM8/26/10
to away3...@googlegroups.com
> hmmm i guess the bsp/vps doesnt recognize oter walls of a cube ...
Would be lots of work just to support Cube collision don't you think??? :))

Of course it does. All outputs straight from Prefab are with active collision detection.
If you have played with tree booleans values, its indeed possible you have set it off.
but seeing the examples and reading the messages I think its simply because you do not set the collision on.

> Problems come when i try to add walls into this room.

K, lets let first start by the beginning.

You need to have a model perfectly enclosed, the cube is an example I gave you to make you understand you need a perfectly enclosed "solid" model.
You indeed can build a room by making a simple cube and add elements to it... that was an example to help you understand.

if you want to set collision detection per added elements, do like this:

myMesh.collider = true;
tree.addChild(myMesh);


To build a series of rooms, you need proceed otherway... Just made this little image to clarify a bit more.
http://www.closier.nl/playground/bsproom.jpg
What you are doing is the A case, while you should build as the B case.

The art is to keep the tree as simple as possible, so you add elements such as tables, chairs etc later on as dynamic objects.
Sometimes it can be wize to merge some element into the main tree.

Hope it helps a bit.

Fabrice

bebensiganteng

unread,
Aug 26, 2010, 5:18:50 AM8/26/10
to Away3D.dev
awesome!! really appreciate it :D

On Aug 26, 12:59 pm, Fabrice3D <fabric...@gmail.com> wrote:
> > hmmm i guess the bsp/vps doesnt recognize oter walls of a cube ...
>
> Would be lots of work just to support Cube collision don't you think???  :))
>
> Of course it does. All outputs straight from Prefab are with active collision detection.
> If you have played with tree booleans values, its indeed possible you have set it off.
> but seeing the examples and reading the messages I think its simply because you do not set the collision on.
>
> > Problems come when i try to add walls into this room.
>
> K, lets let first start by the beginning.
>
> You need to have a model perfectly enclosed, the cube is an example I gave you to make you understand you need a perfectly enclosed "solid" model.
> You indeed can build a room by making a simple cube and add elements to it... that was an example to help you understand.
>
> if you want to set collision detection per added elements, do like this:
>
> myMesh.collider = true;
> tree.addChild(myMesh);
>
> To build a series of rooms, you need proceed otherway... Just made this little image to clarify a bit more.http://www.closier.nl/playground/bsproom.jpg

le_unam

unread,
Aug 26, 2010, 5:51:03 AM8/26/10
to Away3D.dev
oh yes fabrice thats it ... the picture explains excatly what i did
wrong ... thank you!

On 26 Aug., 10:59, Fabrice3D <fabric...@gmail.com> wrote:
> > hmmm i guess the bsp/vps doesnt recognize oter walls of a cube ...
>
> Would be lots of work just to support Cube collision don't you think???  :))
>
> Of course it does. All outputs straight from Prefab are with active collision detection.
> If you have played with tree booleans values, its indeed possible you have set it off.
> but seeing the examples and reading the messages I think its simply because you do not set the collision on.
>
> > Problems come when i try to add walls into this room.
>
> K, lets let first start by the beginning.
>
> You need to have a model perfectly enclosed, the cube is an example I gave you to make you understand you need a perfectly enclosed "solid" model.
> You indeed can build a room by making a simple cube and add elements to it... that was an example to help you understand.
>
> if you want to set collision detection per added elements, do like this:
>
> myMesh.collider = true;
> tree.addChild(myMesh);
>
> To build a series of rooms, you need proceed otherway... Just made this little image to clarify a bit more.http://www.closier.nl/playground/bsproom.jpg

David Lenaerts

unread,
Aug 26, 2010, 6:40:32 AM8/26/10
to away3...@googlegroups.com
Also, what Fabrice hasn't mentioned (I think), is that you can't just add a bunch of cubes together and hand it over to the BSP generator. "Solid" regions (the inside of walls, the outside of the world, etc) can't contain anything, so you can't stack intersecting cubes as walls: For example: http://derschmale.com/bspInters.jpg

Then one more thing, imagine being "outside the world". So if you have a house, and that's your only region. Now imagine being outside the house. You can't have any outside walls there. Walls basically give the bsp system the signal that "hey, where I'm pointing, the player can go" (so only  the region between the outer and inner wall would be considered "solid"). In other words, since that creates a link between solid space and (albeit unintended) non-solid space: that's a leak and will cause errors.

Hope that helps,
David
--
David Lenaerts
Flash platform developer
http://www.derschmale.com

Fabrice3D

unread,
Aug 26, 2010, 6:52:53 AM8/26/10
to away3...@googlegroups.com
Also, what Fabrice hasn't mentioned (I think),
Intersecting cubes are evil. lol :))

Fabrice

bebensiganteng

unread,
Aug 26, 2010, 7:41:27 AM8/26/10
to Away3D.dev
one more question ;)

why sometimes does the application hangs when it's removing one-side
portals?

thanks
Rahmat

On Aug 26, 2:52 pm, Fabrice3D <fabric...@gmail.com> wrote:
> > Also, what Fabrice hasn't mentioned (I think),
>
> Intersecting cubes are evil. lol :))
>
> Fabrice
>
> On Aug 26, 2010, at 12:40 PM, David Lenaerts wrote:
>
> > Also, what Fabrice hasn't mentioned (I think), is that you can't just add a bunch of cubes together and hand it over to the BSP generator. "Solid" regions (the inside of walls, the outside of the world, etc) can't contain anything, so you can't stack intersecting cubes as walls: For example:http://derschmale.com/bspInters.jpg
>
> > Then one more thing, imagine being "outside the world". So if you have a house, and that's your only region. Now imagine being outside the house. You can't have any outside walls there. Walls basically give the bsp system the signal that "hey, where I'm pointing, the player can go" (so only  the region between the outer and inner wall would be considered "solid"). In other words, since that creates a link between solid space and (albeit unintended) non-solid space: that's a leak and will cause errors.
>
> > Hope that helps,
> > David
>

le_unam

unread,
Aug 26, 2010, 7:45:24 AM8/26/10
to Away3D.dev
When i create a cube which represents the outer walls, the ground and
the top of my house and export this as my house. then i create the
walls and export them as a bundle and add them as mesh.collider to the
tree .... would it work?

David Lenaerts

unread,
Aug 26, 2010, 7:45:27 AM8/26/10
to away3...@googlegroups.com
Usually, if anything causes the app to hang, it means you geometry is not correct for pvs (see the rules discussed). A lot of invalid portals may be created which makes it impossible to process them...

David Lenaerts

unread,
Aug 26, 2010, 7:50:28 AM8/26/10
to away3...@googlegroups.com
It might work, given that your base geometry is correct. BUT: that would be completely defying the purpose of bsp/pvs, since in that case you're basically doing the same thing as before, and perhaps even make it worse.

le_unam

unread,
Aug 26, 2010, 7:52:22 AM8/26/10
to Away3D.dev
ah okay ... i understand thank you = )

Fabrice3D

unread,
Aug 26, 2010, 9:02:30 AM8/26/10
to away3...@googlegroups.com
That's case "A" shown on my jpg.
To say it another way: everything that you can name "wall", "ceiling", "floor" should be builded using case B (using no evil cubes)
Stuff like doors, furnitures should be addChilded to tree.

Fabrice

bebensiganteng

unread,
Aug 31, 2010, 7:56:31 AM8/31/10
to Away3D.dev
hi guys,

i have another question regarding with the collision, is it possible
to assign an event listener to the mesh where i can listen for any
collision event which comes from either the BSP mesh or an added mesh
(such as the chair)

something like this perhaps?

myMesh.collider = true;
tree.addChild(myMesh);
myMesh.addEventListener(Event.COLLIDED, onCollided);

again thanks for the wonderful support and ingenious tool :D


myMesh.collider = true;
tree.addChild(myMesh);

David Lenaerts

unread,
Aug 31, 2010, 8:12:36 AM8/31/10
to away3...@googlegroups.com
Hey,

It's not built in my default, although I think Fabrice has had some experience doing things like that for a project :)
Sending out events from the BSP mesh itself is a bit hard and slightly pointless. Hard because you'd get a chunk of the bsp which probably wouldn't mean much to you as a "mesh". Pointless because in 99% of the cases (unless you're free-falling), you're colliding against the floor due to gravity. The best thing you can do is testing if your intended XZ position matches up with the actual position after moving it using the BSPCollider.

Cheers,
David

Fabrice3D

unread,
Aug 31, 2010, 8:26:18 AM8/31/10
to away3...@googlegroups.com
Look at BSPHitest class.
you will not get standard for perf reason all the data you need to identify a given mesh.

however the HitTest class does this on demand, either check a hit from a ray with simple return of intersection.
the second method, "getUVIntersectPosition", returns you an array, with position, meshname, uvs and map of the hitted face.
you can also envoke and not use the array by simply ask after you invoked the HitTest.lastHittedMeshName;

the names are to be compared with your known mesh names, obviously that will be only for the meshes added to the tree.

Fabrice

bebensiganteng

unread,
Aug 31, 2010, 9:25:59 AM8/31/10
to Away3D.dev
thank you sir :) will try and revert
Reply all
Reply to author
Forward
0 new messages