Can someone help me about Away3D’s performance?

Software: Away3D 4.x

Raino, Newbie
Posted: 23 January 2013 07:22 AM   Total Posts: 12

I create 50 Characters(everyone has 4 Sprite3D for body,cloth,hair,weapon)
Totally 200 Sprite3Ds,200 Mesh for ShadowCircle.
Only 400 polys,CPU high,performance lower.
Can any one help?

 

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 23 January 2013 08:16 AM   Total Posts: 166   [ # 1 ]

Show your code. We can’t know your problem.
Do you use clone() method?

   

Raino, Newbie
Posted: 23 January 2013 08:41 AM   Total Posts: 12   [ # 2 ]

Thank you for reply,GoroMatsumoto.
I’ll try to post the key codes first.
for full codes,I need sometime to make it readable.

First I make 2 layers to contain ground plane and characters.
Allow me to make 2D-sprites on 3D-map.

//create scene and viewport
var scene:Scene3D = new Scene3D();
_viewMap = new View3D();
_viewMap.stage3DProxy=stage3DProxy
_viewMap
.shareContext=true;
_viewMap.antiAlias 4;
_viewMap.scene scene;
_viewMap.camera _camera;
Config.main.addChild(_viewMap)

var 
scene:Scene3D = new Scene3D();
_view = new View3D();
_view.stage3DProxy=stage3DProxy
_view
.shareContext=true;
_view.antiAlias 4;
_view.scene scene;
_view.camera _camera;
_view.mouseChildren=false
_view
.mouseEnabled=false
Config
.main.addChild(_view)
- - - - - - - - -
//render loop
stage3DProxy.clear();
stage3DProxy.context3D.setDepthTest(false,Context3DCompareMode.ALWAYS)
_viewMap.render();
stage3DProxy.context3D.setDepthTest(true,Context3DCompareMode.LESS)
_view.render();
stage3DProxy.present(); 

For the character,I create a Clip class extends Sprite3DForClip,slightly changed from Sprite3D.
Then I can make animation by updateUVData,Thanks to Babylon for this point.

//make _geometry of Sprite3D isn't static
private var _geometry SubGeometry;
- - - - - - - - -
//new method updateUVData,reverse means left-right reverse
public function updateUVData(uvs Vector.<Number>,reverse:Boolean=false) : void
{
 
if(reverse){
  
var newuv:Vector.<Number>=new Vector.<Number>();
  
newuv[0]=uvs[2]
  newuv[1]
=uvs[3]
  newuv[2]
=uvs[0]
  newuv[3]
=uvs[1]
  newuv[4]
=uvs[6]
  newuv[5]
=uvs[7]
  newuv[6]
=uvs[4]
  newuv[7]
=uvs[5]
   
  _geometry
.updateUVData(newuv)
 
}else{
  _geometry
.updateUVData(uvs)
 
}

For Avatar(hair,cloth,weapon on character),I simply create other Clips slightly before the body of character.
For shadow,just a plane mesh on the ground.

//add new layer on body //clip.addExLayer(Clip.LAYER_CLOTH,"cloth.model") etc.
public function addExLayer(layer:int,url:String):void{
 
var layerClip:Clip=new Clip(true,-42);
 
layerClip.setURL(url);
 
layerClip.display(_map);
 
layerClip.stopped=true;
 
_exLayerArray.push(layerClip);
 
setPosition();
}
- - - - - - - - -
//change position of exlayers and shadow,when character move.
public function setPosition(x:Object=null,y:Object=null,z:Object=null):void{
 
if(x!=null){
  _x2d
=Number(x);
 
}
 
if(y!=null){
  _y2d
=Number(y);
 
}
 
if(_map!=null){
  this
.x=_x2d*DisplayConfig.GENERIC_ZOOM-_map._engine._offsetX*DisplayConfig.GENERIC_ZOOM;
  
this.z=-_y2d*DisplayConfig.GENERIC_ZOOM-_map._engine._offsetY*DisplayConfig.GENERIC_ZOOM;
  if(
_shadowMesh!=null){
   _shadowMesh
.x=_x2d*DisplayConfig.GENERIC_ZOOM-_map._engine._offsetX*DisplayConfig.GENERIC_ZOOM
   _shadowMesh
.z=-_y2d*DisplayConfig.GENERIC_ZOOM-_map._engine._offsetY*DisplayConfig.GENERIC_ZOOM
  }
  
for(var i:int=0;i<_exLayerArray.length;i++){
   _exLayerArray[i]
.x=this.x+0.001*(i+1);
   
_exLayerArray[i].z=this.z-0.001*(i+1);
  
}
  
if(z!=null){
   this
.y=Number(z);
  
}
 }
   

Raino, Newbie
Posted: 23 January 2013 09:01 AM   Total Posts: 12   [ # 3 ]

I think if I can apply multi textures on one clip for Avatar,
instead of creating multi clips.
It can optimize lots,but I don’t know how to.

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 24 January 2013 01:38 PM   Total Posts: 166   [ # 4 ]

Basically Many meshes occur many drawcalls.
Can you precompose textures of additional clips for each Avatar mesh?

AvatarTxture[i].bitmapdata.draw(Sword000.bitmapdata); 

Of course, you have to resize AvatarTexture bigger than present size.
And you can add more bigger special clips as Mesh.

   

Raino, Newbie
Posted: 25 January 2013 01:42 AM   Total Posts: 12   [ # 5 ]

Precompose isn’t a choice for me.
Too many combination of avatar,too big buffer.

I think the performance is acceptable at least.Just tell the designer don’t put too many character in one screen~

Thank you all the same for help.

   

bart_the_13th, Newbie
Posted: 25 January 2013 01:45 AM   Total Posts: 14   [ # 6 ]

Why do you have to use 2 view3D? I know the answer from here: http://away3d.com/forum/viewthread/3861/

I guess you’re trying to create isometric 2D/3D game so you can just set the sprite3D x and z instead of x and y, setting the y will change the sprite’s height in this case instead of it’s position on the plane. It will be easier to manage since the engine will do all the calculation.

 

   

Raino, Newbie
Posted: 25 January 2013 02:14 AM   Total Posts: 12   [ # 7 ]

Thanks,bart.

setPosition method will easily translate plane-y to 3D-z.
And a full framework modified from 2d-iso game will do other works.

I do like isometric 2D/3D game,because many japanese games are made in this view.

   

Avatar
alihm, Jr. Member
Posted: 25 January 2013 02:13 PM   Total Posts: 49   [ # 8 ]

If it’s eating too much CPU, then probably your graphic card is not supported by Stage3D. Try testing it on a better graphic card or use “constrained” profile to see if it gets better.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X