Well, that would work if i wanted to step thru all of the mesh
containers children and apply a material change to all faces in it,
BUT my issue is even before that. I only need to change OR update the
material property of ONE face that you happen to click on. Each Face()
object is inside its own Mesh() and there will be many of those groups
created, AND than those groups of items are inside a class file that
Extends ObjectContainer3D so i guess you have access to
ObjectContainer3D methods. A new instance is created of this class in
the MAIN class file where I add an invent listener to that instance as
below:

For now i just have one Face() inside one Mesh() and that i believe is
inside an ObjectCainter3D which is added to the SCENE in the MAIN
class, which is added to VIEW.

At first, this works perfectly to set the Face material property:
var mesh:Mesh = new Mesh();
     mesh.name = "H0";
var hex:Face = new Face();
     hex.material = new WireColorMaterial(0xFF0000, {alpha:0.2,
wireColor:0xFFFFFF, thickness:3});

In MAIN class:
private function mouseClick(e:MouseEvent3D):void
{
      trace(e.object)      //Traces "H0: x:0 y:0 z:0" where "H0" is
the name of the mesh ~ mesh.name="H0"
      trace(e.element)   //Traces NULL
      trace(e.material)   //Traces [object WireColorMaterial] So, it
can retrieve what its material property is, i just can't change it
after.


      //This does not update/change the Face objects color
     e.material = new WireColorMaterial(0xFF0000, {alpha:0.2,
wireColor:0xFFFFFF, thickness:3});

      //This does not update/change the Face objects color either
     var hex:Mesh =  gameGrid.getChildByName(e.object.name) as Mesh;
          hex.material = new WireColorMaterial(0x9BE0FD, {alpha:0.3,
wireColor:0xFFFFFF, thickness:3});

     //This gives me a NULL reference error
     var hex:Face =  gameGrid.getChildByName(e.object.name) as Face;
          hex.material = new WireColorMaterial(0x9BE0FD, {alpha:0.3,
wireColor:0xFFFFFF, thickness:3});
}

Seems like a simple thing, don't think its a bug If I draw a hex shape
using RegularPolygon or WireRegularPolygon, the above mouse event
method to change the color works just fine, granted in that case i had
to set ownCanvas=true otherwise i couldn't set the ALPHA and was
giving me null reference errors, BUT in the case of a FACE object, its
gotta be something simple i am missing.....Maybe after changing the
Face material, the objects have to be refreshed/rendered or etc again
to show up... but that is just a wild guess..... :) I have looked thru
a lot of away3D class files trying to find the material update method,
but nothing....





