WOW... what a silly thing to get stuck on....and what a simple solution...... I guess many ways to do the same thing, not enough knowledge to know them all.....lol
THIS worked perfectly..... WireColorMaterial(e.material).wireColor = 0xFF0000; A thousand thanks... :) On May 5, 11:55 am, Reinorvak <[email protected]> wrote: > Try this method instead. > > var mesh:Mesh = gameGrid.getChildByName(e.object.name) as Mesh; > for each(face:Face in mesh.faces) > { > face.material = new WireColorMaterial(0xFF0000, {alpha:0.2, > wireColor:0xFFFFFF, thickness:3}); > > } > > With this you're getting the cell you want selected, and then no > matter how many faces you put inside the object, you'll update them > all. > > I don't think you'll need to assign an entirely new material either so > trying something like: > > WireColorMaterial(face.material).color = 0xFF0000; > > That is if all you're looking for is to change the color, can do the > same way with other properties. > > On May 5, 11:39 am, CyberHawk <[email protected]> wrote: > > > 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 > > ... > > read more »
