Jump to content
  • Advertisement
Sign in to follow this  
Baf

textures and ligths: HELP ME!!!!

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

i'm new, i don't know how to use textures and lights at the same time. I created 3d textured tiles and one directional light but it hits only my loaded meshes, why?

Share this post


Link to post
Share on other sites
Advertisement
Have you made sure that the vertices you are using for your tiles have normals?

Can you post some code.

ace

Share this post


Link to post
Share on other sites
Hi there Baf,
How are you doing?
[The problem]
You light only hits the loaded meshes. 2 things might be happening here.

[The possible solutions]
When working with light you have 2 very important components to note.

1) The normals
2) The material associated with the object (Tells direct3d how you want the light to behave when it hits the material associated with the object
Material:
"A property that determines how a surface reflects light. A material has emissive, diffuse, ambient, and specular properties. The emissive property describes the color of light that a material emits. The diffuse, ambient, and specular properties describe the behavior of reflected light. The sharpness of specular highlights is determined by a power setting. "

Make sure you have a material associated and the normals of the tiles are set.

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
hello Ace and Armadon, help me again...please

I tried with normals and light now hits tiles!! thank you

but isn't a good scene on the screen. it looks vary bad
my tiles are square and drawn in trianglestrip, i don't know how to compute normals,
i have 4 vertex: clockwise 0,1,3,2

i created this function but don't works i think..

the function is for vertex 0(input vertex 0,1,2) e 3 (input vertex 1,2,3)
D3DXVECTOR3 tile::normal( customvertex v1, customvertex v2, customvertex v3){
D3DXVECTOR3 v;
v.x=(v2.y-v1.x)*(v3.z-v1.z)*(v1.y-v3.y)*(v1.z-v2.z);
v.y=(v2.z-v1.z)*(v3.x-v1.x)*(v1.z-v3.z)*(v1.x-v2.x);
v.z=(v2.x-v1.x)*(v3.y-v1.y)*(v1.x-v3.x)*(v1.y-v2.y);
return v;
}
and for vertex 1 e 2 i tried
float k=0.5 ;
D3DXVec3Lerp(&v,&v1,&v2,k);
i have no more ideas!!!! my light is directional (1,0,0)

Share this post


Link to post
Share on other sites
Hi there Baf,
How are you doing?

[The Problem]
Computing normals for your tiles?

[The Solution]
Direct3D comes to the rescue once again.
It supplies us with a cool little equation in the mesh class called Compute Normals.

D3DXComputeNormals:
Computes unit normals for each vertex in a mesh. Provided to support legacy applications. Use D3DXComputeTangentFrameEx for better results.

So what you can do is send your index buffer and vertex buffer to a newly created mesh.

e.g.

ID3DXMesh* mesh;
D3DXCreateMesh(numFaces, numVertices, D3DXMESH_MANAGED, D3DFVF_POSITION | D3DFVF | D3DFVF_NORMAL | D3DFVF_TEX0, device, &mesh);
//Lock the vertex buffer and index buffer and feed it your values.
//after that compute the normals of the mesh
D3DXComputeNormals(mesh, NULL);




I hope this helps a bit.
Keep cool.

Share this post


Link to post
Share on other sites
Thank you Armadon!!! now i can see my terrain,

it looks sharp but it's my first creation

how can i learn more about terrains?





Share this post


Link to post
Share on other sites
There's a wonderful book I read called focus on terrain programming - or something like that. I have forgotten the authors name, but its a small, to the point book that taught me wonders.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!