bit of a conversion problem

Started by
0 comments, last by Armadon 17 years, 11 months ago
i have recntly bought a few tutorials from www.gametutorials.com i am currently trying to convert the c++ direct3d water tutorial to vb.net , i have been trying for ages and can seem to find the problem , i have converted the code over word for word and still dosent work, so below i have posted the c++ and vb.net and i would be very gratefull if somebody could have a look at them and maybe point out some mistakes that i have made. c++ version water.h

#include "d3d_obj.h"
#include "d3d_texture.h"

/////////////
// Macros //
///////////

#define DEG2RAD(x) (x * (D3DX_PI / 180.0f)) // Converts degrees to radians
#define RAD2DEG(x) (x * (180.0f / D3DX_PI)) // Converts radians to degrees

#define F2I(x) ( (int)((x) + 0.5f) ) // Converts a float to int with proper rounding

////////////////
// Constants //
//////////////

const int kWaterTesselation = 32; // Number of rows X cols of tessellated quads in water
const int kWaveTableSize = 36; // Number of entries in the wave table

const float kWaterForce = 1.0f / 25.0f; // Controls the "choppiness" of the water (Range is 0.0f - 1.0f)
								       // 0.0f == Water is still 
								      // 1.0f == Water is VERY choppy (so choppy it looks very bad)
const float kWaterWid = 30.0f; // Width of water (along X-axis)
const float kWaterHgt = 30.0f; // Height of water (along Z-axis)

class CWater
{
	public:
	
		CWater(); // Constructor
		
		bool init(); // Initialize the water object
		void process(); // Process the water object (apply sin() wave to Y value of verts)
		void render(); // Render the water
		
		~CWater(); // Deconstructor

	private:
	
		bool createGeometery(float width, float height, int tesselation);
	
		CD3DTexture mTexture;
		SVertex *mVerts;
		WORD *mIndices;
		
		int mVertCount;
		int mIndexCount;
		int mTesselation;
		
		float mWaveTable[kWaveTableSize];		
};

#endif


water.cpp


#include "water.h"

const CPos kWaterCen(0.0f, 0.0f, 0.0f); // Water is always centered at (0,0,0)

// Helper function for determining if a float is less than or equal to
// another float
inline bool ToleranceLE(float a, float b, float tolerance = 0.001f)
{
	return ((a - tolerance) <= b);
}

// Constructor
CWater::CWater()
{
	memset(mWaveTable, 0, sizeof(mWaveTable));
	
	mVerts = NULL;
	mIndices = NULL;
	
	mVertCount = 0;
	mIndexCount = 0;
	mTesselation = 0;
	
	// "texture" gets initialized by it's constructor 
}

// Init the water object, returns true on success, false otherwise
bool CWater::init()
{
	// Fill the wave table
	float angInc = 360.0f / (float)kWaveTableSize;
	float angle = 0.0f;
	
	// Fill in the table with values of the sine function
	for(int i = 0; i < kWaveTableSize; ++i)
	{
		mWaveTable = sin(DEG2RAD(angle));
		angle += angInc;
	}

	// Create the tessellated quad
	if(!createGeometery(kWaterWid, kWaterHgt, kWaterTesselation))
		return false;
	
	// Load the water texture
	return mTexture.load("water.jpg"); 
}

// Process the water every frame
void CWater::process()
{
	static int startIndex = 0;
	
	int waveIndex = startIndex;
	int vertIndex = 0;
	
	// Loop through all rows of triangles
	for(int i = 0; i <= mTesselation; ++i)
	{
		// Loop through all the columns of triangles
		for(int j = 0; j <= mTesselation; ++j, ++vertIndex)
		{
			// Perturb each vertex
			mVerts[vertIndex].y += mWaveTable[waveIndex] * kWaterForce;
			
			if(++waveIndex == kWaveTableSize)
				waveIndex = 0;
		}
		
	}
	
	// Keep cycling thorough the mWaveTable
	if(++startIndex == kWaveTableSize)
		startIndex = 0;
}

