GetTechnique() public méthode

Gets the technique at the specified index.
public GetTechnique ( int index ) : Technique
index int Index of the technique to return.
Résultat Technique
Exemple #1
0
        /// <summary>
        /// Helper function to set the texture coordinates.  Instead of taking a movie
        /// object, this takes a specific texture name, video size, texture size, and
        /// material.  Sets a texture matrix to adjust the existing coordinates.
        /// </summary>
        /// <param name="textureName">
        /// The name of the texture to adjust.
        /// </param>
        /// <param name="videoSize">
        /// The size of the video in pixels.
        /// </param>
        /// <param name="textureSize">
        /// The size of the expected texture in pixels.
        /// </param>
        /// <param name="material">
        /// The name of the material to search for textures.
        /// </param>
        /// <returns>
        /// True if any texture coordinates were adjusted, false if not.
        /// </returns>
        public static bool SetTextureCoordinates(string textureName, Size videoSize, Size textureSize, string material)
        {
            bool ans = false;

            Axiom.Graphics.Material m = MaterialManager.Instance.GetByName(material);
            if (m != null)
            {
                for (int i = 0; i < m.NumTechniques; i++)
                {
                    for (int j = 0; j < m.GetTechnique(i).NumPasses; j++)
                    {
                        Pass p = m.GetTechnique(i).GetPass(j);
                        for (int k = 0; k < p.NumTextureUnitStages; k++)
                        {
                            if (p.GetTextureUnitState(k).TextureName == textureName)
                            {
                                TextureUnitState tu     = p.GetTextureUnitState(k);
                                float            uRatio = ((float)videoSize.Width) / ((float)textureSize.Width);
                                float            vRatio = ((float)videoSize.Height) / ((float)textureSize.Height);
                                tu.SetTextureScale(1.0f / uRatio, 1.0f / vRatio);
                                tu.SetTextureScroll(-0.5f * (1.0f - uRatio), -0.5f * (1.0f - vRatio));
                                ans = true;
                            }
                        }
                    }
                }
            }
            return(ans);
        }
        public void CameraDataUpdate(InteropBitmap cameraInterop)
        {
            // Stores the cam input as bitmap source
            var imageSource = cameraInterop as BitmapSource;

            // Creates an jpeg encoder
            BitmapEncoder enc = new JpegBitmapEncoder();

            // Create bitmap frame from the image source
            enc.Frames.Add(BitmapFrame.Create(imageSource));

            // Saves the frame to a memory stream
            var ms = new MemoryStream();

            enc.Save(ms);

            // Create a bitmap from the memory stream
            var bitmap = new Bitmap(ms);

            // Get width and height
            int width  = bitmap.Width;
            int height = bitmap.Height;

            // Gets the buffer from the texture
            var texBuffer = m_texture.GetBuffer();

            // Locks the buffer so we can copy data into the buffer
            texBuffer.Lock(BufferLocking.Discard);
            PixelBox   pb   = texBuffer.CurrentLock;
            BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, width, height),
                                              ImageLockMode.ReadOnly,
                                              System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            // Copy the data into the buffer
            CopyMemory(pb.Data, data.Scan0, (uint)((width) * height * 4));

            // Unlock the buffer
            bitmap.UnlockBits(data);
            texBuffer.Unlock();

            // Render using the material
            m_axiomMaterial.GetTechnique(0).GetPass(0).RemoveAllTextureUnitStates();
            m_axiomMaterial.GetTechnique(0).GetPass(0).CreateTextureUnitState("DynamicTexture");

            // Update the camera orientation
            UpdateCameraOrientation();

            try
            {
                // Render a single frame
                m_root.RenderOneFrame();
            }
            catch (Exception e)
            {
                return;
            }
        }
Exemple #3
0
 public RSQuadOperation(CompositorInstance instance, uint pass_id, Material mat)
 {
     this.mat      = mat;
     this.instance = instance;
     this.pass_id  = pass_id;
     mat.Load();
     instance.FireNotifyMaterialSetup(pass_id, mat);
     technique = mat.GetTechnique(0);
     Debug.Assert(technique != null);
 }
        public BspGeometry()
        {
            geometryMat = MaterialManager.Instance.GetByName("Axiom/BspGeometryMaterial");

            if (geometryMat == null)
            {
                geometryMat = (Material) MaterialManager.Instance.Create("Axiom/BspGeometryMaterial");
                geometryMat.ReceiveShadows = true;
                technique = geometryMat.GetTechnique(0);
            }
        }
