alternativaplatform / alternativa3d Goto Github PK
View Code? Open in Web Editor NEWAlternativa3D Flash GPU accelerated 3D engine
Home Page: http://alternativaplatform.com/en/technologies/alternativa3d/
Alternativa3D Flash GPU accelerated 3D engine
Home Page: http://alternativaplatform.com/en/technologies/alternativa3d/
Now is AltrntivaPltfrm, but actual is Alternativa3Den
Оказалось, что ExporterA3D не умеет экспортировать обычный StandartMaterial в котором находится BitmapTextureResource.
private function exportMap(source:TextureResource, channel:int, dest:A3D2):int {
if (source == null) return -1;
var result:A3D2Map = mapsMap[source];
if (result != null) return result.id;
if (source is ExternalTextureResource) {
var resource:ExternalTextureResource = source as ExternalTextureResource;
result = new A3D2Map(channel, mapID, exportImage(resource, dest));
if (dest.maps == null) dest.maps = new Vector.<A3D2Map>();
dest.maps[mapID] = result;
mapsMap[source] = result;
return mapID++;
}
return -1;
}
Почему только if (source is ExternalTextureResource) { ???????? Невероятно!
Я бы сделал пуллреквест только у вас там бинарные библиотеки.
This is more like forum question, but - since it's down - here goes:
} else {
_texture = null;
throw new Error("Cannot upload without data");
}
Why does it have to do that? I could understand throw, but "= null" part is mysterious 😕
См скрин тут явно какое-то говно.
I have two comments about the lookAt methods (in DirectionalLight, SpotLight, Camera3D, and possibly elsewhere):
Thanks!
My initial guess was that lights array is not sorted according to light type and so program cache is ineffective. But then all my lights are omnidirectional, so it should not matter.
When we use Sprite3D we don't want to scale up the bitmapdata if it is not power of two. So, we need to have something like Image in starling.
I made changes (hardcode) to reach such behavior.
Here are some changes in BitmapTextureResource.as:
if (resizeForGPU) {
var wLog2Num:Number = Math.log(data.width)/Math.LN2;
var hLog2Num:Number = Math.log(data.height)/Math.LN2;
var wLog2:int = Math.ceil(wLog2Num);
var hLog2:int = Math.ceil(hLog2Num);
if (wLog2 != wLog2Num || hLog2 != hLog2Num || wLog2 > 11 || hLog2 > 11) {
// Resize bitmap
wLog2 = (wLog2 > 11) ? 11 : wLog2;
hLog2 = (hLog2 > 11) ? 11 : hLog2;
source = new BitmapData(1 << wLog2, 1 << hLog2, data.transparent, 0x0);
source.copyPixels(data, data.rect, new Point(0, 0));
scaleUV = new Rectangle(0, 0, data.width / source.width, data.height / source.height);
}
}
So, we copy data without resizing. source.copyPixels(data, data.rect, new Point(0, 0)); Then save scaleUV to set them in Sprite3D.as:
geometry.setAttributeValues(VertexAttributes.POSITION, Vector.<Number>([0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0]));
geometry.setAttributeValues(VertexAttributes.NORMAL, Vector.<Number>([0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1]));
geometry.setAttributeValues(VertexAttributes.TEXCOORDS[0], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
geometry.setAttributeValues(VertexAttributes.TEXCOORDS[1], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
geometry.setAttributeValues(VertexAttributes.TEXCOORDS[2], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
geometry.setAttributeValues(VertexAttributes.TEXCOORDS[3], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
geometry.setAttributeValues(VertexAttributes.TEXCOORDS[4], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
geometry.setAttributeValues(VertexAttributes.TEXCOORDS[5], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
geometry.setAttributeValues(VertexAttributes.TEXCOORDS[6], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
geometry.setAttributeValues(VertexAttributes.TEXCOORDS[7], Vector.<Number>([0, 0, 0, scaleV, scaleU, scaleV, scaleU, 0]));
I don't know how to integrate it correct into the main code. So it would be great to see similar changes in the next releases.
Thanks.
Object literals are faster than the new operator
Strings, Numbers (including int and uint), and Boolean objects are usually instantiated using literal notation (var str:String = “text”). Objects and Arrays are often instantiated using the “new” operator – this is seldom necessary (only in the case of a fixed-length Array), and is slower.
var o:Object = {}; is faster than var o:Object = new Object();
and
var a:Array = []; is faster than var a:Array = new Array();
The detection does not work on Android & Apple devices.
See thread:
http://forum.alternativaplatform.com/posts/list/10004.page
Problem seems to be in view -> calculateSurfacesDepths where "red" and "green" are always 0.
See discussion at the end of pull request #26
updateBoundBox() in Object3D is completely empty
How to Extended Mode
according to http://forum.alternativaplatform.com/index.php?showtopic=4526&#entry25329 it prevents loading normal maps in blender dae-s
Could we please have a wiki to post tutorials and how-tos?
Hi
When I try to publish my 3ds file with textures in http://a3dplayer.com/ Iget error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at alternativa.engine3d.loaders::ExporterA3D/exportGeometry()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:523]
at alternativa.engine3d.loaders::ExporterA3D/exportMesh()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:370]
at alternativa.engine3d.loaders::ExporterA3D/exportHierarchy()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:256]
at alternativa.engine3d.loaders::ExporterA3D/exportHierarchy()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:267]
at alternativa.engine3d.loaders::ExporterA3D/export()[C:\Develop\platform\clients\fp11\libraries\Alternativa3D\trunk\target\checkout\src\alternativa\engine3d\loaders\ExporterA3D.as:171]
at projects.editor.clients.fp11.Alternativa3DEditor.export.exportSWF.progressPhase::ExportProgressPhase/prepareModelSource()
at projects.editor.clients.fp11.Alternativa3DEditor.export.exportSWF.progressPhase::ExportProgressPhase()
at projects.editor.clients.fp11.Alternativa3DEditor.app::ExportController/exportToSWF()
at projects.editor.clients.fp11.Alternativa3DEditor.app.views.topPanel::TopPanel/__exportSWF_click()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at alternativa.gui.mouse::MouseManager/onClick()[C:\work\fb3\AlternativaGUI\target\checkout\src\alternativa\gui\mouse\MouseManager.as:990]
at alternativa.gui.mouse::MouseManager/onMouseUp()[C:\work\fb3\AlternativaGUI\target\checkout\src\alternativa\gui\mouse\MouseManager.as:1128]
Everything works fine on Windows. However, when I take my code to Android, the Z ordering of objects is all wrong. The following code produces these outputs:
Windows 7 64 Home Premium, Adobe AIR 3.3:http://i49.tinypic.com/20jo2kg.png - Right
Android 3.2.1 Le Pan II, Adobe AIR 3.3: http://i50.tinypic.com/1z1sgtc.png - Wrong
(Flex 4.6 SDK, AIR 3.3 SDK, Alternativa3D 8.27, FlashDevelop 4.0.4 RTM with default "AIR Mobile AS3 App" profile)
package
{
import alternativa.engine3d.core.Camera3D;
import alternativa.engine3d.core.Object3D;
import alternativa.engine3d.core.View;
import alternativa.engine3d.lights.OmniLight;
import alternativa.engine3d.materials.StandardMaterial;
import alternativa.engine3d.primitives.Box;
import alternativa.engine3d.resources.BitmapTextureResource;
import flash.display.BitmapData;
import flash.display.Stage3D;
import flash.events.Event;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
[SWF(width = "1024", height = "720")]
public class Main extends Sprite
{
public var
stage3D :Stage3D = stage.stage3Ds[0],
scene :Object3D = new Object3D(),
camera :Camera3D;
public function Main():void
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage3D = stage.stage3Ds[0];
stage3D.addEventListener(Event.CONTEXT3D_CREATE, onContext3dCreate);
stage3D.requestContext3D();
}
private function onContext3dCreate(event:Event):void
{
camera = new Camera3D(1, 10000);
camera.view = new View(stage.stageWidth, stage.stageHeight);
camera.view.hideLogo();
camera.rotationX = -.5;
camera.rotationY = -1;
scene.addChild(camera);
addChild(camera.view);
var light:OmniLight = new OmniLight(0xffffff, 5000, 10000);
scene.addChild(light);
var normalMap:BitmapTextureResource = new BitmapTextureResource(new BitmapData(1, 1, false, 0x7f7fff));
normalMap.upload(stage3D.context3D);
var texture:BitmapTextureResource = new BitmapTextureResource(new BitmapData(1, 1, false, 0xff0000));
texture.upload(stage3D.context3D);
var material:StandardMaterial = new StandardMaterial(texture, normalMap);
var boxSize:uint = 50;
var boxCount:int = 10;
for (var x:int = 0; x < boxCount; x++)
for (var z:int = 0; z < boxCount; z++)
{
var box:Box = new Box(boxSize - 5, 10, boxSize - 5);
box.geometry.upload(stage3D.context3D);
box.getSurface(0).material = material;
box.x = (boxSize * x) - (boxCount * boxSize);
box.y = 50;
box.z = boxSize * z;
scene.addChild(box);
}
camera.render(stage3D);
}
}
}
var point:Sprite3D = new Sprite3D(16, 16, pMaterial);
point.mouseEnabled = true;
point.mouseChildren = true;
point.useHandCursor = true;
point.alwaysOnTop = true;
Sprite is covered by another mesh. Mouse events does not work.
Only on Android and IOS if you have for example a box on a plane and click on the box, the mouseevent3D will always target the plane.
So the issue is concerning MouseEvent3D with overlapping object.
народ говорит спрайты3д не кулятся http://forum.alternativaplatform.com/posts/list/0/10238.page
https://github.com/AlternativaPlatform/Alternativa3DUtils 404 хотя стоит ссылка из readme
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.