// Render the water object as a triangle strip
void CWater::render()
{
	bool b = g3D->setAlphaBlendMode(true); // Turn on alpha blending

	mTexture.select(); // Select the water texture
	g3D->render(mVerts, mVertCount, mIndices, mIndexCount); // Render the tessellated quad
	
	g3D->setAlphaBlendMode(false); // Turn off alpha blending
}

// Creates a tesselated quad of (width x height) dimensions
// Number of triangles in quad is (tessAmt * tessAmt * 2)
bool CWater::createGeometery(float width, float height, int tessAmt)
{
	if(width < 0.0f || height < 0.0f || tessAmt <= 0)
		return false;

	// Set tesselation amount
	mTesselation = tessAmt;
		
	// Calculate vertex count.  We know that we have (tesselation * tesselation * 2) triangles
	// with 3 vertices per triangle.  So each row of vertices will contain "number of rows + 1"
	// vertices and each column of vertices well contain "number of columns + 1" vertices.  This
	// makes the total number of vertices equal the following equation
	mVertCount = (mTesselation + 1) * (mTesselation + 1);
	
	// Calculate index count.  We know that we'll have (tesselation * tesselation * 2) triangles
	// and we have 3 vertices per triangle, thus the below equation
	mIndexCount = mTesselation * mTesselation * 6;
	
	// Allocate space for vertices and indices
	mVerts = new SVertex[mVertCount];
	mIndices = new WORD[mIndexCount];
	
	if(mVerts == NULL || mIndices == NULL)
		return false;	
	
	// Get the sub divided width and height of each triangle
	float subDivideWid = width * (1.0f / (float)mTesselation);
	float subDivideHgt = height * (1.0f / (float)mTesselation);
	
	// Calculate the starting (x,y) and ending (x,y) of the quad 
	float startX = kWaterCen.x - (width / 2.0f);
	float startY = kWaterCen.z - (height / 2.0f);
	float endX = kWaterCen.x + (width / 2.0f);
	float endY = kWaterCen.z + (height / 2.0f);
	
	float uCoord = 0.0f; // Holds the current trinagle's U coordinate
	float vCoord = 1.0f; // Holds the current triangle's V coordinate
	float uvInc = 1.0f / (float)mTesselation; // Calculate the amount to add to each UV coordinate
	
	int i = 0; // Index for all of for...loops
	
	// Create all the vertices
	for(float y = startY; ToleranceLE(y, endY); y += subDivideHgt)
	{
		for(float x = startX; ToleranceLE(x, endX); x += subDivideWid, ++i)
		{
			// Set the value for the current vert
			mVerts.x = x;
			mVerts.y = kWaterCen.y;
			mVerts.z = y;
			mVerts.u = uCoord;
			mVerts.v = vCoord;
			mVerts.color = D3DCOLOR_ARGB(128, 255, 255, 255);
			
			uCoord += uvInc;			
		}
		
		// Set UV for next row of vertices
		uCoord = 0.0f;
		vCoord -= uvInc;
	}


	
	// Make sure we calculatd the vertex count correctly
	assert(mVertCount == i);
	
	int indexValue = 0;
	int nextRow = 0;
	
	// Look at this sample 2 x 2 quad to understand the pattern used to fill in the indices
	/*
		6----7----8		Index count =  24
		|\ 	 |\   |		Tesselation = 2	
		| \  | \  | 	
		|  \ |  \ |		Pattern is:	0, 3, 1
		|   \|   \|					1, 3, 4
		3----4----5					1, 4, 2
		|\ 	 |\   |					2, 4, 5
		| \  | \  | 				3, 6, 4
		|  \ |  \ |					4, 6, 7
		|   \|   \|					4, 7, 5,
		0----1----2					5, 7, 8
	*/
	
	// Create all the indices
	for(i = 0; i < mIndexCount; i += 6)
	{
		mIndices = indexValue;
		mIndices = indexValue + (mTesselation + <span class="cpp-number">1</span>);
		mIndices = mIndices<span style="font-weight:bold;"> + <span class="cpp-number">1</span>;
		
		indexValue++;
		
		mIndices = indexValue;
		mIndices = indexValue + mTesselation;
		mIndices = mIndices + <span class="cpp-number">1</span>;
		
		<span class="cpp-keyword">if</span>(++nextRow == mTesselation)
		{
			indexValue++;
			nextRow = <span class="cpp-number">0</span>;
		}
	}
	
	<span class="cpp-keyword">return</span> <span class="cpp-keyword">true</span>;
}

