本文整理汇总了C++中vec3::getNormal方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3::getNormal方法的具体用法?C++ vec3::getNormal怎么用?C++ vec3::getNormal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3
的用法示例。
在下文中一共展示了vec3::getNormal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onLeftMouseDown
void EditorToolBar::onLeftMouseDown()
{
ASSERT(world!=0, "world was null! Call setWorld first!");
if(g_GUI.mouseOverSomeWidget) return;
// Get a position on the ground beneath the cursor
float e = selected ? selected->getPos().y : 0.0f;
const vec3 groundPos = getGroundPickPos(e);
// Grab the pool of objects we are working from
ActorSet &objects = world->getObjects();
// Get the id of the object under the mouse cursor
OBJECT_ID id = objects.getClosest<Actor>(groundPos, 2.0f);
// Process the action depending on the current tool
switch(toolBarTools->getTool())
{
case ToolBarForEditorTools::EDITOR_SELECT_TOOL:
if(objects.isMember(id))
{
Actor * p = &objects.get(id);
showActorPane(p);
}
else
{
hideActorPane();
}
break;
case ToolBarForEditorTools::EDITOR_MOVE_TOOL:
{
if(selected)
{
// Hold the right mouse button to slide objects along the y-axis
if(g_Input.MouseRight)
{
vec3 delta = groundPos - selected->getPos();
delta.y=0;
float dist = delta.getMagnitude()*0.3f;
// Place the object on this spot
selected->Place(vec3(selected->getPos().x, dist, selected->getPos().z));
}
else
{
selected->Place(groundPos);
}
}
}
break;
case ToolBarForEditorTools::EDITOR_ROTATE_TOOL:
{
if(selected)
{
const vec3 delta = vec3(selected->getPos().x-groundPos.x, 0, selected->getPos().z-groundPos.z);
const vec3 zAxis = delta.getNormal();
const vec3 yAxis = vec3(0,1,0);
const vec3 xAxis = yAxis.cross(zAxis).getNormal();
mat4 orientation = selected->getOrientation();
orientation.setAxisZ(zAxis);
orientation.setAxisY(yAxis);
orientation.setAxisX(xAxis);
orientation.setPos(vec3(0,0,0));
selected->setOrientation(orientation);
}
}
break;
case ToolBarForEditorTools::EDITOR_ROTATE_X_TOOL:
{
if(selected)
{
vec3 delta = groundPos - selected->getPos();
float angle = atan2f(delta.x, delta.y) * 0.1f;
mat4 rot;
rot.rotateX(angle);
mat4 orientation = selected->getOrientation();
orientation *= rot;
selected->setOrientation(orientation);
}
}
break;
case ToolBarForEditorTools::EDITOR_ROTATE_Z_TOOL:
{
if(selected)
{
vec3 delta = groundPos - selected->getPos();
float angle = atan2f(delta.x, delta.y) * 0.1f;
mat4 rot;
rot.rotateZ(angle);
//.........这里部分代码省略.........