Hi guys, i’ve built a solar system and even though it works ok on a Desktop ( event though the fps varies from 30 to 60 ), it staggers ( low fps ) really bad on a tablet ( in some cases ).
So i’ve decided to ask for some tips & tricks since none of the threads related to performance issues seems to apply to my specific problems.
The low fps occures when a part of an object covers the whole screen ( like looking at a portion of the Sun for example ). Also, i can’t make a SkyBox render on any tablet so far ( major bummer tbh ).
First of all, each planet has a different material and moves on a different trajectory using PathAnimator so i can’t really use the Merge / Clone methods that i’ve been reading so much about.
The orbits are “drawn” using SegmentSet( LinearExtrude didn’t do the job for me visual wise ).
I would also like to mention that no filters are applied to the scene and that the maximum polygons on the screen at any given time is about 45k, the average being 10 - 15k.
=======================================================
Below is the planet + PathAnimator ( the path is extracted from the orbit creation which is not relevant ) creation code ( that should be the core of the problem i think )
/**
* Builds the solar system based on the data read from a config XML file
*/
private final function buildPlanets():void
{
trace("> Adding lights");
var light:PointLight = new PointLight();
light.fallOff = light.radius = Number.MAX_VALUE;
light.ambient = .2;
light.diffuse = 100;
var sunLight:PointLight = new PointLight();
sunLight.ambient = 1;
sunLight.specular = 0;
_scene.addChild(sunLight);
_picker = new StaticLightPicker([light]);
_scene.addChild(light);
var orbit:OrbitCreator = new OrbitCreator();
_animators = new Vector.<PathAnimator>;
trace("> Building system");
var sunPicker:StaticLightPicker = new StaticLightPicker([sunLight]);
_orbits = new Vector.<SegmentSet>;
var orbitV:Vector3D;
for (var i:uint = 0; i < _planets.length; ++i)
{
if (i != 0)
{
orbitV = new Vector3D(_infoXML.orbit[i - 1].@radiusX / ScaleRatios.SCALE, _infoXML.orbit[i - 1].@yPlacement / ScaleRatios.SCALE, _infoXML.orbit[i - 1].@radiusZ / ScaleRatios.SCALE);
_planets[i].x = orbitV.x;
_planets[i].init(_infoXML.planet[i].@size * ScaleRatios.PLANET_SCALE, Values.SPHERE_SEGH, Values.SPHERE_SEGV, _picker, _infoXML.planet[i].@ringRadius, _infoXML.planet[i].@ringAngleX, _infoXML.planet[i].@ringAngleY);
_orbits.push(orbit.buildOrbit(_infoXML.orbit[i - 1].@xPos, orbitV.x, orbitV.y, orbitV.z, _infoXML.orbit[i - 1].@tilt));
_scene.addChild(_orbits[_orbits.length - 1]);
_animators.push(new PathAnimator(orbit.path, _planets[i], null, false));
}
else
{
_planets[i].init(_infoXML.planet[i].@size * ScaleRatios.PLANET_SCALE, Values.SPHERE_SEGH, Values.SPHERE_SEGV, sunPicker);
_planets[i].terrain.material.repeat = true;
}
_planets[i].initRotations(_infoXML.planet[i].@rSpeed, _infoXML.planet[i].@aSpeed * ScaleRatios.SPEED_SCALE);
if (_planets[i].hasAtmosphere)
_planets[i].atmRot = _infoXML.planet[i].@atmSpeed;
_scene.addChild(_planets[i]);
}
_planets[6].ring.material.lightPicker = sunPicker;
_planets[7].ring.material.lightPicker = sunPicker;
// ----START SKYBOX CREATION----
var bmd:BitmapData = new SkyMap().bitmapData;
_scene.addChild(new SkyBox(new BitmapCubeTexture(bmd, bmd, bmd, bmd, bmd, bmd)));
// ----END SKYBOX CREATION----
trace("> Adding interaction");
this.dispatchEvent(new Event("solarSystemCreated", true, true));
_controller.update();
_controller.steps = 40;
addEventListener(Event.ENTER_FRAME, updateScreen);
}