├── .gitattributes ├── .gitignore ├── README.md ├── build.xml └── src ├── com └── adobe │ └── utils │ ├── AGALMacroAssembler.as │ ├── AGALMiniAssembler.as │ ├── extended │ └── AGALMiniAssembler.as │ └── macro │ ├── AGALPreAssembler.as │ ├── AGALVar.as │ ├── BinaryExpression.as │ ├── Expression.as │ ├── ExpressionParser.as │ ├── NumberExpression.as │ ├── UnaryExpression.as │ ├── VM.as │ └── VariableExpression.as └── zest3d ├── applications ├── AGALApplication.as ├── Application.as ├── WindowApplication.as └── Zest3DApplication.as ├── controllers ├── BlendTransformController.as ├── ControlledObject.as ├── Controller.as ├── KeyInfo.as ├── KeyframeController.as ├── ParticleController.as ├── PointController.as ├── SkinController.as ├── TransformController.as └── enum │ └── RepeatType.as ├── datatypes ├── Bound.as └── Transform.as ├── detail ├── BillboardNode.as ├── ClodMesh.as ├── CollapseRecord.as ├── CollapseRecordArray.as ├── DlodNode.as └── SwitchNode.as ├── geometry ├── ParticleGeometry.as └── SkyboxGeometry.as ├── globaleffects ├── GlobalEffect.as └── PlanarReflectionEffect.as ├── localeffects ├── CartoonEffect.as ├── DepthEffect.as ├── DiffuseNormalSpecularEffect.as ├── FlatMaterialEffect.as ├── GlassEffect.as ├── LambertEffect.as ├── MRTEffect.as ├── NormalEffect.as ├── PhongEffect.as ├── ReflectionEffect.as ├── ScreenTargetEffect.as ├── SkyboxEffect.as ├── TextureEffect.as └── WireframeEffect.as ├── primitives ├── CubePrimitive.as ├── CylinderPrimitive.as ├── PlanePrimitive.as ├── Primitive.as ├── SpherePrimitive.as ├── StandardMesh.as └── TorusPrimitive.as ├── renderers ├── Renderer.as ├── agal │ ├── AGALMapping.as │ ├── AGALRenderState.as │ ├── AGALRenderer.as │ ├── AGALRendererData.as │ ├── AGALRendererInput.as │ ├── AGALSamplerState.as │ └── pdr │ │ ├── AGALIndexBuffer.as │ │ ├── AGALPixelShader.as │ │ ├── AGALRenderTarget.as │ │ ├── AGALShader.as │ │ ├── AGALTexture2D.as │ │ ├── AGALTexture3D.as │ │ ├── AGALTextureCube.as │ │ ├── AGALTextureRectangle.as │ │ ├── AGALVertexBuffer.as │ │ ├── AGALVertexFormat.as │ │ └── AGALVertexShader.as └── interfaces │ ├── IIndexBuffer.as │ ├── IPixelShader.as │ ├── IRenderTarget.as │ ├── ITexture1D.as │ ├── ITexture2D.as │ ├── ITexture3D.as │ ├── ITextureCube.as │ ├── ITextureRectangle.as │ ├── IVertexBuffer.as │ ├── IVertexFormat.as │ └── IVertexShader.as ├── resources ├── Buffer.as ├── IndexBuffer.as ├── RenderTarget.as ├── Texture.as ├── Texture2D.as ├── Texture3D.as ├── TextureBase.as ├── TextureCube.as ├── TextureRectangle.as ├── VertexBuffer.as ├── VertexBufferAccessor.as ├── VertexElement.as ├── VertexFormat.as └── enum │ ├── AttributeType.as │ ├── AttributeUsageType.as │ ├── BufferLockingType.as │ ├── BufferUsageType.as │ ├── TextureFormat.as │ └── TextureType.as ├── scenegraph ├── Camera.as ├── CameraNode.as ├── Culler.as ├── Frustum.as ├── Light.as ├── LightNode.as ├── Material.as ├── Node.as ├── Particles.as ├── PickRecord.as ├── Picker.as ├── Polypoint.as ├── ScreenTarget.as ├── Spatial.as ├── TriFan.as ├── TriMesh.as ├── TriStrip.as ├── Triangles.as ├── VisibleSet.as ├── Visual.as └── enum │ ├── CullingType.as │ ├── LightType.as │ ├── PrimitiveType.as │ └── UpdateType.as ├── shaderfloats ├── ShaderFloat.as ├── camera │ ├── CameraModelDVectorConstant.as │ ├── CameraModelPositionConstant.as │ ├── CameraWorldDVectorConstant.as │ └── CameraWorldPositionConstant.as ├── light │ ├── LightAmbientConstant.as │ ├── LightAttenuationConstant.as │ ├── LightDiffuseConstant.as │ ├── LightModelDVectorConstant.as │ ├── LightModelPositionConstant.as │ ├── LightSpecularConstant.as │ ├── LightSpecularExponentConstant.as │ ├── LightSpotConstant.as │ ├── LightWorldDVectorConstant.as │ └── LightWorldPositionConstant.as ├── material │ ├── MaterialAmbientConstant.as │ ├── MaterialDiffuseConstant.as │ ├── MaterialEmissiveConstant.as │ └── MatrialSpecularConstant.as └── matrix │ ├── PMatrixConstant.as │ ├── PVMatrixConstant.as │ ├── PVWMatrixConstant.as │ ├── VMatrixConstant.as │ ├── VWMatrixConstant.as │ └── WMatrixConstant.as ├── shaders ├── PixelShader.as ├── Shader.as ├── ShaderParameters.as ├── VertexShader.as ├── VisualEffect.as ├── VisualEffectInstance.as ├── VisualPass.as ├── VisualTechnique.as ├── enum │ ├── CompareMode.as │ ├── DstBlendMode.as │ ├── OperationType.as │ ├── PixelShaderProfileType.as │ ├── SamplerCoordinateType.as │ ├── SamplerFilterType.as │ ├── SamplerType.as │ ├── SrcBlendMode.as │ ├── VariableSemanticType.as │ ├── VariableType.as │ └── VertexShaderProfileType.as └── states │ ├── AlphaState.as │ ├── CullState.as │ ├── DepthState.as │ ├── OffsetState.as │ ├── StencilState.as │ └── WireState.as └── terrain ├── Terrain.as └── TerrainPage.as /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | zest3d-core 2 | =========== 3 | 4 | Zest3D 5 | 6 | Distributed under the Boost Software License, Version 1.0. 7 | 8 | http://www.boost.org/LICENSE_1_0.txt 9 | 10 | ;) 11 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Running target Build 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/com/adobe/utils/macro/AGALVar.as: -------------------------------------------------------------------------------- 1 | package com.adobe.utils.macro 2 | { 3 | /** 4 | * Class to record information about all the aliases in an AGAL 5 | * shader. Typically a program is interested in making sure all 6 | * the needed constants are set in the constant pool. If isConstant() 7 | * return true, then the x,y,z,w members contain the values required 8 | * for the shader to run correctly. 9 | */ 10 | public class AGALVar 11 | { 12 | public function AGALVar() { }; 13 | public var name:String; // transform 14 | public var target:String; // "vc3", "va2.x" 15 | public var x:Number = Number.NaN; 16 | public var y:Number = Number.NaN; 17 | public var z:Number = Number.NaN; 18 | public var w:Number = Number.NaN; 19 | 20 | public function isConstant():Boolean { return !isNaN( x ); } 21 | public function toString():String { 22 | if ( this.isConstant() ) 23 | return "alias " + target + ", " + name + "( " + x + ", " + y + ", " + z + ", " + w + " )"; 24 | else 25 | return "alias " + target + ", " + name; 26 | } 27 | 28 | } 29 | } -------------------------------------------------------------------------------- /src/com/adobe/utils/macro/BinaryExpression.as: -------------------------------------------------------------------------------- 1 | package com.adobe.utils.macro 2 | { 3 | internal class BinaryExpression extends com.adobe.utils.macro.Expression 4 | { 5 | public function BinaryExpression() { }; 6 | public var op:String; 7 | public var left:Expression; 8 | public var right:Expression; 9 | override public function print( depth:int ):void { 10 | if ( AGALPreAssembler.TRACE_VM ) { 11 | trace( spaces( depth ) + "binary op " + op ); 12 | } 13 | left.print( depth+1 ); 14 | right.print( depth+1 ); 15 | } 16 | 17 | override public function exec( vm:VM ):void { 18 | var varLeft:Number = Number.NaN; 19 | var varRight:Number = Number.NaN; 20 | 21 | left.exec( vm ); 22 | varLeft = vm.stack.pop(); 23 | right.exec( vm ); 24 | varRight = vm.stack.pop(); 25 | 26 | if ( isNaN( varLeft ) ) throw new Error( "Left side of binary expression (" + op + ") is NaN" ); 27 | if ( isNaN( varRight ) ) throw new Error( "Right side of binary expression (" + op + ") is NaN" ); 28 | 29 | switch( op ) { 30 | case "*": 31 | vm.stack.push( varLeft * varRight ); 32 | break; 33 | case "/": 34 | vm.stack.push( varLeft / varRight ); 35 | break; 36 | case "+": 37 | vm.stack.push( varLeft + varRight ); 38 | break; 39 | case "-": 40 | vm.stack.push( varLeft - varRight ); 41 | break; 42 | case ">": 43 | vm.stack.push( (varLeft > varRight) ? 1 : 0 ); 44 | break; 45 | case "<": 46 | vm.stack.push( (varLeft < varRight) ? 1 : 0 ); 47 | break; 48 | case ">=": 49 | vm.stack.push( (varLeft >= varRight) ? 1 : 0 ); 50 | break; 51 | case ">=": 52 | vm.stack.push( (varLeft <= varRight) ? 1 : 0 ); 53 | break; 54 | case "==": 55 | vm.stack.push( (varLeft==varRight) ? 1 : 0 ); 56 | break; 57 | case "!=": 58 | vm.stack.push( (varLeft!=varRight) ? 1 : 0 ); 59 | break; 60 | case "&&": 61 | vm.stack.push( (Boolean(varLeft) && Boolean(varRight)) ? 1 : 0 ); 62 | break; 63 | case "||": 64 | vm.stack.push( (Boolean(varLeft) || Boolean(varRight)) ? 1 : 0 ); 65 | break; 66 | 67 | default: 68 | throw new Error( "unimplemented BinaryExpression exec" ); 69 | break; 70 | } 71 | if ( AGALPreAssembler.TRACE_VM ) { 72 | trace( "::BinaryExpression op" + op + " left=" + varLeft + " right=" +varRight + " push " + vm.stack[vm.stack.length-1] ); 73 | } 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /src/com/adobe/utils/macro/Expression.as: -------------------------------------------------------------------------------- 1 | package com.adobe.utils.macro 2 | { 3 | import com.adobe.utils.macro.VM; 4 | 5 | public class Expression 6 | { 7 | public function print( depth:int ):void { trace( "top" ); } 8 | public function exec( vm:VM ):void { 9 | trace( "WTF" ); 10 | } 11 | 12 | protected function spaces( depth:int ):String 13 | { 14 | // Must be a clever way to do this... 15 | var str:String = ""; 16 | for( var i:int=0; i = new Vector.(); 51 | private var m_ifWasTrue:Vector. = new Vector.(); 52 | } 53 | } -------------------------------------------------------------------------------- /src/com/adobe/utils/macro/VariableExpression.as: -------------------------------------------------------------------------------- 1 | package com.adobe.utils.macro 2 | { 3 | internal class VariableExpression extends com.adobe.utils.macro.Expression 4 | { 5 | public function VariableExpression( n:String ) 6 | { 7 | name = n; 8 | } 9 | public var name:String; 10 | override public function print( depth:int ):void { trace( spaces( depth ) + "variable=" + name ); } 11 | 12 | override public function exec( vm:VM ):void { 13 | if ( AGALPreAssembler.TRACE_VM ) { 14 | trace( "::VariableExpression push var " + name + " value " + vm.vars[ name] ); 15 | } 16 | if ( isNaN( vm.vars[ name] ) ) throw new Error( "VariableExpression NaN. name=" + name ); 17 | vm.stack.push( vm.vars[ name] ); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/zest3d/applications/Application.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013-2014 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.applications 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | 15 | /** 16 | * ... 17 | * @author Gary Paluk 18 | */ 19 | public class Application implements IDisposable 20 | { 21 | 22 | public static const ZEST3D_PATH: String = ""; 23 | public static const PROJECT_PATH: String = ""; 24 | 25 | public function Application() 26 | { 27 | 28 | } 29 | 30 | public function dispose(): void 31 | { 32 | 33 | } 34 | 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /src/zest3d/controllers/Controller.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.controllers 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.core.system.object.PluginObject; 15 | import zest3d.controllers.enum.RepeatType; 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public class Controller extends PluginObject implements IDisposable 21 | { 22 | 23 | public var repeat: RepeatType; 24 | public var minTime: Number; 25 | public var maxTime: Number; 26 | public var phase: Number; 27 | public var frequency: Number; 28 | public var active: Boolean; 29 | 30 | protected var _object: ControlledObject; 31 | protected var _applicationTime: Number; 32 | 33 | public function Controller() 34 | { 35 | repeat = RepeatType.CLAMP; 36 | minTime = 0; 37 | maxTime = 0; 38 | phase = 0; 39 | frequency = 1; 40 | active = true; 41 | _object = null; 42 | _applicationTime = -Number.MAX_VALUE; 43 | } 44 | 45 | public function dispose(): void 46 | { 47 | //TODO 48 | } 49 | 50 | 51 | [Inline] 52 | public function get object(): ControlledObject 53 | { 54 | return _object; 55 | } 56 | 57 | [Inline] 58 | public function get applicationTime(): Number 59 | { 60 | return _applicationTime; 61 | } 62 | 63 | [Inline] 64 | public function set applicationTime( applicationTime: Number ): void 65 | { 66 | _applicationTime = applicationTime; 67 | } 68 | 69 | // virtual 70 | public function update( applicationTime: Number ): Boolean 71 | { 72 | if ( active ) 73 | { 74 | _applicationTime = applicationTime; 75 | return true; 76 | } 77 | return false; 78 | } 79 | 80 | // internal use 81 | public function set object( object: ControlledObject ): void 82 | { 83 | _object = object; 84 | } 85 | 86 | protected function getControlTime( applicationTime: Number ): Number 87 | { 88 | var controlTime: Number = frequency * applicationTime + phase; 89 | 90 | if ( repeat == RepeatType.CLAMP ) 91 | { 92 | if ( controlTime < minTime ) 93 | { 94 | return minTime; 95 | } 96 | if ( controlTime > maxTime ) 97 | { 98 | return maxTime; 99 | } 100 | return controlTime; 101 | } 102 | 103 | var timeRange: Number = maxTime - minTime; 104 | if ( timeRange > 0 ) 105 | { 106 | var multples: Number = ( controlTime - minTime ) / timeRange; 107 | var integerTime: Number = Math.floor( multples ); 108 | var fractionTime: Number = multples - integerTime; 109 | 110 | if ( repeat == RepeatType.WRAP ) 111 | { 112 | return minTime + fractionTime * timeRange; 113 | } 114 | 115 | if ( (int( integerTime ) & 1) ) 116 | { 117 | return maxTime - fractionTime * timeRange; 118 | } 119 | else 120 | { 121 | return minTime + fractionTime * timeRange; 122 | } 123 | } 124 | 125 | return minTime; 126 | } 127 | 128 | //{ NAME SUPPORT 129 | override public function getObjectByName( name: String ): Object 130 | { 131 | return super.getObjectByName( name ); 132 | } 133 | 134 | override public function getAllObjectsByName(name:String, objects:Vector.):void 135 | { 136 | super.getAllObjectsByName(name, objects); 137 | } 138 | //} 139 | } 140 | 141 | } -------------------------------------------------------------------------------- /src/zest3d/controllers/KeyInfo.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.controllers 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class KeyInfo 18 | { 19 | public var ctrlTime: Number = 0; 20 | public var numTimes: int = 0; 21 | public var times: Array = []; 22 | public var lastIndex: int = -1; 23 | public var normTime: Number = 0; 24 | public var i0: int = 0; 25 | public var i1: int = 0; 26 | 27 | public function KeyInfo() { }; 28 | 29 | public function set( ctrlTime: Number, numTimes: int, times: Array, lastIndex: int, normTime: Number, i0: int, i1: int ): void 30 | { 31 | this.ctrlTime = ctrlTime; 32 | this.numTimes = numTimes; 33 | this.times = times; 34 | this.lastIndex = lastIndex; 35 | this.normTime = normTime; 36 | this.i0 = i0; 37 | this.i1 = i1; 38 | } 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/zest3d/controllers/TransformController.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.controllers 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.datatypes.Transform; 15 | import zest3d.scenegraph.Spatial; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class TransformController extends Controller implements IDisposable 22 | { 23 | 24 | protected var _localTransform: Transform; 25 | 26 | public function TransformController( localTransform: Transform ) 27 | { 28 | _localTransform = localTransform; 29 | } 30 | 31 | override public function dispose():void 32 | { 33 | _localTransform.dispose(); 34 | _localTransform = null; 35 | 36 | super.dispose(); 37 | } 38 | 39 | [Inline] 40 | public final function set transform( localTransform: Transform ): void 41 | { 42 | _localTransform = localTransform; 43 | } 44 | 45 | [Inline] 46 | public final function get transform(): Transform 47 | { 48 | return _localTransform; 49 | } 50 | 51 | // virtual 52 | override public function update( applicationTime: Number ): Boolean 53 | { 54 | if ( !super.update( applicationTime ) ) 55 | { 56 | return false; 57 | } 58 | var spatial: Spatial = _object as Spatial; 59 | spatial.localTransform = _localTransform; 60 | return true; 61 | } 62 | 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/zest3d/controllers/enum/RepeatType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.controllers.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class RepeatType 18 | { 19 | 20 | public static const CLAMP: RepeatType = new RepeatType( "clamp" ); 21 | public static const WRAP: RepeatType = new RepeatType( "wrap" ); 22 | public static const CYCLE: RepeatType = new RepeatType( "cycle" ); 23 | 24 | protected var _type: String; 25 | 26 | public function RepeatType( type: String ) 27 | { 28 | _type = type; 29 | } 30 | 31 | public function get type():String 32 | { 33 | return _type; 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /src/zest3d/detail/BillboardNode.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.detail 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.APoint; 15 | import io.plugin.math.algebra.AVector; 16 | import io.plugin.math.algebra.HMatrix; 17 | import zest3d.scenegraph.Camera; 18 | import zest3d.scenegraph.Node; 19 | import zest3d.scenegraph.Spatial; 20 | 21 | /** 22 | * ... 23 | * @author Gary Paluk 24 | */ 25 | public class BillboardNode extends Node implements IDisposable 26 | { 27 | 28 | protected var _camera:Camera; 29 | 30 | public function BillboardNode( camera: Camera = null ) 31 | { 32 | super(); 33 | _camera = camera; 34 | } 35 | 36 | override public function dispose(): void 37 | { 38 | super.dispose(); 39 | } 40 | 41 | public function alignTo( camera: Camera ): void 42 | { 43 | _camera = camera; 44 | } 45 | 46 | override protected function updateWorldData( applicationTime: Number ): void 47 | { 48 | super.updateWorldData( applicationTime ); 49 | 50 | if ( _camera ) 51 | { 52 | var modelPos:APoint = worldTransform.inverse.multiplyAPoint( _camera.position ); 53 | 54 | var angle: Number = Math.atan2( modelPos.x, modelPos.z ); 55 | var orient: HMatrix = new HMatrix().rotation( AVector.UNIT_Y, angle ); 56 | 57 | worldTransform.rotate = worldTransform.rotate.multiply( orient ); 58 | } 59 | 60 | var child: Spatial; 61 | for each( child in _child ) 62 | { 63 | child.update( applicationTime, false ); 64 | } 65 | } 66 | 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /src/zest3d/detail/ClodMesh.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.detail 12 | { 13 | import flash.utils.ByteArray; 14 | import io.plugin.core.interfaces.IDisposable; 15 | import io.plugin.core.system.Assert; 16 | import zest3d.renderers.Renderer; 17 | import zest3d.scenegraph.Culler; 18 | import zest3d.scenegraph.TriMesh; 19 | 20 | /** 21 | * ... 22 | * @author Gary Paluk 23 | */ 24 | public class ClodMesh extends TriMesh implements IDisposable 25 | { 26 | 27 | protected var _currentRecord: int; 28 | protected var _targetRecord: int; 29 | protected var _recordArray: CollapseRecordArray; 30 | 31 | public function ClodMesh( mesh: TriMesh, recordArray: CollapseRecordArray ) 32 | { 33 | super( mesh.vertexFormat, mesh.vertexBuffer, mesh.indexBuffer ); 34 | 35 | _currentRecord = 0; 36 | _targetRecord = 0; 37 | 38 | _recordArray = recordArray; 39 | } 40 | 41 | override public function dispose():void 42 | { 43 | _recordArray.dispose(); 44 | _recordArray = null; 45 | 46 | super.dispose(); 47 | } 48 | 49 | [Inline] 50 | public final function get numRecords(): int 51 | { 52 | return _recordArray.numRecords; 53 | } 54 | 55 | [Inline] 56 | public final function get targetRecord(): int 57 | { 58 | return _targetRecord; 59 | } 60 | 61 | // virtual 62 | [Inline] 63 | public final function get automatedTargetRecord(): int 64 | { 65 | return _targetRecord; 66 | } 67 | 68 | public function selectLevelOfDetail(): void 69 | { 70 | var records: CollapseRecord = _recordArray.records; 71 | 72 | var targetRecord: int = automatedTargetRecord; 73 | 74 | var indices: ByteArray = _iBuffer.data; 75 | var iBufferChanged: Boolean = (_currentRecord != targetRecord ); 76 | 77 | var i: int; 78 | var c: int; 79 | var record: CollapseRecord; 80 | while ( _currentRecord < targetRecord ) 81 | { 82 | ++_currentRecord; 83 | 84 | record = record[ _currentRecord ]; 85 | for ( i = 0; i < record.numIndices; ++i ) 86 | { 87 | c = record.indices[ i ]; 88 | Assert.isTrue( indices[ c ] == record.vThrow, "Inconsistent record in SelectLevelOfDetail." ); 89 | 90 | indices.position = c * 4; 91 | indices.writeUnsignedInt( record.vKeep ); 92 | } 93 | 94 | _vBuffer.numElements = record.numVertices; 95 | _iBuffer.numElements = 3 * record.numTriangles; 96 | } 97 | 98 | while ( _currentRecord > targetRecord ) 99 | { 100 | record = records[ _currentRecord ]; 101 | for ( i = 0; i < record.numIndices; ++i ) 102 | { 103 | c = record.indices[ i ]; 104 | Assert.isTrue( indices[ c ] == record.vKeep, "Inconsistent record in SelectLevelOfDetail." ); 105 | 106 | indices[ c ] = record.vThrow; 107 | } 108 | 109 | --_currentRecord; 110 | var prevRecord: CollapseRecord = records[ _currentRecord ]; 111 | 112 | _vBuffer.numElements = prevRecord.numVertices; 113 | _iBuffer.numElements = 3 * prevRecord.numTriangles; 114 | } 115 | 116 | if ( iBufferChanged ) 117 | { 118 | Renderer.updateAllIndexBuffer( _iBuffer ); 119 | } 120 | } 121 | 122 | 123 | // virtual 124 | override public function getVisibleSet(culler:Culler, noCull:Boolean):void 125 | { 126 | selectLevelOfDetail(); 127 | super.getVisibleSet(culler, noCull); 128 | } 129 | } 130 | 131 | } -------------------------------------------------------------------------------- /src/zest3d/detail/CollapseRecord.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.detail 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | 15 | /** 16 | * ... 17 | * @author Gary Paluk 18 | */ 19 | public class CollapseRecord implements IDisposable 20 | { 21 | 22 | public var vKeep: int; 23 | public var vThrow: int; 24 | public var numVertices: int; 25 | public var numTriangles: int; 26 | 27 | public var numIndices: int; 28 | public var indices: Array; 29 | 30 | public function CollapseRecord( vKeep: int = -1, vThrow: int = -1, numVertices: int = 0, numTriangles: int = 0 ) 31 | { 32 | this.vKeep = vKeep; 33 | this.vThrow = vThrow; 34 | this.numVertices = numVertices; 35 | this.numTriangles = numTriangles; 36 | 37 | numIndices = 0; 38 | indices = []; 39 | } 40 | 41 | public function dispose(): void 42 | { 43 | indices.length = 0; 44 | indices = null; 45 | } 46 | 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /src/zest3d/detail/CollapseRecordArray.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.detail 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | 15 | /** 16 | * ... 17 | * @author Gary Paluk 18 | */ 19 | public class CollapseRecordArray implements IDisposable 20 | { 21 | 22 | protected var _numRecords: int; 23 | protected var _records:CollapseRecord; 24 | 25 | public function CollapseRecordArray( numRecords: int, records: CollapseRecord ) 26 | { 27 | _records = records; 28 | _numRecords = numRecords; 29 | } 30 | 31 | public function dispose(): void 32 | { 33 | _records.dispose(); 34 | _records = null; 35 | } 36 | 37 | [Inline] 38 | public final function get numRecords(): int 39 | { 40 | return _numRecords; 41 | } 42 | 43 | [Inline] 44 | public final function get records(): CollapseRecord 45 | { 46 | return _records; 47 | } 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/zest3d/detail/SwitchNode.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.detail 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.core.system.Assert; 15 | import zest3d.scenegraph.Culler; 16 | import zest3d.scenegraph.Node; 17 | import zest3d.scenegraph.Spatial; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class SwitchNode extends Node implements IDisposable 24 | { 25 | 26 | public static const INVALID_CHILD: int = -1; 27 | 28 | protected var _activeChild: int; 29 | 30 | public function SwitchNode( ) 31 | { 32 | _activeChild = INVALID_CHILD; 33 | } 34 | 35 | override public function dispose(): void 36 | { 37 | super.dispose(); 38 | } 39 | 40 | override public function getVisibleSet( culler: Culler, noCull: Boolean ): void 41 | { 42 | if ( _activeChild == INVALID_CHILD ) 43 | { 44 | return; 45 | } 46 | 47 | var child: Spatial = _child[ _activeChild ]; 48 | if ( child ) 49 | { 50 | child.onGetVisibleSet( culler, noCull ); 51 | } 52 | } 53 | 54 | [Inline] 55 | public final function set activeChild( activeChild: int ): void 56 | { 57 | Assert.isTrue( activeChild == INVALID_CHILD 58 | || activeChild < _child.length , "Invalid active child specified." ) 59 | _activeChild = activeChild; 60 | } 61 | 62 | [Inline] 63 | public final function get activeChild(): int 64 | { 65 | return _activeChild; 66 | } 67 | 68 | [Inline] 69 | public final function disableAllChildren(): void 70 | { 71 | _activeChild = INVALID_CHILD; 72 | } 73 | 74 | 75 | 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /src/zest3d/geometry/ParticleGeometry.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.geometry 12 | { 13 | import flash.utils.ByteArray; 14 | import zest3d.localeffects.TextureEffect; 15 | import zest3d.resources.enum.AttributeType; 16 | import zest3d.resources.enum.AttributeUsageType; 17 | import zest3d.resources.VertexBuffer; 18 | import zest3d.resources.VertexFormat; 19 | import zest3d.scenegraph.Particles; 20 | import zest3d.shaders.enum.DstBlendMode; 21 | import zest3d.shaders.enum.SrcBlendMode; 22 | import zest3d.shaders.states.AlphaState; 23 | import zest3d.shaders.states.DepthState; 24 | 25 | /** 26 | * ... 27 | * @author Gary Paluk - http://www.plugin.io 28 | */ 29 | public class ParticleGeometry extends Particles 30 | { 31 | 32 | // TODO... create Particle geometry specific shaders and set states in there. 33 | public function ParticleGeometry( effect:TextureEffect, numParticles:int, positionSizes:ByteArray, sizeAdjust:Number = 1 ) 34 | { 35 | this.effect = effect; 36 | 37 | var alphaState:AlphaState = effect.getPass(0).alphaState; 38 | alphaState.blendEnabled = true; 39 | alphaState.srcBlend = SrcBlendMode.ONE; 40 | alphaState.dstBlend = DstBlendMode.ONE; 41 | 42 | var depthState:DepthState = effect.getPass(0).depthState; 43 | depthState.enabled = false; 44 | 45 | var vFormat:VertexFormat = new VertexFormat( 2 ); 46 | vFormat.setAttribute( 0, 0, 0, AttributeUsageType.POSITION, AttributeType.FLOAT3, 0 ); 47 | vFormat.setAttribute( 1, 0, 12, AttributeUsageType.TEXCOORD, AttributeType.FLOAT2, 0 ); 48 | vFormat.stride = 20; 49 | 50 | var vBuffer:VertexBuffer = new VertexBuffer( numParticles * 4, vFormat.stride ); 51 | 52 | super( vFormat, vBuffer, 2, positionSizes, sizeAdjust ); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/zest3d/globaleffects/GlobalEffect.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.globaleffects 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.renderers.Renderer; 15 | import zest3d.scenegraph.VisibleSet; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class GlobalEffect implements IDisposable 22 | { 23 | 24 | public function GlobalEffect() 25 | { 26 | 27 | } 28 | 29 | public function dispose(): void 30 | { 31 | 32 | } 33 | 34 | // virtual 35 | public function draw( renderer: Renderer, visible: VisibleSet ): void 36 | { 37 | } 38 | 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/zest3d/localeffects/MRTEffect.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.localeffects 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.resources.Texture2D; 15 | import zest3d.shaderfloats.matrix.PVWMatrixConstant; 16 | import zest3d.shaders.enum.SamplerCoordinateType; 17 | import zest3d.shaders.enum.SamplerFilterType; 18 | import zest3d.shaders.PixelShader; 19 | import zest3d.shaders.VisualEffect; 20 | import zest3d.shaders.VisualEffectInstance; 21 | 22 | /** 23 | * ... 24 | * @author Gary Paluk 25 | */ 26 | public class MRTEffect extends VisualEffect implements IDisposable 27 | { 28 | 29 | public function MRTEffect( texture0:Texture2D, texture1:Texture2D ) 30 | { 31 | var instance:VisualEffectInstance = new VisualEffectInstance( this, 0 ); 32 | instance.setVertexConstantByHandle( 0, 0, new PVWMatrixConstant() ); 33 | instance.setPixelTextureByHandle( 0, 0, texture0 ); 34 | instance.setPixelTextureByHandle( 0, 1, texture1 ); 35 | 36 | super(); 37 | 38 | var pShader:PixelShader = getPixelShader( 0, 0 ); 39 | 40 | // sampler0 41 | pShader.setFilter( 0, SamplerFilterType.LINEAR ); 42 | pShader.setCoordinate( 0, 0, SamplerCoordinateType.CLAMP_EDGE ); 43 | pShader.setCoordinate( 0, 1, SamplerCoordinateType.CLAMP_EDGE ); 44 | 45 | // sampler1 46 | pShader.setFilter( 1, SamplerFilterType.LINEAR ); 47 | pShader.setCoordinate( 1, 0, SamplerCoordinateType.CLAMP_EDGE ); 48 | pShader.setCoordinate( 1, 1, SamplerCoordinateType.CLAMP_EDGE ); 49 | } 50 | 51 | override public function dispose():void 52 | { 53 | super.dispose(); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /src/zest3d/localeffects/NormalEffect.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.localeffects 12 | { 13 | import zest3d.shaderfloats.matrix.PVWMatrixConstant; 14 | import zest3d.shaders.enum.VariableSemanticType; 15 | import zest3d.shaders.enum.VariableType; 16 | import zest3d.shaders.PixelShader; 17 | import zest3d.shaders.states.AlphaState; 18 | import zest3d.shaders.states.CullState; 19 | import zest3d.shaders.states.DepthState; 20 | import zest3d.shaders.states.OffsetState; 21 | import zest3d.shaders.states.StencilState; 22 | import zest3d.shaders.states.WireState; 23 | import zest3d.shaders.VertexShader; 24 | import zest3d.shaders.VisualEffect; 25 | import zest3d.shaders.VisualEffectInstance; 26 | import zest3d.shaders.VisualPass; 27 | import zest3d.shaders.VisualTechnique; 28 | 29 | /** 30 | * ... 31 | * @author Gary Paluk - http://www.plugin.io 32 | */ 33 | public class NormalEffect extends VisualEffectInstance 34 | { 35 | 36 | public static const msAGALVRegisters: Array = [ 0 ]; 37 | public static const msAGALPRegisters: Array = [ 0 ]; 38 | 39 | public static const msVRegisters: Array = 40 | [ 41 | null, 42 | msAGALVRegisters, 43 | null, 44 | null, 45 | null 46 | ]; 47 | 48 | public static const msPRegisters: Array = 49 | [ 50 | null, 51 | msAGALPRegisters, 52 | null, 53 | null, 54 | null 55 | ]; 56 | 57 | public static const msVPrograms: Array = 58 | [ 59 | "", 60 | // AGAL_1_0 61 | "m44 vt0 va0 vc0 \n" + 62 | "mov op vt0 \n" + 63 | 64 | "m33 vt1.xyz va1 vc0 \n" + 65 | "mov vt1.w va1.w \n" + 66 | "mov v0 vt1", 67 | // AGAL_2_0 68 | "", 69 | "", 70 | "" 71 | ]; 72 | 73 | public static const msPPrograms: Array = 74 | [ 75 | "", 76 | // AGAL_1_0 77 | "mov oc v0", 78 | // AGAL_2_0 79 | "", 80 | "", 81 | "" 82 | ]; 83 | 84 | private var _visualEffect:VisualEffect; 85 | 86 | public function NormalEffect() 87 | { 88 | 89 | var vShader: VertexShader = new VertexShader( "Zest3D.NormalEffect", 2, 1, 1, 0, false ); 90 | vShader.setInput( 0, "modelPosition", VariableType.FLOAT3, VariableSemanticType.POSITION ); 91 | vShader.setInput( 1, "modelNormal", VariableType.FLOAT3, VariableSemanticType.NORMAL ); 92 | vShader.setOutput( 0, "clipPosition", VariableType.FLOAT4, VariableSemanticType.POSITION ); 93 | vShader.setConstant( 0, "PVWMatrix", 4 ); 94 | vShader.setBaseRegisters( msVRegisters ); 95 | vShader.setPrograms( msVPrograms ); 96 | 97 | var pShader: PixelShader = new PixelShader( "Zest3D.NormalEffect", 0, 1, 0, 0, false ); 98 | pShader.setOutput( 0, "pixelColor", VariableType.FLOAT4, VariableSemanticType.COLOR0 ); 99 | pShader.setBaseRegisters( msPRegisters ); 100 | pShader.setPrograms( msPPrograms ); 101 | 102 | var pass: VisualPass = new VisualPass(); 103 | pass.vertexShader = vShader; 104 | pass.pixelShader = pShader; 105 | pass.alphaState = new AlphaState(); 106 | pass.cullState = new CullState(); 107 | pass.depthState = new DepthState(); 108 | pass.offsetState = new OffsetState(); 109 | pass.stencilState = new StencilState(); 110 | pass.wireState = new WireState(); 111 | 112 | var technique: VisualTechnique = new VisualTechnique(); 113 | technique.insertPass( pass ); 114 | 115 | _visualEffect = new VisualEffect(); 116 | _visualEffect.insertTechnique( technique ); 117 | 118 | super( _visualEffect, 0 ); 119 | 120 | setVertexConstantByHandle( 0, 0, new PVWMatrixConstant() ); 121 | } 122 | 123 | public function get visualEffect():VisualEffect 124 | { 125 | return _visualEffect; 126 | } 127 | } 128 | 129 | } -------------------------------------------------------------------------------- /src/zest3d/primitives/CubePrimitive.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.primitives 12 | { 13 | import zest3d.datatypes.Transform; 14 | import zest3d.resources.VertexFormat; 15 | import zest3d.scenegraph.TriMesh; 16 | import zest3d.shaders.VisualEffectInstance; 17 | 18 | /** 19 | * ... 20 | * @author Gary Paluk - http://www.plugin.io 21 | */ 22 | public class CubePrimitive extends Primitive 23 | { 24 | 25 | public function CubePrimitive( effect:VisualEffectInstance, hasTexCoords:Boolean = true, hasNormals: Boolean = true, hasBinormals:Boolean = false, hasTangents:Boolean = false, xExtent:int = 1, yExtent:int = 1, zExtent:Number = 1, bothSides:Boolean = false, isStatic:Boolean = true, inside:Boolean = false, transform:Transform = null ) 26 | { 27 | this.effect = effect; 28 | this.bothSides = bothSides; 29 | var vFormat:VertexFormat = generateVertexFormat( hasTexCoords, hasNormals, hasBinormals, hasTangents ); 30 | var primitive:TriMesh = new StandardMesh( vFormat, isStatic, inside, transform ).box( xExtent, yExtent, zExtent ); 31 | super( vFormat, primitive.vertexBuffer, primitive.indexBuffer ); 32 | } 33 | 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/zest3d/primitives/CylinderPrimitive.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.primitives 12 | { 13 | import zest3d.datatypes.Transform; 14 | import zest3d.resources.VertexFormat; 15 | import zest3d.scenegraph.TriMesh; 16 | import zest3d.shaders.VisualEffectInstance; 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class CylinderPrimitive extends Primitive 22 | { 23 | 24 | public function CylinderPrimitive( effect:VisualEffectInstance, hasTexCoords:Boolean = true, hasNormals: Boolean = true, hasBinormals:Boolean = false, hasTangents:Boolean = false, axisSamples:int = 4, radialSamples:int = 16, radius:Number = 1, height:Number = 2, open:Boolean = false, bothSides:Boolean = false, isStatic:Boolean = true, inside:Boolean = false, transform:Transform = null ) 25 | { 26 | this.effect = effect; 27 | this.bothSides = bothSides; 28 | 29 | var vFormat:VertexFormat = generateVertexFormat( hasTexCoords, hasNormals, hasBinormals, hasTangents ); 30 | var primitive:TriMesh = new StandardMesh( vFormat, isStatic, inside, transform ).cylinder( axisSamples, radialSamples, radius, height, open ); 31 | 32 | super( vFormat, primitive.vertexBuffer, primitive.indexBuffer ); 33 | } 34 | 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /src/zest3d/primitives/PlanePrimitive.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.primitives 12 | { 13 | import zest3d.datatypes.Transform; 14 | import zest3d.resources.VertexFormat; 15 | import zest3d.scenegraph.TriMesh; 16 | import zest3d.shaders.VisualEffectInstance; 17 | /** 18 | * ... 19 | * @author Gary Paluk - http://www.plugin.io 20 | */ 21 | public class PlanePrimitive extends Primitive 22 | { 23 | 24 | public function PlanePrimitive( effect:VisualEffectInstance, hasTexCoords:Boolean = true, hasNormals: Boolean = true, hasBinormals:Boolean = false, hasTangents:Boolean = false, xSamples:int = 2, ySamples:int = 2, xExtent:Number = 1, yExtent:Number = 1, bothSides:Boolean = false, isStatic:Boolean = true, inside:Boolean = false, transform:Transform = null ) 25 | { 26 | this.effect = effect; 27 | this.bothSides = bothSides; 28 | var vFormat:VertexFormat = generateVertexFormat( hasTexCoords, hasNormals, hasBinormals, hasTangents ); 29 | var primitive:TriMesh = new StandardMesh( vFormat, isStatic, inside, transform ).rectangle( xSamples, ySamples, xExtent, yExtent ); 30 | 31 | super( vFormat, primitive.vertexBuffer, primitive.indexBuffer ); 32 | } 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /src/zest3d/primitives/Primitive.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.primitives 12 | { 13 | import zest3d.resources.enum.AttributeType; 14 | import zest3d.resources.enum.AttributeUsageType; 15 | import zest3d.resources.IndexBuffer; 16 | import zest3d.resources.VertexBuffer; 17 | import zest3d.resources.VertexFormat; 18 | import zest3d.scenegraph.enum.UpdateType; 19 | import zest3d.scenegraph.TriMesh; 20 | import zest3d.shaders.states.CullState; 21 | 22 | /** 23 | * ... 24 | * @author Gary Paluk - http://www.plugin.io 25 | */ 26 | public class Primitive extends TriMesh 27 | { 28 | 29 | public function Primitive( vFormat:VertexFormat, vertexBuffer:VertexBuffer, indexBuffer:IndexBuffer ) 30 | { 31 | super( vFormat, vertexBuffer, indexBuffer ); 32 | updateModelSpaceVBA(); 33 | } 34 | 35 | protected function updateModelSpaceVBA():void 36 | { 37 | trace( "has normals " + _vba.hasNormal() ); 38 | 39 | if ( _vba.hasTangent() || _vba.hasBinormal() ) 40 | { 41 | if ( _vba.hasTCoord(0) ) 42 | { 43 | updateModelSpace( UpdateType.USE_TCOORD_CHANNEL ); 44 | } 45 | else 46 | { 47 | updateModelSpace( UpdateType.USE_GEOMETRY ); 48 | } 49 | } 50 | } 51 | 52 | protected function generateVertexFormat( hasTexCoords:Boolean = false, hasNormals:Boolean = false, hasBinormals:Boolean = false, hasTangents:Boolean = false ):VertexFormat 53 | { 54 | var numAttributes:Number = 0; 55 | var index:Number = 0; 56 | var offset:Number = 0; 57 | var stride:Number = 0; 58 | 59 | numAttributes++; 60 | 61 | if ( hasTexCoords ) 62 | { 63 | numAttributes++; 64 | } 65 | if ( hasNormals) 66 | { 67 | numAttributes++; 68 | } 69 | if ( hasBinormals ) 70 | { 71 | numAttributes++; 72 | } 73 | if ( hasTangents ) 74 | { 75 | numAttributes++; 76 | } 77 | var vFormat:VertexFormat = new VertexFormat( numAttributes ); 78 | 79 | // positions 80 | vFormat.setAttribute( index, 0, offset, AttributeUsageType.POSITION, AttributeType.FLOAT3, 0 ); 81 | offset += 12; 82 | stride += 12; 83 | index++; 84 | 85 | // texcoords 86 | if ( hasTexCoords ) 87 | { 88 | vFormat.setAttribute( index, 0, offset, AttributeUsageType.TEXCOORD, AttributeType.FLOAT2, 0 ); 89 | offset += 2*4; 90 | index++; 91 | stride += 8; 92 | } 93 | 94 | // normals 95 | if ( hasNormals ) 96 | { 97 | vFormat.setAttribute( index, 0, offset, AttributeUsageType.NORMAL, AttributeType.FLOAT3, 0 ); 98 | offset += 3*4; 99 | index++; 100 | stride += 12; 101 | } 102 | 103 | // binormals 104 | if ( hasBinormals ) 105 | { 106 | vFormat.setAttribute( index, 0, offset, AttributeUsageType.BINORMAL, AttributeType.FLOAT3, 0 ); 107 | offset += 3*4; 108 | index++; 109 | stride += 12; 110 | } 111 | 112 | 113 | // tangents 114 | if ( hasTangents ) 115 | { 116 | vFormat.setAttribute( index, 0, offset, AttributeUsageType.TANGENT, AttributeType.FLOAT3, 0 ); 117 | offset += 3*4; 118 | index++; 119 | stride += 12; 120 | } 121 | 122 | vFormat.stride = stride; 123 | 124 | return vFormat; 125 | } 126 | 127 | public function set bothSides( value:Boolean ):void 128 | { 129 | var i:int; 130 | var cullState:CullState; 131 | if ( value ) 132 | { 133 | for ( i = 0; i < effect.numPasses; ++i ) 134 | { 135 | cullState = effect.getPass( i ).cullState; 136 | cullState.enabled = false; 137 | } 138 | } 139 | else 140 | { 141 | for ( i = 0; i < effect.numPasses; ++i ) 142 | { 143 | cullState = effect.getPass( i ).cullState; 144 | cullState.enabled = true; 145 | } 146 | } 147 | } 148 | } 149 | } -------------------------------------------------------------------------------- /src/zest3d/primitives/SpherePrimitive.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.primitives 12 | { 13 | import zest3d.datatypes.Transform; 14 | import zest3d.resources.VertexFormat; 15 | import zest3d.scenegraph.TriMesh; 16 | import zest3d.shaders.VisualEffectInstance; 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class SpherePrimitive extends Primitive 22 | { 23 | 24 | public function SpherePrimitive( effect:VisualEffectInstance, 25 | hasTexCoords:Boolean = true, 26 | hasNormals: Boolean = true, 27 | hasBinormals:Boolean = false, 28 | hasTangents:Boolean = false, 29 | zSamples:int = 64, 30 | radialSamples:int = 64, 31 | radius:Number = 1, 32 | bothSides:Boolean = false, 33 | isStatic:Boolean = true, 34 | inside:Boolean = false, 35 | transform:Transform = null ) 36 | { 37 | this.effect = effect; 38 | this.bothSides = bothSides; 39 | 40 | var vFormat:VertexFormat = generateVertexFormat( hasTexCoords, hasNormals, hasBinormals, hasTangents ); 41 | var primitive:TriMesh = new StandardMesh( vFormat, isStatic, inside, transform ).sphere( zSamples, radialSamples, radius ); 42 | 43 | super( vFormat, primitive.vertexBuffer, primitive.indexBuffer ); 44 | } 45 | 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /src/zest3d/primitives/TorusPrimitive.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.primitives 12 | { 13 | import zest3d.datatypes.Transform; 14 | import zest3d.resources.VertexFormat; 15 | import zest3d.scenegraph.TriMesh; 16 | import zest3d.shaders.VisualEffectInstance; 17 | /** 18 | * ... 19 | * @author Gary Paluk - http://www.plugin.io 20 | */ 21 | public class TorusPrimitive extends Primitive 22 | { 23 | 24 | public function TorusPrimitive( effect:VisualEffectInstance, hasTexCoords:Boolean = true, hasNormals: Boolean = true, hasBinormals:Boolean = false, hasTangents:Boolean = false, circleSamples:int = 32, radialSamples:int = 16, outerRadius:Number = 1, innerRadius:Number = 0.5, bothSides:Boolean = false, isStatic:Boolean = true, inside:Boolean = false, transform:Transform = null ) 25 | { 26 | this.effect = effect; 27 | this.bothSides = bothSides; 28 | var vFormat:VertexFormat = generateVertexFormat( hasTexCoords, hasNormals, hasBinormals, hasTangents ); 29 | var primitive:TriMesh = new StandardMesh( vFormat, isStatic, inside, transform ).torus( circleSamples, radialSamples, outerRadius, innerRadius ); 30 | super( vFormat, primitive.vertexBuffer, primitive.indexBuffer ); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/AGALRendererData.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal 12 | { 13 | 14 | import flash.display3D.Context3D; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import zest3d.resources.enum.TextureFormat; 17 | 18 | /** 19 | * ... 20 | * @author Gary Paluk 21 | */ 22 | public class AGALRendererData implements IDisposable 23 | { 24 | 25 | public static const MAX_NUM_VSAMPLERS: int = 4; 26 | public static const MAX_NUM_PSAMPLERS: int = 16; 27 | 28 | // internal use only 29 | public var context: Context3D; 30 | 31 | // internal use only 32 | public var currentRS: AGALRenderState; 33 | 34 | // internal use only 35 | public var currentSS: Array; 36 | 37 | // internal use only 38 | public var maxVShaderImages: int = 4; 39 | 40 | // internal use only 41 | public var maxPShaderImages: int = 4; 42 | 43 | // internal use only 44 | public var maxCombinedImages: int; 45 | 46 | public function AGALRendererData( input: AGALRendererInput, width: int, height: int, colorFormat:TextureFormat, depthStencilFormat: TextureFormat, numMultiSamples: int ) 47 | { 48 | context = input.context; 49 | 50 | currentRS = new AGALRenderState( context ); 51 | 52 | currentSS = []; 53 | for ( var i: int = 0; i < MAX_NUM_PSAMPLERS; ++i ) 54 | { 55 | currentSS[ i ] = new AGALSamplerState(); 56 | } 57 | 58 | } 59 | 60 | public function dispose(): void 61 | { 62 | currentRS.dispose(); 63 | currentSS = null; 64 | context = null; 65 | } 66 | 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/AGALRendererInput.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal 12 | { 13 | import flash.display3D.Context3D; 14 | /** 15 | * ... 16 | * @author Gary Paluk 17 | */ 18 | public class AGALRendererInput 19 | { 20 | 21 | protected var _context:Context3D; 22 | 23 | public function AGALRendererInput( context:Context3D ) 24 | { 25 | _context = context; 26 | } 27 | 28 | public function get context(): Context3D 29 | { 30 | return _context; 31 | } 32 | 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/AGALSamplerState.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class AGALSamplerState 18 | { 19 | 20 | // internal use only 21 | public var anisotropy: Number = 1; 22 | 23 | // internal use only 24 | public var lodBias: Number = 0; 25 | 26 | // internal use only 27 | public var magFilter: String = ""; 28 | 29 | // internal use only 30 | public var minFilter: String = ""; 31 | 32 | public var borderColor: Array = [ 0, 0, 0, 0 ]; 33 | 34 | // internal use only 35 | public var wrap: Array = [ 0, 0, 0 ]; 36 | 37 | public function AGALSamplerState() 38 | { 39 | // TODO implement setSamplerAt.... 40 | // trace( "* querying the current sampler state (not implemented)" ); 41 | } 42 | 43 | public function get current(): Array 44 | { 45 | return [ 46 | anisotropy, 47 | lodBias, 48 | magFilter, 49 | minFilter, 50 | borderColor, 51 | wrap[ 0 ], 52 | wrap[ 1 ], 53 | wrap[ 2 ] 54 | ]; 55 | } 56 | 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/pdr/AGALIndexBuffer.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal.pdr 12 | { 13 | import flash.display3D.Context3D; 14 | import flash.display3D.IndexBuffer3D; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import zest3d.renderers.agal.AGALRenderer; 17 | import zest3d.renderers.interfaces.IIndexBuffer; 18 | import zest3d.renderers.Renderer; 19 | import zest3d.resources.enum.BufferLockingType; 20 | import zest3d.resources.IndexBuffer; 21 | 22 | /** 23 | * ... 24 | * @author Gary Paluk 25 | */ 26 | public class AGALIndexBuffer implements IIndexBuffer, IDisposable 27 | { 28 | 29 | private var _renderer: AGALRenderer; 30 | private var _context: Context3D; 31 | private var _indexBuffer: IndexBuffer; 32 | 33 | private var _indexBuffer3D: IndexBuffer3D; 34 | 35 | 36 | public function AGALIndexBuffer( renderer: Renderer, iBuffer: IndexBuffer ) 37 | { 38 | _renderer = renderer as AGALRenderer; 39 | _context = _renderer.data.context; 40 | 41 | _indexBuffer = iBuffer; 42 | 43 | _indexBuffer3D = _context.createIndexBuffer( _indexBuffer.numElements ); 44 | 45 | _indexBuffer3D.uploadFromByteArray( _indexBuffer.data, 0, 0, _indexBuffer.numElements ); 46 | } 47 | 48 | public function dispose(): void 49 | { 50 | _indexBuffer3D.dispose(); 51 | } 52 | 53 | public function enable( renderer: Renderer ): void 54 | { 55 | } 56 | 57 | public function disable( renderer: Renderer ): void 58 | { 59 | } 60 | 61 | public function lock( mode: BufferLockingType ): void 62 | { 63 | } 64 | 65 | public function unlock(): void 66 | { 67 | } 68 | 69 | [Inline] 70 | public final function get indexBuffer3D():IndexBuffer3D 71 | { 72 | return _indexBuffer3D; 73 | } 74 | 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/pdr/AGALPixelShader.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal.pdr 12 | { 13 | import com.adobe.utils.extended.AGALMiniAssembler; 14 | import flash.display3D.Context3D; 15 | import flash.display3D.Context3DProgramType; 16 | import flash.display3D.Program3D; 17 | import flash.utils.ByteArray; 18 | import io.plugin.core.interfaces.IDisposable; 19 | import zest3d.renderers.agal.AGALRenderer; 20 | import zest3d.renderers.interfaces.IPixelShader; 21 | import zest3d.renderers.Renderer; 22 | import zest3d.shaders.enum.PixelShaderProfileType; 23 | import zest3d.shaders.PixelShader; 24 | import zest3d.shaders.ShaderParameters; 25 | 26 | /** 27 | * ... 28 | * @author Gary Paluk 29 | */ 30 | public class AGALPixelShader extends AGALShader implements IPixelShader, IDisposable 31 | { 32 | 33 | private var _renderer: AGALRenderer; 34 | private var _context: Context3D; 35 | private var _pixelShader: PixelShader; 36 | 37 | public static var program: ByteArray; 38 | public var _program: Program3D; 39 | 40 | public function AGALPixelShader( renderer: Renderer, pShader: PixelShader ) 41 | { 42 | _renderer = renderer as AGALRenderer; 43 | _context = _renderer.data.context; 44 | 45 | var programText: String = pShader.getProgram( PixelShader.profile.index ); 46 | var assembler: AGALMiniAssembler = new AGALMiniAssembler( false ); 47 | 48 | 49 | switch( PixelShader.profile ) 50 | { 51 | case PixelShaderProfileType.AGAL_1_0 : 52 | program = assembler.assemble( Context3DProgramType.FRAGMENT, programText, 1 ); 53 | break; 54 | case PixelShaderProfileType.AGAL_2_0 : 55 | program = assembler.assemble( Context3DProgramType.FRAGMENT, programText, 2 ); 56 | break; 57 | } 58 | 59 | _program = _context.createProgram(); 60 | 61 | _program.upload( AGALVertexShader.program, AGALPixelShader.program ); 62 | } 63 | 64 | override public function dispose(): void 65 | { 66 | //TODO _shader 67 | super.dispose(); 68 | } 69 | 70 | public function enable( renderer: Renderer, pShader: PixelShader, parameters: ShaderParameters ): void 71 | { 72 | // glEnable(GL_FRAGMENT_PROGRAM_ARB); 73 | // glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, mShader); 74 | 75 | _context.setProgram( _program ); 76 | 77 | var profile: int = PixelShader.profile.index; 78 | var numConstants: int = pShader.numConstants; 79 | var offset: int = 0; 80 | 81 | 82 | for ( var i: int = 0; i < numConstants; ++i ) 83 | { 84 | var numRegisters: int = pShader.getNumRegistersUsed( i ); 85 | var data: ByteArray = parameters.getConstantByHandle( i ).data; 86 | var baseRegister: int = pShader.getBaseRegister( profile, i ); 87 | 88 | _context.setProgramConstantsFromByteArray( Context3DProgramType.FRAGMENT, offset, numRegisters, data, 0 ); 89 | offset += numRegisters; 90 | 91 | } 92 | 93 | setSamplerState( renderer, pShader, profile, parameters, _renderer.data.maxPShaderImages, _renderer.data.currentSS, _context ); 94 | } 95 | 96 | public function disable( renderer: Renderer, pShader: PixelShader, parameters: ShaderParameters ): void 97 | { 98 | var profile: int = PixelShader.profile.index; 99 | var agalRenderer:AGALRenderer = renderer as AGALRenderer; 100 | 101 | disableTextures( renderer, pShader, profile, parameters, agalRenderer.data.maxPShaderImages ); 102 | } 103 | 104 | } 105 | 106 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/pdr/AGALTexture2D.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal.pdr 12 | { 13 | import flash.display3D.Context3D; 14 | import flash.display3D.textures.Texture; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import zest3d.renderers.agal.AGALMapping; 17 | import zest3d.renderers.agal.AGALRenderer; 18 | import zest3d.renderers.interfaces.ITexture2D; 19 | import zest3d.renderers.Renderer; 20 | import zest3d.resources.enum.BufferLockingType; 21 | import zest3d.resources.enum.TextureFormat; 22 | import zest3d.resources.Texture2D; 23 | 24 | /** 25 | * ... 26 | * @author Gary Paluk 27 | */ 28 | public class AGALTexture2D implements ITexture2D, IDisposable 29 | { 30 | 31 | private var _renderer: AGALRenderer; 32 | private var _texture: Texture2D; 33 | private var _textureFormat: TextureFormat; 34 | private var _context: Context3D; 35 | private var _gpuTexture: Texture; 36 | 37 | public function AGALTexture2D( renderer: AGALRenderer, texture: Texture2D ) 38 | { 39 | _renderer = renderer; 40 | _context = _renderer.data.context; 41 | 42 | _texture = texture; 43 | _textureFormat = texture.format; 44 | 45 | var format: String = AGALMapping.textureFormat[ _textureFormat.index ]; 46 | 47 | //TODO pass a param for optimize RTT 48 | _gpuTexture = _context.createTexture( _texture.width, _texture.height, format, false, 0 ); 49 | 50 | switch( _textureFormat ) 51 | { 52 | case TextureFormat.DXT1: 53 | case TextureFormat.DXT5: 54 | case TextureFormat.ETC1: 55 | case TextureFormat.PVRTC: 56 | case TextureFormat.RGBA: 57 | _gpuTexture.uploadCompressedTextureFromByteArray( _texture.data, 0 ); 58 | break; 59 | case TextureFormat.RGBA8888: 60 | case TextureFormat.RGB888: 61 | case TextureFormat.RGB565: 62 | case TextureFormat.RGBA4444: 63 | _gpuTexture.uploadFromByteArray( _texture.data, 0, 0 ); 64 | break; 65 | default: 66 | throw new Error( "Unknown texture format." ); 67 | break; 68 | } 69 | } 70 | 71 | public function dispose(): void 72 | { 73 | _gpuTexture.dispose(); 74 | } 75 | 76 | public function enable( renderer: Renderer, textureUnit: int ): void 77 | { 78 | _context.setTextureAt( textureUnit, _gpuTexture ); 79 | } 80 | 81 | public function disable( renderer: Renderer, textureUnit: int ): void 82 | { 83 | _context.setTextureAt( textureUnit, null ); 84 | } 85 | 86 | public function lock( level: int, mode: BufferLockingType ): void 87 | { 88 | } 89 | 90 | public function unlock( level: int ): void 91 | { 92 | } 93 | 94 | public function get texture():Texture 95 | { 96 | return _gpuTexture; 97 | } 98 | 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/pdr/AGALTexture3D.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal.pdr 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.renderers.interfaces.ITexture3D; 15 | import zest3d.renderers.Renderer; 16 | import zest3d.resources.enum.BufferLockingType; 17 | import zest3d.resources.Texture3D; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class AGALTexture3D implements ITexture3D, IDisposable 24 | { 25 | 26 | public function AGALTexture3D( renderer: Renderer, texture: Texture3D ) 27 | { 28 | 29 | } 30 | 31 | public function dispose(): void 32 | { 33 | 34 | } 35 | 36 | public function enable( renderer: Renderer, textureUnit: int ): void 37 | { 38 | trace( "* enabling texture 3d." ); 39 | } 40 | 41 | public function disable( renderer: Renderer, textureUnit: int ): void 42 | { 43 | trace( "* disabling texture 3d." ); 44 | } 45 | 46 | public function lock( level: int, mode: BufferLockingType ): void 47 | { 48 | trace( "* locking texture 3d." ); 49 | } 50 | 51 | public function unlock( level: int ): void 52 | { 53 | trace( "* unlocking texture 3d." ); 54 | } 55 | 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/pdr/AGALTextureCube.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal.pdr 12 | { 13 | import flash.display3D.Context3D; 14 | import flash.display3D.textures.CubeTexture; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import zest3d.renderers.agal.AGALMapping; 17 | import zest3d.renderers.agal.AGALRenderer; 18 | import zest3d.renderers.interfaces.ITextureCube; 19 | import zest3d.renderers.Renderer; 20 | import zest3d.resources.enum.BufferLockingType; 21 | import zest3d.resources.enum.TextureFormat; 22 | import zest3d.resources.TextureCube; 23 | 24 | /** 25 | * ... 26 | * @author Gary Paluk 27 | */ 28 | public class AGALTextureCube implements ITextureCube, IDisposable 29 | { 30 | 31 | private var _renderer: AGALRenderer; 32 | private var _texture: TextureCube; 33 | private var _textureFormat: TextureFormat; 34 | private var _context: Context3D; 35 | 36 | private var _gpuTexture: CubeTexture; 37 | 38 | public function AGALTextureCube( renderer: Renderer, texture: TextureCube ) 39 | { 40 | _renderer = renderer as AGALRenderer; 41 | _context = _renderer.data.context; 42 | 43 | _texture = texture; 44 | _textureFormat = texture.format; 45 | 46 | var format: String = AGALMapping.textureFormat[ _textureFormat.index ]; 47 | _gpuTexture = _context.createCubeTexture( _texture.width, format, false, 0 ); 48 | switch( _textureFormat ) 49 | { 50 | case TextureFormat.DXT1: 51 | case TextureFormat.DXT5: 52 | case TextureFormat.ETC1: 53 | case TextureFormat.PVRTC: 54 | case TextureFormat.RGBA: 55 | _gpuTexture.uploadCompressedTextureFromByteArray( _texture.data, 0 ); 56 | break; 57 | case TextureFormat.RGBA8888: 58 | case TextureFormat.RGB888: 59 | case TextureFormat.RGB565: 60 | case TextureFormat.RGBA4444: 61 | _gpuTexture.uploadFromByteArray( _texture.data, 0, 0 ); 62 | _gpuTexture.uploadFromByteArray( _texture.data, 0, 1 ); 63 | _gpuTexture.uploadFromByteArray( _texture.data, 0, 2 ); 64 | _gpuTexture.uploadFromByteArray( _texture.data, 0, 3 ); 65 | _gpuTexture.uploadFromByteArray( _texture.data, 0, 4 ); 66 | _gpuTexture.uploadFromByteArray( _texture.data, 0, 5 ); 67 | break; 68 | } 69 | } 70 | 71 | public function dispose(): void 72 | { 73 | _gpuTexture.dispose(); 74 | } 75 | 76 | public function enable( renderer: Renderer, textureUnit: int ): void 77 | { 78 | _context.setTextureAt( textureUnit, _gpuTexture ); 79 | } 80 | 81 | public function disable( renderer: Renderer, textureUnit: int ): void 82 | { 83 | _context.setTextureAt( textureUnit, null ); 84 | } 85 | 86 | public function lock( face: int, level: int, mode: BufferLockingType ): void 87 | { 88 | } 89 | 90 | public function unlock( face: int, level: int ): void 91 | { 92 | } 93 | 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/pdr/AGALTextureRectangle.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal.pdr 12 | { 13 | import flash.display3D.Context3D; 14 | import flash.display3D.textures.RectangleTexture; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import zest3d.renderers.agal.AGALMapping; 17 | import zest3d.renderers.agal.AGALRenderer; 18 | import zest3d.renderers.interfaces.ITextureRectangle; 19 | import zest3d.renderers.Renderer; 20 | import zest3d.resources.enum.BufferLockingType; 21 | import zest3d.resources.enum.TextureFormat; 22 | import zest3d.resources.TextureRectangle; 23 | 24 | /** 25 | * ... 26 | * @author Gary Paluk 27 | */ 28 | public class AGALTextureRectangle implements ITextureRectangle, IDisposable 29 | { 30 | 31 | private var _renderer: AGALRenderer; 32 | private var _texture: TextureRectangle; 33 | private var _textureFormat: TextureFormat; 34 | private var _context: Context3D; 35 | private var _gpuTexture: RectangleTexture; 36 | 37 | public function AGALTextureRectangle( renderer: AGALRenderer, texture: TextureRectangle ) 38 | { 39 | _renderer = renderer; 40 | _context = _renderer.data.context; 41 | 42 | _texture = texture; 43 | _textureFormat = texture.format; 44 | 45 | var format: String = AGALMapping.textureFormat[ _textureFormat.index ]; 46 | 47 | //TODO pass a param for optimize RTT 48 | _gpuTexture = _context.createRectangleTexture( _texture.width, _texture.height, format, false ); 49 | 50 | switch( _textureFormat ) 51 | { 52 | /* 53 | case TextureFormat.DXT1: 54 | case TextureFormat.DXT5: 55 | case TextureFormat.ETC1: 56 | case TextureFormat.PVRTC: 57 | case TextureFormat.RGBA: 58 | _gpuTexture.uploadCompressedTextureFromByteArray( _texture.data, 0 ); 59 | break; 60 | */ 61 | case TextureFormat.RGBA8888: 62 | case TextureFormat.RGB888: 63 | case TextureFormat.RGB565: 64 | case TextureFormat.RGBA4444: 65 | _gpuTexture.uploadFromByteArray( _texture.data, 0 ); 66 | break; 67 | default: 68 | throw new Error( "Unknown texture format." ); 69 | break; 70 | } 71 | } 72 | 73 | public function dispose(): void 74 | { 75 | _gpuTexture.dispose(); 76 | } 77 | 78 | public function enable( renderer: Renderer, textureUnit: int ): void 79 | { 80 | _context.setTextureAt( textureUnit, _gpuTexture ); 81 | } 82 | 83 | public function disable( renderer: Renderer, textureUnit: int ): void 84 | { 85 | _context.setTextureAt( textureUnit, null ); 86 | } 87 | 88 | //TODO rectangles do not support mips (remove levels) 89 | public function lock( level: int, mode: BufferLockingType ): void 90 | { 91 | } 92 | 93 | public function unlock( level: int ): void 94 | { 95 | } 96 | 97 | public function get texture():RectangleTexture 98 | { 99 | return _gpuTexture; 100 | } 101 | 102 | } 103 | 104 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/pdr/AGALVertexBuffer.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal.pdr 12 | { 13 | import flash.display3D.Context3D; 14 | import flash.display3D.VertexBuffer3D; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import zest3d.renderers.agal.AGALRenderer; 17 | import zest3d.renderers.interfaces.IVertexBuffer; 18 | import zest3d.renderers.Renderer; 19 | import zest3d.resources.enum.BufferLockingType; 20 | import zest3d.resources.VertexBuffer; 21 | 22 | /** 23 | * ... 24 | * @author Gary Paluk 25 | */ 26 | public class AGALVertexBuffer implements IVertexBuffer, IDisposable 27 | { 28 | 29 | private var _renderer: AGALRenderer 30 | private var _context: Context3D; 31 | private var _vertexBuffer: VertexBuffer; 32 | 33 | private var _vertexBuffer3D: VertexBuffer3D; 34 | 35 | public static var currentVBuffer: VertexBuffer3D; 36 | 37 | public function AGALVertexBuffer( renderer: Renderer, vBuffer: VertexBuffer ) 38 | { 39 | _renderer = renderer as AGALRenderer; 40 | _context = _renderer.data.context; 41 | 42 | _vertexBuffer = vBuffer; 43 | 44 | _vertexBuffer3D = _context.createVertexBuffer( _vertexBuffer.numElements, _vertexBuffer.elementSize / 4 ); 45 | 46 | _vertexBuffer3D.uploadFromByteArray( _vertexBuffer.data, 0, 0, _vertexBuffer.numElements ); 47 | 48 | } 49 | 50 | public function dispose(): void 51 | { 52 | _vertexBuffer3D.dispose(); 53 | } 54 | 55 | public function enable( renderer: Renderer, vertexSize: uint, streamIndex: uint, offset: uint ): void 56 | { 57 | 58 | currentVBuffer = _vertexBuffer3D; 59 | } 60 | 61 | public function disable( renderer: Renderer, steamIndex: uint ): void 62 | { 63 | } 64 | 65 | public function lock( mode: BufferLockingType ): void 66 | { 67 | } 68 | 69 | public function unlock(): void 70 | { 71 | } 72 | 73 | [Inline] 74 | public final function get vertexBuffer3D():VertexBuffer3D 75 | { 76 | return _vertexBuffer3D; 77 | } 78 | 79 | } 80 | 81 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/agal/pdr/AGALVertexShader.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.agal.pdr 12 | { 13 | import com.adobe.utils.extended.AGALMiniAssembler; 14 | import flash.display3D.Context3D; 15 | import flash.display3D.Context3DProgramType; 16 | import flash.utils.ByteArray; 17 | import io.plugin.core.interfaces.IDisposable; 18 | import zest3d.renderers.agal.AGALRenderer; 19 | import zest3d.renderers.interfaces.IVertexShader; 20 | import zest3d.renderers.Renderer; 21 | import zest3d.shaders.enum.VertexShaderProfileType; 22 | import zest3d.shaders.ShaderParameters; 23 | import zest3d.shaders.VertexShader; 24 | 25 | /** 26 | * ... 27 | * @author Gary Paluk 28 | */ 29 | public class AGALVertexShader extends AGALShader implements IVertexShader, IDisposable 30 | { 31 | 32 | private var _renderer: AGALRenderer; 33 | private var _context: Context3D; 34 | private var _vertexShader: VertexShader; 35 | 36 | public static var program: ByteArray; 37 | 38 | 39 | public function AGALVertexShader( renderer: Renderer, vShader: VertexShader ) 40 | { 41 | _renderer = renderer as AGALRenderer; 42 | _context = _renderer.data.context; 43 | 44 | var programText: String = vShader.getProgram( VertexShader.profile.index ); 45 | var assembler:AGALMiniAssembler = new AGALMiniAssembler( false ); 46 | 47 | switch( VertexShader.profile ) 48 | { 49 | case VertexShaderProfileType.AGAL_1_0: 50 | program = assembler.assemble( Context3DProgramType.VERTEX, programText, 1 ); 51 | break; 52 | case VertexShaderProfileType.AGAL_2_0: 53 | program = assembler.assemble( Context3DProgramType.VERTEX, programText, 2 ); 54 | break; 55 | } 56 | } 57 | 58 | override public function dispose(): void 59 | { 60 | //TODO dispose _shader 61 | super.dispose(); 62 | } 63 | 64 | public function enable( renderer: Renderer, vShader: VertexShader, parameters: ShaderParameters ): void 65 | { 66 | // glEnable(GL_VERTEX_PROGRAM_ARB); 67 | // glBindProgramARB(GL_VERTEX_PROGRAM_ARB, mShader); 68 | 69 | var profile: int = VertexShader.profile.index; 70 | var numConstants: int = vShader.numConstants; 71 | 72 | var offset: int = 0; 73 | for ( var i: int = 0; i < numConstants; ++i ) 74 | { 75 | var numRegisters: int = vShader.getNumRegistersUsed( i ); 76 | var data: ByteArray = parameters.getConstantByHandle( i ).data; 77 | var baseRegister: int = vShader.getBaseRegister( profile, i ); 78 | 79 | // TODO set all offsets etc (We have lots of power here) 80 | _context.setProgramConstantsFromByteArray( Context3DProgramType.VERTEX, offset, numRegisters, data, 0 ); 81 | offset += numRegisters; 82 | } 83 | 84 | var agalRenderer: AGALRenderer = renderer as AGALRenderer; 85 | 86 | setSamplerState( renderer, vShader, profile, parameters, agalRenderer.data.maxVShaderImages, agalRenderer.data.currentSS, _context ); 87 | } 88 | 89 | public function disable( renderer: Renderer, vShader: VertexShader, parameters: ShaderParameters ): void 90 | { 91 | var profile: int = VertexShader.profile.index; 92 | var agalRenderer:AGALRenderer = renderer as AGALRenderer; 93 | 94 | disableTextures( renderer, vShader, profile, parameters, agalRenderer.data.maxVShaderImages ); 95 | } 96 | 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/IIndexBuffer.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.resources.enum.BufferLockingType; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public interface IIndexBuffer 21 | { 22 | function enable( renderer: Renderer ): void; 23 | function disable( renderer: Renderer ): void; 24 | function lock( mode: BufferLockingType ): void; 25 | function unlock(): void; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/IPixelShader.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.shaders.PixelShader; 15 | import zest3d.shaders.ShaderParameters; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public interface IPixelShader 22 | { 23 | function enable( renderer: Renderer, pShader:PixelShader, parameters: ShaderParameters ): void; 24 | function disable( renderer: Renderer, pShader: PixelShader, parameters: ShaderParameters ): void; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/IRenderTarget.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.resources.Texture2D; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public interface IRenderTarget 21 | { 22 | function enable( renderer: Renderer ): void; 23 | function disable( renderer: Renderer ): void; 24 | function readColor( i: int, renderer: Renderer, texture: Texture2D ): void; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/ITexture1D.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.resources.enum.BufferLockingType; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public interface ITexture1D 21 | { 22 | function enable( renderer: Renderer, textureUnit: int ): void; 23 | function disable( renderer: Renderer, textureUnit: int ): void; 24 | function lock( level: int, mode: BufferLockingType ): void; 25 | function unlock( level: int ): void; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/ITexture2D.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.resources.enum.BufferLockingType; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public interface ITexture2D 21 | { 22 | function enable( renderer: Renderer, textureUnit: int ): void; 23 | function disable( renderer: Renderer, textureUnit: int ): void; 24 | function lock( level: int, mode: BufferLockingType ): void; 25 | function unlock( level: int ): void; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/ITexture3D.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.resources.enum.BufferLockingType; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public interface ITexture3D 21 | { 22 | function enable( renderer: Renderer, textureUnit: int ): void; 23 | function disable( renderer: Renderer, textureUnit: int ): void; 24 | function lock( level: int, mode: BufferLockingType ): void; 25 | function unlock( level: int ): void; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/ITextureCube.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.resources.enum.BufferLockingType; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public interface ITextureCube 21 | { 22 | function enable( renderer: Renderer, textureUnit: int ): void; 23 | function disable( renderer: Renderer, textureUnit: int ): void; 24 | function lock( face: int, level: int, mode: BufferLockingType ): void; 25 | function unlock( face: int, level: int ): void; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/ITextureRectangle.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.resources.enum.BufferLockingType; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public interface ITextureRectangle 21 | { 22 | function enable( renderer: Renderer, textureUnit: int ): void; 23 | function disable( renderer: Renderer, textureUnit: int ): void; 24 | function lock( level: int, mode: BufferLockingType ): void; 25 | function unlock( level: int ): void; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/IVertexBuffer.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.resources.enum.BufferLockingType; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public interface IVertexBuffer 21 | { 22 | function enable( renderer: Renderer, vertexSize: uint, streamIndex: uint, offset: uint ): void; 23 | function disable( renderer: Renderer, streamIndex: uint ): void; 24 | function lock( mode: BufferLockingType ): void; 25 | function unlock(): void; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/IVertexFormat.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | /** 15 | * ... 16 | * @author Gary Paluk 17 | */ 18 | public interface IVertexFormat 19 | { 20 | function enable( renderer: Renderer ): void; 21 | function disable( renderer: Renderer ): void; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /src/zest3d/renderers/interfaces/IVertexShader.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.renderers.interfaces 12 | { 13 | import zest3d.renderers.Renderer; 14 | import zest3d.shaders.ShaderParameters; 15 | import zest3d.shaders.VertexShader; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public interface IVertexShader 22 | { 23 | function enable( renderer: Renderer, vShader: VertexShader, parameters: ShaderParameters ): void; 24 | function disable( renderer: Renderer, vShader: VertexShader, parameters: ShaderParameters ): void; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /src/zest3d/resources/Buffer.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources 12 | { 13 | import flash.utils.ByteArray; 14 | import flash.utils.Endian; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import io.plugin.core.system.object.PluginObject; 17 | import zest3d.resources.enum.BufferUsageType; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class Buffer extends PluginObject implements IDisposable 24 | { 25 | 26 | protected var _numElements: int; 27 | protected var _elementSize: int; 28 | protected var _usage: BufferUsageType; 29 | protected var _numBytes: int; 30 | protected var _data: ByteArray; 31 | 32 | public function Buffer( numElements: int, elementSize: int, usage: BufferUsageType ) 33 | { 34 | _numElements = numElements; 35 | _elementSize = elementSize; 36 | _usage = usage; 37 | _numBytes = numElements * elementSize; 38 | 39 | _data = new ByteArray( ); 40 | _data.endian = Endian.LITTLE_ENDIAN; 41 | _data.length = _numBytes; 42 | } 43 | 44 | public function dispose(): void 45 | { 46 | _data.length = 0; 47 | _data = null; 48 | } 49 | 50 | [Inline] 51 | public final function get numElements(): int 52 | { 53 | return _numElements; 54 | } 55 | 56 | [Inline] 57 | public final function get elementSize():int 58 | { 59 | return _elementSize; 60 | } 61 | 62 | [Inline] 63 | public final function get usage(): BufferUsageType 64 | { 65 | return _usage; 66 | } 67 | 68 | [Inline] 69 | public final function set numElements( numElements: int ): void 70 | { 71 | _numElements = numElements; 72 | } 73 | 74 | [Inline] 75 | public final function get numBytes(): int 76 | { 77 | return _numBytes; 78 | } 79 | 80 | [Inline] 81 | public final function get data():ByteArray 82 | { 83 | return _data; 84 | } 85 | 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/zest3d/resources/IndexBuffer.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.renderers.Renderer; 15 | import zest3d.resources.enum.BufferUsageType; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class IndexBuffer extends Buffer implements IDisposable 22 | { 23 | 24 | protected var _offset: int; 25 | 26 | public function IndexBuffer( numIndices: int, elementSize: int, usage: BufferUsageType = null ) 27 | { 28 | usage ||= BufferUsageType.STATIC; 29 | 30 | super( numIndices, elementSize, usage ) 31 | _offset = 0; 32 | } 33 | 34 | public function setIndexAt( index: int, value: uint ): void 35 | { 36 | _data.position = index * _elementSize; 37 | _data.writeShort( value ); 38 | } 39 | 40 | override public function dispose():void 41 | { 42 | Renderer.unbindAllIndexBuffer( this ); 43 | super.dispose(); 44 | } 45 | 46 | [Inline] 47 | public final function set offset( offset: int ): void 48 | { 49 | if ( offset >= 0 ) 50 | { 51 | _offset = offset; 52 | return; 53 | } 54 | throw new ArgumentError( "The offset must be positive." ); 55 | } 56 | 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /src/zest3d/resources/RenderTarget.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.core.system.Assert; 15 | import io.plugin.core.system.object.PluginObject; 16 | import zest3d.renderers.Renderer; 17 | import zest3d.resources.enum.BufferUsageType; 18 | import zest3d.resources.enum.TextureFormat; 19 | 20 | /** 21 | * ... 22 | * @author Gary Paluk 23 | */ 24 | public class RenderTarget extends PluginObject implements IDisposable 25 | { 26 | 27 | protected var _numTargets: int; 28 | protected var _colorTextures: Array; 29 | protected var _depthStencilTexture: TextureRectangle; 30 | protected var _hasMipmaps: Boolean; 31 | 32 | public function RenderTarget( numTargets: int, tFormat: TextureFormat, width: int, 33 | height: int, hasMipmaps: Boolean, hasDepthStencil: Boolean ) 34 | { 35 | _numTargets = numTargets; 36 | _hasMipmaps = hasMipmaps; 37 | 38 | Assert.isTrue( _numTargets > 0 ); 39 | 40 | _colorTextures = []; 41 | 42 | var i: int = 0; 43 | for ( i = 0; i < _numTargets; ++i ) 44 | { 45 | _colorTextures[i] = new TextureRectangle( tFormat, width, height, BufferUsageType.RENDERTARGET ); 46 | } 47 | 48 | if ( hasDepthStencil ) 49 | { 50 | _depthStencilTexture = new TextureRectangle( TextureFormat.RGBA8888, width, height, BufferUsageType.DEPTHSTENCIL ); 51 | } 52 | } 53 | 54 | public function dispose(): void 55 | { 56 | Renderer.unbindAllRenderTarget( this ); 57 | for each( var texture:TextureRectangle in _colorTextures ) 58 | { 59 | texture.dispose(); 60 | } 61 | _colorTextures = null; 62 | } 63 | 64 | [Inline] 65 | public final function get numTargets(): int 66 | { 67 | return _numTargets; 68 | } 69 | 70 | [Inline] 71 | public final function get format(): TextureFormat 72 | { 73 | return _colorTextures[0].format; 74 | } 75 | 76 | [Inline] 77 | public final function get width(): int 78 | { 79 | return _colorTextures[0].width; 80 | } 81 | 82 | [Inline] 83 | public final function get height(): int 84 | { 85 | return _colorTextures[0].height; 86 | } 87 | 88 | [Inline] 89 | public final function getColorTextureAt( index: int ): TextureRectangle 90 | { 91 | return _colorTextures[index]; 92 | } 93 | 94 | [Inline] 95 | public final function get depthStencilTexture(): TextureRectangle 96 | { 97 | return _depthStencilTexture; 98 | } 99 | 100 | [Inline] 101 | public final function get hasMipmaps(): Boolean 102 | { 103 | return _hasMipmaps; 104 | } 105 | 106 | [Inline] 107 | public final function get hasDepthStencil(): Boolean 108 | { 109 | return _depthStencilTexture != null; 110 | } 111 | 112 | } 113 | 114 | } -------------------------------------------------------------------------------- /src/zest3d/resources/Texture.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources 12 | { 13 | import flash.utils.ByteArray; 14 | import plugin.image.atf.ATFReader; 15 | import zest3d.resources.enum.TextureFormat; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk - http://www.plugin.io 20 | */ 21 | public class Texture 22 | { 23 | 24 | public static function fromByteArray( data:ByteArray, type:String = null ):TextureBase 25 | { 26 | var reader:ATFReader = new ATFReader( data ); 27 | var format:TextureFormat; 28 | var texture:TextureBase; 29 | 30 | switch( reader.format ) 31 | { 32 | case 0: 33 | format = TextureFormat.RGB888; 34 | break; 35 | case 1: 36 | format = TextureFormat.RGBA8888; 37 | break; 38 | case 2: 39 | case 3: 40 | format = TextureFormat.DXT1; 41 | break; 42 | case 4: 43 | case 5: 44 | format = TextureFormat.DXT5; 45 | break; 46 | default: 47 | throw new Error( "Invalid ATF format " + format ); 48 | } 49 | 50 | switch( reader.cubemap ) 51 | { 52 | case 0x0: 53 | if ( type == "rectangle" ) 54 | { 55 | texture = new TextureRectangle( format, reader.width, reader.height ); 56 | } 57 | else 58 | { 59 | texture = new Texture2D( format, reader.width, reader.height, reader.count ); 60 | } 61 | break; 62 | case 0x1: 63 | texture = new TextureCube( format, reader.width, reader.count ); 64 | break; 65 | default : 66 | throw new Error( "Invalid ATF type " + reader.cubemap ); 67 | } 68 | texture.data = reader.data; 69 | return texture as TextureBase; 70 | } 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /src/zest3d/resources/Texture3D.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.renderers.Renderer; 15 | import zest3d.resources.enum.BufferUsageType; 16 | import zest3d.resources.enum.TextureFormat; 17 | import zest3d.resources.enum.TextureType; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class Texture3D extends TextureBase implements IDisposable 24 | { 25 | 26 | public function Texture3D( format: TextureFormat, dim0: int, dim1: int, dim2: int, numLevels: int, usage: BufferUsageType = null ) 27 | { 28 | usage ||= BufferUsageType.TEXTURE; 29 | super( format, TextureType.TEXTURE_3D, usage, numLevels ); 30 | } 31 | 32 | override public function dispose():void 33 | { 34 | Renderer.unbindAllTexture3D( this ); 35 | super.dispose(); 36 | } 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/zest3d/resources/TextureCube.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources 12 | { 13 | import flash.utils.ByteArray; 14 | import flash.utils.Endian; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import io.plugin.core.system.Assert; 17 | import io.plugin.math.base.BitHacks; 18 | import zest3d.renderers.Renderer; 19 | import zest3d.resources.enum.BufferUsageType; 20 | import zest3d.resources.enum.TextureFormat; 21 | import zest3d.resources.enum.TextureType; 22 | 23 | /** 24 | * ... 25 | * @author Gary Paluk 26 | */ 27 | public class TextureCube extends TextureBase implements IDisposable 28 | { 29 | 30 | public function TextureCube( format: TextureFormat, dimension: int, numLevels: int, usage: BufferUsageType = null ) 31 | { 32 | usage ||= BufferUsageType.TEXTURE; 33 | super( format, TextureType.TEXTURE_CUBE, usage, numLevels ); 34 | 35 | Assert.isTrue( dimension > 0, "Dimension must be positive" ); 36 | _dimension[0][0] = dimension; 37 | _dimension[1][0] = dimension; 38 | 39 | var logDim: uint = BitHacks.logOfPowerTwoUint( uint( dimension ) ); 40 | var maxLevels: int = int( logDim ) + 1; 41 | 42 | if ( numLevels == 0 ) 43 | { 44 | _numLevels = maxLevels; 45 | } 46 | else if ( numLevels <= maxLevels ) 47 | { 48 | _numLevels = numLevels; 49 | } 50 | else 51 | { 52 | Assert.isTrue( false, "Invalid number of levels." ); 53 | } 54 | 55 | //computeNumLevelBytes(); 56 | _data = new ByteArray(); 57 | _data.endian = Endian.LITTLE_ENDIAN; 58 | _data.length = _numTotalBytes; 59 | } 60 | 61 | override public function dispose():void 62 | { 63 | Renderer.unbindAllTextureCube( this ); 64 | super.dispose(); 65 | } 66 | 67 | [Inline] 68 | public final function get width(): int 69 | { 70 | return getDimension( 0, 0 ); 71 | } 72 | 73 | [Inline] 74 | public final function get height(): int 75 | { 76 | return getDimension( 1, 0 ); 77 | } 78 | 79 | public function generateMipmaps(): void 80 | { 81 | throw new Error( "TextureCube::generateMipmaps() is currently unsupported" ); 82 | } 83 | 84 | public function get hasMipmaps(): Boolean 85 | { 86 | /* 87 | var logDim: uint = BitHacks.logOfPowerTwoUint( uint( dimension ) ); 88 | var maxLevels: int = int( logDim ) + 1; 89 | 90 | return _numLevels == maxLevels; 91 | */ 92 | return false; //TODO implement mipmap checks 93 | } 94 | 95 | //TODO return face and level 96 | /* 97 | override public function get data( face: int, level: int ): ByteArray 98 | { 99 | return _data; 100 | } 101 | */ 102 | 103 | protected function computeNumLevelBytes(): void 104 | { 105 | throw new Error( "TextureCube::computeNumLevelBytes() is currently unsupported" ); 106 | } 107 | 108 | public static function fromByteArray( data:ByteArray ):TextureCube 109 | { 110 | return Texture.fromByteArray( data ) as TextureCube; 111 | } 112 | } 113 | 114 | } -------------------------------------------------------------------------------- /src/zest3d/resources/TextureRectangle.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources 12 | { 13 | import flash.utils.ByteArray; 14 | import flash.utils.Endian; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import io.plugin.core.system.Assert; 17 | import zest3d.renderers.Renderer; 18 | import zest3d.resources.enum.BufferUsageType; 19 | import zest3d.resources.enum.TextureFormat; 20 | import zest3d.resources.enum.TextureType; 21 | 22 | /** 23 | * ... 24 | * @author Gary Paluk 25 | */ 26 | public class TextureRectangle extends TextureBase implements IDisposable 27 | { 28 | 29 | public function TextureRectangle( format: TextureFormat, dimension0: int, dimension1: int, usage: BufferUsageType = null ) 30 | { 31 | usage ||= BufferUsageType.TEXTURE; 32 | super( format, TextureType.TEXTURE_RECTANGLE, usage, 0 ); 33 | 34 | Assert.isTrue( dimension0 > 0, "Dimension0 must be positive." ); 35 | Assert.isTrue( dimension1 > 0, "Dimension1 must be positive." ); 36 | 37 | _dimension[ 0 ][ 0 ] = dimension0; 38 | _dimension[ 1 ][ 0 ] = dimension1; 39 | 40 | _numLevels = 0; 41 | 42 | computeNumLevelBytes(); 43 | _data = new ByteArray(); 44 | _data.endian = Endian.LITTLE_ENDIAN; 45 | _data.length = _numTotalBytes; 46 | } 47 | 48 | override public function dispose():void 49 | { 50 | Renderer.unbindAllTextureRectangle( this ); 51 | super.dispose(); 52 | } 53 | 54 | [Inline] 55 | public final function get width(): int 56 | { 57 | return getDimension( 0, 0 ); 58 | } 59 | 60 | [Inline] 61 | public final function get height(): int 62 | { 63 | return getDimension( 1, 0 ); 64 | } 65 | 66 | public function get hasMipmaps(): Boolean 67 | { 68 | return false; 69 | } 70 | 71 | protected function computeNumLevelBytes(): void 72 | { 73 | var dim0: int = _dimension[0][0]; 74 | var dim1: int = _dimension[1][0]; 75 | var level: int; 76 | _numTotalBytes = 0; 77 | 78 | if ( _format == TextureFormat.DXT1 ) 79 | { 80 | for ( level = 0; level < _numLevels; ++level ) 81 | { 82 | var max0: int = dim0 / 4; 83 | if ( max0 < 1 ) 84 | { 85 | max0 = 1; 86 | } 87 | var max1: int = dim1 / 4; 88 | if ( max1 < 1 ) 89 | { 90 | max1 = 1; 91 | } 92 | 93 | _numLevelBytes[ level ] = 8 * max0 * max1; 94 | _numTotalBytes += _numLevelBytes[ level ]; 95 | _dimension[ 0 ][ level ] = dim0; 96 | _dimension[ 1 ][ level ] = dim1; 97 | _dimension[ 2 ][ level ] = 1; 98 | 99 | if ( dim0 > 1 ) 100 | { 101 | dim0 >>= 1; 102 | } 103 | if ( dim1 > 1 ) 104 | { 105 | dim1 >>= 1; 106 | } 107 | } 108 | } 109 | else if ( _format == TextureFormat.DXT5 ) 110 | { 111 | for ( level = 0; level < _numLevels; ++level ) 112 | { 113 | _numLevelBytes[ level ] = msPixelSize[ _format.index ] * dim0 * dim1; 114 | _numTotalBytes += _numLevelBytes[ level ]; 115 | _dimension[0][level] = dim0; 116 | _dimension[1][level] = dim1; 117 | _dimension[2][level] = 1; 118 | 119 | if ( dim0 > 1 ) 120 | { 121 | dim0 >>= 1; 122 | } 123 | if ( dim1 > 1 ) 124 | { 125 | dim1 >>= 1; 126 | } 127 | } 128 | 129 | _levelOffsets[ 0 ] = 0; 130 | for ( level = 0; level < _numLevels - 1; ++level ) 131 | { 132 | _levelOffsets[level+1] = _levelOffsets[level] + _numLevelBytes[level]; 133 | } 134 | } 135 | } 136 | 137 | public static function fromByteArray( data:ByteArray ):TextureRectangle 138 | { 139 | return Texture.fromByteArray( data ) as TextureRectangle; 140 | } 141 | } 142 | 143 | } -------------------------------------------------------------------------------- /src/zest3d/resources/VertexBuffer.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.renderers.Renderer; 15 | import zest3d.resources.enum.BufferUsageType; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class VertexBuffer extends Buffer implements IDisposable 22 | { 23 | 24 | public function VertexBuffer( numVertices: int, vertexSize: int, usage: BufferUsageType = null ) 25 | { 26 | usage ||= BufferUsageType.STATIC; 27 | super( numVertices, vertexSize, usage ); 28 | } 29 | 30 | override public function dispose():void 31 | { 32 | Renderer.unbindAllVertexBuffer( this ); 33 | super.dispose(); 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /src/zest3d/resources/VertexElement.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.resources.enum.AttributeType; 15 | import zest3d.resources.enum.AttributeUsageType; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class VertexElement implements IDisposable 22 | { 23 | 24 | public var streamIndex: uint; 25 | public var offset: uint; 26 | public var type: AttributeType; 27 | public var usage: AttributeUsageType; 28 | public var usageIndex: uint; 29 | 30 | public function VertexElement() 31 | { 32 | streamIndex = 0; 33 | offset = 0; 34 | type = AttributeType.NONE; 35 | usage = AttributeUsageType.NONE; 36 | usageIndex = 0; 37 | } 38 | 39 | public function dispose(): void 40 | { 41 | type = null; 42 | usage = null; 43 | } 44 | 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/zest3d/resources/enum/AttributeType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class AttributeType 18 | { 19 | 20 | public static const NONE: AttributeType = new AttributeType( "none", 0 ); 21 | public static const FLOAT1: AttributeType = new AttributeType( "float1", 1 ); 22 | public static const FLOAT2: AttributeType = new AttributeType( "float2", 2 ); 23 | public static const FLOAT3: AttributeType = new AttributeType( "float3", 3 ); 24 | public static const FLOAT4: AttributeType = new AttributeType( "float4", 4 ); 25 | 26 | public static const QUANTITY: int = 5; 27 | 28 | protected var _type: String; 29 | protected var _index: int; 30 | 31 | public function AttributeType( type: String, index: int ) 32 | { 33 | _type = type; 34 | _index = index; 35 | } 36 | 37 | public function get type():String 38 | { 39 | return _type; 40 | } 41 | 42 | public function get index():int 43 | { 44 | return _index; 45 | } 46 | 47 | public static function toVector(): Vector. 48 | { 49 | return Vector. 50 | ([ 51 | NONE, 52 | FLOAT1, 53 | FLOAT2, 54 | FLOAT3, 55 | FLOAT4/*, 56 | HALF1, 57 | HALF2, 58 | HALF3, 59 | HALF4, 60 | UBYTE4, 61 | SHORT1, 62 | SHORT2, 63 | SHORT4*/ 64 | ]); 65 | } 66 | 67 | public function toString(): String 68 | { 69 | return "[object AttributeType] (type: " + type + ", index: " + index + ")"; 70 | } 71 | 72 | } 73 | 74 | } -------------------------------------------------------------------------------- /src/zest3d/resources/enum/AttributeUsageType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class AttributeUsageType 18 | { 19 | 20 | public static const NONE: AttributeUsageType = new AttributeUsageType( "none", 0 ); 21 | public static const POSITION: AttributeUsageType = new AttributeUsageType( "position", 1 ); 22 | public static const NORMAL: AttributeUsageType = new AttributeUsageType( "normal", 2 ); 23 | public static const TANGENT: AttributeUsageType = new AttributeUsageType( "tangent", 3 ); 24 | public static const BINORMAL: AttributeUsageType = new AttributeUsageType( "binormal", 4 ); 25 | public static const TEXCOORD: AttributeUsageType = new AttributeUsageType( "texCoord", 5 ); 26 | public static const COLOR: AttributeUsageType = new AttributeUsageType( "color", 6 ); 27 | public static const BLENDINDICES: AttributeUsageType = new AttributeUsageType( "blendIndices", 7 ); 28 | public static const BLENDWEIGHT: AttributeUsageType = new AttributeUsageType( "blendWeight", 8 ); 29 | public static const FOGCOORD: AttributeUsageType = new AttributeUsageType( "fogCoord", 9 ); 30 | public static const PSIZE: AttributeUsageType = new AttributeUsageType( "pSize", 10 ); 31 | 32 | public static const QUANTITY: int = 11; 33 | 34 | protected var _type: String; 35 | protected var _index: int; 36 | public function AttributeUsageType( type: String, index: int ) 37 | { 38 | _type = type; 39 | _index = index; 40 | } 41 | 42 | public function get type():String 43 | { 44 | return _type; 45 | } 46 | 47 | public function get index():int 48 | { 49 | return _index; 50 | } 51 | 52 | public static function toVector(): Vector. 53 | { 54 | return Vector. 55 | ([ 56 | NONE, 57 | POSITION, 58 | NORMAL, 59 | TANGENT, 60 | BINORMAL, 61 | TEXCOORD, 62 | COLOR, 63 | BLENDINDICES, 64 | BLENDWEIGHT, 65 | FOGCOORD, 66 | PSIZE 67 | ]); 68 | } 69 | 70 | public function toString(): String 71 | { 72 | return "[object AttributeUsageType] (type: " + type + ")"; 73 | } 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /src/zest3d/resources/enum/BufferLockingType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class BufferLockingType 18 | { 19 | 20 | public static const READ_ONLY: BufferLockingType = new BufferLockingType( "readOnly" ); 21 | public static const WRITE_ONLY: BufferLockingType = new BufferLockingType( "writeOnly" ); 22 | public static const READ_WRITE: BufferLockingType = new BufferLockingType( "readWrite" ); 23 | 24 | public static const QUANTITY: int = 3; 25 | 26 | protected var _type: String; 27 | public function BufferLockingType( type: String ) 28 | { 29 | _type = type; 30 | } 31 | 32 | public function get type():String 33 | { 34 | return _type; 35 | } 36 | 37 | public static function toVector(): Vector. 38 | { 39 | return Vector. 40 | ([ 41 | READ_ONLY, 42 | WRITE_ONLY, 43 | READ_WRITE 44 | ]); 45 | } 46 | 47 | public function toString(): String 48 | { 49 | return "[object BufferLockingType] (type: " + type + ")"; 50 | } 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/zest3d/resources/enum/BufferUsageType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class BufferUsageType 18 | { 19 | 20 | public static const STATIC: BufferUsageType = new BufferUsageType( "static" ); 21 | public static const DYNAMIC: BufferUsageType = new BufferUsageType( "dynamic" ); 22 | public static const RENDERTARGET: BufferUsageType = new BufferUsageType( "rendertarget" ); 23 | public static const DEPTHSTENCIL: BufferUsageType = new BufferUsageType( "depthstencil" ); 24 | public static const TEXTURE: BufferUsageType = new BufferUsageType( "texture" ); 25 | 26 | public static const QUANTITY: int = 5; 27 | 28 | 29 | protected var _type: String; 30 | public function BufferUsageType( type: String ) 31 | { 32 | _type = type; 33 | } 34 | 35 | public static function toVector(): Vector. 36 | { 37 | return Vector. 38 | ([ 39 | STATIC, 40 | DYNAMIC, 41 | RENDERTARGET, 42 | DEPTHSTENCIL, 43 | TEXTURE 44 | ]); 45 | } 46 | 47 | public function get type():String 48 | { 49 | return _type; 50 | } 51 | 52 | public function toString(): String 53 | { 54 | return "[object BufferUsageType] (type: " + type + ")"; 55 | } 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/zest3d/resources/enum/TextureFormat.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class TextureFormat 18 | { 19 | 20 | public static const DXT1: TextureFormat = new TextureFormat( "DXT1", 0 ); 21 | public static const DXT5: TextureFormat = new TextureFormat( "DXT5", 1 ); 22 | public static const ETC1: TextureFormat = new TextureFormat( "ETC1", 2 ); 23 | public static const PVRTC: TextureFormat = new TextureFormat( "PVRTC", 3 ); 24 | public static const RGBA: TextureFormat = new TextureFormat( "RGBA", 4 ); 25 | 26 | public static const RGBA8888: TextureFormat = new TextureFormat( "RGBA8888", 10 ); 27 | public static const RGB888: TextureFormat = new TextureFormat( "RGB888", 11 ); 28 | public static const RGB565: TextureFormat = new TextureFormat( "RGB565", 12 ); 29 | public static const RGBA4444: TextureFormat = new TextureFormat( "RGBA4444", 13 ); 30 | 31 | protected var _type: String; 32 | protected var _index: int; 33 | public function TextureFormat( type: String, index: int ) 34 | { 35 | _type = type; 36 | _index = index; 37 | } 38 | 39 | public function get type():String 40 | { 41 | return _type; 42 | } 43 | 44 | public function get index():int 45 | { 46 | return _index; 47 | } 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/zest3d/resources/enum/TextureType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.resources.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class TextureType 18 | { 19 | 20 | public static const TEXTURE_2D: TextureType = new TextureType( "texture2D", 0 ); 21 | public static const TEXTURE_3D: TextureType = new TextureType( "texture3D", 1 ); 22 | public static const TEXTURE_CUBE: TextureType = new TextureType( "textureCube", 2 ); 23 | public static const TEXTURE_RECTANGLE: TextureType = new TextureType( "textureRectangle", 3 ); 24 | 25 | public static const MAX_VALUE: int = 4; 26 | 27 | protected var _type: String; 28 | protected var _index: int; 29 | public function TextureType( type: String, index: int ) 30 | { 31 | _type = type; 32 | _index = index; 33 | } 34 | 35 | public static function toVector(): Vector. 36 | { 37 | return Vector. 38 | ([ 39 | TEXTURE_2D, 40 | TEXTURE_3D, 41 | TEXTURE_CUBE 42 | ]); 43 | } 44 | 45 | public function get type():String 46 | { 47 | return _type; 48 | } 49 | 50 | public function get index():int 51 | { 52 | return _index; 53 | } 54 | 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/CameraNode.as: -------------------------------------------------------------------------------- 1 | package zest3d.scenegraph 2 | { 3 | import io.plugin.core.interfaces.IDisposable; 4 | import io.plugin.math.algebra.APoint; 5 | import io.plugin.math.algebra.AVector; 6 | import io.plugin.math.algebra.HMatrix; 7 | 8 | /** 9 | * ... 10 | * @author Gary Paluk - http://www.plugin.io 11 | */ 12 | public class CameraNode extends Node implements IDisposable 13 | { 14 | 15 | protected var _camera:Camera; 16 | 17 | public function CameraNode( camera:Camera = null ) 18 | { 19 | _camera = camera; 20 | if ( _camera ) 21 | { 22 | localTransform.translate = _camera.position; 23 | var rotation:HMatrix = HMatrix.fromTuple( _camera.dVector.toTuple(), 24 | _camera.uVector.toTuple(), 25 | _camera.rVector.toTuple(), 26 | APoint.ORIGIN.toTuple(), 27 | true ); 28 | localTransform.rotate = rotation; 29 | } 30 | } 31 | 32 | override public function dispose():void 33 | { 34 | super.dispose(); 35 | } 36 | 37 | public function set camera( camera:Camera ):void 38 | { 39 | _camera = camera; 40 | 41 | localTransform.translate = _camera.position; 42 | var rotation:HMatrix = HMatrix.fromTuple( _camera.dVector.toTuple(), 43 | _camera.uVector.toTuple(), 44 | _camera.rVector.toTuple(), 45 | APoint.ORIGIN.toTuple(), 46 | true ); 47 | localTransform.rotate = rotation; 48 | 49 | update(); 50 | } 51 | 52 | [Inline] 53 | public final function get camera( ):Camera 54 | { 55 | return _camera; 56 | } 57 | 58 | // virtual 59 | override protected function updateWorldData(applicationTime:Number):void 60 | { 61 | super.updateWorldData( applicationTime ); 62 | if ( _camera ) 63 | { 64 | var camPosition:APoint = worldTransform.translate; 65 | 66 | var col0:Array = worldTransform.rotate.getColumn( 0 ); 67 | var col1:Array = worldTransform.rotate.getColumn( 1 ); 68 | var col2:Array = worldTransform.rotate.getColumn( 2 ); 69 | 70 | //TODO pool this object creation 71 | var camDVector:AVector = new AVector( col0[0], col0[1], col0[2] ); 72 | var camUVector:AVector = new AVector( col1[0], col1[1], col1[2] ); 73 | var camRVector:AVector = new AVector( col2[0], col2[1], col2[2] ); 74 | 75 | _camera.setFrame( camPosition, camDVector, camUVector, camRVector ); 76 | } 77 | } 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/Frustum.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | 15 | /** 16 | * ... 17 | * @author Gary Paluk 18 | */ 19 | public class Frustum implements IDisposable 20 | { 21 | 22 | protected var _dMin: Number; 23 | protected var _dMax: Number; 24 | protected var _uMin: Number; 25 | protected var _uMax: Number; 26 | protected var _rMin: Number; 27 | protected var _rMax: Number; 28 | 29 | public function Frustum( dMin: Number, dMax: Number, uMin: Number, uMax:Number, rMin: Number, rMax: Number ) 30 | { 31 | _dMin = dMin; 32 | _dMax = dMax; 33 | _uMin = uMin; 34 | _uMax = uMax; 35 | _rMin = rMin; 36 | _rMax = rMax; 37 | } 38 | 39 | public function dispose(): void 40 | { 41 | 42 | } 43 | 44 | [Inline] 45 | public final function get dMin():Number 46 | { 47 | return _dMin; 48 | } 49 | 50 | [Inline] 51 | public final function get dMax():Number 52 | { 53 | return _dMax; 54 | } 55 | 56 | [Inline] 57 | public final function get uMin():Number 58 | { 59 | return _uMin; 60 | } 61 | 62 | [Inline] 63 | public final function get uMax():Number 64 | { 65 | return _uMax; 66 | } 67 | 68 | [Inline] 69 | public final function get rMin():Number 70 | { 71 | return _rMin; 72 | } 73 | 74 | [Inline] 75 | public final function get rMax():Number 76 | { 77 | return _rMax; 78 | } 79 | 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/Light.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.graphics.Color; 14 | import io.plugin.core.interfaces.IDisposable; 15 | import io.plugin.core.system.Assert; 16 | import io.plugin.math.algebra.APoint; 17 | import io.plugin.math.algebra.AVector; 18 | import zest3d.scenegraph.enum.LightType; 19 | 20 | /** 21 | * ... 22 | * @author Gary Paluk 23 | */ 24 | public class Light implements IDisposable 25 | { 26 | 27 | public var position: APoint; 28 | public var dVector: AVector; 29 | public var uVector: AVector; 30 | public var rVector: AVector; 31 | 32 | public var ambient: Color; 33 | public var diffuse: Color; 34 | public var specular: Color; 35 | 36 | public var constant: Number; 37 | public var linear: Number; 38 | public var quadratic: Number; 39 | public var intensity: Number; 40 | 41 | private var _angle: Number; 42 | public var cosAngle: Number; 43 | public var sinAngle: Number; 44 | public var exponent: Number; 45 | 46 | protected var _type: LightType; 47 | 48 | public function Light(type: LightType = null) 49 | { 50 | _type = type ||= LightType.AMBIENT; 51 | ambient = new Color( 0, 0, 0, 1 ); 52 | diffuse = new Color( 0, 0, 0, 1 ); 53 | specular = new Color( 0, 0, 0, 1 ); 54 | constant = 1; 55 | linear = 0; 56 | quadratic = 0; 57 | intensity = 1; 58 | angle = Math.PI; 59 | cosAngle = -1; 60 | exponent = 1; 61 | position = APoint.ORIGIN; 62 | dVector = AVector.UNIT_Z_NEGATIVE; 63 | uVector = AVector.UNIT_Y; 64 | rVector = AVector.UNIT_X; 65 | } 66 | 67 | public function dispose(): void 68 | { 69 | _type = null; 70 | 71 | ambient.dispose(); 72 | diffuse.dispose(); 73 | specular.dispose(); 74 | 75 | position.dispose(); 76 | dVector.dispose(); 77 | uVector.dispose(); 78 | rVector.dispose(); 79 | 80 | ambient = null; 81 | diffuse = null; 82 | specular = null; 83 | 84 | position = null; 85 | dVector = null; 86 | uVector = null; 87 | rVector = null; 88 | } 89 | 90 | [Inline] 91 | public final function set type( type: LightType ): void 92 | { 93 | _type = type; 94 | } 95 | 96 | [Inline] 97 | public final function get type(): LightType 98 | { 99 | return _type; 100 | } 101 | 102 | [Inline] 103 | public final function get angle(): Number 104 | { 105 | return _angle; 106 | } 107 | 108 | public function set angle( value: Number ): void 109 | { 110 | Assert.isTrue( 0 < value && value <= Math.PI, "Angle out of range." ); 111 | _angle = value; 112 | cosAngle = Math.cos( value ); 113 | sinAngle = Math.sin( value ); 114 | } 115 | 116 | public function set direction( direction: AVector ): void 117 | { 118 | dVector = direction; 119 | AVector.generateOrthonormalBasis( uVector, rVector, dVector ); 120 | } 121 | 122 | } 123 | 124 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/LightNode.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.APoint; 15 | import io.plugin.math.algebra.HMatrix; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class LightNode extends Node implements IDisposable 22 | { 23 | 24 | protected var _light: Light; 25 | 26 | public function LightNode( light: Light ) 27 | { 28 | _light = light; 29 | 30 | if ( _light ) 31 | { 32 | localTransform.translate = light.position; 33 | 34 | var rotate:HMatrix = HMatrix.fromTuple( _light.dVector.toTuple(), 35 | _light.uVector.toTuple(), 36 | _light.rVector.toTuple(), 37 | APoint.ORIGIN.toTuple(), 38 | true ); 39 | 40 | localTransform.rotate = rotate; 41 | } 42 | } 43 | 44 | override public function dispose():void 45 | { 46 | 47 | super.dispose(); 48 | } 49 | 50 | [Inline] 51 | public final function set light( light: Light ): void 52 | { 53 | _light = light; 54 | 55 | if ( _light ) 56 | { 57 | localTransform.translate = light.position; 58 | 59 | var rotate:HMatrix = HMatrix.fromTuple( _light.dVector.toTuple(), 60 | _light.uVector.toTuple(), 61 | _light.rVector.toTuple(), 62 | APoint.ORIGIN.toTuple(), 63 | true ); 64 | 65 | localTransform.rotate = rotate; 66 | 67 | update(); 68 | } 69 | } 70 | 71 | [Inline] 72 | public final function get light( ): Light 73 | { 74 | return _light; 75 | } 76 | 77 | override protected function updateWorldData(applicationTime:Number):void 78 | { 79 | super.updateWorldData(applicationTime); 80 | 81 | if ( _light ) 82 | { 83 | _light.position = worldTransform.translate; 84 | 85 | var col0: Array = worldTransform.rotate.getColumn( 0 ); 86 | var col1: Array = worldTransform.rotate.getColumn( 1 ); 87 | var col2: Array = worldTransform.rotate.getColumn( 2 ); 88 | 89 | _light.dVector.set( col0[ 0 ], col0[ 1 ], col0[ 2 ] ); 90 | _light.uVector.set( col1[ 0 ], col1[ 1 ], col1[ 2 ] ); 91 | _light.rVector.set( col2[ 0 ], col2[ 1 ], col2[ 2 ] ); 92 | } 93 | } 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/Material.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.graphics.Color; 14 | import io.plugin.core.interfaces.IDisposable; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public class Material implements IDisposable 21 | { 22 | 23 | public var emissive: Color; 24 | public var ambient: Color; 25 | public var diffuse: Color; 26 | public var specular: Color; 27 | 28 | public function Material() 29 | { 30 | emissive = new Color( 0, 0, 0, 1 ); 31 | ambient = new Color( 0, 0, 0, 1 ); 32 | diffuse = new Color( 0, 0, 0, 1 ); 33 | specular = new Color( 0, 0, 0, 0 ); 34 | } 35 | 36 | public function dispose(): void 37 | { 38 | emissive.dispose(); 39 | emissive = null; 40 | 41 | ambient.dispose(); 42 | ambient = null; 43 | 44 | diffuse.dispose(); 45 | diffuse = null; 46 | 47 | specular.dispose(); 48 | specular = null; 49 | } 50 | 51 | } 52 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/PickRecord.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | 15 | /** 16 | * ... 17 | * @author Gary Paluk 18 | */ 19 | public class PickRecord 20 | { 21 | 22 | public var intersected: Spatial; 23 | public var t: Number = 0; 24 | public var triangle: int; 25 | public var bary: Array = []; 26 | 27 | public function PickRecord() 28 | { 29 | 30 | } 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/Polypoint.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.resources.VertexBuffer; 15 | import zest3d.resources.VertexFormat; 16 | import zest3d.scenegraph.enum.PrimitiveType; 17 | 18 | /** 19 | * ... 20 | * @author Gary Paluk 21 | */ 22 | public class Polypoint extends Visual implements IDisposable 23 | { 24 | 25 | protected var _numPoints: int; 26 | 27 | public function Polypoint( vFormat: VertexFormat, vBuffer: VertexBuffer ) 28 | { 29 | super( PrimitiveType.POLYPOINT, vFormat, vBuffer ); 30 | } 31 | 32 | override public function dispose():void 33 | { 34 | 35 | super.dispose(); 36 | } 37 | 38 | public function get maxNumPoints(): int 39 | { 40 | return _vBuffer.numElements; 41 | } 42 | 43 | public function set numPoints( numPoints: int ): void 44 | { 45 | var numVerties: int = _vBuffer.numElements; 46 | if ( 0 <= numPoints && numPoints <= numVerties ) 47 | { 48 | _numPoints = numPoints; 49 | } 50 | else 51 | { 52 | _numPoints = numVerties; 53 | } 54 | } 55 | 56 | [Inline] 57 | public function get numPoints(): int 58 | { 59 | return _numPoints; 60 | } 61 | 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/TriFan.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.resources.IndexBuffer; 15 | import zest3d.resources.VertexBuffer; 16 | import zest3d.resources.VertexFormat; 17 | import zest3d.scenegraph.enum.PrimitiveType; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class TriFan extends Triangles implements IDisposable 24 | { 25 | 26 | public function TriFan( vFormat: VertexFormat, vBuffer: VertexBuffer, iBuffer: IndexBuffer ) 27 | { 28 | super( PrimitiveType.TRIFAN, vFormat, vBuffer, iBuffer ); 29 | } 30 | 31 | override public function get numTriangles():int 32 | { 33 | return _iBuffer.numElements - 2; 34 | } 35 | 36 | override public function getTriangleAt(index:int, data:Array):Boolean 37 | { 38 | if ( 0 <= index && index < numTriangles ) 39 | { 40 | _iBuffer.data.position = index * _iBuffer.elementSize; 41 | 42 | if ( _iBuffer.elementSize == 2 ) 43 | { 44 | data[ 0 ] = _iBuffer.data.readShort(); 45 | data[ 1 ] = _iBuffer.data.readShort(); 46 | data[ 2 ] = _iBuffer.data.readShort(); 47 | } 48 | else if( _iBuffer.elementSize == 4 ) 49 | { 50 | data[ 0 ] = _iBuffer.data.readInt(); 51 | data[ 1 ] = _iBuffer.data.readInt(); 52 | data[ 2 ] = _iBuffer.data.readInt(); 53 | } 54 | else 55 | { 56 | throw new Error( "Unsupported element size." ); 57 | } 58 | 59 | return true; 60 | } 61 | return false; 62 | } 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/TriMesh.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.resources.IndexBuffer; 15 | import zest3d.resources.VertexBuffer; 16 | import zest3d.resources.VertexFormat; 17 | import zest3d.scenegraph.enum.PrimitiveType; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class TriMesh extends Triangles implements IDisposable 24 | { 25 | 26 | public function TriMesh( vFormat:VertexFormat, vBuffer: VertexBuffer, iBuffer: IndexBuffer = null ) 27 | { 28 | super( PrimitiveType.TRIMESH, vFormat, vBuffer, iBuffer ); 29 | } 30 | 31 | override public function get numTriangles():int 32 | { 33 | return int( _iBuffer.numElements / 3 ); 34 | } 35 | 36 | override public function getTriangleAt(index:int, data:Array):Boolean 37 | { 38 | 39 | if ( 0 <= index && index < numTriangles ) 40 | { 41 | _iBuffer.data.position = index * ( _iBuffer.elementSize * 3 ); 42 | 43 | data[ 0 ] = _iBuffer.data.readShort(); 44 | data[ 1 ] = _iBuffer.data.readShort(); 45 | data[ 2 ] = _iBuffer.data.readShort(); 46 | 47 | return true; 48 | } 49 | return false; 50 | } 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/TriStrip.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.core.system.Assert; 15 | import zest3d.resources.IndexBuffer; 16 | import zest3d.resources.VertexBuffer; 17 | import zest3d.resources.VertexFormat; 18 | import zest3d.scenegraph.enum.PrimitiveType; 19 | 20 | /** 21 | * ... 22 | * @author Gary Paluk 23 | */ 24 | public class TriStrip extends Triangles implements IDisposable 25 | { 26 | 27 | public function TriStrip( vFormat: VertexFormat, vBuffer: VertexBuffer, iBuffer: IndexBuffer ) 28 | { 29 | super( PrimitiveType.TRISTRIP, vFormat, vBuffer, iBuffer ); 30 | Assert.isTrue( _iBuffer.numElements >= _vBuffer.numElements, "Not enough elements for the index buffer." ); 31 | 32 | //TODO consider a help that can auto-generate strip indices 33 | /* 34 | var numVertices: int = _vBuffer.numElements; 35 | var iBuffer: IndexBuffer = new IndexBuffer( numVertices, ..... 36 | */ 37 | } 38 | 39 | override public function dispose():void 40 | { 41 | super.dispose(); 42 | } 43 | 44 | override public function getTriangleAt(index:int, data:Array):Boolean 45 | { 46 | if ( 0 <= index && index < numTriangles ) 47 | { 48 | _iBuffer.data.position = index * _iBuffer.elementSize; 49 | 50 | if ( _iBuffer.elementSize == 2 ) 51 | { 52 | 53 | data[ 0 ] = _iBuffer.data.readShort(); 54 | if ( index & 1 ) 55 | { 56 | data[ 2 ] = _iBuffer.data.readShort(); 57 | data[ 1 ] = _iBuffer.data.readShort(); 58 | } 59 | else 60 | { 61 | data[ 1 ] = _iBuffer.data.readShort(); 62 | data[ 2 ] = _iBuffer.data.readShort(); 63 | } 64 | } 65 | else if ( _iBuffer.elementSize == 4 ) 66 | { 67 | data[ 0 ] = _iBuffer.data.readInt(); 68 | if ( index & 1 ) 69 | { 70 | data[ 2 ] = _iBuffer.data.readInt(); 71 | data[ 1 ] = _iBuffer.data.readInt(); 72 | } 73 | else 74 | { 75 | data[ 1 ] = _iBuffer.data.readInt(); 76 | data[ 2 ] = _iBuffer.data.readInt(); 77 | } 78 | } 79 | else 80 | { 81 | throw new Error( "Unsupported element size." ); 82 | } 83 | 84 | return ( data[ 0 ] != data[ 1 ] && data[ 0 ] != data[ 2 ] && data[ 1 ] != data[ 2 ] ); 85 | } 86 | 87 | return false; 88 | } 89 | 90 | override public function get numTriangles():int 91 | { 92 | return _iBuffer.numElements - 2; 93 | } 94 | 95 | } 96 | 97 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/VisibleSet.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.core.system.Assert; 15 | 16 | /** 17 | * ... 18 | * @author Gary Paluk 19 | */ 20 | public class VisibleSet implements IDisposable 21 | { 22 | 23 | private var _visible: Vector.; 24 | 25 | public function VisibleSet() 26 | { 27 | _visible = new Vector.(); 28 | } 29 | 30 | public function dispose(): void 31 | { 32 | for each( var d:IDisposable in _visible ) 33 | { 34 | d.dispose(); 35 | } 36 | _visible = null; 37 | } 38 | 39 | 40 | [Inline] 41 | public final function get numVisible(): int 42 | { 43 | return _visible.length; 44 | } 45 | 46 | [Inline] 47 | public final function getAllVisible(): Vector. 48 | { 49 | return _visible; 50 | } 51 | 52 | [Inline] 53 | public final function getVisibleAt( index: int ): Spatial 54 | { 55 | Assert.isTrue( 0 <= index && index < numVisible, "Invalid index to GetVisible." ); 56 | return _visible[ index ]; 57 | } 58 | 59 | public function insert( visible: Spatial ): void 60 | { 61 | _visible.push( visible ); 62 | } 63 | 64 | [inline] 65 | public final function clear(): void 66 | { 67 | /* 68 | for each( var d:IDisposable in _visible ) 69 | { 70 | d.dispose(); 71 | } 72 | */ 73 | _visible.length = 0; 74 | } 75 | 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/enum/CullingType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class CullingType 18 | { 19 | 20 | public static const DYNAMIC: CullingType = new CullingType( "dynamic" ); 21 | public static const ALWAYS: CullingType = new CullingType( "always" ); 22 | public static const NEVER: CullingType = new CullingType( "never" ); 23 | 24 | public static const QUANTITY: int = 3; 25 | 26 | protected var _type: String; 27 | public function CullingType( type: String ) 28 | { 29 | _type = type; 30 | } 31 | 32 | public function get type():String 33 | { 34 | return _type; 35 | } 36 | 37 | public static function toVector(): Vector. 38 | { 39 | return Vector. 40 | ([ 41 | DYNAMIC, 42 | ALWAYS, 43 | NEVER 44 | ]); 45 | } 46 | 47 | public function toString(): String 48 | { 49 | return "[object CullingType] (type: " + type + ")"; 50 | } 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/enum/LightType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class LightType 18 | { 19 | 20 | public static const AMBIENT: LightType = new LightType( "ambient", 0 ); 21 | public static const DIRECTIONAL: LightType = new LightType( "directional", 1 ); 22 | public static const POINT: LightType = new LightType( "point", 2 ); 23 | public static const SPOT: LightType = new LightType( "spot", 3 ); 24 | 25 | public static const QUANITY: int = 4; 26 | 27 | protected var _type: String; 28 | protected var _index: int; 29 | public function LightType( type: String, index: int ) 30 | { 31 | _type = type; 32 | _index = index; 33 | } 34 | 35 | public static function toVector(): Vector. 36 | { 37 | return Vector. 38 | ([ 39 | AMBIENT, 40 | DIRECTIONAL, 41 | POINT, 42 | SPOT 43 | ]); 44 | } 45 | 46 | [Inline] 47 | public final function get type():String 48 | { 49 | return _type; 50 | } 51 | 52 | [Inline] 53 | public final function get index():int 54 | { 55 | return _index; 56 | } 57 | 58 | public function toString(): String 59 | { 60 | return "[object LightType] (type: " + type + ", index: " + index + ")"; 61 | } 62 | 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/enum/PrimitiveType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class PrimitiveType 18 | { 19 | 20 | public static const NONE: PrimitiveType = new PrimitiveType( "none" ); 21 | public static const POLYPOINT: PrimitiveType = new PrimitiveType( "polypoint" ); 22 | public static const POLYSEGMENTS_DISJOINT: PrimitiveType = new PrimitiveType( "polysegmentsDisjoint" ); 23 | public static const POLYSEGMENTS_CONTIGUOUS: PrimitiveType = new PrimitiveType( "polysegmentsContiguous" ); 24 | public static const TRIANGLES: PrimitiveType = new PrimitiveType( "triangles" ); // abstract 25 | public static const TRIMESH: PrimitiveType = new PrimitiveType( "trimesh" ); 26 | public static const TRISTRIP: PrimitiveType = new PrimitiveType( "tristrip" ); 27 | public static const TRIFAN: PrimitiveType = new PrimitiveType( "trifan" ); 28 | 29 | public static const QUANTITY: int = 8; 30 | 31 | protected var _type: String; 32 | 33 | public function PrimitiveType( type: String ) 34 | { 35 | _type = type; 36 | } 37 | 38 | public function get type():String 39 | { 40 | return _type; 41 | } 42 | 43 | public static function toVector(): Vector. 44 | { 45 | return Vector. 46 | ([ 47 | NONE, 48 | POLYPOINT, 49 | POLYSEGMENTS_DISJOINT, 50 | POLYSEGMENTS_CONTIGUOUS, 51 | TRIANGLES, 52 | TRIMESH, 53 | TRISTRIP, 54 | TRIFAN 55 | ]); 56 | } 57 | 58 | public function toString(): String 59 | { 60 | return "[object PrimitiveType] (type: " + type + ")"; 61 | } 62 | 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/zest3d/scenegraph/enum/UpdateType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.scenegraph.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class UpdateType 18 | { 19 | 20 | public static const MODEL_BOUND_ONLY: UpdateType = new UpdateType( "modelBoundOnly", -3 ); 21 | public static const NORMALS: UpdateType = new UpdateType( "normals", -2 ); 22 | public static const USE_GEOMETRY: UpdateType = new UpdateType( "useGeometry", -1 ); 23 | public static const USE_TCOORD_CHANNEL: UpdateType = new UpdateType( "useTCoordChannel", 0 ); 24 | 25 | public static const QUANTITY: int = 4; 26 | 27 | protected var _type: String; 28 | protected var _index: int; 29 | 30 | public function UpdateType( type: String, index: int ) 31 | { 32 | _type = type; 33 | _index = index; 34 | } 35 | 36 | public function get type():String 37 | { 38 | return _type; 39 | } 40 | 41 | public function get index():int 42 | { 43 | return _index; 44 | } 45 | 46 | public static function toVector(): Vector. 47 | { 48 | return Vector. 49 | ([ 50 | MODEL_BOUND_ONLY, 51 | NORMALS, 52 | USE_GEOMETRY, 53 | USE_TCOORD_CHANNEL 54 | ]) 55 | } 56 | 57 | public function toString(): String 58 | { 59 | return "[object UpdateType] (type: " + type + ", index: " + index + ")"; 60 | } 61 | 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/ShaderFloat.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats 12 | { 13 | import flash.utils.ByteArray; 14 | import flash.utils.Endian; 15 | import io.plugin.core.interfaces.IDisposable; 16 | import io.plugin.core.system.Assert; 17 | import zest3d.scenegraph.Camera; 18 | import zest3d.scenegraph.Visual; 19 | 20 | /** 21 | * ... 22 | * @author Gary Paluk 23 | */ 24 | public class ShaderFloat implements IDisposable 25 | { 26 | 27 | protected var _numElements: int; 28 | protected var _data: ByteArray; 29 | protected var _allowUpdater: Boolean; 30 | 31 | public function ShaderFloat( numRegisters: int ) 32 | { 33 | _allowUpdater = false; 34 | this.numRegisters = numRegisters; 35 | } 36 | 37 | public function dispose(): void 38 | { 39 | _data = null; 40 | } 41 | 42 | public function set numRegisters( numRegisters: int ): void 43 | { 44 | Assert.isTrue( numRegisters > 0, "Number of registers must be positive." ); 45 | 46 | _numElements = 4 * numRegisters; 47 | _data = new ByteArray(); 48 | _data.endian = Endian.LITTLE_ENDIAN; 49 | } 50 | 51 | [Inline] 52 | public final function get numRegisters(): int 53 | { 54 | return int( _numElements / 4 ); 55 | } 56 | 57 | [Inline] 58 | public final function get data(): ByteArray 59 | { 60 | return _data; 61 | } 62 | 63 | public function setRegister( index: int, data: Array ): void 64 | { 65 | Assert.isTrue( 0 <= index && index < _numElements / 4, "Invalid register" ); 66 | 67 | _data.position = ( (index * 4) * 4 ); 68 | var offset: int = 0; 69 | _data.writeFloat( data[ offset++ ] ); 70 | _data.writeFloat( data[ offset++ ] ); 71 | _data.writeFloat( data[ offset++ ] ); 72 | _data.writeFloat( data[ offset++ ] ); 73 | } 74 | 75 | public function setRegisters( data: Array ): void 76 | { 77 | _data.position = 0; 78 | var offset: int = 0; 79 | _data.writeFloat( data[ offset++ ] ); 80 | } 81 | 82 | public function getRegister( index: int ): Array 83 | { 84 | Assert.isTrue( 0 <= index && index < _numElements / 4, "Invalid register" ); 85 | 86 | _data.position = ( (index * 4) * 4 ); 87 | return [ _data.readFloat(), 88 | _data.readFloat(), 89 | _data.readFloat(), 90 | _data.readFloat() ]; 91 | } 92 | 93 | public function getRegisters( ): Array 94 | { 95 | _data.position = 0; 96 | var out: Array = []; 97 | for ( var i: int = 0; i < _numElements; ++i ) 98 | { 99 | out[ i ] = _data.readFloat(); 100 | } 101 | return out; 102 | } 103 | 104 | [Inline] 105 | public final function enableUpdater(): void 106 | { 107 | _allowUpdater = true; 108 | } 109 | 110 | [Inline] 111 | public final function disableUpdater(): void 112 | { 113 | _allowUpdater = false; 114 | } 115 | 116 | [Inline] 117 | public final function allowUpdater(): Boolean 118 | { 119 | return _allowUpdater; 120 | } 121 | 122 | // virtual 123 | public function update( visual: Visual, camera: Camera ): void 124 | { 125 | throw new Error( "ShaderFloat::update must be overridden." ); 126 | } 127 | 128 | } 129 | 130 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/camera/CameraModelDVectorConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.camera 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.AVector; 15 | import io.plugin.math.algebra.HMatrix; 16 | import zest3d.scenegraph.Camera; 17 | import zest3d.scenegraph.Visual; 18 | import zest3d.shaderfloats.ShaderFloat; 19 | 20 | /** 21 | * ... 22 | * @author Gary Paluk 23 | */ 24 | public class CameraModelDVectorConstant extends ShaderFloat implements IDisposable 25 | { 26 | 27 | public function CameraModelDVectorConstant() 28 | { 29 | super( 1 ); 30 | _allowUpdater = true; 31 | } 32 | 33 | override public function dispose():void 34 | { 35 | super.dispose(); 36 | } 37 | 38 | override public function update(visual:Visual, camera:Camera):void 39 | { 40 | var worldDVector: AVector = camera.dVector; 41 | var worldInvMatrix: HMatrix = visual.worldTransform.inverse; 42 | var modelDVector: AVector = worldInvMatrix.multiplyAVector( worldDVector ); 43 | 44 | var tuple: Array = modelDVector.toTuple(); 45 | 46 | _data.position = 0; 47 | for ( var i: int = 0; i < 4; ++i ) 48 | { 49 | _data.writeFloat( tuple[ i ] ); 50 | } 51 | } 52 | 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/camera/CameraModelPositionConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.camera 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.APoint; 15 | import io.plugin.math.algebra.HMatrix; 16 | import zest3d.scenegraph.Camera; 17 | import zest3d.scenegraph.Visual; 18 | import zest3d.shaderfloats.ShaderFloat; 19 | 20 | /** 21 | * ... 22 | * @author Gary Paluk 23 | */ 24 | public class CameraModelPositionConstant extends ShaderFloat implements IDisposable 25 | { 26 | 27 | public function CameraModelPositionConstant() 28 | { 29 | super( 1 ); 30 | _allowUpdater = true; 31 | } 32 | 33 | override public function dispose():void 34 | { 35 | super.dispose(); 36 | } 37 | 38 | override public function update(visual:Visual, camera:Camera):void 39 | { 40 | var worldPosition: APoint = camera.position; 41 | var worldInvMatrix: HMatrix = visual.worldTransform.inverse; 42 | var modelPosition: APoint = worldInvMatrix.multiplyAPoint( worldPosition ); 43 | 44 | var tuple: Array = modelPosition.toTuple(); 45 | 46 | _data.position = 0; 47 | for ( var i: int = 0; i < 4; ++i ) 48 | { 49 | _data.writeFloat( tuple[ i ] ); 50 | } 51 | } 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/camera/CameraWorldDVectorConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.camera 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Visual; 16 | import zest3d.shaderfloats.ShaderFloat; 17 | 18 | /** 19 | * ... 20 | * @author Gary Paluk 21 | */ 22 | public class CameraWorldDVectorConstant extends ShaderFloat implements IDisposable 23 | { 24 | 25 | public function CameraWorldDVectorConstant() 26 | { 27 | super( 1 ); 28 | _allowUpdater = true; 29 | } 30 | 31 | override public function dispose():void 32 | { 33 | super.dispose(); 34 | } 35 | 36 | override public function update(visual:Visual, camera:Camera):void 37 | { 38 | var tuple: Array = camera.dVector.toTuple(); 39 | 40 | _data.position = 0; 41 | for ( var i: int = 0; i < 4; ++i ) 42 | { 43 | _data.writeFloat( tuple[ i ] ); 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/camera/CameraWorldPositionConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.camera 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Visual; 16 | import zest3d.shaderfloats.ShaderFloat; 17 | 18 | /** 19 | * ... 20 | * @author Gary Paluk 21 | */ 22 | public class CameraWorldPositionConstant extends ShaderFloat implements IDisposable 23 | { 24 | 25 | public function CameraWorldPositionConstant() 26 | { 27 | super( 1 ); 28 | _allowUpdater = true; 29 | } 30 | 31 | override public function dispose():void 32 | { 33 | super.dispose(); 34 | } 35 | 36 | override public function update(visual:Visual, camera:Camera):void 37 | { 38 | var tuple: Array = camera.position.toTuple(); 39 | 40 | _data.position = 0; 41 | for ( var i: int = 0; i < 4; ++i ) 42 | { 43 | _data.writeFloat( tuple[ i ] ); 44 | } 45 | 46 | } 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightAmbientConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.light 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Light; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class LightAmbientConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _light: Light; 27 | 28 | public function LightAmbientConstant( light: Light ) 29 | { 30 | super( 1 ); 31 | _light = light; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _light.dispose(); 38 | _light = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | var tuple: Array = _light.ambient.toArray(); 46 | _data.position = 0; 47 | for ( var i: int = 0; i < 4; ++i ) 48 | { 49 | _data.writeFloat( tuple[ i ] ); 50 | } 51 | } 52 | 53 | public function get light(): Light 54 | { 55 | return _light; 56 | } 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightAttenuationConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.light 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Light; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class LightAttenuationConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _light: Light; 27 | 28 | public function LightAttenuationConstant( light: Light ) 29 | { 30 | super( 1 ); 31 | _light = light; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _light.dispose(); 38 | _light = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | _data.position = 0; 46 | _data.writeFloat( _light.constant ); 47 | _data.writeFloat( _light.linear ); 48 | _data.writeFloat( _light.quadratic ); 49 | _data.writeFloat( _light.intensity ); 50 | } 51 | 52 | public function get light(): Light 53 | { 54 | return _light; 55 | } 56 | 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightDiffuseConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.light 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Light; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class LightDiffuseConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _light: Light; 27 | 28 | public function LightDiffuseConstant( light: Light ) 29 | { 30 | super( 1 ); 31 | _light = light; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _light.dispose(); 38 | _light = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | var tuple: Array = _light.diffuse.toArray(); 46 | _data.position = 0; 47 | for ( var i: int = 0; i < 4; ++i ) 48 | { 49 | _data.writeFloat( tuple[ i ] ); 50 | } 51 | } 52 | 53 | public function get light(): Light 54 | { 55 | return _light; 56 | } 57 | 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightModelDVectorConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.light 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.AVector; 15 | import io.plugin.math.algebra.HMatrix; 16 | import zest3d.scenegraph.Camera; 17 | import zest3d.scenegraph.Light; 18 | import zest3d.scenegraph.Visual; 19 | import zest3d.shaderfloats.ShaderFloat; 20 | 21 | /** 22 | * ... 23 | * @author Gary Paluk 24 | */ 25 | public class LightModelDVectorConstant extends ShaderFloat implements IDisposable 26 | { 27 | 28 | protected var _light: Light; 29 | 30 | public function LightModelDVectorConstant( light: Light ) 31 | { 32 | super( 1 ); 33 | _light = light; 34 | _allowUpdater = true; 35 | } 36 | 37 | override public function dispose():void 38 | { 39 | _light.dispose(); 40 | _light = null; 41 | 42 | super.dispose(); 43 | } 44 | 45 | override public function update(visual:Visual, camera:Camera):void 46 | { 47 | var worldInvMatrix: HMatrix = visual.worldTransform.inverse; 48 | var modelDVector: AVector = worldInvMatrix.multiplyAVector( _light.dVector ); 49 | 50 | var tuple: Array = modelDVector.toTuple(); 51 | _data.position = 0; 52 | for ( var i: int = 0; i < 4; ++i ) 53 | { 54 | _data.writeFloat( tuple[ i ] ); 55 | } 56 | } 57 | 58 | public function get light(): Light 59 | { 60 | return _light; 61 | } 62 | 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightModelPositionConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.light 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.APoint; 15 | import io.plugin.math.algebra.HMatrix; 16 | import zest3d.scenegraph.Camera; 17 | import zest3d.scenegraph.Light; 18 | import zest3d.scenegraph.Visual; 19 | import zest3d.shaderfloats.ShaderFloat; 20 | 21 | /** 22 | * ... 23 | * @author Gary Paluk 24 | */ 25 | public class LightModelPositionConstant extends ShaderFloat implements IDisposable 26 | { 27 | 28 | protected var _light: Light; 29 | 30 | public function LightModelPositionConstant( light: Light ) 31 | { 32 | super( 1 ); 33 | _light = light; 34 | _allowUpdater = true; 35 | } 36 | 37 | override public function dispose():void 38 | { 39 | _light.dispose(); 40 | _light = null; 41 | 42 | super.dispose(); 43 | } 44 | 45 | override public function update(visual:Visual, camera:Camera):void 46 | { 47 | var worldPosition: APoint = _light.position; 48 | var worldInvMatrix: HMatrix = visual.worldTransform.inverse; 49 | var modelPosition: APoint = worldInvMatrix.multiplyAPoint( worldPosition ); 50 | 51 | var tuple: Array = modelPosition.toTuple(); 52 | 53 | _data.position = 0; 54 | for ( var i: int = 0; i < 4; ++i ) 55 | { 56 | _data.writeFloat( tuple[ i ] ); 57 | } 58 | } 59 | 60 | public function get light(): Light 61 | { 62 | return _light; 63 | } 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightSpecularConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.light 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Light; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class LightSpecularConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _light: Light; 27 | 28 | public function LightSpecularConstant( light: Light ) 29 | { 30 | super( 1 ); 31 | _light = light; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _light.dispose(); 38 | _light = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | var tuple: Array = _light.specular.toArray(); 46 | _data.position = 0; 47 | 48 | for ( var i: int = 0; i < 4; ++i ) 49 | { 50 | _data.writeFloat( tuple[ i ] ); 51 | } 52 | } 53 | 54 | public function get light(): Light 55 | { 56 | return _light; 57 | } 58 | 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightSpecularExponentConstant.as: -------------------------------------------------------------------------------- 1 | package zest3d.shaderfloats.light 2 | { 3 | import io.plugin.core.interfaces.IDisposable; 4 | import zest3d.scenegraph.Camera; 5 | import zest3d.scenegraph.Light; 6 | import zest3d.scenegraph.Visual; 7 | import zest3d.shaderfloats.ShaderFloat; 8 | 9 | /** 10 | * ... 11 | * @author Gary Paluk - http://www.plugin.io 12 | */ 13 | public class LightSpecularExponentConstant extends ShaderFloat implements IDisposable 14 | { 15 | protected var _light:Light; 16 | 17 | public function LightSpecularExponentConstant( light:Light ) 18 | { 19 | super( 1 ); 20 | _light = light; 21 | _allowUpdater = true; 22 | } 23 | 24 | override public function update(visual:Visual, camera:Camera):void 25 | { 26 | var tuple: Array = [ _light.exponent, 0, 0, 0 ]; 27 | _data.position = 0; 28 | 29 | for ( var i: int = 0; i < 4; ++i ) 30 | { 31 | _data.writeFloat( tuple[ i ] ); 32 | } 33 | } 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightSpotConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.light 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Light; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class LightSpotConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _light: Light; 27 | 28 | public function LightSpotConstant( light: Light ) 29 | { 30 | super( 1 ); 31 | _light = light; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _light.dispose(); 38 | _light = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | _data.position = 0; 46 | _data.writeFloat( _light.angle ); 47 | _data.writeFloat( _light.cosAngle ); 48 | _data.writeFloat( _light.sinAngle ); 49 | _data.writeFloat( _light.exponent ); 50 | } 51 | 52 | public function get light(): Light 53 | { 54 | return _light; 55 | } 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightWorldDVectorConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.light 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Light; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class LightWorldDVectorConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _light: Light; 27 | 28 | public function LightWorldDVectorConstant( light: Light ) 29 | { 30 | super( 1 ); 31 | _light = light; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _light.dispose(); 38 | _light = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | var tuple: Array = _light.dVector.toTuple(); 46 | 47 | _data.position = 0; 48 | for ( var i: int = 0; i < 4; ++i ) 49 | { 50 | _data.writeFloat( tuple[ i ] ); 51 | } 52 | } 53 | 54 | public function get light(): Light 55 | { 56 | return _light; 57 | } 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/light/LightWorldPositionConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.light 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Light; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class LightWorldPositionConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _light: Light; 27 | 28 | public function LightWorldPositionConstant( light: Light ) 29 | { 30 | super( 1 ); 31 | _light = light; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _light.dispose(); 38 | _light = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | var tuple: Array = _light.position.toTuple(); 46 | _data.position = 0; 47 | 48 | for ( var i: int = 0; i < 4; ++i ) 49 | { 50 | _data.writeFloat( tuple[ i ] ); 51 | } 52 | } 53 | 54 | public function get light(): Light 55 | { 56 | return _light; 57 | } 58 | 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/material/MaterialAmbientConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.material 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Material; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class MaterialAmbientConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _material: Material; 27 | 28 | public function MaterialAmbientConstant( material: Material ) 29 | { 30 | super( 1 ); 31 | _material = material; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _material.dispose(); 38 | _material = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | var tuple: Array = _material.ambient.toArray(); 46 | _data.position = 0; 47 | for ( var i: int = 0; i < 4; ++i ) 48 | { 49 | _data.writeFloat( tuple[ i ] ); 50 | } 51 | } 52 | 53 | public function get material(): Material 54 | { 55 | return _material; 56 | } 57 | 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/material/MaterialDiffuseConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.material 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Material; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class MaterialDiffuseConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _material: Material; 27 | 28 | public function MaterialDiffuseConstant( material: Material ) 29 | { 30 | super( 1 ); 31 | _material = material; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _material.dispose(); 38 | _material = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | var tuple: Array = _material.diffuse.toArray(); 46 | _data.position = 0; 47 | for ( var i: int = 0; i < 4; ++i ) 48 | { 49 | _data.writeFloat( tuple[ i ] ); 50 | } 51 | } 52 | 53 | public function get material(): Material 54 | { 55 | return _material; 56 | } 57 | 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/material/MaterialEmissiveConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.material 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Material; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class MaterialEmissiveConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _material: Material; 27 | 28 | public function MaterialEmissiveConstant( material: Material ) 29 | { 30 | super( 1 ); 31 | _material = material; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _material.dispose(); 38 | _material = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | _data.position = 0; 46 | var tuple: Array = _material.emissive.toArray(); 47 | for ( var i: int = 0; i < 4; ++i ) 48 | { 49 | _data.writeFloat( tuple[ i ] ); 50 | } 51 | } 52 | 53 | public function get material(): Material 54 | { 55 | return _material; 56 | } 57 | 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/material/MatrialSpecularConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.material 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Material; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class MatrialSpecularConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | protected var _material: Material; 27 | 28 | public function MatrialSpecularConstant( material: Material ) 29 | { 30 | super( 1 ); 31 | _material = material; 32 | _allowUpdater = true; 33 | } 34 | 35 | override public function dispose():void 36 | { 37 | _material.dispose(); 38 | _material = null; 39 | 40 | super.dispose(); 41 | } 42 | 43 | override public function update(visual:Visual, camera:Camera):void 44 | { 45 | var tuple: Array = _material.specular.toArray(); 46 | _data.position = 0; 47 | 48 | for ( var i: int = 0; i < 4; ++i ) 49 | { 50 | _data.writeFloat( tuple[ i ] ); 51 | } 52 | } 53 | 54 | public function get material(): Material 55 | { 56 | return _material; 57 | } 58 | 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/matrix/PMatrixConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.matrix 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.HMatrix; 15 | import zest3d.scenegraph.Camera; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class PMatrixConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | public function PMatrixConstant() 27 | { 28 | super( 4 ); 29 | _allowUpdater = true; 30 | } 31 | 32 | override public function dispose():void 33 | { 34 | super.dispose(); 35 | } 36 | 37 | override public function update(visual:Visual, camera:Camera):void 38 | { 39 | var projMatrix: HMatrix = camera.projectionMatrix; 40 | 41 | _data.position = 0; 42 | var tuple: Array = projMatrix.toTuple(); 43 | for ( var i: int; i < 16; ++i ) 44 | { 45 | _data.writeFloat( tuple[ i ] ); 46 | } 47 | 48 | } 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/matrix/PVMatrixConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.matrix 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.HMatrix; 15 | import zest3d.scenegraph.Camera; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class PVMatrixConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | public function PVMatrixConstant() 27 | { 28 | super( 4 ); 29 | _allowUpdater = true; 30 | } 31 | 32 | override public function dispose():void 33 | { 34 | super.dispose(); 35 | } 36 | 37 | override public function update(visual:Visual, camera:Camera):void 38 | { 39 | var projViewMatrix: HMatrix = camera.projectionViewMatrix; 40 | var tuple: Array = projViewMatrix.toTuple(); 41 | 42 | _data.position = 0; 43 | for ( var i: int = 0; i < 16; ++i ) 44 | { 45 | _data.writeFloat( tuple[ i ] ); 46 | } 47 | } 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/matrix/PVWMatrixConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.matrix 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.HMatrix; 15 | import zest3d.scenegraph.Camera; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class PVWMatrixConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | public function PVWMatrixConstant() 27 | { 28 | super( 4 ); 29 | _allowUpdater = true; 30 | } 31 | 32 | override public function dispose():void 33 | { 34 | super.dispose(); 35 | } 36 | 37 | override public function update(visual:Visual, camera:Camera):void 38 | { 39 | var projViewMatrix: HMatrix = camera.projectionViewMatrix; 40 | var worldMatrix: HMatrix = visual.worldTransform.matrix; 41 | 42 | var projViewWorldMatrix: HMatrix = projViewMatrix.multiply( worldMatrix ); 43 | 44 | var tuple: Array = projViewWorldMatrix.toTuple(); 45 | _data.position = 0; 46 | 47 | 48 | for ( var i: int = 0; i < 16; ++i ) 49 | { 50 | _data.writeFloat( tuple[ i ] ); 51 | } 52 | 53 | 54 | } 55 | 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/matrix/VMatrixConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.matrix 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Visual; 16 | import zest3d.shaderfloats.ShaderFloat; 17 | 18 | /** 19 | * ... 20 | * @author Gary Paluk 21 | */ 22 | public class VMatrixConstant extends ShaderFloat implements IDisposable 23 | { 24 | 25 | public function VMatrixConstant() 26 | { 27 | super( 4 ); 28 | _allowUpdater = true; 29 | } 30 | 31 | override public function dispose():void 32 | { 33 | super.dispose(); 34 | } 35 | 36 | override public function update(visual:Visual, camera:Camera):void 37 | { 38 | var tuple: Array = camera.viewMatrix.toTuple(); 39 | 40 | _data.position = 0; 41 | for ( var i: int = 0; i < 16; ++i ) 42 | { 43 | _data.writeFloat( tuple[ i ] ); 44 | } 45 | } 46 | 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/matrix/VWMatrixConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.matrix 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import io.plugin.math.algebra.HMatrix; 15 | import zest3d.scenegraph.Camera; 16 | import zest3d.scenegraph.Visual; 17 | import zest3d.shaderfloats.ShaderFloat; 18 | 19 | /** 20 | * ... 21 | * @author Gary Paluk 22 | */ 23 | public class VWMatrixConstant extends ShaderFloat implements IDisposable 24 | { 25 | 26 | public function VWMatrixConstant() 27 | { 28 | super( 4 ); 29 | _allowUpdater = true; 30 | } 31 | 32 | override public function dispose():void 33 | { 34 | super.dispose(); 35 | } 36 | 37 | override public function update(visual:Visual, camera:Camera):void 38 | { 39 | var viewMatrix: HMatrix = camera.viewMatrix; 40 | var worldMatrix: HMatrix = visual.worldTransform.matrix; 41 | var viewWorldMatrix: HMatrix = viewMatrix.multiply( worldMatrix ); 42 | 43 | var tuple: Array = viewWorldMatrix.toTuple(); 44 | _data.position = 0; 45 | 46 | for ( var i: int = 0; i < 16; ++i ) 47 | { 48 | _data.writeFloat( tuple[ i ] ); 49 | } 50 | } 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /src/zest3d/shaderfloats/matrix/WMatrixConstant.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaderfloats.matrix 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.scenegraph.Camera; 15 | import zest3d.scenegraph.Visual; 16 | import zest3d.shaderfloats.ShaderFloat; 17 | 18 | /** 19 | * ... 20 | * @author Gary Paluk 21 | */ 22 | public class WMatrixConstant extends ShaderFloat implements IDisposable 23 | { 24 | 25 | public function WMatrixConstant() 26 | { 27 | super( 4 ); 28 | _allowUpdater = true; 29 | } 30 | 31 | override public function dispose():void 32 | { 33 | super.dispose(); 34 | } 35 | 36 | override public function update(visual:Visual, camera:Camera):void 37 | { 38 | 39 | var tuple: Array = visual.worldTransform.matrix.toTuple(); 40 | 41 | _data.position = 0; 42 | for ( var i: int = 0; i < 16; ++i ) 43 | { 44 | _data.writeFloat( tuple[ i ] ); 45 | } 46 | 47 | } 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/PixelShader.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.renderers.Renderer; 15 | import zest3d.shaders.enum.PixelShaderProfileType; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class PixelShader extends Shader implements IDisposable 22 | { 23 | 24 | protected static var msProfile: PixelShaderProfileType = PixelShaderProfileType.AGAL_1_0; 25 | 26 | public function PixelShader( programName: String, numInputs: int, numOutputs: int, numConstants: int, numSamplers: int, profileOwner: Boolean ) 27 | { 28 | super( programName, numInputs, numOutputs, numConstants, numSamplers, profileOwner ); 29 | } 30 | 31 | override public function dispose():void 32 | { 33 | Renderer.unbindAllPixelShader( this ); 34 | super.dispose(); 35 | } 36 | 37 | public static function get profile(): PixelShaderProfileType 38 | { 39 | return msProfile; 40 | } 41 | 42 | public static function set profile( profile: PixelShaderProfileType ): void 43 | { 44 | msProfile = profile; 45 | } 46 | 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/VertexShader.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.renderers.Renderer; 15 | import zest3d.shaders.enum.VertexShaderProfileType; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class VertexShader extends Shader implements IDisposable 22 | { 23 | 24 | protected static var msProfile: VertexShaderProfileType = VertexShaderProfileType.AGAL_1_0; 25 | 26 | public function VertexShader( programName: String, numInputs: int, numOutputs: int, numConstants: int, numSamplers: int, profileOwner: Boolean ) 27 | { 28 | super( programName, numInputs, numOutputs, numConstants, numSamplers, profileOwner ); 29 | } 30 | 31 | override public function dispose(): void 32 | { 33 | Renderer.unbindAllVertexShader( this ); 34 | super.dispose(); 35 | } 36 | 37 | public static function set profile( profile: VertexShaderProfileType ): void 38 | { 39 | msProfile = profile; 40 | } 41 | 42 | public static function get profile(): VertexShaderProfileType 43 | { 44 | return msProfile; 45 | } 46 | 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/VisualPass.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.shaders.states.AlphaState; 15 | import zest3d.shaders.states.CullState; 16 | import zest3d.shaders.states.DepthState; 17 | import zest3d.shaders.states.OffsetState; 18 | import zest3d.shaders.states.StencilState; 19 | import zest3d.shaders.states.WireState; 20 | 21 | /** 22 | * ... 23 | * @author Gary Paluk 24 | */ 25 | public class VisualPass implements IDisposable 26 | { 27 | 28 | protected var _vShader: VertexShader; 29 | protected var _pShader: PixelShader; 30 | protected var _alphaState: AlphaState; 31 | protected var _cullState: CullState; 32 | protected var _depthState: DepthState; 33 | protected var _offsetState: OffsetState; 34 | protected var _stencilState: StencilState; 35 | protected var _wireState: WireState; 36 | 37 | public function VisualPass() 38 | { 39 | 40 | } 41 | 42 | public function dispose(): void 43 | { 44 | _vShader.dispose(); 45 | _pShader.dispose(); 46 | _alphaState.dispose(); 47 | _cullState.dispose(); 48 | _depthState.dispose(); 49 | _offsetState.dispose(); 50 | _stencilState.dispose(); 51 | _wireState.dispose(); 52 | 53 | _vShader = null; 54 | _pShader = null; 55 | _alphaState = null; 56 | _cullState = null; 57 | _depthState = null; 58 | _offsetState = null; 59 | _stencilState = null; 60 | _wireState = null; 61 | } 62 | 63 | [Inline] 64 | public final function set vertexShader( vShader: VertexShader ): void 65 | { 66 | _vShader = vShader; 67 | } 68 | 69 | [Inline] 70 | public final function set pixelShader( pShader: PixelShader ): void 71 | { 72 | _pShader = pShader; 73 | } 74 | 75 | [Inline] 76 | public final function set alphaState( alphaState: AlphaState ): void 77 | { 78 | _alphaState = alphaState; 79 | } 80 | 81 | [Inline] 82 | public final function set cullState( cullState: CullState ): void 83 | { 84 | _cullState = cullState; 85 | } 86 | 87 | [Inline] 88 | public final function set depthState( depthState: DepthState ): void 89 | { 90 | _depthState = depthState; 91 | } 92 | 93 | [Inline] 94 | public final function set offsetState( offsetState: OffsetState ): void 95 | { 96 | _offsetState = offsetState; 97 | } 98 | 99 | [Inline] 100 | public final function set stencilState( stencilState: StencilState ): void 101 | { 102 | _stencilState = stencilState; 103 | } 104 | 105 | [Inline] 106 | public final function set wireState( wireState: WireState ): void 107 | { 108 | _wireState = wireState; 109 | } 110 | 111 | 112 | 113 | [Inline] 114 | public final function get vertexShader(): VertexShader 115 | { 116 | return _vShader; 117 | } 118 | 119 | [Inline] 120 | public final function get pixelShader(): PixelShader 121 | { 122 | return _pShader; 123 | } 124 | 125 | [Inline] 126 | public final function get alphaState(): AlphaState 127 | { 128 | return _alphaState; 129 | } 130 | 131 | [Inline] 132 | public final function get cullState(): CullState 133 | { 134 | return _cullState; 135 | } 136 | 137 | [Inline] 138 | public final function get depthState(): DepthState 139 | { 140 | return _depthState; 141 | } 142 | 143 | [Inline] 144 | public final function get offsetState(): OffsetState 145 | { 146 | return _offsetState; 147 | } 148 | 149 | [Inline] 150 | public final function get stencilState(): StencilState 151 | { 152 | return _stencilState; 153 | } 154 | 155 | [Inline] 156 | public final function get wireState(): WireState 157 | { 158 | return _wireState; 159 | } 160 | 161 | } 162 | 163 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/VisualTechnique.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders 12 | { 13 | import io.plugin.core.errors.IllegalArgumentError; 14 | import io.plugin.core.interfaces.IDisposable; 15 | import zest3d.shaders.states.AlphaState; 16 | import zest3d.shaders.states.CullState; 17 | import zest3d.shaders.states.DepthState; 18 | import zest3d.shaders.states.OffsetState; 19 | import zest3d.shaders.states.StencilState; 20 | import zest3d.shaders.states.WireState; 21 | 22 | /** 23 | * ... 24 | * @author Gary Paluk 25 | */ 26 | public class VisualTechnique implements IDisposable 27 | { 28 | 29 | protected var _passes:Vector. 30 | 31 | public function VisualTechnique() 32 | { 33 | _passes = new Vector.(); 34 | } 35 | 36 | public function dispose(): void 37 | { 38 | for each( var pass: VisualPass in _passes ) 39 | { 40 | pass.dispose(); 41 | } 42 | _passes = null; 43 | } 44 | 45 | public function insertPass( pass:VisualPass ): void 46 | { 47 | if ( pass ) 48 | { 49 | _passes.push( pass ); 50 | return; 51 | } 52 | throw new IllegalArgumentError( "Input to InsertPass must be nonnull." ); 53 | } 54 | 55 | [Inline] 56 | public final function get numPasses(): int 57 | { 58 | return _passes.length; 59 | } 60 | 61 | public function getPass( index: int ): VisualPass 62 | { 63 | if ( 0 <= index && index < _passes.length ) 64 | { 65 | return _passes[ index ]; 66 | } 67 | throw new IllegalArgumentError( "Invalid index." ); 68 | } 69 | 70 | public function getVertexShader( index: int ): VertexShader 71 | { 72 | if ( 0 <= index && index < _passes.length ) 73 | { 74 | return _passes[ index ].vertexShader; 75 | } 76 | throw new IllegalArgumentError( "Invalid index." ); 77 | } 78 | 79 | public function getPixelShader( index: int ): PixelShader 80 | { 81 | if ( 0 <= index && index < _passes.length ) 82 | { 83 | return _passes[ index ].pixelShader; 84 | } 85 | throw new IllegalArgumentError( "Invalid index." ); 86 | } 87 | 88 | public function getAlphaState( index: int ): AlphaState 89 | { 90 | if ( 0 <= index && index < _passes.length ) 91 | { 92 | return _passes[ index ].alphaState; 93 | } 94 | throw new IllegalArgumentError( "Invalid index." ); 95 | } 96 | 97 | public function getCullState( index: int ): CullState 98 | { 99 | if ( 0 <= index && index < _passes.length ) 100 | { 101 | return _passes[ index ].cullState; 102 | } 103 | throw new IllegalArgumentError( "Invalid index." ); 104 | } 105 | 106 | public function getDepthState( index: int ): DepthState 107 | { 108 | if ( 0 <= index && index < _passes.length ) 109 | { 110 | return _passes[ index ].depthState; 111 | } 112 | throw new IllegalArgumentError( "Invalid index." ); 113 | } 114 | 115 | public function getOffsetState( index: int ): OffsetState 116 | { 117 | if ( 0 <= index && index < _passes.length ) 118 | { 119 | return _passes[ index ].offsetState; 120 | } 121 | throw new IllegalArgumentError( "Invalid index." ); 122 | } 123 | 124 | public function getStencilState( index: int ): StencilState 125 | { 126 | if ( 0 <= index && index < _passes.length ) 127 | { 128 | return _passes[ index ].stencilState; 129 | } 130 | throw new IllegalArgumentError( "Invalid index." ); 131 | } 132 | 133 | public function getWireState( index: int ): WireState 134 | { 135 | if ( 0 <= index && index < _passes.length ) 136 | { 137 | return _passes[ index ].wireState; 138 | } 139 | throw new IllegalArgumentError( "Invalid index." ); 140 | } 141 | 142 | } 143 | 144 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/CompareMode.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class CompareMode 18 | { 19 | 20 | public static const NEVER: CompareMode = new CompareMode( "never", 0 ); 21 | public static const LESS: CompareMode = new CompareMode( "less", 1 ); 22 | public static const EQUAL: CompareMode = new CompareMode( "equal", 2 ); 23 | public static const LEQUAL: CompareMode = new CompareMode( "lequal", 3 ); 24 | public static const GREATER: CompareMode = new CompareMode( "greater", 4 ); 25 | public static const NOTEQUAL: CompareMode = new CompareMode( "notequal", 5 ); 26 | public static const GEQUAL: CompareMode = new CompareMode( "gequal", 6 ); 27 | public static const ALWAYS: CompareMode = new CompareMode( "always", 7 ); 28 | 29 | public static const QUANTITY: int = 8; 30 | 31 | public static function toVector(): Vector. 32 | { 33 | return Vector. 34 | ([ 35 | NEVER, 36 | LESS, 37 | EQUAL, 38 | LEQUAL, 39 | GREATER, 40 | NOTEQUAL, 41 | GEQUAL, 42 | ALWAYS 43 | ]); 44 | } 45 | 46 | protected var _type: String; 47 | protected var _index: int; 48 | public function CompareMode( type: String, index: int ) 49 | { 50 | _type = type; 51 | _index = index; 52 | } 53 | 54 | public function get type():String 55 | { 56 | return _type; 57 | } 58 | 59 | public function get index():int 60 | { 61 | return _index; 62 | } 63 | 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/DstBlendMode.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class DstBlendMode 18 | { 19 | 20 | public static const ZERO: DstBlendMode = new DstBlendMode( "zero", 0 ); 21 | public static const ONE: DstBlendMode = new DstBlendMode( "one", 1 ); 22 | public static const SRC_COLOR: DstBlendMode = new DstBlendMode( "srcColor", 2 ); 23 | public static const ONE_MINUS_SRC_COLOR: DstBlendMode = new DstBlendMode( "oneMinusSrcColor", 3 ); 24 | public static const SRC_ALPHA: DstBlendMode = new DstBlendMode( "srcAlpha", 4 ); 25 | public static const ONE_MINUS_SRC_ALPHA: DstBlendMode = new DstBlendMode( "oneMinusSrcAlpha", 5 ); 26 | public static const DST_ALPHA: DstBlendMode = new DstBlendMode( "dstAlpha", 6 ); 27 | public static const ONE_MINUS_DST_ALPHA: DstBlendMode = new DstBlendMode( "oneMinusDstAlpha", 7 ); 28 | public static const CONSTANT_COLOR: DstBlendMode = new DstBlendMode( "constantColor", 8 ); 29 | public static const ONE_MINUS_CONSTANT_COLOR: DstBlendMode = new DstBlendMode( "oneMinusConstantColor", 9 ); 30 | public static const CONSTANT_ALPHA: DstBlendMode = new DstBlendMode( "constantAlpha", 10 ); 31 | public static const ONE_MINUS_CONSTANT_ALPHA: DstBlendMode = new DstBlendMode( "oneMinusConstantAlpha", 11 ); 32 | 33 | public static const QUANTITY: int = 12; 34 | 35 | protected var _type: String; 36 | protected var _index: int; 37 | public function DstBlendMode( type: String, index: int ) 38 | { 39 | _type = type; 40 | _index = index; 41 | } 42 | 43 | public static function toVector(): Vector. 44 | { 45 | return Vector. 46 | ([ 47 | ZERO, 48 | ONE, 49 | SRC_COLOR, 50 | ONE_MINUS_SRC_COLOR, 51 | SRC_ALPHA, 52 | ONE_MINUS_SRC_ALPHA, 53 | DST_ALPHA, 54 | ONE_MINUS_DST_ALPHA, 55 | CONSTANT_COLOR, 56 | ONE_MINUS_CONSTANT_COLOR, 57 | CONSTANT_ALPHA, 58 | ONE_MINUS_CONSTANT_ALPHA 59 | ]); 60 | } 61 | 62 | public function get type():String 63 | { 64 | return _type; 65 | } 66 | 67 | public function get index():int 68 | { 69 | return _index; 70 | } 71 | 72 | } 73 | 74 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/OperationType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class OperationType 18 | { 19 | 20 | public static const KEEP: OperationType = new OperationType( "keep", 0 ); 21 | public static const ZERO: OperationType = new OperationType( "zero", 1 ); 22 | public static const REPLACE: OperationType = new OperationType( "replace", 2 ); 23 | public static const INCREMENT: OperationType = new OperationType( "increment", 3 ); 24 | public static const DECREMENT: OperationType = new OperationType( "decrement", 4 ); 25 | public static const INVERT: OperationType = new OperationType( "invert", 5 ); 26 | 27 | public static const QUANTITY: int = 6; 28 | 29 | protected var _type: String; 30 | protected var _index: int; 31 | 32 | public function OperationType( type: String, index: int ) 33 | { 34 | _type = type; 35 | _index = index; 36 | } 37 | 38 | public static function toVector(): Vector. 39 | { 40 | return Vector. 41 | ([ 42 | KEEP, 43 | ZERO, 44 | REPLACE, 45 | INCREMENT, 46 | DECREMENT, 47 | INVERT 48 | ]); 49 | } 50 | 51 | public function get type():String 52 | { 53 | return _type; 54 | } 55 | 56 | public function get index():int 57 | { 58 | return _index; 59 | } 60 | 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/PixelShaderProfileType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class PixelShaderProfileType 18 | { 19 | 20 | public static const NONE: PixelShaderProfileType = new PixelShaderProfileType( "none", 0 ); 21 | public static const AGAL_1_0: PixelShaderProfileType = new PixelShaderProfileType( "agal_1_0", 1 ); 22 | public static const AGAL_2_0: PixelShaderProfileType = new PixelShaderProfileType( "agal_2_0", 2 ); 23 | 24 | protected var _type: String; 25 | protected var _index: int; 26 | public function PixelShaderProfileType( type: String, index: int ) 27 | { 28 | _type = type; 29 | _index = index; 30 | } 31 | 32 | public static function toVector(): Vector. 33 | { 34 | return Vector. 35 | ([ 36 | NONE, 37 | AGAL_1_0, 38 | AGAL_2_0 39 | ]); 40 | } 41 | 42 | public function get type():String 43 | { 44 | return _type; 45 | } 46 | 47 | public function get index():int 48 | { 49 | return _index; 50 | } 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/SamplerCoordinateType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class SamplerCoordinateType 18 | { 19 | 20 | public static const NONE: SamplerCoordinateType = new SamplerCoordinateType( "none", 0 ); 21 | public static const CLAMP: SamplerCoordinateType = new SamplerCoordinateType( "clamp", 1 ); 22 | public static const REPEAT: SamplerCoordinateType = new SamplerCoordinateType( "repeat", 2 ); 23 | public static const MIRRORED_REPEAT: SamplerCoordinateType = new SamplerCoordinateType( "mirroredRepeat", 3 ); 24 | public static const CLAMP_BORDER: SamplerCoordinateType = new SamplerCoordinateType( "clampBorder", 4 ); 25 | public static const CLAMP_EDGE: SamplerCoordinateType = new SamplerCoordinateType( "clampEdge", 5 ); 26 | 27 | public static const QUANTITY: int = 6; 28 | 29 | protected var _type: String; 30 | protected var _index: int; 31 | public function SamplerCoordinateType( type: String, index: int ) 32 | { 33 | _type = type; 34 | _index = index; 35 | } 36 | 37 | public static function toVector(): Vector. 38 | { 39 | return Vector. 40 | ([ 41 | NONE, 42 | CLAMP, 43 | REPEAT, 44 | MIRRORED_REPEAT, 45 | CLAMP_BORDER, 46 | CLAMP_EDGE 47 | ]); 48 | } 49 | 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/SamplerFilterType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class SamplerFilterType 18 | { 19 | 20 | public static const NONE: SamplerFilterType = new SamplerFilterType( "none", 0 ); 21 | public static const NEAREST: SamplerFilterType = new SamplerFilterType( "nearest", 1 ); 22 | public static const LINEAR: SamplerFilterType = new SamplerFilterType( "linear", 2 ); 23 | public static const NEAREST_NEAREST: SamplerFilterType = new SamplerFilterType( "nearestNearest", 3 ); 24 | public static const NEAREST_LINEAR: SamplerFilterType = new SamplerFilterType( "nearestLinear", 4 ); 25 | public static const LINEAR_NEAREST: SamplerFilterType = new SamplerFilterType( "linearNearest", 5 ); 26 | public static const LINEAR_LINEAR: SamplerFilterType = new SamplerFilterType( "linearLinear", 6 ); 27 | 28 | public static const QUANTITY: int = 7; 29 | 30 | protected var _type: String; 31 | protected var _index: int; 32 | public function SamplerFilterType( type: String, index: int ) 33 | { 34 | _type = type; 35 | _index = index; 36 | } 37 | 38 | public function get type():String 39 | { 40 | return _type; 41 | } 42 | 43 | public function get index():int 44 | { 45 | return _index; 46 | } 47 | 48 | public static function toVector(): Vector. 49 | { 50 | return Vector. 51 | ([ 52 | NONE, 53 | NEAREST, 54 | LINEAR, 55 | NEAREST_NEAREST, 56 | NEAREST_LINEAR, 57 | LINEAR_NEAREST, 58 | LINEAR_LINEAR 59 | ]); 60 | } 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/SamplerType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class SamplerType 18 | { 19 | 20 | public static const NONE: SamplerType = new SamplerType( "none", 0 ); 21 | //public static const TYPE_1D: SamplerType = new SamplerType( "1d", 1 ); 22 | public static const TYPE_2D: SamplerType = new SamplerType( "2d", 2 ); 23 | public static const TYPE_3D: SamplerType = new SamplerType( "3d", 3 ); 24 | public static const CUBE: SamplerType = new SamplerType( "cube", 4 ); 25 | public static const RECTANGLE: SamplerType = new SamplerType( "rectangle", 5 ); 26 | 27 | public static const QUANTITY: int = 5; 28 | 29 | protected var _type: String; 30 | protected var _index: int; 31 | public function SamplerType( type: String, index: int ) 32 | { 33 | _type = type; 34 | _index = index; 35 | } 36 | 37 | public static function toVector():Vector. 38 | { 39 | return Vector. 40 | ([ 41 | NONE, 42 | //TYPE_1D, 43 | TYPE_2D, 44 | TYPE_3D, 45 | CUBE, 46 | RECTANGLE 47 | ]); 48 | } 49 | 50 | [Inline] 51 | public final function get type():String 52 | { 53 | return _type; 54 | } 55 | 56 | [Inline] 57 | public final function get index():int 58 | { 59 | return _index; 60 | } 61 | 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/SrcBlendMode.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class SrcBlendMode 18 | { 19 | 20 | public static const ZERO: SrcBlendMode = new SrcBlendMode( "zero", 0 ); 21 | public static const ONE: SrcBlendMode = new SrcBlendMode( "one", 1 ); 22 | public static const DST_COLOR: SrcBlendMode = new SrcBlendMode( "dstColor", 2 ); 23 | public static const ONE_MINUS_DST_COLOR: SrcBlendMode = new SrcBlendMode( "oneMinusDstColor", 3 ); 24 | public static const SRC_ALPHA: SrcBlendMode = new SrcBlendMode( "srcAlpha", 4 ); 25 | public static const ONE_MINUS_SRC_ALPHA: SrcBlendMode = new SrcBlendMode( "oneMinusSrcAlpha", 5 ); 26 | public static const DST_ALPHA: SrcBlendMode = new SrcBlendMode( "dstAlpha", 6 ); 27 | public static const ONE_MINUS_DST_ALPHA: SrcBlendMode = new SrcBlendMode( "oneMinusDstAlpha", 7 ); 28 | public static const SRC_ALPHA_SATURATE: SrcBlendMode = new SrcBlendMode( "srcAlphaSaturate", 8 ); 29 | public static const CONSTANT_COLOR: SrcBlendMode = new SrcBlendMode( "constantColor", 9 ); 30 | public static const ONE_MINUS_CONSTANT_COLOR: SrcBlendMode = new SrcBlendMode( "oneMinusConstantColor", 10 ); 31 | //public static const CONSTANT_ALPHA: SrcBlendMode = new SrcBlendMode( "constantAlpha", 11 ); 32 | //public static const ONE_MINUS_CONSTANT_ALPHA: SrcBlendMode = new SrcBlendMode( "oneMinusConstantAlpha", 12 ); 33 | 34 | public static const QUANTITY: int = 11; 35 | 36 | 37 | public static function toVector():Vector. 38 | { 39 | return Vector. 40 | ([ 41 | ZERO, 42 | ONE, 43 | DST_COLOR, 44 | ONE_MINUS_DST_COLOR, 45 | SRC_ALPHA, 46 | ONE_MINUS_SRC_ALPHA, 47 | DST_ALPHA, 48 | ONE_MINUS_DST_ALPHA, 49 | SRC_ALPHA_SATURATE, 50 | CONSTANT_COLOR, 51 | ONE_MINUS_CONSTANT_COLOR/*, 52 | CONSTANT_ALPHA, 53 | ONE_MINUS_CONSTANT_ALPHA*/ 54 | ]); 55 | } 56 | 57 | protected var _type: String; 58 | protected var _index: int; 59 | public function SrcBlendMode( type: String, index: int ) 60 | { 61 | _type = type; 62 | _index = index; 63 | } 64 | 65 | public function get type():String 66 | { 67 | return _type; 68 | } 69 | 70 | public function get index():int 71 | { 72 | return _index; 73 | } 74 | 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/VariableSemanticType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class VariableSemanticType 18 | { 19 | 20 | public static const NONE: VariableSemanticType = new VariableSemanticType( "none", 0 ); 21 | public static const POSITION: VariableSemanticType = new VariableSemanticType( "position", 1 ); 22 | public static const BLENDWEIGHT: VariableSemanticType = new VariableSemanticType( "blendWeight", 2 ); 23 | public static const NORMAL: VariableSemanticType = new VariableSemanticType( "normal", 3 ); 24 | public static const COLOR0: VariableSemanticType = new VariableSemanticType( "color0", 4 ); 25 | public static const COLOR1: VariableSemanticType = new VariableSemanticType( "color1", 5 ); 26 | public static const FOGCOORD: VariableSemanticType = new VariableSemanticType( "fogCoord", 6 ); 27 | public static const PSIZE: VariableSemanticType = new VariableSemanticType( "pSize", 7 ); 28 | public static const BLENDINDICES: VariableSemanticType = new VariableSemanticType( "blendIndices", 8 ); 29 | public static const TEXCOORD0: VariableSemanticType = new VariableSemanticType( "texCoord0", 9 ); 30 | public static const TEXCOORD1: VariableSemanticType = new VariableSemanticType( "texCoord1", 10 ); 31 | public static const TEXCOORD2: VariableSemanticType = new VariableSemanticType( "texCoord2", 11 ); 32 | public static const TEXCOORD3: VariableSemanticType = new VariableSemanticType( "texCoord3", 12 ); 33 | public static const TEXCOORD4: VariableSemanticType = new VariableSemanticType( "texCoord4", 13 ); 34 | public static const TEXCOORD5: VariableSemanticType = new VariableSemanticType( "texCoord5", 14 ); 35 | public static const TEXCOORD6: VariableSemanticType = new VariableSemanticType( "texCoord6", 15 ); 36 | public static const TEXCOORD7: VariableSemanticType = new VariableSemanticType( "texCoord7", 16 ); 37 | public static const FOG: VariableSemanticType = new VariableSemanticType( "fog", 17 ); 38 | public static const TANGENT: VariableSemanticType = new VariableSemanticType( "tangent", 18 ); 39 | public static const BINORMAL: VariableSemanticType = new VariableSemanticType( "binormal", 19 ); 40 | public static const COLOR2: VariableSemanticType = new VariableSemanticType( "color2", 20 ); 41 | public static const COLOR3: VariableSemanticType = new VariableSemanticType( "color3", 21 ); 42 | public static const DEPTH0: VariableSemanticType = new VariableSemanticType( "depth0", 22 ); 43 | 44 | protected var _type: String; 45 | protected var _index: int; 46 | public function VariableSemanticType( type: String, index: int ) 47 | { 48 | _type = type; 49 | _index = index; 50 | } 51 | 52 | public function get type():String 53 | { 54 | return _type; 55 | } 56 | 57 | public function get index():int 58 | { 59 | return _index; 60 | } 61 | 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/enum/VertexShaderProfileType.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.enum 12 | { 13 | /** 14 | * ... 15 | * @author Gary Paluk 16 | */ 17 | public class VertexShaderProfileType 18 | { 19 | 20 | public static const NONE: VertexShaderProfileType = new VertexShaderProfileType( "none", 0 ); 21 | public static const AGAL_1_0: VertexShaderProfileType = new VertexShaderProfileType( "agal_1_0", 1 ); 22 | public static const AGAL_2_0: VertexShaderProfileType = new VertexShaderProfileType( "agal_2_0", 2 ); 23 | 24 | public static function toVector(): Vector. 25 | { 26 | return Vector. 27 | ([ 28 | NONE, 29 | AGAL_1_0, 30 | AGAL_2_0 31 | ]); 32 | } 33 | 34 | protected var _type: String; 35 | protected var _index: int; 36 | public function VertexShaderProfileType( type: String, index: int ) 37 | { 38 | _type = type; 39 | _index = index; 40 | } 41 | 42 | public function get type():String 43 | { 44 | return _type; 45 | } 46 | 47 | public function get index():int 48 | { 49 | return _index; 50 | } 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/states/AlphaState.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.states 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.shaders.enum.CompareMode; 15 | import zest3d.shaders.enum.DstBlendMode; 16 | import zest3d.shaders.enum.SrcBlendMode; 17 | 18 | /** 19 | * ... 20 | * @author Gary Paluk 21 | */ 22 | public class AlphaState implements IDisposable 23 | { 24 | 25 | public var blendEnabled: Boolean; 26 | public var srcBlend: SrcBlendMode; 27 | public var dstBlend: DstBlendMode; 28 | public var compareEnabled: Boolean; 29 | public var compare: CompareMode; 30 | public var reference: Number; 31 | public var constantColor: Array; 32 | 33 | public function AlphaState() 34 | { 35 | blendEnabled = false; 36 | srcBlend = SrcBlendMode.SRC_ALPHA; 37 | dstBlend = DstBlendMode.ONE_MINUS_SRC_ALPHA; 38 | compareEnabled = false; 39 | compare = CompareMode.ALWAYS; 40 | reference = 0; 41 | constantColor = [0, 0, 0, 0]; 42 | } 43 | 44 | public function dispose(): void 45 | { 46 | srcBlend = null; 47 | dstBlend = null; 48 | compare = null; 49 | constantColor = null; 50 | } 51 | 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/states/CullState.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.states 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | 15 | /** 16 | * ... 17 | * @author Gary Paluk 18 | */ 19 | public class CullState implements IDisposable 20 | { 21 | 22 | public var enabled: Boolean; 23 | public var ccwOrder: Boolean; 24 | 25 | public function CullState() 26 | { 27 | enabled = true; 28 | ccwOrder = true; 29 | } 30 | 31 | public function dispose(): void 32 | { 33 | 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/states/DepthState.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.states 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.shaders.enum.CompareMode; 15 | /** 16 | * ... 17 | * @author Gary Paluk 18 | */ 19 | public class DepthState implements IDisposable 20 | { 21 | 22 | public var enabled: Boolean; 23 | public var writable: Boolean; 24 | public var compare: CompareMode; 25 | 26 | public function DepthState() 27 | { 28 | enabled = true; 29 | writable = true; 30 | compare = CompareMode.LEQUAL; 31 | } 32 | 33 | public function dispose(): void 34 | { 35 | compare = null; 36 | } 37 | 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/states/OffsetState.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.states 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | 15 | /** 16 | * ... 17 | * @author Gary Paluk 18 | */ 19 | public class OffsetState implements IDisposable 20 | { 21 | 22 | public var fillEnabled: Boolean; 23 | public var lineEnabled: Boolean; 24 | public var pointEnabled: Boolean; 25 | 26 | public var scale: Number; 27 | public var bias: Number; 28 | 29 | public function OffsetState() 30 | { 31 | fillEnabled = false; 32 | lineEnabled = false; 33 | pointEnabled = false; 34 | scale = 0; 35 | bias = 0; 36 | } 37 | 38 | public function dispose(): void 39 | { 40 | 41 | } 42 | 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/states/StencilState.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.states 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | import zest3d.shaders.enum.CompareMode; 15 | import zest3d.shaders.enum.OperationType; 16 | 17 | /** 18 | * ... 19 | * @author Gary Paluk 20 | */ 21 | public class StencilState implements IDisposable 22 | { 23 | 24 | public var enabled: Boolean; 25 | public var compare: CompareMode; 26 | public var reference: uint; 27 | public var mask: uint; 28 | public var writeMask: uint; 29 | 30 | public var onFail: OperationType; 31 | public var onZFail: OperationType; 32 | public var onZPass: OperationType; 33 | 34 | public function StencilState() 35 | { 36 | enabled = false; 37 | compare = CompareMode.NEVER; 38 | reference = 0; 39 | mask = 0xff; // 8-bit mask 40 | writeMask = 0xff; // 8-bit mask 41 | 42 | onFail = OperationType.KEEP; 43 | onZFail = OperationType.KEEP; 44 | onZPass = OperationType.KEEP; 45 | } 46 | 47 | public function dispose(): void 48 | { 49 | } 50 | 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /src/zest3d/shaders/states/WireState.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Plugin.IO - http://www.plugin.io 3 | * Copyright (c) 2013 4 | * 5 | * Geometric Tools, LLC 6 | * Copyright (c) 1998-2012 7 | * 8 | * Distributed under the Boost Software License, Version 1.0. 9 | * http://www.boost.org/LICENSE_1_0.txt 10 | */ 11 | package zest3d.shaders.states 12 | { 13 | import io.plugin.core.interfaces.IDisposable; 14 | 15 | /** 16 | * ... 17 | * @author Gary Paluk 18 | */ 19 | public class WireState implements IDisposable 20 | { 21 | 22 | public var enabled: Boolean; 23 | 24 | public function WireState() 25 | { 26 | enabled = false; 27 | } 28 | 29 | public function dispose(): void 30 | { 31 | 32 | } 33 | 34 | } 35 | 36 | } --------------------------------------------------------------------------------