コード例 #1
0
ファイル: ZeroLengthSection.cpp プロジェクト: lge88/OpenSees
// Establish the external nodes and set up the transformation matrix
// for orientation
void
ZeroLengthSection::setUp(int Nd1, int Nd2, const Vector &x, const Vector &yp)
{ 
    // ensure the connectedExternalNode ID is of correct size & set values
  if (connectedExternalNodes.Size() != 2) {
    opserr << "ZeroLengthSection::setUp -- failed to create an ID of correct size\n";
    exit(-1);
  }
    
    connectedExternalNodes(0) = Nd1;
    connectedExternalNodes(1) = Nd2;
    
	int i;
    for (i=0; i<2; i++)
      theNodes[i] = 0;

    // check that vectors for orientation are correct size
    if ( x.Size() != 3 || yp.Size() != 3 )
      opserr << "ZeroLengthSection::setUp -- incorrect dimension of orientation vectors\n";
			

    // establish orientation of element for the tranformation matrix
    // z = x cross yp
    static Vector z(3);
    z(0) = x(1)*yp(2) - x(2)*yp(1);
    z(1) = x(2)*yp(0) - x(0)*yp(2);
    z(2) = x(0)*yp(1) - x(1)*yp(0);

    // y = z cross x
    static Vector y(3);
    y(0) = z(1)*x(2) - z(2)*x(1);
    y(1) = z(2)*x(0) - z(0)*x(2);
    y(2) = z(0)*x(1) - z(1)*x(0);

    // compute length(norm) of vectors
    double xn = x.Norm();
    double yn = y.Norm();
    double zn = z.Norm();

    // check valid x and y vectors, i.e. not parallel and of zero length
    if (xn == 0 || yn == 0 || zn == 0)
      opserr << "ZeroLengthSection::setUp -- invalid vectors to constructor\n";
    
    // create transformation matrix of direction cosines
    for (i = 0; i < 3; i++) {
		transformation(0,i) = x(i)/xn;
		transformation(1,i) = y(i)/yn;
		transformation(2,i) = z(i)/zn;
	}
}
コード例 #2
0
int GzPutTriangle(GzRender	*render, int numParts, GzToken *nameList, 
				  GzPointer	*valueList)
