|
| damo |
Post
#1
|
|
Advanced Member Group: Members Posts: 43 Joined: 20-June 06 Member No.: 26 |
Hi all,
I'm currently testing the new release and i find some new bugs. The Sphere object is not really a "sphere" and faces are not correctly render. You can see an exemple here : CODE /* classe Univers Version 0.1 Auteur : Damo Copyright Tamina */ import sandy.core.group.*; import sandy.core.data.*; import sandy.view.*; import sandy.core.*; import sandy.skin.*; import sandy.primitive.*; import sandy.core.transform.*; import sandy.events.*; import sandy.util.*; import sandy.math.Matrix4Math; import sandy.math.VectorMath; import mx.utils.Delegate; import flash.display.BitmapData; class testBeta2 { // Propriétés d'instance private var __screen:MovieClip; private var __cam:Camera3D; private var __rootGrp:Group; private var circlePos:Number=-180; private var incrementeur:Number=5; private var __grille3D:Plane3D; //Test focal private var _fov:Number = 29; private var _ratio:Number = 2.4; public var monDispatcher:MovieClip; //Constructeur function testBeta2 () { } //Methodes public function init(largeur:Number, hauteur:Number):Void { //Initialisation de la camera __screen = _root.createEmptyMovieClip("scene3D",7); World3D.getInstance().setContainer(__screen); __cam = new Camera3D(largeur, hauteur); __cam.setPerspectiveProjection(_fov,_ratio,1.0,1000.0); __cam.setPosition(0, 30, -600); __cam.lookAt(0,0,0); World3D.getInstance().setCamera( __cam ); //Initialisation du groupe root __rootGrp = new Group(); World3D.getInstance().setRootGroup( __rootGrp ); //Creation de la grille __rootGrp.addChild(createGrille()); //Creation du fond __rootGrp.addChild(createFond()); //Rendu World3D.getInstance().render(); //Ecoute rotation var unEcouteur:Object = new Object(); unEcouteur.onKeyDown = Delegate.create(this, worldRotate); unEcouteur.onKeyUp = Delegate.create(this, initWorldRotate); Key.addListener(unEcouteur); } //*********** PRIVATE ****************// private function initWorldRotate():Void { incrementeur = 5; } private function worldRotate():Void { var distance:Number = 600; var pi:Number = Math.PI; if(Key.isDown(Key.LEFT)) { var CamY:Number = World3D.getInstance().getCamera().getPosition().y; // On tourne vers la gauche circlePos -=incrementeur; incrementeur++; World3D.getInstance().getCamera().setPosition(Math.cos(circlePos*pi/360)*distance,CamY,Math.sin(circlePos*pi/360)*distance); World3D.getInstance().getCamera().lookAt(0,0,0); } if(Key.isDown(Key.RIGHT)) { var CamY:Number = World3D.getInstance().getCamera().getPosition().y; // On tourne vers la droite circlePos +=incrementeur; incrementeur++; World3D.getInstance().getCamera().setPosition(Math.cos(circlePos*pi/360)*distance,CamY,Math.sin(circlePos*pi/360)*distance); World3D.getInstance().getCamera().lookAt(0,0,0); } } private function createGrille():TransformGroup{ var grilleSkin:MixedSkin = new MixedSkin(0x00FF00,20,0x00FF00,100,1); var grilleTGrp:TransformGroup = new TransformGroup (); __grille3D = new Plane3D(150,150,6,"quad"); __grille3D.setSkin(grilleSkin); grilleTGrp.addChild(__grille3D); return grilleTGrp; } private function createFond():TransformGroup{ var fondSkin:BitmapData = BitmapData.loadBitmap("3246.jpg"); var maSkin:TextureSkin = new TextureSkin(fondSkin); var fondTGrp:TransformGroup = new TransformGroup (); var monFond:Sphere = new Sphere(50,1,"tri"); //monFond.enableBackFaceCulling(false); monFond.setSkin(maSkin); fondTGrp.addChild(monFond); return fondTGrp; } } |
| damo |
Post
#2
|
|
Advanced Member Group: Members Posts: 43 Joined: 20-June 06 Member No.: 26 |
QUOTE "with 0 in camera height, it is the same???" Exactly ! QUOTE Otherwise, in fact, i meant to do this : __cam.setPosition(0, 0, -600); See the attachment for result (IMG:style_emoticons/default/mellow.gif) |
| Petit |
Post
#3
|
|
Advanced Member Group: Moderator Posts: 560 Joined: 21-June 06 From: Borgholm, Sweden Member No.: 38 |
You are right that there is a bug in the sort order, which means faces that should really be hidden behind others, are rendered. This is something that is worked on. The fact that the sphere in your first example was not a sphere, has to do with two things: 1. The quality setting is '1' which gives you far too few faces to build a sphere. A setting of '10' is more like it. 2. You had set the aspect ration of the camera projection to 2.4, which means that you get a cigar rather than a sphere. Then of course there are other problems as well. One is that your image doesn't seem to cover the whole sphere, leaving a white part. It is also not easy to tell how a square image should be projected on a sphere, to make it distort nicely. Attached is my test of your application, the best I could get. Here are my changes: CODE //Test focal private var _fov:Number = 29; private var _ratio:Number = 1; // aspect ration is 1.0 Camera position. I used a smaller distance: CODE __cam.setPosition(0, 30, -300); And in the worldRotate method I changed the distance accordingly: CODE var distance:Number = 300; I set a higher quality for the Sphere: CODE var monFond:Sphere = new Sphere(50,10,"tri"); Attached is the result: Attached File(s) |
| Lo-Fi Version | Time is now: 26th July 2007 - 11:03 AM |