Mike Gralish wrote:
> I'm having a problem with a 3d mesh.
> It's a simple hard-coded mesh that makes a prism shape.
> It shows fine until i set the shader.blend to something besides 100.
>
> When I set the blend to say 90, It will sometimes show pixelated yellow/red,
> light blue, white, or not at all. This toggling happens dynamically when in
> the bounding rects of other moving objects. But it displays poorly even
> when soloing in the world.
>
> Once it blended beatifully... until I moved another object close to it, then
> the prism went a bright red. All this with no change in the constructor
> code. Changing the .visiblity (#both, #front, #back) doesn't seem to effect
> the blend problem.
> Is it mesh magic or am I gorking a parameter somewhere?
Working on a question arised about triangular extrusions in another Director list,
the way I found to get a prism free from magic was to add a fourth point to the
triangular end cap which, after having been extruded, defines the second end cap
as well as the six (+ 2) vertices of the prism (if I'm not wrong, your mesh
constructor is for a prism having triangles for end caps).
BTW the magic I experienced is a bit different from the one you reported. It is
essentially into the end caps that show, don't show, show in part and/or appear as
transparent. I don't think it's a problem of normals. Anyway their aspect is quite
phantasmal. The question is far from being definitely solved, at least for prisms
made up with eight faces. As I said, all problems seem vanish if both the triangular
ends are subdivided into three triangles each. This leads to a prism with 12 faces
and 8 vertices. I tried this type of prism also in a textured version, and it worked
well.
You may wish to give this code a shot. It builds the prism immediately in a new 3D
castmember, in the slot number five. In the case, copy the code below into a
movie script of a new movie internal cast, type buildColoredPrism() in the message
window and hit Enter. You should get a golden prism in the new 3D member that
is created in the slot #5.
Some things to take into consideration.
- I work with Windows + DirectX. Other types of renderers could produce different
results.
- If you open the 3D Inspector window (Dir 8.5) and click the button Rotate Camera the
prism
will seem rotate in the window and you'll see gray areas melded with the yellow
rotating
together with. This may be fuorviating on a first time, though if it's the camera to
rotate,
the prism never changes position in respect with the directional light, so the faces
in
shadow are ever the same.
- I can't observe a great influence of the shader on the rendering of the model. I
never used
one with simple coloured models, according to the example reported in the docs (the
piramid).
Though I saw you used one in the snippet of your code and I tried to apply it so as
it was.
With the shader I get one bright-white area on the vertex hit by the directional
light.
The area disappear commenting out 'meshShader = scene.newshader("mesh shd",
#standard)',
but setting meshShader.blend = 0 or = 100 its intensity does not change.
Also, it could be interesting having the missing part of your code to try with it.
-- <BOC>
on buildColoredPrism()
if member(5).type = #shockwave3d then member(5).erase()
scene = new(#shockwave3D, member(5))
scene.light("UIAmbient").color = rgb(255, 255, 255)
scene.light("UIDirectional").color = rgb(255, 255, 255)
p1 = vector( 0.0, -43.3, 37.5 ) -- define an equilater triangle
p2 = vector( 43.3, -43.3, -37.5 )
p3 = vector( -43.3, -43.3, -37.5 )
ed = 86.6 -- define the amplitude of the extrusion
p31 = 0.5 * (p3 - p1) -- calculate the baricenter of the triangle
(the fourth point)
q2 = p1 + p31
p22 = (p2 - q2) / 3.0
p4 = q2 + p22
-- define the extrusion vector as the normal to the triangle defined by p1, p2, p3
e = (p22.cross(p31)).getNormalized() * ed
meshShader = scene.newshader("mesh shd", #standard)
meshShader.blend = 100
-- define the mesh by means of the four original points and the four extruded ones
prism = scene.newModel("MP", mGenerateMesh(scene, p1, p2, p3, p4, p1 + e, p2 + e, p3
+ e, p4 + e))
prism.shaderList = meshShader
end
on mGenerateMesh(scene, p1, p2, p3, p4, p5, p6, p7, p8)
m = scene.newMesh("MPR", 12, 8, 0, 12, 0)
m.vertexList = [p1, p2, p3, p4, p5, p6, p7, p8]
m.colorList = [rgb("ffff00")]
-- The position attributes in the comments below apply to the initial front view
m.face[1].vertices = [3, 5, 7] -- Left end polygon (2 faces)
m.face[2].vertices = [3, 1, 5]
m.face[3].vertices = [1, 6, 5] -- Right end polygon (2 faces)
m.face[4].vertices = [1, 2, 6]
m.face[5].vertices = [2, 7, 6] -- Back end polygon (2 faces)
m.face[6].vertices = [2, 3, 7]
m.face[7].vertices = [2, 1, 4] -- Lower end polygon (3 faces)
m.face[8].vertices = [1, 3, 4]
m.face[9].vertices = [3, 2, 4]
m.face[10].vertices = [7, 5, 8] -- Upper end polygon (3 faces)
m.face[11].vertices = [5, 6, 8]
m.face[12].vertices = [6, 7, 8]
m.face[1].colors = [1, 1, 1]
m.face[2].colors = [1, 1, 1]
m.face[3].colors = [1, 1, 1]
m.face[4].colors = [1, 1, 1]
m.face[5].colors = [1, 1, 1]
m.face[6].colors = [1, 1, 1]
m.face[7].colors = [1, 1, 1]
m.face[8].colors = [1, 1, 1]
m.face[9].colors = [1, 1, 1]
m.face[10].colors = [1, 1, 1]
m.face[11].colors = [1, 1, 1]
m.face[12].colors = [1, 1, 1]
m.generateNormals(#smooth)
m.build()
return m
end
-- <EOC>
Hope this help,
IFC Programming Consultant
http://www.chnexus.com/athroon~/index.htm
mailto:[EMAIL PROTECTED] | [EMAIL PROTECTED]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]