Multiple materials on each face of the CUBE and when clicked on any material it should be handled differently

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple materials on each face of the CUBE and when clicked on any material it should be handled differently

Mahesh
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hi

I am implementing a cube with composite material. Till now most of the issues resolved except the bellow ones.
Goals are:
1. On each face of the CUBE we can have .gif or .jpg any kind of image say size may be 300x300. And on each face I should be able to place another image say 50x50 image at x=50 and y=70.
2. Then clicking on each image I should be able handle click event differently. For ex: If clicked on 50x50 image it should be handled differently. Basically i should get its respective material object.

Problems which I am facing are:
1. When a .gif image is face of the cube and a .jpg is place on top of it, whatever the image's size is, it occupies whole face(if 300x300 is cube face and 50x50 is the top placed image, it becomes 300x300) .As BitmapMaterial does not have a rectangle as in case of MovieMaterial we have it, so that we can place an image at particular x, y position on the cube face using this rectangle.

if both are MovieMaterial the no issues, and even placing MovieMaterial on to of face which is BitmapMaterial, it is fine.

2. Click on Face and on placed image should trigger their respective web link
From the library what I see is when cube is created CompositeMaterial is treated as whole material even it is having maltiple materials inside it. So I am always getting CompositeMaterial instead the respective material object where mouse is clicked.

Any kind help is appreciated. Please help me to fix these issues.

Here is my cube construction

public var sphereGroup:DisplayObject3D;
                        public var material1:Object;
                        public var material2:Object;
                        public var material3:Object;
                        public var material4:Object;
                        public var material5:Object;
                        public var material6:Object;
                        private var layer:ViewportLayer;
                        private var _mainCube:DisplayObject3D;
                        private var _mList:MaterialsList;
                        private function done(e:Event = null):void{
                                view = new CustomView(this.screen.width,this.screen.height,false);
                                view.viewport.interactive = true;
                        // view.viewport.buttonMode = true;
                                material1 = getMaterial(0);
                                material2 = getMaterial(1);
                                material3 = getMaterial(2);
                                if(m_objDataObject.m_nTotalImages == 4){
                                        material4 = getMaterial(3);
                                }
                                //As of now face 5 and 6 are hidden so no need to add ctas, its just a dummy face
                                material5 = getMaterial(0);
                                material6 = getMaterial(0);
                               
                                material1.tiled = true;
                                material1.smooth = true;
                                material1.tiled = true;
                                material2.smooth = true;
                                material3.tiled = true;
                                material3.smooth = true;
                                if(m_objDataObject.m_nTotalImages == 4){
                                        material4.tiled = true;
                                        material4.smooth = true;
                                }
                                material6.smooth = material5.smooth = true;
                                var adjust:Number = this.screen.width/4;
                                if(m_objDataObject.m_nTotalImages == 3)
                                        cube = new Cube(new MaterialsList({front:material3,back:material1,left:material3,right:material2,top:material5,bottom:material6}),this.screen.width-adjust,this.screen.width-adjust,this.screen.height-adjust,10,10,10);
                                else
                                        cube = new Cube(new MaterialsList({front:material3,back:material1,left:material4,right:material2,top:material5,bottom:material6}),this.screen.width-adjust,this.screen.width-adjust,this.screen.height-adjust,2,2,2);
                                _mainCube = new DisplayObject3D();
                                view.scene.addChild(_mainCube);
                               
                                canvasElement.rawChildren.addChild(view);
                                cube.rotationY = 0;
                                cube.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK,navigateOnClick);
                                this.addEventListener(Event.ENTER_FRAME, rotateObject);
                                eism = new ExtendedInteractiveSceneManager(view.viewport);
                        }


Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Multiple materials on each face of the CUBE and when clicked on any material it should be handled differently

Mahesh
This post has NOT been accepted by the mailing list yet.
RenderHitData object always stores values of cube face when mouse is hovered on it. But as I am using composite material onMouse should store actual material object's(face) values. I tried many changes but nothing succeed.