本文整理匯總了C#中TerraViewer.RenderContext11.SetIndexBuffer方法的典型用法代碼示例。如果您正苦於以下問題:C# RenderContext11.SetIndexBuffer方法的具體用法?C# RenderContext11.SetIndexBuffer怎麽用?C# RenderContext11.SetIndexBuffer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TerraViewer.RenderContext11
的用法示例。
在下文中一共展示了RenderContext11.SetIndexBuffer方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Draw3D
public override bool Draw3D(RenderContext11 renderContext, float transparancy, Tile parent)
{
RenderedGeneration = CurrentRenderGeneration;
TilesTouched++;
InViewFrustum = true;
if (!ReadyToRender)
{
TileCache.AddTileToQueue(this);
return false;
}
TilesInView++;
if (!CreateGeometry(renderContext, true))
{
return false;
}
renderContext.SetVertexBuffer(vertexBuffer);
renderContext.MainTexture = texture;
renderContext.SetIndexBuffer( indexBuffer[0]);
int partCount = this.TriangleCount;
TrianglesRendered += partCount;
renderContext.devContext.DrawIndexed(indexBuffer[0].Count, 0, 0);
return true;
}
示例2: RenderPart
public override void RenderPart(RenderContext11 renderContext, int part, float opacity, bool combine)
{
if (dsm != null && dsm.DsmIndex != null)
{
renderContext.SetIndexBuffer(dsm.DsmIndex);
renderContext.SetVertexBuffer(dsm.VertexBuffer);
if (dsm.Subsets.Length > 4)
{
switch (part)
{
case 0:
part = 2;
break;
case 1:
part = 3;
// return;
break;
case 2:
part = 0;
break;
case 3:
part = 1;
break;
}
renderContext.devContext.DrawIndexed(dsm.Subsets[part + 1] - dsm.Subsets[part], dsm.Subsets[part], 0);
}
else
{
if (dsm.Subsets.Length > 0)
{
renderContext.devContext.DrawIndexed(dsm.Subsets[0] , 0, 0);
}
}
}
else
{
base.RenderPart(renderContext, part, opacity, combine);
}
}
示例3: beginDrawing
public void beginDrawing(RenderContext11 renderContext)
{
if (vertexBuffer != null)
{
renderContext.SetVertexBuffer(vertexBuffer);
}
else if (tangentVertexBuffer != null)
{
renderContext.SetVertexBuffer(tangentVertexBuffer);
}
if (indexBuffer != null)
{
renderContext.SetIndexBuffer(indexBuffer);
}
SharpDX.Direct3D11.DeviceContext devContext = renderContext.Device.ImmediateContext;
devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
}
示例4: Draw
//.........這裏部分代碼省略.........
// 2D Point coordinates. 3d also supported which would add a Z. There's also an optional measure (M) that can be used.
var Xcoord = p.X;
var Ycoord = p.Y;
if (shapefile.Projection == ShapeFile.Projections.Geo)
{
lastItem = Coordinates.GeoTo3d(Ycoord, Xcoord);
}
else if (shapefile.Projection == ShapeFile.Projections.PolarStereo)
{
lastItem = Coordinates.SterographicTo3d(Xcoord, Ycoord, 1, standardParallel, centralMeridian, offsetX, offsetY, mapScale, north).Vector3;
}
vertList.Add(lastItem);
currentIndex++;
lines = false;
}
}
shapeVertexCount = vertList.Count;
shapeFileVertex = new PositionVertexBuffer11(vertList.Count, RenderContext11.PrepDevice);
var verts = (Vector3[])shapeFileVertex.Lock(0, 0); // Lock the buffer (which will return our structs)
var indexer = 0;
foreach (var vert in vertList)
{
verts[indexer++] = vert;
}
shapeFileVertex.Unlock();
shapeIndexCount = indexList.Count;
if (lines)
{
if (indexList.Count > 65500)
{
isLongIndex = true;
shapeFileIndex = new IndexBuffer11(typeof(UInt32), indexList.Count, RenderContext11.PrepDevice);
}
else
{
isLongIndex = false;
shapeFileIndex = new IndexBuffer11(typeof(short), indexList.Count, RenderContext11.PrepDevice);
}
if (isLongIndex)
{
indexer = 0;
var indexes = (UInt32[])shapeFileIndex.Lock();
foreach (var indexVal in indexList)
{
indexes[indexer++] = indexVal;
}
shapeFileIndex.Unlock();
}
else
{
indexer = 0;
var indexes = (short[])shapeFileIndex.Lock();
foreach (var indexVal in indexList)
{
indexes[indexer++] = (short)indexVal;
}
shapeFileIndex.Unlock();
}
}
}
renderContext.DepthStencilMode = DepthStencilMode.Off;
renderContext.BlendMode = BlendMode.Alpha;
SimpleLineShader11.Color = Color.FromArgb((int)(opacity * 255), Color);
var mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
mat.Transpose();
SimpleLineShader11.WVPMatrix = mat;
SimpleLineShader11.CameraPosition = Vector3d.TransformCoordinate(renderContext.CameraPosition, Matrix3d.Invert(renderContext.World)).Vector3;
SimpleLineShader11.ShowFarSide = false;
SimpleLineShader11.Sky = false;
renderContext.SetVertexBuffer(shapeFileVertex);
SimpleLineShader11.Use(renderContext.devContext);
if (lines)
{
renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineList;
renderContext.SetIndexBuffer(shapeFileIndex);
renderContext.devContext.DrawIndexed(shapeFileIndex.Count, 0, 0);
}
else
{
renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList;
renderContext.devContext.Draw(shapeVertexCount, 0);
}
renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
return true;
}
示例5: DrawLines
public void DrawLines(RenderContext11 renderContext, float opacity, Color color)
{
if (linePoints.Count < 2)
{
return;
}
InitLineBuffer();
Matrix3d savedWorld = renderContext.World;
Matrix3d savedView = renderContext.View;
if (localCenter != Vector3d.Empty)
{
usingLocalCenter = true;
Vector3d temp = localCenter;
if (UseNonRotatingFrame)
{
renderContext.World = Matrix3d.Translation(temp) * renderContext.WorldBaseNonRotating * Matrix3d.Translation(-renderContext.CameraPosition);
}
else
{
renderContext.World = Matrix3d.Translation(temp) * renderContext.WorldBase * Matrix3d.Translation(-renderContext.CameraPosition);
}
renderContext.View = Matrix3d.Translation(renderContext.CameraPosition) * renderContext.ViewBase;
}
renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineList;
Color col = Color.FromArgb((int)(color.A * opacity), (int)(color.R * opacity), (int)(color.G * opacity), (int)(color.B * opacity));
SimpleLineShader11.Color = col;
SharpDX.Matrix mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
mat.Transpose();
SimpleLineShader11.WVPMatrix = mat;
SimpleLineShader11.CameraPosition = Vector3d.TransformCoordinate(renderContext.CameraPosition, Matrix3d.Invert(renderContext.World)).Vector3;
SimpleLineShader11.ShowFarSide = true;
SimpleLineShader11.Sky = Sky;
renderContext.setRasterizerState(TriangleCullMode.CullClockwise);
if (DepthBuffered)
{
renderContext.DepthStencilMode = DepthStencilMode.ZReadWrite;
}
else
{
renderContext.DepthStencilMode = DepthStencilMode.Off;
}
SimpleLineShader11.Use(renderContext.devContext);
if (aaFix)
{
renderContext.setRasterizerState(TriangleCullMode.Off, false);
}
foreach (PositionVertexBuffer11 lineBuffer in lineBuffers)
{
renderContext.SetVertexBuffer(lineBuffer);
renderContext.SetIndexBuffer(null);
renderContext.devContext.Draw(lineBuffer.Count, 0);
}
if (aaFix)
{
renderContext.setRasterizerState(TriangleCullMode.Off, true);
}
if (usingLocalCenter)
{
renderContext.World = savedWorld;
renderContext.View = savedView;
}
}
示例6: Draw3D
public override bool Draw3D(RenderContext11 renderContext, float transparancy, Tile parent)
{
InViewFrustum = true;
transparancy = transparancy / 100;
if (transparancy > 1f)
{
transparancy = 1.0f;
}
if (transparancy < 0f)
{
transparancy = 0;
}
if (!ReadyToRender)
{
TileCache.AddTileToQueue(this);
if (texture == null)
{
return false;
}
}
if (!CreateGeometry(renderContext, true))
{
return false;
}
renderContext.MainTexture = texture;
renderContext.SetVertexBuffer(vertexBuffer);
renderContext.SetIndexBuffer(indexBuffer);
renderContext.PreDraw();
renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
renderContext.devContext.DrawIndexed(6, 0, 0);
return true;
}
示例7: RenderPart
public virtual void RenderPart(RenderContext11 renderContext, int part, float opacity, bool combine)
{
int partCount = this.TriangleCount / 4;
TrianglesRendered += partCount;
renderContext.SetIndexBuffer(GetIndexBuffer(part, accomidation));
renderContext.devContext.DrawIndexed(partCount*3, 0, 0);
}
示例8: Draw
public void Draw(RenderContext11 renderContext, int count, Texture11 texture, float opacity, IndexBuffer11 indexBufferIn)
{
setupShader(renderContext, texture, opacity);
count = Math.Min(this.count, count);
switch (renderStrategy)
{
case RenderStrategy.GeometryShader:
renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList;
renderContext.SetVertexBuffer(0, vertexBuffer);
renderContext.SetIndexBuffer(indexBufferIn);
renderContext.devContext.DrawIndexed(count, 0, 0);
renderContext.Device.ImmediateContext.GeometryShader.Set(null);
break;
}
}
示例9: DrawFixedResolutionSphere
public static void DrawFixedResolutionSphere(RenderContext11 renderContext, int sphereIndex)
{
if (sphereVertexBuffers != null && sphereVertexBuffers[sphereIndex] != null)
{
renderContext.Device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
renderContext.Device.ImmediateContext.InputAssembler.InputLayout = renderContext.Shader.inputLayout(PlanetShader11.StandardVertexLayout.PositionNormalTex2);
renderContext.PreDraw();
renderContext.SetVertexBuffer(sphereVertexBuffers[sphereIndex]);
renderContext.SetIndexBuffer(sphereIndexBuffers[sphereIndex]);
renderContext.devContext.DrawIndexed(sphereIndexBuffers[sphereIndex].Count, 0, 0);
}
}
示例10: DrawSphere
//.........這裏部分代碼省略.........
{
var referenceFrameName = Enum.GetName(typeof(SolarSystemObjects), (SolarSystemObjects)planetID);
foreach (var layer in LayerManager.AllMaps[referenceFrameName].Layers)
{
if (layer.Enabled && layer is ImageSetLayer)
{
if (((ImageSetLayer)layer).OverrideDefaultLayer)
{
defaultLayer = ((ImageSetLayer)layer).ImageSet;
defaultLayerColor = layer.Color;
useMultires = true;
break;
}
}
}
}
if (useMultires)
{
renderContext.DepthStencilMode = DepthStencilMode.ZReadWrite;
if (sphereIndex < 4)
{
IImageSet planet = null;
if (defaultLayer != null)
{
planet = defaultLayer;
}
else
{
var planetName = GetNameFrom3dId(planetID);
var imageSetName = planetName == "Mars" ? "Visible Imagery" : planetName;
planet = Earth3d.MainWindow.GetImagesetByName(imageSetName);
}
if (planet != null)
{
var normColor = new Vector4(defaultLayerColor.R, defaultLayerColor.G, defaultLayerColor.B, defaultLayerColor.A) * (1.0f / 255.0f);
if (RenderContext11.sRGB)
{
normColor.X = (float) Math.Pow(normColor.X, 2.2);
normColor.Y = (float)Math.Pow(normColor.Y, 2.2);
normColor.Z = (float)Math.Pow(normColor.Z, 2.2);
}
renderContext.Shader.DiffuseColor = normColor;
renderContext.setRasterizerState(TriangleCullMode.CullClockwise);
Earth3d.MainWindow.DrawTiledSphere(planet, 100, Color.White);
if (planetID == (int)SolarSystemObjects.Earth && Settings.Active.ShowClouds)
{
if (CloudTexture != null)
{
var cloudShaderKey = new PlanetShaderKey(PlanetSurfaceStyle.Diffuse, Settings.Active.ShowEarthSky, 0);
cloudShaderKey.eclipseShadowCount = shaderKey.eclipseShadowCount;
cloudShaderKey.HasAtmosphere = shaderKey.HasAtmosphere;
if (!Settings.Active.SolarSystemLighting)
{
cloudShaderKey.style = PlanetSurfaceStyle.Emissive;
}
SetupPlanetSurfaceEffect(renderContext, cloudShaderKey, 1.0f);
SetAtmosphereConstants(renderContext, planetID, 1.0f, CalcSkyGeometryHeight(planetID));
renderContext.MainTexture = CloudTexture;
var savedWorld = renderContext.World;
var cloudScale = 1.0 + (EarthCloudHeightMeters) / 6378100.0;
renderContext.World = Matrix3d.Scaling(cloudScale, cloudScale, cloudScale) * renderContext.World;
renderContext.setRasterizerState(TriangleCullMode.CullCounterClockwise);
renderContext.DepthStencilMode = DepthStencilMode.Off;
renderContext.BlendMode = BlendMode.Alpha;
DrawFixedResolutionSphere(renderContext, sphereIndex);
renderContext.World = savedWorld;
renderContext.DepthStencilMode = DepthStencilMode.ZReadWrite;
renderContext.BlendMode = BlendMode.None;
}
}
return;
}
}
}
renderContext.MainTexture = texture;
renderContext.Device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
renderContext.Device.ImmediateContext.InputAssembler.InputLayout = renderContext.Shader.inputLayout(PlanetShader11.StandardVertexLayout.PositionNormalTex2);
renderContext.PreDraw();
renderContext.SetVertexBuffer(sphereVertexBuffers[sphereIndex]);
renderContext.SetIndexBuffer(sphereIndexBuffers[sphereIndex]);
renderContext.devContext.DrawIndexed(sphereIndexBuffers[sphereIndex].Count, 0, 0);
}