本文整理汇总了C++中IVideoDriver::draw2DRectangle方法的典型用法代码示例。如果您正苦于以下问题:C++ IVideoDriver::draw2DRectangle方法的具体用法?C++ IVideoDriver::draw2DRectangle怎么用?C++ IVideoDriver::draw2DRectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVideoDriver
的用法示例。
在下文中一共展示了IVideoDriver::draw2DRectangle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void GUIForumPostItem::draw()
{
if ( !IsVisible )
return;
IVideoDriver* pVideo = Environment->getVideoDriver();
SColor black(255, 0, 0, 0), darkBlue(255, 0, 0, 128);
pVideo->draw2DRectangle( AbsoluteRect, black, black, darkBlue, darkBlue, &AbsoluteClippingRect );
IGUIElement::draw();
}
示例2: viewportTick
void Editor::viewportTick(Viewport viewport, rect<s32> rect,
bool mousehit, bool middlehit)
{
// Init
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
IGUIEnvironment *guienv = device->getGUIEnvironment();
ViewportType type = state->getViewportType(viewport);
// Draw camera
smgr->setActiveCamera(camera[(int)viewport]);
driver->setViewPort(rect);
if (type == VIEWT_BOTTOM)
plane->setVisible(false);
smgr->drawAll();
if (type == VIEWT_BOTTOM)
plane->setVisible(true);
// Callbacks
if (state->Mode())
state->Mode()->viewportTick(viewport, driver, rect);
if (viewport_drag == viewport) {
vector2di delta = state->mouse_position;
delta -= viewport_drag_last;
viewport_drag_last = state->mouse_position;
viewport_offset[(int)viewport].X -= (f32)delta.X * 0.01f;
viewport_offset[(int)viewport].Y += (f32)delta.Y * 0.01f;
if (viewport_offset[(int)viewport].X > 0.5)
viewport_offset[(int)viewport].X = 0.5;
if (viewport_offset[(int)viewport].X < -0.5)
viewport_offset[(int)viewport].X = -0.5;
if (viewport_offset[(int)viewport].Y > 0.5)
viewport_offset[(int)viewport].Y = 0.5;
if (viewport_offset[(int)viewport].Y < -0.5)
viewport_offset[(int)viewport].Y = -0.5;
applyCameraOffsets(viewport);
}
if (middlehit && rect.isPointInside(state->mouse_position)
&& type != VIEWT_PERS) {
viewport_drag = viewport;
viewport_drag_last = state->mouse_position;
}
// Draw text
driver->setViewPort(rects32(0, 0, driver->getScreenSize().Width,
driver->getScreenSize().Height));
{
static const wchar_t* labels[7] = {L"Perspective", L"Front", L"Left",
L"Top", L"Back", L"Right", L"Bottom"};
// Handle clicking
position2d<s32> labelpos(rect.LowerRightCorner.X - 86,
rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?30:10));
rects32 backgroundrect(rect.LowerRightCorner.X - 96,
rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?25:5),
rect.LowerRightCorner.X - 5,
rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?185:165));
bool context_is_open = (viewport_contextmenu == viewport);
if (mousehit && !state->menu->dialog) {
if ((rects32(labelpos.X, labelpos.Y, labelpos.X + 90,
labelpos.Y + 25)).isPointInside(state->mouse_position)) {
viewport_contextmenu = viewport;
} else if (context_is_open) {
context_is_open = false;
viewport_contextmenu = VIEW_NONE;
if (backgroundrect.isPointInside(state->mouse_position)) {
int y = 0;
for (int i = 0; i < 7; i++) {
if (i != (int)type) {
int ty = rect.UpperLeftCorner.Y +
((rect.UpperLeftCorner.Y < 50)?56:36)
+ y * 20;
rects32 trect(rect.LowerRightCorner.X - 96,
ty,
rect.LowerRightCorner.X - 5, ty + 20);
y++;
if (trect.isPointInside(state->mouse_position)) {
viewport_offset[(int)viewport] = vector3df(0, 0, 0);
state->settings->set(viewportToSetting(viewport),
viewportTypeToSetting((ViewportType)i));
recreateCameras();
break;
}
}
}
}
}
}
// Context menu
if (context_is_open) {
// Context menu background
driver->draw2DRectangle(SColor(100, 32, 32, 32), backgroundrect);
s32 y2 = rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?52:32);
driver->draw2DLine(position2d<s32>(rect.LowerRightCorner.X - 96, y2),
position2d<s32>(rect.LowerRightCorner.X - 5, y2),
SColor(100, 255, 255, 255));
// Draw options
//.........这里部分代码省略.........
示例3: render
// render
// override render state
void CGameAnimatedMeshSceneNode::render()
{
#ifdef GSEDITOR
CGameObject::EObjectState state = m_owner->getObjectState();
// draw bbox on select
if (
state == CGameObject::Move ||
state == CGameObject::Review
)
setDebugDataVisible( EDS_BBOX );
else
setDebugDataVisible( 0 );
// call object draw
m_owner->drawObject();
#endif
// draw animesh
CAnimatedMeshSceneNode::render();
#ifdef GSANIMATION
// get driver
IVideoDriver* driver = getSceneManager()->getVideoDriver();
ISkinnedMesh *mesh = (ISkinnedMesh*)getMesh();
IView *pView = getIView();
irr::gui::IGUIFont* font = getSceneManager()->getGUIEnvironment()->getBuiltInFont();
video::SMaterial debug_mat;
debug_mat.Lighting = false;
debug_mat.AntiAliasing = 0;
debug_mat.ZBuffer = video::ECFN_NEVER;
for (u32 g=0; g < mesh->getAllJoints().size(); ++g)
{
ISkinnedMesh::SJoint *joint = mesh->getAllJoints()[g];
core::vector3df v;
//basic bone
//core::matrix4 mat1 = joint->GlobalInversedMatrix;
//mat1.makeInverse();
//anim bone
core::matrix4 mat1 = joint->GlobalAnimatedMatrix;
// get position
mat1.transformVect( v );
// scale with character
v *= m_owner->getScale();
// draw name bone on screen
int x, y;
pView->getScreenCoordinatesFrom3DPosition( v, &x, &y );
wchar_t text[1024];
uiString::copy<wchar_t, const c8>( text, joint->Name.c_str() );
// draw bone position
SColor c = SColor(255,0,0,255);
driver->setMaterial(debug_mat);
driver->draw2DRectangle( c, core::rect<s32>( x - 2, y - 2, x + 2, y + 2 ) );
// draw text
font->draw( text, core::rect<s32>( x + 10, y, x + 100, y + 50), SColor(255, 255,255,0) );
}
#endif
#ifdef GSEDITOR
// draw move
if (
state == CGameObject::Move ||
state == CGameObject::Rotation ||
state == CGameObject::Scale
)
m_owner->drawFrontUpLeftVector();
if ( state == CGameObject::Rotation )
m_owner->drawCircleAroundObject();
#endif
}
示例4: main
int main(int argc, char** argv) {
CustomEventReceiver receiver;
IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(800, 600), 16, false, false, false, &receiver);
if (!device) {
return EXIT_FAILURE;
}
device->setWindowCaption(L"Solar System Simulator");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* sceneManager = device->getSceneManager();
scene::ISceneCollisionManager* collisionManager= sceneManager->getSceneCollisionManager();
IGUIEnvironment* guiEnv = device->getGUIEnvironment();
guiEnv->addStaticText(L"Click on a planet to attach the camera to it", rect<s32>(10,10,260,22), false);
sf::SoundBuffer buffer;
if (buffer.loadFromFile(currentPath() + "/sounds/burning.aif")) {
sf::Listener::setPosition(0, 0,0);
sf::Sound sound;
sound.setBuffer(buffer);
sound.setPosition(0, 0, 0);
sound.setLoop(true);
sound.play();
}
const char* spaceTexturePath = ( currentPath() + "/textures/space.jpg" ).c_str();
video::ITexture* space = driver->getTexture(spaceTexturePath);
scene::ISceneNode* skybox = sceneManager->addSkyBoxSceneNode(space, space, space, space, space, space);
sceneManager->addLightSceneNode(0, vector3df(0, 0, -50), video::SColorf(1.0f, 1.0f, 1.0f), 50.0f, 1001);
PlanetFactory planetFactory(sceneManager, driver);
Planet sun = planetFactory.create(PlanetId::Sun);
Planet earth = planetFactory.create(PlanetId::Earth);
Planet pluto = planetFactory.create(PlanetId::Pluto);
Planet jupiter = planetFactory.create(PlanetId::Jupiter);
Planet uranus = planetFactory.create(PlanetId::Uranus);
Planet neptune = planetFactory.create(PlanetId::Neptune);
vector<Planet> planets = { sun, planetFactory.create(PlanetId::Mercury) };
planets.push_back(planetFactory.create(PlanetId::Venus));
planets.push_back(earth);
planets.push_back(planetFactory.create(PlanetId::Mars));
planets.push_back(jupiter);
planets.push_back(planetFactory.create(PlanetId::Saturn));
planets.push_back(uranus);
planets.push_back(neptune);
planets.push_back(pluto);
ICameraSceneNode* camera = sceneManager->addCameraSceneNode(0, vector3df(0,0,40), vector3df(0,0,0));
rect<s32> mainCameraViewPortRect(0, 0, 800, 600);
ICameraSceneNode* topViewCamera = sceneManager->addCameraSceneNode(0, vector3df(0,50,0), vector3df(0,0,0));
sceneManager->setAmbientLight(video::SColorf(255.0,255.0,255.0));
ISceneNode* selectedNode = sun.node;
while(device->run()) {
if(receiver.GetMouseState().LeftButtonDown) {
position2di mousepos = receiver.GetMouseState().Position;
line3df ray = sceneManager->getSceneCollisionManager()->getRayFromScreenCoordinates( mousepos, camera);
vector3df intersection;
triangle3df tri;
for(Planet& planet : planets) {
ITriangleSelector* wselector = sceneManager->createTriangleSelectorFromBoundingBox(planet.node);
if (collisionManager->getCollisionPoint(ray, wselector, intersection, tri, planet.node)) {
selectedNode = planet.node;
}
wselector->drop();
}
}
camera->setTarget(selectedNode->getAbsolutePosition());
skybox->setVisible(true);
driver->setViewPort(mainCameraViewPortRect);
driver->beginScene(true, true, SColor(255,100,101,140));
sceneManager->setActiveCamera(camera);
sceneManager->drawAll();
guiEnv->drawAll();
driver->setViewPort(rect<s32>(0, 380, 200, 600));
driver->draw2DRectangle(SColor(100,0,0,190), mainCameraViewPortRect);
skybox->setVisible(false);
sceneManager->setActiveCamera(topViewCamera);
sceneManager->drawAll();
driver->endScene();
}
device->drop();
return EXIT_SUCCESS;
}