Exemple #5
0
        ///<summary>
        ///    Create a local dummy material with one technique but no passes.
        ///    The material is detached from the Material Manager to make sure it is destroyed
        ///    when going out of scope.
        ///</summary>
        protected Material CreateLocalMaterial()
        {
            Material mat = (Material)MaterialManager.Instance.Create("CompositorInstanceMaterial" + materialDummyCounter);

            ++materialDummyCounter;
            // Ogre removed it from the resource list, but no such API exists in
            // in Axiom.
            MaterialManager.Instance.Unload(mat);
            /// Remove all passes from first technique
            mat.GetTechnique(0).RemoveAllPasses();
            return(mat);
        }
Exemple #6
0
        /// <summary>
        /// Helper function to replace an entity in the scene.  Adjusts the
        /// texture coordinates to flip the video.  That may be wrong on
        /// everything except DirectX / DirectShow.
        /// </summary>
        /// <param name="en">
        /// The entity we're going to replace.
        /// </param>
        /// <param name="meshName">
        /// The name of the mesh to create.
        /// </param>
        /// <param name="materialName">
        /// The name of the material to create.
        /// </param>
        /// <param name="textureName">
        /// The name of the texture to create.
        /// </param>
        /// <param name="videoSize">
        /// The size of the movie, in width by height pixels.
        /// </param>
        /// <param name="textureSize">
        /// The size of the texture, in width by height pixels.
        /// </param>
        /// <returns></returns>
        private static bool ReplaceEntity(
            Entity en,
            string meshName, string materialName, string textureName,
            Size videoSize, Size textureSize)
        {
            Mesh me = MeshManager.Instance.CreatePlane(
                meshName, // name
                new Axiom.MathLib.Plane(new Axiom.MathLib.Vector3(0, 0, -1), new Axiom.MathLib.Vector3(0, 0, 0)),
                videoSize.Width,
                videoSize.Height,
                1,                                 // xsegments
                1,                                 // ysegments
                true,                              // normals
                1,                                 // numtexcoords
                1.0f,                              // utile
                1.0f,                              // vtile
                new Axiom.MathLib.Vector3(0, 1, 0) // upvec
                );

            en.Mesh = me;
            Axiom.Graphics.Material m = MaterialManager.Instance.GetByName(materialName);
            if (m == null)
            {
                m = (Axiom.Graphics.Material)
                    MaterialManager.Instance.Create(materialName, true);
                ColorEx c = new ColorEx(1.0f, 1.0f, 1.0f);
                m.Ambient = c;
                m.Diffuse = c;
                for (int i = 0; i < m.GetTechnique(0).NumPasses; i++)
                {
                    Pass p = m.GetTechnique(0).GetPass(i);
                    p.RemoveAllTextureUnitStates();
                    p.CreateTextureUnitState(textureName);
                }
            }
            en.MaterialName = materialName;
            return(true);
        }
				/// <summary>
				/// 
				/// </summary>
				/// <param name="prof"></param>
				/// <param name="mat"></param>
				/// <param name="terrain"></param>
				/// <param name="compositeMap"></param>
				public virtual void UpdateParams( SM2Profile prof, Material mat, Terrain terrain, bool compositeMap )
				{
					Pass p = mat.GetTechnique( 0 ).GetPass( 0 );
					if ( compositeMap )
					{
						UpdateVpParams( prof, terrain, TechniqueType.RenderCompositeMap, p.VertexProgramParameters );
						UpdateFpParams( prof, terrain, TechniqueType.RenderCompositeMap, p.FragmentProgramParameters );
					}
					else
					{
						//high lod
						UpdateVpParams( prof, terrain, TechniqueType.HighLod, p.VertexProgramParameters );
						UpdateFpParams( prof, terrain, TechniqueType.HighLod, p.FragmentProgramParameters );

						//low lod
						p = mat.GetTechnique( 1 ).GetPass( 0 );
						UpdateVpParams( prof, terrain, TechniqueType.LowLod, p.VertexProgramParameters );
						UpdateFpParams( prof, terrain, TechniqueType.LowLod, p.FragmentProgramParameters );
					}
				}
        public void UpdateMaterial(Material material)
        {
            if (useParams)
            {
                Pass pass = material.GetTechnique(0).GetPass(0);
                pass.GetTextureUnitState(0).SetTextureName(sandTextureName);
                pass.GetTextureUnitState(1).SetTextureName(grassTextureName);
                pass.GetTextureUnitState(2).SetTextureName(rockTextureName);
                pass.GetTextureUnitState(3).SetTextureName(snowTextureName);
                GpuProgramParameters vertexParams = pass.VertexProgramParameters;
                vertexParams.SetNamedConstant("splatConfig", new Vector3(sandToGrassHeight, grassToRockHeight, rockToSnowHeight));
                vertexParams.SetNamedConstant("textureTileSize", new Vector3(textureTileSize, 0, 0));

                if (useGeneratedShadeMask)
                {
                    Page.SetShadeMask(material, 4);
                }
                else
                {
                    pass.GetTextureUnitState(4).SetTextureName(shadeMaskTextureName);
                }
            }
        }
        private TextureUnitState LoadMaterialTextures(int p, int lightmapNumber, Material material)
        {
            TextureUnitState t;
            if(pass[p].textureName == "$lightmap")
            {
                string lightmapName = String.Format("@lightmap{0}", lightmapNumber);
                t = material.GetTechnique(0).GetPass(0).CreateTextureUnitState(lightmapName);
            }
                // Animated texture support
            else if(pass[p].animNumFrames > 0)
            {
                float sequenceTime = pass[p].animNumFrames / pass[p].animFps;

                /* Pre-load textures
                    We need to know if each one was loaded OK since extensions may change for each
                    Quake3 can still include alternate extension filenames e.g. jpg instead of tga
                    Pain in the arse - have to check for each frame as letters<n>.tga for example
                    is different per frame!
                    */
                for(uint alt = 0; alt < pass[p].animNumFrames; ++alt)
                {
                    try
                    {
                        TextureManager.Instance.Load(pass[p].frames[alt]);
                    }
                    catch
                    {
                        // Try alternate extension
                        pass[p].frames[alt] = GetAlternateName(pass[p].frames[alt]);

                        try
                        {
                            TextureManager.Instance.Load(pass[p].frames[alt]);
                        }
                        catch
                        {
                            // stuffed - no texture
                        }
                    }

                }

                t = material.GetTechnique(0).GetPass(0).CreateTextureUnitState("");
                t.SetAnimatedTextureName(pass[p].frames, pass[p].animNumFrames, sequenceTime);

                if(t.IsBlank)
                {
                    for(int alt = 0; alt < pass[p].animNumFrames; alt++)
                        pass[p].frames[alt] = GetAlternateName(pass[p].frames[alt]);

                    t.SetAnimatedTextureName(pass[p].frames, pass[p].animNumFrames, sequenceTime);
                }
            }
            else
            {
                // Quake3 can still include alternate extension filenames e.g. jpg instead of tga
                // Pain in the arse - have to check for failure
                try
                {
                    TextureManager.Instance.Load(pass[p].textureName);
                }
                catch
                {
                    // Try alternate extension
                    pass[p].textureName = GetAlternateName(pass[p].textureName);

                    try
                    {
                        TextureManager.Instance.Load(pass[p].textureName);
                    }
                    catch
                    {
                        // stuffed - no texture
                    }
                }

                t = material.GetTechnique(0).GetPass(0).CreateTextureUnitState(pass[p].textureName);
            }
            return t;
        }
 public static void SetShadeMask(Material mat, int texunit)
 {
     if (shadeMask == null)
     {
         BuildShadeMask();
     }
     mat.GetTechnique(0).GetPass(0).GetTextureUnitState(texunit).SetTextureName(shadeMask.Name);
 }
        public override void LoadWorldGeometry(string fileName)
        {
            TerrainOptions options = new TerrainOptions();

            DataSet optionData = new DataSet();
            optionData.ReadXml(fileName);
            DataTable table = optionData.Tables[0];
            DataRow row = table.Rows[0];

            string terrainFileName = "";
            string detailTexture = "";
            string worldTexture = "";

            if(table.Columns["Terrain"] != null)
            {
                terrainFileName = (string)row["Terrain"];
            }

            if(table.Columns["DetailTexture"] != null)
            {
                detailTexture = (string)row["DetailTexture"];
            }

            if(table.Columns["WorldTexture"] != null)
            {
                worldTexture = (string)row["WorldTexture"];
            }

            if(table.Columns["MaxMipMapLevel"] != null)
            {
                options.maxMipmap = Convert.ToInt32(row["MaxMipMapLevel"]);
            }

            if(table.Columns["DetailTile"] != null)
            {
                options.detailTile = Convert.ToInt32(row["DetailTile"]);
            }

            if(table.Columns["MaxPixelError"] != null)
            {
                options.maxPixelError = Convert.ToInt32(row["MaxPixelError"]);
            }

            if(table.Columns["TileSize"] != null)
            {
                options.size = Convert.ToInt32(row["TileSize"]);
            }

            if(table.Columns["ScaleX"] != null)
            {
                options.scalex = StringConverter.ParseFloat((string)row["ScaleX"]);
            }

            if(table.Columns["ScaleY"] != null)
            {
                options.scaley = StringConverter.ParseFloat((string)row["ScaleY"]);
            }

            if(table.Columns["ScaleZ"] != null)
            {
                options.scalez = StringConverter.ParseFloat((string)row["ScaleZ"]);
            }

            if(table.Columns["VertexNormals"] != null)
            {
                options.isLit = ((string)row["VertexNormals"]) == "yes" ? true : false;
            }

            scale = new Vector3(options.scalex, options.scaley, options.scalez);
            tileSize = options.size;

            // load the heightmap
            Image image = Image.FromFile(terrainFileName);

            // TODO: Check terrain size for 2^n + 1

            // get the data from the heightmap
            options.data = image.Data;

            options.worldSize = image.Width;

            float maxx = options.scalex * options.worldSize;
            float maxy = 255 * options.scaley;
            float maxz = options.scalez * options.worldSize;

            Resize(new AxisAlignedBox(Vector3.Zero, new Vector3(maxx, maxy, maxz)));

            terrainMaterial = CreateMaterial("Terrain");

            if(worldTexture != "")
            {
                terrainMaterial.GetTechnique(0).GetPass(0).CreateTextureUnitState(worldTexture, 0);
            }

            if(detailTexture != "")
            {
                terrainMaterial.GetTechnique(0).GetPass(0).CreateTextureUnitState(detailTexture, 1);
            }

            terrainMaterial.Lighting = options.isLit;
            terrainMaterial.Load();

            terrainRoot = (SceneNode)RootSceneNode.CreateChild("TerrainRoot");

            numTiles = (options.worldSize - 1) / (options.size - 1);

            tiles = new TerrainRenderable[numTiles, numTiles];

            int p = 0, q = 0;

            for(int j = 0; j < options.worldSize - 1; j += (options.size - 1))
            {
                p = 0;

                for(int i = 0; i < options.worldSize - 1; i += (options.size - 1))
                {
                    options.startx = i;
                    options.startz = j;

                    string name = string.Format("Tile[{0},{1}]", p, q);

                    SceneNode node = (SceneNode)terrainRoot.CreateChild(name);
                    TerrainRenderable tile = new TerrainRenderable();
                    tile.Name = name;

                    tile.SetMaterial(terrainMaterial);
                    tile.Init(options);

                    tiles[p,q] = tile;

                    node.AttachObject(tile);

                    p++;
                }

                q++;
            }

            int size1 = tiles.GetLength(0);
            int size2 = tiles.GetLength(1);

            for(int j = 0; j < size1; j++)
            {
                for(int i = 0; i < size2; i++)
                {
                    if(j != size1 - 1)
                    {
                        ((TerrainRenderable)tiles[i,j]).SetNeighbor(Neighbor.South, (TerrainRenderable)tiles[i, j + 1]);
                        ((TerrainRenderable)tiles[i,j + 1]).SetNeighbor(Neighbor.North, (TerrainRenderable)tiles[i, j]);
                    }

                    if(i != size2 - 1)
                    {
                        ((TerrainRenderable)tiles[i,j]).SetNeighbor(Neighbor.East, (TerrainRenderable)tiles[i + 1, j]);
                        ((TerrainRenderable)tiles[i + 1,j]).SetNeighbor(Neighbor.West, (TerrainRenderable)tiles[i, j]);
                    }
                }
            }

            #if NOT_USED
            if(false) // && options.isLit) //TODO: Fix
            {
                for(int j = 0; j < size1; j++)
                {
                    for(int i = 0; i < size2; i++)
                    {
                        ((TerrainRenderable)tiles[i,j]).CalculateNormals();
                    }
                }
            }
            #endif
            this.terrainOptions = options; //we need these later for GetHeightAt, so make them a member variable
        }
 public RSQuadOperation(CompositorInstance instance, uint pass_id, Material mat)
 {
     this.mat = mat;
     this.instance = instance;
     this.pass_id = pass_id;
     mat.Load();
     instance.FireNotifyMaterialSetup(pass_id, mat);
     technique = mat.GetTechnique(0);
     Debug.Assert(technique != null);
 }
		/*
		 * System::Void JointPositionOverlay::copyBitmapToTexture()
{
  // Lock the texture buffer so we can write to it

  Ogre::HardwarePixelBufferSharedPtr buffer = mTexture->getBuffer ();
  buffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
  const Ogre::PixelBox &pb = buffer->getCurrentLock();
  Ogre::uint32 *texData = static_cast<Ogre::uint32*>(pb.data);


  // Lock the bitmap buffer so we can read from it

  System::Drawing::Imaging::BitmapData^ bmd = 
    mBitmap->LockBits(
      System::Drawing::Rectangle(0, 0, mBitmap->Width, mBitmap->Height),
      System::Drawing::Imaging::ImageLockMode::ReadOnly, 
      System::Drawing::Imaging::PixelFormat::Format32bppArgb);
  Ogre::uint32* mapData = static_cast<Ogre::uint32*>(bmd->Scan0.ToPointer());


  // Now copy the data between buffers

  size_t height = std::min (pb.getHeight(), (size_t)bmd->Height);
  size_t width = std::min(pb.getWidth(), (size_t)bmd->Width);
  for(size_t y=0; y<height; ++y) 
    for(size_t x=0; x<width; ++x) 
      texData[pb.rowPitch*y + x] = mapData[bmd->Stride/4 * y + x];


  // Unlock the buffers again

  mBitmap->UnlockBits(bmd);
  buffer->unlock();
}
		 * 
		 * 
		 * 
		 */

		/// <summary>
		/// Creates the dynamic texture and material.
		/// </summary>
		/// <param name="TextureName">Name of the texture.</param>
		/// <param name="MaterialName">Name of the material.</param>
		/// <param name="textureHeight">Height of the texture.</param>
		/// <param name="textureWidth">Width of the texture.</param>
		/// <param name="texture">The texture.</param>
		/// <param name="material">The material.</param>
		public static void CreateDynamicTextureAndMaterial(string TextureName, string MaterialName, int textureWidth, int textureHeight, out Texture texture, out Material material)
		{
			texture = TextureManager.Instance.CreateManual(TextureName,
						ResourceGroupManager.DefaultResourceGroupName,
						TextureType.TwoD, textureWidth, textureHeight, 0,
						Axiom.Media.PixelFormat.A8R8G8B8, TextureUsage.DynamicWriteOnlyDiscardable);


			material = (Material)MaterialManager.Instance.Create(MaterialName,
						ResourceGroupManager.DefaultResourceGroupName);

			material.GetTechnique(0).GetPass(0).CreateTextureUnitState(TextureName);


		}
