本文整理汇总了C#中TerraViewer.RenderContext11.SetVertexBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# RenderContext11.SetVertexBuffer方法的具体用法?C# RenderContext11.SetVertexBuffer怎么用?C# RenderContext11.SetVertexBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TerraViewer.RenderContext11
的用法示例。
在下文中一共展示了RenderContext11.SetVertexBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public static void Draw(RenderContext11 renderContext, PositionColoredTextured[] points, int count, Texture11 texture, SharpDX.Direct3D.PrimitiveTopology primitiveType, float opacity = 1.0f)
{
if (VertexBuffer == null)
{
VertexBuffer = new Buffer(renderContext.Device, System.Runtime.InteropServices.Marshal.SizeOf(points[0]) * 2500, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, System.Runtime.InteropServices.Marshal.SizeOf(points[0]));
VertexBufferBinding = new VertexBufferBinding(VertexBuffer, System.Runtime.InteropServices.Marshal.SizeOf((points[0])), 0);
}
renderContext.devContext.InputAssembler.PrimitiveTopology = primitiveType;
renderContext.BlendMode = BlendMode.Alpha;
renderContext.setRasterizerState(TriangleCullMode.Off);
SharpDX.Matrix mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
mat.Transpose();
WarpOutputShader.MatWVP = mat;
WarpOutputShader.Use(renderContext.devContext, texture != null, opacity);
renderContext.SetVertexBuffer(VertexBufferBinding);
DataBox box = renderContext.devContext.MapSubresource(VertexBuffer, 0, MapMode.WriteDiscard, MapFlags.None);
Utilities.Write(box.DataPointer, points, 0, count);
renderContext.devContext.UnmapSubresource(VertexBuffer, 0);
if (texture != null)
{
renderContext.devContext.PixelShader.SetShaderResource(0, texture.ResourceView);
}
else
{
renderContext.devContext.PixelShader.SetShaderResource(0, null);
}
renderContext.devContext.Draw(count, 0);
}
示例2: DrawEllipse
// Draw an ellipse with the specified semi-major axis and eccentricity. The orbit is drawn over a single period,
// fading from full brightness at the given eccentric anomaly.
//
// In order to match exactly the position at which a planet is drawn, the planet's position at the current time
// must be passed as a parameter. positionNow is in the current coordinate system of the render context, not the
// translated and rotated system of the orbital plane.
public static void DrawEllipse(RenderContext11 renderContext, double semiMajorAxis, double eccentricity, double eccentricAnomaly, Color color, Matrix3d worldMatrix, Vector3d positionNow)
{
if (ellipseShader == null)
{
ellipseShader = new EllipseShader11();
}
if (ellipseVertexBuffer == null)
{
ellipseVertexBuffer = CreateEllipseVertexBuffer( 500);
}
Matrix3d savedWorld = renderContext.World;
renderContext.World = worldMatrix;
renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineStrip;
renderContext.SetVertexBuffer(ellipseVertexBuffer);
ellipseShader.UseShader(renderContext, semiMajorAxis, eccentricity, eccentricAnomaly, new SharpDX.Color(color.R, color.G, color.B, color.A), savedWorld, positionNow);
renderContext.devContext.Draw(ellipseVertexBuffer.Count, 0);
renderContext.World = savedWorld;
}
示例3: Draw3D
public override bool Draw3D(RenderContext11 renderContext, float opacity, Tile parent)
{
InViewFrustum = true;
RenderedGeneration = CurrentRenderGeneration;
if (!ReadyToRender)
{
TileCache.AddTileToQueue(this);
return false;
}
InViewFrustum = true;
if (starVertexBuffer == null)
{
starProfile = Texture11.FromBitmap( Resources.StarProfile);
var count = stars.Count;
var index = 0;
starCount = count;
starVertexBuffer = new PositionColorSizeVertexBuffer11(count, RenderContext11.PrepDevice);
var points = (PositionColorSize[])starVertexBuffer.Lock(0, 0); // Lock the buffer (which will return our structs)
foreach (var star in stars)
{
var pos = Coordinates.RADecTo3d(star.RA + 12, star.Dec, 1f);
points[index].Position = pos.Vector3;
points[index].Color = star.Col;
var radDec = (.5) / Math.Pow(1.6, star.Magnitude);
points[index].size = (float)radDec;
index++;
}
starVertexBuffer.Unlock();
}
renderContext.SetVertexBuffer(starVertexBuffer);
renderContext.BlendMode = BlendMode.Additive;
renderContext.DepthStencilMode = DepthStencilMode.Off;
renderContext.setRasterizerState(TriangleCullMode.Off);
var mvp = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
mvp.Transpose();
PointSpriteShader11.WVPMatrix = mvp;
PointSpriteShader11.Color = Color.White;
var adjustedScale = (float)(1 / (Earth3d.MainWindow.ZoomFactor / 360));
PointSpriteShader11.ViewportScale = new Vector2((2.0f / renderContext.ViewPort.Width) * adjustedScale, (2.0f / renderContext.ViewPort.Height) * adjustedScale);
PointSpriteShader11.PointScaleFactors = new Vector3(0.0f, 0.0f, 10000.0f);
PointSpriteShader11.Use(renderContext.Device.ImmediateContext);
renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, starProfile.ResourceView);
renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList;
renderContext.devContext.Draw(starCount, 0);
renderContext.Device.ImmediateContext.GeometryShader.Set(null);
// Reset blend mode so we don't mess up subsequent sky layer rendering
renderContext.BlendMode = BlendMode.Alpha;
return true;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
}
示例7: Draw
public void Draw(RenderContext11 renderContext, float opacity, Color color)
{
if (glyphCache == null || glyphCache.Version > glyphVersion)
{
PrepareBatch();
}
Color col = Color.FromArgb((int)(color.A * opacity), (int)(color.R * opacity), (int)(color.G * opacity), (int)(color.B * opacity));
SimpleGeometryShader11.Color = col;
SharpDX.Matrix mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
mat.Transpose();
SimpleGeometryShader11.WVPMatrix = mat;
renderContext.setRasterizerState(TriangleCullMode.CullCounterClockwise);
BlendMode bm = renderContext.BlendMode;
DepthStencilMode dm = renderContext.DepthStencilMode;
//renderContext.DepthStencilMode = DepthStencilMode.ZReadOnly;
renderContext.BlendMode = BlendMode.Alpha;
SimpleGeometryShader11.Use(renderContext.devContext);
renderContext.MainTexture = glyphCache.Texture;
// Debug to get Glyhph textures and caches
// SharpDX.Direct3D11.Texture2D.ToFile(renderContext.devContext, glyphCache.Texture.Texture, SharpDX.Direct3D11.ImageFileFormat.Png, "c:\\temp\\texture2.png");
renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
renderContext.SetVertexBuffer(vertexBuffer);
renderContext.devContext.Draw(vertexBuffer.Count, 0);
renderContext.DepthStencilMode = dm;
renderContext.BlendMode = bm;
//dump cache
// glyphCache.SaveToXML("c:\\temp\\glyphCache.xml");
}
示例8: 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;
}
示例9: Draw3D
//.........这里部分代码省略.........
{
renderPart[childIndex].TargetState = renderPart[childIndex].State = false;
}
if (renderPart[childIndex].TargetState == true || !blendMode)
{
renderPart[childIndex].State = renderPart[childIndex].TargetState;
}
}
else
{
renderPart[childIndex].State = true;
}
if (renderPart[childIndex].State == true)
{
anythingToRender = true;
}
childIndex++;
}
}
if (childRendered || anythingToRender)
{
RenderedAtOrBelowGeneration = CurrentRenderGeneration;
if (parent != null)
{
parent.RenderedAtOrBelowGeneration = RenderedAtOrBelowGeneration;
}
}
if (!anythingToRender)
{
return true;
}
if (!CreateGeometry(renderContext, true))
{
return false;
}
TilesInView++;
if ( wireFrame)
{
renderContext.MainTexture = null;
}
else
{
renderContext.MainTexture = texture;
}
renderContext.SetVertexBuffer(vertexBuffer);
accomidation = ComputeAccomidation();
for (int i = 0; i < 4; i++)
{
if (blendMode) //|| ShowElevation == false)
{
if ((renderPart[i].State && opacity == 1.0) || renderPart[i].TargetState)
{
renderContext.LocalCenter = localCenter;
renderContext.PreDraw();
if (dataset.DataSetType == ImageSetType.Sky)
{
HDRPixelShader.constants.opacity = renderPart[i].Opacity * opacity;
HDRPixelShader.Use(renderContext.devContext);
}
RenderPart(renderContext, i, renderPart[i].Opacity * opacity, false);
}
}
else
{
if (renderPart[i].TargetState)
{
renderContext.LocalCenter = localCenter;
renderContext.PreDraw();
if (dataset.DataSetType == ImageSetType.Sky)
{
HDRPixelShader.constants.opacity = opacity;
HDRPixelShader.Use(renderContext.devContext);
}
RenderPart(renderContext, i, opacity, false);
}
}
}
}
finally
{
if (usingLocalCenter)
{
renderContext.World = savedWorld;
renderContext.View = savedView;
}
}
return true;
}
示例10: 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;
}
}
示例11: DrawEllipse
// This version of DrawEllipse works without a 'head' point
public static void DrawEllipse(RenderContext11 renderContext, double semiMajorAxis, double eccentricity, double eccentricAnomaly, Color color, Matrix3d worldMatrix)
{
if (ellipseShader == null)
{
ellipseShader = new EllipseShader11();
}
if (ellipseWithoutStartPointVertexBuffer == null)
{
ellipseWithoutStartPointVertexBuffer = CreateEllipseVertexBufferWithoutStartPoint(360);
}
var savedWorld = renderContext.World;
renderContext.World = worldMatrix;
renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineStrip;
renderContext.SetVertexBuffer(ellipseWithoutStartPointVertexBuffer);
ellipseShader.UseShader(renderContext, semiMajorAxis, eccentricity, eccentricAnomaly, new SharpDX.Color(color.R, color.G, color.B, color.A), savedWorld, new Vector3d(0.0, 0.0, 0.0));
renderContext.devContext.Draw(ellipseWithoutStartPointVertexBuffer.Count, 0);
renderContext.World = savedWorld;
}
示例12: render
public void render(RenderContext11 renderContext, Color color, Matrix3d worldMatrix, double jd, Vector3d positionNow, double duration)
{
duration = pathDuration;
if (vertexBuffer != null)
{
var dt = coverageDuration / ((int) pointCount - 1);
var t0 = points[0].jd;
var firstPoint = (int)Math.Floor((t0 - jd) / dt);
firstPoint = Math.Max(0, firstPoint);
var lastPoint = (int)Math.Floor((t0 - (jd - duration)) / dt);
lastPoint = Math.Min(points.Length - 1, lastPoint);
var drawCount = lastPoint - firstPoint;
var timeOffset = (t0 - jd) / coverageDuration;
var savedWorld = renderContext.World;
renderContext.World = worldMatrix;
renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineStrip;
OrbitTraceShader.UseShader(renderContext, new SharpDX.Color(color.R, color.G, color.B, color.A), savedWorld, positionNow, timeOffset, 1.5);
renderContext.SetVertexBuffer(vertexBuffer);
renderContext.Device.ImmediateContext.Draw(drawCount, firstPoint);
renderContext.World = savedWorld;
}
}
示例13: 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);
}
}
示例14: 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;
}
示例15: DrawLabels
public void DrawLabels(RenderContext11 renderContext)
{
if (positions.Count < 1)
{
return;
}
InitLabelBuffer();
renderContext.SetVertexBuffer(labelBuffer);
renderContext.BlendMode = BlendMode.Alpha;
renderContext.DepthStencilMode = DepthStencilMode.Off;
renderContext.setRasterizerState(TriangleCullMode.Off);
var mvp = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
mvp.Transpose();
PointSpriteShader11.WVPMatrix = mvp;
PointSpriteShader11.Color = SharpDX.Color.White;
var adjustedScale = .01f; // (float)(1 / (Earth3d.MainWindow.ZoomFactor / 360));
PointSpriteShader11.ViewportScale = new Vector2((2.0f / renderContext.ViewPort.Width) * adjustedScale, (2.0f / renderContext.ViewPort.Height) * adjustedScale);
PointSpriteShader11.PointScaleFactors = new Vector3(0.0f, 0.0f, 10000.0f);
PointSpriteShader11.Use(renderContext.Device.ImmediateContext);
renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, texture.ResourceView);
renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList;
renderContext.devContext.Draw(labelBuffer.Count, 0);
renderContext.Device.ImmediateContext.GeometryShader.Set(null);
}