dx9 help [SOLVED]

Just starting out? Need help? Post your questions and find answers here.
spike0314
User
User
Posts: 17
Joined: Wed Oct 24, 2007 12:28 pm

dx9 help [SOLVED]

Post by spike0314 »

Hi all
im trying to use Dx9 to create a Mesh but i can seem to get this peace of code to work. ( :( ive been at this peace of code four 2 days now :( :( )

Code: Select all

LocalMesh.ID3DXMesh

 Dim vertices.MYVERTEX(3)

  vertices(0)\x = 0.0
  vertices(0)\y = 10.0
  vertices(0)\z = 50
  vertices(0)\color = D3DCOLOR_ARGB(255,255,0,0)


  vertices(1)\x = 10.0
  vertices(1)\y = 0.0
  vertices(1)\z = 50
vertices(1)\color = D3DCOLOR_ARGB(255,0,255,0)
  
  vertices(2)\x = -10.0
  vertices(2)\y = 0.0
  vertices(2)\z = 50
    vertices(2)\color = D3DCOLOR_ARGB(255,0,0,255)

 D3DXCreateMeshFVF(1,3,#D3DXMESH_MANAGED ,#D3DFVF_XYZ | #D3DFVF_DIFFUSE,MMS_D3DDEVICE , @LocalMesh)

Protected *pVertices=0  
LocalMesh\LockVertexBuffer(0 , @*pVertices)
CopyMemory(@vertices(),*pVertices, 3*16)
    
LocalMesh\UnlockVertexBuffer()
all it does is use the first vertexbut will not add 1 or 2.
Last edited by spike0314 on Thu Apr 10, 2008 6:22 pm, edited 1 time in total.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

you only dim 3 places in your array 0 - 3, you call for 12

You could use a 3d array and tell the 0,0 0,1 0,2 0,3 :: 1,0 1,1 1,2 1,3 :: 2,0 2,1 2,2 2,3 the values and then pop them out...
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
spike0314
User
User
Posts: 17
Joined: Wed Oct 24, 2007 12:28 pm

Post by spike0314 »

Im sorry i dont under stand what you mean?? :oops:
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

I think he means it should be this:

Code: Select all

Dim vertices.MYVERTEX(11)

and not...

Dim vertices.MYVERTEX(3)

Last edited by SFSxOI on Wed Apr 09, 2008 9:36 pm, edited 2 times in total.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Presumably MYVERTEX is a structure used to assign 4 variables so there is in fact nothing wrong with the dim().
spike0314
User
User
Posts: 17
Joined: Wed Oct 24, 2007 12:28 pm

Post by spike0314 »

MYVERTEX is a structure

and this is the structure layout

Code: Select all

Structure MYVERTEX
    x.f
    y.f
    z.f
    color.l
EndStructure

I think the problem lies with-in "*pVertices" as it only adds vertices(0) to the mesh.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

Yep, what happens when you try

Code: Select all

Dim vertices.MYVERTEX(11)
spike0314
User
User
Posts: 17
Joined: Wed Oct 24, 2007 12:28 pm

Post by spike0314 »

same only shows vertices(0) :(
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

Have you tried the other functions of the interface, to check whether you are just reading it back incorrectly?

For example, what do

LocalMesh\GetNumBytesPerVertex()

and

LocalMesh\GetNumVertices()

give as results?
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
spike0314
User
User
Posts: 17
Joined: Wed Oct 24, 2007 12:28 pm

Post by spike0314 »

ok this is ding my head in now.

@Tinman
i have tryed LocalMesh\GetNumVertices() but that will always just return the number that is in D3DXCreateMeshFVF(faces,vertex)
so it will return 3.

as for LocalMesh\GetNumBytesPerVertex() that returns 16 as it's the size of the structure.

I have sent this screenshot of my results:
Image

and i have also used this command in the main loop

Code: Select all

D3DDEVICE\SetRenderState(#D3DRS_FILLMODE,   #D3DFILL_POINT )
spike0314
User
User
Posts: 17
Joined: Wed Oct 24, 2007 12:28 pm

Post by spike0314 »

:D :D :D I found my problem.

The way it works is if you dont render the face's it will only show 1 vertex
:oops:
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

??
can you post the complete code?
spike0314
User
User
Posts: 17
Joined: Wed Oct 24, 2007 12:28 pm

Post by spike0314 »

here is the code:

Code: Select all


localmesh.ID3DXMesh

Structure MYVERTEX
    x.f
    y.f
    z.f
    color.l
EndStructure

Dim vertices.MYVERTEX(3)

  vertices(0)\x = 0.0
  vertices(0)\y = 10.0
  vertices(0)\z = 50
  vertices(0)\color = D3DCOLOR_ARGB(255,255,0,0)


  vertices(1)\x = 10.0
  vertices(1)\y = 0.0
  vertices(1)\z = 50
  vertices(1)\color = D3DCOLOR_ARGB(255,0,255,0)
  
  vertices(2)\x = -10.0
  vertices(2)\y = 0.0
  vertices(2)\z = 50
  vertices(2)\color = D3DCOLOR_ARGB(255,0,0,255)
  
 
 D3DXCreateMeshFVF(1,3,#D3DXMESH_MANAGED |#D3DXMESH_32BIT ,#D3DFVF_XYZ | #D3DFVF_DIFFUSE,MMS_D3DDEVICE , @LocalMesh)

*pVert=#Null

  *pVBuf.IDIRECT3DVERTEXBUFFER9;
 LocalMesh\GetVertexBuffer(@*pVBuf)
  *pVBuf\Lock( 0, 0, @*pVert, 0 )
      CopyMemory(vertices(),*pVert,3* SizeOf(MYVERTEX))

  	  Debug PeekF(*pVert)
	  Debug PeekF(*pVert+4)
	  Debug PeekF(*pVert+8)
	  Debug PeekL(*pVert+12)
	    
  	  Debug PeekF(*pVert+16)
	  Debug PeekF(*pVert+20)
	  Debug PeekF(*pVert+24)
	  Debug PeekL(*pVert+28)
	    
	  Debug PeekF(*pVert+32)
	  Debug PeekF(*pVert+36)
	  Debug PeekF(*pVert+40)
	  Debug PeekL(*pVert+44)  
	  
*pVBuf\Unlock()
*pVBuf\Release()

*pInd=#Null
LocalMesh\LockIndexBuffer(#D3DLOCK_DISCARD,@*pInd)
      PokeL(*pInd,0)
      PokeL(*pInd+4,1)
      PokeL(*pInd+8,2)
LocalMesh\UnlockIndexBuffer();
hope that helps
Post Reply