2 Problems: with textures and intersecting objects.

Software: Away3D 4.x

Parez, Newbie
Posted: 11 January 2012 01:40 PM   Total Posts: 11

Hi everyone. I started to learn Away3D engine only yesterday and I have few questions.. Firstly, I have a problem with intersecting objects. I created some Cubes of the same height, some of which intersect with each other and when moving the camera there is a bug in the place of the intersection: one “random” cube overlaps others. And it looks terrible. Is there a way to create something like spline of primitives so that unneeded parts (like place of cubes intersection) are not displaied. Here you can see how it looks like:
http://parez.emo.su/Maze.html
To move the camera, click and drag the mouse.
The other problem that you can also see through this link is the texture display. All walls in the maze use same material: http://xmages.net/i/3306372 The p.roblem is that though the “repeat” property of the material is set to true, texture doesn’t tile. The worst thing is that if you look at horizontal walls, you’ll see that texture actually stretchs to fit the size of the cube. How can I make texture not stretch across the cube, but repeat or sometimes (if it is bigger than the cube’s surface) crop?

p.s.
By “create something like spline” I mean the following:
For example I have two cubes looking like “|_” and I want to combine them into one complex figure like “L”

   

Avatar
Fabrice Closier, Administrator
Posted: 11 January 2012 02:07 PM   Total Posts: 1265   [ # 1 ]

The geometry is incorrect. It overlaps.
You should consider LinearExtrude…  Here a very old example in 2.x.
http://www.closier.nl/blog/?p=57
You would this way also prevent to use the cube class which is not really made for this kind of application. Take a look at the 2d demo of the principle behind to see why.

You need also to define the way materials are repeated along u and/or v axis. You need to pass the factors per geometry. mymesh.geometry.scaleUV(1,3);  Another reason to avoid Cubes.

Finally, I would use the Merge class to ensure there are not too much objects in the scenery.

   

Parez, Newbie
Posted: 11 January 2012 02:51 PM   Total Posts: 11   [ # 2 ]

Thanks a lot. Very helpful information, I haven’t noticed this class.
And you said that textures problems is

Another reason to avoid Cubes

. You mean that if I use LinearExtrude class, I will not have to specify the factors per geometry like I had to do with Cubes?

And are there any articles on LinearExtrude class implementation?

   

Avatar
Fabrice Closier, Administrator
Posted: 11 January 2012 04:38 PM   Total Posts: 1265   [ # 3 ]

That’s up to you! Note that the class has on itself has also mapping options.
the maps are for instance, set 0-1 for each segment. so if you define your maze using “cubical cells” each and every segment would have same length, and since they can be applied per segment, a perfectly square map would do just fine. Repeat would not even be required, only a perfectly seamless map.

Also we have in tools a projector class. So you could project your map from top for instance and define the way it needs to be repeated. You probably would have in this case to isolate the walls and top parts and project before merge.

   

Parez, Newbie
Posted: 12 January 2012 09:16 AM   Total Posts: 11   [ # 4 ]

Sorry for my stupidity. I’m newbie to 3D programming. Can you give me an example code of using LinearExtrude class, please? Thanks.

   

Avatar
Fabrice Closier, Administrator
Posted: 12 January 2012 09:42 AM   Total Posts: 1265   [ # 5 ]

There are a few extrusions examples in older broomstick examples repo. Once we reach final 4.0, we’ll add examples.
The example functions should work with no or little work.

   

Parez, Newbie
Posted: 12 January 2012 10:08 AM   Total Posts: 11   [ # 6 ]

Thanks, I’ve found an example. By the way, there is a small mistake in the documentation. In the LinearExtrude class where constructor function parameters are described. Lines of parameters’ descriptions don’t match with the names of parameters. I mean this:


material:MaterialBase (default = null) — [optional] Vector.<Vector3D>. A series of Vector3D’s representing the profile information to be repeated/rotated around a given axis.

vectors:Vector.<Vector3D> (default = null) — [optional] String. The axis to elevate along: X_AXIS, Y_AXIS or Z_AXIS. Default is LinearExtrusion.Y_AXIS.

axis:String (default = NaN) — [optional] Number. The elevation offset along the defined axis.

offset:Number (default = 10) — [optional] uint. The subdivision of the geometry between 2 vector3D. Default is 32.

and so on.

____________________________________________________
I tried to draw closed path with LinearExtrude class, but it closes it incorrectly. The junction of walls (from last point to start point) doesn’t look holistic. It has a gap.
____________________________________________________
I found out why the junction had a gap. If I set walls width to something different from 0, extrusion closes incorrectly as the origin point is in the center of the wall. So I have to close path manually. I changed my code to this:

wallsVectors.push(new Vector3D(0,wallWidth/2,-2));
wallsVectors.push(new Vector3D(mazeMatrix[0].length*pathWidth,wallWidth/2,-2));
wallsVectors.push(new Vector3D(mazeMatrix[0].length*pathWidth,mazeMatrix.length*pathWidth,-2));
wallsVectors.push(new Vector3D(wallWidth/2,mazeMatrix.length*pathWidth,-2));
wallsVectors.push(new Vector3D(-wallWidth/2,0,-2)); 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X