本文整理汇总了C++中LLViewerRegion::getLand方法的典型用法代码示例。如果您正苦于以下问题:C++ LLViewerRegion::getLand方法的具体用法?C++ LLViewerRegion::getLand怎么用?C++ LLViewerRegion::getLand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLViewerRegion
的用法示例。
在下文中一共展示了LLViewerRegion::getLand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateVisibilities
void LLWorld::updateVisibilities()
{
F32 cur_far_clip = LLViewerCamera::getInstance()->getFar();
// Go through the culled list and check for visible regions (region is visible if land is visible)
for (region_list_t::iterator iter = mCulledRegionList.begin();
iter != mCulledRegionList.end(); )
{
region_list_t::iterator curiter = iter++;
LLViewerRegion* regionp = *curiter;
LLSpatialPartition* part = regionp->getSpatialPartition(LLViewerRegion::PARTITION_TERRAIN);
if (part)
{
LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0);
if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1]))
{
mCulledRegionList.erase(curiter);
mVisibleRegionList.push_back(regionp);
}
}
}
// Update all of the visible regions
for (region_list_t::iterator iter = mVisibleRegionList.begin();
iter != mVisibleRegionList.end(); )
{
region_list_t::iterator curiter = iter++;
LLViewerRegion* regionp = *curiter;
if (!regionp->getLand().hasZData())
{
continue;
}
LLSpatialPartition* part = regionp->getSpatialPartition(LLViewerRegion::PARTITION_TERRAIN);
if (part)
{
LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0);
if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1]))
{
regionp->calculateCameraDistance();
if (!gNoRender)
{
regionp->getLand().updatePatchVisibilities(gAgent);
}
}
else
{
mVisibleRegionList.erase(curiter);
mCulledRegionList.push_back(regionp);
}
}
}
// Sort visible regions
mVisibleRegionList.sort(LLViewerRegion::CompareDistance());
LLViewerCamera::getInstance()->setFar(cur_far_clip);
}
示例2: render
// Draw the area that will be affected.
void LLToolBrushLand::render()
{
if(mGotHover)
{
//llinfos << "LLToolBrushLand::render()" << llendl;
LLVector3d spot;
if(gViewerWindow->mousePointOnLandGlobal(mMouseX, mMouseY, &spot))
{
spot.mdV[VX] = floor( spot.mdV[VX] + 0.5 );
spot.mdV[VY] = floor( spot.mdV[VY] + 0.5 );
mBrushSize = gSavedSettings.getF32("LandBrushSize");
region_list_t regions;
determineAffectedRegions(regions, spot);
// Now, for each region, render the overlay
LLVector3 pos_world = gAgent.getRegion()->getPosRegionFromGlobal(spot);
for(region_list_t::iterator iter = regions.begin();
iter != regions.end(); ++iter)
{
LLViewerRegion* region = *iter;
renderOverlay(region->getLand(),
region->getPosRegionFromGlobal(spot),
pos_world);
}
}
mGotHover = FALSE;
}
}
示例3: resolveLandHeightGlobal
F32 LLWorld::resolveLandHeightGlobal(const LLVector3d &pos_global)
{
LLViewerRegion *regionp = getRegionFromPosGlobal(pos_global);
if (regionp)
{
return regionp->getLand().resolveHeightGlobal(pos_global);
}
return 0.0f;
}
示例4: resolveLandNormalGlobal
LLVector3 LLWorld::resolveLandNormalGlobal(const LLVector3d &pos_global)
{
LLViewerRegion *regionp = getRegionFromPosGlobal(pos_global);
if (!regionp)
{
return LLVector3::z_axis;
}
return regionp->getLand().resolveNormalGlobal(pos_global);
}
示例5: getRegionFromPosGlobal
LLSurfacePatch * LLWorld::resolveLandPatchGlobal(const LLVector3d &pos_global)
{
// returns a pointer to the patch at this location
LLViewerRegion *regionp = getRegionFromPosGlobal(pos_global);
if (!regionp)
{
return NULL;
}
return regionp->getLand().resolvePatchGlobal(pos_global);
}
示例6: updateVisibilities
void LLWorld::updateVisibilities()
{
F32 cur_far_clip = LLViewerCamera::getInstance()->getFar();
LLViewerCamera::getInstance()->setFar(mLandFarClip);
F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth;
// Go through the culled list and check for visible regions
for (region_list_t::iterator iter = mCulledRegionList.begin();
iter != mCulledRegionList.end(); )
{
region_list_t::iterator curiter = iter++;
LLViewerRegion* regionp = *curiter;
F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ();
F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared);
if (!regionp->getLand().hasZData()
|| LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius))
{
mCulledRegionList.erase(curiter);
mVisibleRegionList.push_back(regionp);
}
}
// Update all of the visible regions
for (region_list_t::iterator iter = mVisibleRegionList.begin();
iter != mVisibleRegionList.end(); )
{
region_list_t::iterator curiter = iter++;
LLViewerRegion* regionp = *curiter;
if (!regionp->getLand().hasZData())
{
continue;
}
F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ();
F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared);
if (LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius))
{
regionp->calculateCameraDistance();
if (!gNoRender)
{
regionp->getLand().updatePatchVisibilities(gAgent);
}
}
else
{
mVisibleRegionList.erase(curiter);
mCulledRegionList.push_back(regionp);
}
}
// Sort visible regions
mVisibleRegionList.sort(LLViewerRegion::CompareDistance());
LLViewerCamera::getInstance()->setFar(cur_far_clip);
}
示例7: handleMouseDown
BOOL LLToolBrushLand::handleMouseDown(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;
// Find the z value of the initial click.
LLVector3d spot;
if( gViewerWindow->mousePointOnLandGlobal( x, y, &spot ) )
{
// Round to nearest X,Y grid
spot.mdV[VX] = floor( spot.mdV[VX] + 0.5 );
spot.mdV[VY] = floor( spot.mdV[VY] + 0.5 );
LLRegionPosition region_position( spot );
LLViewerRegion* regionp = region_position.getRegion();
if (!canTerraform(regionp))
{
alertNoTerraform(regionp);
return TRUE;
}
LLVector3 pos_region = region_position.getPositionRegion();
U32 grids = regionp->getLand().mGridsPerEdge;
S32 i = llclamp( (S32)pos_region.mV[VX], 0, (S32)grids );
S32 j = llclamp( (S32)pos_region.mV[VY], 0, (S32)grids );
mStartingZ = regionp->getLand().getZ(i+j*grids);
mMouseX = x;
mMouseY = y;
gIdleCallbacks.addFunction( &LLToolBrushLand::onIdle, (void*)this );
setMouseCapture( TRUE );
LLViewerParcelMgr::getInstance()->setSelectionVisible(FALSE);
handled = TRUE;
}
return handled;
}
示例8: draw
void LLNetMap::draw()
{
static LLFrameTimer map_timer;
if (mObjectImagep.isNull())
{
createObjectImage();
}
mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f));
mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f));
F32 rotation = 0;
// Prepare a scissor region
{
LLGLEnable scissor(GL_SCISSOR_TEST);
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLLocalClipRect clip(getLocalRect());
glMatrixMode(GL_MODELVIEW);
// Draw background rectangle
if(isBackgroundVisible())
{
gGL.color4fv(isBackgroundOpaque() ? getBackgroundColor().mV : getTransparentColor().mV);
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0);
}
}
// region 0,0 is in the middle
S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX);
S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY);
gGL.pushMatrix();
gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f);
BOOL rotate_map = gSavedSettings.getBOOL( "MiniMapRotate" );
if( rotate_map )
{
// rotate subsequent draws to agent rotation
rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f);
}
// figure out where agent is
S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters());
LLColor4 this_region_color = gColors.getColor( "NetMapThisRegion" );
LLColor4 live_region_color = gColors.getColor( "NetMapLiveRegion" );
LLColor4 dead_region_color = gColors.getColor( "NetMapDeadRegion" );
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
{
LLViewerRegion* regionp = *iter;
// Find x and y position relative to camera's center.
LLVector3 origin_agent = regionp->getOriginAgent();
LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent();
F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale;
F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale;
// background region rectangle
F32 bottom = relative_y;
F32 left = relative_x;
F32 top = bottom + mScale ;
F32 right = left + mScale ;
gGL.color4fv(regionp == gAgent.getRegion() ? this_region_color.mV : live_region_color.mV);
if (!regionp->isAlive())
{
gGL.color4fv(dead_region_color.mV);
}
// Draw using texture.
gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture());
gGL.begin(LLRender::QUADS);
gGL.texCoord2f(0.f, 1.f);
gGL.vertex2f(left, top);
gGL.texCoord2f(0.f, 0.f);
gGL.vertex2f(left, bottom);
gGL.texCoord2f(1.f, 0.f);
gGL.vertex2f(right, bottom);
gGL.texCoord2f(1.f, 1.f);
gGL.vertex2f(right, top);
gGL.end();
// Draw water
gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f);
{
if (regionp->getLand().getWaterTexture())
{
gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture());
gGL.begin(LLRender::QUADS);
gGL.texCoord2f(0.f, 1.f);
gGL.vertex2f(left, top);
gGL.texCoord2f(0.f, 0.f);
//.........这里部分代码省略.........
示例9: draw
void LLNetMap::draw()
{
static LLFrameTimer map_timer;
static LLUIColor map_avatar_color = LLUIColorTable::instance().getColor("MapAvatarColor", LLColor4::white);
static LLUIColor map_avatar_friend_color = LLUIColorTable::instance().getColor("MapAvatarFriendColor", LLColor4::white);
static LLUIColor map_track_color = LLUIColorTable::instance().getColor("MapTrackColor", LLColor4::white);
static LLUIColor map_track_disabled_color = LLUIColorTable::instance().getColor("MapTrackDisabledColor", LLColor4::white);
static LLUIColor map_frustum_color = LLUIColorTable::instance().getColor("MapFrustumColor", LLColor4::white);
static LLUIColor map_frustum_rotating_color = LLUIColorTable::instance().getColor("MapFrustumRotatingColor", LLColor4::white);
if (mObjectImagep.isNull())
{
createObjectImage();
}
mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f));
mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f));
// Prepare a scissor region
F32 rotation = 0;
gGL.pushMatrix();
gGL.pushUIMatrix();
LLVector3 offset = gGL.getUITranslation();
LLVector3 scale = gGL.getUIScale();
glLoadIdentity();
gGL.loadUIIdentity();
glScalef(scale.mV[0], scale.mV[1], scale.mV[2]);
gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]);
{
LLLocalClipRect clip(getLocalRect());
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
glMatrixMode(GL_MODELVIEW);
// Draw background rectangle
LLColor4 background_color = mBackgroundColor.get();
gGL.color4fv( background_color.mV );
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0);
}
// region 0,0 is in the middle
S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX);
S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY);
gGL.pushMatrix();
gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f);
static LLUICachedControl<bool> rotate_map("MiniMapRotate", true);
if( rotate_map )
{
// rotate subsequent draws to agent rotation
rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f);
}
// figure out where agent is
S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters());
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
{
LLViewerRegion* regionp = *iter;
// Find x and y position relative to camera's center.
LLVector3 origin_agent = regionp->getOriginAgent();
LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent();
F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale;
F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale;
// background region rectangle
F32 bottom = relative_y;
F32 left = relative_x;
F32 top = bottom + mScale ;
F32 right = left + mScale ;
if (regionp == gAgent.getRegion())
{
gGL.color4f(1.f, 1.f, 1.f, 1.f);
}
else
{
gGL.color4f(0.8f, 0.8f, 0.8f, 1.f);
}
if (!regionp->isAlive())
{
gGL.color4f(1.f, 0.5f, 0.5f, 1.f);
}
// Draw using texture.
gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture());
gGL.begin(LLRender::QUADS);
gGL.texCoord2f(0.f, 1.f);
//.........这里部分代码省略.........
示例10: modifyLandInSelectionGlobal
void LLToolBrushLand::modifyLandInSelectionGlobal()
{
if (LLViewerParcelMgr::getInstance()->selectionEmpty())
{
return;
}
if (LLToolMgr::getInstance()->getCurrentTool() == LLToolSelectLand::getInstance())
{
// selecting land, don't do anything
return;
}
LLVector3d min;
LLVector3d max;
LLViewerParcelMgr::getInstance()->getSelection(min, max);
S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction");
mLastAffectedRegions.clear();
determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], min.mdV[VY], 0));
determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], max.mdV[VY], 0));
determineAffectedRegions(mLastAffectedRegions, LLVector3d(max.mdV[VX], min.mdV[VY], 0));
determineAffectedRegions(mLastAffectedRegions, LLVector3d(max.mdV[VX], max.mdV[VY], 0));
LLRegionPosition mid_point_region((min + max) * 0.5);
LLViewerRegion* center_region = mid_point_region.getRegion();
if (center_region)
{
LLVector3 pos_region = mid_point_region.getPositionRegion();
U32 grids = center_region->getLand().mGridsPerEdge;
S32 i = llclamp( (S32)pos_region.mV[VX], 0, (S32)grids );
S32 j = llclamp( (S32)pos_region.mV[VY], 0, (S32)grids );
mStartingZ = center_region->getLand().getZ(i+j*grids);
}
else
{
mStartingZ = 0.f;
}
// Stop if our selection include a no-terraform region
for(region_list_t::iterator iter = mLastAffectedRegions.begin();
iter != mLastAffectedRegions.end(); ++iter)
{
LLViewerRegion* regionp = *iter;
if (!canTerraform(regionp))
{
alertNoTerraform(regionp);
return;
}
}
for(region_list_t::iterator iter = mLastAffectedRegions.begin();
iter != mLastAffectedRegions.end(); ++iter)
{
LLViewerRegion* regionp = *iter;
//BOOL is_changed = FALSE;
LLVector3 min_region = regionp->getPosRegionFromGlobal(min);
LLVector3 max_region = regionp->getPosRegionFromGlobal(max);
min_region.clamp(0.f, regionp->getWidth());
max_region.clamp(0.f, regionp->getWidth());
F32 seconds = gSavedSettings.getF32("LandBrushForce");
LLSurface &land = regionp->getLand();
char action = E_LAND_LEVEL;
switch (radioAction)
{
case 0:
// // average toward mStartingZ
action = E_LAND_LEVEL;
seconds *= 0.25f;
break;
case 1:
action = E_LAND_RAISE;
seconds *= 0.25f;
break;
case 2:
action = E_LAND_LOWER;
seconds *= 0.25f;
break;
case 3:
action = E_LAND_SMOOTH;
seconds *= 5.0f;
break;
case 4:
action = E_LAND_NOISE;
seconds *= 0.5f;
break;
case 5:
action = E_LAND_REVERT;
seconds = 0.5f;
break;
default:
//action = E_LAND_INVALID;
//seconds = 0.0f;
return;
break;
//.........这里部分代码省略.........
示例11: modifyLandAtPointGlobal
void LLToolBrushLand::modifyLandAtPointGlobal(const LLVector3d &pos_global,
MASK mask)
{
S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction");
mLastAffectedRegions.clear();
determineAffectedRegions(mLastAffectedRegions, pos_global);
for(region_list_t::iterator iter = mLastAffectedRegions.begin();
iter != mLastAffectedRegions.end(); ++iter)
{
LLViewerRegion* regionp = *iter;
//BOOL is_changed = FALSE;
LLVector3 pos_region = regionp->getPosRegionFromGlobal(pos_global);
LLSurface &land = regionp->getLand();
char action = E_LAND_LEVEL;
switch (radioAction)
{
case 0:
// // average toward mStartingZ
action = E_LAND_LEVEL;
break;
case 1:
action = E_LAND_RAISE;
break;
case 2:
action = E_LAND_LOWER;
break;
case 3:
action = E_LAND_SMOOTH;
break;
case 4:
action = E_LAND_NOISE;
break;
case 5:
action = E_LAND_REVERT;
break;
default:
action = E_LAND_INVALID;
break;
}
// Don't send a message to the region if nothing changed.
//if(!is_changed) continue;
// Now to update the patch information so it will redraw correctly.
LLSurfacePatch *patchp= land.resolvePatchRegion(pos_region);
if (patchp)
{
patchp->dirtyZ();
}
// Also force the property lines to update, normals to recompute, etc.
regionp->forceUpdate();
// tell the simulator what we've done
F32 seconds = (1.0f / gFPSClamped) * gSavedSettings.getF32("LandBrushForce");
F32 x_pos = (F32)pos_region.mV[VX];
F32 y_pos = (F32)pos_region.mV[VY];
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_ModifyLand);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_ModifyBlock);
msg->addU8Fast(_PREHASH_Action, (U8)action);
msg->addU8Fast(_PREHASH_BrushSize, getBrushIndex());
msg->addF32Fast(_PREHASH_Seconds, seconds);
msg->addF32Fast(_PREHASH_Height, mStartingZ);
msg->nextBlockFast(_PREHASH_ParcelData);
msg->addS32Fast(_PREHASH_LocalID, -1);
msg->addF32Fast(_PREHASH_West, x_pos );
msg->addF32Fast(_PREHASH_South, y_pos );
msg->addF32Fast(_PREHASH_East, x_pos );
msg->addF32Fast(_PREHASH_North, y_pos );
msg->nextBlock("ModifyBlockExtended");
msg->addF32("BrushSize", mBrushSize);
msg->sendMessage(regionp->getHost());
}
}
示例12: updateWaterObjects
//.........这里部分代码省略.........
}
// Found a new connected region.
++number_of_connected_regions;
if (new_region_found->getName().empty())
{
// Uninitialized LLViewerRegion, don't use it's water height.
LL_DEBUGS("WaterHeight") << " Uninitialized region." << LL_ENDL;
++uninitialized_regions;
continue;
}
nxny_pairs.push(nxny_pairs_type::value_type(cnx, cny));
water_heights[cindex] = new_region_found->getWaterHeight();
LL_DEBUGS("WaterHeight") << " Found a new region (name: " << new_region_found->getName() << "; water height: " << water_heights[cindex] << " m)!" << LL_ENDL;
}
}
llinfos << "Number of connected regions: " << number_of_connected_regions << " (" << uninitialized_regions <<
" uninitialized); number of regions bordering Hole water: " << bordering_hole <<
"; number of regions bordering Edge water: " << bordering_edge << llendl;
llinfos << "Coastline count (height, count): ";
bool first = true;
for (std::map<S32, int>::iterator iter = water_height_counts.begin(); iter != water_height_counts.end(); ++iter)
{
if (!first) llcont << ", ";
llcont << "(" << (iter->first / 100.f) << ", " << iter->second << ")";
first = false;
}
llcont << llendl;
llinfos << "Water height used for Hole and Edge water objects: " << water_height << llendl;
// Update all Region water objects.
for (region_list_t::iterator iter = mRegionList.begin(); iter != mRegionList.end(); ++iter)
{
LLViewerRegion* regionp = *iter;
LLVOWater* waterp = regionp->getLand().getWaterObj();
if (waterp)
{
gObjectList.updateActive(waterp);
}
}
// Clean up all existing Hole water objects.
for (std::list<LLVOWater*>::iterator iter = mHoleWaterObjects.begin();
iter != mHoleWaterObjects.end(); ++iter)
{
LLVOWater* waterp = *iter;
gObjectList.killObject(waterp);
}
mHoleWaterObjects.clear();
// Let the Edge and Hole water boxes be 1024 meter high so that they
// are never too small to be drawn (A LL_VO_*_WATER box has water
// rendered on it's bottom surface only), and put their bottom at
// the current regions water height.
F32 const box_height = 1024;
F32 const water_center_z = water_height + box_height / 2;
const S32 step = 256;
// Create new Hole water objects within 'range' where there is no region.
for (S32 x = min_x; x <= max_x; x += step)
{
for (S32 y = min_y; y <= max_y; y += step)
{
U64 region_handle = to_region_handle(x, y);
if (!getRegionFromHandle(region_handle))
{
LLVOWater* waterp = (LLVOWater*)gObjectList.createObjectViewer(LLViewerObject::LL_VO_VOID_WATER, gAgent.getRegion());
waterp->setUseTexture(FALSE);
示例13: draw
void LLNetMap::draw()
{
static LLFrameTimer map_timer;
if (mObjectImagep.isNull())
{
createObjectImage();
}
mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f));
mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f));
// Prepare a scissor region
F32 rotation = 0;
{
LLGLEnable scissor(GL_SCISSOR_TEST);
{
LLGLSNoTexture no_texture;
LLLocalClipRect clip(getLocalRect());
glMatrixMode(GL_MODELVIEW);
// Draw background rectangle
gGL.color4fv( mBackgroundColor.mV );
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0);
}
// region 0,0 is in the middle
S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX);
S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY);
gGL.pushMatrix();
gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f);
if( LLNetMap::sRotateMap )
{
// rotate subsequent draws to agent rotation
rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f);
}
// figure out where agent is
S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters());
for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->mActiveRegionList.begin();
iter != LLWorld::getInstance()->mActiveRegionList.end(); ++iter)
{
LLViewerRegion* regionp = *iter;
// Find x and y position relative to camera's center.
LLVector3 origin_agent = regionp->getOriginAgent();
LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent();
F32 relative_x = (rel_region_pos.mV[0] / region_width) * gMiniMapScale;
F32 relative_y = (rel_region_pos.mV[1] / region_width) * gMiniMapScale;
// background region rectangle
F32 bottom = relative_y;
F32 left = relative_x;
F32 top = bottom + gMiniMapScale ;
F32 right = left + gMiniMapScale ;
if (regionp == gAgent.getRegion())
{
gGL.color4f(1.f, 1.f, 1.f, 1.f);
}
else
{
gGL.color4f(0.8f, 0.8f, 0.8f, 1.f);
}
if (!regionp->isAlive())
{
gGL.color4f(1.f, 0.5f, 0.5f, 1.f);
}
// Draw using texture.
LLViewerImage::bindTexture(regionp->getLand().getSTexture());
gGL.begin(LLVertexBuffer::QUADS);
gGL.texCoord2f(0.f, 1.f);
gGL.vertex2f(left, top);
gGL.texCoord2f(0.f, 0.f);
gGL.vertex2f(left, bottom);
gGL.texCoord2f(1.f, 0.f);
gGL.vertex2f(right, bottom);
gGL.texCoord2f(1.f, 1.f);
gGL.vertex2f(right, top);
gGL.end();
// Draw water
gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f);
{
if (regionp->getLand().getWaterTexture())
{
LLViewerImage::bindTexture(regionp->getLand().getWaterTexture());
gGL.begin(LLVertexBuffer::QUADS);
gGL.texCoord2f(0.f, 1.f);
gGL.vertex2f(left, top);
//.........这里部分代码省略.........
示例14: updateVisibilities
void LLWorld::updateVisibilities()
{
F32 cur_far_clip = LLViewerCamera::getInstance()->getFar();
//-------------------------voodoo--------------------------
//LLViewerCamera::getInstance()->setFar(mLandFarClip);
//F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth;
//-------------------------------------------------------------
// Go through the culled list and check for visible regions
for (region_list_t::iterator iter = mCulledRegionList.begin();
iter != mCulledRegionList.end(); )
{
region_list_t::iterator curiter = iter++;
LLViewerRegion* regionp = *curiter;
LLSpatialPartition* part = regionp->getSpatialPartition(LLViewerRegion::PARTITION_TERRAIN);
if (part)
//-------------------------Voodoo-------------------------------------
//F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ();
//F32 radius = 0.5f * (F32) sqrt(height * height + diagonal_squared);
//if (!regionp->getLand().hasZData()
// || LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius))
//---------------------------------------------------------------------
{
LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0);
if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1]))
{
mCulledRegionList.erase(curiter);
mVisibleRegionList.push_back(regionp);
}
}
}
// Update all of the visible regions
for (region_list_t::iterator iter = mVisibleRegionList.begin();
iter != mVisibleRegionList.end(); )
{
region_list_t::iterator curiter = iter++;
LLViewerRegion* regionp = *curiter;
if (!regionp->getLand().hasZData())
{
continue;
}
LLSpatialPartition* part = regionp->getSpatialPartition(LLViewerRegion::PARTITION_TERRAIN);
if (part)
{
LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0);
if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1]))
{
regionp->calculateCameraDistance();
if (!gNoRender)
{
regionp->getLand().updatePatchVisibilities(gAgent);
}
}
else
{
mVisibleRegionList.erase(curiter);
mCulledRegionList.push_back(regionp);
}
}
}
// Sort visible regions
mVisibleRegionList.sort(LLViewerRegion::CompareDistance());
LLViewerCamera::getInstance()->setFar(cur_far_clip);
}
示例15: resolveStepHeightGlobal
// Takes a line defined by "point_a" and "point_b" and determines the closest (to point_a)
// point where the the line intersects an object or the land surface. Stores the results
// in "intersection" and "intersection_normal" and returns a scalar value that represents
// the normalized distance along the line from "point_a" to "intersection".
//
// Currently assumes point_a and point_b only differ in z-direction,
// but it may eventually become more general.
F32 LLWorld::resolveStepHeightGlobal(const LLVOAvatar* avatarp, const LLVector3d &point_a, const LLVector3d &point_b,
LLVector3d &intersection, LLVector3 &intersection_normal,
LLViewerObject **viewerObjectPtr)
{
// initialize return value to null
if (viewerObjectPtr)
{
*viewerObjectPtr = NULL;
}
LLViewerRegion *regionp = getRegionFromPosGlobal(point_a);
if (!regionp)
{
// We're outside the world
intersection = 0.5f * (point_a + point_b);
intersection_normal.setVec(0.0f, 0.0f, 1.0f);
return 0.5f;
}
// calculate the length of the segment
F32 segment_length = (F32)((point_a - point_b).length());
if (0.0f == segment_length)
{
intersection = point_a;
intersection_normal.setVec(0.0f, 0.0f, 1.0f);
return segment_length;
}
// get land height
// Note: we assume that the line is parallel to z-axis here
LLVector3d land_intersection = point_a;
F32 normalized_land_distance;
land_intersection.mdV[VZ] = regionp->getLand().resolveHeightGlobal(point_a);
normalized_land_distance = (F32)(point_a.mdV[VZ] - land_intersection.mdV[VZ]) / segment_length;
intersection = land_intersection;
intersection_normal = resolveLandNormalGlobal(land_intersection);
if (avatarp && !avatarp->mFootPlane.isExactlyClear())
{
LLVector3 foot_plane_normal(avatarp->mFootPlane.mV);
LLVector3 start_pt = avatarp->getRegion()->getPosRegionFromGlobal(point_a);
// added 0.05 meters to compensate for error in foot plane reported by Havok
F32 norm_dist_from_plane = ((start_pt * foot_plane_normal) - avatarp->mFootPlane.mV[VW]) + 0.05f;
norm_dist_from_plane = llclamp(norm_dist_from_plane / segment_length, 0.f, 1.f);
if (norm_dist_from_plane < normalized_land_distance)
{
// collided with object before land
normalized_land_distance = norm_dist_from_plane;
intersection = point_a;
intersection.mdV[VZ] -= norm_dist_from_plane * segment_length;
intersection_normal = foot_plane_normal;
}
else
{
intersection = land_intersection;
intersection_normal = resolveLandNormalGlobal(land_intersection);
}
}
return normalized_land_distance;
}