Mesh (VertexBuffer) movement 
Author Message
 Mesh (VertexBuffer) movement

As a preface, I'm sure this is a stupid question...

I was fooling around with DirectX, following tutorials,
etc.

I load a mesh:

 Set g_Mesh = (LoadMesh....)

etc,

I want to move the vertices (more precisly i want to move
the entire modeled object)

This is my problem
(not exact code, just to give the idea)

[user presses left key]...then

(3DXMeshVertexBuffer8GetData into V())

    For i = 0 To modP.g_Mesh.GetNumVertices

        V(i).y = V(i).y + 50
    Next i

(D3DXMeshVertexBuffer8SetData V())

In my head, I think that if every vertex is moved 50 units
in the +y direction, the entire rendered mesh should move
50 units....but thats not what happens.  The model appears
to stretch in that direction instead.

How would you take the vertex data from a mesh and
translate it?  And what does adding 50 to the y component
of every vertex really do?

I thank anyone in advance for thier time....

Doug



Tue, 08 Feb 2005 07:56:48 GMT  
 Mesh (VertexBuffer) movement
I think I am on the right track of what is going on..

g_Mesh.GetFVF is D3DFVF_NORMAL Or D3DFVF_XYZ

MY array of vertices is dimmed as D3DVERTEX

Soooo....if the size of a (D3DFVF_NORMAL or D3DFVF_XYZ) is
different I wouldnt be getting every vertex...hence
stretching.

Any thoughts?

Quote:
>-----Original Message-----
>As a preface, I'm sure this is a stupid question...

>I was fooling around with DirectX, following tutorials,
>etc.

>I load a mesh:

> Set g_Mesh = (LoadMesh....)

>etc,

>I want to move the vertices (more precisly i want to move
>the entire modeled object)

>This is my problem
>(not exact code, just to give the idea)

>[user presses left key]...then

>(3DXMeshVertexBuffer8GetData into V())

>    For i = 0 To modP.g_Mesh.GetNumVertices

>        V(i).y = V(i).y + 50
>    Next i

>(D3DXMeshVertexBuffer8SetData V())

>In my head, I think that if every vertex is moved 50
units
>in the +y direction, the entire rendered mesh should move
>50 units....but thats not what happens.  The model
appears
>to stretch in that direction instead.

>How would you take the vertex data from a mesh and
>translate it?  And what does adding 50 to the y component
>of every vertex really do?

>I thank anyone in advance for thier time....

>Doug
>.



Tue, 08 Feb 2005 08:22:24 GMT  
 Mesh (VertexBuffer) movement
That was it

Instead of

V() as D3DVERTEX

Private Type MeshVertex
   x as single
   y as single
   z as single
   normal as D3DVECTOR
end type
V() as MeshVertex

As a side note, how would one know to make the positional
x,y,z first?  How does a developer know that the normal
vector data is after the positional?

I assume
Private Type MeshVertex
   normal as D3DVECTOR
   x as single
   y as single
   z as single
end type
wouldnt work, since when I changed y I would actually be
changing the y component of the normal.

Quote:
>-----Original Message-----
>As a preface, I'm sure this is a stupid question...

>I was fooling around with DirectX, following tutorials,
>etc.

>I load a mesh:

> Set g_Mesh = (LoadMesh....)

>etc,

>I want to move the vertices (more precisly i want to move
>the entire modeled object)

>This is my problem
>(not exact code, just to give the idea)

>[user presses left key]...then

>(3DXMeshVertexBuffer8GetData into V())

>    For i = 0 To modP.g_Mesh.GetNumVertices

>        V(i).y = V(i).y + 50
>    Next i

>(D3DXMeshVertexBuffer8SetData V())

>In my head, I think that if every vertex is moved 50
units
>in the +y direction, the entire rendered mesh should move
>50 units....but thats not what happens.  The model
appears
>to stretch in that direction instead.

>How would you take the vertex data from a mesh and
>translate it?  And what does adding 50 to the y component
>of every vertex really do?

>I thank anyone in advance for thier time....

>Doug
>.



Tue, 08 Feb 2005 08:28:07 GMT  
 Mesh (VertexBuffer) movement
- Set world matrix on device
- render mesh
- translate world matrix to new location in world space and set on device
- render mesh again
- repeat

It will be very slow touching every vertex in a large mesh.

--
Eric DeBrosse
http://www.mvps.org/vbdx/
Microsoft Visual Basic DirectX MVP

The opinions expressed in this message are my own personal views and
do not reflect the official views of Microsoft Corporation. The MVP program
does not constitute employment or contractual obligation with Microsoft.


Quote:
> I think I am on the right track of what is going on..

> g_Mesh.GetFVF is D3DFVF_NORMAL Or D3DFVF_XYZ

> MY array of vertices is dimmed as D3DVERTEX

> Soooo....if the size of a (D3DFVF_NORMAL or D3DFVF_XYZ) is
> different I wouldnt be getting every vertex...hence
> stretching.

> Any thoughts?

> >-----Original Message-----
> >As a preface, I'm sure this is a stupid question...

> >I was fooling around with DirectX, following tutorials,
> >etc.

> >I load a mesh:

> > Set g_Mesh = (LoadMesh....)

> >etc,

> >I want to move the vertices (more precisly i want to move
> >the entire modeled object)

> >This is my problem
> >(not exact code, just to give the idea)

> >[user presses left key]...then

> >(3DXMeshVertexBuffer8GetData into V())

> >    For i = 0 To modP.g_Mesh.GetNumVertices

> >        V(i).y = V(i).y + 50
> >    Next i

> >(D3DXMeshVertexBuffer8SetData V())

> >In my head, I think that if every vertex is moved 50
> units
> >in the +y direction, the entire rendered mesh should move
> >50 units....but thats not what happens.  The model
> appears
> >to stretch in that direction instead.

> >How would you take the vertex data from a mesh and
> >translate it?  And what does adding 50 to the y component
> >of every vertex really do?

> >I thank anyone in advance for thier time....

> >Doug
> >.



Tue, 08 Feb 2005 08:40:21 GMT  
 Mesh (VertexBuffer) movement
Hey...thanks for the reponse.

I apologize again for the newbieness...

I see how that would be best for a single mesh, but how
would that effect multiple meshes that move indepentently
in world space?

Do you set world, render mesh 1, translate world
(to "move" mesh 1), render mesh 2 in this newly translated
world, then translate world again to move mesh 2?  (That
made no sense... :)  )

For instance if you wanted two meshes to get closer to
each other every time I press a key. I would think you
would need to set new vertices on one or both meshes to
make them move in world space....but I look forward to
your comments.

Quote:
>-----Original Message-----
>- Set world matrix on device
>- render mesh
>- translate world matrix to new location in world space
and set on device
>- render mesh again
>- repeat

>It will be very slow touching every vertex in a large
mesh.

>--
>Eric DeBrosse
>http://www.mvps.org/vbdx/
>Microsoft Visual Basic DirectX MVP

>The opinions expressed in this message are my own
personal views and
>do not reflect the official views of Microsoft

Corporation. The MVP program

- Show quoted text -

Quote:
>does not constitute employment or contractual obligation
with Microsoft.



>> I think I am on the right track of what is going on..

>> g_Mesh.GetFVF is D3DFVF_NORMAL Or D3DFVF_XYZ

>> MY array of vertices is dimmed as D3DVERTEX

>> Soooo....if the size of a (D3DFVF_NORMAL or D3DFVF_XYZ)
is
>> different I wouldnt be getting every vertex...hence
>> stretching.

>> Any thoughts?

>> >-----Original Message-----
>> >As a preface, I'm sure this is a stupid question...

>> >I was fooling around with DirectX, following tutorials,
>> >etc.

>> >I load a mesh:

>> > Set g_Mesh = (LoadMesh....)

>> >etc,

>> >I want to move the vertices (more precisly i want to
move
>> >the entire modeled object)

>> >This is my problem
>> >(not exact code, just to give the idea)

>> >[user presses left key]...then

>> >(3DXMeshVertexBuffer8GetData into V())

>> >    For i = 0 To modP.g_Mesh.GetNumVertices

>> >        V(i).y = V(i).y + 50
>> >    Next i

>> >(D3DXMeshVertexBuffer8SetData V())

>> >In my head, I think that if every vertex is moved 50
>> units
>> >in the +y direction, the entire rendered mesh should
move
>> >50 units....but thats not what happens.  The model
>> appears
>> >to stretch in that direction instead.

>> >How would you take the vertex data from a mesh and
>> >translate it?  And what does adding 50 to the y
component
>> >of every vertex really do?

