Walking through a room

40 views
Skip to first unread message

le_unam

unread,
Jun 9, 2010, 8:20:55 AM6/9/10
to Away3D.dev
Hey guys i have some basic questions about creating a room and walking
through it. i have already created a room and i am able to walk
through but i dont know if i took the right way to create it. Now i
just want to get some general questions.

For the First person view, to walk through my room i decided to took
the SpringCam. Would you use SpringCam too or is there an other, maybe
better way? My Problem with SpringCam is that the relations of Walls,
floor and roof seem to be broken. if i take the measurments of my room
at home and project them to away3d it seems to be incorrect. my walls
at home are 2,20 meters so i tried to make 220px in away. my cube,
which i follow with springcam, i place at y = 180 because i thought, i
am 1,80meters. but this gets a bad result in relation to the other
elements. You know? what is a good way to go there? i can solve this
problem if i set the height down and keep the widths but that isnt
what i want.

Another question is how to create a room. I created my rooms
exclusively by taking planes for each wall or floor or roof, but some
guys say you should use a cube. Of yourse when i just want to create
an easy room with 4 walls i can take a cube but what when the room has
no symmetrie or for example windows? Is there a trick to handle this
or are planes the right way?

In dependence on this ... how to create a rounded wall or other
rounded selfmade elements? What can i use? I heared something about
SegmentExtrude, LinearExtrude or PathExtrude but i cant get detailled
information about this classes and how to handle them. What leads to
my last point.

What is the best way to get used with away3d? How can i learn away3d
the best way? Where should i have the information how to use
SegmentExtrusion for example. It seems to be more than two lines of
code. if someone takes the time to help me and answer me my questions
i would be very happy and grateful.

Sorry for my bad english.

Greetz Manu

David Lenaerts

unread,
Jun 9, 2010, 8:38:03 AM6/9/10
to away3...@googlegroups.com
I would use a 3D modeler to create that (well, if I could model). It's really not easy to do it by compositing planes etc, and would probably not result in efficient models.
You could use Blender, for instance: it's free, but it's user interface is sent from hell. You can export it in a format compatible with Away3D (for instance as an obj file). If you use PreFab and model to some restrictions, you can use Prefab3D and the BSP builder to get the walk-around for free :)

joebass

unread,
Jun 9, 2010, 8:52:58 AM6/9/10
to Away3D.dev
As far as camera and movement other than what David mentioned, I'm
working on something similar and found the Frustum Hotel Room demo to
be a great help.
> --http://www.derschmale.com- Hide quoted text -
>
> - Show quoted text -

le_unam

unread,
Jun 9, 2010, 9:08:50 AM6/9/10
to Away3D.dev
Thanks for your fast answers.

I have PreFab installed, but i`m not really used to it, so i have to
learn how it works. Of course to model all elements is a way i knew
before but i thought loading models would slow down the swf. Doesnt
it?

I know frustum hotel room demo and i got some great help from it too,
but all in all i think it contains too much information, that i can
understand the background behind all. i tried to take the collisionmap
from there but i didnt get it work = (
Is there any example in the web with an collisionmap for an easy room
with only one cube in the center so that everybody can understand it?
all examples are so complicated i think, it has to be more easier.
> > --http://www.derschmale.com-Hide quoted text -

joebass

unread,
Jun 9, 2010, 10:46:16 AM6/9/10
to Away3D.dev
I'm a newbie so take my comments with a grain of salt. My
understanding is that loading models as opposed to constructing in
Away with the extrude classes or primitives will require more
resources. However, it may be difficult to do everything you'd like
within the native Away classes. If you do use a 3D modeler, get it
into PreFab and use the export features, adding your models within
your code is a breeze. So cool Fabrice.

As far as the collision map stuff with the Frustum example, it was a
challenge for me to adopt them too. It took some playing around with
the orientation of the collision map image (I added a plane and
applied the map image to it to get an idea of orientation. Also
scales of the collision image and your model are things you may have
to look at. Then it's just a matter of applying your geometry to the
image with trial and error.
> > > --http://www.derschmale.com-Hidequoted text -
>
> > > - Show quoted text -- Hide quoted text -

Fabrice3D

unread,
Jun 9, 2010, 11:48:43 AM6/9/10
to away3...@googlegroups.com
the collisionmap class is nothing than a color map reader.
that would be for instance the map seen from above.
each kind of element having its own color.

the class, at runtime, once you pass it a coordinate x,y on the map (the x,z of the camera in ratio), reads the colormap.
if a color is found that you have declared, it fires an event.

so the class doesn't handle the collision
if you set say where your table is a yellow region on that map
basically after you have set the "color" listener, it triggers on the yellow reading

collisionmap = new CollisionMap(mycolormap, this, 1 , 1); //here 1/1 ratio on x and y. if your floor is say 2048x2048 and map 1024x1024, pass 2,2
collisionmap.setColorEvent(0xFFFF00, "yellow", onYellow);

private function onYellow(event:Event):void
{
trace("WARNING this is an valuable furniture, look out!!";
}

what you do with the collision reading, is up to you. Bartek, for instance, for its circuit game, used a similar construction
where the color was different from the main road. --> slowDown();

but when it comes to real collision handling, i would consider take a look at BSP generation as David suggested,
in fact thats the reason why we've spend the time and effort to make it in the first place.

as a side note, take care making the colormap, if you use flash lib and the source is not a vector info that you draw, that
compression, might influence the colors. so no event is triggered. So either you apply a custom threshold to the class,
or the easy way, test the colors at locations you know the exact color. There is a getter just for that reason in the class.

Fabrice

le_unam

unread,
Jun 10, 2010, 2:53:58 AM6/10/10
to Away3D.dev
Hey thanks ... i tried it, but i got an error and i dont know why ...

-------------------------------------------------------
myCollision = new BitmapData(Cast.bitmap(collision));
myCollisionmap = new CollisionMap(myCollision, 10, 10);
myCollisionmap.setColorEvent(0xFF0000, "red", onCollision);

myCollisionmap.read(myEyes.x, -myEyes.z);

public function onCollision()
{
trace("berührt");
}

---------------------------------------------------------

Can you check it?
Thanks = )
> >>>> --http://www.derschmale.com-Hidequotedtext -

Fabrice3D

unread,
Jun 10, 2010, 3:58:43 AM6/10/10
to away3...@googlegroups.com
What error? Missing one param? --> onCollision(e:Event) may be?

Fabrice

le_unam

unread,
Jun 10, 2010, 4:26:35 AM6/10/10
to Away3D.dev
i try to translate it with my english:

----------------
myCollision = new BitmapData(Cast...... === implicit compilation
of the value flash.display:BitmapData to an unrelated type int.
===
wrong number of arguments. two needed.
----------------

why int? i have declared it as BitmapData so i cant find the problem,
but maybe this error will go away with the others? I cant understand
this because i did it the same way like the other materials for
example.

---------------
myCollisionmap = new CollisionMap(myCollision, 10, 10); === access of
an undifined property myCollisionmap.
---------------
why undifined? How to define it? In my Class i say private var
myCollisionmap:CollisionMap;
Where is the error? = (

le_unam

unread,
Jun 12, 2010, 5:10:09 AM6/12/10
to Away3D.dev
Fabrice? Can you please help me? Or maybe someone else? = (

le_unam

unread,
Jul 9, 2010, 3:10:15 AM7/9/10
to Away3D.dev
Can anyone please help me with collision map? i spend so much time for
this now, but it doesnt work = (

Fabrice3D

unread,
Jul 9, 2010, 4:22:31 AM7/9/10
to away3...@googlegroups.com
> i spend so much time for this now, but it doesnt work = (
If you expect some guidance, you have to tell bits more.

reading at your previous questions, these were as3/synthax related issues.
wrong params to constructors or wrong types..

Are you still stuck with the same issues?

Fabrice

le_unam

unread,
Jul 9, 2010, 5:33:54 AM7/9/10
to Away3D.dev
hey fabrice thank you ... well i tried to make an easy example for
collision map. i created a cube, which is followed by the camera and a
plane with the texture of the collisionmap for easy understanding. but
i still get an error ... maybe you can check my code for syntax
problems. it would be very nice.


code --------------------------------------------------------------

package
{
import away3d.cameras.SpringCam;
import away3d.containers.*;
import away3d.core.base.Object3D;
import away3d.core.clip.FrustumClipping;
import away3d.core.math.Number3D;
import away3d.core.render.Renderer;
import away3d.core.utils.Cast;
import away3d.extrusions.CollisionMap;
import away3d.materials.*;
import away3d.primitives.*;

import flash.display.DisplayObjectContainer;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;

[SWF(width="800", height="600", frameRate="30", quality="LOW",
backgroundColor="0xFFFFFF")]
public class colltest extends MovieClip
{
private var myScene:Scene3D;
private var myCamera:SpringCam;
private var myClipping:FrustumClipping;
private var myCube:Cube;
private var myView:View3D;
private var myCollision:BitmapData;
private var myCollisonmap:CollisionMap;

private var keyIsDown:Boolean = false;
private var keyHandler:Number = 0;

private var myBoden:Plane;

public function colltest()
{
initEngine();
initObjects();
initEventListeners();
}

public function initEngine()
{
myScene = new Scene3D;
myCamera = new SpringCam;
myClipping = new FrustumClipping;

myView = new View3D( { scene:myScene, camera:myCamera,
clipping:myClipping, renderer:Renderer.CORRECT_Z_ORDER,
x:stage.stageWidth / 2, y:stage.stageHeight / 2 } );
addChild(myView);

myScene.addChild(myCamera);

myCube = new Cube( { width:1, height:1, depth:1 } );
myScene.addChild(myCube);

myCamera.zoom = 10;
myCamera.focus = 100;
myCamera.mass = 10;
myCamera.damping = 10;
myCamera.stiffness = 10;
myCamera.target = myCube;
myCamera.lookAt(myCube.position);
myCamera.lookOffset = new Number3D(0, 0, 100);
myCamera.positionOffset = new Number3D(0, 0, 50);

myCollision = new BitmapData(Cast.bitmap(cmap));
myCollisionmap = new CollisionMap(myCollision, 1, 1);
myCollisionmap.setColorEvent(0xFF0000, "red", onCollision);

myView.render();
}

public function initObjects()
{
var myMaterial:BitmapMaterial = new
BitmapMaterial(Cast.bitmap(cmap));
myBoden = new Plane ( { material:myMaterial, width:1000, height:
1000, y: -stage.stageWidth / 2 } );
myScene.addChild(myBoden);
}

public function onCollision()
{
trace("berührt");
}

public function initEventListeners()
{
addEventListener(Event.ENTER_FRAME, initEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUp);
}

public function keyDown(e:KeyboardEvent):void
{
keyIsDown = true;
keyHandler = e.keyCode;
}

public function keyUp(e:KeyboardEvent):void
{
keyIsDown = false;
}


public function initEnterFrame(e:Event):void
{
if (keyIsDown)
{
switch(keyHandler)
{
case 65: myCube.moveLeft(20); break;
case 68: myCube.moveRight(20); break;
case 87: myCube.moveForward(20); break;
case 83: myCube.moveBackward(20); break;
}
}

myCollisionmap.read(myCube.x, -myCube.z);

myCamera.view;
myView.render();
}
}

}

codeend -------------------------------------------------------

maybe i forgot something to import? i dont know .... do you see any
errors?
if i comment the lines of collisonmap out ... i can walk over the
plane with the collisionmap texture.

greetings manuel

le_unam

unread,
Jul 9, 2010, 8:00:11 AM7/9/10
to Away3D.dev
hey fabrice okay now there are no more errors ... it was an syntax
problem. But the collisionmap isnt still working. nothing happens when
walking over the "red" area = (
where can be the mistake? the y position of the cube doesnt matter
right?
what about the offset position of the map? ist it necessary to set it?

best regards

Fabrice3D

unread,
Jul 9, 2010, 9:10:20 AM7/9/10
to away3...@googlegroups.com
you have a scale ratio 1, 1 passed to class

trace your x and -z when you ask the "read"
they are probably exceeded the bounds of your map.

try attach on top of your scene this map or a duplicate, and setPixel at this coords...
i bet you are way off.

Fabrice

le_unam

unread,
Jul 9, 2010, 10:06:48 AM7/9/10
to Away3D.dev
hey thanks for your answer ... i will try this ... the scale ratio 1,1
is because my plane is width:1000, height:1000 and my map is width:
1000, height:1000 too.
maybe there is an offset problem or something like this. thanks

le_unam

unread,
Jul 9, 2010, 10:41:18 AM7/9/10
to Away3D.dev
okay ehm the x and z values seem to be correct. on startup it is 0, 0
when i move forward it counts ... -20 -40 -60 -80 -100 .... and so on.
but why should is use -z? whats the matter with the -? can u please
explain it to me?
what about the offset position of the map? where is the startpoint?
lower left corner = 0, 0 ?
> ...
>
> Erfahren Sie mehr »

le_unam

unread,
Jul 9, 2010, 10:46:07 AM7/9/10
to Away3D.dev
okay ehm the x and z values seem to be correct. on startup it is 0, 0
when i move forward it counts ... -20 -40 -60 -80 -100 .... and so on.
but why should is use -z? whats the matter with the -? can u please
explain it to me?
what about the offset position of the map? where is the startpoint?
lower left corner = 0, 0 ?

On 9 Jul., 16:06, le_unam <le_u...@hotmail.de> wrote:
> ...
>
> Erfahren Sie mehr »

Fabrice3D

unread,
Jul 9, 2010, 11:54:13 AM7/9/10
to away3...@googlegroups.com
because uv's are 1 where in flash they'll be 0
and one where you would expect a height value

then, this is important make sure the color you test on IS the color you think it is...

make a test at a position on the map you know its say "yellow"
check the reading value and the one you entered for the event.
due to compression algo's if you use a bitmap color might change

fix is to draw with vector movieclips, and draw this movieclip into bitmap runtime.

again, to test addchild your map above, and plot the readings and trace the colors to see if correct
the class as a special test call for this purpose --> doc

Fabrice

le_unam

unread,
Jul 12, 2010, 5:00:46 AM7/12/10
to Away3D.dev
hey fabrice ... thank you sooo much. The getcolor information did
help. the problem was that my "red" in the picture was compressed from
#ff0000 to #fe0000. Dont know why but its okay ... now it works
great .... big big thanks :-*
> >>>>walkingover the "red" area = (

le_unam

unread,
Jul 12, 2010, 5:02:24 AM7/12/10
to Away3D.dev
hey fabrice ... thank you sooo much. The getcolor information did
help. the problem was that my "red" in the picture was compressed from
#ff0000 to #fe0000. Dont know why but its okay ... now it works
great .... big big thanks :-*

On 9 Jul., 17:54, Fabrice3D <fabric...@gmail.com> wrote:
> >>>>walkingover the "red" area = (

le_unam

unread,
Jul 13, 2010, 2:43:57 AM7/13/10
to Away3D.dev
ehm okay, now there is another small problem ... the collisionmap is
at the wrong position. Is there a way to change it? i tried offset but
i dont know how offset works. i placed a plane with the texture off my
collisionmap withouth setting any x and z values. so its equal to the
collisionmap and works fine, but if i set the plane.x = 150 and
collisionmap.offsetX = 150 its not the same ... why? can anybody
explain what offset does? thank you = )
> ...
>
> Erfahren Sie mehr »

Fabrice3D

unread,
Jul 13, 2010, 3:33:02 AM7/13/10
to away3...@googlegroups.com
The default is set to center of the map, yet reading a bmd is allways topleft.
so you define as cm.offsetX = cm.offsetX-150; or + 150 if you have a your Plane in negative x;
The way you have define now, works, but the readings are made in world x/z positive quadrant only.

its confusing but very simple. Try think from top of your scene that the -x and -z of your sceneobjects bounds
are the top left on the map, the x and z of the object must be the downright. if your map is smaller than the object bounds units
just define the factorX and Y in ratio.

Fabrice

Reply all
Reply to author
Forward
0 new messages