void CGraphicsCamera::RotateX( double angleInc, CWindowFilter& filter )
{
	//keep track of our rotation - might need this later?
	m_rot.x += angleInc;
	if( m_rot.x > M_PI*2 )
		m_rot.x = 0.0;
	else if( m_rot.x < -M_PI*2 )
		m_rot.x = 0.0;
	filter.SetRotations( m_rot );

	//JL Note 2/11/2009 - let's try rotating about the global x axis...
	CVector3D right( 1, 0, 0);
	//get the quaternion representation of this rotation
	//CVector3D right = m_up.cross( CVector3D( m_pos, m_focalPt ).normalize() );
	CQuaternion quat( angleInc, CVector3D( right ).normalize() );
	double m[4][4] = {0.};
	//convert to the 4x4 rotation matrix form
	quat.QuatToMat( m );
	CVector3D v1( m_pos, m_focalPt );
	//multiply our view vector by the rotation matrix
	v1 = v1*m;
	//update our position
	m_pos = CPoint3D( v1.x + m_focalPt.x, v1.y + m_focalPt.y, v1.z + m_focalPt.z );
	//update our camera's up vector
	m_up = m_up*m;
}
void CGraphicsCamera::RotateXY( double xInc, double yInc, CWindowFilter& filter )
{
	m_rot.x += xInc;
	if( m_rot.x > M_PI*2 )
		m_rot.x = 0.0;
	else if( m_rot.x < -M_PI*2 )
		m_rot.x = 0.0;
	m_rot.y += yInc;
	if( m_rot.y > M_PI*2 )
		m_rot.y = 0.0;
	else if( m_rot.y < -M_PI*2 )
		m_rot.y = 0.0;
	filter.SetRotations( m_rot );

	//get the quaternion representation of this rotation
	CVector3D right = m_up.cross( CVector3D( m_pos, m_focalPt ).normalize() );
	CQuaternion xquat( xInc, CVector3D( right ).normalize() );
	CQuaternion yquat( yInc, m_up.normalize() );
	CQuaternion total_quat = xquat + yquat;
	total_quat.normalize();

	double m[4][4] = {0.};
	total_quat.QuatToMat( m );
	CVector3D v1( m_pos, m_focalPt );
	//multiply our view vector by the rotation matrix
	v1 = v1*m;
	//update our position
	m_pos = CPoint3D( v1.x + m_focalPt.x, v1.y + m_focalPt.y, v1.z + m_focalPt.z );
	//update our camera's up vector
	m_up = m_up*m;

}
예제 #3
0
CIntersectionInfo::CIntersectionInfo() : m_vecNormal(0,0,0), m_vecIncoming(0,0,0)
{
	m_colObject		= CColor (0,0,0);
	m_ptIntersection= CPoint3D (0,0,0);
	m_pShapeObject	= 0;
	m_texIntersection	= CTexCoords(0,0);
	m_eIntersectionType=ENTRY;
}
예제 #4
0
void
CQGnuPlotColorBox::
setOrigin(const QPointF &p)
{
  CPoint2D p1 = CQUtil::fromQPoint(p);

  CGnuPlotColorBox::setOrigin(CPoint3D(p1.x, p1.y, 0));
}
CGraphicsRigidDiaphragmLoad::CGraphicsRigidDiaphragmLoad( const CRigidDiaphragmLoad* pRDL ):
m_etDir( DY ),
m_loc( CPoint3D() ),
m_textPoint ( CPoint() ),
m_axis( CVector3D() ),
m_rot( 0.f ),
m_pRDL( pRDL )
{
}
CDataGraphicsPlate::~CDataGraphicsPlate(void)
{
	for( int i = 0; i < 4; i++ ){
		m_resultMagAtNode[i] = 0.;
		m_texCoords[i] = CPoint3D();
	}
	m_pP = NULL;
	m_pRC = NULL;
}
예제 #7
0
void ThothWindow::on_colorButton_clicked()
{
    ModelInfo mi;
    int pos = ui->buttonGroup->checkedId();
    int texture;
    popUp->setText("");
    if(pos != -1)
    {
        switch(pos)
        {
        case -2:
            qDebug() << "Pressed 1";
            mi.textureName.color.c1 = CPoint3D(m_color.red()/255.f, m_color.green()/255.f, m_color.blue()/255.f);
            mi.textureName.material.M1 = textureName;
            texture = 1;
            break;
        case -4:
            qDebug() << "Pressed 2";
            mi.textureName.color.c2 = CPoint3D(m_color.red()/255.f, m_color.green()/255.f, m_color.blue()/255.f);
            mi.textureName.material.M2 = textureName;
            texture = 2;
            break;
        case -3:
            qDebug() << "Pressed 3";
            mi.textureName.color.c3 = CPoint3D(m_color.red()/255.f, m_color.green()/255.f, m_color.blue()/255.f);
            mi.textureName.material.M3 = textureName;
            texture = 3;
            break;
        case -5:
            qDebug() << "Pressed 4";
            mi.textureName.color.c4 = CPoint3D(m_color.red()/255.f, m_color.green()/255.f, m_color.blue()/255.f);
            mi.textureName.material.M4 = textureName;
            texture = 4;
            break;

        }
        ui->statusBar->showMessage("Changing texture to the objet...", 2000);
        emit newModel(mi, texture);
    }
    else
    {
        popUp->setText("Select in which texture you want to put it");
    }
}
CGraphicsNodeLoad::CGraphicsNodeLoad( const CNodalLoad* pNL ):
m_etDir( DY ),
m_loc( CPoint3D() ),
m_textPoint ( CPoint() ),
m_axis( CVector3D() ),
m_rot( 0.f ),
m_pNL( pNL )
{
	SetupNodeLoad( );
}
CGraphicsCamera::CGraphicsCamera( HWND hWnd, HDC hDC, HGLRC hGLRC ) :
m_hDC( hDC ),
m_hGLRC( hGLRC ),
m_hWnd( hWnd ),
m_Aspect( 1.0 ),
m_up( CVector3D( 0., 1., 0. ) ),
m_pos( CPoint3D( 0.0, 0.0, -10.0 ) ),
m_dir( CVector3D( 0.0, 0.0, -1.0 ) ),
m_rot( CPoint3D( 0.0, 0.0, 0.0 ) ),
m_ViewVolumeWidth( EMPTY_VIEW_VOLUME_WIDTH ),
m_ViewVolumeHeight( EMPTY_VIEW_VOLUME_HEIGHT ),
m_Near( Z_NEAR ),
m_Far( Z_FAR ),
m_focalPt( CPoint3D::ORIGIN ),
m_bBusy( false ),
m_gridPlane(),
m_bPerspective( true ),
m_cx( 100 ),
m_cy( 100 )
{
}
//rotate the camera angleInc radians around a unit vector
void CGraphicsCamera::Rotate( CVector3D axis, double angleInc )
{
	CQuaternion quat( angleInc, axis.normalize() );
	double m[4][4] = {0.};
	quat.QuatToMat( m );
	CVector3D v1( m_pos, m_focalPt );
	//multiply our view vector by the rotation matrix
	v1 = v1*m;
	//update our position
	m_pos = CPoint3D( v1.x + m_focalPt.x, v1.y + m_focalPt.y, v1.z + m_focalPt.z );
	//update our camera's up vector
	m_up = m_up*m;
}
예제 #11
0
파일: RichModel.cpp 프로젝트: wxnfifth/DGG
void CRichModel::AssignColor(const vector<double>& diffused_value_r ,
                             const vector<double>& diffused_value_g ,
                             const vector<double>& diffused_value_b )
{
    m_vertex_colors.resize( m_Verts.size());
    assert(diffused_value_r.size() == m_vertex_colors.size());
    assert(diffused_value_g.size() == m_vertex_colors.size());
    assert(diffused_value_b.size() == m_vertex_colors.size());
    for(int i = 0; i < m_vertex_colors.size();++i) {
        m_vertex_colors[i] = CPoint3D(diffused_value_r[i] ,
                                      diffused_value_g[i] ,
                                      diffused_value_b[i]);
    }
}
예제 #12
0
파일: GeomCalc.cpp 프로젝트: vujn/chenan
//operators
//modified by wangxin 
CPoint3D CPoint3D::operator*( const MATRIX3D& matrix ) const
{
	double rx, ry, rz, sc;
	rx = x*matrix.a[0] + y*matrix.a[4] + z*matrix.a[8] + matrix.a[12];
	ry = x*matrix.a[1] + y*matrix.a[5] + z*matrix.a[9] + matrix.a[13];
	rz = x*matrix.a[2] + y*matrix.a[6] + z*matrix.a[10] + matrix.a[14];
	sc = x*matrix.a[3] + y*matrix.a[7] + z*matrix.a[11] + matrix.a[15];
	if(sc==0)
		sc=1;
	rx /= sc;
	ry /= sc;
	rz /= sc;
	return CPoint3D( rx, ry, rz );
}
//void CGraphicsCamera::Rotate
void CGraphicsCamera::Rotate( const CPoint3D& euler_angles )
{
	CQuaternion q( euler_angles.x, euler_angles.y, euler_angles.z );
	double m[4][4] = {0. };
	q.QuatToMat( m );
	CVector3D v1( m_pos, m_focalPt );
	double dist = v1.length();
	v1 = CVector3D( 0., 0., 1. );
	v1*dist;
	
	m_pos = CPoint3D( v1.x + m_focalPt.x, v1.y + m_focalPt.y, v1.z + m_focalPt.z );
	m_up = CVector3D( 0., 1., 0. );
	Rotate( CVector3D::X_AXIS, euler_angles.x );
	Rotate( CVector3D::Y_AXIS, euler_angles.y );
	Rotate( CVector3D::Z_AXIS, euler_angles.z );
	//m_up = m_up*m;
}
예제 #14
0
void CCustomParser::parse(const std::string& filename) {
	std::ifstream in(filename);
	std::string s;
	while(std::getline(in, s)) {
		std::istringstream s_stream(s);
		std::string cur_s;
		s_stream >> cur_s;
		if(cur_s == "sphere") {
			double c_x, c_y, c_z, radius;
			int r, g, b;
			s_stream >> c_x >> c_y >> c_z >> radius;
			s_stream >> r >> g >> b;
			CMaterial mat;
			mat.set_color(CColor(r, g, b));
			CSphere* sphere = new CSphere(radius, CPoint3D(c_x, c_y, c_z), mat);
			m_objects.push_back(sphere);	
		}
		else if(cur_s == "camera") {
void CDataGraphicsPlate::Initialize( const CPlanar* pP )
{
	m_pP = pP;
	for( int i = 0; i < 4; i++ ){
		m_resultMagAtNode[i] = 0.;
		m_texCoords[i] = CPoint3D();
	}
	CHECK_IF( pP )
	{
		m_bTriangle = (m_pP->node(4) == m_pP->node(1)) || (m_pP->node(4) == NULL);
		int nPts = m_bTriangle ? 3 : 4;
		for( int i = 0; i < nPts; i++ ) {
			const CNode* pN = m_pP->node(i+1);
			if( pN ) { // TeK Added Error checking, crashed with a corrupted file...
				m_points[i] = *pN;
			}
		}
	}
}
예제 #16
0
    void CCamera::Init() {
        m_eye = CPoint3D(0, 0, 1000.0);

        m_ref[0] = 0;
        m_ref[1] = 0;
        m_ref[2] = 0;

        m_far = 10000;
        m_near = 1;

        m_width = 2400.0;
        m_height = 2400.0;

        m_updir[0] = 0.0;
        m_updir[1] = 1.0;
        m_updir[2] = 0.0;

        m_screen[0] = 400;
        m_screen[1] = 400;
    }
// The following function is called to indicate how much of the 
// real world to use and also the center of the view
void CGraphicsCamera::SetupWorldSizeAndCenter( double width, double height,
											  double /*depth*/, double xCenter, 
											  double yCenter, double zCenter )
{
	// code below assumes an XY View (I think) and needs to be modified in the future
	m_ViewVolumeWidth = width;
	m_ViewVolumeHeight = height;
	m_pos.z = zCenter;
	//make sure we have good view of the origin
	if( equal( m_pos.z, 0.0 ) )
		m_pos.z = EMPTY_VIEW_VOLUME_ZPOS;

	m_pos.x = xCenter;
	m_pos.y = yCenter;

	m_focalPt = CPoint3D( xCenter, yCenter, zCenter );

	SetupViewVolume( width*2, height*2 );
	m_pos.z *= m_pos.z;
	MoveTo( m_pos );
}
예제 #18
0
파일: RichModel.cpp 프로젝트: wxnfifth/DGG
void CRichModel::ReadColorFile(const string& clr_file_name)
{
    m_vertex_colors.resize( m_Verts.size());
    FILE* clr_file = fopen(clr_file_name.c_str() , "r");
    for(int i = 0; i < m_vertex_colors.size();++i) {
        char buf[256];
        if ( fgets (buf , 100 , clr_file) != NULL ){
            int r , g , b;
            sscanf(buf,"%*s%d%d%d" , &r , &g , &b);
            g = 0;
            b = 0;
            m_vertex_colors[i] = CPoint3D(r/255.0,g/255.0,b/255.0);
            if( i < 10 ){
                fprintf(stderr,"%lf %lf %lf\n" , r/255.0,0,0);
            }
        }else{
            assert(false);
        }           
    }
    fclose(clr_file);
}
예제 #19
0
bool
CImportX3D::
read(CFile &file)
{
  file_ = &file;

  std::string line;

  file_->readLine(line);

  CStrWords words = CStrUtil::toWords(line, NULL);

  int num_points = CStrUtil::toInteger(words[0].getWord());
  int num_lines  = CStrUtil::toInteger(words[1].getWord());

  for (int i = 0; i < num_points; i++) {
    file_->readLine(line);

    CStrWords words = CStrUtil::toWords(line, NULL);

    double x =  CStrUtil::toReal(words[0].getWord());
    double y = -CStrUtil::toReal(words[1].getWord());
    double z =  CStrUtil::toReal(words[2].getWord());

    object_->addVertex(CPoint3D(x, y, z));
  }

  for (int j = 0; j < num_lines; j++) {
    file_->readLine(line);

    CStrWords words = CStrUtil::toWords(line, NULL);

    int start = CStrUtil::toInteger(words[0].getWord());
    int end   = CStrUtil::toInteger(words[1].getWord());

    object_->addLine(start, end);
  }

  return true;
}
void CGraphicsCamera::RotateZ( double angleInc, CWindowFilter& filter )
{
	m_rot.z += angleInc;
	if( m_rot.z > M_PI*2 )
		m_rot.z = 0.0;
	else if( m_rot.z < -M_PI*2 )
		m_rot.z = 0.0;
	filter.SetRotations( m_rot );

	//JL note 2/11/2009 - let's try rotating around the global z axis...
	CQuaternion quat( angleInc, CVector3D( 0, 0, 1 ) );
	//CQuaternion quat( angleInc, CVector3D( m_pos, m_focalPt ).normalize() );
	double m[4][4] = {0.};
	quat.QuatToMat( m );
	CVector3D v1( m_pos, m_focalPt );
	//multiply our view vector by the rotation matrix
	v1 = v1*m;
	//update our position
	m_pos = CPoint3D( v1.x + m_focalPt.x, v1.y + m_focalPt.y, v1.z + m_focalPt.z );
	//update our camera's up vector
	m_up = m_up*m;
}
예제 #21
0
CGeomAxes3D::
CGeomAxes3D(CGeomScene3D *pscene, const std::string &name) :
 CGeomObject3D(pscene, name)
{
  uint vertices[6];

  vertices[0] = addVertex(CPoint3D( 0,  0,  1));
  vertices[1] = addVertex(CPoint3D( 0,  0, -1));
  vertices[2] = addVertex(CPoint3D( 0,  1,  0));
  vertices[3] = addVertex(CPoint3D( 0, -1,  0));
  vertices[4] = addVertex(CPoint3D( 1,  0,  0));
  vertices[5] = addVertex(CPoint3D(-1,  0,  0));

  for (int i = 0; i < 3; ++i) {
    int v1 = vertices[2*i    ];
    int v2 = vertices[2*i + 1];

    addLine(v1, v2);
  }
}
예제 #22
0
static void
CCeilRayTraceMoveLightCmd(ClLanguageCommand *command, ClLanguageArgs *args, void *data)
{
  args->setSpaceSeparated(true);

  args->setArgs(command);

  std::string id    = "light";
  CPoint3D    delta = CPoint3D(0,0,0);

  uint num_args = args->getNumArgs();

  int error_code;

  for (uint i = 0; i < num_args; ++i) {
    std::string arg = args->getArg(i + 1, &error_code);

    if (arg[0] == '-') {
      if      (arg == "-id") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        id = args->getStringArg(i + 1, &error_code);
      }
      else if (arg == "-delta") {
        double *reals;
        uint    num_reals;

        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

        if (error_code == 0 && num_reals == 3)
          delta = CPoint3D(reals[0], reals[1], reals[2]);
      }
      else
        ClParserInst->error("Invalid option '%s'", arg.c_str());
    }
    else
      ClParserInst->error("Invalid argument '%s'", arg.c_str());
  }

  CCeilRayTrace *raytrace = static_cast<CCeilRayTrace *>(data);

  CRayTraceLight *light = raytrace->getRayTrace()->getLight(id);

  if (light == NULL) {
    ClParserInst->error("Invalid light '%s'", id.c_str());
    return;
  }

  CGeomPoint3D vertex = light->getPosition();

  light->setPosition(vertex.getModel() + delta);
}
예제 #23
0
static void
CCeilRayTraceAddLightCmd(ClLanguageCommand *command, ClLanguageArgs *args, void *data)
{
  args->setSpaceSeparated(true);

  args->setArgs(command);

  std::string id       = "light";
  CPoint3D    position = CPoint3D(0,0,0);
  std::string color    = "";

  uint num_args = args->getNumArgs();

  int error_code;

  for (uint i = 0; i < num_args; ++i) {
    std::string arg = args->getArg(i + 1, &error_code);

    if (arg[0] == '-') {
      if      (arg == "-id") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        id = args->getStringArg(i + 1, &error_code);
      }
      else if (arg == "-position") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        double *reals;
        uint    num_reals;

        args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

        if (error_code == 0 && num_reals == 3)
          position = CPoint3D(reals[0], reals[1], reals[2]);
      }
      else if (arg == "-color") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        color = args->getStringArg(i + 1, &error_code);
      }
      else
        ClParserInst->error("Invalid option '%s'", arg.c_str());
    }
    else
      ClParserInst->error("Invalid argument '%s'", arg.c_str());
  }

  CCeilRayTrace *raytrace = static_cast<CCeilRayTrace *>(data);

  CRayTraceLight *light = raytrace->getRayTrace()->addLight(position);

  if (color != "")
    light->setAmbient(CRGBName::toRGBA(color));

  light->setName(id);
}
예제 #24
0
static void
CCeilRayTraceAddModelCmd(ClLanguageCommand *command, ClLanguageArgs *args, void *data)
{
  args->setSpaceSeparated(true);

  args->setArgs(command);

  std::string filename;
  double      scale(1.0);
  bool        auto_scale(false);
  CPoint3D    translate(0,0,0);
  bool        auto_translate(false);
  CPoint3D    rotate(0,0,0);

  CRayTraceShapeData shape_data;

  CCeilRayTraceParseShapeArgs(args, shape_data);

  uint num_args = args->getNumArgs();

  int error_code, skip;

  for (uint i = 0; i < num_args; ++i) {
    std::string arg = args->getArg(i + 1, &error_code);

    if (arg[0] == '-') {
      if      (arg == "-filename") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        filename = args->getStringArg(i + 1, &error_code);
      }
      else if (arg == "-scale") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        scale = args->getRealArg(i + 1, &error_code);
      }
      else if (arg == "-auto_scale") {
        auto_scale = true;
      }
      else if (arg == "-translate") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        double *reals;
        uint    num_reals;

        args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

        if (error_code == 0 && num_reals == 3)
          translate = CPoint3D(reals[0], reals[1], reals[2]);
      }
      else if (arg == "-auto_translate") {
        auto_translate = true;
      }
      else if (arg == "-rotate") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        double *reals;
        uint    num_reals;

        args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

        if (error_code == 0 && num_reals == 3)
          rotate = CPoint3D(reals[0], reals[1], reals[2]);
      }
      else if (CCeilRayTraceIsShapeArg(arg, &skip)) {
        i += skip;
      }
      else
        ClParserInst->error("Invalid option '%s'", arg.c_str());
    }
    else
      ClParserInst->error("Invalid argument '%s'", arg.c_str());
  }

  CCeilRayTrace *raytrace = static_cast<CCeilRayTrace *>(data);

  raytrace->getRayTrace()->addModel(filename, scale, auto_scale, translate,
                                    auto_translate, rotate, shape_data);
}
예제 #25
0
static void
CCeilRayTraceAddPlaneCmd(ClLanguageCommand *command, ClLanguageArgs *args, void *data)
{
  args->setSpaceSeparated(true);

  args->setArgs(command);

  CPoint3D p1(0,0,0);
  CPoint3D p2(1,0,0);
  CPoint3D p3(1,1,0);

  CRayTraceShapeData shape_data;

  CCeilRayTraceParseShapeArgs(args, shape_data);

  uint num_args = args->getNumArgs();

  int error_code, skip;

  for (uint i = 0; i < num_args; ++i) {
    std::string arg = args->getArg(i + 1, &error_code);

    if (arg[0] == '-') {
      if      (arg == "-p1") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        double *reals;
        uint    num_reals;

        args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

        if (error_code == 0 && num_reals == 3)
          p1 = CPoint3D(reals[0], reals[1], reals[2]);
      }
      else if (arg == "-p2") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        double *reals;
        uint    num_reals;

        args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

        if (error_code == 0 && num_reals == 3)
          p2 = CPoint3D(reals[0], reals[1], reals[2]);
      }
      else if (arg == "-p3") {
        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        double *reals;
        uint    num_reals;

        args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

        if (error_code == 0 && num_reals == 3)
          p3 = CPoint3D(reals[0], reals[1], reals[2]);
      }
      else if (CCeilRayTraceIsShapeArg(arg, &skip)) {
        i += skip;
      }
      else
        ClParserInst->error("Invalid option '%s'", arg.c_str());
    }
    else
      ClParserInst->error("Invalid argument '%s'", arg.c_str());
  }

  CCeilRayTrace *raytrace = static_cast<CCeilRayTrace *>(data);

  raytrace->getRayTrace()->addPlane(p1, p2, p3, shape_data);
}
예제 #26
0
파일: GeomCalc.cpp 프로젝트: vujn/chenan
CPoint3D CPoint3D::operator/(double d) const
{
	return CPoint3D(x / d, y / d, z / d);
}
예제 #27
0
파일: GeomCalc.cpp 프로젝트: vujn/chenan
CPoint3D CPoint3D::operator+( VECTOR3D v ) const
{
	return CPoint3D( x+v.dx, y+v.dy, z+v.dz );
}
예제 #28
0
static void
CCeilRayTraceMoveCameraCmd(ClLanguageCommand *command, ClLanguageArgs *args, void *data)
{
  args->setSpaceSeparated(true);

  args->setArgs(command);

  COptValT<CPoint3D> delta;
  COptValT<CPoint3D> position;

  uint num_args = args->getNumArgs();

  int error_code;

  for (uint i = 0; i < num_args; ++i) {
    std::string arg = args->getArg(i + 1, &error_code);

    if (arg[0] == '-') {
      if      (arg == "-position") {
        double *reals;
        uint    num_reals;

        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

        if (error_code == 0 && num_reals == 3)
          position = CPoint3D(reals[0], reals[1], reals[2]);
      }
      else if (arg == "-delta") {
        double *reals;
        uint    num_reals;

        ++i;

        if (i >= num_args) {
          ClParserInst->error("Missing value for '%s'", arg.c_str());
          break;
        }

        args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

        if (error_code == 0 && num_reals == 3)
          delta = CPoint3D(reals[0], reals[1], reals[2]);
      }
      else
        ClParserInst->error("Invalid option '%s'", arg.c_str());
    }
    else
      ClParserInst->error("Invalid argument '%s'", arg.c_str());
  }

  CCeilRayTrace *raytrace = static_cast<CCeilRayTrace *>(data);

  CRayTraceCamera *camera = raytrace->getRayTrace()->getCamera();

  if (camera) {
    if      (position.isValid())
      camera->setPosition(position.getValue());
    else if (delta.isValid())
      camera->setPosition(camera->getPosition() + delta.getValue());
  }
}
예제 #29
0
static void
CCeilRayTraceParseShapeArgs(ClLanguageArgs *args, CRayTraceShapeData &shape_data)
{
  uint num_args = args->getNumArgs();

  int error_code;

  for (uint i = 0; i < num_args; ++i) {
    std::string arg = args->getArg(i + 1, &error_code);

    if (arg[0] != '-')
      continue;

    if      (arg == "-id") {
      ++i;

      if (i >= num_args) {
        ClParserInst->error("Missing value for '%s'", arg.c_str());
        break;
      }

      shape_data.id = args->getStringArg(i + 1, &error_code);
    }
    else if (arg == "-color") {
      ++i;

      if (i >= num_args) {
        ClParserInst->error("Missing value for '%s'", arg.c_str());
        break;
      }

      shape_data.color = args->getStringArg(i + 1, &error_code);
    }
    else if (arg == "-translate") {
      double *reals;
      uint    num_reals;

      ++i;

      if (i >= num_args) {
        ClParserInst->error("Missing value for '%s'", arg.c_str());
        break;
      }

      args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

      if (error_code == 0 && num_reals == 3)
        shape_data.translate = CPoint3D(reals[0], reals[1], reals[2]);
    }
    else if (arg == "-scale") {
      double *reals;
      uint    num_reals;

      ++i;

      if (i >= num_args) {
        ClParserInst->error("Missing value for '%s'", arg.c_str());
        break;
      }

      args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

      if (error_code == 0 && num_reals == 3)
        shape_data.scale = CPoint3D(reals[0], reals[1], reals[2]);
    }
    else if (arg == "-rotate") {
      double *reals;
      uint    num_reals;

      ++i;

      if (i >= num_args) {
        ClParserInst->error("Missing value for '%s'", arg.c_str());
        break;
      }

      args->getRealArrayArg(i + 1, &reals, &num_reals, &error_code);

      if (error_code == 0 && num_reals == 3)
        shape_data.rotate = CPoint3D(reals[0], reals[1], reals[2]);
    }
    else if (arg == "-marble") {
      shape_data.marble = true;
    }
    else if (arg == "-noise") {
      shape_data.noise = true;
    }
    else if (arg == "-mandelbrot") {
      shape_data.mandelbrot = true;
    }
    else if (arg == "-image") {
      ++i;

      if (i >= num_args) {
        ClParserInst->error("Missing value for '%s'", arg.c_str());
        break;
      }

      shape_data.image = args->getStringArg(i + 1, &error_code);
    }
    else if (arg == "-reflect") {
      ++i;

      if (i >= num_args) {
        ClParserInst->error("Missing value for '%s'", arg.c_str());
        break;
      }

      shape_data.reflect = args->getRealArg(i + 1, &error_code);
    }
    else if (arg == "-refract") {
      ++i;

      if (i >= num_args) {
        ClParserInst->error("Missing value for '%s'", arg.c_str());
        break;
      }

      shape_data.refract = args->getRealArg(i + 1, &error_code);
    }
    else if (arg == "-refract_index") {
      ++i;

      if (i >= num_args) {
        ClParserInst->error("Missing value for '%s'", arg.c_str());
        break;
      }

      shape_data.refract_index = args->getRealArg(i + 1, &error_code);
    }
  }
}
예제 #30
0
파일: GeomCalc.cpp 프로젝트: vujn/chenan
CPoint3D CPoint3D::operator-( VECTOR3D v ) const
{
	return CPoint3D( x-v.dx, y-v.dy, z-v.dz );
}