/* numParts : how many names and values */
{
/*  
- pass in a triangle description with tokens and values corresponding to 
      GZ_POSITION:3 vert positions in model space 
- Xform positions of verts  
- Clip - just discard any triangle with verts behind view plane 
       - test for triangles with all three verts off-screen 
- invoke triangle rasterizer  
*/ 

	GzCoord *transfVert, *NormVert;
	if(render==NULL)
		return GZ_FAILURE;
	for(int i=0; i<numParts;i++ )
	{
		GzCoord *coord=(GzCoord *)(valueList[i]);	
	  if(nameList[i]==GZ_POSITION)
		{
		transfVert=(GzCoord *)malloc(3*sizeof(GzCoord));
			
		
			for(int i=0;i<3;i++)
			transformation(render->Ximage[render->matlevel],coord[i],transfVert[i] );
				
			//
			//Rasterization( render,transfVert);
		}
	  else if (nameList[i]==GZ_NORMAL)
                {
            NormVert=(GzCoord *)malloc(3*sizeof(GzCoord));
		//	GzCoord *coord=(GzCoord *)(valueList[i]);	
		
			for(int i=0;i<3;i++)
			transformation(render->Xnorm[render->matlevel],coord[i],NormVert[i] );
				
			//Rasterization( render,transfVert);   
                }
	   else if (nameList[i]==GZ_NULL_TOKEN)
		{
			
		}
	}
	
	Rasterization( render,transfVert,NormVert);
	return GZ_SUCCESS;
}
コード例 #3
0
ファイル: repo_pca.cpp プロジェクト: 3drepo/3drepocore
std::vector<double> repo::core::RepoPCA::getXYZTransformationMatrix() const
{
	// Assimp is row-major while GLC is plain weird. GLC seems to be row-major
	// however the translation is in the last row of the transformation matrix
	// rather than the last column.
	// See the bottom of to get the idea
	// http://www.ia.hiof.no/~borres/cgraph/math/threed/p-threed.html
    std::vector<double> transformation(16);

    aiMatrix3x3t<float>tempTranspose = aiMatrix3x3t<float>(xyzRotationMatrix).Transpose();

    transformation[0] = tempTranspose.a1;
    transformation[1] = tempTranspose.a2;
    transformation[2] = tempTranspose.a3;
    transformation[3] = 0;

    transformation[4] = tempTranspose.b1;
    transformation[5] = tempTranspose.b2;
    transformation[6] = tempTranspose.b3;
    transformation[7] = 0;

    transformation[8] = tempTranspose.c1;
    transformation[9] = tempTranspose.c2;
    transformation[10] = tempTranspose.c3;
    transformation[11] = 0;

    transformation[12] = xyzCentroid.x;
    transformation[13] = xyzCentroid.y;
    transformation[14] = xyzCentroid.z;
    transformation[15] = 1;
	
    return transformation;
}
コード例 #4
0
transform3d<T> transformation3(IT begin, IT end, bool& success)
{

  minimath::matrix<T,4,3> ref; // 4x3 to allow for rotation + translation
  minimath::matrix<T,3> meas;

  unsigned int index = 0;

  // to-do write something to assign elements to matrix
  for (IT iPair = begin; iPair !=end; ++iPair)
  {
    for (unsigned int i = 0; i < 3; ++i)
    {
      ref(i, index) = (*iPair)[0][i];
      meas(i, index) = (*iPair)[1][i];
    }
    ++index;
  }
  minimath::setRow(ref, point3d<T>(1,1,1), 3);
  
  // find rotation!
  matrix<T, 3, 4> rot = transformation(ref, meas, success);
  
  return success ? transform3d<T>(rot) : transform3d<T>();

}
コード例 #5
0
void ComponentRenderAsModel::draw() const
{
	if(!dead || getDeathBehavior()!=Ghost)
	{
		ASSERT(model, "Null pointer: model");

		const float modelScale = lastReportedHeight / modelHeight;

		CHECK_GL_ERROR();

		mat4 transformation(lastReportedPosition,
		                    lastReportedOrientation.getAxisX(),
		                    lastReportedOrientation.getAxisY(),
		                    lastReportedOrientation.getAxisZ());

		glPushMatrix();
		glMultMatrixf(transformation);
		glTranslatef(0.0f, 0.0f, -lastReportedHeight/2.0f);
		glScalef(modelScale, modelScale, modelScale);
		glPushAttrib(GL_ALL_ATTRIB_BITS);
		drawModel(true);
		glPopAttrib();
		glPopMatrix();

		CHECK_GL_ERROR();
	}
}
コード例 #6
0
bool PictureShape::saveSvg(SvgSavingContext &context)
{
    KoImageData *imageData = qobject_cast<KoImageData*>(userData());
    if (!imageData) {
        qWarning() << "Picture has no image data. Omitting.";
        return false;
    }

    context.shapeWriter().startElement("image");
    context.shapeWriter().addAttribute("id", context.getID(this));

    QTransform m = transformation();
    if (m.type() == QTransform::TxTranslate) {
        const QPointF pos = position();
        context.shapeWriter().addAttributePt("x", pos.x());
        context.shapeWriter().addAttributePt("y", pos.y());
    } else {
        context.shapeWriter().addAttribute("transform", SvgUtil::transformToString(m));
    }

    const QSizeF s = size();
    context.shapeWriter().addAttributePt("width", s.width());
    context.shapeWriter().addAttributePt("height", s.height());
    context.shapeWriter().addAttribute("xlink:href", context.saveImage(imageData));
    context.shapeWriter().endElement();

    return true;
}
コード例 #7
0
void ComponentPhysicsGeom::drawAxes() const
{
	CHECK_GL_ERROR();
	glPushAttrib(GL_ALL_ATTRIB_BITS);
	{
		glLineWidth(2.0f);

		const mat3 orientation = getOrientation();
		mat4 transformation(getPosition(),
			                orientation.getAxisX(),
							orientation.getAxisY(),
							orientation.getAxisZ());

		glPushMatrix();
		glMultMatrixf(transformation);

		glBegin(GL_LINES);
		glColor4fv(red);
		glVertex3fv(vec3(0,0,0));
		glVertex3fv(orientation.getAxisX());

		glColor4fv(green);
		glVertex3fv(vec3(0,0,0));
		glVertex3fv(orientation.getAxisY());

		glColor4fv(blue);
		glVertex3fv(vec3(0,0,0));
		glVertex3fv(orientation.getAxisZ());
		glEnd();

		glPopMatrix();
	}
	glPopAttrib();
	CHECK_GL_ERROR();
}
コード例 #8
0
QByteArray PHISHtmlGeneric::effectStyle() const
{
    QByteArray arr;
    arr.reserve( 400 );
    if ( _it->hasGraphicEffect() ) {
        if ( _it->effect()->graphicsType()==PHIEffect::GTShadow ) {
            arr+=textShadowStyle();
            if ( arr.isEmpty() ) {
                QColor c;
                qreal xOff, yOff, radius;
                _it->effect()->shadow( c, xOff, yOff, radius );
                arr+=boxShadowKeyword()+':'+QByteArray::number( static_cast<int>(xOff) )+"px ";
                arr+=QByteArray::number( static_cast<int>(yOff) )+"px ";
                arr+=QByteArray::number( static_cast<int>(radius) )+"px ";
                arr+=c.name().toLatin1()+';';
            }
        }
    }
    QTransform t=transformation();
    if ( t.isIdentity() ) return arr;
    arr+=transformOriginKeyword()+":0 0;";
    arr+=transformKeyword()+":matrix("+QByteArray::number( t.m11(), 'f' )
        +','+QByteArray::number( t.m12(), 'f' )+','+QByteArray::number( t.m21(), 'f' )
        +','+QByteArray::number( t.m22(), 'f' )+','+QByteArray::number( static_cast<int>(t.m31()) )
        +','+QByteArray::number( static_cast<int>(t.m32()) )+");";
    return arr;
}
コード例 #9
0
std::vector<double> repo::core::RepoBoundingBox::getTransformationMatrix() const
{
    std::vector<double> transformation(16);

    RepoVertex centroid = RepoVertex(max+min);

    transformation[0] = 1;
    transformation[1] = 0;
    transformation[2] = 0;
    transformation[3] = 0;

    transformation[4] = 0;
    transformation[5] = 1;
    transformation[6] = 0;
    transformation[7] = 0;

    transformation[8] = 0;
    transformation[9] = 0;
    transformation[10] = 1;
    transformation[11] = 0;

    transformation[12] = centroid.x/2;
    transformation[13] = centroid.y/2;
    transformation[14] = centroid.z/2;
    transformation[15] = 1;

    return transformation;
}
コード例 #10
0
 float convert(unsigned short raw) const {
   if (raw == 0) return 0.0;
   float val = transformation((static_cast<double>(raw) - 1500.0) / 400.0);
   if (val < -1.0f) val = -1.0f;
   if (val > 1.0f)  val =  1.0f;
   return val;
 }