Exemple #14
0
        ///<summary>
        ///    Collect rendering passes. Here, passes are converted into render target operations
        ///    and queued with queueRenderSystemOp.
        ///</summary>
        protected void CollectPasses(CompositorTargetOperation finalState, CompositionTargetPass target)
        {
            /// Here, passes are converted into render target operations
            Pass      targetpass;
            Technique srctech;
            Material  srcmat;

            foreach (CompositionPass pass in target.Passes)
            {
                switch (pass.Type)
                {
                case CompositorPassType.Clear:
                    QueueRenderSystemOp(finalState, new RSClearOperation(
                                            pass.ClearBuffers,
                                            pass.ClearColor,
                                            pass.ClearDepth,
                                            pass.ClearStencil));
                    break;

                case CompositorPassType.Stencil:
                    QueueRenderSystemOp(finalState, new RSStencilOperation(
                                            pass.StencilCheck, pass.StencilFunc, pass.StencilRefValue,
                                            pass.StencilMask, pass.StencilFailOp, pass.StencilDepthFailOp,
                                            pass.StencilPassOp, pass.StencilTwoSidedOperation
                                            ));
                    break;

                case CompositorPassType.RenderScene:
                    if ((int)pass.FirstRenderQueue < (int)finalState.CurrentQueueGroupID)
                    {
                        /// Mismatch -- warn user
                        /// XXX We could support repeating the last queue, with some effort
                        LogManager.Instance.Write("Warning in compilation of Compositor "
                                                  + compositor.Name + ": Attempt to render queue " +
                                                  pass.FirstRenderQueue + " before " +
                                                  finalState.CurrentQueueGroupID);
                    }
                    /// Add render queues
                    for (RenderQueueGroupID x = pass.FirstRenderQueue; x <= pass.LastRenderQueue; ++x)
                    {
                        Debug.Assert(x >= 0);
                        finalState.RenderQueues[(int)x] = true;
                    }
                    finalState.CurrentQueueGroupID = (RenderQueueGroupID)((int)pass.LastRenderQueue + 1);
                    finalState.FindVisibleObjects  = true;
                    finalState.MaterialScheme      = target.MaterialScheme;

                    break;

                case CompositorPassType.RenderQuad:
                    srcmat = pass.Material;
                    if (srcmat == null)
                    {
                        /// No material -- warn user
                        LogManager.Instance.Write("Warning in compilation of Compositor "
                                                  + compositor.Name + ": No material defined for composition pass");
                        break;
                    }
                    srcmat.Load();
                    if (srcmat.SupportedTechniques.Count == 0)
                    {
                        /// No supported techniques -- warn user
                        LogManager.Instance.Write("Warning in compilation of Compositor "
                                                  + compositor.Name + ": material " + srcmat.Name + " has no supported techniques");
                        break;
                    }
                    srctech = srcmat.GetBestTechnique(0);
                    /// Create local material
                    Material localMat = CreateLocalMaterial();
                    /// Copy and adapt passes from source material
                    for (int i = 0; i < srctech.NumPasses; i++)
                    {
                        Pass srcpass = srctech.GetPass(i);
                        /// Create new target pass
                        targetpass = localMat.GetTechnique(0).CreatePass();
                        srcpass.CopyTo(targetpass);
                        /// Set up inputs
                        int numInputs = pass.GetNumInputs();
                        for (int x = 0; x < numInputs; x++)
                        {
                            string inp = pass.Inputs[x];
                            if (inp != string.Empty)
                            {
                                if (x < targetpass.NumTextureUnitStages)
                                {
                                    targetpass.GetTextureUnitState(x).SetTextureName(GetSourceForTex(inp));
                                }
                                else
                                {
                                    /// Texture unit not there
                                    LogManager.Instance.Write("Warning in compilation of Compositor "
                                                              + compositor.Name + ": material " + srcmat.Name + " texture unit "
                                                              + x + " out of bounds");
                                }
                            }
                        }
                    }
                    QueueRenderSystemOp(finalState, new RSQuadOperation(this, pass.Identifier, localMat));
                    break;
                }
            }
        }
