Commit e245c01c authored by Ken Martin's avatar Ken Martin
Browse files

new renderer arch

parent 53a361aa
......@@ -163,14 +163,14 @@ view_calc (Xgl_pt_f3d *eye, Xgl_pt_f3d *focus,
// Description:
// Implement base class method.
void vlXglrCamera::Render(vlRenderer *ren)
void vlXglrCamera::Render(vlCamera *cam, vlRenderer *ren)
{
this->Render((vlXglrRenderer *)ren);
this->Render(cam, (vlXglrRenderer *)ren);
}
// Description:
// Actual camera render method.
void vlXglrCamera::Render(vlXglrRenderer *ren)
void vlXglrCamera::Render(vlCamera *cam, vlXglrRenderer *ren)
{
Xgl_ctx *context;
Xgl_win_ras *win_ras = NULL; // XGLR Window Raster object
......@@ -186,6 +186,7 @@ void vlXglrCamera::Render(vlXglrRenderer *ren)
float twist;
float matrix[4][4];
vlXglrRenderWindow *rw;
float *Position, *FocalPoint, *ClippingRange;
context = ren->GetContext();
win_ras = ren->GetRaster();
......@@ -201,7 +202,7 @@ void vlXglrCamera::Render(vlXglrRenderer *ren)
switch ((ren->GetRenderWindow())->GetStereoType())
{
case VL_STEREO_CRYSTAL_EYES:
if (this->LeftEye)
if (cam->GetLeftEye())
{
xgl_object_set(*win_ras,
XGL_WIN_RAS_STEREO_MODE,XGL_STEREO_LEFT,NULL);
......@@ -224,12 +225,16 @@ void vlXglrCamera::Render(vlXglrRenderer *ren)
}
ClippingRange = cam->GetClippingRange();
Position = cam->GetPosition();
FocalPoint = cam->GetFocalPoint();
// get the background color
background = ren->GetBackground();
bg_color.r = background[0];
bg_color.g = background[1];
bg_color.b = background[2];
if (this->LeftEye || (!stereo) ||
if (cam->GetLeftEye() || (!stereo) ||
((ren->GetRenderWindow())->GetStereoType() != VL_STEREO_CRYSTAL_EYES))
{
xgl_object_set(*context,XGL_CTX_BACKGROUND_COLOR,
......@@ -251,41 +256,41 @@ void vlXglrCamera::Render(vlXglrRenderer *ren)
ren->SetAspect(aspect);
trans = xgl_object_create(xglr_sys_state,XGL_TRANS,NULL,NULL);
eye.x = this->Position[0];
eye.y = this->Position[1];
eye.z = this->Position[2];
focus.x = this->FocalPoint[0];
focus.y = this->FocalPoint[1];
focus.z = this->FocalPoint[2];
eye.x = Position[0];
eye.y = Position[1];
eye.z = Position[2];
focus.x = FocalPoint[0];
focus.y = FocalPoint[1];
focus.z = FocalPoint[2];
/* xgl_object_set(*context,XGL_CTX_VDC_WINDOW, &vdc_bounds, NULL); */
xgl_object_set(*context,XGL_CTX_VDC_WINDOW, &vdc_bounds, NULL);
xgl_object_set(*context,XGL_CTX_VIEW_CLIP_BOUNDS, &vdc_bounds, NULL);
twist = this->GetTwist();
twist = cam->GetTwist();
if (stereo)
{
if (this->LeftEye)
if (cam->GetLeftEye())
{
view_calc(&eye,&focus,this->ClippingRange[0],
this->ClippingRange[1],
this->ViewAngle,twist,&trans,this->Distance,
-1.0*this->EyeAngle,aspect[0]/aspect[1]);
view_calc(&eye,&focus,ClippingRange[0],
ClippingRange[1],
cam->GetViewAngle(),twist,&trans,cam->GetDistance(),
-1.0*cam->GetEyeAngle(),aspect[0]/aspect[1]);
}
else
{
view_calc(&eye,&focus,this->ClippingRange[0],
this->ClippingRange[1],
this->ViewAngle,twist,&trans,this->Distance,
this->EyeAngle,aspect[0]/aspect[1]);
view_calc(&eye,&focus,ClippingRange[0],
ClippingRange[1],
cam->GetViewAngle(),twist,&trans,cam->GetDistance(),
cam->GetEyeAngle(),aspect[0]/aspect[1]);
}
}
else
{
view_calc(&eye,&focus,this->ClippingRange[0],
this->ClippingRange[1],
this->ViewAngle,twist,&trans,this->Distance,
view_calc(&eye,&focus,ClippingRange[0],
ClippingRange[1],
cam->GetViewAngle(),twist,&trans,cam->GetDistance(),
0.0,aspect[0]/aspect[1]);
}
......@@ -297,7 +302,7 @@ void vlXglrCamera::Render(vlXglrRenderer *ren)
// if we have a stereo renderer, draw other eye next time
if (stereo)
{
if (this->LeftEye) this->LeftEye = 0;
else this->LeftEye = 1;
if (cam->GetLeftEye()) cam->SetLeftEye(0);
else cam->SetLeftEye(1);
}
}
......@@ -20,29 +20,35 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
// Description:
// Implement base class method.
void vlXglrLight::Render(vlRenderer *ren,int light_index)
void vlXglrLight::Render(vlLight *lgt, vlRenderer *ren,int light_index)
{
this->Render((vlXglrRenderer *)ren,light_index);
this->Render(lgt, (vlXglrRenderer *)ren,light_index);
}
// Description:
// Actual light render method.
void vlXglrLight::Render(vlXglrRenderer *ren,int light_index)
void vlXglrLight::Render(vlLight *lgt, vlXglrRenderer *ren,int light_index)
{
Xgl_light *lights;
Xgl_color light_color;
Xgl_pt_f3d direction;
float *Color, *Position, *FocalPoint;
float Intensity;
lights = ren->GetLightArray();
// get required info from light
light_color.rgb.r = this->Intensity * this->Color[0];
light_color.rgb.g = this->Intensity * this->Color[1];
light_color.rgb.b = this->Intensity * this->Color[2];
Intensity = lgt->GetIntensity();
Color = lgt->GetColor();
light_color.rgb.r = Intensity * Color[0];
light_color.rgb.g = Intensity * Color[1];
light_color.rgb.b = Intensity * Color[2];
direction.x = this->Position[0] - this->FocalPoint[0];
direction.y = this->Position[1] - this->FocalPoint[1];
direction.z = this->Position[2] - this->FocalPoint[2];
FocalPoint = lgt->GetFocalPoint();
Position = lgt->GetPosition();
direction.x = Position[0] - FocalPoint[0];
direction.y = Position[1] - FocalPoint[1];
direction.z = Position[2] - FocalPoint[2];
lights = ren->GetLightArray();
// define the light source
xgl_object_set(lights[light_index],
......
......@@ -21,66 +21,77 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
// Description:
// Implement base class method.
void vlXglrProperty::Render(vlRenderer *ren)
void vlXglrProperty::Render(vlProperty *prop, vlRenderer *ren)
{
this->Render((vlXglrRenderer *)ren);
this->Render(prop, (vlXglrRenderer *)ren);
}
// Description:
// Actual property render method.
void vlXglrProperty::Render(vlXglrRenderer *ren)
void vlXglrProperty::Render(vlProperty *prop, vlXglrRenderer *ren)
{
int i, method, line_method;
Xgl_ctx *context;
Xgl_color_rgb diffuseColor;
Xgl_color_rgb specularColor;
float Ambient, Diffuse, Specular;
float *AmbientColor, *DiffuseColor, *SpecularColor;
Ambient = prop->GetAmbient();
Diffuse = prop->GetDiffuse();
Specular = prop->GetSpecular();
AmbientColor = prop->GetAmbientColor();
DiffuseColor = prop->GetDiffuseColor();
SpecularColor = prop->GetSpecularColor();
// get the context for this renderer
context = ren->GetContext();
diffuseColor.r = this->DiffuseColor[0];
diffuseColor.g = this->DiffuseColor[1];
diffuseColor.b = this->DiffuseColor[2];
specularColor.r = this->SpecularColor[0];
specularColor.g = this->SpecularColor[1];
specularColor.b = this->SpecularColor[2];
diffuseColor.r = DiffuseColor[0];
diffuseColor.g = DiffuseColor[1];
diffuseColor.b = DiffuseColor[2];
specularColor.r = SpecularColor[0];
specularColor.g = SpecularColor[1];
specularColor.b = SpecularColor[2];
// see if this is a frontface or backface property
if (this->Backface == 0.0)
if (prop->GetBackface() == 0.0)
{
xgl_object_set(*context,
XGL_3D_CTX_SURF_FRONT_AMBIENT, this->Ambient,
XGL_3D_CTX_SURF_FRONT_DIFFUSE, this->Diffuse,
XGL_3D_CTX_SURF_FRONT_SPECULAR, this->Specular,
XGL_3D_CTX_SURF_FRONT_SPECULAR_POWER, this->SpecularPower,
XGL_3D_CTX_SURF_FRONT_AMBIENT, Ambient,
XGL_3D_CTX_SURF_FRONT_DIFFUSE, Diffuse,
XGL_3D_CTX_SURF_FRONT_SPECULAR, Specular,
XGL_3D_CTX_SURF_FRONT_SPECULAR_POWER,
prop->GetSpecularPower(),
XGL_3D_CTX_SURF_FRONT_SPECULAR_COLOR, &specularColor,
XGL_CTX_SURF_FRONT_COLOR, &diffuseColor,
XGL_CTX_LINE_COLOR, &DiffuseColor,
XGL_3D_CTX_SURF_BACK_AMBIENT, this->Ambient,
XGL_3D_CTX_SURF_BACK_DIFFUSE, this->Diffuse,
XGL_3D_CTX_SURF_BACK_SPECULAR, this->Specular,
XGL_3D_CTX_SURF_BACK_SPECULAR_POWER, this->SpecularPower,
XGL_3D_CTX_SURF_BACK_AMBIENT, Ambient,
XGL_3D_CTX_SURF_BACK_DIFFUSE, Diffuse,
XGL_3D_CTX_SURF_BACK_SPECULAR, Specular,
XGL_3D_CTX_SURF_BACK_SPECULAR_POWER,
prop->GetSpecularPower(),
XGL_3D_CTX_SURF_BACK_SPECULAR_COLOR, &specularColor,
XGL_3D_CTX_SURF_BACK_COLOR, &diffuseColor,
XGL_3D_CTX_SURF_FRONT_TRANSP, 1.0-this->Transparency,
XGL_3D_CTX_SURF_BACK_TRANSP, 1.0-this->Transparency,
XGL_3D_CTX_SURF_FRONT_TRANSP, 1.0-prop->GetTransparency(),
XGL_3D_CTX_SURF_BACK_TRANSP, 1.0-prop->GetTransparency(),
NULL);
}
else
{
xgl_object_set(*context,
XGL_3D_CTX_SURF_BACK_AMBIENT, this->Ambient,
XGL_3D_CTX_SURF_BACK_DIFFUSE, this->Diffuse,
XGL_3D_CTX_SURF_BACK_SPECULAR, this->Specular,
XGL_3D_CTX_SURF_BACK_SPECULAR_POWER, this->SpecularPower,
XGL_3D_CTX_SURF_BACK_AMBIENT, Ambient,
XGL_3D_CTX_SURF_BACK_DIFFUSE, Diffuse,
XGL_3D_CTX_SURF_BACK_SPECULAR, Specular,
XGL_3D_CTX_SURF_BACK_SPECULAR_POWER, prop->GetSpecularPower(),
XGL_3D_CTX_SURF_BACK_SPECULAR_COLOR, &specularColor,
XGL_3D_CTX_SURF_BACK_COLOR, &diffuseColor,
XGL_3D_CTX_SURF_BACK_TRANSP, 1.0-this->Transparency,
XGL_3D_CTX_SURF_BACK_TRANSP, 1.0-prop->GetTransparency(),
NULL);
return;
}
switch (this->Representation)
switch (prop->GetRepresentation())
{
case VL_POINTS:
xgl_object_set(*context,
......@@ -109,7 +120,7 @@ void vlXglrProperty::Render(vlXglrRenderer *ren)
}
// set interpolation
switch (this->Interpolation)
switch (prop->GetInterpolation())
{
case VL_FLAT:
method = XGL_ILLUM_PER_FACET;
......@@ -132,6 +143,5 @@ void vlXglrProperty::Render(vlXglrRenderer *ren)
NULL);
// Tell the geometry primitives about the default properties
vlXglrPrimitive::SetProperty(this);
vlXglrPrimitive::SetProperty(prop);
}
......@@ -3,8 +3,8 @@
Program: Visualization Library
Module: XglrRen.cc
Language: C++
Date: $Date$
Version: $Revision$
Date: 04/20/95
Version: 1.2
This file is part of the Visualization Library. No part of this file or its
contents may be copied, reproduced or altered in any way without the express
......
......@@ -36,28 +36,14 @@ vlXglrRenderWindow::vlXglrRenderWindow()
strcpy(this->Name,"Visualization Library - XGL");
}
// Description:
// Create a XGL-specific actor.
vlActor *vlXglrRenderWindow::MakeActor()
{
vlActor *actor;
vlXglrProperty *prop;
actor = new vlActor;
prop = new vlXglrProperty;
actor->SetProperty((vlProperty *)prop);
return (vlActor *)actor;
}
// Description:
// Create a XGL specific light.
vlLight *vlXglrRenderWindow::MakeLight()
vlLightDevice *vlXglrRenderWindow::MakeLight()
{
vlXglrLight *light;
light = new vlXglrLight;
return (vlLight *)light;
return (vlLightDevice *)light;
}
// Description:
......@@ -77,32 +63,32 @@ vlRenderer *vlXglrRenderWindow::MakeRenderer()
// Description:
// Create a XGL specific camera.
vlCamera *vlXglrRenderWindow::MakeCamera()
vlCameraDevice *vlXglrRenderWindow::MakeCamera()
{
vlXglrCamera *camera;
camera = new vlXglrCamera;
return (vlCamera *)camera;
return (vlCameraDevice *)camera;
}
// Description:
// Create a XGL specific property.
vlProperty *vlXglrRenderWindow::MakeProperty()
vlPropertyDevice *vlXglrRenderWindow::MakeProperty()
{
vlXglrProperty *property;
property = new vlXglrProperty;
return (vlProperty *)property;
return (vlPropertyDevice *)property;
}
// Description:
// Create a XGL specific texture.
vlTexture *vlXglrRenderWindow::MakeTexture()
vlTextureDevice *vlXglrRenderWindow::MakeTexture()
{
vlXglrTexture *texture;
texture = new vlXglrTexture;
return (vlTexture *)texture;
return (vlTextureDevice *)texture;
}
// Description:
......
......@@ -31,14 +31,14 @@ vlXglrTexture::vlXglrTexture()
// Description:
// Implement base class method.
void vlXglrTexture::Load(vlRenderer *ren)
void vlXglrTexture::Load(vlTexture *txt, vlRenderer *ren)
{
this->Load((vlXglrRenderer *)ren);
this->Load(txt, (vlXglrRenderer *)ren);
}
// Description:
// Actual Texture load method.
void vlXglrTexture::Load(vlXglrRenderer *ren)
void vlXglrTexture::Load(vlTexture *txt, vlXglrRenderer *ren)
{
// currently a nop
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment