当前位置: 首页>>代码示例>>C#>>正文


C# Device.DrawIndexedUserPrimitives方法代码示例

本文整理汇总了C#中Device.DrawIndexedUserPrimitives方法的典型用法代码示例。如果您正苦于以下问题:C# Device.DrawIndexedUserPrimitives方法的具体用法?C# Device.DrawIndexedUserPrimitives怎么用?C# Device.DrawIndexedUserPrimitives使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device的用法示例。


在下文中一共展示了Device.DrawIndexedUserPrimitives方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: drawMesh

        /// <summary>
        /// Draw this model using a render context.
        /// </summary>
        /// <param name="pDevice">The render device to draw too.</param>
        public void drawMesh(Device pDevice)
        {
            // Compute the vertex stride.
            int iSize = Marshal.SizeOf(typeof(PositionTextured));

            // For each attribute.
            for (int iAttr = 0; iAttr < tAttibutes.Length; ++iAttr)
            {
                // Reference the attribute.
                Attribute pAttr = tAttibutes[iAttr];

                // Push it's material.
                pDevice.SetTexture(0, tTextures[iAttr]);

                // Draw that part of the vertex buffer.
                pDevice.DrawIndexedUserPrimitives<UInt32, PositionTextured>(PrimitiveType.TriangleList, pAttr.iVertexStart, pAttr.iVertexCount, pAttr.iFaceCount, tIndex, Format.Index32, tVertex, iSize);
            }
        }
开发者ID:dkushner,项目名称:managed-assimp,代码行数:22,代码来源:SimpleModel.cs

示例2: Render


//.........这里部分代码省略.........
                        {
                            //localOrigin = BoundingBox.CalculateCenter();
                            Point3d centerPoint =
                                 MathEngine.SphericalToCartesian(centerLatitude, centerLongitude,
                                                                             quadTileSet.LayerRadius);
                            Point3d northHalf =
                                 MathEngine.SphericalToCartesian(Angle.FromDegrees(north), centerLongitude,
                                                                             quadTileSet.LayerRadius);
                            Point3d eastHalf =
                                 MathEngine.SphericalToCartesian(centerLatitude, Angle.FromDegrees(east),
                                                                             quadTileSet.LayerRadius);

                            Vector4 xdir = (2 * (eastHalf - centerPoint)).Vector4;
                            Vector4 ydir = (2 * (northHalf - centerPoint)).Vector4;
                            // up vector is radius at center point, normalized
                            Point3d zdir3 = centerPoint;
                            zdir3.normalize();
                            Vector4 zdir = zdir3.Vector4;
                            // local frame origin at SW corner, relative to local origin
                            Point3d localFrameOrigin = northHalf + eastHalf - centerPoint - localOrigin;
                            Vector4 lfoW = localFrameOrigin.Vector4;
                            lfoW.W = 1;
                            lfoW.Transform(device.Transform.World);
                            effect.SetValue(param, localFrameOrigin.Vector4); // JBTODO: Should this be lfoW?

                            param = (EffectHandle)quadTileSet.EffectParameters["LocalFrameXAxis"];
                            if (param != null) effect.SetValue(param, xdir);
                            param = (EffectHandle)quadTileSet.EffectParameters["LocalFrameYAxis"];
                            if (param != null) effect.SetValue(param, ydir);
                            param = (EffectHandle)quadTileSet.EffectParameters["LocalFrameZAxis"];
                            if (param != null) effect.SetValue(param, zdir);
                        }
                    }
                    catch
                    {
                    }

                    int numPasses = effect.Begin(0);
                    for (int i = 0; i < numPasses; i++)
                    {
                        effect.BeginPass(i);
                        device.DrawIndexedUserPrimitives(PrimitiveType.TriangleList, 0,
                                                                    verts.Length, vertexIndexes.Length / 3, vertexIndexes, true,
                                                                    verts);

                        effect.EndPass();
                    }

                    effect.End();
                    device.SetTextureStageState(1, TextureStageStates.TextureCoordinateIndex, tc1);
                }
                else
                {
                    if (World.Settings.EnableSunShading)
                    {
                        Point3d sunPosition = SunCalculator.GetGeocentricPosition(TimeKeeper.CurrentTimeUtc);
                        Vector3 sunVector = new Vector3(
                             (float)sunPosition.X,
                             (float)sunPosition.Y,
                             (float)sunPosition.Z);

                        device.RenderState.Lighting = true;
                        Material material = new Material();
                        material.Diffuse = Color.White;
                        material.Ambient = Color.White;

                        device.Material = material;
                        device.RenderState.AmbientColor = World.Settings.ShadingAmbientColor.ToArgb();
                        device.RenderState.NormalizeNormals = true;
                        device.RenderState.AlphaBlendEnable = true;

                        device.Lights[0].Enabled = true;
                        device.Lights[0].Type = LightType.Directional;
                        device.Lights[0].Diffuse = LightColor;
                        device.Lights[0].Direction = sunVector;

                        device.TextureState[0].ColorOperation = TextureOperation.Modulate;
                        device.TextureState[0].ColorArgument1 = TextureArgument.Diffuse;
                        device.TextureState[0].ColorArgument2 = TextureArgument.TextureColor;
                    }
                    else
                    {
                        device.RenderState.Lighting = false;
                        device.RenderState.Ambient = World.Settings.StandardAmbientColor;
                    }

                    device.RenderState.TextureFactor = Color.FromArgb(m_CurrentOpacity, 255, 255, 255).ToArgb();
                    device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
                    device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
                    device.TextureState[0].AlphaArgument2 = TextureArgument.TFactor;

                    device.DrawIndexedUserPrimitives(PrimitiveType.TriangleList, 0,
                                                                verts.Length, vertexIndexes.Length / 3, vertexIndexes, true, verts);

               device.RenderState.TextureFactor = Color.FromArgb(255, 255, 255, 255).ToArgb();
                }
            }
            if (isMultitexturing)
                device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Disable);
        }
