Beispiel #1
0
PanelDrawable::PanelDrawable(float width, float height, const PanelConfig& panelConfig) : Drawable(width, height) {
	isUi = true;
	float sectionWidth = panelConfig.sectionWidth;
	float sectionHeight = panelConfig.sectionHeight;
	float doubleWidth = (sectionWidth * 2);
	float doubleHeight = (sectionHeight * 2);
	float halfWidth = width / 2;
	float halfHeight = height / 2;

	int dirs[] = { -1, 0, 1 };
	std::string names[9] = { "upper_left", "upper_middle", "upper_right", "middle_left", "middle", "middle_right", "bottom_left", "bottom_middle", "bottom_right" };
	float size[9][2] = {
		{ sectionWidth, sectionHeight },
		{ width - doubleWidth, sectionHeight },
		{ sectionWidth, sectionHeight },
		{ sectionWidth, height - doubleHeight },
		{ width - doubleWidth, height - doubleHeight },
		{ sectionWidth, height - doubleHeight },
		{ sectionWidth, sectionHeight },
		{ width - doubleWidth, sectionHeight },
		{ sectionWidth, sectionHeight }
	};

	int count = 0;
	for (int yDir : dirs) {
		for (int xDir : dirs) {
			Vector2fPtr posOffset(GCC_NEW Vector2f((halfWidth - (sectionWidth / 2)) * xDir, (halfHeight -(sectionHeight / 2)) * yDir));
			std::string name = names[count];

			SectionDrawablePtr sectionDrawable(GCC_NEW SectionDrawable(size[count][0], size[count][1], posOffset, panelConfig.panelSections.at(name)));
			mSections.push_back(sectionDrawable);
			count++;
		}
	}
}
Beispiel #2
0
void Game::updateCamera()
{
    core::vector3df posOffset(0.f,-200.f,200.f);
    core::vector3df lookOffset(0.f,-30.f,0.f);
    if (!character.isInBattle())
    {
        core::vector3df posPlayer = character.getPosition();
        camera->setPosition(posPlayer - posOffset);
        camera->setTarget(posPlayer - lookOffset);
    }
    else
    {
        core::vector3df posBattle = battleSceneNode->getTerrainCenter();
        camera->setPosition(posBattle - posOffset);
        camera->setTarget(posBattle - lookOffset);
    }
}
Beispiel #3
0
ButtonDrawable::ButtonDrawable(float width, float height, const ButtonConfig& buttonConfig) : Drawable(width, height) {
	isUi = true;
	state = ButtonState::UP;
	mSections[ButtonState::UP] = vector<SectionDrawablePtr>();
	mSections[ButtonState::OVER] = vector<SectionDrawablePtr>();
	mSections[ButtonState::DOWN] = vector<SectionDrawablePtr>();

	float sectionWidth = buttonConfig.sectionWidth;
	float sectionHeight = buttonConfig.sectionHeight;
	float halfWidth = width / 2;
	float halfHeight = height / 2;

	int dirs[] = { -1, 0, 1 };
	std::string names[9] = { "upper_left", "upper_middle", "upper_right", "middle_left", "middle", "middle_right", "bottom_left", "bottom_middle", "bottom_right" };
	float size[9][2] = {
		{ sectionWidth, sectionHeight },
		{ width - (2 * sectionWidth), sectionHeight },
		{ sectionWidth, sectionHeight },
		{ sectionWidth, height -(2 * sectionHeight) },
		{ width - (2 * sectionWidth), height - (2 * sectionHeight) },
		{ sectionWidth, height - (2 * sectionHeight) },
		{ sectionWidth, sectionHeight },
		{ width - (2 * sectionWidth), sectionHeight },
		{ sectionWidth, sectionHeight }
	};

	int count = 0;
	for (int yDir : dirs) {
		for (int xDir : dirs) {
			Vector2fPtr posOffset(GCC_NEW Vector2f((halfWidth - (sectionWidth / 2)) * xDir, (halfHeight - (sectionHeight / 2)) * yDir));
			std::string name = names[count];

			SectionDrawablePtr upDrawable(GCC_NEW SectionDrawable(size[count][0], size[count][1], posOffset, buttonConfig.buttonUp.at(name)));
			SectionDrawablePtr overDrawable(GCC_NEW SectionDrawable(size[count][0], size[count][1], posOffset, buttonConfig.buttonOver.at(name)));
			SectionDrawablePtr downDrawable(GCC_NEW SectionDrawable(size[count][0], size[count][1], posOffset, buttonConfig.buttonDown.at(name)));
			mSections.at(ButtonState::UP).push_back(upDrawable);
			mSections.at(ButtonState::OVER).push_back(overDrawable);
			mSections.at(ButtonState::DOWN).push_back(downDrawable);
			count++;
		}
	}
}
Beispiel #4
0
void Car::apply_physics(Map &map)
{
	if(m_physicTimer.ticked())
	{
		//float currentSpeed = norm(m_speedVector);

		sf::Transformable::rotate(m_rotation/**(currentSpeed / m_maxSpeed)*/);
		float rotation = getRotation();
		float accelFactor = m_physicTimer.getFullWaitedDuration().asSeconds();

		//calculate the new speed with the acceleration
		m_speed += accelFactor*m_acceleration;
		if(m_speed > m_maxSpeed)
		{
			m_speed = m_maxSpeed;
			//std::cout<< "max attained\n";
		}
		else if(m_speed < -m_maxSpeed)
		{
			m_speed = -m_maxSpeed;
			//std::cout<< "min attained\n";
		}

		sf::Vector2f posOffset(
		m_speed*accelFactor*std::cos(rotation*M_PI/180)
		, m_speed*accelFactor*std::sin(rotation*M_PI/180)
		);

		//calculate the new position with the speed
		move(posOffset);


		//collisions tests
		bool collided = false;
		int i = 0;
		collision::LineHitBox lineBox;
		for(Map::iterator it = map.begin(); it != map.end() && !collided; it++)
		{	
			collided = collision::collision(getHitBox(), it->getHitBox(), lineBox);
		}
		if(collided)
		{
			move(-posOffset); //return to position before collision
			posOffset = collision::bounceVector(
			posOffset
			,collision::normale(lineBox, getPosition())
			);

			move(posOffset);
			setRotation(angle(posOffset));
			m_speed /= 4;
			std::cout<< getPosition().x<< " ; "<< getPosition().y<< '\n';
		}


		m_acceleration = 0;
		m_physicTimer.restart();

	}

	//draw the speed at the right place
	m_speedIndicator.setPosition(getPosition() - sf::Vector2f(400, 300));
	std::stringstream stream;
	stream<< int(m_speed);
	std::string indicatorString;
	stream>> indicatorString;

	m_speedIndicator.setString(indicatorString);
}
  SceneForRaytracingCamp3::SceneForRaytracingCamp3() {
    const Vector3 objectsCenter(0, 0, 0);

    std::vector<std::string> files;
    files.push_back("input_data/marble1.png");
    files.push_back("input_data/marble2.jpg");
    files.push_back("input_data/marble3.jpg");
    files.push_back("input_data/marble4.jpg");

    double refraction_rate = 2.0;
    double radius = 17.0;
    double haba = 5;

    Vector3 posOffset(50 - (radius+haba) * 2 * 5, 0, -150);

    int size = files.size();
    for (int texIdx = -10; texIdx < size; texIdx++)
    {
      double z = texIdx * (radius + haba) * 2.0 * 2.0;
      int trueTexIdx = texIdx;
      while (trueTexIdx < 0) trueTexIdx += size;
      trueTexIdx %= size;

      ImageHandler::IMAGE_ID tex_id = ImageHandler::GetInstance().LoadFromFile(files[trueTexIdx]);
      for (int rateIdx = -15; rateIdx <= 25; rateIdx++)
      {
        double rate1 = rateIdx*0.1;
        if (rate1 < 0) rate1 = -rate1;
        if (rate1 > 1) rate1 = 2 - rate1;
        rate1 = std::max(std::min(rate1, 1.0), 0.0);
        double rate2 = 1 - rate1;

        double x = rateIdx * (radius + haba) * 2.0;

        Vector3 pos1(x, radius, z), pos2(x, radius, z + (radius + haba) * 2);

        // Diffuse + Refraction
        {
          Material mat1(Material::REFLECTION_TYPE_LAMBERT, Color(), Color(1, 1, 1), 0, tex_id);
          Material mat2(Material::REFLECTION_TYPE_REFRACTION, Color(), Color(1, 1, 1), refraction_rate, ImageHandler::INVALID_IMAGE_ID);

          auto obj = new Sphere(radius, pos1 + posOffset, mat1);
          obj->GetMaterial(0)->rate_ = rate1;
          obj->AddMaterial(mat2, rate2);
          AddObject(obj, true, true);
        }

        // Diffuse + Reflection
        {
          Material mat1(Material::REFLECTION_TYPE_LAMBERT, Color(), Color(1, 1, 1), 0, tex_id);
          Material mat2(Material::REFLECTION_TYPE_SPECULAR, Color(), Color(1, 1, 1), refraction_rate, ImageHandler::INVALID_IMAGE_ID);

          auto obj = new Sphere(radius, pos2 + posOffset, mat1);
          obj->GetMaterial(0)->rate_ = rate1;
          obj->AddMaterial(mat2, rate2);
          AddObject(obj, true, true);
        }

      }
    }

    AddInfiniteFLoor(0, Material(Material::REFLECTION_TYPE_LAMBERT, Color(), Color(1, 1, 1)));

    m_ibl.reset(new IBL("input_data/Barce_Rooftop_C_Env.hdr", 1000000.0, objectsCenter));


    ConstructQBVH();
  }