On May 5, 9:42 am, Reinorvak <[email protected]> wrote:
> From what I'm reading you're having the problem of being off by one.
>
> All faces are stored in a mesh, all meshes are stored in the grid, so
> you'll want something like this.
>
> for each(var mesh:Mesh in grid.children)
> {
>     for each(var face:Face in mesh.faces)
>         applyMaterails...
>
> }
>
> On May 5, 12:26 am, CyberHawk <[email protected]> wrote:
>
> > [Sorry about previous message(s), accidentally hit enter and it posted
> > it unfinished]
>
> > Ok, I messed around with the Face() object and it seems like it is
> > exactly what i was looking for, EXCEPT i can't figure out one tiny
> > thing as described below:
>
> > //In the SecondClass AS3 Class File (Extends ObjectContainer3D)
> > ------------------------------------------------------------------------------------------------
> > var hex:Face = new Face();   // Create Face object, in this example it
> > is a square
> >      hex.moveTo(0,0,0);
> >      hex.moveTo(-50, 0, 0)
> >      hex.lineTo(-50,0,-50);
> >      hex.lineTo(50,0,-50);
> >      hex.lineTo(50,0,50);
> >      hex.lineTo(-50,0,50);
> >      hex.lineTo(-50,0,0);
>
> >      // Set the material. This works great and it lets me set the
> > color of the face and it lets me change the outline of the Face to a
> > different color and thickness
> >      hex.material = new WireColorMaterial(0xff0000, {alpha:0.2,
> > wireColor:0xFFFFFF, thickness:2});
>
> >      //This is only so that i can assign a NAME to each hexagon so i
> > can retrieve it later because a Face() object does not have a ".name"
> > property.
> >      var mesh:Mesh = new Mesh();
> >           mesh.name = "hex1";
>
> >         mesh.addFace(hex);
> >         this.addChild(mesh);
>
> > That all works and is displayed fine on screen. I do not add a mouse
> > event to the Face() object in this class, but have tried that and it
> > did not work for me.
>
> > In the MAIN AS3 Class file: (Extends Sprite)
> > ----------------------------------------------------------------
> > grid:SecondClass = new SecondClass();
> > grid.addEventListener(MouseEvent3D.MOUSE_DOWN, mouseClick);
>
> > private function mouseClick(e:MouseEvent3D):void
> > {
> >         //This does not do anything, but also does not give any error
> > messages. This way works for other primitive objects, but not for a
> > Face(),
> >         var obj:Mesh =  grid.getChildByName(e.object.name) as Mesh;
> >              obj.material = new WireColorMaterial(0x9BE0FD, {alpha:0.2,
> > wireColor:0xFFFFFF, thickness:3});
>
> >         // This gives the Error #1009 Nulll Object Reference, so that
> > does not work..
> >         var obj:Face =  grid.getChildByName(e.object.name) as Face;
> >              obj.material = new WireColorMaterial(0x9BE0FD, {alpha:0.2,
> > wireColor:0xFFFFFF, thickness:3});
>
> > }
>
> > For kicks, i tried using ColorMaterial(), WireframeMaterial(), and
> > ShadingColorMaterial() but noting worked.
>
> > I am sure it is something VERY simple i am missing or don't yet
> > know.... any hints would be wonderful.. :)
>
> > Thank you again.
>
> > > > Thank you everyone for all of the suggestions and thanks Rob, i think
> > > > your way sounds like the way to go. I will mess around with it and see
> > > > where i get.
>
> > > > Last night i was figuring out how to draw lines in Away3D and never
> > > > could get Line2D to work, not without seeing some examples on how to
> > > > use it at least, BUT i did managed to get LineSegment() to work,
> > > > assign it a line thickness and color, and be able to add it to an
> > > > ObjectContainer3D so i can display it.
>
> > > > BUT as for a base object to draw lines on, I also got Sprite2D /
> > > > Sprite3D to display on screen, BUT its problem was that it is designed
> > > > to always face the camera and since i am using HoverCamera3D where the
> > > > hex plane or stage can be made to tilt and also pan across the screen,
> > > > that would not work for me. Besides, never figured creating a simple
> > > > SPRITE object would be so complicated in Away3D as compared to Native
> > > > Flash...lol... at least took a bit to figure out what worked without
> > > > assigning the Sprite an Bitmap image.
>
> > > > I was also hoping that an object similar to SHAPE() in Flash was
> > > > possible in Away3D as the SHAPE is something lightweight to draw on
> > > > but does not get bloated easily with extra stuff like MouseEvents or
> > > > etc. Also, in Native Flash you can actually draw different shapes
> > > > using either SPRITE or SHAPE and using drawPath and beingFIll/endFill
> > > > for color SO there had to be a way to do something similar in Away3D.
>
> > > > But, i think that FACE object in Away3D is just what i was looking for
> > > > so again thanks for everyone and will give that a try first and see
> > > > where i get.
>
> > > > On May 4, 3:27 am, Rob Bateman <[email protected]> wrote:
>
> > >> > > Hey CyberHawk
>
> > >> > > the best way to draw a hexagon in teh way you're desciubing is 
> > >> > > probably
> > >> > > using the drawing api on the face class. This is similar to the 
> > >> > > native
> > >> > > drawing api in flash, and just requires that you create a mesh 
> > >> > > object, and
> > >> > > add each face using something like:
>
> > >> > > var hex:Face = new Face();
> > >> > > hex.moveTo(p0X, p0Y, 0);
> > >> > > hex.lineTo(p1X, p1Y, 0);
> > >> > > hex.lineTo(p2X, p2Y, 0);
> > >> > > hex.lineTo(p3X, p3Y, 0);
> > >> > > hex.lineTo(p4X, p4Y, 0);
> > >> > > hex.lineTo(p5X, p5Y, 0);
> > >> > > hex.lineTo(p0X, p0Y, 0);
>
> > >> > > mesh.addFace(hex)
>
> > >> > > you can then apply materials to the face using the 'material' 
> > >> > > property, and
> > >> > > react to mouse events in the usual way etc
>
> > >> > > Rob
>
> > >> > > On Tue, May 4, 2010 at 7:42 AM, Peter Kapelyan <[email protected]> 
> > >> > > wrote:
> > >>> > > > You can also have a sort of dynamic or LOD material, or just a 
> > >>> > > > high-res
> > >>> > > > low-res version (high res shows if you are super close, and 
> > >>> > > > concerned with
> > >>> > > > it looking crappy). So Plane + png or bitmap will be your 
> > >>> > > > fastest, best bet.
> > >>> > > > Next best bet might be just to outline each shape with vector 
> > >>> > > > lines, but
> > >>> > > > you'll have to find a way to fill that shape, and it most likely  
> > >>> > > > won't be
> > >>> > > > as fast as what I said earlier.
>
> > >>> > > > -Pete
>
> > >>> > > > On Mon, May 3, 2010 at 5:21 PM, Reinorvak 
> > >>> > > > <[email protected]>wrote:
>
> > >>>> > > >> You can use the Plane method if you're clever about it. Depends 
> > >>>> > > >> on how
> > >>>> > > >> you use your picking. Just from using 3D experience though, 
> > >>>> > > >> Less faces
> > >>>> > > >> is usually the better option so I'd vote towards Line2D or 
> > >>>> > > >> Sprite.
>
> > >>>> > > >> As for zooming in and out, I've seen little effect on PNGs 
> > >>>> > > >> really
> > >>>> > > >> unless you get really really really close to these 
> > >>>> > > >> models/images/etc.
> > >>>> > > >> If you can make the texture repeatable, you could do it simply 
> > >>>> > > >> with
> > >>>> > > >> one giant plane, and repeat the texture across it till you're
> > >>>> > > >> satisfied, unless it needs to be more dynamic then that. You'd 
> > >>>> > > >> have a
> > >>>> > > >> square map, with a hexagonal field.
>
> > >>>> > > >> On May 3, 5:12 pm, CyberHawk <[email protected]> wrote:
> > >>>>> > > >> > Well, i don't what to use a PLANE as that means my grid has 
> > >>>>> > > >> > to be
> > >>>>> > > >> > square in shape. I need/would like to create a hexagon 
> > >>>>> > > >> > shaped grid. I
> > >>>>> > > >> > have thought about just creating a PNG image of a hexagon 
> > >>>>> > > >> > with a
> > >>>>> > > >> > partial transparent background and a certain color outline 
> > >>>>> > > >> > in like
> > >>>>> > > >> > Photoshop or similar, BUT that means if i later change 
> > >>>>> > > >> > something, i
> > >>>>> > > >> > have to recreate it ever time. Not saying it is hard or 
> > >>>>> > > >> > anything, but
> > >>>>> > > >> > it makes it less dynamically generated. If that is the ONLY 
> > >>>>> > > >> > way to do
> > >>>>> > > >> > it, i definitely will have to do it that way as this issue 
> > >>>>> > > >> > is holding
> > >>>>> > > >> > back my project, but i was hoping to find a way to draw the 
> > >>>>> > > >> > hexagons
> > >>>>> > > >> > instead of creating a PNG. It is not an absolute requirement 
> > >>>>> > > >> > to be
> > >>>>> > > >> > partially transparent, it could be completely transparent, 
> > >>>>> > > >> > but i did
> > >>>>> > > >> > not try that yet as i wasn't sure how the PNG would look 
> > >>>>> > > >> > like once you
> > >>>>> > > >> > zoom in and out on the grid, as in if it will distort the 
> > >>>>> > > >> > image or
> > >>>>> > > >> > not.
>
> > >>>>> > > >> > On May 3, 4:59 pm, Peter Kapelyan <[email protected]> 
> > >>>>> > > >> > wrote:
>
> > >>>>>> > > >> > > Why not just use a plane (two polys) with a MovieClip or 
> > >>>>>> > > >> > > regular
> > >>>> > > >> bitmap
> > >>>>>> > > >> > > (png?). The mouse *should detect the parts that are 
> > >>>>>> > > >> > > transparent as
> > >>>>>> > > >> > > unclickable, so you can have hundreds of those, quite 
> > >>>>>> > > >> > > possibly.
>
> > >>>>>> > > >> > > -Pete
>
> > >>>>>> > > >> > > On Mon, May 3, 2010 at 4:35 PM, CyberHawk 
> > >>>>>> > > >> > > <[email protected]>
> > >>>> > > >> wrote:
> > >>>>>>> > > >> > > > I have such a simple problem/issue/question that i 
> > >>>>>>> > > >> > > > can't seem to
> > >>>> > > >> find
> > >>>>>>> > > >> > > > quite the answer to without asking. So, I am using 
> > >>>>>>> > > >> > > > Away3D 3.5
> > >>>> > > >> (Latest
> > >>>>>>> > > >> > > > as of this question 5-3-10) and for starters all i am 
> > >>>>>>> > > >> > > > trying to do
> > >>>> > > >> is
> > >>>>>>> > > >> > > > create a hexagonal shaped grid using smaller hexagons. 
> > >>>>>>> > > >> > > >  The MAIN
> > >>>>>>> > > >> > > > purpose for this larger hexagon grid is so you can 
> > >>>>>>> > > >> > > > drag other 3D
> > >>>>>>> > > >> > > > objects to it from a list later on and the grid 
> > >>>>>>> > > >> > > > accepts mouse clicks
> > >>>>>>> > > >> > > > so you can select the hexagons.
>
> > >>>> > > >> -----------------------------------------------------------------------------------------------
> > >>>>>>> > > >> > > > I am creating one hexagon shape (Side=6) using the 
> > >>>>>>> > > >> > > > object type
> > >>>>>>> > > >> > > > "RegularPolygon", Radius=57, and i am using that as a 
> > >>>>>>> > > >> > > > BASE since i
> > >>>>>>> > > >> > > > want to set a color to it, an “alpha= 0.3, 
> > >>>>>>> > > >> > > > ownCanva=true”, to make
> > >>>> > > >> it
> > >>>>>>> > > >> > > > partially transparent so the background show's thru 
> > >>>>>>> > > >> > > > and i need to
>
> ...
>
> read more »

Reply via email to