本文整理汇总了C#中LevelEditorCore.ViewControl.GetWorldRay方法的典型用法代码示例。如果您正苦于以下问题:C# ViewControl.GetWorldRay方法的具体用法?C# ViewControl.GetWorldRay怎么用?C# ViewControl.GetWorldRay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LevelEditorCore.ViewControl
的用法示例。
在下文中一共展示了ViewControl.GetWorldRay方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Vec2F
void IManipulator.Render(ViewControl vc)
{
TerrainGob terrain = m_terrainEditor.TerrainEditorControl.SelectedTerrain;
TerrainBrush brush = m_terrainEditor.TerrainEditorControl.SelectedBrush;
TerrainMap terrainMap = m_terrainEditor.TerrainEditorControl.SelectedTerrainMap;
if (brush == null || (!brush.CanApplyTo(terrain) && !brush.CanApplyTo(terrainMap))) return;
Vec2F drawscale = new Vec2F(1.0f,1.0f);
if (brush.CanApplyTo(terrainMap))
{
ImageData mapImg = terrainMap.GetSurface();
ImageData hmImg = terrain.GetSurface();
drawscale.X = (float)hmImg.Width / (float)mapImg.Width;
drawscale.Y = (float)hmImg.Height / (float)mapImg.Height;
}
Point scrPt = vc.PointToClient(Control.MousePosition);
if (!vc.ClientRectangle.Contains(scrPt)) return;
Ray3F rayw = vc.GetWorldRay(scrPt);
TerrainGob.RayPickRetVal retval;
if (terrain.RayPick(rayw, out retval))
{
terrain.DrawBrush(brush, drawscale, retval.hitpos);
}
}
示例2: Pick
public bool Pick(ViewControl vc, Point scrPt)
{
m_highlightMaterialGUID = ~0ul;
m_highlight.Clear();
var ray = vc.GetWorldRay(scrPt);
var endPt = ray.Origin + vc.Camera.FarZ * ray.Direction;
var nativeVC = vc as GUILayer.IViewContext;
if (nativeVC == null) return false;
// do an intersection test here, and find the material under the cursor
var pick = XLEBridgeUtils.Picking.RayPick(
nativeVC, ray, XLEBridgeUtils.Picking.Flags.Objects);
if (pick != null && pick.Length > 0)
{
m_highlightMaterialGUID = pick[0].materialGuid;
m_highlight.Add(pick[0].documentId, pick[0].instanceId);
using (var placements = nativeVC.SceneManager.GetPlacementsEditor())
{
m_highlight.DoFixup(placements);
}
}
return true;
}
示例3: OnEndDrag
public void OnEndDrag(ViewControl vc, Point scrPt)
{
var ray = vc.GetWorldRay(scrPt);
var endPt = ray.Origin + vc.Camera.FarZ * ray.Direction;
// do an intersection test here, and find the material under the cursor
var pick = XLEBridgeUtils.Picking.RayPick(
vc as GUILayer.IViewContext, ray, XLEBridgeUtils.Picking.Flags.Objects);
if (pick != null && pick.Length > 0)
{
Context.PreviewModelName = pick[0].modelName;
Context.PreviewModelBinding = pick[0].materialGuid;
Context.MaterialName = pick[0].materialName;
}
m_highlightMaterialGUID = ~0ul;
m_highlight.Clear();
}
示例4:
bool IManipulator.Pick(ViewControl vc, System.Drawing.Point scrPt)
{
TerrainGob terrain = m_terrainEditor.TerrainEditorControl.SelectedTerrain;
TerrainBrush brush = m_terrainEditor.TerrainEditorControl.SelectedBrush;
if (terrain != null && brush != null)
{
FlattenBrush fbrush = brush as FlattenBrush;
if (fbrush != null)
{
Ray3F rayw = vc.GetWorldRay(scrPt);
TerrainGob.RayPickRetVal retval;
if (terrain.RayPick(rayw, out retval))
{
Point pt = terrain.WorldToSurfaceSpace(retval.hitpos);
ImageData hm = terrain.GetSurface();
fbrush.Height = hm.GetPixelFloat(pt.X, pt.Y);
}
}
return true;
}
return false;
}
示例5: HitTest
private bool HitTest(out Vec3F result, Point pt, ViewControl vc)
{
var ray = vc.GetWorldRay(pt);
var pick = XLEBridgeUtils.Picking.RayPick(
vc as GUILayer.IViewContext, ray, XLEBridgeUtils.Picking.Flags.Terrain);
if (pick != null && pick.Length > 0)
{
result = pick[0].hitPt;
return true;
}
result = new Vec3F(0.0f, 0.0f, 0.0f);
return false;
}
示例6: OnDragging
public override void OnDragging(ViewControl vc, Point scrPt)
{
if (m_hitRegion == HitRegion.None || m_activeOp == null || m_activeOp.NodeList.Count == 0)
return;
// create ray in view space.
Ray3F rayV = vc.GetWorldRay(scrPt);
using (var intersectionScene = GameEngine.GetEditorSceneManager().GetIntersectionScene())
{
Vec3F intersectionPt;
if (!CalculateTerrainIntersection(vc, rayV, intersectionScene, out intersectionPt))
return;
if (m_pendingStartPt)
{
m_startPt = intersectionPt;
m_pendingStartPt = false;
}
else
{
bool clampToSurface = Control.ModifierKeys == Keys.Shift;
Vec3F translate = new Vec3F(intersectionPt.X - m_startPt.X, intersectionPt.Y - m_startPt.Y, 0.0f);
for (int i = 0; i < m_activeOp.NodeList.Count; i++)
{
ITransformable node = m_activeOp.NodeList[i];
Path<DomNode> path = new Path<DomNode>(Adapters.Cast<DomNode>(node).GetPath());
Matrix4F parentLocalToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
Matrix4F parentWorldToLocal = new Matrix4F();
parentWorldToLocal.Invert(parentLocalToWorld);
Vec3F newWorldPos = m_originalTranslations[i] + translate;
float terrainHeight = 0.0f;
if (GUILayer.EditorInterfaceUtils.GetTerrainHeight(
out terrainHeight, intersectionScene, newWorldPos.X, newWorldPos.Y)) {
newWorldPos.Z = terrainHeight + (clampToSurface ? 0.0f : m_originalHeights[i]);
Vec3F localTranslation;
parentWorldToLocal.TransformVector(newWorldPos, out localTranslation);
node.Translation = localTranslation;
}
}
}
}
}
示例7: ApplyBrush
private void ApplyBrush(ViewControl vc, System.Drawing.Point scrPt)
{
TerrainGob terrain = m_terrainEditor.TerrainEditorControl.SelectedTerrain;
TerrainBrush brush = m_terrainEditor.TerrainEditorControl.SelectedBrush;
TerrainMap terrainMap = m_terrainEditor.TerrainEditorControl.SelectedTerrainMap;
if (brush == null || (!brush.CanApplyTo(terrain) && !brush.CanApplyTo(terrainMap))) return;
Ray3F rayw = vc.GetWorldRay(scrPt);
TerrainGob.RayPickRetVal retval;
if (terrain.RayPick(rayw, out retval))
{
TerrainOp op = null;
if (brush.CanApplyTo(terrain))
{
Point pt = terrain.WorldToSurfaceSpace(retval.hitpos);
brush.Apply(terrain, pt.X, pt.Y, out op);
}
else if (brush.CanApplyTo(terrainMap))
{
Point pt = terrainMap.WorldToSurfaceSpace(retval.hitpos);
brush.Apply(terrainMap, pt.X, pt.Y, out op);
}
m_tmpOps.Add(op);
m_terrainOpList.Add(new WeakReference(op));
m_memUsage += op.SizeInBytes;
}
}