开发者ID:paladin74,项目名称:Dapple,代码行数:101,代码来源:QuadTile.cs

示例3: Render

		/// <summary>
		/// Render one of the 4 quadrants with optional download indicator
		/// </summary>
		void Render(Device device, CustomVertex.PositionNormalTextured[] verts, QuadTile child)
		{
			bool isMultitexturing = false;
			
			if(!World.Settings.EnableSunShading)
			{
				if (World.Settings.ShowDownloadIndicator && child != null)
				{
					// Check/display download activity
					GeoSpatialDownloadRequest request = child.DownloadRequest;
					if (child.isDownloadingTerrain)
					{
						device.SetTexture(1, QuadTileSet.DownloadTerrainTexture);
						isMultitexturing = true;
					}
						//else if (request != null)
					else if(child.WaitingForDownload)
					{
						if (child.IsDownloadingImage)
							device.SetTexture(1, QuadTileSet.DownloadInProgressTexture);
						else
							device.SetTexture(1, QuadTileSet.DownloadQueuedTexture);
						isMultitexturing = true;
					}
				}
			}
			
			if (isMultitexturing)
				device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.BlendTextureAlpha);

			if(verts != null && vertexIndexes != null)
			{
                if (QuadTileSet.Effect != null)
                {
                    Effect effect = QuadTileSet.Effect;

                    // FIXME: just use the first technique for now
                    effect.Technique = effect.GetTechnique(0);
                    effect.SetValue("WorldViewProj", Matrix.Multiply(device.Transform.World, Matrix.Multiply(device.Transform.View, device.Transform.Projection)));
                    try
                    {
                        effect.SetValue("Tex0", textures[0]);
                        effect.SetValue("Tex1", textures[1]);
                        effect.SetValue("Brightness", QuadTileSet.GrayscaleBrightness);
                        float opacity = (float)QuadTileSet.Opacity / 255.0f;
                        effect.SetValue("Opacity", opacity);
                    }
                    catch
                    {
                    }

                    int numPasses = effect.Begin(0);
                    for (int i = 0; i < numPasses; i++)
                    {
                        effect.BeginPass(i);
                        device.DrawIndexedUserPrimitives(PrimitiveType.TriangleList, 0,
                            verts.Length, vertexIndexes.Length / 3, vertexIndexes, true, verts);

                        effect.EndPass();
                    }

                    effect.End();
                }
                else if (!QuadTileSet.RenderGrayscale || (device.DeviceCaps.PixelShaderVersion.Major < 1))
                {
                    if (World.Settings.EnableSunShading)
                    {
                        Point3d sunPosition = SunCalculator.GetGeocentricPosition(TimeKeeper.CurrentTimeUtc);
                        Vector3 sunVector = new Vector3(
                            (float)sunPosition.X,
                            (float)sunPosition.Y,
                            (float)sunPosition.Z);

                        device.RenderState.Lighting = true;
                        Material material = new Material();
                        material.Diffuse = System.Drawing.Color.White;
                        material.Ambient = System.Drawing.Color.White;

                        device.Material = material;
                        device.RenderState.AmbientColor = World.Settings.ShadingAmbientColor.ToArgb();
                        device.RenderState.NormalizeNormals = true;
                        device.RenderState.AlphaBlendEnable = true;

                        device.Lights[0].Enabled = true;
                        device.Lights[0].Type = LightType.Directional;
                        device.Lights[0].Diffuse = System.Drawing.Color.White;
                        device.Lights[0].Direction = sunVector;

                        device.TextureState[0].ColorOperation = TextureOperation.Modulate;
                        device.TextureState[0].ColorArgument1 = TextureArgument.Diffuse;
                        device.TextureState[0].ColorArgument2 = TextureArgument.TextureColor;
                    }
                    else
                    {
                        device.RenderState.Lighting = false;
                        device.RenderState.Ambient = World.Settings.StandardAmbientColor;
                    }
//.........这里部分代码省略.........
开发者ID:jpespartero,项目名称:WorldWind,代码行数:101,代码来源:QuadTile.cs

示例4: Render

        /// <summary>
        /// Render one of the 4 quadrants with optional download indicator
        /// </summary>
        private void Render(Device device, CustomVertex.PositionTextured[] verts, QuadTile child)
        {
            bool isMultitexturing = false;
            if (World.Settings.ShowDownloadIndicator
                && child != null) {
                // Check/display download activity
                GeoSpatialDownloadRequest request = child.DownloadRequest;
                if (child.isDownloadingTerrain) {
                    device.SetTexture(1, QuadTileSet.DownloadTerrainTexture);
                    isMultitexturing = true;
                }
                    //else if (request != null)
                else if (child.WaitingForDownload) {
                    if (child.IsDownloadingImage) {
                        device.SetTexture(1, QuadTileSet.DownloadInProgressTexture);
                    }
                    else {
                        device.SetTexture(1, QuadTileSet.DownloadQueuedTexture);
                    }
                    isMultitexturing = true;
                }
            }

            if (isMultitexturing) {
                device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int) TextureOperation.BlendTextureAlpha);
            }

            if (verts != null
                && vertexIndexes != null) {
                device.DrawIndexedUserPrimitives(PrimitiveType.TriangleList, 0, verts.Length, vertexIndexes.Length/3, vertexIndexes, true, verts);
            }

            if (isMultitexturing) {
                device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int) TextureOperation.Disable);
            }
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:39,代码来源:QuadTile.cs


注:本文中的Device.DrawIndexedUserPrimitives方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。