コード例 #11
0
ファイル: Marker.cpp プロジェクト: M-Mueller/TonARt
float Marker::getRotationAngleZ(float* trans)
{
	//basic idea: multiply (0,1,0) with transformation matrix, project the resulting vector to the xy-plane
	//and calculate the angle between this vector and (0,1,0)

	float data[] = {0.0, 1.0, 0.0, 0.0};//up vector of the marker
	cv::Mat initial(4,1,CV_32F, data);

	//the animation should always float in the up direction of the center
	cv::Mat transformation(4,4,CV_32F, (void*)trans);

	//apply marker transformation to up vector (only rotation since direction.w=0)
	cv::Mat transformed;
	cv::gemm(transformation, initial, 1.0, cv::Mat::eye(4,4,CV_32F), 0.0, transformed);
	transformed.at<float>(0,2)=0; //project to xy-plane

	float cosinus = ( transformed.at<float>(0,1) / length(transformed)); //i dot t = 0.0*t.x + 1.0*t.y + 0.0*t.z = t.y

	float angle = (acos(cosinus)*180)/M_PI;

	if(transformed.at<float>(0,0)<0)
		angle=360-angle;

	return angle;
}
コード例 #12
0
ファイル: 7.c プロジェクト: Georgi-Kratchkov/TP
main()
{
	int x,y,i,z,n = 0;
	float arr[10];
	float a = 0.0;
 
	printf("Vavedete chisloto\n");
	scanf("%d",&x);
	
	for(i=0, n=0; n<10; i++)
	{
		if (transformation(cos(i)) == x)
		{
			arr[n] = cos(i);
			++n;
		}
	}
   
	for(i=0; i < 10; i++)
	{
		printf("Arr{%d} : %f\n", i, arr[i]);
	}
   
	return 0;
}
コード例 #13
0
PointLightRenderable::PointLightRenderable(ShaderProgramPtr shaderProgram, PointLightPtr light) :
    HierarchicalRenderable(shaderProgram), m_light(light),
    m_pBuffer(0), m_cBuffer(0), m_nBuffer(0)
{
    std::vector<glm::vec3> tmp_x, tmp_n;
    unsigned int strips=20, slices=20;
    glm::mat4 transformation(1.0);

    teachers::getUnitSphere(tmp_x, tmp_n, strips, slices);
    m_positions.insert(m_positions.end(), tmp_x.begin(), tmp_x.end());
    m_normals.insert(m_normals.end(), tmp_n.begin(), tmp_n.end());
    m_colors.resize(m_positions.size(), glm::vec4(light->diffuse(),1.0));

    transformation = glm::translate(glm::mat4(1.0), m_light->position());
    setParentTransform(transformation);

    //Create buffers
    glGenBuffers(1, &m_pBuffer); //vertices
    glGenBuffers(1, &m_cBuffer); //colors
    glGenBuffers(1, &m_nBuffer); //normals

    //Activate buffer and send data to the graphics card
    glcheck(glBindBuffer(GL_ARRAY_BUFFER, m_pBuffer));
    glcheck(glBufferData(GL_ARRAY_BUFFER, m_positions.size()*sizeof(glm::vec3), m_positions.data(), GL_STATIC_DRAW));
    glcheck(glBindBuffer(GL_ARRAY_BUFFER, m_cBuffer));
    glcheck(glBufferData(GL_ARRAY_BUFFER, m_colors.size()*sizeof(glm::vec4), m_colors.data(), GL_STATIC_DRAW));
    glcheck(glBindBuffer(GL_ARRAY_BUFFER, m_nBuffer));
    glcheck(glBufferData(GL_ARRAY_BUFFER, m_normals.size()*sizeof(glm::vec3), m_normals.data(), GL_STATIC_DRAW));
}
コード例 #14
0
 bool DBClientCursorShimTransform::more() {
     while (cursor.rawMore()) {
         if (transformation(cursor.rawNext(), &nextDoc))
             return true;
     }
     return false;
 }
