Public Group

#### Archived

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

# Movement & Textures

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

## Recommended Posts

I might as well kill two birds with one stone here. This is where I am at right now. I have two triangles which comprise my ground. Its textured with this cheese grass texture I created. Problem one, the ground and the walls are created in the same struct. Am I still able to texture both the walls and the ground with different textures? If so, how, they are assigned the texture both at ->SetTexture(0, &g_pTexture), how would I load up more then one texture? Next questions how can I control the movement of the camera. I am currently doing everything with the matrices, and if you press a key I call a function called MoveForward(), which sets my Player struct position, which is D3DXVECTOR3, to z+=(velocity) * (cosf(g_Player.angle)); where angle is static at 1.0f. It moves in a Z motion zooming in. But does anyone have a tutorial on WHY we have to use cosf and sinf to get these things done. I''m not super in math, but I can do that math, I just can''t remember it :D

##### Share on other sites
Hi again,

If you have the walls and the floor in the same vertex buffer, you can still draw the wall vertices and floor vertices by separate DrawPrimitive calls. Just set the start offset when drawing, as i explained earlier.

You may be confused in the "assign texture to object" part.
One doesn''t actually assign textures to objects, but when one sets a texture to the device, all drawing operations from that point on will use the texture, until a new texture (or null) is set.

As for trigonometry, that''s the way it is. Don''t worry, though, when you use it actively you will remember it better

-Nik

##### Share on other sites
Yeah I have the floor textured but not the walls. But my setTexture is handled in my RENDER() function. I was just wondering how I could texture my walls if everything is in the same process.

My Render function looks something like:

g_pd3dDevice->SetTexture(0, &g_pTexture);
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 8);
g_pd3dDevice->SetTexture(0, 0);
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 9,12);

Something like that. Now how would I load another texture? It looks like i would have to go,

g_pd3dDevice->SetTexture(0, &g_pTexture);
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 8);
DXD3DCreateTextureFromFile("NEWTEXTURE.jpg");
g_pd3dDevice->SetTexture(0, &g_pTexture);
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 9,12);

Which obviously wouldn''t be too "elite" since the texture added is being handled in the Render() function.

##### Share on other sites
Declare an another pointer for your second texture

Also, load all textures before rendering, the load process is relatively slow.

-Nik

##### Share on other sites
Thanks Nik, you have really helped me out with alot of this stuff! I appreciate it.

Mike

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633657
• Total Posts
3013197
×