mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-27 18:39:07 -07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -17,6 +17,6 @@ package alternativa {
|
||||
/**
|
||||
* Library version in the format: generation.feature-version.fix-version.
|
||||
*/
|
||||
public static const version:String = "8.31.0";
|
||||
public static const version:String = "8.32.0";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ package alternativa.engine3d.loaders {
|
||||
|
||||
private var data:ByteArray;
|
||||
private var objectDatas:Object;
|
||||
private var animationDatas:Array;
|
||||
private var animationDatas:Vector.<AnimationData>;
|
||||
private var materialDatas:Object;
|
||||
|
||||
/**
|
||||
@@ -313,7 +313,7 @@ package alternativa.engine3d.loaders {
|
||||
case 0xB006: // spot target
|
||||
case 0xB007:
|
||||
if (animationDatas == null) {
|
||||
animationDatas = new Array();
|
||||
animationDatas = new Vector.<AnimationData>();
|
||||
}
|
||||
var animation:AnimationData = new AnimationData();
|
||||
animation.chunkId = chunkInfo.id;
|
||||
@@ -803,7 +803,7 @@ package alternativa.engine3d.loaders {
|
||||
}
|
||||
|
||||
var vertices:Vector.<Vertex> = new Vector.<Vertex>(objectData.vertices.length/3);
|
||||
var faces:Array = new Array(objectData.faces.length/3); // Vector.<Face> can't .sortOn()
|
||||
var faces:Vector.<Face> = new Vector.<Face>(objectData.faces.length/3);
|
||||
|
||||
buildInitialGeometry(vertices, faces, objectData, animationData, scale);
|
||||
|
||||
@@ -884,7 +884,7 @@ package alternativa.engine3d.loaders {
|
||||
mesh.calculateBoundBox();
|
||||
}
|
||||
|
||||
private function buildInitialGeometry(vertices:Vector.<Vertex>, faces:Array, objectData:ObjectData, animationData:AnimationData, scale:Number):void {
|
||||
private function buildInitialGeometry(vertices:Vector.<Vertex>, faces:Vector.<Face>, objectData:ObjectData, animationData:AnimationData, scale:Number):void {
|
||||
var correct:Boolean = false;
|
||||
if (animationData != null) {
|
||||
var a:Number = objectData.a;
|
||||
@@ -964,7 +964,7 @@ package alternativa.engine3d.loaders {
|
||||
}
|
||||
}
|
||||
|
||||
private function cloneVerticesToRespectSmoothGroups(vertices:Vector.<Vertex>, faces:Array):void {
|
||||
private function cloneVerticesToRespectSmoothGroups(vertices:Vector.<Vertex>, faces:Vector.<Face>):void {
|
||||
// Actions with smoothing groups:
|
||||
// - if vertex is in faces with groups 1+2 and 3, then it is duplicated
|
||||
// - if vertex is in faces with groups 1+2, 3 and 1+3, then it is not duplicated
|
||||
@@ -1040,7 +1040,7 @@ package alternativa.engine3d.loaders {
|
||||
}
|
||||
}
|
||||
|
||||
private function cloneAndTransformVerticesToRespectUVTransforms(vertices:Vector.<Vertex>, faces:Array):void {
|
||||
private function cloneAndTransformVerticesToRespectUVTransforms(vertices:Vector.<Vertex>, faces:Vector.<Face>):void {
|
||||
// Actions with UV transformation
|
||||
// if vertex in faces with different transform materials, then it is duplicated
|
||||
var n:int, m:int, p:int, q:int, len:int, numVertices:int = vertices.length, numFaces:int = faces.length;
|
||||
@@ -1110,7 +1110,7 @@ package alternativa.engine3d.loaders {
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateVertexNormals(vertices:Vector.<Vertex>, faces:Array):void {
|
||||
private function calculateVertexNormals(vertices:Vector.<Vertex>, faces:Vector.<Face>):void {
|
||||
var n:int, m:int, numFaces:int = faces.length;
|
||||
for (n = 0; n < numFaces; n++) {
|
||||
var face:Face = Face(faces [n]);
|
||||
@@ -1157,7 +1157,7 @@ package alternativa.engine3d.loaders {
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateVertexTangents(vertices:Vector.<Vertex>, faces:Array):void {
|
||||
private function calculateVertexTangents(vertices:Vector.<Vertex>, faces:Vector.<Face>):void {
|
||||
var n:int, m:int, numVertices:int = vertices.length, numFaces:int = faces.length;
|
||||
for (n = 0; n < numFaces; n++) {
|
||||
var face:Face = Face(faces [n]);
|
||||
@@ -1319,7 +1319,7 @@ package alternativa.engine3d.loaders {
|
||||
}
|
||||
}
|
||||
|
||||
private function assignMaterialsToFaces(faces:Array, objectData:ObjectData):void {
|
||||
private function assignMaterialsToFaces(faces:Vector.<Face>, objectData:ObjectData):void {
|
||||
// Assign materials
|
||||
if (objectData.surfaces != null) {
|
||||
for (var key:String in objectData.surfaces) {
|
||||
@@ -1338,12 +1338,32 @@ package alternativa.engine3d.loaders {
|
||||
}
|
||||
}
|
||||
|
||||
private function collectFacesIntoSurfaces(faces:Array, defaultMaterialData:MaterialData):Vector.<uint> {
|
||||
private function sortFacesBySurface(a:Vector.<Face>, left:int, right:int):void {
|
||||
var pivot:uint, tmp:Face;
|
||||
var i:int = left;
|
||||
var j:int = right;
|
||||
pivot = a[int((left + right) >> 1)].surface;
|
||||
while (i <= j) {
|
||||
while (a[i].surface < pivot) i++;
|
||||
while (a[j].surface > pivot) j--;
|
||||
if (i <= j) {
|
||||
tmp = a[i];
|
||||
a[i] = a[j];
|
||||
i++;
|
||||
a[j] = tmp;
|
||||
j--;
|
||||
}
|
||||
}
|
||||
if (left < j) sortFacesBySurface(a, left, j);
|
||||
if (i < right) sortFacesBySurface(a, i, right);
|
||||
}
|
||||
|
||||
private function collectFacesIntoSurfaces(faces:Vector.<Face>, defaultMaterialData:MaterialData):Vector.<uint> {
|
||||
var numFaces:int = faces.length;
|
||||
// Sort faces on materials
|
||||
faces.sortOn("surface");
|
||||
if (numFaces) sortFacesBySurface(faces, 0, numFaces - 1);
|
||||
|
||||
// Create indices, calculate indexBegin and numTriangles
|
||||
var numFaces:int = faces.length;
|
||||
var indices:Vector.<uint> = new Vector.<uint>(numFaces*3, true);
|
||||
|
||||
var lastMaterialData:MaterialData;
|
||||
|
||||
@@ -1076,9 +1076,6 @@ package alternativa.engine3d.materials {
|
||||
// Iterate groups
|
||||
var materialKey:int;
|
||||
var program:StandardMaterialProgram;
|
||||
var omniLightCount:int = 0;
|
||||
var directionalLightCount:int = 0;
|
||||
var spotLightCount:int = 0;
|
||||
|
||||
if (groupsCount == 0 && shadowGroupLength == 0) {
|
||||
// There is only Ambient light on the scene
|
||||
@@ -1121,9 +1118,14 @@ package alternativa.engine3d.materials {
|
||||
// Form key
|
||||
materialKey = (isFirstGroup) ? ((lightMap != null) ? LIGHT_MAP_BIT : 0) : 0;
|
||||
materialKey |= (_normalMapSpace << NORMAL_MAP_SPACE_OFFSET) | ((glossinessMap != null) ? GLOSSINESS_MAP_BIT : 0) | ((specularMap != null) ? SPECULAR_MAP_BIT : 0);
|
||||
var omniLightCount:int = 0;
|
||||
var directionalLightCount:int = 0;
|
||||
var spotLightCount:int = 0;
|
||||
for (j = 0; j < lightGroupLength; j++) {
|
||||
light = lightGroup[j];
|
||||
if (light is OmniLight) omniLightCount++; else if (light is DirectionalLight) directionalLightCount++; else if (light is SpotLight) spotLightCount++;
|
||||
if (light is OmniLight) omniLightCount++;
|
||||
else if (light is DirectionalLight) directionalLightCount++;
|
||||
else if (light is SpotLight) spotLightCount++;
|
||||
}
|
||||
materialKey |= omniLightCount << OMNI_LIGHT_OFFSET;
|
||||
materialKey |= directionalLightCount << DIRECTIONAL_LIGHT_OFFSET;
|
||||
@@ -1170,7 +1172,9 @@ package alternativa.engine3d.materials {
|
||||
materialKey = (isFirstGroup) ? ((lightMap != null) ? LIGHT_MAP_BIT : 0) : 0;
|
||||
materialKey |= (_normalMapSpace << NORMAL_MAP_SPACE_OFFSET) | ((glossinessMap != null) ? GLOSSINESS_MAP_BIT : 0) | ((specularMap != null) ? SPECULAR_MAP_BIT : 0);
|
||||
materialKey |= light.shadow.type << SHADOW_OFFSET;
|
||||
if (light is OmniLight) materialKey |= 1 << OMNI_LIGHT_OFFSET; else if (light is DirectionalLight) materialKey |= 1 << DIRECTIONAL_LIGHT_OFFSET; else if (light is SpotLight) materialKey |= 1 << SPOT_LIGHT_OFFSET;
|
||||
if (light is OmniLight) materialKey |= 1 << OMNI_LIGHT_OFFSET;
|
||||
else if (light is DirectionalLight) materialKey |= 1 << DIRECTIONAL_LIGHT_OFFSET;
|
||||
else if (light is SpotLight) materialKey |= 1 << SPOT_LIGHT_OFFSET;
|
||||
|
||||
// Для группы создаем программу и дроуюнит
|
||||
// Opaque pass
|
||||
|
||||
@@ -42,13 +42,8 @@ package alternativa.engine3d.utils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a BoundBox of hierarchy of objects.
|
||||
*
|
||||
* @param object Container which contains the hierarchy.
|
||||
* @param boundBoxSpace <code>Object3D</code> in coordinates of which the BoundBox will be calculated.
|
||||
* @param result Instance of <code>BoundBox</code> to which calculated properties will be set.
|
||||
*
|
||||
* @return Instance given as <code>result</code> property with properties updated according to calculations. If <code>result</code> property was not set, new instance of <code>BoundBox</code> will be created.
|
||||
* @private
|
||||
* Performs calculation of bound box of objects hierarchy branch.
|
||||
*/
|
||||
public static function calculateHierarchyBoundBox(object:Object3D, boundBoxSpace:Object3D = null, result:BoundBox = null):BoundBox {
|
||||
if (result == null) result = new BoundBox();
|
||||
|
||||
Reference in New Issue
Block a user