コード例 #15
0
ファイル: Human.cpp プロジェクト: nonothing/Dyna-Blaster
void HumanFire::updateTransformation(float dt)
{
	if (!_isDead)
	{
		_isImmortal = !_isImmortal;
		transformation(_isImmortal);
	}
}
コード例 #16
0
QByteArray PHISHtmlGeneric::effectJS() const
{
    QByteArray arr;
    if ( _it->effects()==PHIEffect::ENone ) return arr;
    arr.reserve( 200 );
    if ( _it->effects() & PHIEffect::EFadeIn ) {
        qint32 start, duration;
        quint8 ease;
        qreal maxOpac;
        _it->fadeIn( start, duration, maxOpac, ease );
        arr+="$('"+_it->id()+"').fadeIn("+QByteArray::number( start )
            +','+QByteArray::number( duration )+','+QByteArray::number( maxOpac )
            +",'"+PHI::toEasingCurveByteArray( ease )+"');\n";
    }
    if ( _it->effects() & PHIEffect::EFadeOut ) {
        qint32 start, duration;
        quint8 ease;
        qreal minOpac;
        _it->fadeOut( start, duration, minOpac, ease );
        arr+="$('"+_it->id()+"').fadeOut("+QByteArray::number( start )+","
            +QByteArray::number( duration )+','+QByteArray::number( minOpac )
            +",'"+PHI::toEasingCurveByteArray( ease )+"');\n";
    }
    if ( _it->effects() & PHIEffect::EMoveTo ) {
        qint32 start, duration, left, top;
        quint8 ease;
        _it->effect()->moveTo( start, duration, left, top, ease );
        QRect r=transformationPosition( transformation() );
        arr+="$('"+_it->id()+"').moveTo("+QByteArray::number( left+r.x() )+','
            +QByteArray::number( top+r.y() )+','+QByteArray::number( start )+','
            +QByteArray::number( duration )
            +",'"+PHI::toEasingCurveByteArray( ease )+"');\n";
    }
    if ( _it->effects() & PHIEffect::EMoveBy ) {
        qint32 start, duration, x, y, w, h;
        quint8 ease;
        _it->effect()->moveBy( start, duration, x, y, w, h, ease );
        arr+="$('"+_it->id()+"').moveBy("+QByteArray::number( x )+','
            +QByteArray::number( y )+','+QByteArray::number( w )+','
            +QByteArray::number( h )+','+QByteArray::number( start )+','
            +QByteArray::number( duration )+",'"+PHI::toEasingCurveByteArray( ease )+"');\n";
    }
    if ( _it->effects() & PHIEffect::ERotateIn ) {
        quint8 axis;
        qint32 start, duration;
        _it->effect()->rotateIn( axis, start, duration );
        arr+="$('"+_it->id()+"').rotateIn("+QByteArray::number( axis )+','
            +QByteArray::number( start )+','+QByteArray::number( duration )+");\n";
    }
    if ( _it->effects() & PHIEffect::ERotateOut ) {
        quint8 axis;
        qint32 start, duration;
        _it->effect()->rotateOut( axis, start, duration );
        arr+="$('"+_it->id()+"').rotateOut("+QByteArray::number( axis )+','
            +QByteArray::number( start )+','+QByteArray::number( duration )+");\n";
    }
    return arr;
}
コード例 #17
0
ファイル: XercesTools.hpp プロジェクト: MGwynne/oklibrary
 inline void write_xml(std::ostream& target, const XMLCh* const s) {
   struct transformation {
     const char * const p;
     transformation(const XMLCh* const s) : p(xercesc::XMLString::transcode(s)) {}
     ~transformation() { delete [] p; }
   };
   transformation transformation(s);
   target << transformation.p;
  }
