首页 \ 问答 \ DirectX 9.0顶点缓冲区更新(DirectX 9.0 vertex buffer updating)

DirectX 9.0顶点缓冲区更新(DirectX 9.0 vertex buffer updating)

我使用DirectX 9.0制作了一个小型3D查看器应用程序。 现在我想添加一些编辑功能。 假设我想编辑一个大的多边形。 当用户编辑形状时,将添加,删除和移动顶点。 现在,每个多边形都存储为顶点缓冲区。 我的问题是,在用户编辑形状时存储和显示形状的最佳方法是什么? 如果我每次发生变化时都会破坏并重新创建顶点缓冲区,我相信它会过于耗费资源并且不够理想。

我虽然我也应该在主帖上问我的问题,所以他们在这里:

我有三个不同的任务,其中两个我不知道如何实现:
1)编辑顶点:简单,我将用VB中的新位置更新旧顶点。
2)删除顶点:这里发生了什么? 如何在不创建新VB的情况下删除它? 我应该添加一个空白的VB吗?
3)添加顶点:这里怎么样? 我可以更改动态VB的长度并在末尾添加顶点吗?

我认为另一个想法会起作用:
1)编辑很容易
2)删除只意味着我将覆盖已删除的顶点,可能是前一个或下一个顶点的位置,因此它将不可见。
3)Addition将创建一个新的顶点缓冲区,但会像Vector或List一样调整大小。 每次重新创建它的大小都会是这样的
NewSize = OldSize * 1.1(增加10%)
所以连续添加不必重新创建VB。
所以1和2永远不会创建一个新的VB,3有时可能创建一个。 这听起来怎么样?


I've made a small 3D viewer application using DirectX 9.0. Now I would like to add some editing functionality. Suppose that I want to edit a large polygon. While the user edits the shape, vertices would be added, deleted and moved. Right now each polygon is stored as a vertex buffer. My question is, what is the best way to store and display the shape while the user edits it? If i destroy and re-create the vertex buffer each time a change happens, I believe it will be too resource intensive and suboptimal.

I though I should ask my questions in the main post as well so here they are :

I have three different tasks, two of which I don't know how to implement :
1) Editing a vertex : Easy, I will just update the old vertex with the new position in the VB.
2) Deleting a vertex : What happens here? How do I remove it without creating a new VB? Should I just add a blank VB?
3) Adding a vertex : What about here? Can I change the length of a dynamic VB and add vertices at the end?

Another thought here that I believe would work :
1) Editing is easy
2) Deleting would just mean that I will overwrite the deleted vertex with possibly the position of the previous or the next vertex, so it will not be visible.
3) Addition will create a new vertex buffer, but will resize like a Vector or a List. Each time it's re-created it's size would be something like
NewSize = OldSize * 1.1 (adding 10% more)
so that successive additions do not have to re-create the VB.
So 1 & 2 never create a new VB and 3 might sometimes create one. How does this sound?


原文:https://stackoverflow.com/questions/9537837
更新时间:2023-04-26 21:04

最满意答案

您可以从Binding派生一个类来预设ConverterCulture,并使用它来代替原始绑定,例如

    Public Class Binding
        Inherits System.Windows.Data.Binding

        Public Sub New()
            MyBase.New()
            ConverterCulture = System.Globalization.CultureInfo.CurrentCulture
        End Sub
        Public Sub New(ByVal path As String)
            MyBase.New(path)
            ConverterCulture = System.Globalization.CultureInfo.CurrentCulture
       End Sub
    End Class

<TextBlock Text="{my:Binding TimeTest, StringFormat=t}" />

您也可以尝试自定义StringFormat,例如StringFormat ='HH:mm'


You can derive a class from Binding which presets the ConverterCulture, and use this instead of the original binding, like

    Public Class Binding
        Inherits System.Windows.Data.Binding

        Public Sub New()
            MyBase.New()
            ConverterCulture = System.Globalization.CultureInfo.CurrentCulture
        End Sub
        Public Sub New(ByVal path As String)
            MyBase.New(path)
            ConverterCulture = System.Globalization.CultureInfo.CurrentCulture
       End Sub
    End Class

and

<TextBlock Text="{my:Binding TimeTest, StringFormat=t}" />

You might also try a custom StringFormat, like StringFormat='HH:mm'

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。