Sign in to follow this  

D3DXCreateText Mesh -- Setting Textures

This topic is 3771 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

(DX9) Time for another newbie question by coderdave =-) Background: I use D3DXCreateText by using a ID3DXFont I made earlier (called localFont below)
	hres = D3DXCreateTextW(device, localFont->GetDC(),
		                 messageW, 0.001f, 0.4f, &fontMesh, NULL, NULL );

Let's say messageW is "Hello World!" so basically it creates a 3D Mesh of the text "Hello World!" for me and stores it in my not-so-exciting variable name, fontMesh. Everything is working perfectly so far. Except its pretty plain. Now I want to color this up. You know, put some jazz into it. Now I read on the DrunkenHyena that the vertex buffer in the resulting mesh is of FVF type D3DFVF_NORMAL | D3DFVF_XYZ and so far this empirically seems true for me........ hmm, nothing about texture coordinates in there. So using something like-
device->SetTexture(0, texture);

I find that, yeah, without texture coordinates, its coloring the whole thing with pixel (1,1) of my texture image! Doh! So the newb question of the day is --- how do I put more interesting textures onto this mesh that can span outside of (1,1) of the texture image? I've considered unlocking and writing into its vertex buffer and seeing if I can go about changing the FVF but somehow this seems to be a tragically wrong approach to me, or perhaps I lack the competance as a coder to invent a conversion that I know won't crash. Maybe texturing up mesh-text is just the wrong way to go about spicing up fonts in general? It could be, but I've seen other work that indicates otherwise (i.e., BluffTitler- a program that overlays "tricked out" 3d text onto movies and they're using DX9 for it).

Share this post


Link to post
Share on other sites
this is a non-trivial problem.

Use ID3DXMesh::CloneMesh() to add the texture coordinate storage, but then its down to to you to put the actual data in. D3DX provides UV Atlas support, but that might be overkill here. Some sort of projection based on the normals might work, but ultimately you have to define what you want to map and to where [smile]

hth
Jack

Share this post


Link to post
Share on other sites

This topic is 3771 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this