omni shadows: Skin joints matrices calculation

This commit is contained in:
Yaski
2012-04-26 18:31:17 +06:00
parent 1268c217cc
commit 9da1b80004
4 changed files with 36 additions and 37 deletions

View File

@@ -17,6 +17,6 @@ package alternativa {
/**
* Library version in the format: generation.feature-version.fix-version.
*/
public static const version:String = "8.29.0";
public static const version:String = "8.30.0";
}
}

View File

@@ -294,7 +294,7 @@ public class Camera3D extends Object3D {
}
occludersLength = j;
occluders.length = j;
// Check light influence (?)
// Check light influence
for (i = 0, j = 0; i < lightsLength; i++) {
light = lights[i];
light.localToCameraTransform.calculateInversion(light.cameraToLocalTransform);
@@ -303,11 +303,12 @@ public class Camera3D extends Object3D {
light.green = ((light.color >> 8) & 0xFF) * light.intensity / 255;
light.blue = (light.color & 0xFF) * light.intensity / 255;
// Debug
light.collectDraws(this, null, 0, false);
light.collectDraws(this, null, 0, false);
if (debug && light.boundBox != null && (checkInDebug(light) & Debug.BOUNDS)) Debug.drawBoundBox(this, light.boundBox, light.localToCameraTransform);
// Shadows preparing
if (light.shadow != null) {
// TODO: Need check by occluders
light.shadow.process(this);
}
lights[j] = light;

View File

@@ -24,7 +24,7 @@ package alternativa.engine3d.objects {
/**
* @private
* A joint transform matrix.
* A joint transform matrix. Geometry -> Joint -> Skin
*/
alternativa3d var jointTransform:Transform3D = new Transform3D();

View File

@@ -20,6 +20,7 @@ package alternativa.engine3d.shadows {
import alternativa.engine3d.materials.compiler.Linker;
import alternativa.engine3d.materials.compiler.Procedure;
import alternativa.engine3d.materials.compiler.VariableType;
import alternativa.engine3d.objects.Joint;
import alternativa.engine3d.objects.Mesh;
import alternativa.engine3d.objects.Skin;
import alternativa.engine3d.objects.Surface;
@@ -215,30 +216,30 @@ package alternativa.engine3d.shadows {
var castersCount:int = _casters.length;
// calculating some transformation matrices
// TODO: not transform invisible objects
for (i = 0; i < castersCount; i++) {
caster = _casters[i];
if (caster.transformChanged) caster.composeTransforms();
caster.lightToLocalTransform.combine(caster.cameraToLocalTransform, _light.localToCameraTransform);
caster.localToLightTransform.combine(_light.cameraToLocalTransform, caster.localToCameraTransform);
var skin:Skin = caster as Skin;
if (skin != null) {
// Calculate joints matrices
for (var child:Object3D = skin.childrenList; child != null; child = child.next) {
if (child.transformChanged) child.composeTransforms();
// Write transformToSkin matrix to localToGlobalTransform property
child.localToGlobalTransform.copy(child.transform);
if (child is Joint) {
Joint(child).calculateTransform();
}
skin.calculateJointsTransforms(child);
}
}
if (caster.childrenList != null) calculateChildrenTransforms(caster);
// TODO: repair skin
// var skin:Skin = caster as Skin;
// if (skin != null) {
// // Расчет матриц джоинтов
// for (var child:Object3D = skin.childrenList; child != null; child = child.next) {
// if (child.transformChanged) child.composeTransforms();
// // Записываем в localToGlobalTransform матрицу перевода в скин
// child.localToGlobalTransform.copy(child.transform);
// if (child is Joint) {
// Joint(child).calculateTransform();
// }
// skin.calculateJointsTransforms(child);
// }
// }
}
// Iterate through six cameras
@@ -323,23 +324,21 @@ package alternativa.engine3d.shadows {
child.localToLightTransform.combine(root.localToLightTransform, child.transform);
child.lightToLocalTransform.combine(child.inverseTransform, root.lightToLocalTransform);
if (child.childrenList != null) calculateChildrenTransforms(child);
var skin:Skin = child as Skin;
if (skin != null) {
// Calculate joints matrices
for (var skinChild:Object3D = skin.childrenList; skinChild != null; skinChild = skinChild.next) {
if (skinChild.transformChanged) skinChild.composeTransforms();
// Write transformToSkin matrix to localToGlobalTransform property
skinChild.localToGlobalTransform.copy(skinChild.transform);
if (skinChild is Joint) {
Joint(skinChild).calculateTransform();
}
skin.calculateJointsTransforms(skinChild);
}
}
// TODO: repair skin
// // расчет матриц трансформаций для скинов
// var skin:Skin = child as Skin;
// if (skin != null) {
// // Расчет матриц джоинтов
// for (var skinChild:Object3D = skin.childrenList; skinChild != null; skinChild = skinChild.next) {
// if (skinChild.transformChanged) skinChild.composeTransforms();
// // Записываем в localToGlobalTransform матрицу перевода в скин
// skinChild.localToGlobalTransform.copy(skinChild.transform);
// if (skinChild is Joint) {
// Joint(skinChild).calculateTransform();
// }
// skin.calculateJointsTransforms(skinChild);
// }
// }
if (child.childrenList != null) calculateChildrenTransforms(child);
}
}
@@ -373,7 +372,6 @@ package alternativa.engine3d.shadows {
private function collectDraws(context:Context3D, caster:Object3D, edgeCamera:Camera3D):void{
// если объект является мешем, собираем для него дроуколы
var mesh:Mesh = caster as Mesh;
if (mesh != null && mesh.geometry != null) {