[vtkusers] altering the normals
mepisto
mepisto at hotmail.com
Sat Jun 22 07:46:49 EDT 2002
hi all,
I m trying to simulate bump mapping on a sphere by changing the normals in a random manner. I actually make a vtkFloatArray with random numbers and copy that array with the SetNormals to a vtkPointData of the sphere.
The methode doesnt work. What I m I doing wrong?
kind regards
Stijn
#------------------------------
# BUMP MAPPING
#------------------------------
# create the sphere
vtkSphereSource bump
bump SetThetaResolution 20
bump SetPhiResolution 20
bump SetRadius 1.8
bump Update
vtkPolyDataNormals qqq
qqq SetInput [bump GetOutput]
qqq ComputePointNormalsOn
qqq Update
vtkPolyData pDatat
set pDatat [bump GetOutput]
puts [$pDatat GetNumberOfPoints]
pDatat Update
vtkPointData pData1
set pData1 [[[qqq GetOutput] GetPointData] GetNormals] #get the normals data
puts [$pData1 GetNumberOfTuples ]
pData1 Update
vtkFloatArray floatArrayNormals
vtkMath rand
floatArrayNormals SetNumberOfComponents 3
floatArrayNormals SetNumberOfTuples 362
for {set i 0} {$i<362} {incr i} {
floatArrayNormals InsertNextValue [rand Random 0 1]
# puts [floatArrayNormals GetValue $i]
}
puts [floatArrayNormals GetNumberOfTuples]
pData1 SetNormals floatArrayNormals
pData1 Update
pDatat Update
qqq Update
bump Update
vtkPolyDataMapper bumpMapper
bumpMapper SetInput [bump GetOutput]
vtkActor bumpActor
bumpActor SetMapper bumpMapper
[bumpActor GetProperty] SetColor 0.9 0.1 0.15
bumpActor SetPosition 2.5 1.6 2.55
eval [bumpActor GetProperty] SetInterpolationToGouraud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020622/88e9a310/attachment.htm>
More information about the vtkusers
mailing list