コード例 #18
0
Rhtranslink::Rhtranslink ()
{
  psthetai = 0;
  pcthetai = 1;
  psalphai = 0;
  pcalphai = 1;
  pai = 0;
  pdi = 0;
  pS = 1;
  transformation (psthetai, pcthetai, psalphai, pcalphai, pai, pdi);
}
コード例 #19
0
 void project3dPoints(const Mat& points, const Mat& rvec, const Mat& tvec, Mat& modif_points)
 {
     modif_points.create(1, points.cols, CV_32FC3);
     Mat R(3, 3, CV_64FC1);
     Rodrigues(rvec, R);
     Mat transformation(3, 4, CV_64F);
     Mat r = transformation.colRange(0, 3);
     R.copyTo(r);
     Mat t = transformation.colRange(3, 4);
     tvec.copyTo(t);
     transform(points, modif_points, transformation);
 }
コード例 #20
0
    void GeoCoordinateTransformer::transformToDestinationSRS(CityModel* model)
    {
        GeoTransform transformation(m_destinationSRS, m_logger);

        if (!model->getEnvelope().srsName().empty()) {
            transformation.setSourceSRS(model->getEnvelope().srsName());
        }

        for (unsigned int i = 0; i < model->getNumRootCityObjects(); i++) {
            transformRecursive(model->getRootCityObject(i), transformation);
        }
    }
コード例 #21
0
ファイル: Point.cpp プロジェクト: natanelia/grafika
void Point::scale(float scaleX, float scaleY, float scaleZ){
    float matrix[4][4];
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            matrix[i][j] = 0;
        }
    }
    matrix[0][0]=scaleX;
    matrix[1][1]=scaleY;
    matrix[2][2]=scaleZ;
    matrix[3][3]=1; //nilai akhir matrix
    transformation(matrix);
}
コード例 #22
0
KoClipPath *PictureShape::generateClipPath()
{
    QPainterPath path = _Private::generateOutline(imageData()->image());
    path = path * QTransform().scale(size().width(), size().height());

    KoPathShape *pathShape = KoPathShape::createShapeFromPainterPath(path);

    //createShapeFromPainterPath converts the path topleft into a shape topleft
    //and the pathShape needs to be on top of us. So to preserve both we do:
    pathShape->setTransformation(pathShape->transformation() * transformation());

    return new KoClipPath(this, new KoClipData(pathShape));
}
コード例 #23
0
QByteArray PHISHtmlTrident5::effectStyle() const
{
    QByteArray arr, filter;
    arr.reserve( 300 );
    QTransform t=transformation();
    if ( _it->hasGraphicEffect() && t.isIdentity() ) {
        filter.reserve( 200 );
        filter+=" filter:";
        QRectF r( 0, 0, _it->width(), _it->height() );
        if ( _it->effect()->graphicsType()==PHIEffect::GTShadow ) {
            if ( useBoxShadow() ) {
                QColor c;
                qreal xOff, yOff, radius;
                _it->effect()->shadow( c, xOff, yOff, radius );
                filter.clear();
                filter+="box-shadow:"+QByteArray::number( static_cast<int>(xOff) )+"px ";
                filter+=QByteArray::number( static_cast<int>(yOff) )+"px ";
                filter+=QByteArray::number( static_cast<int>(radius) )+"px rgba(";
                filter+=QByteArray::number( c.red() )+','+QByteArray::number( c.green() )+','
                    +QByteArray::number( c.blue() )+','+QByteArray::number( c.alphaF(), 'f', 3 )+");";
            } else {
                QColor c;
                qreal xOff, yOff, radius;
                _it->effect()->shadow( c, xOff, yOff, radius );
                filter+="progid:DXImageTransform.Microsoft.DropShadow(Color='#";
                filter+=QByteArray::number( c.rgba(), 16 )+"',OffX="+QByteArray::number( xOff );
                filter+=",OffY="+QByteArray::number( yOff )+")";
                if ( xOff<0 ) r.adjust( xOff, 0, 0, 0 );
                if ( yOff<0 ) r.adjust( 0, yOff, 0, 0 );
            }
        } else if ( _it->effect()->graphicsType()==PHIEffect::GTBlur ) {
            qreal radius;
            _it->effect()->blur( radius );
            filter+="progid:DXImageTransform.Microsoft.Blur(PixelRadius=";
            filter+=QByteArray::number( radius )+')';
            r.adjust( -radius, -radius, 0, 0 );
        } else return arr;
        if ( !filter.endsWith( ';' ) ) filter+=';';
        filter+="-ms-transform:translate("+QByteArray::number( static_cast<int>(r.x()) )+"px,"
              +QByteArray::number( static_cast<int>(r.y()) )+"px);";
        return filter;
    }
    if ( t.isIdentity() ) return arr;
    arr+="-ms-transform-origin:0 0;";
    arr+="-ms-transform:matrix("+QByteArray::number( t.m11(), 'f' )
        +','+QByteArray::number( t.m12(), 'f' )+','+QByteArray::number( t.m21(), 'f' )
        +','+QByteArray::number( t.m22(), 'f' )+','+QByteArray::number( static_cast<int>(t.m31()) )
        +','+QByteArray::number( static_cast<int>(t.m32()) )+");";
    arr+=filter;
    return arr;
}
コード例 #24
0
ファイル: robot_link.cpp プロジェクト: dknetz/gpu-voxels
Matrix4f RobotLink::getPoseAsGpuMat4f()
{
  // call getPose() explicitely and do NOT use pose_property_
  // to trigger recursive calculation
  KDL::Frame pose = getPose();

  Matrix4f transformation(
    pose.M.data[0], pose.M.data[1], pose.M.data[2], pose.p.x(),
    pose.M.data[3], pose.M.data[4], pose.M.data[5], pose.p.y(),
    pose.M.data[6], pose.M.data[7], pose.M.data[8], pose.p.z(),
    0.0,            0.0,            0.0,            1.0
  );

  return transformation;
}
コード例 #25
0
void PHISHtmlGeneric::diaShow() const
{
    bool useTmp( false );
    int i;
    QByteArray postfix;
    QList <QByteArray> ids;
    QString imageId;
    QTransform t=transformation();
    if ( _it->hasGraphicEffect() ) postfix=QByteArray::fromRawData( "_g", 2 );
    if ( !t.isIdentity() ) postfix=QByteArray::fromRawData( "_t", 2 );
    for ( i=0; i<_it->pictureBookIds().count(); i++ ) {
        imageId=_it->pictureBookIds().at( i );
        // check if we have a graphical changed picture
        if ( !postfix.isNull() || imageId.startsWith( QLatin1String( "phi" ) )
                || (_it->itemProperties() & PHIItem::PNoCache) ) {
            imageId=checkForImageId( postfix, i ); // image already cached?
            useTmp=true;
            if ( imageId.isNull() ) {
                imageId=_it->pictureBookIds().at( i );
                QImage img=createImageImage( imageId );
                if ( _it->hasGraphicEffect() ) img=graphicsEffectImage( img );
                if ( !t.isIdentity() ) img=img.transformed( t, Qt::SmoothTransformation );
                imageId=storeImage( img, postfix, i );
                if ( imageId.isNull() ) return;
            }
        }
        ids.append( imageId.toUtf8() );
    }
    i=0;
    QByteArray src, imgid;
    QByteArray style=" style=\"position:absolute;"+transformationPositionStyle( t, true );
    QList <QByteArray> titles=_it->toolTipData().split(':');
    _out+=_indent+"<div "+id();
    if ( titles.count()==1 ) _out+=title();
    _out+=style+"\">\n";
    style=" style=\"left:0;top:0;";
    if ( t.isIdentity() ) style+="width:"+QByteArray::number( _it->width() )+"px;height:"
        +QByteArray::number( _it->height() )+"px;";
    foreach ( src, ids ) {
        src="/phi.phis?phiimg="+src+"";
        if ( useTmp ) src+="&amp;phitmp=1";
        imgid=_it->id()+"_phi_"+QByteArray::number( i );
        _out+='\t';
        imageSource( src, style, imgid, (titles.count()>i ? titles.at( i ): QByteArray()) );
        i++;
    }
コード例 #26
0
ファイル: Point.cpp プロジェクト: natanelia/grafika
void Point::rotateX(float degree){
    //ClockWise
    float degreeRadian = degree * PI / 180.0;
    float matrix[4][4];
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            matrix[i][j] = 0;
        }
    }
    matrix[0][0]=1;
    matrix[3][3]=1;
    matrix[1][1]=cos(degreeRadian);
    matrix[1][2]=sin(degreeRadian);
    matrix[2][1]=sin(degreeRadian)*(-1);
    matrix[2][2]=cos(degreeRadian);
    transformation(matrix);
}
コード例 #27
0
void Primitive::Draw(const VBO& vbos)
{
	// position
	glBindBuffer(GL_ARRAY_BUFFER, vbos.m_vbo);
	glBufferData(GL_ARRAY_BUFFER, 3 * m_positions.size() * sizeof(float), &m_positions[0], GL_STREAM_DRAW);

	// color
	glBindBuffer(GL_ARRAY_BUFFER, vbos.m_cbo);
	glBufferData(GL_ARRAY_BUFFER, 3 * m_colors.size() * sizeof(float), &m_colors[0], GL_STREAM_DRAW);

	// normal
	glBindBuffer(GL_ARRAY_BUFFER, vbos.m_nbo);
	glBufferData(GL_ARRAY_BUFFER, 3 * m_normals.size() * sizeof(float), &m_normals[0], GL_STREAM_DRAW);

	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbos.m_ibo);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof(unsigned short), &m_indices[0], GL_STATIC_DRAW);

	glEnableVertexAttribArray(0);
	glEnableVertexAttribArray(1);
	glEnableVertexAttribArray(2);

	glBindBuffer(GL_ARRAY_BUFFER, vbos.m_vbo);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

	glBindBuffer(GL_ARRAY_BUFFER, vbos.m_cbo);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);

	glBindBuffer(GL_ARRAY_BUFFER, vbos.m_nbo);
	glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, 0);

	glm::mat4 transformation(1.0f);
	transformation = glm::translate(transformation, m_pos);

	glUniformMatrix4fv(vbos.m_uniform_transformation, 1, false, &transformation[0][0]);

	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbos.m_ibo);
	glDrawElements(GL_TRIANGLES, m_indices.size(), GL_UNSIGNED_SHORT, 0);//GL_UNSIGNED_INT

	glDisableVertexAttribArray(0);
	glDisableVertexAttribArray(1);
	glDisableVertexAttribArray(2);

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
コード例 #28
0
ファイル: Point.cpp プロジェクト: natanelia/grafika
 void Point::translation(float dx, float dy, float dz){
    float matrix[4][4];
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            matrix[i][j] = 0;
        }
    }
    matrix[0][0]=1; //Transform_XAxis
    matrix[1][1]=1; //Transform_YAxis
    matrix[2][2]=1; //Transform_ZAxis
    matrix[3][3]=1; //nilai akhir matrix

    //nilai translasi
    matrix[3][0]=dx;
    matrix[3][1]=dy;
    matrix[3][2]=dz;
    transformation(matrix);
 }
