Permalink
Browse files

[Flash] impl. SortType and SortKey

  • Loading branch information...
1 parent 80e8234 commit d1ccd3567dee99b3582b57f0e14ed13a55ea97bb @tsturm tsturm committed May 26, 2012
@@ -49,19 +49,40 @@
<body>
<x3d x="0px" y="0px" width="1024px" height="512px" backend="flash">
<Scene DEF='scene'>
- <Viewpoint centerOfRotation='0 0 40' position='4.5 0 100'></Viewpoint>
- <Transform>
- <Shape bboxCenter="2.7269497 0 20.0641994" bboxSize="81.8891029 50.9567986 40.1283989">
- <Appearance>
- <Material diffuseColor=".7 .7 .7" specularColor=".5 .5 .5"></Material>
- <ImageTexture url="texture/DiffuseTexture.JPG"></ImageTexture>
- </Appearance>
- <BinaryGeometry primType='"TRIANGLES"' index="index.txt.bin" coord="coord.txt.bin"
- normal="normal.txt.bin" texCoord="texcoord.txt.bin" color="color.txt.bin">
- </BinaryGeometry>
- </Shape>
- </Transform>
- </Scene>
+ <Background skyColor='1 1 1'></Background>
+ <Transform translation='0 0 0'>
+ <Shape solid='false'>
+ <Appearance DEF='_01_-_Default' sortType='transparent'>
+ <Material diffuseColor='0 0 1' specularColor='0.2 0.2 0.2' shininess='0.15' transparency='0.5'></Material>
+ </Appearance>
+ <Box></Box>
+ </Shape>
+ </Transform>
+ <Transform translation='0 0 -3'>
+ <Shape solid='false'>
+ <Appearance DEF='_01_-_Default' sortType='transparent'>
+ <Material diffuseColor='0 0 1' specularColor='0.2 0.2 0.2' shininess='0.15' transparency='0.5'></Material>
+ </Appearance>
+ <Box></Box>
+ </Shape>
+ </Transform>
+ <Transform translation='0 0 -6'>
+ <Shape solid='false'>
+ <Appearance DEF='_01_-_Default' sortType='transparent'>
+ <Material diffuseColor='1 1 0' specularColor='0.2 0.2 0.2' shininess='0.15' transparency='0.5'></Material>
+ </Appearance>
+ <Box size='1 1 1'></Box>
+ </Shape>
+ </Transform>
+ <Transform translation='0 0 -9'>
+ <Shape solid='false'>
+ <Appearance DEF='_01_-_Default' sortType='transparent'>
+ <Material diffuseColor='1 1 0' specularColor='0.2 0.2 0.2' shininess='0.15' transparency='0.5'></Material>
+ </Appearance>
+ <Box size='1 1 1'></Box>
+ </Shape>
+ </Transform>
+ </Scene>
</x3d>
</body>
</html>
Binary file not shown.
@@ -162,7 +162,7 @@ package x3dom {
{
this._scene.getDrawableObject( uint(value.id) ).type = String( value.type );
this._scene.getDrawableObject( uint(value.id) ).sortType = String( value.sortType );
- this._scene.getDrawableObject( uint(value.id) ).sortKey = String( value.sortKey );
+ this._scene.getDrawableObject( uint(value.id) ).sortKey = Number( value.sortKey );
this._scene.getDrawableObject( uint(value.id) ).shape.setProperties( value );
}
@@ -90,7 +90,7 @@ package x3dom
*/
public function set sortType(sortType:String) : void
{
- this._sortType = sortType;
+ this._sortType = sortType.toLowerCase();
}
/**
@@ -88,7 +88,13 @@
*/
private function zSorting(a:DrawableObject, b:DrawableObject) : Number
{
- return this._viewMatrix.transformVector(a.center).z - this._viewMatrix.transformVector(b.center).z;
+ if(a.sortType == b.sortType) {
+ if(a.sortKey == b.sortKey) {
+ return this._viewMatrix.transformVector(a.center).z - this._viewMatrix.transformVector(b.center).z;
+ }
+ return a.sortKey - b.sortKey;
+ }
+ return (a.sortType < b.sortType) ? -1 : (a.sortType > b.sortType) ? 1 : 0;
}
/**
@@ -242,6 +248,9 @@
return this._pickedPos;
}
+ /**
+ * @private
+ */
public function get drawableObjects() : Array
{
this._drawableObjects.sort(zSorting);
@@ -174,7 +174,7 @@ package x3dom.shaders
}
shader += "sat ft3, ft3\n"; //saturate(NdotL)
- shader += "add ft3, fc3, ft3\n"; //rgb += emissiveColor
+ shader += "add ft3.xyz, fc3.xyz, ft3.xyz\n"; //rgb += emissiveColor
shader += "sub ft4, ft3, fc4\n";
shader += "kil ft4.wwww\n";
shader += "mov oc, ft3 \n"; //Output Color
@@ -193,7 +193,7 @@ package x3dom.shaders
shader += "mov ft1.w, fc1.w\n";
shader += "sat ft1, ft1\n"; //saturate(NdotL)
- shader += "add ft1, fc3, ft1\n"; //rgb += emissiveColor
+ shader += "add ft1.xyz, fc3.xyz, ft1.xyz\n"; //rgb += emissiveColor
shader += "sub ft2, ft1, fc4\n";
shader += "kil ft2.wwww\n";
shader += "mov oc, ft1 \n"; //Output Color
View
@@ -335,7 +335,7 @@ x3dom.gfx_flash = (function() {
this.object.setMeshProperties( { id: shape._objectID,
type: "ImageGeometry",
sortType: shape._cf.appearance.node._vf.sortType,
- sortKey: shape._cf.appearance.node._vf.sortType,
+ sortKey: shape._cf.appearance.node._vf.sortKey,
solid: shape.isSolid(),
bboxMin: shape._cf.geometry.node.getMin().toGL(),
bboxMax: shape._cf.geometry.node.getMax().toGL(),
@@ -347,15 +347,15 @@ x3dom.gfx_flash = (function() {
this.object.setMeshProperties( { id: shape._objectID,
type: "BinaryGeometry",
sortType: shape._cf.appearance.node._vf.sortType,
- sortKey: shape._cf.appearance.node._vf.sortType,
+ sortKey: shape._cf.appearance.node._vf.sortKey,
solid: shape.isSolid(),
primType: shape._cf.geometry.node._vf.primType,
vertexCount: shape._cf.geometry.node._vf.vertexCount } );
} else {
this.object.setMeshProperties( { id: shape._objectID,
type: "Default",
sortType: shape._cf.appearance.node._vf.sortType,
- sortKey: shape._cf.appearance.node._vf.sortType,
+ sortKey: shape._cf.appearance.node._vf.sortKey,
solid: shape.isSolid() } );
}
@@ -557,7 +557,7 @@ x3dom.gfx_flash = (function() {
this.object.setMeshProperties( { id: shape._objectID,
type: "Text",
sortType: shape._cf.appearance.node._vf.sortType,
- sortKey: shape._cf.appearance.node._vf.sortType,
+ sortKey: shape._cf.appearance.node._vf.sortKey,
solid: shape.isSolid(),
text: shape._cf.geometry.node._vf.string,
fontFamily: ['SERIF'],
@@ -573,7 +573,7 @@ x3dom.gfx_flash = (function() {
this.object.setMeshProperties( { id: shape._objectID,
type: "Text",
sortType: shape._cf.appearance.node._vf.sortType,
- sortKey: shape._cf.appearance.node._vf.sortType,
+ sortKey: shape._cf.appearance.node._vf.sortKey,
solid: shape.isSolid(),
text: shape._cf.geometry.node._vf.string,
fontFamily: fontStyleNode._vf.family.toString(),

0 comments on commit d1ccd35

Please sign in to comment.