Post

 Resources 

Console

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

 All Forums
 VBGamer
 VBGamer
 Vertex Buffer -> Mesh

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
Sr. Guapo Posted - Jun 13 2004 : 1:21:34 PM
Okay, I am making a simple terrain heightmap generator for my game. What I need to do is create a mesh file givin the heightmap.

I can create the vertex buffer in a nested loop, but is there a way to convert a vertex buffer to a mesh? I have tried everything, and I looked for two hours on MSDN, but I didn't see anything like what I want to do.

My other option is to create the terrain in Milkshape (it can make a heightmapped terrain) and export it to an X-file. However, I would still need to create a data file containing the height at all the various points.

I would appreciate any suggestions/comments... thanks
15   L A T E S T    R E P L I E S    (Newest First)
Sr. Guapo Posted - Jun 16 2004 : 12:33:32 AM
OK, new problem. I have been attempting to make this work in VB .NET and DX9. I am trying to load the data into a 2D array of vertices. Should I just use the PositionTextured vertices? Also, should I use a vertex buffer, or just load the straight vertex data when rendering? Sorry, I am really confused... DX9 (and VB .NET for that matter) is different from what I am used to, so it is giving me headaches.

PS - these are very DX9 specific questions, if anyone is familiar with it...
Sr. Guapo Posted - Jun 15 2004 : 5:58:26 PM
Okay, I always learned that 32 bit machines (like all of the currect PC's) can process a 32 bit number (long/single in VB6) faster than another type (integer, byte, double in VB6). Does this mean I should use integers in VB .NET since they are 32 bit?
game_maker Posted - Jun 15 2004 : 4:42:55 PM
and Long in VB.Net = 8 bytes

that's why

if you compute your file from vb.6 and read it from VB.Net here is the problem but if you compute from VB.Net and read it from VB.Net you won't face any problem with Variable Types
VBBR Posted - Jun 15 2004 : 2:39:02 PM
In VB6:
- Integer: 2 bytes
- Long: 4 bytes

In VB.NET:
- Short: 2 bytes
- Integer: 4 bytes

So that's just a name exchange basically. It screws up file reading because you could be reading 4 bytes in a row instead of 2 or something like that, so the numbers end up mixed up or half their original bytes.
Eric Coleman Posted - Jun 15 2004 : 12:41:30 PM
Generally that "LONG" number translates to 4 letters (4 bytes). For example, I use the number 1128811092 ("TJHC") as the first four bytes in an archive file that I created so that I can recognize the file as being something that I created. If you look at wotsit.org, you'll find a lot of file formats do this. Gif, bmp, zip, etc, all have an ID number at the very beginning.
Sr. Guapo Posted - Jun 15 2004 : 10:52:48 AM
OK, I figured YCredit was something like that... . I just wanted to make sure it wasn't an important variable. That is a good idea, I should probably do that if I ever plan to make a real game.

The error: Yes, the file loads now. Out of curiousity, why is that? A long should be that, a long integer, so anything an integer can hold, a long can...
game_maker Posted - Jun 15 2004 : 02:49:01 AM
Hi

423107387 this is just YazeedCredit (My ID number) ,, I saw Quake did it in md2 and I made the same

  
if YCredit <> 423107387 then exit sub
  


that's the idea behind Credits (protect your files) but I didn't wrote this condition in all of my files (i.e. I make No sence)

about the error :

in VB.Net change all Long Variable Types to Integer

Sr. Guapo Posted - Jun 15 2004 : 12:22:50 AM
Sorry... I get an error when I am trying to load a binary in .NET... It occurs when I try to redim the H() variable in this set of code:

  
        FileOpen(95, path, OpenMode.Binary)  
  
        FileGet(95, yCredit)  
        FileGet(95, LandSize)  
        FileGet(95, nVertex)  
        FileGet(95, nTriangle)  
        ReDim H(LandSize, LandSize)  
        FileGet(95, H)  
  
        FileClose(95)  
  
  


aparently, LandSize comes out as some HUGE number (86,745,454,497,511: 86 trillion). I assume .NET must do something different than VB6, because the code is almost identical. I am very unknowledgable about file I/O in VB, so any help is appreciated...
Sr. Guapo Posted - Jun 14 2004 : 11:28:32 PM
Thank you very much . I will try and incorporate some of that into my game.

I just have one question. What is the YCredit variable for in the file? It seems you save a huge arbitrary number stored in it (423107387), then do nothing with the number when it is loaded...
game_maker Posted - Jun 14 2004 : 8:39:09 PM
and here how to create terrain files

Download Attachment: terrain-files.zip
31 KB

best regards
game_maker Posted - Jun 14 2004 : 8:26:53 PM
it's smooth really ,,, the problem from choosing your points I guess

OK ,, I just wrote a small example for you

Download Attachment: terrain.zip
109.95 KB

regards

Sr. Guapo Posted - Jun 14 2004 : 6:43:08 PM
OK, I implemented that function... It just did the same thing as the previous version (though it is more accurate). It is still very jerky like described above...

I want to be able to make my own Vertex Buffer to store the vertices, that is what I need help with.
game_maker Posted - Jun 14 2004 : 5:58:04 PM
you are working with 2 points right ?

1 - (x,,z)
2 - (x+1,,z+1)

that's the only problem ,,, you should work with 4 points becouse each one of the for point's effect in our Y aren't they ?

1 - (x,y1,z)
2 - (x+1,y2,z)
3 - (x,y3,z+1)
4- (x+1,y4,z+1)

and I use equation of Line (y = mx * b) same as you did


I just design it in 3DSmax

Ok ,,, now we have four points and a point (xd,,zd) and we wan't to find yd

simply we create 2 lines (you can find the line if you have to points or one point and slope)

we have 4 point so we can create (3*2*1) = 6 lines

we only need 2 lines ,,,,,,, so

we pick point 1 and 2 to make a line1 ,,, and pick 3 and 4 to make line2

then we find y1 and y2

y1 ,y2 : the y value of line1 and line2 when x = xd

then we find y3

thats it

notice :

to find y1 :
m = ((P2.Y - P1.Y) / (P2.X - P1.X))
xd = (X - P2.X)
b = P2.Y
y1 = m * xd + b

  
    Public Function getHeight(ByVal x As Single, ByVal z As Single) As Single
        If x < 0 Or x > size - 1 Or z < 0 Or z > size - 1 Then
            Return (0.0)  
        Else
         Y1 = ((P2.Y - P1.Y) / (P2.X - P1.X)) * (X - P2.X) + P2.Y  
         Y2 = ((P4.Y - P3.Y) / (P4.X - P3.X)) * (X - P4.X) + P4.Y  
            Return (((Y2 - Y1) / (P4.Z - P1.Z)) * (Z - P4.Z) + Y2)  
        End If
    End Function
  


there is other math method :

you can use equation of plane (you have tocheck what is the plane your character standing on then substitute to find y3
Sr. Guapo Posted - Jun 14 2004 : 2:59:03 PM
That is what I am trying to do. I send the x and z coordinates to a function, GetHeight():

  
    Public Function getHeight(ByVal x As Single, ByVal z As Single) As Single
        If x < 0 Or x > size - 1 Or z < 0 Or z > size - 1 Then
            Return (0.0)  
        Else
            tmpDecX = x - (x \ 1)  
            tmpDecZ = z - (z \ 1)  
  
            tmpH1 = height(x \ 1, z \ 1)  
            tmpH2 = height(x \ 1 + 1, z \ 1 + 1)  
            tmpDiff = tmpH2 - tmpH1  
            tmpDist = Math.Sqrt(tmpDecX * tmpDecX + tmpDecZ * tmpDecZ)  
  
            Return (tmpDiff * tmpDist + tmpH1)  
        End If
    End Function
  


Sorry if the code is a little unreadable, I wrote this very late at night... Anyway, I could have made this a one line return statement, but I think it is faster to break things up like this (correct me if I'm wrong). It is still very jerky, like I will be walking along at a certain height, then fly up/down all of a sudden. I thought this function would fix it, but aparently not...
masterbooda Posted - Jun 14 2004 : 2:35:48 PM
No kidding, that 3dstudio max is expensive, but it is the only 3d editor I will use... nothing has comapared to it, not even maya.... think god my brother inlaw owns it........whoops......um.... nothing...

oh and about the mesh thing, a lot of this post is over my head, but aren't all files just little ones and zeros... maybe you can find a way to interpret the file yourself and create it from that... And of course you can find file conversions for 3d files of nearly every type on line and free..

I noticed you where using an heightmap file... I know this isn't very accurate, but couldn't you take sort of an average of how far from the x and y the position the man is take the 4 colors and find an average mean... I am probably babbling and making no sense... sorry...

(1)----(2)
| |
| o |
(3)----(4)

Crude I know, but the o is where the dude or character is at, now take the color from the heightmap's four colors (1pixel apart)... and average a mean to the character and that is your height... but I am probably making an easy situation worse...

DaBooda out...

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

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