<span class="cpp-comment">// Free the memory</span>
CWater::~CWater()
{
	<span class="cpp-keyword">if</span>(mVerts)
	{
		<span class="cpp-keyword">delete</span>[] mVerts;
		mVerts = NULL;
	}
	
	<span class="cpp-keyword">if</span>(mIndices)
	{
		<span class="cpp-keyword">delete</span>[] mIndices;
		mIndices = NULL;
	}
}


</pre></div><!–ENDSCRIPT–>


and here is my vb.net conversion

<!–STARTSCRIPT–><!–source lang="vb"–><div class="source"><pre>

    <span class="vb-keyword">Public</span> <span class="vb-keyword">Class</span> RealisticWater

        <span class="vb-keyword">Public</span> <span class="vb-keyword">Function</span> Deg2Rad(ByVal X As Single) As Single
            Return X * (PI / 180.0F) <span class="vb-comment">'convert degrees to radian</span>
        <span class="vb-keyword">End</span> <span class="vb-keyword">Function</span>

        <span class="vb-keyword">Public</span> <span class="vb-keyword">Function</span> Rad2Deg(ByVal x As Single) As Single
            Return x * (180.0F / PI) <span class="vb-comment">'converts radians to degrees</span>
        <span class="vb-keyword">End</span> <span class="vb-keyword">Function</span>

        <span class="vb-keyword">Public</span> <span class="vb-keyword">Function</span> F2I(ByVal x As Single) As Integer
            Return CType(x + 0.5F, Integer) <span class="vb-comment">'converts  float to int with proper rounding</span>
        <span class="vb-keyword">End</span> <span class="vb-keyword">Function</span>

        <span class="vb-keyword">Private</span> <span class="vb-keyword">Const</span> kWaterTesselation As Single = 32 <span class="vb-comment">' number of row columns of teselation in water</span>
        <span class="vb-keyword">Private</span> <span class="vb-keyword">Const</span> kWaveTableSize As Single = 36 <span class="vb-comment">' number of entries in the wav table</span>
        <span class="vb-keyword">Private</span> <span class="vb-keyword">Const</span> kWaterForce As Single = 0.1F / 25.0F <span class="vb-comment">' // Controls the "choppiness" of the water (Range is 0.0f - 1.0f)</span>
        <span class="vb-comment">'// 0.0f == Water is still </span>
        <span class="vb-comment">'// 1.0f == Water is VERY choppy (so choppy it looks very bad)</span>
        <span class="vb-keyword">Private</span> <span class="vb-keyword">Const</span> kWaterWid As Single = 30.0F <span class="vb-comment">'width of water along x axis</span>
        <span class="vb-keyword">Private</span> <span class="vb-keyword">Const</span> kWaterHgt As Single = 30.0F <span class="vb-comment">' height of water along z axis</span>

#Region <span class="vb-literal">"Water Vertex Structure"</span>
        <span class="vb-keyword">Public</span> Structure WVertex
            <span class="vb-keyword">Public</span> x, y, z As Single
            <span class="vb-keyword">Public</span> Color As Integer
            <span class="vb-keyword">Public</span> u, v As Single
            <span class="vb-keyword">Public</span> <span class="vb-keyword">Const</span> Format As VertexFormats = VertexFormats.Position Or VertexFormats.Diffuse Or (1 &lt;&lt; VertexFormats.TextureCountShift)
            <span class="vb-comment">'Public Const Format As VertexFormats = VertexFormats.Diffuse Or VertexFormats.Position Or (1 &lt;&lt; VertexFormats.TextureCountShift)</span>
        <span class="vb-keyword">End</span> Structure