コード例 #29
0
GLC_Matrix4x4 GLC_AbstractManipulator::manipulate(const GLC_Point3d& newPoint)
{
	Q_ASSERT(m_IsInManipulateState);

	// Select the projection direction
	GLC_Vector3d projectionDirection;
	if (m_pViewport->useOrtho())
	{
		projectionDirection= m_pViewport->cameraHandle()->forward().normalize();
	}
	else
	{
		projectionDirection= (newPoint - m_pViewport->cameraHandle()->eye());
	}

	// Use concrete class to compute matrix
	GLC_Matrix4x4 transformation(doManipulate(newPoint, projectionDirection));

	return transformation;
}
コード例 #30
0
QByteArray PHISHtmlWebKit532::effectStyle() const
{
    QByteArray arr;
    arr.reserve( 400 );
    if ( _it->hasGraphicEffect() ) {
        if ( _it->effect()->graphicsType()==PHIEffect::GTShadow ) {
            arr+=textShadowStyle();
            if ( arr.isEmpty() ) {
                QColor c;
                qreal xOff, yOff, radius;
                _it->effect()->shadow( c, xOff, yOff, radius );
                arr+="-webkit-box-shadow:"+QByteArray::number( static_cast<int>(xOff) )+"px ";
                arr+=QByteArray::number( static_cast<int>(yOff) )+"px ";
                arr+=QByteArray::number( static_cast<int>(radius) )+"px ";
                arr+=c.name().toLatin1()+';';
            }
        }
    }

    QTransform t=transformation();
    if ( t.isIdentity() ) return arr;
    arr+="-webkit-transform-origin:0 0;";
    if ( _isMacOSX ) {
        arr+="-webkit-transform:matrix3d("
            +QByteArray::number( t.m11(), 'f' )+','
            +QByteArray::number( t.m12(), 'f' )+",0,"
            +QByteArray::number( t.m13(), 'f' )+','
            +QByteArray::number( t.m21(), 'f' )+','
            +QByteArray::number( t.m22(), 'f' )+",0,"
            +QByteArray::number( t.m23(), 'f' )+",0,0,1,0,"
            +QByteArray::number( t.m31(), 'f' )+','
            +QByteArray::number( t.m32(), 'f' )+",0,"
            +QByteArray::number( t.m33(), 'f' )+");";
    } else {
        arr+="-webkit-transform:matrix("+QByteArray::number( t.m11(), 'f' )
            +','+QByteArray::number( t.m12(), 'f' )+','+QByteArray::number( t.m21(), 'f' )
            +','+QByteArray::number( t.m22(), 'f' )+','+QByteArray::number( t.m31(), 'f' )
            +','+QByteArray::number( t.m32(), 'f' )+");";
    }
    return arr;
}