Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 CreateFlags.TriangleStrip

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
The Pentium Guy Posted - Mar 21 2004 : 12:35:33 PM
hey, i tried making a function that creates a cube easily, unfortunately, the compiler doesnt like the number of primitaves i provided(a cube has 6 faces, thus 12 vertices..)

here's my function

[vb]

Public Function CreateCube(ByVal TopLeftPos As Vector3, ByVal Width As Integer, ByVal Height As Integer, ByVal Depth As Integer, ByVal ImageLocation As String) As CustomVertex.PositionTextured


Dim vertices() As CustomVertex.PositionTextured
Dim ColorKeyVal As Color = Color.FromArgb(255, 0, 255, 0) 'LimeGreen

Try

SprTexture = TextureLoader.FromFile(d3ddev, ImageLocation)

VertBuffer = New VertexBuffer(GetType(CustomVertex.PositionTextured), 8, d3ddev, Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default)


vertices = VertBuffer.Lock(0, 0)

'-----------------------------
' Front face - The Z's are the same
'Top Left
vertices(0) = CreateFlexVertex(TopLeftPos.X, TopLeftPos.Y, TopLeftPos.Z, 0, 0)
'Bottom Left
vertices(1) = CreateFlexVertex(TopLeftPos.X, TopLeftPos.Y + Height, TopLeftPos.Z, 0, 1)
'Top Right
vertices(2) = CreateFlexVertex(TopLeftPos.X + Width, TopLeftPos.Y, TopLeftPos.Z, 1, 0)
'Bottom Right
vertices(3) = CreateFlexVertex(TopLeftPos.X + Width, TopLeftPos.Y + Height, TopLeftPos.Z, 1, 1)
'------------------------------



'-----------------------------
' Top face - The Y's are the same
'***Note: The Front Face's Top Left and Top Right are shared by the Top Face's Bottom Left and Bottom Right, so we don't need them
'
'Top Left(Prentend you're looking at this face from the top)
vertices(4) = CreateFlexVertex(TopLeftPos.X, TopLeftPos.Y, TopLeftPos.Z + Depth, 0, 0)
'Top Right
vertices(5) = CreateFlexVertex(TopLeftPos.X + Width, TopLeftPos.Y, TopLeftPos.Z + Depth, 1, 0)
'------------------------------



'-----------------------------
' Bottom face - The Y's are the same
'***Note: The Front Face's Bottom Left and Bottom Right are shared by the Bottom Face's Top Left and Top Right
'
'Bottom Left(Prentend you're "underneath" this face)
vertices(6) = CreateFlexVertex(TopLeftPos.X, TopLeftPos.Y + Height, TopLeftPos.Z + Depth, 0, 0)
'Bottom Right
vertices(7) = CreateFlexVertex(TopLeftPos.X + Width, TopLeftPos.Y + Height, TopLeftPos.Z + Depth, 1, 0)
'------------------------------


'-----------------------------
' Left face - The X's are the same
'***Note: All of the Left Face's vertices are shared by the other vertices
'-----------------------------

'-----------------------------
' Right face - The X's are the same
'***Note: All of the Left Face's vertices are shared by the other vertices
'-----------------------------

'-----------------------------
' Back face - The Z's are the same
'***Note: All of the Left Face's vertices are shared by the other vertices
'-----------------------------


VertBuffer.Unlock()

Catch de As Exception
MessageBox.Show("Something stupid happened while creating your cube... so yeah. Error: " & de.Message, "3D Initialization.", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

End Function

[/vb]

and here's the render sub(where the problem is)
[vb]
Public Sub Render()

d3ddev.VertexFormat = CustomVertex.PositionTextured.Format
d3ddev.SetStreamSource(0, VertBuffer, 0)
d3ddev.SetTexture(0, SprTexture)
d3ddev.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 12) '<-- right here
End Sub

[/vb]

does anyone know waht im doing wrong here?,
thanks,
-Pent-
8   L A T E S T    R E P L I E S    (Newest First)
Peter Posted - Mar 25 2004 : 7:48:53 PM
Yeah, thats oop taken to an insane level

And it cant be fast ;)
Eric Coleman Posted - Mar 25 2004 : 09:39:15 AM
A triangle as a class seems a bit overboard IMHO.
The Pentium Guy Posted - Mar 24 2004 : 4:44:44 PM
oh yeah, sorry that's what i meant :)
VBBR Posted - Mar 23 2004 : 5:33:20 PM
One more thing, the primitive count of DrawPrimitives is the number of TRIANGLES and not number of vertices.
The Pentium Guy Posted - Mar 23 2004 : 5:22:41 PM
yeah ur right, i did have the logic wrong -
what i jsut did was created a Triangle class, and then created a Rectangle Class which inherited from the triangle class, and then created a CUBE class which inherited from the RECTANGLE class and put it all together and it worked o_O,
its a much bigger releif doing that then just creating a cube class..
and plus its a little bit more organized :)
thanks,
pent
Eric Coleman Posted - Mar 22 2004 : 12:57:55 PM
I think you have the logic wrong in creating your cube. A cube face is comprised of 2 triangles. That translates to 6 vertices per "square" face. With 6 faces that's a total of 36 vertices, not 12. You can reduce this if you use indexed primitives, but from what you're doing, you're not indexing them, so I won't explain that.
The Pentium Guy Posted - Mar 22 2004 : 12:47:36 PM
oh, no, it's right,

i realized what i did wrong,
TriangleStrip reads the vertices this order:
012, 123, 234, 345, 456.. etc

and the order that i have them in, it doesnt like :p
VBBR Posted - Mar 21 2004 : 1:52:50 PM
I think you did something wrong when creating the buffer. Look in www.directx4vb.com for a good tutorial on D3D9.

VBGamer © Go To Top Of Page
This page was generated in 0.08 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.