protected void SubscribeDepthChanged(ISceneNode sceneNode) { UnsubscribeDepthChanged(); sceneNode.DepthChanged += OnSceneNodeDepthChanged; _depthSubscription = sceneNode; }
public UcWorldNodeVisualCache(IDiContainer di, ISceneNode node) { standardMaterialCache = di.Get <IStandardMaterialCache>(); Node = node; parentObj = di.Get <IGlobalObjectService>().VisualObjects; unityObjects = new List <Pair <GameObject, MaterialPropertyBlock> >(); }
private void CreateGizmosForSubtree(ISceneNode subtreeRoot, int depth) { if (subtreeRoot.ParentNode != null && !gizmosByNodes.ContainsKey(subtreeRoot.ParentNode)) { return; } var storyAspect = subtreeRoot.SearchComponent <IStoryComponent>(); if (storyAspect == null) { return; } var newGizmo = AmFactory.Factory.CreateWorldNodeWithComponent <StoryFlowchartNodeGizmoComponent>(out var newGizmoComponent); newGizmo.Name = $"NodeGizmo({subtreeRoot.Name})"; newGizmoComponent.ReferencedNode = subtreeRoot; newGizmoComponent.Depth = depth; Node.ChildNodes.Add(newGizmo); gizmosByNodes.Add(subtreeRoot, newGizmo); //if (subtreeRoot.ParentNode != null) // AddNewEdge(new UnorderedPair<ISceneNode>(subtreeRoot.ParentNode, subtreeRoot), parentChildMaterial); foreach (var child in subtreeRoot.ChildNodes) { CreateGizmosForSubtree(child, depth + 1); } }
public static ISceneNodeViewModel Create(ISceneNode node, SkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper, PackFileService pf, AnimationControllerViewModel animationControllerViewModel, IComponentManager componentManager) { switch (node) { case MainEditableNode mainNode: return(new MainEditableNodeViewModel(mainNode, skeletonAnimationLookUpHelper, animationControllerViewModel, pf)); case Rmv2ModelNode m: return(new ModelSceneNodeViewModel(m)); case Rmv2LodNode l: return(new LodSceneNodeViewModel(l)); case Rmv2MeshNode m: return(new MeshSceneNodeViewModel(m, pf, skeletonAnimationLookUpHelper, componentManager)); case SkeletonNode s: return(new SkeletonSceneNodeViewModel(s, pf, skeletonAnimationLookUpHelper)); case GroupNode n: { if (n.IsEditable && n.Parent != null) { return(new GroupNodeViewModel(n)); } return(null); } default: return(null); } }
public ISceneNode RectangleEditGizmo(ISceneNode rectangleNode) { var gizmoRoot = AmFactory.Create <SceneNode>(); gizmoRoot.Name = "RectangleEditGizmo"; gizmoRoot.Components.Add(EditRectangleGizmoComponent.Create(rectangleNode)); var dragGizmo = AmFactory.Create <SceneNode>(); var dragComponent = AmFactory.Create <DragRectangleGizmoComponent>(); dragGizmo.Components.Add(dragComponent); gizmoRoot.ChildNodes.Add(dragGizmo); ISceneNode CreateResizeGizmo(ResizeRectangleGizmoPlace place) { var resizeGizmo = AmFactory.Create <SceneNode>(); var resizeComponent = AmFactory.Create <ResizeRectangleGizmoComponent>(); resizeComponent.Place = place; resizeGizmo.Components.Add(resizeComponent); return(resizeGizmo); } gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.Left)); gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.Right)); gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.Bottom)); gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.Top)); gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.BottomLeft)); gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.BottomRight)); gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.TopLeft)); gizmoRoot.ChildNodes.Add(CreateResizeGizmo(ResizeRectangleGizmoPlace.TopRight)); return(gizmoRoot); }
public void LoadContent() { _spriteBatch = new SpriteBatch(_graphics); _world = new StaticEntityWorld(_game.Services); var pp = _graphics.PresentationParameters; _camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight)); _cameraNode = _world.Scene.Root.CreateChild("Camera"); _cameraNode.Position = new Vector3(_camera.ScreenSize / 2.0f, 0.0f); _cameraNode.Scale = new Vector3(.5f); _cameraNode.Attach(_camera); // Create the tile map. _terrain = new Terrain(new Vector2(102.4f, 102.4f), 51.2f, 9); _terrain.DebugEnabled = true; _world.Add(_terrain); // Create the circle brush. _circleBrush = new CircleBrush(2.5f); _circleBrushNode = _world.Scene.CreateSceneNode(); _circleBrushNode.Attach(new CircleRenderable(2.5f, 64) { Color = Vector3.One }); }
public static IntVector2 GetPixelPos(this IViewport viewport, ISceneNode node) { // todo: optimize //var visualNonuniformScale = node.MainVisual?.NonUniformScale ?? new Vector3(1, 1, 1); //var visualTransform = node.MainVisual?.Transform ?? Transform.Identity; //var worldMat = Matrix4x4.Scaling(visualNonuniformScale) * // (visualTransform * node.GlobalTransform).ToMatrix4x4(); var worldMat = node.GlobalTransform.ToMatrix4x4(); // todo: use specific layer var camera = viewport.View.Layers[0].Camera; var viewFrame = camera.GetGlobalFrame(); var viewMat = viewFrame.GetViewMat(); var projMat = camera.GetProjectionMat(viewport.AspectRatio); var viewProjMat = viewMat * projMat; var worldViewProjMat = worldMat * viewProjMat; var hmgnCoord = new Vector4(0, 0, 0, 1) * worldViewProjMat; var normalizedCoord = (hmgnCoord / hmgnCoord.W).Xyz; return(new IntVector2( (int)((normalizedCoord.X + 1f) / 2f * viewport.Width), (int)((-normalizedCoord.Y + 1f) / 2f * viewport.Height))); }
/// <summary> /// resizes the collection /// </summary> /// <param name="size">new size</param> public void Resize(int size) { System.Diagnostics.Debug.Assert(size >= filled); ISceneNode[] newArray = new ISceneNode[size]; Array.Copy(array, newArray, filled); array = newArray; }
public void FocusOn(IFocusNodeComponent aFocusNode) { var newNode = aFocusNode.Node; var newCamera = aFocusNode.DefaultViewpointMechanism.CreateControlledViewpoint(); if (mainLayer.Camera == null) { mainLayer.Camera = newCamera; } else if (newNode.Scene != FocusNode.Scene) { mainLayer.Camera = new SceneTransitionCamera(mainLayer.Camera, newCamera, TransitionDuration, () => mainLayer.VisibleScene = newNode.Scene, () => mainLayer.Camera = newCamera); } else { mainLayer.Camera = new TransitionCamera(mainLayer.Camera, newCamera, TransitionDuration, () => mainLayer.Camera = newCamera); } if (mainLayer.VisibleScene == null) { mainLayer.VisibleScene = newNode.Scene; } FocusNode = aFocusNode.Node; navigationService.OnFocus(aFocusNode.Node.Id); }
public static EditRectangleGizmoComponent Create(ISceneNode rectangleNode) { var result = AmFactory.Create <EditRectangleGizmoComponent>(); result.RectangleNode = rectangleNode; return(result); }
public void AddChild(ISceneNode child) { if (_childAddQueue.Contains(child) == false && _childList.Contains(child) == false) { if (_isUpdating) { lock (_childAddQueue) { if (_childAddQueue.Contains(child) == false && _childList.Contains(child) == false) { _childAddQueue.Add(child); if (child.Parent != this) { child.Parent = this; } } } } else { lock (_childList) { if (_childAddQueue.Contains(child) == false && _childList.Contains(child) == false) { _childList.Add(child); if (child.Parent != this) { child.Parent = this; } } } } } }
public AudioAspect(ISceneNode node) { Node = node; // MoviePlayback = Node.GetAspect<IRectangleComponent>().MoviePlayback; /*MoviePlayback =*/ // Node.GetAspect<IMovie>(); // Grab playback from node }
public FreeLandDefaultViewpointMechanism(ISceneNode node, FreeControlledCamera.Props props, IKeyboardInputProvider keyboardInputProvider) { this.props = props; this.keyboardInputProvider = keyboardInputProvider; this.node = node; FixedCamera = CreateControlledViewpoint(); }
public WorldPasteUndoable(ICopyPasteContent content, ISceneNode destination) { source = content.Source; sourceItem = content.Item; copy = content.Copy; this.destination = destination; }
public static ISceneNode Find(string targetName, ISceneNode root) { // use a private constructor to achieve the Find method SearchVisitor currentVisitor = new SearchVisitor(targetName, root); return currentVisitor.Result; }
public RotateEntityTool(ISceneNode entity, IToolService toolService, IUndoRedoService undoRedo) { this.entity = entity; this.toolService = toolService; this.undoRedo = undoRedo; initialLocalTransform = entity.Transform; }
protected override void OnSceneNodeChanged(ISceneNode sceneNode) { // Copy the position and orientation. if (_localPosition != null) { sceneNode.LocalPosition = (Vector3)_localPosition; _localPosition = null; } if (_localOrientation != null) { sceneNode.LocalOrientation = (Quaternion)_localOrientation; _localOrientation = null; } // Set the parent. if (sceneNode != null) { if (_parent != null && _parent.SceneNode != null) { sceneNode.Parent = _parent.SceneNode; } else { // Default the parent to the scene root. sceneNode.Parent = World.Scene.Root; } } }
void SelectObjectsHirarchy(ISceneNode root, Ray ray, ref ISelectable output_selectedNode, ref float bestDistance) { if (root.IsVisible) { if (root is ISelectable selectableNode && selectableNode.IsSelectable) { var distance = GeometryIntersection.IntersectObject(ray, selectableNode.Geometry, selectableNode.ModelMatrix); if (distance != null) { if (distance < bestDistance) { bestDistance = distance.Value; output_selectedNode = selectableNode; } } } bool isUnselectableGroup = root is GroupNode groupNode && groupNode.IsLockable == true && groupNode.IsSelectable == false; if (!isUnselectableGroup) { foreach (var child in root.Children) { SelectObjectsHirarchy(child, ray, ref output_selectedNode, ref bestDistance); } } } }
private void OnCoreInteractionEvent(ICoreInterationEvent args) { if (args.Category != CoreInteractionEventCategory.PrimarySelection) { return; } if (args.Type == CoreInteractionEventType.Happened) { if (scene == null) { scene = master.Node.Scene; } if (gizmo == null) { gizmo = commonNodeFactory.RectangleEditGizmo(master.Node); } else if (scene.AuxuliaryNodes.Contains(gizmo)) { return; } scene.AuxuliaryNodes.Add(gizmo); } else if (args.Type == CoreInteractionEventType.Released) { scene.AuxuliaryNodes.Remove(gizmo); } }
private void OnNavigationEvent(INavigationEvent args) { if (hasFreeCamera || args.CausedByFocusing) { return; } var aFocusNode = navigationService.Current.GetComponent <IFocusNodeComponent>(); var newNode = aFocusNode.Node; var newCamera = aFocusNode.DefaultViewpointMechanism.CreateControlledViewpoint(); if (mainLayer.Camera == null || newNode.Scene != FocusNode.Scene) { mainLayer.Camera = newCamera; } // todo: find real one var layoutInstance = storyService.RootLayoutInstance; var initialCameraProps = mainLayer.Camera.GetProps(); var interLevel = navigationService.InterLevelTransition; var path = layoutInstance.GetPath(initialCameraProps, navigationService.Current.Id, navigationService.State, interLevel); switch (args.Type) { case NavigationEventType.Reset: if (mainLayer.Camera == null) { mainLayer.Camera = newCamera; } else { mainLayer.Camera = new SceneTransitionCamera(mainLayer.Camera, newCamera, TransitionDuration, () => mainLayer.VisibleScene = newNode.Scene, () => mainLayer.Camera = newCamera); } break; case NavigationEventType.MoveToNextFork: mainLayer.Camera = args.MoveInstantly ? newCamera : new StoryPathCamera(path, initialCameraProps, null, OnReachedFork); break; case NavigationEventType.MoveToPrevFork: mainLayer.Camera = args.MoveInstantly ? newCamera : new StoryPathCamera(path, initialCameraProps, null, OnReachedFork); break; case NavigationEventType.MoveToSpecific: mainLayer.Camera = args.MoveInstantly ? newCamera : new StoryPathCamera(path, initialCameraProps, newCamera.GetProps(), () => { mainLayer.Camera = newCamera; }); break; default: throw new ArgumentOutOfRangeException(nameof(args.Type), args.Type, null); } FocusNode = navigationService.Current; }
public StoryGraph(ISceneNode root, IReadOnlyList <Pair <int> > edges, bool sameLayout) { SameLayout = sameLayout; var aspectsUnsorted = root.GetComponent <IStoryComponent>().EnumerateStoryAspectsDeep(SameLayout).ToArray(); var maxId = aspectsUnsorted.Max(x => x.Node.Id); EnoughIntegers = Enumerable.Range(0, maxId + 1).ToArray(); Aspects = aspectsUnsorted.ToDictionary(x => x.Node.Id, x => x); NodeObjects = aspectsUnsorted.ToDictionary(x => x.Node.Id, x => x.Node); NodeIds = aspectsUnsorted.Select(x => x.Node.Id).ToArray(); IsUsed = EnoughIntegers.Select(x => NodeObjects.ContainsKey(x)).ToArray(); Indices = NodeObjects.ToDictionary(x => x.Value, x => x.Key); Children = Aspects.ToDictionary(x => x.Key, x => (IReadOnlyList <int>)x.Value.EnumerateImmediateStoryChildren(SameLayout).Select(y => y.Node.Id).ToArray()); Root = root.Id; Parents = NodeObjects.ToDictionary(x => x.Key, x => x.Value.ParentNode?.Id ?? -1); Depths = NodeIds.ToDictionary(x => x, CalculateNodeDepth); Depth = CalculateDepth(Root); Leaves = EnumerateLeaves(Root).ToArray(); NonLeaves = EnumerateNonLeaves(Root).ToArray(); BuildPrevNext(edges, out var next, out var previous, out var goodEdges); Next = next; Previous = previous; Neighbors = Leaves.ToDictionary(x => x, x => (IReadOnlyList <int>)Next[x].Concat(Previous[x]).ToArray()); Edges = goodEdges; LeveledEdges = BuildLeveledEdges(); BuildLeveledPrevNext(out var leveledNext, out var leveledPrev); LeveledNext = leveledNext; LeveledPrevious = leveledPrev; LeveledNeighbors = NodeIds.ToDictionary(x => x, x => (IReadOnlyList <int>)LeveledNext[x].Concat(LeveledPrevious[x]).ToArray()); ExternalConnections = BuildExternal(); NodesInBfsOrder = BreadthFirstSearch().ToArray(); }
public SceneManager(WpfGame game) : base(game) { RootNode = new GroupNode("Root") { SceneManager = this, IsEditable = true, IsLockable = false }; }
public ISceneNode Load(PackFile file, ISceneNode parent, AnimationPlayer player, ref string skeletonName) { if (file == null) { throw new Exception("File is null in SceneLoader::Load"); } _logger.Here().Information($"Attempting to load file {file.Name}"); //string _refSkeletonName = null; switch (file.Extention) { case ".variantmeshdefinition": LoadVariantMesh(file, ref parent, player, ref skeletonName); break; case ".rigid_model_v2": LoadRigidMesh(file, ref parent, player, ref skeletonName); break; case ".wsmodel": LoadWsModel(file, ref parent, player, ref skeletonName); break; default: throw new Exception("Unknown mesh extention"); } //if (!string.IsNullOrWhiteSpace(_refSkeletonName)) // skeletonName = _refSkeletonName; //else // skeletonName = skeletonName; return(parent); }
private TableLayout BuildConnectionsLayout(ISceneNode selectedNode) { var listLayout = new TableLayout { Padding = new Padding(5), Spacing = new Size(5, 5), }; if (storyService.GlobalGraph.Children[selectedNode.Id].Any()) { return(listLayout); } foreach (var nextId in storyService.GlobalGraph.Next[selectedNode.Id]) { var nextIdLoc = nextId; var next = worldTreeService.GetById(nextId); var label = new Label { Text = next.Name }; var removeButton = new Button { Text = "X", Width = 20, Height = 20 }; removeButton.Click += (s, a) => { // todo: undo/redo storyService.RemoveEdge(selectedNode.Id, nextIdLoc); Actualize(selectedNode); }; listLayout.Rows.Add(new TableRow(new TableCell(label, true), new TableCell(removeButton))); } return(listLayout); }
public ScaleEntityTool(ISceneNode entity, IToolService toolService, IUndoRedoService undoRedo) { this.entity = entity; this.toolService = toolService; this.undoRedo = undoRedo; cTransformable = entity.GetComponent <ITransformable3DComponent>(); initialLocalTransform = entity.Transform; }
public virtual void UnloadContent() { if (_sceneNode != null) { _sceneNode.Dispose(); _sceneNode = null; } }
public FixedCamera(ISceneNode node, Vector3 eye, Vector3 roughForward, Vector3 roughUp, float fov, float zNear, float zFar) { this.node = node; frame = new CameraFrame(eye, roughForward, roughUp); this.fov = fov; this.zNear = zNear; this.zFar = zFar; }
/// <summary> /// Inserts one new child node to this parent node. /// </summary> /// <param name="ch">Child node to add.</param> /// <param name="toParent">Transform from local space of the child to the parent's space.</param> public virtual void InsertChild(ISceneNode ch, Matrix4d toParent) { children.AddLast(ch); ch.ToParent = toParent; toParent.Invert(); ch.FromParent = toParent; ch.Parent = this; }
public void OnWorldRootChanged(ISceneNode newRoot, IStoryGraph newSg) { gizmosByNodes.Clear(); edgeGizmos.Clear(); Node.ChildNodes.Clear(); CreateGizmosForSubtree(newRoot, 0); OnGraphUpdated(newSg); }
public void Build(IGuiMenuBuilder builder, ISceneNode node) { foreach (var cGui in node.SearchComponents <IGuiComponent>()) { builder.StartSection(); cGui.BuildMenuSection(builder); } }
public BorderCurveLocalCache(IContext glContext, ISceneNode entity) { this.glContext = glContext; this.entity = entity; aspect = entity.GetComponent <IRichTextComponent>(); bufferPointCapacity = 512; isDirty = true; }
private SearchVisitor(string name, ISceneNode root) { // fields init this.targetName = name; this.Result = null; notFound = true; // search every node dfs(name, root); }
public CSceneNode(ISceneNode parentNode) { m_parentNode = parentNode; // This statement is a exception for top node if (null != m_parentNode) { m_parentNode.Children.Add(this); } }
public bool AddChild(ISceneNode kid) { _children.Add(kid); // radius of sphere shoud be fixed right here //Vector3 kidPos = kid.SceneNodeProperties().ToWorld.getposition; //Vector3 dir = kidPos - _properties.ToWorld.getposition; //float newRadius = dir.length + kid.SceneNodeProperties().Radius; //if (newRadius > _properties.Radius) // _properties = newRadius; return true; }
public void Detach() { if (SceneNode != null) { // Reset the scene node first, because calling Detach on the scene node will also call // the Detach method on the movable. Setting this property to null first will prevent a // circular method call thanks to the previous if statement. ISceneNode previous = SceneNode; SceneNode = null; previous.Detach(this); OnDetached(); } }
public void AttachTo(ISceneNode sceneNode) { if (SceneNode != sceneNode) { Detach(); // Set the scene node first, because calling Attach on the scene node will also call // the AttachTo method on the movable. Setting this property first will prevent a // circular method call thanks to the previous if statement. SceneNode = sceneNode; SceneNode.Attach(this); OnAttached(sceneNode); } }
protected override ISceneNode CreateSceneNode() { var sceneNode = World.Scene.CreateSceneNode(Name); var innerSphere = sceneNode.CreateChild("InnerSphere"); innerSphere.Attach(new SpherePrimitive(1.0f, 16)); _outerRing = sceneNode.CreateChild("OuterRing"); _outerRing.Attach(new TorusPrimitive(2.5f, 0.25f, 16)); _innerRing = _outerRing.CreateChild("OuterRing"); _innerRing.Attach(new TorusPrimitive(2.25f, 0.25f, 16)); return sceneNode; }
public void Draw(ISceneNode scene, RenderTarget2D target) { scene.UpdateWorldTransform(Camera.World); GraphicsDevice.SetRenderTarget(target); GraphicsDevice.RasterizerState = RasterizerState.CullNone; GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; GraphicsDevice.BlendState = BlendState.AlphaBlend; //GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.Transparent); Effect.CurrentTechnique = Effect.Techniques[0]; Effect.Projection = Camera.Projection; Effect.View = Camera.View; scene.Draw(this); }
public bool SetModel(ISceneNode Model) { if (Model == null) return false; m_Model = Model; // Get total animation steps try { m_simulationImpl.Model = m_Model; StopAnimation(); this.AnimationTotalProgress = m_simulationImpl.GetAnimationTotalProgress(); } catch(Exception ex) { string errMsg = ex.Message + "\n" + ex.StackTrace; vtk.vtkOutputWindow.GetInstance().DisplayErrorText(errMsg); } return true; }
/// <summary> /// A utility method to read the models node and construct the scene /// </summary> /// <param name="topNode"></param> /// <param name="modelsNode"></param> public static void ReadModels(ISceneNode topNode, XmlNode modelsNode) { //XmlNodeList xmlSubNodes = modelsNode.SelectNodes(ModelXMLDefinition.ModelNode); //foreach (XmlNode xmlSubNode in xmlSubNodes) //{ // string id = string.Empty; // // Get type // foreach (XmlAttribute attri in xmlSubNode.Attributes) // { // // get id // if (attri.Name.CompareTo(ModelXMLDefinition.idAttri) == 0) // { // id = attri.InnerText; // } // // Ingore others if the id is null or empty // if (string.IsNullOrEmpty(id)) continue; // // get type // if (string.Compare(attri.Name, ModelXMLDefinition.typeAttri, true) == 0) // { // string type = attri.InnerText; // if (string.Compare(type, ModelXMLDefinition.pipeTypeAttri, true) == 0) // { // CPipeModel pipeModel = new CPipeModel(); // pipeModel.ReadFromXMLNode(xmlSubNode); // } // else // { // // So far ,there are only pipe and other models. // // Modify the code to tell different models. // CNormalModel normalModel = new CNormalModel(topNode); // normalModel.ReadFromXMLNode(xmlSubNode); // } // construct models // } // get type // } // foreach attribute //} // foreach node }
public CFuboModel(ISceneNode parentNode) : base(parentNode) { }
private Vector3D m_scaleDirection = new Vector3D(-1, 0, 0); // default is -x. public CZhujiangModel(ISceneNode parentNode) : base(parentNode) { }
public void runIndoorTest() { device = new IrrlichtDevice(SelectedDriverType, new Dimension2D(800,600), 16, false, true, false); device.EventReceiver = this; device.ResizeAble = true; device.WindowCaption = "Irrlicht.NET indoor test"; // load some textures and meshes ITexture texSydney = device.VideoDriver.GetTexture(@"..\..\media\sydney.bmp"); ITexture texWall = device.VideoDriver.GetTexture(@"..\..\media\wall.jpg"); ITexture texLogo = device.VideoDriver.GetTexture(@"..\..\media\irrlichtlogoaligned.jpg"); Irrlicht.Scene.IAnimatedMesh mesh = device.SceneManager.GetMesh(@"..\..\media\sydney.md2"); if (mesh == null) { System.Windows.Forms.MessageBox.Show( @"Could not load mesh ..\..\media\sydney.md2, exiting.", "Problem starting program"); return; } // add a cube to the scene ISceneNode node = device.SceneManager.AddCubeSceneNode(15, null, -1, new Vector3D(30,-15,0)); node.SetMaterialTexture(0, texWall); node.SetMaterialFlag(Irrlicht.Video.MaterialFlag.LIGHTING, false); // add an animator to the cube to make it rotate ISceneNodeAnimator anim = device.SceneManager.CreateRotationAnimator(new Vector3D(0.2f, 0.2f, 0)); node.AddAnimator(anim); // add animated mesh IAnimatedMeshSceneNode anode = device.SceneManager.AddAnimatedMeshSceneNode(mesh, null, -1); anode.SetMaterialTexture(0, texSydney); anode.SetMaterialFlag(MaterialFlag.LIGHTING, false); anode.Scale = new Vector3D(2,2,2); anode.Position = new Vector3D(0, -20, 0); // add a shadow Shadow = anode.AddShadowVolumeSceneNode(); if (Shadow != null) Shadow.Visible = false; // where no light there no shadow device.SceneManager.AddLightSceneNode(null, new Vector3D(20,100,-50), new Colorf(255,0,0), 200, -1); // add quake 3 level device.FileSystem.AddZipFileArchive("../../media/map-20kdm2.pk3"); IAnimatedMesh q3levelmesh = device.SceneManager.GetMesh("20kdm2.bsp"); ISceneNode q3node = device.SceneManager.AddOctTreeSceneNode(q3levelmesh, null, -1); q3node.Position = new Vector3D(-1370,-130,-1400); // create octtree triangle selector for q3 mesh ITriangleSelector selector = device.SceneManager.CreateOctTreeTriangleSelector( q3levelmesh.GetMesh(0), q3node, 128); // add billboard IBillboardSceneNode bill = device.SceneManager.AddBillboardSceneNode(null, new Dimension2Df(20,20), new Vector3D(0,0,0), -1); bill.SetMaterialType(MaterialType.TRANSPARENT_ADD_COLOR); bill.SetMaterialTexture(0, device.VideoDriver.GetTexture("../../media/particle.bmp")); bill.SetMaterialFlag(MaterialFlag.LIGHTING, false); bill.SetMaterialFlag(MaterialFlag.ZBUFFER, false); // create camera ICameraSceneNode cam = device.SceneManager.AddCameraSceneNodeFPS(null, 100, 300, -1); cam.Position = new Vector3D(20,300,-50); // make cursor invisible device.CursorControl.Visible = false; // create collision animator and add it to the camera ISceneNodeAnimator collAnim = device.SceneManager.CreateCollisionResponseAnimator( selector, cam, new Vector3D(30,50,30), // size of ellipsoid around camera new Vector3D(0, -3, 0), // gravity new Vector3D(0, 50, 0), // translation 0.0005f); // sliding value cam.AddAnimator(collAnim); // load some font and set it into the skin IGUIFont font = device.GUIEnvironment.GetFont("../../media/fonthaettenschweiler.bmp"); device.GUIEnvironment.Skin.Font = font; // add some gui stuff device.GUIEnvironment.AddMessageBox("Hello World", "I'm a Irrlicht.NET MessageBox. Please press SPACE to close me.", true, MessageBoxFlag.OK | MessageBoxFlag.CANCEL, null, -1); // start drawing loop int fps = 0; device.Run(); // fix for a temporary bug where quit messages are not be removed in the queue while(device.Run()) if (device.WindowActive) { device.VideoDriver.BeginScene(true, true, new Color(255,0,0,50)); // draw scene device.SceneManager.DrawAll(); device.GUIEnvironment.DrawAll(); // do some collision testing Line3D line = new Line3D(); line.start = cam.Position; line.end = ((cam.Target - line.start).Normalize() * 1000.0f ) + line.start; Vector3D intersection = new Vector3D(); Triangle3D tri = new Triangle3D(); if (device.SceneManager.SceneCollisionManager.GetCollisionPoint( line, selector, out intersection, out tri)) { bill.Position = intersection; Material mat = new Material(); mat.Lighting = false; device.VideoDriver.SetTransform(TransformationState.WORLD, new Matrix4()); device.VideoDriver.SetMaterial(mat); device.VideoDriver.Draw3DTriangle(tri, new Color(0,255,0,0)); } // draw 2d logo device.VideoDriver.Draw2DImage( texLogo, new Position2D(10,10), new Rect(0,0,88,31), new Rect(new Position2D(0,0),device.VideoDriver.ScreenSize), new Color(0xffffff), false); // draw some text font.Draw("Press 'S' to toggle the visibility of the realtime shadow.", new Position2D(120,20), new Color(100,150,200,200)); device.VideoDriver.EndScene(); if (fps != device.VideoDriver.FPS) { fps = device.VideoDriver.FPS; device.WindowCaption = "Irrlicht.NET test (primitives:" + device.VideoDriver.PrimitiveCountDrawn + ") fps:" + fps; } } }
public void Remove(ISceneNode child) { children.Remove(child); }
public void Add(ISceneNode child) { children.Add(child); }
private void dfs(string name, ISceneNode root) { // return if it's nil if (root == null) return; if (root is IGroupNode) { // check for the root this.CompareToTarget(root); // check for it's children foreach (ISceneNode tmpNode in (root as IGroupNode)) { if (notFound && tmpNode != null) { dfs(name, tmpNode); } } } }
private Vector3D m_scaleDirection = new Vector3D(1, 1, 0); // default is x. public CFillSegment(ISceneNode parentNode) : base(parentNode) { }
public void LoadContent() { _spriteBatch = new SpriteBatch(_graphics); _world = new DynamicEntityWorld(_game.Services); var pp = _graphics.PresentationParameters; _debugView = new DebugViewXNA(_world.PhysicsWorld); _debugView.LoadContent(_graphics, _content); _camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight)); _cameraNode = _world.Scene.Root.CreateChild("Camera"); _cameraNode.Attach(_camera); // Create the tile map. var terrainSize = new Vector2(4096.0f, 2048.0f); _terrain = new Terrain(terrainSize, 128.0f, 7) { DebugEnabled = false, Position = new Vector3(50.0f, -terrainSize.Y / 2.0f, 0.0f), TextureName = @"Textures\SpaceRock" }; _world.Add(_terrain); GenerateTunnels(new Vector2(50.0f, 0)); // Create the circle brush. _circleBrush = new CircleBrush(2.5f); _circleBrushNode = _world.Scene.CreateSceneNode(); _circleBrushNode.Attach(new CircleRenderable(2.5f, 64) { Color = Vector3.One }); // Dust cloud _dustCloud = _world.Scene.CreateSceneNode("DustCloud"); _dustCloud.Position = new Vector3(0.0f, 0.0f, -1.0f); _dustCloud.Attach(new DustCloud()); _world.Scene.Root.AddChild(_dustCloud); // Player _playerEntity = new SpaceShip(); _playerEntity.Attach(new PlayerController()); _playerEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f)); _world.Add(_playerEntity); _payloadEntity = new Payload(); _payloadEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f)); _world.Add(_payloadEntity); _payloadChain = PayloadChain.Connect(_playerEntity, _payloadEntity, Vector2.UnitX * -20.0f); }
public Scene(ISceneNode rootNode) { _cameras = rootNode.GetNodes<CameraNode>().OrderBy(c => c.Order).ToList(); _lights = rootNode.GetNodes<LightNode>().ToList(); _shapes = rootNode.GetNodes<ShapeNode>().ToList(); }
/// <summary> /// This method is called when the movable is attached to the given scene node. /// </summary> /// <param name="sceneNode">The scene node to which the movable was attached.</param> protected virtual void OnAttached(ISceneNode sceneNode) { }
public Root(ISceneNode root) { rootNode = root; }
public CCableSegment(ISceneNode node) : base(node) { }
/// <summary> /// Inserts one new child node to this parent node. /// </summary> /// <param name="ch">Child node to add.</param> /// <param name="toParent">Transform from local space of the child to the parent's space.</param> public virtual void InsertChild( ISceneNode ch, Matrix4d toParent ) { children.AddLast( ch ); ch.ToParent = toParent; toParent.Invert(); ch.FromParent = toParent; ch.Parent = this; }
public void Add(ISceneNode node) { _Nodes.Add(node); }
public void Remove(ISceneNode node) { _Nodes.Remove(node); }
public CFillModel(ISceneNode parentNode) : base(parentNode) { }
private void CompareToTarget(ISceneNode node) { if (notFound && targetName == node.Name) { notFound = false; this.Result = node; } }
public void LoadContent() { m_debug.LoadContent(); var pp = m_graphics.PresentationParameters; // Create our entity world. m_world = new DynamicEntityWorld(m_game.Services); // Create the debug view. m_debugView = new DebugViewXNA(m_world.PhysicsWorld); m_debugView.LoadContent(m_graphics, m_content); // Create the camera. m_camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight)); m_cameraNode = m_world.Scene.Root.CreateChild("Camera"); m_cameraNode.Attach(m_camera); // Create the player. m_player = new Entities.Player( new StaticSprite(Vector2.One * 10.0f, m_content.Load<Texture2D>(@"Sprites\Ship01"), "Player")); m_player.Attach(new Controllers.PlayerMovement(m_camera)); m_world.Add(m_player); m_player.Position = new Vector2(0.0f, 0.0f); // Create the layers. m_playerLayer = new DefaultLayer(typeof(ISprite), "Player", 0.5f) { Scene = m_world.Scene }; m_backgroundLayer = new DefaultLayer(0.0f) { Scene = m_world.Scene }; // Create the background. var deepSpaceSprite = new StaticSprite(Vector2.One * 200.0f, m_content.Load<Texture2D>(@"Textures\Background01"), null) { BlendState = BlendState.Additive }; var lessDeepSpaceSprite = new StaticSprite(Vector2.One * 400.0f, m_content.Load<Texture2D>(@"Textures\Background02"), null) { BlendState = BlendState.Additive }; m_deepSpaceNode = m_cameraNode.CreateChild("Background_DeepSpace"); m_deepSpaceNode.Depth = -1.0f; // Move the background into the back. m_deepSpaceNode.Attach(deepSpaceSprite); m_lessDeepSpaceNode = m_cameraNode.CreateChild("Background_LessDeepSpace"); m_lessDeepSpaceNode.Depth = -0.9f; // Move the background into the back, but in front of the other background. m_lessDeepSpaceNode.Attach(lessDeepSpaceSprite); m_backgroundLayer.AddRenderable(deepSpaceSprite); m_backgroundLayer.AddRenderable(lessDeepSpaceSprite); // Create the dust cloud. var dustCloud = new Movables.DustCloud(100); m_dustCloudNode = m_world.Scene.Root.CreateChild("DustCloud"); m_dustCloudNode.Depth = -0.8f; m_dustCloudNode.Attach(dustCloud); m_backgroundLayer.AddRenderable(dustCloud); // Create the planet. m_terrainLayer = new DefaultLayer(typeof(Entities.TerrainRegion), null, 0.0f) { Scene = m_world.Scene }; m_miscLayer = new DefaultLayer(typeof(ISprite), "MISC_", -0.5f) { Scene = m_world.Scene }; CreatePlanet(); }
public CStaticModel(ISceneNode parentNode) : base(parentNode) { }