//-----------------------------------------------------------------------------
// Purpose: creates a new keyframe at the specified time
// Input  : time - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
CMapEntity *CMapAnimator::CreateNewKeyFrame( float time )
{
	// work out where we are in the animation
	CMapKeyFrame *key;
	CMapKeyFrame *pPrevKey;
	float partialTime = GetKeyFramesAtTime( time, key, pPrevKey );

	CMapEntity *pCurrentEnt = dynamic_cast<CMapEntity*>( key->Parent );

	// check to see if we're direction on a key frame
	Vector posOffset( 0, 0, 0 );
	if ( partialTime == 0 )
	{
		// create this new key frame slightly after the current one, and offset
		posOffset[0] = 64;
	}

	// get our orientation and position at this time
	Vector vOrigin;
	QAngle angles;
	Quaternion qAngles;
	GetAnimationAtTime( key, pPrevKey, partialTime, vOrigin, qAngles, m_iPositionInterpolator, m_iRotationInterpolator );
	QuaternionAngles( qAngles, angles );

	// create the new map entity
	CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
	CMapWorld *pWorld = pDoc->GetMapWorld();

	CMapEntity *pNewEntity = new CMapEntity;

	Vector newPos;
	VectorAdd( vOrigin, posOffset, newPos );
	pNewEntity->SetPlaceholder( TRUE );
	pNewEntity->SetOrigin( newPos );
	pNewEntity->SetClass( "keyframe_track" );

	char buf[128];
	sprintf( buf, "%f %f %f", angles[0], angles[1], angles[2] );
	pNewEntity->SetKeyValue( "angles", buf );

	// link it into the keyframe list

	// take over this existing next keyframe pointer
	const char *nextKeyName = pCurrentEnt->GetKeyValue( "NextKey" );
	if ( nextKeyName )
	{
		pNewEntity->SetKeyValue( "NextKey", nextKeyName );
	}
		
	// create a new unique name for this ent
	char newName[128];
	const char *oldName = pCurrentEnt->GetKeyValue( "targetname" );
	if ( !oldName || oldName[0] == 0 )
		oldName = "keyframe";

	CMapEntity::GenerateNewTargetname( oldName, newName, 127 );
	pNewEntity->SetKeyValue( "targetname", newName );

	// point the current entity at the newly created one
	pCurrentEnt->SetKeyValue( "NextKey", newName );

	// copy any relevant values
	const char *keyValue = pCurrentEnt->GetKeyValue( "parentname" );
	if ( keyValue )
		pNewEntity->SetKeyValue( "parentname", keyValue );

	keyValue = pCurrentEnt->GetKeyValue( "MoveSpeed" );
	if ( keyValue )
		pNewEntity->SetKeyValue( "MoveSpeed", keyValue );

	return(pNewEntity);
}
Beispiel #7
0
static DD4hep::Geometry::Ref_t createHCal (
  DD4hep::Geometry::LCDD& lcdd,
  xml_h xmlElement,
  DD4hep::Geometry::SensitiveDetector sensDet
  ) {
  // Get the Gaudi message service and message stream:
  ServiceHandle<IMessageSvc> msgSvc("MessageSvc", "HCalConstruction");
  MsgStream lLog(&(*msgSvc), "HCalConstruction");

  xml_det_t xmlDet = xmlElement;
  std::string detName = xmlDet.nameStr();
  //Make DetElement
  DetElement hCal(detName, xmlDet.id());
  // Get status for the RecoGeometry what is status?
  // xml_comp_t xmlStatus = xmlDet.child(_U(status));
  // int status = xmlStatus.id();
  // add Extension to Detlement for the RecoGeometry
  // Let's skip this for now...
  // Det::DetCylinderVolume* detVolume = new Det::DetCylinderVolume(status);
  // hCal.addExtension<Det::IDetExtension>(detVolume);

  // Make volume that envelopes the whole barrel; set material to air
  Dimension dimensions(xmlDet.dimensions());
  DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmax(), dimensions.dz());
  Volume envelopeVolume(detName, envelopeShape, lcdd.air());
  // Invisibility seems to be broken in visualisation tags, have to hardcode that
  // envelopeVolume.setVisAttributes(lcdd, dimensions.visStr());
  envelopeVolume.setVisAttributes(lcdd.invisible());

  // set the sensitive detector type to the DD4hep calorimeter
  sensDet.setType("SimpleCalorimeterSD");

  // Add structural support made of steel inside of HCal
  xml_comp_t xFacePlate = xmlElement.child("face_plate");
  double dRhoFacePlate = xFacePlate.thickness();
  double sensitiveBarrelRmin = dimensions.rmin() + dRhoFacePlate;
  DetElement facePlate("facePlate", 0);
  DD4hep::Geometry::Tube facePlateShape(dimensions.rmin(), sensitiveBarrelRmin, dimensions.dz());
  Volume facePlateVol("facePlate", facePlateShape, lcdd.material(xFacePlate.materialStr()));
  facePlateVol.setVisAttributes(lcdd, xFacePlate.visStr());
  PlacedVolume placedFacePlate = envelopeVolume.placeVolume(facePlateVol);
  placedFacePlate.addPhysVolID("facePlate", facePlate.id());
  facePlate.setPlacement(placedFacePlate);


  // Add structural support made of steel at both ends of HCal
  xml_comp_t xEndPlate = xmlElement.child("end_plate");
  double dZEndPlate = xEndPlate.thickness();

  DD4hep::Geometry::Tube endPlateShape(dimensions.rmin(), dimensions.rmax(), dZEndPlate);
  Volume endPlateVol("endPlate", endPlateShape, lcdd.material(xEndPlate.materialStr()));
  endPlateVol.setVisAttributes(lcdd, xEndPlate.visStr());

  DetElement endPlatePos("endPlate", 0);
  DD4hep::Geometry::Position posOffset(0, 0, dimensions.dz() -  dZEndPlate);
  PlacedVolume placedEndPlatePos = envelopeVolume.placeVolume(endPlateVol, posOffset);
  placedEndPlatePos.addPhysVolID("endPlatePos", endPlatePos.id());
  endPlatePos.setPlacement(placedEndPlatePos);

  DetElement endPlateNeg("endPlate", 1);
  DD4hep::Geometry::Position negOffset(0, 0, -dimensions.dz() +  dZEndPlate);
  PlacedVolume placedEndPlateNeg = envelopeVolume.placeVolume(endPlateVol, negOffset);
  placedEndPlateNeg.addPhysVolID("endPlateNeg", endPlateNeg.id());
  endPlateNeg.setPlacement(placedEndPlateNeg);


  // Hard-coded assumption that we have two different sequences for the modules
  std::vector<xml_comp_t> sequences = {xmlElement.child("sequence_a"), xmlElement.child("sequence_b")};
  // NOTE: This assumes that both have the same dimensions!
  Dimension moduleDimensions(sequences[0].dimensions());
  double dzModule = moduleDimensions.dz();

  // calculate the number of modules fitting in phi, Z and Rho
  unsigned int numModulesPhi = moduleDimensions.phiBins();
  unsigned int numModulesZ = static_cast<unsigned>(dimensions.dz() / dzModule);
  unsigned int numModulesR = static_cast<unsigned>((dimensions.rmax() - sensitiveBarrelRmin) / moduleDimensions.dr());
  lLog << MSG::DEBUG << "constructing " << numModulesPhi << " modules per ring in phi, "
                     << numModulesZ << " rings in Z, "
                     << numModulesR << " rings (layers) in Rho"
                     << numModulesR*numModulesZ*numModulesPhi << " modules" << endmsg;

  // Calculate correction along z based on the module size (can only have natural number of modules)
  double dzDetector = numModulesZ * dzModule + dZEndPlate;
  lLog << MSG::INFO << "correction of dz:" << dimensions.dz() - dzDetector << endmsg;

  // calculate the dimensions of one module:
  double dphi = 2 * dd4hep::pi / static_cast<double>(numModulesPhi);
  double tn = tan(dphi / 2.);
  double spacing = moduleDimensions.x();
  double dy0 = moduleDimensions.dz();
  double dz0 = moduleDimensions.dr() / 2.;

  double drWedge = cos(dphi / 2.) * (dimensions.rmax() - sensitiveBarrelRmin) * 0.5;

  double dxWedge1 = tn * sensitiveBarrelRmin - spacing;
  double dxWedge2 = tn * cos(dphi / 2.) * dimensions.rmax() - spacing;

  // First we construct one wedge with width of one module:
  Volume subWedgeVolume("subWedge", DD4hep::Geometry::Trapezoid(
        dxWedge1, dxWedge2, dzModule, dzModule, drWedge
      ), lcdd.material("Air")
  );
  for (unsigned int idxLayer = 0; idxLayer < numModulesR; ++idxLayer) {
    auto layerName = std::string("wedge") + DD4hep::XML::_toString(idxLayer, "layer%d");
    unsigned int sequenceIdx = idxLayer % 2;
    double rminLayer = idxLayer * moduleDimensions.dr();
    double rmaxLayer = (idxLayer + 1) * cos(dphi / 2.) * moduleDimensions.dr();
    double dx1 = tn * (rminLayer + sensitiveBarrelRmin) - spacing;
    double dx2 = tn * cos(dphi / 2.) * (rmaxLayer + sensitiveBarrelRmin) - spacing;
    // -drWedge to place it in the middle of the wedge-volume
    double rMiddle = rminLayer + 0.5 * moduleDimensions.dr() - drWedge;
    Volume moduleVolume(layerName, DD4hep::Geometry::Trapezoid(
        dx1, dx2, dy0, dy0, dz0
      ), lcdd.material("Air")
    );
    moduleVolume.setVisAttributes(lcdd.invisible());
    unsigned int idxSubMod = 0;
    // DetElement moduleDet(wedgeDet, layerName, idxLayer);
    double modCompZOffset = -moduleDimensions.dz();
    for (xml_coll_t xCompColl(sequences[sequenceIdx], _U(module_component)); xCompColl; ++xCompColl, ++idxSubMod) {
      xml_comp_t xComp = xCompColl;
      std::string subModuleName = layerName+DD4hep::XML::_toString(idxSubMod, "module_component%d");
      double dyComp = xComp.thickness();
      Volume modCompVol(subModuleName, DD4hep::Geometry::Trapezoid(
          dx1, dx2, dyComp, dyComp, dz0
        ), lcdd.material(xComp.materialStr())
      );
      if (xComp.isSensitive()) {
        modCompVol.setSensitiveDetector(sensDet);
      }
      modCompVol.setVisAttributes(lcdd, xComp.visStr());
      // modCompVol.setVisAttributes(lcdd.invisible());
      // DetElement modCompDet(wedgeDet, subModuleName, idxSubMod);
      DD4hep::Geometry::Position offset(0, modCompZOffset + dyComp + xComp.y_offset()*2, 0);
      PlacedVolume placedModCompVol = moduleVolume.placeVolume(modCompVol, offset);
      placedModCompVol.addPhysVolID("sub_module", idxSubMod);
      // modCompDet.setPlacement(placedModCompVol);
      modCompZOffset += xComp.thickness()*2 + xComp.y_offset()*2;
    }
    DD4hep::Geometry::Position modOffset(0, 0, rMiddle);
    PlacedVolume placedModuleVol = subWedgeVolume.placeVolume(moduleVolume, modOffset);
    placedModuleVol.addPhysVolID("layer", idxLayer);
    // moduleDet.setPlacement(placedModuleVol);
  }

  // Now we place the components along z within the wedge
  Volume wedgeVolume("wedge", DD4hep::Geometry::Trapezoid(
        dxWedge1, dxWedge2, dzDetector, dzDetector, drWedge
      ), lcdd.material("Air")
  );
  wedgeVolume.setVisAttributes(lcdd.invisible());

  for (unsigned int idxZRow = 0; idxZRow < numModulesZ; ++idxZRow) {
    double zOffset = -dzDetector + dZEndPlate * 2 + (2*idxZRow + 1) * dzModule;
    auto wedgeRowName = DD4hep::XML::_toString(idxZRow, "row%d");
    DD4hep::Geometry::Position wedgeOffset(0, zOffset, 0);
    PlacedVolume placedRowVolume = wedgeVolume.placeVolume(subWedgeVolume, wedgeOffset);
    placedRowVolume.addPhysVolID("row", idxZRow);
    // wedgeDet.setPlacement(placedWedgeVol);
  }

  // Finally we place all the wedges around phi
  for (unsigned int idxPhi = 0; idxPhi < numModulesPhi; ++idxPhi) {
    auto modName = DD4hep::XML::_toString(idxPhi, "mod%d");
    // Volume and DetElement for one row in Z
    DetElement wedgeDet(hCal, modName, idxPhi);
    // moduleVolume.setVisAttributes(lcdd, sequences[sequenceIdx].visStr());
    // moduleVolume.setVisAttributes(lcdd.invisible());
    // calculate position and rotation of this wedge;
    // first rotation due to default rotation of trapezoid
    double phi = 0.5 * dphi - idxPhi * dphi; // 0.5*dphi for middle of module
    double yPosModule = (sensitiveBarrelRmin + drWedge) * cos(phi);
    double xPosModule = (sensitiveBarrelRmin + drWedge) * sin(phi);
    DD4hep::Geometry::Position moduleOffset(xPosModule, yPosModule, 0);
    DD4hep::Geometry::Transform3D trans(
      DD4hep::Geometry::RotationX(-0.5*dd4hep::pi)*
      DD4hep::Geometry::RotationY(phi),
      moduleOffset
    );
    PlacedVolume placedWedgeVol = envelopeVolume.placeVolume(wedgeVolume, trans);
    placedWedgeVol.addPhysVolID("wedge", idxPhi);
    wedgeDet.setPlacement(placedWedgeVol);
  }

  //Place envelope (or barrel) volume
  Volume motherVol = lcdd.pickMotherVolume(hCal);
  PlacedVolume placedHCal = motherVol.placeVolume(envelopeVolume);
  placedHCal.addPhysVolID("system", hCal.id());
  hCal.setPlacement(placedHCal);
  return hCal;

}
	void DGStdCursorPictureLayer::updateCustomGpuParameter(DShaderObject* so)
	{
		if (!so->isValid())
		{
			return;
		}
		// we assume the so is the only so named "UI_StdCursor_t0_p0"
		DMatrix4 vertTransform;
		DMatrix3 uvTransform = DMatrix3::IDENTITY;
		DGCursor::CursorAction action;
		DVector2 posOffset(0.0f, 0.0f);
		DReal cw = mHostCursor->getSize().getWidth() * 0.5f;
		DReal ch = mHostCursor->getSize().getHeight() * 0.5f;
		bool makeOffset = false;
		switch (mHostCursor->getCursorAction())
		{
		case Duel::DGCursor::CA_Idle:
			action = DGCursor::CA_Idle;
			makeOffset = true;
			break;
		case Duel::DGCursor::CA_Busy:
			action = DGCursor::CA_Busy;
			makeOffset = true;
			break;
		case Duel::DGCursor::CA_Pressed:
			action = DGCursor::CA_Pressed;
			makeOffset = true;
			break;
		case Duel::DGCursor::CA_Drag:
			action = DGCursor::CA_Drag;
			makeOffset = true;
			break;
		case Duel::DGCursor::CA_ScaleHorizontal:
			action = DGCursor::CA_ScaleHorizontal;
			break;
		case Duel::DGCursor::CA_ScaleVertical:
			action = DGCursor::CA_ScaleVertical;
			break;
		case Duel::DGCursor::CA_Scale_LeftCorner:
			action = DGCursor::CA_Scale_LeftCorner;
			break;
		case Duel::DGCursor::CA_Scale_RightCorner:
			action = DGCursor::CA_Scale_RightCorner;
			break;
		case Duel::DGCursor::CA_Link:
			action = DGCursor::CA_Link;
			makeOffset = true;
			break;
		case Duel::DGCursor::CA_Scroll:
			action = DGCursor::CA_Scroll;
			break;
		case Duel::DGCursor::CA_Edit:
			action = DGCursor::CA_Edit;
			break;
		case Duel::DGCursor::CA_Invalid:
			action = DGCursor::CA_Invalid;
			break;
		default:
			action = DGCursor::CA_Idle;
			makeOffset = true;
			break;
		}
		if (makeOffset)
		{
			posOffset.x += cw;
			posOffset.y -= ch;
		}
		// 因为标准ui的HotPoint根据不同的动作会有不同的坐标, 因此需要重新计算.
		DVector2 pos = mHostCursor->getPointInScreen();
		pos += posOffset;
		DGSize winSize((DReal)mHostCursor->getHostWindow()->getWidth(),
			(DReal)mHostCursor->getHostWindow()->getHeight());
		vertTransform = DGGUIMathTool::getScreenSpaceTransform(pos, mHostCursor->getSize(), winSize);
		so->getVertexProgramParameters()->setValue("vertTransform", vertTransform);

		// 处理UV, 反正标准Cursor图里只有12个图标. 直接计算.
		DReal uvXScale = 1.0f / 12.0f;
		uvTransform[0][0] = uvXScale;
		uint32 iconId = (uint32)action;
		DReal uvXOffset = uvXScale * iconId;
		// 列主序, 列主存储, x 位移.
		uvTransform[2][0] = uvXOffset;
		so->getVertexProgramParameters()->setValue("uvTransform", uvTransform);
	
		so->getPixelProgramParameters()->setValue("texUnit", mTexture->getAs<DTexture>()->getGpuTexutureConstant());

	}