在三維空間中移動物體,我的最直接的想法就是改變物體的坐标,這也是我弄懂一些三維空間中坐标關系後的唯一抓手,這也是之前經常導入模型确顯示不了的根本問題,畢竟三維模型不由我控制,不過得實話實說,我真心控制不了,對 3dmax 真是一知半解,有機會一定要加強一下。
感覺頻繁的建立、删除頂點緩存,是否太過浪費資源,耗費保貴的時間呢?是以,在官方網站一頓狂查亂猜,終于找到這麼個有點靠譜的家夥來幫幫忙,大家研究後,發現它隻能更新其中一部分頂點的坐标,而不能把整體進行偏移,這個可能真的不适合用于移動物體時,對整體坐标的一緻偏移量增減了。
換個角度......
寫部落格就這點好,邊寫着,邊像是有人在看一樣,思路總會源源不斷地湧現出來!
N久後,
是否可以移動坐标原點呢?
但坐标原點移動了,其它物體也有了偏 移量的增減,這也是行不通的。
簡單地說,我能和GPU互動的,隻是給這一堆資料,這堆資料看似雜亂,但都是從實際的三維坐标系中取出來的物體的頂點的實際坐标,且我要求3D美工把物體中心放在坐标原點,一是,初始不需要任何偏移;二是,導進來,我就釘死這個物體在螢幕中心,必何我能看到它,這也是N久以來“血”的教訓的結果;
有些東西确實不需要強制這樣或那樣,但沒有約定,就會出現多種可能,我沒那麼多時間去解決這些可能性,因為我的目标不在那裡,是以我需要排除這些幹撓因素,直奔主題,那麼有些實踐得來的方法,雖然在明眼人看來有些愚蠢,但對我來說,是解決問題的良藥,至少是目前來說。
好啦,還是沒有好辦法,那我還是用同樣,在明眼人看來是愚蠢的方法來做我需要完成的事情,也許以後會發現新大陸,但至少目前來說,我隻能在這塊在我看來肥沃的土地上種我的菜,打我的糧,就這麼簡單。
複雜的事情,簡單處理,雖然稍顯愚蠢,但目前的條件下能達到目的,就是明智之舉!您說不是嗎?!
如您确實看不過眼兒了,真心歡迎指教,謝謝了先。
glBufferSubData — 更新緩存對象資料存儲的一部分 update a subset of a buffer object's data store
<code>void glBufferSubData(</code>
GLenum target,
GLintptr offset,
GLsizeiptr size,
const GLvoid * data<code>)</code>;
<a target="_blank"></a>
<dl></dl>
<dt><code>target</code></dt>
<dd></dd>
Specifies the target buffer object. The symbolic constant must be <code>GL_ARRAY_BUFFER</code> or <code>GL_ELEMENT_ARRAY_BUFFER</code>.
<dt><code>offset</code></dt>
Specifies the offset into the buffer object's data store where data replacement will begin, measured in bytes.
<dt><code>size</code></dt>
Specifies the size in bytes of the data store region being replaced.
<dt><code>data</code></dt>
Specifies a pointer to the new data that will be copied into the data store.
<code>glBufferSubData</code> redefines some or all of the data store for the buffer object currently bound to <code>target</code>. Data starting at byte offset <code>offset</code> and
extending for <code>size</code> bytes is copied to the data store from the memory pointed to by <code>data</code>. An error is thrown if <code>offset</code> and <code>size</code> together
define a range beyond the bounds of the buffer object's data store.
When replacing the entire data store, consider using <code>glBufferSubData</code> rather than completely recreating the data store with <code>glBufferData</code>. This avoids the cost of reallocating the data store.
Consider using multiple buffer objects to avoid stalling the rendering pipeline during data store updates. If any rendering in the pipeline makes reference to data in the buffer object being updated by <code>glBufferSubData</code>, especially
from the specific region being updated, that rendering must drain from the pipeline before the data store can be updated.
Clients must align data elements consistent with the requirements of the client platform, with an additional base-level requirement that an offset within a buffer to a datum comprising N be a multiple of N.
<code>GL_INVALID_ENUM</code> is generated if <code>target</code> is not <code>GL_ARRAY_BUFFER</code> or <code>GL_ELEMENT_ARRAY_BUFFER</code>.
<code>GL_INVALID_VALUE</code> is generated if <code>offset</code> or <code>size</code> is negative, or if together they define
a region of memory that extends beyond the buffer object's allocated data store.
<code>GL_INVALID_OPERATION</code> is generated if the reserved buffer object name 0 is bound to <code>target</code>.