odd entityshininess problem

Blitz3D Forums/Blitz3D Beginners Area/odd entityshininess problem

Nate the Great(Posted 2008) [#1]
here is my code.




I was confused when I discovered that the red triangle that I created didn't have the same shininess effects as the rest of the cube. does anyone know what I am doing wrong or why this is happening?


Nate the Great(Posted 2008) [#2]
edit

does anyone know if this is a bug in blitz3d?


Zethrax(Posted 2008) [#3]
Odd. If you do an 'UpdateNormals ripple' before applying any of the visible properties, the EntityColor is not applied to the rectangle either.

Switching 'FlipMesh' to be before the visible properties are applied didn't change anything, so that's apparently not the cause of the problem.

Creating a brush and using PaintMesh and PaintSurface didn't fix the problem.


Stevie G(Posted 2008) [#4]
Shininess depends on vertex normals which you are not speficying for the 4 new vertexes.

If you use Updatenormals after the flip command this should work.


Floyd(Posted 2008) [#5]
The trouble here is that UpdateNormals considers all triangles which share a given vertex. When two identical triangles are placed "back to back" everything cancels out and the normal vectors become zero.

You really should specify the normals manually when building the mesh. This guarantees you get what you want, not what UpdateNormals guesses you want. However, here is a lazy fix without doing that.

Graphics3D 640,480,0,2

cam = CreateCamera()
TurnEntity cam,90,0,0
MoveEntity cam,0,0,-10
CameraZoom cam, 5


lit = CreateLight()
TurnEntity lit,90,0,0

square = CreateMesh()
ripsurf = CreateSurface(square)

v1 = AddVertex(ripsurf,-1,0,-1)
v2 = AddVertex(ripsurf,-1,0,1)
v3 = AddVertex(ripsurf,1,0,-1)
v4 = AddVertex(ripsurf,1,0,1)

AddTriangle(ripsurf,v1,v2,v3)
AddTriangle(ripsurf,v2,v4,v3)

; We have a one-sided square with no normals defined. Now apply quick and dirty fix.

UpdateNormals square

temp = CopyMesh(square)
FlipMesh temp
AddMesh temp, square
FreeEntity temp

EntityColor square,255,0,0

EntityShininess square,1

While Not KeyDown(1)
	TurnEntity square,1,0,0
	RenderWorld
	Flip
Wend



Nate the Great(Posted 2008) [#6]
Thanks for the help! It works now. I have run into this problem many times before but I have never been able to solve it. Thanks again