>> >I thank anyone in advance for thier time....

>> >Doug
>> >.

>.



Tue, 08 Feb 2005 09:30:55 GMT  
 Mesh (VertexBuffer) movement
I'm no expert but using the flexible vertex formats requires the data in
memory to be in a specific order.  The help topic Vertex Formats  explains
it all and is found in the following url (adjust to suit your system).

r
ogrammersGuide
/UsingDirect3D/VertexData/FixedFunction/VertexFormats/VFormats.htm

Happy reading.
Bruce


Quote:
> That was it

> Instead of

> V() as D3DVERTEX

> Private Type MeshVertex
>    x as single
>    y as single
>    z as single
>    normal as D3DVECTOR
> end type
> V() as MeshVertex

> As a side note, how would one know to make the positional
> x,y,z first?  How does a developer know that the normal
> vector data is after the positional?

> I assume
> Private Type MeshVertex
>    normal as D3DVECTOR
>    x as single
>    y as single
>    z as single
> end type
> wouldnt work, since when I changed y I would actually be
> changing the y component of the normal.

> >-----Original Message-----
> >As a preface, I'm sure this is a stupid question...

> >I was fooling around with DirectX, following tutorials,
> >etc.

> >I load a mesh:

> > Set g_Mesh = (LoadMesh....)

> >etc,

> >I want to move the vertices (more precisly i want to move
> >the entire modeled object)

> >This is my problem
> >(not exact code, just to give the idea)

> >[user presses left key]...then

> >(3DXMeshVertexBuffer8GetData into V())

> >    For i = 0 To modP.g_Mesh.GetNumVertices

> >        V(i).y = V(i).y + 50
> >    Next i

> >(D3DXMeshVertexBuffer8SetData V())

> >In my head, I think that if every vertex is moved 50
> units
> >in the +y direction, the entire rendered mesh should move
> >50 units....but thats not what happens.  The model
> appears
> >to stretch in that direction instead.

> >How would you take the vertex data from a mesh and
> >translate it?  And what does adding 50 to the y component
> >of every vertex really do?

> >I thank anyone in advance for thier time....

> >Doug
> >.



Tue, 08 Feb 2005 14:43:49 GMT  
 Mesh (VertexBuffer) movement
use a world transform to position objects.


Quote:
> I think I am on the right track of what is going on..

> g_Mesh.GetFVF is D3DFVF_NORMAL Or D3DFVF_XYZ

> MY array of vertices is dimmed as D3DVERTEX

> Soooo....if the size of a (D3DFVF_NORMAL or D3DFVF_XYZ) is
> different I wouldnt be getting every vertex...hence
> stretching.

> Any thoughts?

> >-----Original Message-----
> >As a preface, I'm sure this is a stupid question...

> >I was fooling around with DirectX, following tutorials,
> >etc.

> >I load a mesh:

> > Set g_Mesh = (LoadMesh....)

> >etc,

> >I want to move the vertices (more precisly i want to move
> >the entire modeled object)

> >This is my problem
> >(not exact code, just to give the idea)

> >[user presses left key]...then

> >(3DXMeshVertexBuffer8GetData into V())

> >    For i = 0 To modP.g_Mesh.GetNumVertices

> >        V(i).y = V(i).y + 50
> >    Next i

> >(D3DXMeshVertexBuffer8SetData V())

> >In my head, I think that if every vertex is moved 50
> units
> >in the +y direction, the entire rendered mesh should move
> >50 units....but thats not what happens.  The model
> appears
> >to stretch in that direction instead.

> >How would you take the vertex data from a mesh and
> >translate it?  And what does adding 50 to the y component
> >of every vertex really do?

> >I thank anyone in advance for thier time....

> >Doug
> >.



Tue, 08 Mar 2005 01:55:56 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Mesh Names or Mesh Subset Names

2. Mesh Picking, Boned Animation, Faked Meshes

3. Progressive meshes / Simplifying meshes

4. Capturing Mouse Movement Before Pointer Movement

5. Capturing Mouse Movement Before Pointer Movement

6. Capturing Mouse Movement Before Pointer Movement

7. vertexbuffer and dx9

8. Filling Vertexbuffers

9. Strange error message creating vertexbuffer

10. Mesh generation

11. Shaded Mesh over VB5 forms?

12. How to get the W component from a Mesh

 

 
Powered by phpBB® Forum Software