#<span class="vb-keyword">End</span> Region

        <span class="vb-keyword">Private</span> mTexture As Direct3D.Texture
        <span class="vb-keyword">Private</span> mVerts() As WVertex
        <span class="vb-keyword">Private</span> mIndices() As Integer
        <span class="vb-keyword">Private</span> mVertCount As Integer
        <span class="vb-keyword">Private</span> mIndexCount As Integer
        <span class="vb-keyword">Private</span> mTesselation As Single
        <span class="vb-keyword">Private</span> mWaveTable(kWaveTableSize) As Single
        <span class="vb-keyword">Private</span> kWaterCen As Vector3 = New Vector3(0, 0, 0) <span class="vb-comment">'water is always cenetred at 0.0f</span>
        <span class="vb-keyword">Private</span> Dev As Direct3D.Device

        <span class="vb-keyword">Public</span> <span class="vb-keyword">Function</span> ToleranceLE(ByVal a As Single, ByVal b As Single, Optional ByVal tolerance As Single = 0.001F) As Boolean
            Return ((a - tolerance) &lt;= b)
        <span class="vb-keyword">End</span> <span class="vb-keyword">Function</span>

        <span class="vb-comment">'// Constructor</span>
        <span class="vb-keyword">Public</span> <span class="vb-keyword">Sub</span> New(ByVal Device As Direct3D.Device, ByVal TexturePath As <span class="vb-function">String</span>)
            Dev = Device
            mVerts = <span class="vb-keyword">Nothing</span>
            mIndices = <span class="vb-keyword">Nothing</span>
            mVertCount = 0
            mIndexCount = 0
            mTesselation = 0
            Init(TexturePath)
        <span class="vb-keyword">End</span> <span class="vb-keyword">Sub</span>

        <span class="vb-comment">'// Init the water object, returns true on success, false otherwise</span>
        <span class="vb-keyword">Private</span> <span class="vb-keyword">Sub</span> Init(ByVal TexturePath As <span class="vb-function">String</span>)
            <span class="vb-comment">'// Fill the wave table</span>
            <span class="vb-keyword">Dim</span> anginc As Single = 360.0F / CType(kWaveTableSize, Single)
            <span class="vb-keyword">Dim</span> angle As Single = 0.0F
            <span class="vb-keyword">Dim</span> I As Integer

            <span class="vb-comment">'// Fill in the table with values of the sine function</span>
            <span class="vb-keyword">For</span> I = 0 To kWaveTableSize - 1
                mWaveTable(I) = <span class="vb-function">Sin</span>(Deg2Rad(angle))
                angle += anginc
            <span class="vb-keyword">Next</span>

            <span class="vb-comment">'// Create the tessellated quad</span>
            CreateGeometery(kWaterWid, kWaterHgt, kWaterTesselation)

            <span class="vb-comment">'// Load the water texture</span>
            mTexture = TextureLoader.FromFile(Dev, TexturePath)
        <span class="vb-keyword">End</span> <span class="vb-keyword">Sub</span>


        <span class="vb-comment">'// Process the water every frame</span>
        <span class="vb-keyword">Public</span> <span class="vb-keyword">Sub</span> Process()
            Static startIndex As Integer = 0
            <span class="vb-keyword">Dim</span> waveIndex As Integer = startIndex
            <span class="vb-keyword">Dim</span> vertIndex As Integer = 0
            <span class="vb-keyword">Dim</span> i As Integer
            <span class="vb-keyword">Dim</span> j As Integer

            <span class="vb-comment">'// Loop through all rows of triangles</span>
            <span class="vb-keyword">For</span> i = 0 To mTesselation <span class="vb-comment">'- 1</span>
                <span class="vb-comment">'// Loop through all the columns of triangles</span>
                <span class="vb-keyword">For</span> j = 0 To mTesselation
                    <span class="vb-comment">'// Perturb each vertex</span>
                    mVerts(vertIndex).y += mWaveTable(waveIndex) * kWaterForce
                    <span class="vb-keyword">If</span> System.Threading.Interlocked.Increment(waveIndex) = kWaveTableSize <span class="vb-keyword">Then</span>
                        waveIndex = 0
                    <span class="vb-keyword">End</span> <span class="vb-keyword">If</span>
                <span class="vb-keyword">Next</span>
            <span class="vb-keyword">Next</span>

            <span class="vb-comment">'// Keep cycling thorough the mWaveTable</span>
            <span class="vb-keyword">If</span> System.Threading.Interlocked.Increment(startIndex) = kWaveTableSize <span class="vb-keyword">Then</span>
                startIndex = 0
            <span class="vb-keyword">End</span> <span class="vb-keyword">If</span>
        <span class="vb-keyword">End</span> <span class="vb-keyword">Sub</span>


        <span class="vb-keyword">Public</span> <span class="vb-keyword">Sub</span> Process2()
            Static startindex As Integer
            <span class="vb-keyword">Dim</span> waveindex As Integer = startindex
            <span class="vb-keyword">Dim</span> vertindex As Integer
            <span class="vb-keyword">Dim</span> i As Integer
            <span class="vb-keyword">Dim</span> j As Integer
            <span class="vb-comment">'// Loop through all rows of triangles</span>
            <span class="vb-keyword">For</span> i = 0 To mTesselation
                <span class="vb-comment">'// Loop through all the columns of triangles</span>
                <span class="vb-keyword">For</span> j = 0 To mTesselation
                    <span class="vb-comment">'// Perturb each vertex</span>
                    mVerts(vertindex).y += mWaveTable(waveIndex) * kWaterForce
                    vertindex += 1
                    waveindex += 1
                    <span class="vb-keyword">If</span> waveindex = kWaveTableSize <span class="vb-keyword">Then</span>
                        waveindex = 0
                    <span class="vb-keyword">End</span> <span class="vb-keyword">If</span>
                <span class="vb-keyword">Next</span>
            <span class="vb-keyword">Next</span>
            <span class="vb-comment">'// Keep cycling thorough the mWaveTable</span>
            startindex += 1
            <span class="vb-keyword">If</span> startindex = kWaveTableSize <span class="vb-keyword">Then</span>
                startindex = 0
            <span class="vb-keyword">End</span> <span class="vb-keyword">If</span>
        <span class="vb-keyword">End</span> <span class="vb-keyword">Sub</span>


        <span class="vb-comment">'// Render the water object as a triangle strip</span>
        <span class="vb-keyword">Public</span> <span class="vb-keyword">Sub</span> Render()
            Dev.RenderState.AlphaBlendEnable = <span class="vb-keyword">True</span>
            Dev.RenderState.Lighting = <span class="vb-keyword">False</span>
            Dev.VertexFormat = WVertex.Format
            Dev.SetTexture(0, mTexture)
            Dev.RenderState.CullMode = Cull.None
            Dev.DrawIndexedUserPrimitives(PrimitiveType.TriangleStrip, 0, mIndexCount, mIndexCount / 3, mIndices, <span class="vb-keyword">False</span>, mVerts)
            Dev.RenderState.Lighting = <span class="vb-keyword">True</span>
            Dev.RenderState.AlphaBlendEnable = <span class="vb-keyword">False</span>
        <span class="vb-keyword">End</span> <span class="vb-keyword">Sub</span>


        <span class="vb-comment">'// Creates a tesselated quad of (width x height) dimensions</span>
        <span class="vb-comment">'// Number of triangles in quad is (tessAmt * tessAmt * 2)</span>
        <span class="vb-keyword">Public</span> <span class="vb-keyword">Function</span> createGeometery(ByVal width As Single, ByVal height As Single, ByVal tessAmt As Single) As Boolean

            <span class="vb-keyword">If</span> width &lt; 0.0F Or height &lt; 0.0F Or tessAmt &lt;= 0 <span class="vb-keyword">Then</span> Return <span class="vb-keyword">False</span>

            <span class="vb-comment">'Set tesselation amount </span>
            mTesselation = tessAmt

            <span class="vb-comment">' Calculate vertex count.  We know that we have (tesselation * tesselation * 2) triangles </span>
            <span class="vb-comment">' with 3 vertices per triangle.  So each row of vertices will contain "number of rows + 1" </span>
            <span class="vb-comment">' vertices and each column of vertices well contain "number of columns + 1" vertices.  This </span>
            <span class="vb-comment">' makes the total number of vertices equal the following equation </span>
            mVertCount = (mTesselation + 1) * (mTesselation + 1)

            <span class="vb-comment">' Calculate index count.  We know that we'll have (tesselation * tesselation * 2) triangles </span>
            <span class="vb-comment">' and we have 3 vertices per triangle, thus the below equation </span>
            mIndexCount = mTesselation * mTesselation * 6

            <span class="vb-comment">' Allocate space for vertices and indices </span>
            <span class="vb-keyword">ReDim</span> mVerts(mVertCount)
            <span class="vb-keyword">ReDim</span> mIndices(mIndexCount)

            <span class="vb-comment">'not sure how this could ever be true given the two lines above </span>
            <span class="vb-comment">'if mVerts = NULL or  mIndices == NULL Then Return False </span>

            <span class="vb-comment">' Get the sub divided width and height of each triangle </span>
            <span class="vb-keyword">Dim</span> subDivideWid As Single = width * (1 / mTesselation)
            <span class="vb-keyword">Dim</span> subDivideHgt As Single = height * (1 / mTesselation)

            <span class="vb-keyword">Dim</span> startx As Single
            <span class="vb-keyword">Dim</span> starty As Single
            <span class="vb-keyword">Dim</span> endx As Single
            <span class="vb-keyword">Dim</span> endy As Single
            <span class="vb-keyword">Dim</span> ucoord As Single
            <span class="vb-keyword">Dim</span> vcoord As Single
            <span class="vb-keyword">Dim</span> uvinc As Single

            <span class="vb-comment">' Calculate the starting (x,y) and ending (x,y) of the quad </span>
            startx = kWaterCen.X - (width / 2.0F)
            starty = kWaterCen.Z - (height / 2.0F)
            endx = kWaterCen.X + (width / 2.0F)
            endy = kWaterCen.Z + (height / 2.0F)

            ucoord = 0.0F <span class="vb-comment">' Holds the current trinagle's U coordinate </span>
            vcoord = 1.0F <span class="vb-comment">' Holds the current triangle's V coordinate </span>

            uvinc = 1.0F / mTesselation <span class="vb-comment">' Calculate the amount to add to each UV coordinate </span>

            <span class="vb-keyword">Dim</span> i As Integer = 0 <span class="vb-comment">' Index for all of for…loops </span>
            <span class="vb-keyword">Dim</span> y As Single
            <span class="vb-keyword">Dim</span> x As Single

            <span class="vb-comment">' Create all the vertices </span>
            <span class="vb-keyword">For</span> y = starty To ToleranceLE(y, endy) Step subDivideHgt
                <span class="vb-keyword">For</span> x = startx To ToleranceLE(x, endx) Step subDivideWid

                    <span class="vb-comment">' Set the value for the current vert </span>
                    mVerts(i).x = x
                    mVerts(i).y = kWaterCen.Y
                    mVerts(i).z = y
                    mVerts(i).u = ucoord
                    mVerts(i).v = vcoord
                    mVerts(i).Color = Color.FromArgb(128, 255, 255, 255).ToArgb

                    ucoord += uvinc

                    i += 1

                <span class="vb-keyword">Next</span> x

                <span class="vb-comment">' Set UV for next row of vertices </span>
                ucoord = 0.0F
                vcoord -= uvinc

            <span class="vb-keyword">Next</span> y

            <span class="vb-comment">' Make sure we calculatd the vertex count correctly </span>
            <span class="vb-comment">'If mVertCount &lt;&gt; i Then Throw New Exception("Vertex count does not equal " &amp; i.ToString)</span>

            <span class="vb-keyword">Dim</span> indexValue As Integer = 0
            <span class="vb-keyword">Dim</span> nextRow As Integer = 0

            <span class="vb-comment">' Look at this sample 2 x 2 quad to understand the pattern used to fill in the indices </span>
            <span class="vb-comment">'6—-7—-8      Index count =  24 </span>
            <span class="vb-comment">'|\     |\   |      Tesselation = 2    </span>
            <span class="vb-comment">'| \  | \  |      </span>
            <span class="vb-comment">'|  \ |  \ |      Pattern is:   0, 3, 1 </span>
            <span class="vb-comment">'|   \|   \|               1, 3, 4 </span>
            <span class="vb-comment">'3—-4—-5               1, 4, 2 </span>
            <span class="vb-comment">'|\     |\   |               2, 4, 5 </span>
            <span class="vb-comment">'| \  | \  |             3, 6, 4 </span>
            <span class="vb-comment">'|  \ |  \ |               4, 6, 7 </span>
            <span class="vb-comment">'|   \|   \|               4, 7, 5, </span>
            <span class="vb-comment">'0—-1—-2               5, 7, 8 </span>


            <span class="vb-comment">' Create all the indices </span>
            <span class="vb-keyword">For</span> i = 0 To mIndexCount - 1 Step 6

                mIndices(i) = indexValue
                mIndices(i + 1) = indexValue + mTesselation + 1
                mIndices(i + 2) = mIndices(i) + 1

                indexValue += 1

                mIndices(i + 3) = indexValue
                mIndices(i + 4) = indexValue + mTesselation
                mIndices(i + 5) = mIndices(i + 4) + 1

                nextRow += 1

                <span class="vb-keyword">If</span> nextRow = mTesselation <span class="vb-keyword">Then</span>
                    indexValue += 1
                    nextRow = 0
                <span class="vb-keyword">End</span> <span class="vb-keyword">If</span>

            <span class="vb-keyword">Next</span> i

            Return <span class="vb-keyword">True</span>
        <span class="vb-keyword">End</span> <span class="vb-keyword">Function</span>


        <span class="vb-keyword">Public</span> <span class="vb-keyword">Sub</span> Dispose()
            <span class="vb-keyword">Erase</span> mVerts
            <span class="vb-keyword">Erase</span> mIndices
        <span class="vb-keyword">End</span> <span class="vb-keyword">Sub</span>

    <span class="vb-keyword">End</span> <span class="vb-keyword">Class</span>



</pre></div><!–ENDSCRIPT–>

plase any help will be very helpfull ive been  trying for ages to get this working and i cant seem to see anything wrong.

sorry i though i used the code tags already, i know im really sorry about all the code but the prob is i have gone trough it loadz of times and icant find the prob. the prob is it dosent render properly, but from what i can see its the vertice generation that causes the prob, i just for the life of me figure it out. and im not convberting opengl to MDX, its c++ MDX to vb.net MDX, which i have done loadz of times and should be almost identical, but i cant seem to find the problem.

<!–EDIT–><span class=editedby><!–/EDIT–>[Edited by - tuvd on May 17, 2006 6:25:36 AM]<!–EDIT–></span><!–/EDIT–>
Advertisement
Please place your code in the source tags. It's a bit difficult to read.

Also, alot of people that answer questions on these forums don't really have time to go through a whole bunch of code like that. A simple question with regards to conversion might be something like how do I convert ID3DXSprite to MDX or what is the MDX equavalent.

It's just a few tips to better help your answering and you might find that you will get a much faster reply ;)

Stay cool.

This topic is closed to new replies.

Advertisement