specific triangles

Blitz3D Forums/Blitz3D Programming/specific triangles

Eviltoes(Posted 2007) [#1]
I am trying to make my own lighting system for my current project, I have been thinking a lot as to how I would make meshes light up on one side and not the other, in response to a light source near by, without using blitz3d's lights. I decided that the best way I could do this is to check the triangles near my lights for whetrher or not they can "see" it. But i do not know how I would go about cycling through all the triangles in a mesh, and anyway, this seems like it would be awfully slow. Is there a better way to do this that doesn't require any external dlls and does not use b3d's lights? Even if, how would you cycle through all the triangles in a mesh?


Matty(Posted 2007) [#2]
Looping through all triangles in a mesh and altering the vertex colors for each vertex will be much slower than blitz3d's standard light system and not look any better.

To cycle through all triangles/vertices in a mesh you would do something like this:


for s=1 to countsurfaces(mesh)
     surf=getsurface(mesh,s)
     for v=0 to countvertices(surf)-1
           ;reference your vertex/vertices here with the vertexred/vertexgreen and vertexblue functions

     next 

next




Stevie G(Posted 2007) [#3]
Have a look at the lightmesh - never used it myself as happy with Blitz lights. You doing a flashlight or something?


big10p(Posted 2007) [#4]
Yeah, what do you need this for and why are B3D/DX lights no good?

To do this yourself in software would only mean having to do what DX lights are doing in hardware anyway, and so would be much slower.


Eviltoes(Posted 2007) [#5]
I'm just want to see if I can do it.

And I don't like b3d's lights, b3d's lights aren't what I'm looking for, I want for the light to really only light a certain area, like a lamp would only allow one to see, say 20 feet, and if there is another person in the distance with a lamp, you could see everything in that lamp's range, but nothing in between, I've noticed that even with the lightrange() command, I can still see pretty much everything outside the light's range.

And I don't know what DX's lights look like, I think. How would you switch between b3d's lights and DX's?


Subirenihil(Posted 2007) [#6]
AmbientLight 0,0,0 ;Default is 128,128,128 which makes everything visible

LightRange seems to not be setting a cutoff range so much as the scale of the falloff. This falloff matches realistic light behavior. The amount of light that reaches the object is inversely proportional to the square of the distance between the light and the object. Therefore all object will be lit by a point light, albeit far ones will be very dimly lit.