Exemple #15
0
		protected void InitTextureLighting()
		{
			if ( targetRenderSystem.Capabilities.TextureUnitCount < 2 )
				LogManager.Instance.Write( "--WARNING--At least 2 available texture units are required for BSP dynamic lighting!" );

			Texture texLight = TextureLight.CreateTexture();

			textureLightMaterial = (Material)MaterialManager.Instance.GetByName( "Axiom/BspTextureLightMaterial" );
			if ( textureLightMaterial == null )
			{
				textureLightMaterial = (Material)MaterialManager.Instance.Create( "Axiom/BspTextureLightMaterial", ResourceGroupManager.DefaultResourceGroupName );
				textureLightPass = textureLightMaterial.GetTechnique( 0 ).GetPass( 0 );
				// the texture light
				TextureUnitState tex = textureLightPass.CreateTextureUnitState( texLight.Name );
				tex.SetColorOperation( LayerBlendOperation.Modulate );
				tex.ColorBlendMode.source2 = LayerBlendSource.Diffuse;
				tex.SetAlphaOperation( LayerBlendOperationEx.Modulate );
				tex.AlphaBlendMode.source2 = LayerBlendSource.Diffuse;
				tex.TextureCoordSet = 2;
                tex.SetTextureAddressingMode( TextureAddressing.Clamp );

				// The geometry texture without lightmap. Use the light texture on this
				// pass, the appropriate texture will be rendered at RenderTextureLighting
				tex = textureLightPass.CreateTextureUnitState( texLight.Name );
				tex.SetColorOperation( LayerBlendOperation.Modulate );
				tex.SetAlphaOperation( LayerBlendOperationEx.Modulate );
                tex.SetTextureAddressingMode( TextureAddressing.Wrap );

				textureLightPass.SetSceneBlending( SceneBlendType.TransparentAlpha );

				textureLightMaterial.CullingMode = CullingMode.None;
				textureLightMaterial.Lighting = false;
			}
			else
			{
				textureLightPass = textureLightMaterial.GetTechnique( 0 ).GetPass( 0 );
			}
		}
        public void Initialize(Window window)
        {
            m_window = window;

            InitializeOculus();

            InitializeGloves();

            // Create the root object
            m_root = new Root("GlovesLog.log");

            // Configure the render system
            SetRenderingSystem();

            // Create render window
            m_renderWindow = m_root.Initialize(true);

            // Loads the resources
            ResourceGroupManager.Instance.AddResourceLocation("media", "Folder", true);
            ResourceGroupManager.Instance.InitializeAllResourceGroups();

            // Create the screen manager
            m_sceneManager = m_root.CreateSceneManager(SceneType.Generic);

            InitializeCameras();

            InitializeViewports();

            InitializeLight();

            // Create material to render ClEye camera input
            m_axiomMaterial = MaterialManager.Instance.Create("dynamicResource", "Materials") as Material;

            // Create texture to render the CLEye camera input to
            m_texture = TextureManager.Instance.CreateManual("DynamicTexture",
                                                             ResourceGroupManager.DefaultResourceGroupName,
                                                             TextureType.TwoD, 640, 480, 2, PixelFormat.R8G8B8,
                                                             TextureUsage.RenderTarget);

            // Set the cameras in the scene
            SceneNode cameraNode = m_sceneManager.RootSceneNode.CreateChildSceneNode("CameraNode", new Vector3(0, 0, 0));

            cameraNode.AttachObject(m_camera[0]);
            cameraNode.AttachObject(m_camera[1]);

            InitializeEntities();

            // Initialize the material that will draw the camera input
            m_axiomMaterial.GetTechnique(0).GetPass(0).CreateTextureUnitState("DynamicTexture");
            m_axiomMaterial.GetTechnique(0).GetPass(0).DepthCheck      = false;
            m_axiomMaterial.GetTechnique(0).GetPass(0).DepthWrite      = false;
            m_axiomMaterial.GetTechnique(0).GetPass(0).LightingEnabled = false;

            // Initialize the rectangle input onto which the camera input will be rendered
            m_rect = new Rectangle2D(true);
            //m_rect.SetCorners(-1.15f, 1.0f, 1.15f, -1.0f);
            m_rect.SetCorners(-0.85f, 0.7f, 0.85f, -0.7f);
            m_rect.Material         = m_axiomMaterial;
            m_rect.RenderQueueGroup = RenderQueueGroupID.Background;
            SceneNode node = m_sceneManager.RootSceneNode.CreateChildSceneNode("Background");

            node.AttachObject(m_rect);

            // Set the function to the FrameStarted event
            m_root.FrameStarted += FrameStarted;

            InitializeCLEyeCameras();

            // Not recording
            m_record = false;

            // Not loading from file
            m_renderFromFile = false;

            // Initialize the gloves capture  string arrays
            m_gloveCaptureL    = new string[30];
            m_gloveCaptureL[0] = "Left Glove Capture";
            m_gloveCaptureL[1] = "\r\n";

            m_gloveCaptureR    = new string[30];
            m_gloveCaptureR[0] = "Right Glove Capture";
            m_gloveCaptureR[1] = "\r\n";
        }
        public void UpdateMaterial(Material material)
        {
            if (useParams)
            {
                // Note: If we change the number of alpha map mosaics, we may need to update the GPU
                // shader to support
                Pass pass = material.GetTechnique(0).GetPass(0);
                GpuProgramParameters vertexParams = pass.VertexProgramParameters;
                vertexParams.SetNamedConstant("textureTileSize", new Vector3(textureTileSize, 0, 0));

                // set splatting textures
                int offset = alphaMapMosaicNames.Length;
                for (int i = 0; i < layerTextureNames.Length; i++)
                {
                    pass.GetTextureUnitState(offset + i).SetTextureName(layerTextureNames[i]);
                }

                pass.GetTextureUnitState(10).SetTextureName(detailTextureName);
            }
        }
