<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi all,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; I did a little class that open 
an stl file, the construction of this classe set all parameters to see a blue 
background and gouraud shaded object.</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; I instantiate my class on 
WM_CREATE funcion of visual c++ wizard.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; Until now all works fine, but 
when I try change background color through a method that I&nbsp;implemented, I 
always recieve a error message saying&nbsp;the memory can't be read, acess 
violation.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; What is wrong ?</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; Can't I acess a RenderWindow 
object method after it has being created ?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; Look a fragment of my 
code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2><STRONG>method to change background 
color:</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><EM>&nbsp;&nbsp;&nbsp; void 
CVTKStlViewer::BackgroundColor(COLORREF 
newColor)<BR>{<BR>&nbsp;<BR>&nbsp;ren-&gt;SetBackground(GetRValue(newColor),GetGValue(newColor),GetBValue(newColor));&nbsp;</EM><STRONG>// 
this&nbsp;line is the 
problem</STRONG><BR><EM>&nbsp;iren-&gt;Render();</EM></FONT></DIV>
<DIV><EM></EM>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><EM>}</EM></FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
</FONT></DIV><STRONG>constructor:</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2>CVTKStlViewer::CVTKStlViewer(HWND 
childview)<BR>{<BR>&nbsp;BkgColor = RGB(0,0,1);<BR>&nbsp;ObjColor = 
RGB(1,0.5,0);<BR>&nbsp;</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=Arial size=2>
<DIV><BR>&nbsp;// create a rendering window and renderer<BR>&nbsp; vtkRenderer 
*ren = vtkRenderer::New();<BR>&nbsp; vtkRenderWindow *renWindow = 
vtkRenderWindow::New();<BR>&nbsp;&nbsp;&nbsp; 
renWindow-&gt;AddRenderer(ren);<BR>&nbsp;renWindow-&gt;SetParentId(childview);<BR>&nbsp;renWindow-&gt;SetSize( 
800, 600 );</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;iren = 
vtkRenderWindowInteractor::New();<BR>&nbsp;vtkInteractorStyleTrackballCamera 
*TrackballCameraStyle = vtkInteractorStyleTrackballCamera::New();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;iren-&gt;SetInteractorStyle 
(TrackballCameraStyle);<BR>&nbsp;&nbsp;iren-&gt;SetRenderWindow(renWindow);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;sr = vtkSTLReader::New();<BR>&nbsp;&nbsp;sr-&gt;SetFileName 
("c:/vtk-src-windows/vtkData/cow.stl");</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;vtkPolyDataNormals *pNormals = 
vtkPolyDataNormals::New();<BR>&nbsp;&nbsp;pNormals-&gt;SetFeatureAngle 
(80);<BR>&nbsp;&nbsp;pNormals-&gt;SetInput(sr-&gt;GetOutput());</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;stlMapper = 
vtkPolyDataMapper::New();<BR>&nbsp;&nbsp;stlMapper-&gt;SetInput(pNormals-&gt;GetOutput());</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;stlActor = 
vtkLODActor::New();<BR>&nbsp;&nbsp;stlActor-&gt;SetMapper(stlMapper);<BR>&nbsp;&nbsp;stlActor-&gt;GetProperty()-&gt;SetColor(GetRValue(ObjColor),GetGValue(ObjColor),GetBValue(ObjColor));</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;&nbsp;stlActor-&gt;GetProperty()-&gt;SetInterpolationToGouraud();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;ren-&gt;AddActor(stlActor);<BR>&nbsp;ren-&gt;SetBackground(GetRValue(BkgColor),GetGValue(BkgColor),GetBValue(BkgColor));</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; // draw the resulting scene<BR>&nbsp;renWindow-&gt;Render();</DIV>
<DIV>&nbsp;</DIV>
<DIV>}</FONT></DIV></BODY></HTML>