protected override MovableObject _createInstance(string name, NamedParameterList param) { // must have mesh parameter string caption = null; string fontName = null; if (param != null) { if (param.ContainsKey("caption")) { caption = (string)param["caption"]; } if (param.ContainsKey("fontName")) { fontName = (string)param["fontName"]; } } if (caption == null) { throw new AxiomException("'caption' parameter required when constructing MovableText."); } if (fontName == null) { throw new AxiomException("'fontName' parameter required when constructing MovableText."); } var text = new MovableText(name, caption, fontName); text.MovableType = Type; return(text); }
protected void InitNativeCreatedWindow(NamedParameterList miscParams) { LogManager.Instance.Write("\tInitNativeCreateWindow called"); if (miscParams != null) { if (miscParams.ContainsKey("externalWindowInfo")) { this.windowInfo = (IWindowInfo)miscParams["externalWindowInfo"]; } if (miscParams.ContainsKey("externalGLContext")) { var value = miscParams["externalGLContext"]; if (value is IGraphicsContext) { this.context = new AndroidContext(this.glSupport, (value as IGraphicsContext), this.windowInfo); } else { var ex = new InvalidCastException(); throw new AxiomException("externalGLContext must be of type IGraphicsContext", ex); } } } }
protected override MovableObject _createInstance(string name, NamedParameterList param) { var maxElements = 20; var numberOfChains = 1; var useTextureCoords = true; var useVertexColors = true; var isDynamic = true; // optional parameters if (param != null) { if (param.ContainsKey("maxElements")) { maxElements = Convert.ToInt32(param["maxElements"]); } if (param.ContainsKey("numberOfChains")) { numberOfChains = Convert.ToInt32(param["numberOfChains"]); } if (param.ContainsKey("useTextureCoords")) { useTextureCoords = Convert.ToBoolean(param["useTextureCoords"]); } if (param.ContainsKey("useVertexColours")) { useVertexColors = Convert.ToBoolean(param["useVertexColours"]); } else if (param.ContainsKey("useVertexColors")) { useVertexColors = Convert.ToBoolean(param["useVertexColors"]); } if (param.ContainsKey("isDynamic")) { isDynamic = Convert.ToBoolean(param["isDynamic"]); } } return(new RibbonTrail(name, maxElements, numberOfChains, useTextureCoords, useVertexColors, isDynamic)); }
protected override MovableObject _createInstance( string name, NamedParameterList param ) { // must have mesh parameter Mesh pMesh = null; if ( param != null ) { if ( param.ContainsKey( "mesh" ) ) { if ( param[ "mesh" ] is Mesh ) { pMesh = (Mesh)param[ "mesh" ]; } else { pMesh = MeshManager.Instance.Load( param[ "mesh" ].ToString(), ResourceGroupManager.AutoDetectResourceGroupName ); } } } if ( pMesh == null ) { throw new AxiomException( "'mesh' parameter required when constructing an Entity." ); } var ent = new Entity( name, pMesh ); ent.MovableType = Type; return ent; }
protected override MovableObject _createInstance( string name, NamedParameterList param ) { // may have parameters bool externalData = false; int poolSize = 0; if ( param != null ) { if ( param.ContainsKey( "poolSize" ) ) { poolSize = Convert.ToInt32( param[ "poolSize" ] ); } if ( param.ContainsKey( "externalData" ) ) { externalData = Convert.ToBoolean( param[ "externalData" ] ); } } BillboardSet bSet; if ( poolSize > 0 ) { bSet = new BillboardSet( name, poolSize, externalData ); } else { bSet = new BillboardSet( name, 0 ); } bSet.MovableType = TypeName; return bSet; }
protected override MovableObject _createInstance( string name, NamedParameterList param ) { Light light = new Light( name ); if ( param != null ) { // Setting the light type first before any property specific to a certain light type if ( param.ContainsKey( "type" ) ) { switch ( param[ "type" ].ToString() ) { case "point": light.Type = LightType.Point; break; case "directional": light.Type = LightType.Directional; break; case "spot": case "spotlight": light.Type = LightType.Spotlight; break; default: throw new AxiomException( "Invalid light type '" + param[ "type" ] + "'." ); } } // Common properties if ( param.ContainsKey( "position" ) ) { light.Position = Vector3.Parse( param[ "position" ].ToString() ); } if ( param.ContainsKey( "direction" ) ) { light.Direction = Vector3.Parse( param[ "direction" ].ToString() ); } if ( param.ContainsKey( "diffuseColour" ) ) { light.Diffuse = ColorEx.Parse_0_255_String( param[ "diffuseColour" ].ToString() ); } if ( param.ContainsKey( "specularColour" ) ) { light.Specular = ColorEx.Parse_0_255_String( param[ "specularColour" ].ToString() ); } if ( param.ContainsKey( "attenuation" ) ) { Vector4 attenuation = Vector4.Parse( param[ "attenuation" ].ToString() ); light.SetAttenuation( attenuation.x, attenuation.y, attenuation.z, attenuation.w ); } if ( param.ContainsKey( "castShadows" ) ) { light.CastShadows = Convert.ToBoolean( param[ "castShadows" ].ToString() ); } if ( param.ContainsKey( "visible" ) ) { light.CastShadows = Convert.ToBoolean( param[ "visible" ].ToString() ); } // TODO: Add PowerScale Property to Light if ( param.ContainsKey( "powerScale" ) ) { light.PowerScale = (float)Convert.ToDouble( param[ "powerScale" ].ToString() ); } // TODO: Add ShadowFarDistance to Light if ( param.ContainsKey( "shadowFarDistance" ) ) { light.ShadowFarDistance = (float)Convert.ToDouble( param[ "shadowFarDistance" ].ToString() ); } // Spotlight properties if ( param.ContainsKey( "spotlightInner" ) ) { light.SpotlightInnerAngle = (float)Convert.ToDouble( param[ "spotlightInner" ].ToString() ); } if ( param.ContainsKey( "spotlightOuter" ) ) { light.SpotlightOuterAngle = (float)Convert.ToDouble( param[ "spotlightOuter" ].ToString() ); } if ( param.ContainsKey( "spotlightFalloff" ) ) { light.SpotlightFalloff = (float)Convert.ToDouble( param[ "spotlightFalloff" ].ToString() ); } } return light; }
protected override MovableObject _createInstance( string name, NamedParameterList param ) { int maxElements = 20; int numberOfChains = 1; bool useTextureCoords = true; bool useVertexColors = true; bool isDynamic = true; // optional parameters if ( param != null ) { if ( param.ContainsKey( "maxElements" ) ) { maxElements = Convert.ToInt32( param[ "maxElements" ] ); } if ( param.ContainsKey( "numberOfChains" ) ) { numberOfChains = Convert.ToInt32( param[ "numberOfChains" ] ); } if ( param.ContainsKey( "useTextureCoords" ) ) { useTextureCoords = Convert.ToBoolean( param[ "useTextureCoords" ] ); } if ( param.ContainsKey( "useVertexColours" ) ) { useVertexColors = Convert.ToBoolean( param[ "useVertexColours" ] ); } else if ( param.ContainsKey( "useVertexColors" ) ) { useVertexColors = Convert.ToBoolean( param[ "useVertexColors" ] ); } if ( param.ContainsKey( "isDynamic" ) ) { isDynamic = Convert.ToBoolean( param[ "isDynamic" ] ); } } return new BillboardChain( name, maxElements, numberOfChains, useTextureCoords, useVertexColors, isDynamic ); }
/// <summary> /// Initializes a RenderWindow Instance /// </summary> /// <param name="name"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="fullScreen"></param> /// <param name="miscParams"></param> public override void Create(string name, int width, int height, bool fullScreen, NamedParameterList miscParams) { var parentHWnd = IntPtr.Zero; var externalHWnd = IntPtr.Zero; var title = name; var colourDepth = 32; var left = -1; // Defaults to screen center var top = -1; // Defaults to screen center var depthBuffer = true; var border = ""; var outerSize = false; _useNVPerfHUD = false; _fsaaQuality = 0; _vSync = false; if (miscParams != null) { // left (x) if (miscParams.ContainsKey("left")) { left = Int32.Parse(miscParams["left"].ToString()); } // top (y) if (miscParams.ContainsKey("top")) { top = Int32.Parse(miscParams["top"].ToString()); } // Window title if (miscParams.ContainsKey("title")) { title = (string)miscParams["title"]; } if (miscParams.ContainsKey("xnaGraphicsDevice")) { var graphics = miscParams["xnaGraphicsDevice"] as GraphicsDevice; this.Driver.XnaDevice = graphics; } #if !(XBOX || XBOX360) // parentWindowHandle -> parentHWnd if (miscParams.ContainsKey("parentWindowHandle")) { var handle = miscParams["parentWindowHandle"]; if (handle.GetType() == typeof(IntPtr)) { parentHWnd = (IntPtr)handle; } else if (handle.GetType() == typeof(Int32)) { parentHWnd = new IntPtr((int)handle); } } // externalWindowHandle -> externalHWnd if (miscParams.ContainsKey("externalWindowHandle")) { var handle = miscParams["externalWindowHandle"]; if (handle.GetType() == typeof(IntPtr)) { externalHWnd = (IntPtr)handle; } else if (handle.GetType() == typeof(Int32)) { externalHWnd = new IntPtr((int)handle); } } #endif // vsync [parseBool] if (miscParams.ContainsKey("vsync")) { _vSync = bool.Parse(miscParams["vsync"].ToString()); } // displayFrequency if (miscParams.ContainsKey("displayFrequency")) { _displayFrequency = Int32.Parse(miscParams["displayFrequency"].ToString()); } // colourDepth if (miscParams.ContainsKey("colorDepth")) { colourDepth = Int32.Parse(miscParams["colorDepth"].ToString()); } // depthBuffer [parseBool] if (miscParams.ContainsKey("depthBuffer")) { depthBuffer = bool.Parse(miscParams["depthBuffer"].ToString()); } //FSAA type should hold a bool value, because anti-aliasing is either enabled, or it isn't. //// FSAA type //if ( miscParams.ContainsKey( "FSAA" ) ) //{ // //_fsaaType = (MultiSampleType)miscParams[ "FSAA" ]; //} // FSAA quality if (miscParams.ContainsKey("FSAAQuality")) { _fsaaQuality = Int32.Parse(miscParams["FSAAQuality"].ToString()); } // window border style if (miscParams.ContainsKey("border")) { border = ((string)miscParams["border"]).ToLower(); } // set outer dimensions? if (miscParams.ContainsKey("outerDimensions")) { outerSize = bool.Parse(miscParams["outerDimensions"].ToString()); } // NV perf HUD? if (miscParams.ContainsKey("useNVPerfHUD")) { _useNVPerfHUD = bool.Parse(miscParams["useNVPerfHUD"].ToString()); } } #if !(XBOX || XBOX360 || SILVERLIGHT || WINDOWS_PHONE) if (_windowHandle != IntPtr.Zero) { Dispose(); } if (externalHWnd == IntPtr.Zero) { this.width = width; this.height = height; this.top = top; this.left = left; _isExternal = false; var newWin = new DefaultForm(); newWin.Text = title; /* If we're in fullscreen, we can use the device's back and stencil buffers. * If we're in windowed mode, we'll want our own. * get references to the render target and depth stencil surface */ if (!fullScreen) { newWin.StartPosition = FormStartPosition.CenterScreen; if (parentHWnd != IntPtr.Zero) { newWin.Parent = Control.FromHandle(parentHWnd); } else { if (border == "none") { newWin.FormBorderStyle = FormBorderStyle.None; } else if (border == "fixed") { newWin.FormBorderStyle = FormBorderStyle.FixedSingle; newWin.MaximizeBox = false; } } if (!outerSize) { newWin.ClientSize = new Size(Width, Height); } else { newWin.Width = Width; newWin.Height = Height; } if (top < 0) { top = (Screen.PrimaryScreen.Bounds.Height - Height) / 2; } if (left < 0) { left = (Screen.PrimaryScreen.Bounds.Width - Width) / 2; } } else { //dwStyle |= WS_POPUP; top = left = 0; } // Create our main window newWin.Top = top; newWin.Left = left; newWin.RenderWindow = this; _windowHandle = newWin.Handle; WindowEventMonitor.Instance.RegisterWindow(this); } else { _windowHandle = externalHWnd; _isExternal = true; } #endif // set the params of the window this.name = name; colorDepth = colourDepth; this.width = width; this.height = height; IsFullScreen = fullScreen; isDepthBuffered = depthBuffer; this.top = top; this.left = left; if (Driver.XnaDevice == null) { CreateXnaResources(); } #if !(XBOX || XBOX360 || SILVERLIGHT || WINDOWS_PHONE) (Control.FromHandle(_windowHandle)).Show(); #endif IsActive = true; _isClosed = false; LogManager.Instance.Write("[XNA] : Created D3D9 Rendering Window '{0}' : {1}x{2}, {3}bpp", Name, Width, Height, ColorDepth); }
protected override MovableObject _createInstance( string name, NamedParameterList param ) { // must have mesh parameter string caption = null; string fontName = null; if ( param != null ) { if ( param.ContainsKey( "caption" ) ) { caption = (string)param[ "caption" ]; } if ( param.ContainsKey( "fontName" ) ) { fontName = (string)param[ "fontName" ]; } } if ( caption == null ) { throw new AxiomException( "'caption' parameter required when constructing MovableText." ); } if ( fontName == null ) { throw new AxiomException( "'fontName' parameter required when constructing MovableText." ); } MovableText text = new MovableText( name, caption, fontName ); text.MovableType = this.Type; return text; }
protected void InitNativeCreatedWindow( NamedParameterList miscParams ) { LogManager.Instance.Write( "\tInitNativeCreateWindow called" ); if ( miscParams != null ) { if ( miscParams.ContainsKey( "externalWindowInfo" ) ) { this.windowInfo = (IWindowInfo) miscParams[ "externalWindowInfo" ]; } if ( miscParams.ContainsKey( "externalGLContext" ) ) { var value = miscParams[ "externalGLContext" ]; if ( value is IGraphicsContext ) { this.context = new AndroidContext( this.glSupport, ( value as IGraphicsContext ), this.windowInfo ); } else { var ex = new InvalidCastException(); throw new AxiomException( "externalGLContext must be of type IGraphicsContext", ex ); } } } }
/// <summary> /// Initializes a RenderWindow Instance /// </summary> /// <param name="name"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="fullScreen"></param> /// <param name="miscParams"></param> public override void Create( string name, int width, int height, bool fullScreen, NamedParameterList miscParams ) { var parentHWnd = IntPtr.Zero; var externalHWnd = IntPtr.Zero; var title = name; var colourDepth = 32; var left = -1; // Defaults to screen center var top = -1; // Defaults to screen center var depthBuffer = true; var border = ""; var outerSize = false; _useNVPerfHUD = false; _fsaaQuality = 0; _vSync = false; if ( miscParams != null ) { // left (x) if ( miscParams.ContainsKey( "left" ) ) { left = Int32.Parse( miscParams[ "left" ].ToString() ); } // top (y) if ( miscParams.ContainsKey( "top" ) ) { top = Int32.Parse( miscParams[ "top" ].ToString() ); } // Window title if ( miscParams.ContainsKey( "title" ) ) { title = (string)miscParams[ "title" ]; } if ( miscParams.ContainsKey( "xnaGraphicsDevice" ) ) { var graphics = miscParams[ "xnaGraphicsDevice" ] as GraphicsDevice; this.Driver.XnaDevice = graphics; } #if !(XBOX || XBOX360) // parentWindowHandle -> parentHWnd if ( miscParams.ContainsKey( "parentWindowHandle" ) ) { var handle = miscParams[ "parentWindowHandle" ]; if ( handle.GetType() == typeof( IntPtr ) ) { parentHWnd = (IntPtr)handle; } else if ( handle.GetType() == typeof( Int32 ) ) { parentHWnd = new IntPtr( (int)handle ); } } // externalWindowHandle -> externalHWnd if ( miscParams.ContainsKey( "externalWindowHandle" ) ) { var handle = miscParams[ "externalWindowHandle" ]; if ( handle.GetType() == typeof( IntPtr ) ) { externalHWnd = (IntPtr)handle; } else if ( handle.GetType() == typeof( Int32 ) ) { externalHWnd = new IntPtr( (int)handle ); } } #endif // vsync [parseBool] if ( miscParams.ContainsKey( "vsync" ) ) { _vSync = bool.Parse( miscParams[ "vsync" ].ToString() ); } // displayFrequency if ( miscParams.ContainsKey( "displayFrequency" ) ) { _displayFrequency = Int32.Parse( miscParams[ "displayFrequency" ].ToString() ); } // colourDepth if ( miscParams.ContainsKey( "colorDepth" ) ) { colourDepth = Int32.Parse( miscParams[ "colorDepth" ].ToString() ); } // depthBuffer [parseBool] if ( miscParams.ContainsKey( "depthBuffer" ) ) { depthBuffer = bool.Parse( miscParams[ "depthBuffer" ].ToString() ); } //FSAA type should hold a bool value, because anti-aliasing is either enabled, or it isn't. //// FSAA type //if ( miscParams.ContainsKey( "FSAA" ) ) //{ // //_fsaaType = (MultiSampleType)miscParams[ "FSAA" ]; //} // FSAA quality if ( miscParams.ContainsKey( "FSAAQuality" ) ) { _fsaaQuality = Int32.Parse( miscParams[ "FSAAQuality" ].ToString() ); } // window border style if ( miscParams.ContainsKey( "border" ) ) { border = ( (string)miscParams[ "border" ] ).ToLower(); } // set outer dimensions? if ( miscParams.ContainsKey( "outerDimensions" ) ) { outerSize = bool.Parse( miscParams[ "outerDimensions" ].ToString() ); } // NV perf HUD? if ( miscParams.ContainsKey( "useNVPerfHUD" ) ) { _useNVPerfHUD = bool.Parse( miscParams[ "useNVPerfHUD" ].ToString() ); } } #if !(XBOX || XBOX360 || SILVERLIGHT || WINDOWS_PHONE ) if ( _windowHandle != IntPtr.Zero ) { Dispose(); } if ( externalHWnd == IntPtr.Zero ) { this.width = width; this.height = height; this.top = top; this.left = left; _isExternal = false; var newWin = new DefaultForm(); newWin.Text = title; /* If we're in fullscreen, we can use the device's back and stencil buffers. * If we're in windowed mode, we'll want our own. * get references to the render target and depth stencil surface */ if ( !fullScreen ) { newWin.StartPosition = FormStartPosition.CenterScreen; if ( parentHWnd != IntPtr.Zero ) { newWin.Parent = Control.FromHandle( parentHWnd ); } else { if ( border == "none" ) { newWin.FormBorderStyle = FormBorderStyle.None; } else if ( border == "fixed" ) { newWin.FormBorderStyle = FormBorderStyle.FixedSingle; newWin.MaximizeBox = false; } } if ( !outerSize ) { newWin.ClientSize = new Size( Width, Height ); } else { newWin.Width = Width; newWin.Height = Height; } if ( top < 0 ) { top = ( Screen.PrimaryScreen.Bounds.Height - Height ) / 2; } if ( left < 0 ) { left = ( Screen.PrimaryScreen.Bounds.Width - Width ) / 2; } } else { //dwStyle |= WS_POPUP; top = left = 0; } // Create our main window newWin.Top = top; newWin.Left = left; newWin.RenderWindow = this; _windowHandle = newWin.Handle; WindowEventMonitor.Instance.RegisterWindow( this ); } else { _windowHandle = externalHWnd; _isExternal = true; } #endif // set the params of the window this.name = name; colorDepth = colourDepth; this.width = width; this.height = height; IsFullScreen = fullScreen; isDepthBuffered = depthBuffer; this.top = top; this.left = left; if ( Driver.XnaDevice == null ) CreateXnaResources(); #if !(XBOX || XBOX360 || SILVERLIGHT || WINDOWS_PHONE ) ( Control.FromHandle( _windowHandle ) ).Show(); #endif IsActive = true; _isClosed = false; LogManager.Instance.Write( "[XNA] : Created D3D9 Rendering Window '{0}' : {1}x{2}, {3}bpp", Name, Width, Height, ColorDepth ); }