Change segments at run time, uv mapping error bug?

Software: Away3D 3.x

Neugls, Newbie
Posted: 13 August 2012 09:34 AM   Total Posts: 5

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 ++
      }
  }

   

Neugls, Newbie
Posted: 14 August 2012 08:00 AM   Total Posts: 5   [ # 1 ]

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.

grin

 

   

Richard Olsson, Administrator
Posted: 14 August 2012 10:51 AM   Total Posts: 1192   [ # 2 ]

Great, I’m glad you were able to solve it. If you want to modify BitmapMaterial (or any other part of the engine) to fix this bug, please feel free to file a pull request to the away3d-core-fp10 repository on GitHub and we could potentially merge it.

 

   

Neugls, Newbie
Posted: 03 December 2012 08:25 AM   Total Posts: 5   [ # 3 ]

Sorry for long time to response to you. downer

I am honored that I was able to have the opportunity to contributing a little to away3d

I have changed two files, BitmapMaterial.asand TransformBitmapMaterial.as, added one function, modified two function.

I have added function:

arcane function InvalidateFaceVO():void{
   
for each (_faceMaterialVO in _faceDictionary)
 
_faceMaterialVO.invalidated true;

in BitmapMaterial.as  at line 83, and added one line:

InvalidateFaceVO(); 

in function updateMaterial of BitmapMaterial and TransformBitmapMaterial.

The attachment comes with the final files.

 

File Attachments
modified_files.zip  (File Size: 10KB - Downloads: 311)
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X