away3d / away3d-core-fp10

Away3D engine for Flash Player 10
http://www.away3d.com
33 stars 11 forks source link

Change segments at run time, uv mapping error bug? #21

Open Neugls opened 12 years ago

Neugls commented 12 years ago

If you changes the segments of Plane or Cube which I have noticed, the result may have UV mapping error. I have the following code

                    plane = new Plane();
        plane.width = 500;
        plane.height = 500;
        plane.bothsides = true;
        plane.segmentsH = 1;
        plane.segmentsW = 1;
        plane.material = new BitmapFileMaterial("");
        scene.addChild(plane);

        StartToRender();
        stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
    }

    protected function onKeyDown(E:KeyboardEvent):void{
        if(E.keyCode == Keyboard.F3){
            plane.width += 3;
            plane.segmentsW ++
        }
        if(E.keyCode == Keyboard.F4){
            plane.height += 3;
            plane.segmentsH ++
        }
    }
richardolsson commented 12 years ago

Although we have not made any official decisions regarding supporting old versions of the engine, I'm afraid that it's unlikely that this bug will be fixed for Away3D 3.6, now that stable Flash Player 11 has been out for almost a year, and Away3D 4.0 was first published a year ago. All our effort is going towards further developing the total rewrite of the engine that is Away3D 4.x.

Neugls commented 12 years ago

Thank you for reply, can you give me any tip for me what can i do to fix this for I have an old project used away3d 3.6, I think I should make it fixed before using the Away3d 4.x


Neugls Work Studio Neugls NeuglsWorkStudio@gmail.com

Neugls commented 12 years ago

I think I have found out where caused this problem after a days time reading the source code of Away3d 3.6. This bug may appear when you use the BitmapMaterial, For the render rendering a triangle face, it calls the renderTriangle method of the BitmapMaterial. In BitmapMaterial, it used a dictionary called _faceDictionary to store the uvt data of the face , when the uv data changed in the faces, the _faceDictionary did not changes, so it caused the problem. To sets the invalidated property of the _faceMaterialVO in dictionary _faceDictionary may fix this bug. I extends the BitmapMaterial and add a new method to update this, it works.

richardolsson commented 12 years ago

Feel free to file a pull request if you fix the issue in the Away3D code.