Exemple #18
0
			public DebugRenderable( Node parent )
			{
				_parent = parent;

				string materialName = "Axiom/Debug/AxesMat";
				_material = (Material)MaterialManager.Instance[ materialName ];
				if ( _material == null )
				{
					_material = (Material)MaterialManager.Instance.Create( materialName, ResourceGroupManager.InternalResourceGroupName );
					Pass p = _material.GetTechnique( 0 ).GetPass( 0 );
					p.LightingEnabled = false;
					//TODO: p.PolygonModeOverrideable = false;
					p.VertexColorTracking = TrackVertexColor.Ambient;
					p.SetSceneBlending( SceneBlendType.TransparentAlpha );
					p.CullingMode = CullingMode.None;
					p.DepthWrite = false;
				}

				string meshName = "Axiom/Debug/AxesMesh";
				_mesh = MeshManager.Instance[ meshName ];
				if ( _mesh == null )
				{
					ManualObject mo = new ManualObject( "tmp" );
					mo.Begin( Material.Name, OperationType.TriangleList );
					/* 3 axes, each made up of 2 of these (base plane = XY)
					 *   .------------|\
					 *   '------------|/
					 */
					mo.EstimateVertexCount( 7 * 2 * 3 );
					mo.EstimateIndexCount( 3 * 2 * 3 );
					Quaternion[] quat = new Quaternion[ 6 ];
					ColorEx[] col = new ColorEx[ 3 ];

					// x-axis
					quat[ 0 ] = Quaternion.Identity;
					quat[ 1 ] = Quaternion.FromAxes( Vector3.UnitX, Vector3.NegativeUnitZ, Vector3.UnitY );
					col[ 0 ] = ColorEx.Red;
					col[ 0 ].a = 0.8f;
					// y-axis
					quat[ 2 ] = Quaternion.FromAxes( Vector3.UnitY, Vector3.NegativeUnitX, Vector3.UnitZ );
					quat[ 3 ] = Quaternion.FromAxes( Vector3.UnitY, Vector3.UnitZ, Vector3.UnitX );
					col[ 1 ] = ColorEx.Green;
					col[ 1 ].a = 0.8f;
					// z-axis
					quat[ 4 ] = Quaternion.FromAxes( Vector3.UnitZ, Vector3.UnitY, Vector3.NegativeUnitX );
					quat[ 5 ] = Quaternion.FromAxes( Vector3.UnitZ, Vector3.UnitX, Vector3.UnitY );
					col[ 2 ] = ColorEx.Blue;
					col[ 2 ].a = 0.8f;

					Vector3[] basepos = new Vector3[ 7 ]  
										{
											// stalk
											new Vector3(0f, 0.05f, 0f), 
											new Vector3(0f, -0.05f, 0f),
											new Vector3(0.7f, -0.05f, 0f),
											new Vector3(0.7f, 0.05f, 0f),
											// head
											new Vector3(0.7f, -0.15f, 0f),
											new Vector3(1f, 0f, 0f),
											new Vector3(0.7f, 0.15f, 0f)
										};


					// vertices
					// 6 arrows
					for ( int i = 0; i < 6; ++i )
					{
						// 7 points
						for ( int p = 0; p < 7; ++p )
						{
							Vector3 pos = quat[ i ] * basepos[ p ];
							mo.Position( pos );
							mo.Color( col[ i / 2 ] );
						}
					}

					// indices
					// 6 arrows
					for ( int i = 0; i < 6; ++i )
					{
						ushort baseIndex = (ushort)( i * 7 );
						mo.Triangle( (ushort)( baseIndex + 0 ), (ushort)( baseIndex + 1 ), (ushort)( baseIndex + 2 ) );
						mo.Triangle( (ushort)( baseIndex + 0 ), (ushort)( baseIndex + 2 ), (ushort)( baseIndex + 3 ) );
						mo.Triangle( (ushort)( baseIndex + 4 ), (ushort)( baseIndex + 5 ), (ushort)( baseIndex + 6 ) );
					}

					mo.End();

					_mesh = mo.ConvertToMesh( meshName, ResourceGroupManager.InternalResourceGroupName );
				}
			}
