Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Solarbeam

More terrain blues...

This topic is 6497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What follows is for d3d
VOID GenerateTerrain(terrain &plane, D3DVECTOR origin, 
					 DWORD dwGridSize,FLOAT fScale, 
					 float pheight)
{
	int i, j, total, z;

	D3DVECTOR *grid;
	grid = new D3DVECTOR[dwGridSize];
	grid = new D3DVECTOR[dwGridSize];

	for (i = 0; i[j] = ((D3DVECTOR)(D3DVECTOR(i*fScale, j*fScale, z) + origin)); // error right here!
		}
	}

	int index, pos;

	plane.TerrainVertices = new D3DVERTEX[((dwGridSize-1)^2)*6];

	while (index < dwGridSize * 5)
	{
		plane.TerrainVertices[index] = D3DVERTEX(grid[pos][pos], D3DVECTOR(0, 0, 1), index, index);
		plane.TerrainVertices[index+1] = D3DVERTEX(grid[pos][pos+1], D3DVECTOR(0, 0, 1), index, index+1);
		plane.TerrainVertices[index+2] = D3DVERTEX(grid[pos+1][pos], D3DVECTOR(0, 0, 1), index+1, index);
		plane.TerrainVertices[index+3] = D3DVERTEX(grid[pos+1][pos+1], D3DVECTOR(0, 0, 1), index+1, index+1);
		plane.TerrainVertices[index+4] = D3DVERTEX(grid[pos+1][pos], D3DVECTOR(0, 0, 1), index+1, index);
		plane.TerrainVertices[index+5] = D3DVERTEX(grid[pos][pos+1], D3DVECTOR(0, 0, 1), index, index+1);
		index += 6;
		pos++;
	}

	plane.NumTerrainVertices = index;
}
 
Ok, it gives me this error on the line where i say grid[i][j] = This is the error: C:\mssdk\samples\Multimedia\D3dim\Arena\CamArena\Utility.cpp(182) : error C2679: binary ''='' : no operator defined which takes a right-hand operand of type ''struct _D3DVECTOR'' (or there is no acceptable conversion) I know what this is caused by - there isnt an overloaded = for doing D3DVECTOR[] =...is there an easy way to fix this, or am i gonna have to rip apart my dx headers?

Share this post


Link to post
Share on other sites
Advertisement
Please? This is the last obstacle in my way to having actual terrain...ive been wrestling with it for days, almost 2 weeks now...

Share this post


Link to post
Share on other sites
Don''t blame me if I''m wrong, but I think you have to put the following line before you include

#define D3D_OVERLOADS

Share this post


Link to post
Share on other sites
Um, ok, i used d3dxvector instead. Odd, now its giving me 8 errors...

Its saying "operator ''['' is ambiguous" on each of my uses of arrays. For instance, it says that grid[j] is ambiguous and that plane.TerrainVertices[index] is also ambiguous. What does this mean?

Share this post


Link to post
Share on other sites
I had a similar problem. I never figured it out (I know C very well, but not a lot of C++), but I got it working without the macro.

Look at the header file (d3dtypes.h, I believe?). Copy the body of the macro D3DVECTOR directly into your code. So instead of calling the macro, you are doing what the macro does manually in your code.

If you figure it out, let me know.

CP

"Can't you see it's only life! We can laugh about it!" - Seal

Share this post


Link to post
Share on other sites
Um, ??? I dont exactly get what you're saying. Whats all this about a macro? You mean the preprocessor types (#define)? Or are you talking about overloaded operators?

[MODIFIED]
Ok, I see what you're saying. It still doesnt fix my problem, though. Im currently trying to implement terrain as a class...anyone who has any input feel free to help...

Edited by - Solarbeam on October 5, 2000 7:13:31 PM

Share this post


Link to post
Share on other sites
Here''s how microsoft does it, why do what''s already been done?

D3DVERTEX* g_pTerrainVertices = NULL;
DWORD g_dwNumTerrainVertices = 0L;
WORD* g_pTerrainIndices = NULL;
DWORD g_dwNumTerrainIndices = 0L;

VOID GenerateTerrainGrid( DWORD dwGridSize, FLOAT fScale )
{
DWORD i, j, ind;

g_dwNumTerrainVertices = dwGridSize * dwGridSize;
g_dwNumTerrainIndices = (dwGridSize-1) * (dwGridSize-1) * 6;
g_pTerrainVertices = new D3DVERTEX[ g_dwNumTerrainVertices ];
g_pTerrainIndices = new WORD[ g_dwNumTerrainIndices ];

for( i=0; i {
for( j=0; j {
FLOAT u = i / (FLOAT)(dwGridSize-1);
FLOAT v = j / (FLOAT)(dwGridSize-1);
FLOAT x = fScale * ( 2*u - 1 );
FLOAT z = fScale * ( 2*v - 1 );

g_pTerrainVertices[i*dwGridSize+j] =
D3DVERTEX( D3DVECTOR(x,0,z), D3DVECTOR(0,1,0), u, v );
}
}

for( i=ind=0; i {
for( j=0; j {
g_pTerrainIndices[ind++] = (WORD)( (i+0)*dwGridSize + (j+0) );
g_pTerrainIndices[ind++] = (WORD)( (i+0)*dwGridSize + (j+1) );
g_pTerrainIndices[ind++] = (WORD)( (i+1)*dwGridSize + (j+0) );
g_pTerrainIndices[ind++] = (WORD)( (i+1)*dwGridSize + (j+0) );
g_pTerrainIndices[ind++] = (WORD)( (i+0)*dwGridSize + (j+1) );
g_pTerrainIndices[ind++] = (WORD)( (i+1)*dwGridSize + (j+1) );
}
}
}

Share this post


Link to post
Share on other sites
I tried to use that, but it didnt seem to work...What the heck are Indices, anyway? The SDK assumes that you know what they are. Also, it seems to require global vars. I tried to adapt it to use this struct:

struct terrain {
D3DVERTEX* g_pTerrainVertices;
DWORD g_dwNumTerrainVertices;
WORD* g_pTerrainIndices;
DWORD g_dwNumTerrainIndices;
}

And i changed the argument list of GenerateTerrainGrid to this:

VOID GenerateTerrainGrid( terrain &plane, DWORD dwGridSize, FLOAT fScale )

I replaced all the references to the global vars to point to plane, but it didnt seem to work. Yes, I used DrawIndexedPrimitive, but it wouldnt draw anything at all.

I really want a routine that can make rough ground; that one cant.


Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!