mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-26 18:09:14 -07:00
New mouse handling implemented in LOD. trace in camera removed. And bonus: now lights can be placed in LOD.
This commit is contained in:
@@ -328,8 +328,6 @@ public class Camera3D extends Object3D {
|
|||||||
}
|
}
|
||||||
raysLength = view.raysLength;
|
raysLength = view.raysLength;
|
||||||
|
|
||||||
trace(raysLength, globalMouseHandlingType);
|
|
||||||
|
|
||||||
// Check getting in frustum and occluding
|
// Check getting in frustum and occluding
|
||||||
if (root.culling >= 0 && (root.boundBox == null || occludersLength == 0 || !root.boundBox.checkOcclusion(occluders, occludersLength, root.localToCameraTransform))) {
|
if (root.culling >= 0 && (root.boundBox == null || occludersLength == 0 || !root.boundBox.checkOcclusion(occluders, occludersLength, root.localToCameraTransform))) {
|
||||||
// Check if the ray crossing the bounding box
|
// Check if the ray crossing the bounding box
|
||||||
|
|||||||
@@ -169,14 +169,17 @@ package alternativa.engine3d.objects {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Holds current level
|
||||||
|
private var level:Object3D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
override alternativa3d function collectDraws(camera:Camera3D, lights:Vector.<Light3D>, lightsLength:int, useShadow:Boolean):void {
|
override alternativa3d function calculateVisibility(camera:Camera3D):void {
|
||||||
var distance:Number = Math.sqrt(localToCameraTransform.d*localToCameraTransform.d + localToCameraTransform.h*localToCameraTransform.h + localToCameraTransform.l*localToCameraTransform.l);
|
var distance:Number = Math.sqrt(localToCameraTransform.d*localToCameraTransform.d + localToCameraTransform.h*localToCameraTransform.h + localToCameraTransform.l*localToCameraTransform.l);
|
||||||
for (var level:Object3D = levelList; level != null; level = level.next) {
|
for (level = levelList; level != null; level = level.next) {
|
||||||
if (distance <= level.distance) {
|
if (distance <= level.distance) {
|
||||||
collectChildDraws(level, this, camera, lights, lightsLength, useShadow);
|
calculateChildVisibility(level, this, camera);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,15 +188,39 @@ package alternativa.engine3d.objects {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
alternativa3d function collectChildDraws(child:Object3D, parent:Object3D, camera:Camera3D, lights:Vector.<Light3D>, lightsLength:int, useShadow:Boolean):void {
|
alternativa3d function calculateChildVisibility(child:Object3D, parent:Object3D, camera:Camera3D):void {
|
||||||
// Composing direct and reverse matrices
|
// Composing direct and reverse matrices
|
||||||
if (child.transformChanged) child.composeTransforms();
|
if (child.transformChanged) child.composeTransforms();
|
||||||
// Calculation of transfer matrix from camera to local space.
|
// Calculation of transfer matrix from camera to local space.
|
||||||
child.cameraToLocalTransform.combine(child.inverseTransform, parent.cameraToLocalTransform);
|
child.cameraToLocalTransform.combine(child.inverseTransform, parent.cameraToLocalTransform);
|
||||||
// Calculation of transfer matrix from local space to camera.
|
// Calculation of transfer matrix from local space to camera.
|
||||||
child.localToCameraTransform.combine(parent.localToCameraTransform, child.transform);
|
child.localToCameraTransform.combine(parent.localToCameraTransform, child.transform);
|
||||||
|
|
||||||
|
if (child.mouseEnabled) camera.globalMouseHandlingType |= child.mouseHandlingType;
|
||||||
// Pass
|
// Pass
|
||||||
child.culling = parent.culling;
|
child.culling = parent.culling;
|
||||||
|
// Calculating visibility of the self content
|
||||||
|
if (child.culling >= 0) child.calculateVisibility(camera);
|
||||||
|
|
||||||
|
// Hierarchical call
|
||||||
|
for (var c:Object3D = child.childrenList; c != null; c = c.next) {
|
||||||
|
calculateChildVisibility(c, child, camera);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
override alternativa3d function collectDraws(camera:Camera3D, lights:Vector.<Light3D>, lightsLength:int, useShadow:Boolean):void {
|
||||||
|
// Level must be choosen in CalculateVisibility
|
||||||
|
if (level != null) collectChildDraws(level, this, camera, lights, lightsLength, useShadow);
|
||||||
|
level = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
alternativa3d function collectChildDraws(child:Object3D, parent:Object3D, camera:Camera3D, lights:Vector.<Light3D>, lightsLength:int, useShadow:Boolean):void {
|
||||||
child.listening = parent.listening;
|
child.listening = parent.listening;
|
||||||
// If object needs on light sources.
|
// If object needs on light sources.
|
||||||
if (lightsLength > 0 && child.useLights) {
|
if (lightsLength > 0 && child.useLights) {
|
||||||
|
|||||||
Reference in New Issue
Block a user