Показать сообщение отдельно
Старый 15.11.2012, 21:56
billion вне форума Посмотреть профиль Отправить личное сообщение для billion Посетить домашнюю страницу billion Найти все сообщения от billion
  № 1  
Ответить с цитированием
billion

Регистрация: Jan 2002
Сообщений: 149
Отправить сообщение для billion с помощью ICQ
По умолчанию Во всех 3D движках такие тормоза?

решил попробовать 3D движки....

настроил санди 3D и запульнул сразу 500 кубиков на сцену.

удивился фпс.... в среднем 4 фпс

собственно вопрос: все движки так тормозят или я что-то не так делаю?

использовал три материала и рендеринг при входе во фрейм:

Код AS3:
package
{
	import com.google.maps.LatLng;
	import com.google.maps.Map3D;
 
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;
	import flash.geom.Point;
 
	import sandy.core.Scene3D;
	import sandy.core.scenegraph.Camera3D;
	import sandy.core.scenegraph.Group;
	import sandy.core.scenegraph.Shape3D;
	import sandy.materials.Appearance;
	import sandy.materials.ColorMaterial;
	import sandy.materials.WireFrameMaterial;
	import sandy.materials.attributes.GouraudAttributes;
	import sandy.materials.attributes.LightAttributes;
	import sandy.materials.attributes.LineAttributes;
	import sandy.materials.attributes.MaterialAttributes;
	import sandy.materials.attributes.MediumAttributes;
	import sandy.materials.attributes.OutlineAttributes;
	import sandy.materials.attributes.VertexNormalAttributes;
	import sandy.primitive.Box;
	import sandy.primitive.PrimitiveMode;
 
	[Event( name="clicked", type="sandydemo.BoxEvent" )]
 
	public class Boxes extends Sprite
	{
		public var scene:Scene3D;
		private var selectedMenuItem:Shape3D;
		public var arr:Array = [];
		public var camera:Camera3D;
		private var rootik:Group;
 
		public function Boxes()
		{
			init();
			addEventListener(Event.ADDED_TO_STAGE, onadded);
		}
 
		protected function onadded(event:Event):void
		{
			stage.frameRate = 100;
		}
 
		public function setRoll(val:Number):void {
			camera.roll = -val;
			scene.render();
		}
 
		public function setCenter(pp:Point, zz:Number, pitch:Number):void {
			camera.x = -pp.x;
			camera.y = pp.y;
			camera.z = -100*Math.pow(2, 18-zz);
			scene.render();
		}
 
		private function init():void
		{
			camera = new Camera3D(1920, 1080);
			camera.x = 0;
			camera.y = 0;
			camera.z = -500;
			camera.lookAt(0, 0, 0 );
 
			rootik = new Group( "root" );
 
			scene = new Scene3D("scene", this, camera, rootik );
			var len:uint = 500;
			var i:uint = 0;
			while (i<len) {
				arr[i] = new Box("red box", Math.random()*200, Math.random()*200, Math.random()*20*10, PrimitiveMode.QUAD, 0 );
				configureBox(arr[i], 0xff0000, Math.random()*1920, Math.random()*1080 );
				i++;
			}
 
			scene.render();
		}
 
		private function mouseOverHandler( event:MouseEvent ):void
		{
			var container:Sprite = event.target as Sprite;
			container.filters = [
				new GlowFilter( 0xffffff, 1, 12, 12 )
			];
		}
 
		private function mouseOutHandler( event:MouseEvent ):void
		{
			var container:Sprite = event.target as Sprite;
			container.filters = [];
		}
 
		private function clickHandler( event:MouseEvent ):void
		{
			var container:Sprite = event.target as Sprite;
			var currentShape:Shape3D = getShape3DByContainer( container );
			var boxEvent:BoxEvent = new BoxEvent( BoxEvent.CLICKED );
			boxEvent.which = currentShape.name;
			dispatchEvent( boxEvent );
		}
 
		private function getShape3DByContainer( container:Sprite ):Shape3D
		{
			for each( var shape:Object in scene.root.children )
			if( shape is Shape3D && shape.container == container )
				return shape as Shape3D;
 
			return null;
		}
 
		private function configureBox( item:Shape3D, color:uint, x:int, y:int ):void
		{
			var mattAttr:MaterialAttributes = new MaterialAttributes(
				new LightAttributes(false, 0.5), 
				new OutlineAttributes(3, 0xff0000, 1),
				new LineAttributes(1, 0, 1)
			);
 
			item.appearance = new Appearance(
				new ColorMaterial(color, 0.5, mattAttr)
			);
			item.appearance.frontMaterial.lightingEnable = true;
 
			item.x = x;
			item.y = y;
			item.rotateZ = Math.random()*180;
			item.container.addEventListener( MouseEvent.MOUSE_OVER, mouseOverHandler );
			item.container.addEventListener( MouseEvent.MOUSE_OUT, mouseOutHandler );
			item.container.addEventListener( MouseEvent.CLICK, clickHandler );
			item.container.useHandCursor = true;
			item.container.buttonMode = true;
 
			scene.root.addChild(item);
		}
	}
}
Код AS3:
boxes = new Boxes();
				spriteContainer.addChild(boxes);
				addEventListener(Event.ENTER_FRAME, onvch);
				spriteContainer.addChild(new Stats());
 
 
			protected function onvch(event:*):void
			{
				boxes.setCenter(new Point(mouseX-1500, mouseY), 14, 0); 
			}