Exemple #19
0
		protected override void load()
		{
			// clarabie - nov 18, 2008
			// modified this to check for an existing material instead of always
			// creating a new one. Allows more flexibility, but also specifically allows us to
			// solve the problem of XNA not having fixed function support

			_material = (Material)MaterialManager.Instance.GetByName( "Fonts/" + _name );

			if ( _material == null )
			{

				// create a material for this font
				_material = (Material)MaterialManager.Instance.Create( "Fonts/" + _name, Group );

				TextureUnitState unitState = null;
				bool blendByAlpha = false;

				if ( _fontType == FontType.TrueType )
				{
#if !( XBOX || XBOX360 )
					// create the font bitmap on the fly
					createTexture();

					// a texture layer was added in CreateTexture
					unitState = _material.GetTechnique( 0 ).GetPass( 0 ).GetTextureUnitState( 0 );

					blendByAlpha = true;
#endif
				}
				else
				{
					// load this texture
					// TODO In general, modify any methods like this that throw their own exception rather than returning null, so the caller can decide how to handle a missing resource.
					_texture = TextureManager.Instance.Load( Source, Group, TextureType.TwoD, 0 );

					blendByAlpha = texture.HasAlpha;
					// pre-created font images
					unitState = Material.GetTechnique( 0 ).GetPass( 0 ).CreateTextureUnitState( Source );
				}

				// set texture addressing mode to Clamp to eliminate fuzzy edges
                if ( unitState != null )
                    unitState.SetTextureAddressingMode( TextureAddressing.Clamp );

				// set up blending mode
				if ( blendByAlpha )
				{
					_material.SetSceneBlending( SceneBlendType.TransparentAlpha );
				}
				else
				{
					// assume black background here
					_material.SetSceneBlending( SceneBlendType.Add );
				}
			}
		}
		public RSQuadOperation( CompositorInstance instance, uint pass_id, Material mat )
		{
			Material = mat;
			Instance = instance;
			PassId = pass_id;
			QuadLeft = -1;
			QuadRight = 1;
			QuadTop = 1;
			QuadBottom = -1;

			mat.Load();
			instance.OnMaterialSetup( new CompositorInstanceMaterialEventArgs( PassId, Material ) );
			Technique = mat.GetTechnique( 0 );
			Debug.Assert( Technique != null, "Material has no supported technique." );
		}
        /// <summary>
        ///    Loads either an image based font, or creates one on the fly from a TrueType font file.
        /// </summary>
        protected override void LoadImpl()
        {
            // create a material for this font
            material = (Material)MaterialManager.Instance.Create("Fonts/" + name);

            TextureUnitState unitState = null;
            bool blendByAlpha = false;

            if (fontType == FontType.TrueType) {
                // create the font bitmap on the fly
                CreateTexture();
                // a texture layer was added in CreateTexture
                unitState = material.GetTechnique(0).GetPass(0).GetTextureUnitState(0);
                blendByAlpha = true;
            }
            else {
                // pre-created font images
                unitState = material.GetTechnique(0).GetPass(0).CreateTextureUnitState(source);
                // load this texture
                // TODO: In general, modify any methods like this that throw their own exception rather than returning null, so the caller can decide how to handle a missing resource.
                Texture texture = TextureManager.Instance.Load(source);
                blendByAlpha = texture.HasAlpha;
            }

            // set texture addressing mode to Clamp to eliminate fuzzy edges
            unitState.TextureAddressing = TextureAddressing.Clamp;

            // set up blending mode
            if(blendByAlpha) {
                material.SetSceneBlending(SceneBlendType.TransparentAlpha);
            }
            else {
                // assume black background here
                material.SetSceneBlending(SceneBlendType.Add);
            }
        }