コード例 #1
10
ファイル: User.cs プロジェクト: RenaudWasTaken/SkyLands
        public User(StateManager stateMgr, API.Geo.World world)
        {
            this.mStateMgr = stateMgr;
            this.mWorld = world;
            this.mTimeSinceGUIOpen = new Timer();

            this.mCameraMan = null;
            this.IsAllowedToMoveCam = true;
            this.IsFreeCamMode = true;
            Camera cam = this.mStateMgr.Camera;
            cam.Position = new Vector3(-203, 633, -183);
            cam.Orientation = new Quaternion(0.3977548f, -0.1096644f, -0.8781486f, -0.2421133f);
            this.mCameraMan = new CameraMan(cam);
            this.mSelectedAllies = new HashSet<VanillaNonPlayer>();
            this.mRandom = new Random();

            this.mFigures = new MOIS.KeyCode[10];
            for (int i = 0; i < 9; i++)
                this.mFigures[i] = (MOIS.KeyCode)System.Enum.Parse(typeof(MOIS.KeyCode), "KC_" + (i + 1));
            this.mFigures[9] = MOIS.KeyCode.KC_0;

            this.mWireCube = this.mStateMgr.SceneMgr.RootSceneNode.CreateChildSceneNode();
            this.mWireCube.AttachObject(StaticRectangle.CreateRectangle(this.mStateMgr.SceneMgr, Vector3.UNIT_SCALE * Cst.CUBE_SIDE));
            this.mWireCube.SetVisible(false);

            this.Inventory = new Inventory(10, 4, new int[] { 3, 0, 1, 2 }, true);
        }
コード例 #2
0
 /// <param name="thing">The connected lthing, used for updating sounds. You can pass null to skip updating sounds.</param>
 public MogreMotionState(LThing thing, Vector3 position, Quaternion orientation, SceneNode node)
 {
     transform = new Matrix4(orientation);
     transform.MakeTransform(position, Vector3.UNIT_SCALE, orientation);
     this.node = node;
     this.owner = thing;
 }
コード例 #3
0
ファイル: ClockNode.cs プロジェクト: Download/Irrlicht-Lime
		public static ClockNode AddClockNode(SceneNode parent)
		{
			ClockNode n = new ClockNode(parent, parent.SceneManager);
			n.Drop();

			return n;
		}
コード例 #4
0
        public KnightyCamera(string name)
            : base(name)
        {
            var sceneMgr = LKernel.GetG<SceneManager>();

            // make our camera and set some properties
            Camera = sceneMgr.CreateCamera(name);
            Camera.NearClipDistance = 0.1f;
            Camera.FarClipDistance = 700f;
            Camera.AutoAspectRatio = true;

            // create the nodes we're going to interpolate
            CameraNode = sceneMgr.RootSceneNode.CreateChildSceneNode(name + "_KnightyCameraNode", new Vector3(0, Settings.Default.CameraNodeYOffset, Settings.Default.CameraNodeZOffset));
            TargetNode = sceneMgr.RootSceneNode.CreateChildSceneNode(name + "_KnightyCameraTargetNode", new Vector3(0, Settings.Default.CameraTargetYOffset, 0));

            CameraNode.SetAutoTracking(true, TargetNode);
            CameraNode.SetFixedYawAxis(true);

            CameraNode.AttachObject(Camera);

            // create the fixed nodes that are attached to the kart
            followKart = LKernel.GetG<PlayerManager>().MainPlayer.Kart;
            kartCamNode = followKart.RootNode.CreateChildSceneNode(name + "_KartKnightyCameraNode", new Vector3(0, Settings.Default.CameraNodeYOffset, Settings.Default.CameraNodeZOffset));
            kartTargetNode = followKart.RootNode.CreateChildSceneNode(name + "_KartKnightyCameraTargetNode", new Vector3(0, Settings.Default.CameraTargetYOffset, 0));

            CameraNode.Position = kartCamNode._getDerivedPosition();
            TargetNode.Position = kartTargetNode._getDerivedPosition();

            // initialise some stuff for the ray casting
            rayLength = (CameraNode.Position - TargetNode.Position).Length;
            world = LKernel.GetG<PhysicsMain>().World;
        }
コード例 #5
0
ファイル: RenderPass.cs プロジェクト: jyunfan2015/Calcifer
 public virtual void Visit(SceneNode node)
 {
     node.BeginRender();
     node.RenderNode();
     node.VisitChildren(this);
     node.EndRender();
 }
コード例 #6
0
        /// <summary>
        /// For ribbons!
        /// </summary>
        /// <param name="lthing">The Thing this component is attached to</param>
        /// <param name="template">The template from the Thing</param>
        /// <param name="block">The block we're creating this component from</param>
        public RibbonComponent(LThing lthing, ThingBlock template, RibbonBlock block)
        {
            ID = IDs.Incremental;
            var sceneMgr = LKernel.GetG<SceneManager>();

            Name = block.GetStringProperty("name", template.ThingName);

            // if ribbons are disabled, don't bother creating anything
            if (!Options.GetBool("Ribbons"))
                return;

            Ribbon = LKernel.GetG<SceneManager>().CreateRibbonTrail(Name + ID + "Ribbon");

            // set up some properties
            Ribbon.SetMaterialName(block.GetStringProperty("material", "ribbon"));
            Ribbon.TrailLength = block.GetFloatProperty("length", 5f);
            Ribbon.MaxChainElements = (uint) block.GetFloatProperty("elements", 10f);
            Ribbon.SetInitialWidth(0, block.GetFloatProperty("width", 1f));
            Ribbon.SetInitialColour(0, block.GetQuatProperty("colour", new Quaternion(1, 1, 1, 1)).ToColourValue());
            Ribbon.SetColourChange(0, block.GetQuatProperty("colourchange", new Quaternion(0, 0, 0, 3)).ToColourValue());
            Ribbon.SetWidthChange(0, block.GetFloatProperty("widthchange", 1f));

            // attach it to the node
            RibbonNode = LKernel.GetG<SceneManager>().RootSceneNode.CreateChildSceneNode(Name + ID + "RibbonNode");
            TrackedRibbonNode = lthing.RootNode.CreateChildSceneNode(Name + ID + "TrackedRibbonNode");
            Ribbon.AddNode(TrackedRibbonNode);
            RibbonNode.AttachObject(Ribbon);

            TrackedRibbonNode.Position = block.GetVectorProperty("position", null);
        }
コード例 #7
0
ファイル: INF1.cs プロジェクト: CryZe/WindEditor2
        private static SceneNode LoadINF1FromFile(SceneNode rootNode, EndianBinaryReader reader, long chunkStart)
        {
            ushort unknown1 = reader.ReadUInt16(); // A lot of Link's models have it but no idea what it means. Alt. doc says: "0 for BDL, 01 for BMD"
            ushort padding = reader.ReadUInt16();
            uint packetCount = reader.ReadUInt32(); // Total number of Packets across all Batches in file.
            uint vertexCount = reader.ReadUInt32(); // Total number of vertexes across all batches within the file.
            uint hierarchyDataOffset = reader.ReadUInt32();

            // The Hierarchy defines how Joints, Materials and Shapes are laid out. This allows them to bind a material
            // and draw multiple shapes (batches) with the material. It also complicates drawing things, but whatever.
            reader.BaseStream.Position = chunkStart + hierarchyDataOffset;

            List<InfoNode> infoNodes = new List<InfoNode>();
            InfoNode curNode = null;

            do
            {
                curNode = new InfoNode();
                curNode.Type = (HierarchyDataTypes)reader.ReadUInt16();
                curNode.Value = reader.ReadUInt16(); // "Index into Joint, Material, or Shape table.

                infoNodes.Add(curNode);
            }
            while (curNode.Type != HierarchyDataTypes.Finish);

            ConvertInfoHiearchyToSceneGraph(ref rootNode, infoNodes, 0);
            return rootNode;
        }
コード例 #8
0
ファイル: Tutorial.cs プロジェクト: Bobbylon5/Mogre14
        /// <summary>
        /// This method create the initial scene
        /// </summary>
        protected override void CreateScene()
        {
            #region Basics
            physics = new Physics();

            robot = new Robot(mSceneMgr);
            robot.setPosition(new Vector3(000, 0, 300));
            environment = new Environment(mSceneMgr, mWindow);
            playerModel = new PlayerModel(mSceneMgr);
            playerModel.setPosition(new Vector3(0, -80, 50));
            playerModel.hRotate(new Vector3(600, 0, 0));
            #endregion

            #region Camera
            cameraNode = mSceneMgr.CreateSceneNode();
            cameraNode.AttachObject(mCamera);
            playerModel.AddChild(cameraNode);
            inputsManager.PlayerModel = playerModel;
            #endregion

            #region Part 9
            PlayerStats playerStats = new PlayerStats();
            gameHMD = new GameInterface(mSceneMgr, mWindow, playerStats);
            #endregion

            robots = new List<Robot>();
            robots.Add(robot);
            robotsToRemove = new List<Robot>();
            bombs = new List<Bomb>();
            bombsToRemove = new List<Bomb>();
            physics.StartSimTimer();
        }
コード例 #9
0
ファイル: Particles.cs プロジェクト: Download/Irrlicht-Lime
		public void Add(SceneNode parent, uint time)
		{
			ParticleSystemSceneNode ps = device.SceneManager.AddParticleSystemSceneNode(false, parent);

			ParticleEmitter em = ps.CreateBoxEmitter(
				new AABBox(parent.BoundingBox.MinEdge / 4, parent.BoundingBox.MaxEdge / 4),
				new Vector3Df(0.0f, 0.025f, 0.0f),
				100, 200,
				new Color(0xffffffff), new Color(0xffffffff),
				1500, 2500);

			em.MinStartSize = new Dimension2Df(parent.BoundingBox.Extent.X, parent.BoundingBox.Extent.Y);
			em.MaxStartSize = em.MinStartSize * 1.5f;

			ps.Emitter = em;
			em.Drop();

			ParticleAffector paf = ps.CreateFadeOutParticleAffector();
			ps.AddAffector(paf);
			paf.Drop();

			ps.SetMaterialFlag(MaterialFlag.Lighting, false);
			ps.SetMaterialFlag(MaterialFlag.ZWrite, false);
			ps.SetMaterialTexture(0, device.VideoDriver.GetTexture("../../media/fireball.bmp"));
			ps.SetMaterialType(MaterialType.TransparentAddColor);

			particleNodes.Add(new ParticleNode(ps, time));
		}
コード例 #10
0
        public GrassPatchSceneNode(SceneNode parent, SceneManager mgr, int id, bool createIfEmpty,
                                   Vector3D gridPos, string filepath, Texture heightMap, Texture colourMap,
                                   Texture grassMap, SceneNode terrain, WindGenerator wind)
            : base(parent, mgr, id)
        {
            DrawDistance = GRASS_PATCH_SIZE * 1.5f;
            MaxDensity = 800;
            TerrainHeightMap = heightMap;
            TerrainColourMap = colourMap;
            TerrainGrassMap = grassMap;
            Terrain = terrain;
            WindGen = wind;
            lastwindtime = 0;
            lastdrawcount = 0;
            redrawnextloop = true;
            MaxFPS = 0;
            _mgr = mgr;
            WindRes = 5;

            filename = string.Format("{0}/{1}.{2}.grass", filepath, gridpos.X, gridpos.Z);
            gridpos = gridPos;
            Position = new Vector3D(gridpos.X * GRASS_PATCH_SIZE, 0f,
                                    gridpos.Z * GRASS_PATCH_SIZE);

            ImageCount = new Dimension2D(4, 2);

            if (!Load())
                Create(createIfEmpty);
        }
コード例 #11
0
        private float _timeSinceLastFrameLastUpdate; // Time value passed to the last call of the method "Update"

        #endregion Fields

        #region Constructors

        public CameraControlSystem(SceneManager sceneManager, string name, Camera camera = null, bool reCalcOnTargetMoving = true)
        {
            _sceneMgr = sceneManager;
            _name = name;
            _targetNode = null;
            _targetNodeListener = null;
            _recalcOnTargetMoving = reCalcOnTargetMoving;
            _currentCameraMode = null;

            _cameraNode = _sceneMgr.RootSceneNode.CreateChildSceneNode(_name + "SceneNode");

            if (camera == null) {
                _camera = _sceneMgr.CreateCamera(_name);
                _isOwnCamera = true;
            } else {
                _camera = camera;
                _isOwnCamera = false;
            }

            //Reset to default parameters
            _camera.Position = Vector3.ZERO;
            _camera.Orientation = Quaternion.IDENTITY;

            // ... and attach the Ogre camera to the camera node
            _cameraNode.AttachObject(_camera);

            _cameraModes = new Dictionary<string, CameraMode>();
        }
コード例 #12
0
        private SceneNode BuildInternal(object source, SceneNode parent, bool forceBuild,
            ref bool cancelLoad)
        {
            SceneNode node = BuildNodeInternal(source, parent, forceBuild);

            if (node == null)
                return parent;

            if (cancelLoad)
                return node;

            lock (s_lock)
            {
                // We must catch cyclic graphs to avoid infinite recursion.
                if (s_ancestors.Contains(source))
                    return node;
                try
                {
                    s_ancestors.Add(source);

                    ISceneGraphHierarchy modelNode = source.As<ISceneGraphHierarchy>();
                    IEnumerable<object> children = (modelNode != null) ? modelNode.GetChildren() : m_treeView.GetChildren(source);
                    
                    foreach (object child in children )
                        BuildInternal(child, node, false, ref cancelLoad);
                }
                finally
                {
                    s_ancestors.Remove(source);
                }
            }

            return node;
        }
コード例 #13
0
		public void Add(SceneNode node, uint duration, Vector3Df targetPosition, Vector3Df targetRotation, Vector3Df targetScale)
		{
			Remove(node);

			irrDevice.Timer.Tick();

			AnimationItem a = new AnimationItem();
			a.Node = node;
			a.Node.Grab();
			a.Duration = duration;
			a.StartTime = irrDevice.Timer.Time;
			
			if (targetPosition != null)
			{
				a.TargetPosition = targetPosition;
				a.StartPosition = node.Position;
			}

			if (targetRotation != null)
			{
				a.TargetRotation = targetRotation;
				a.StartRotation = node.Rotation;
			}

			if (targetScale != null)
			{
				a.TargetScale = targetScale;
				a.StartScale = node.Scale;
			}

			lock (animationItems)
			{
				animationItems.Add(a);
			}
		}
コード例 #14
0
ファイル: CaelumBase.cs プロジェクト: huytd/fosproject
        /// <summary>
        /// Disposes all resources used by this element.</summary>
        public virtual void Dispose()
        {
            if (mNode != null)
                mNode.Dispose();

            mNode = null;
        }
コード例 #15
0
        public override void CreateScene()
        {
            TexturePtr mTexture = TextureManager.Singleton.CreateManual("RenderArea",
                                      ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D,
                                      512, 512, 0, PixelFormat.PF_R8G8B8, (int)TextureUsage.TU_RENDERTARGET);
            rttTex = mTexture.GetBuffer().GetRenderTarget();
            rttTex.IsAutoUpdated = false;
            {
                // Create the camera
                Camera camera2 = sceneMgr.CreateCamera("PlayerCam2");

                camera2.Position = new Vector3(0, 0, 3);
                camera2.LookAt(new Vector3(0.0f, 0.0f, 0.0f));
                camera2.NearClipDistance = 1;

                Viewport v = rttTex.AddViewport(camera2);

                MaterialPtr mat = MaterialManager.Singleton.GetByName("CgTutorials/RenderToTexture_Material");
                mat.GetTechnique(0).GetPass(0).GetTextureUnitState(0).SetTextureName("RenderArea");
                v.BackgroundColour = new ColourValue(0.0f, 0.3f, 0.2f, 0.0f);
                //v.SetClearEveryFrame(false);
                //v.OverlaysEnabled = false;
                rttTex.PreRenderTargetUpdate += new RenderTargetListener.PreRenderTargetUpdateHandler(RenderArea_PreRenderTargetUpdate);
                rttTex.PostRenderTargetUpdate += new RenderTargetListener.PostRenderTargetUpdateHandler(RenderArea_PostRenderTargetUpdate);
            }

            node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("TutorialRender2TexNode1");
            node2 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("TutorialRender2TexNode2");

            manualObj1 = sceneMgr.CreateManualObject("TutorialRender2TexObject1");
            manualObj2 = sceneMgr.CreateManualObject("TutorialRender2TexObject2");

            node1.AttachObject(DrawTriangle1(manualObj1));
            node2.AttachObject(DrawTriangle2(manualObj2));
        }
コード例 #16
0
        public void Attach(SceneNode parent)
        {
            localParent = parent;
            localRoot = parent = new SceneNode(parent);
            var physicsComponent = Record.GetComponent<PhysicsComponent>();
            if (physicsComponent != null) new DebugDrawNode(parent, physicsComponent.Body);

            var transformComponent = Record.GetComponent<TransformComponent>();
            if (meshData == null) return;
            parent = new TransformNode(parent, transformComponent ?? new TransformComponent());
            var animationComponent = Record.GetComponent(default(AnimationComponent), true);
            if (animationComponent != null) parent = new AnimationNode(parent, animationComponent);
            var tri = meshData.Submeshes[0].Triangles;
            var vert = meshData.Submeshes[0].Vertices;
            var vbo = new VertexBuffer(vert.Length * SkinnedVertex.Size, BufferTarget.ArrayBuffer,
                                       BufferUsageHint.StaticDraw);
            var ibo = new VertexBuffer(tri.Length * Vector3i.Size, BufferTarget.ElementArrayBuffer,
                                       BufferUsageHint.StaticDraw);
            vbo.Write(0, vert);
            ibo.Write(0, tri);
            var vboNode = new VBONode(parent, vbo, ibo);
            foreach (var matGroup in from g in meshData.Submeshes group g by g.Material)
            {
                foreach (var geometry in matGroup)
                {
                    var mat = matGroup.Key;
                    new SubmeshNode(new MaterialNode(vboNode, mat), geometry);
                }
            }
        }
コード例 #17
0
        public MovableText(string name, SceneManager sceneMgr, SceneNode node, Size size)
        {
            this.texture = TextureManager.Singleton.CreateManual(
                name + "Texture",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D,
                (uint)size.Width,
                (uint)size.Height,
                0,
                PixelFormat.PF_A8R8G8B8);

            this.material = MaterialManager.Singleton.Create(name + "Material", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            this.material.GetTechnique(0).GetPass(0).CreateTextureUnitState(this.texture.Name);
            this.material.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            this.material.SetDepthCheckEnabled(false);

            this.billboardSet = sceneMgr.CreateBillboardSet();
            this.billboardSet.SetMaterialName(this.material.Name);
            this.billboardSet.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;

            this.billboard = this.billboardSet.CreateBillboard(Vector3.ZERO);
            this.billboard.SetDimensions(size.Width, size.Height);
            this.billboard.Colour = ColourValue.ZERO;

            node.AttachObject(this.billboardSet);
            this.sceneMgr = sceneMgr;
            this.size = size;
        }
コード例 #18
0
ファイル: BasicDemo.cs プロジェクト: raiker/BulletSharp
        public override void CreateScene()
        {
            // Set ambient light and fog
            sceneMgr.AmbientLight = new ColourValue(0, 0, 0);
            sceneMgr.SetFog(FogMode.FOG_LINEAR, skyColor, 0, 150, 300);

            // Create sun-light
            Light light = sceneMgr.CreateLight("Sun");
            light.Type = Light.LightTypes.LT_POINT;
            light.Position = new Vector3(150, 100, 150);

            sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE;
		    sceneMgr.ShadowFarDistance = 100;
		    sceneMgr.ShadowColour = new ColourValue(0.7f, 0.7f, 0.7f);
		    sceneMgr.SetShadowTextureSize(512);

            // Ground
            Plane ground = new Plane(Vector3.UNIT_Y, 1);
            MeshManager.Singleton.CreatePlane("groundPlane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                ground, 500, 500, 20, 20, true, 1, 1, 1, Vector3.UNIT_Z);

            Entity groundEnt = sceneMgr.CreateEntity("groundPlaneEntity", "groundPlane");
            groundEnt.CastShadows = true;
            groundEnt.SetMaterialName("BoxMaterial/Ground");

            planeNode = sceneMgr.RootSceneNode.CreateChildSceneNode();
            planeNode.AttachObject(groundEnt);

            physics = new Physics(sceneMgr);
        }
コード例 #19
0
ファイル: WayPoint.cs プロジェクト: janPierdolnikParda/RPG
        public WayPoint()
        {
            _Orientation = Quaternion.IDENTITY;
            _DisplayNameOffset = new Vector3(0, 0.2f, 0);

            Entity = Engine.Singleton.SceneManager.CreateEntity("Spawn.mesh");
            Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                Node,
                Quaternion.IDENTITY,
                0.1f,
                Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;
            collision.CalculateInertialMatrix(out inertia, out offset);

            Inertia = inertia;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(0, inertia * 0);

            Body.ForceCallback += BodyForceCallback;

            Body.UserData = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.WaypointMaterialID;
            //Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;

            collision.Dispose();
        }
コード例 #20
0
ファイル: Shadows.cs プロジェクト: Download/Irrlicht-Lime
		public void RemoveObject(SceneNode node)
		{
			if (buildThread != null)
				buildThread.Join();

			objects.Remove(node);
		}
コード例 #21
0
ファイル: Shadows.cs プロジェクト: Download/Irrlicht-Lime
		public void RemoveLight(SceneNode node)
		{
			if (buildThread != null)
				buildThread.Join();

			lights.Remove(node);
		}
コード例 #22
0
 public FirstPersonModel(Character character, SceneNode eyeNode)
     : base(character)
 {
     this.EyeNode = eyeNode;
     WeaponSceneNode = EyeNode.CreateChildSceneNode();
     WeaponCenterNode = WeaponSceneNode.CreateChildSceneNode();
 }
コード例 #23
0
        public void Add(SceneNode sceneNode)
        {
            if (_dictSceneNode.ContainsKey (sceneNode.name) == true)
                return;

            _dictSceneNode.Add (sceneNode.name, sceneNode);
        }
コード例 #24
0
ファイル: MultiBlock.cs プロジェクト: RenaudWasTaken/SkyLands
 public void display(Island currentIsland, API.Geo.World currentWorld)
 {
     if (this.faceNumber > 0) {
         block.End();
         this.node = this.mIsland.Node.CreateChildSceneNode("MultiBlockNode-" + this.mName);
         this.node.AttachObject(block);
     }
 }
コード例 #25
0
ファイル: Bullet.cs プロジェクト: RenaudWasTaken/SkyLands
 public Bullet(VanillaCharacter source, SceneNode node, Vector3 forwardDir)
 {
     this.mSource = source;
     this.mYawNode = node;
     this.mRay = new Ray(this.mYawNode.Position, this.mYawNode.Orientation * Vector3.NEGATIVE_UNIT_Z);
     this.mForwardDir = forwardDir;
     this.mAccurateTest = true;
 }
コード例 #26
0
 public int Add(SceneNode sn)
 {
     if (IndexOf(sn.Name) > 0) throw new InvalidOperationException("A SceneNode with the name \"" + sn.Name + "\" already exists.");
     lock (allSceneNodes2)
     {
         return allSceneNodes2.Add(((SceneNode)sn));
     }
 }
コード例 #27
0
ファイル: SceneClip.cs プロジェクト: agustinsantos/mogregis3d
 /// <summary> Construct an SceneClip object with the given Clip scene.
 /// 
 /// </summary>
 /// <param name="Clip">the Clip scene.
 /// </param>
 public SceneClip(SceneNode clip)
 {
     #if PENDING
     this.clip = clip;
     if (isVisible())
         clip.addVisibleParent(this);
     #endif
 }
コード例 #28
0
ファイル: Map.cs プロジェクト: Marchew/Tachycardia
 public void SetGraphicsMesh(String meshFile)
 {
     m_GraphicsNode =
         Core.Singleton.m_SceneManager.RootSceneNode.CreateChildSceneNode();
     m_GraphicsEntity = Core.Singleton.m_SceneManager.CreateEntity(meshFile);
     m_GraphicsNode.AttachObject(m_GraphicsEntity);
     m_GraphicsEntity.CastShadows = false;
 }
コード例 #29
0
ファイル: Shadows.cs プロジェクト: Download/Irrlicht-Lime
		public void AddLight(SceneNode node)
		{
			if (buildThread != null)
				buildThread.Join();

			node.UpdateAbsolutePosition();
			lights.Add(node);
		}
コード例 #30
0
ファイル: Physics.cs プロジェクト: rhynodegreat/BulletSharp
 public MogreMotionState(Entity entity, SceneNode node, Matrix4 startTransform)
 {
     this.entity = entity;
     this.node = node;
     
     node.Position = startTransform.GetTrans();
     node.Orientation = startTransform.ExtractQuaternion();
 }
コード例 #31
0
 public void InitializeControls(MyModel m)
 {
     mCurrentSelectedNode = m.GetRootNode();
     BuildSceneTree(mCurrentSelectedNode);
     SelectedNodeSetControl();
 }
コード例 #32
0
 public void SetSceneNodes(SceneNode parent, SceneNode adNode)
 {
     this.parent = parent;
     this.adNode = adNode;
 }
コード例 #33
0
 public void SetGrid()
 {
     mainGrid = sceneMgr.RootSceneNode.CreateChildSceneNode("mainGrid_node");
     mainGrid.SetPosition(0, -0.05f, 0);
     mainGrid.AttachObject(CreateGrid(sceneMgr, 30f, 1f, "main"));
 }
コード例 #34
0
        public PlantRenderable(IndexData ind, VertexData vert, AxisAlignedBox bbox, PageCoord pc, SceneNode parent, Vector3 blockLoc)
        {
            indexData       = ind;
            vertexData      = vert;
            material        = MaterialManager.Instance.GetByName("Multiverse/DetailVeg");
            box             = bbox;
            pageCoord       = pc;
            parentSceneNode = parent;
            sceneNode       = parentSceneNode.CreateChildSceneNode(string.Format("DetailVeg-{0}", pageCoord));
            sceneNode.AttachObject(this);
            sceneNode.Position = new Vector3(blockLoc.x, 0, blockLoc.z);

            this.ShowBoundingBox = false;

            CastShadows = true;
        }
コード例 #35
0
        ClockNode(SceneNode parent, SceneManager smgr)
            : base(parent, smgr)
        {
            OnGetBoundingBox    += new GetBoundingBoxEventHandler(ClockNode_OnGetBoundingBox);
            OnGetMaterialCount  += new GetMaterialCountEventHandler(ClockNode_OnGetMaterialCount);
            OnGetMaterial       += new GetMaterialEventHandler(ClockNode_OnGetMaterial);
            OnRegisterSceneNode += new RegisterSceneNodeEventHandler(ClockNode_OnRegisterSceneNode);
            OnRender            += new RenderEventHandler(ClockNode_OnRender);
            OnAnimate           += new AnimateEventHandler(ClockNode_OnAnimate);

            // add clock face

            Mesh          mesh      = SceneManager.GeometryCreator.CreateCylinderMesh(100, 32, 6, new Color(180, 180, 180));
            MeshSceneNode clockFace = SceneManager.AddMeshSceneNode(mesh, this);

            clockFace.Rotation = new Vector3Df(90, 0, 0);
            clockFace.Position = new Vector3Df(0, 0, 10);
            mesh.Drop();

            clockFace.UpdateAbsolutePosition();
            boundingBox = clockFace.BoundingBoxTransformed;
            for (int i = 0; i < clockFace.MaterialCount; i++)
            {
                materialList.Add(clockFace.GetMaterial(i));
            }

            // add clock center

            mesh = SceneManager.GeometryCreator.CreateCylinderMesh(10, 24, 16, new Color(255, 255, 255), false);
            MeshSceneNode clockCenter = SceneManager.AddMeshSceneNode(mesh, this);

            clockCenter.Rotation = new Vector3Df(90, 0, 0);
            clockCenter.Position = new Vector3Df(0, 0, -14);
            mesh.Drop();

            clockCenter.UpdateAbsolutePosition();
            boundingBox.AddInternalBox(clockCenter.BoundingBoxTransformed);
            for (int i = 0; i < clockCenter.MaterialCount; i++)
            {
                materialList.Add(clockCenter.GetMaterial(i));
            }

            // add clock ticks

            for (int j = 0; j < 12; j++)
            {
                mesh = SceneManager.GeometryCreator.CreateCylinderMesh(5, 10, 16, new Color(255, 255, 255), false);
                MeshSceneNode clockTick = SceneManager.AddMeshSceneNode(mesh, this);
                clockTick.Rotation = new Vector3Df(90, 0, 0);

                float s = (float)Math.Sin((j * (360 / 12)) / (180 / Math.PI));
                float c = (float)Math.Cos((j * (360 / 12)) / (180 / Math.PI));
                clockTick.Position = new Vector3Df(s * 80, c * 80, 0);

                if ((j % 3) == 0)
                {
                    clockTick.Scale = new Vector3Df(2, 1, 2);
                }

                mesh.Drop();

                clockTick.UpdateAbsolutePosition();
                boundingBox.AddInternalBox(clockTick.BoundingBoxTransformed);
                for (int i = 0; i < clockTick.MaterialCount; i++)
                {
                    materialList.Add(clockTick.GetMaterial(i));
                }
            }

            // add hour arrow

            mesh       = SceneManager.GeometryCreator.CreateArrowMesh(12, 12, 40, 35, 4, 4, new Color(40, 40, 255), new Color(40, 40, 255));
            arrowHours = SceneManager.AddMeshSceneNode(mesh, this);
            arrowHours.GetMaterial(0).EmissiveColor = new Color(0, 0, 255);
            arrowHours.GetMaterial(1).EmissiveColor = new Color(0, 0, 255);
            arrowHours.Position = new Vector3Df(0, 0, 3);
            mesh.Drop();

            arrowHours.UpdateAbsolutePosition();
            boundingBox.AddInternalBox(arrowHours.BoundingBoxTransformed);
            for (int i = 0; i < arrowHours.MaterialCount; i++)
            {
                materialList.Add(arrowHours.GetMaterial(i));
            }

            // add minute arrow

            mesh         = SceneManager.GeometryCreator.CreateArrowMesh(12, 12, 60, 50, 4, 4, new Color(40, 255, 40), new Color(40, 255, 40));
            arrowMinutes = SceneManager.AddMeshSceneNode(mesh, this);
            arrowMinutes.GetMaterial(0).EmissiveColor = new Color(0, 255, 0);
            arrowMinutes.GetMaterial(1).EmissiveColor = new Color(0, 255, 0);
            arrowMinutes.Position = new Vector3Df(0, 0, -5);
            mesh.Drop();

            arrowMinutes.UpdateAbsolutePosition();
            boundingBox.AddInternalBox(arrowMinutes.BoundingBoxTransformed);
            for (int i = 0; i < arrowMinutes.MaterialCount; i++)
            {
                materialList.Add(arrowMinutes.GetMaterial(i));
            }

            // add second arrow

            mesh         = SceneManager.GeometryCreator.CreateArrowMesh(12, 12, 70, 60, 2, 2, new Color(255, 40, 40), new Color(255, 40, 40));
            arrowSeconds = SceneManager.AddMeshSceneNode(mesh, this);
            arrowSeconds.GetMaterial(0).EmissiveColor = new Color(255, 0, 0);
            arrowSeconds.GetMaterial(1).EmissiveColor = new Color(255, 0, 0);
            arrowSeconds.Position = new Vector3Df(0, 0, -11);
            mesh.Drop();

            arrowSeconds.UpdateAbsolutePosition();
            boundingBox.AddInternalBox(arrowSeconds.BoundingBoxTransformed);
            for (int i = 0; i < arrowSeconds.MaterialCount; i++)
            {
                materialList.Add(arrowSeconds.GetMaterial(i));
            }

            SceneManager.AddLightSceneNode(arrowSeconds, new Vector3Df(0, 70, 0), new Colorf(arrowSeconds.GetMaterial(0).EmissiveColor), 80);
            SceneManager.AddLightSceneNode(arrowMinutes, new Vector3Df(0, 60, 0), new Colorf(arrowMinutes.GetMaterial(0).EmissiveColor), 60);
            SceneManager.AddLightSceneNode(arrowHours, new Vector3Df(0, 40, 0), new Colorf(arrowHours.GetMaterial(0).EmissiveColor), 40);
        }
コード例 #36
0
ファイル: FigureSample.cs プロジェクト: terrynoya/DigitalRune
        // Add a 3D coordinate cross.
        private void CreateGizmo(SpriteFont spriteFont)
        {
            var gizmoNode = new SceneNode
            {
                Name       = "Gizmo",
                Children   = new SceneNodeCollection(),
                PoseLocal  = new Pose(new Vector3F(3, 2, 0)),
                ScaleLocal = new Vector3F(0.5f)
            };

            // Red arrow
            var arrow = new PathFigure2F();

            arrow.Segments.Add(new LineSegment2F {
                Point1 = new Vector2F(0, 0), Point2 = new Vector2F(1, 0)
            });
            arrow.Segments.Add(new LineSegment2F {
                Point1 = new Vector2F(1, 0), Point2 = new Vector2F(0.9f, 0.02f)
            });
            arrow.Segments.Add(new LineSegment2F {
                Point1 = new Vector2F(1, 0), Point2 = new Vector2F(0.9f, -0.02f)
            });
            var figureNode = new FigureNode(arrow)
            {
                Name            = "Gizmo X",
                StrokeThickness = 2,
                StrokeColor     = new Vector3F(1, 0, 0),
                PoseLocal       = new Pose(new Vector3F(0, 0, 0))
            };

            gizmoNode.Children.Add(figureNode);

            // Green arrow
            var transformedArrow = new TransformedFigure(arrow)
            {
                Pose = new Pose(Matrix33F.CreateRotationZ(MathHelper.ToRadians(90)))
            };

            figureNode = new FigureNode(transformedArrow)
            {
                Name            = "Gizmo Y",
                StrokeThickness = 2,
                StrokeColor     = new Vector3F(0, 1, 0),
                PoseLocal       = new Pose(new Vector3F(0, 0, 0))
            };
            gizmoNode.Children.Add(figureNode);

            // Blue arrow
            transformedArrow = new TransformedFigure(arrow)
            {
                Pose = new Pose(Matrix33F.CreateRotationY(MathHelper.ToRadians(-90)))
            };
            figureNode = new FigureNode(transformedArrow)
            {
                Name            = "Gizmo Z",
                StrokeThickness = 2,
                StrokeColor     = new Vector3F(0, 0, 1),
                PoseLocal       = new Pose(new Vector3F(0, 0, 0))
            };
            gizmoNode.Children.Add(figureNode);

            // Red arc
            var arc = new PathFigure2F();

            arc.Segments.Add(
                new StrokedSegment2F(
                    new LineSegment2F {
                Point1 = new Vector2F(0, 0), Point2 = new Vector2F(1, 0),
            },
                    false));
            arc.Segments.Add(
                new ArcSegment2F
            {
                Point1 = new Vector2F(1, 0),
                Point2 = new Vector2F(0, 1),
                Radius = new Vector2F(1, 1)
            });
            arc.Segments.Add(
                new StrokedSegment2F(
                    new LineSegment2F {
                Point1 = new Vector2F(0, 1), Point2 = new Vector2F(0, 0),
            },
                    false));
            var transformedArc = new TransformedFigure(arc)
            {
                Scale = new Vector3F(0.333f),
                Pose  = new Pose(Matrix33F.CreateRotationY(MathHelper.ToRadians(-90)))
            };

            figureNode = new FigureNode(transformedArc)
            {
                Name            = "Gizmo YZ",
                StrokeThickness = 2,
                StrokeColor     = new Vector3F(1, 0, 0),
                FillColor       = new Vector3F(1, 0, 0),
                FillAlpha       = 0.5f,
                PoseLocal       = new Pose(new Vector3F(0, 0, 0))
            };
            gizmoNode.Children.Add(figureNode);

            // Green arc
            transformedArc = new TransformedFigure(arc)
            {
                Scale = new Vector3F(0.333f),
                Pose  = new Pose(Matrix33F.CreateRotationX(MathHelper.ToRadians(90)))
            };
            figureNode = new FigureNode(transformedArc)
            {
                Name            = "Gizmo XZ",
                StrokeThickness = 2,
                StrokeColor     = new Vector3F(0, 1, 0),
                FillColor       = new Vector3F(0, 1, 0),
                FillAlpha       = 0.5f,
                PoseLocal       = new Pose(new Vector3F(0, 0, 0))
            };
            gizmoNode.Children.Add(figureNode);

            // Blue arc
            transformedArc = new TransformedFigure(arc)
            {
                Scale = new Vector3F(0.333f),
            };
            figureNode = new FigureNode(transformedArc)
            {
                Name            = "Gizmo XY",
                StrokeThickness = 2,
                StrokeColor     = new Vector3F(0, 0, 1),
                FillColor       = new Vector3F(0, 0, 1),
                FillAlpha       = 0.5f,
                PoseLocal       = new Pose(new Vector3F(0, 0, 0))
            };
            gizmoNode.Children.Add(figureNode);

            // Labels "X", "Y", "Z"
            var spriteNode = new SpriteNode(new TextSprite("X", spriteFont))
            {
                Color     = new Vector3F(1, 0, 0),
                Origin    = new Vector2F(0, 1),
                PoseLocal = new Pose(new Vector3F(1, 0, 0))
            };

            gizmoNode.Children.Add(spriteNode);
            spriteNode = new SpriteNode(new TextSprite("Y", spriteFont))
            {
                Color     = new Vector3F(0, 1, 0),
                Origin    = new Vector2F(0, 1),
                PoseLocal = new Pose(new Vector3F(0, 1, 0))
            };
            gizmoNode.Children.Add(spriteNode);
            spriteNode = new SpriteNode(new TextSprite("Z", spriteFont))
            {
                Color     = new Vector3F(0, 0, 1),
                Origin    = new Vector2F(0, 1),
                PoseLocal = new Pose(new Vector3F(0, 0, 1))
            };
            gizmoNode.Children.Add(spriteNode);

            _scene.Children.Add(gizmoNode);
        }
コード例 #37
0
 private void UnsubscribeBoundChangeEvent(SceneNode item)
 {
     item.TransformBoundChanged -= Item_OnBoundChanged;
 }
コード例 #38
0
 /// <summary>
 /// Removes the item.
 /// </summary>
 /// <param name="item">The item.</param>
 public abstract void RemoveItem(SceneNode item);
コード例 #39
0
 /// <summary>
 /// Adds the pending item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public abstract bool AddPendingItem(SceneNode item);
コード例 #40
0
        static void Main()
        {
            DriverType?driverType = AskForDriver();

            if (!driverType.HasValue)
            {
                return;
            }

            IrrlichtDevice device = IrrlichtDevice.CreateDevice(driverType.Value, new Dimension2Di(ResX, ResY), 32, fullScreen);

            if (device == null)
            {
                return;
            }

            device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent);
            VideoDriver  driver = device.VideoDriver;
            SceneManager smgr   = device.SceneManager;

            // load model
            AnimatedMesh model = smgr.GetMesh("../../media/sydney.md2");

            if (model == null)
            {
                return;
            }

            AnimatedMeshSceneNode model_node = smgr.AddAnimatedMeshSceneNode(model);

            // load texture
            if (model_node != null)
            {
                Texture texture = driver.GetTexture("../../media/sydney.bmp");
                model_node.SetMaterialTexture(0, texture);
                model_node.SetMD2Animation(AnimationTypeMD2.Run);
                model_node.SetMaterialFlag(MaterialFlag.Lighting, false);
            }

            // load map
            device.FileSystem.AddFileArchive("../../media/map-20kdm2.pk3");
            AnimatedMesh map = smgr.GetMesh("20kdm2.bsp");

            if (map != null)
            {
                SceneNode map_node = smgr.AddOctreeSceneNode(map.GetMesh(0));
                map_node.Position = new Vector3Df(-850, -220, -850);
            }

            // create 3 fixed and one user-controlled cameras
            camera[0]          = smgr.AddCameraSceneNode(null, new Vector3Df(50, 0, 0), new Vector3Df(0)); // font
            camera[1]          = smgr.AddCameraSceneNode(null, new Vector3Df(0, 50, 0), new Vector3Df(0)); // top
            camera[2]          = smgr.AddCameraSceneNode(null, new Vector3Df(0, 0, 50), new Vector3Df(0)); // left
            camera[3]          = smgr.AddCameraSceneNodeFPS();                                             // user-controlled
            camera[3].Position = new Vector3Df(-50, 0, -50);

            device.CursorControl.Visible = false;

            int lastFPS = -1;

            while (device.Run())
            {
                // set the viewpoint to the whole screen and begin scene
                driver.ViewPort = new Recti(0, 0, ResX, ResY);
                driver.BeginScene(ClearBufferFlag.All, new Color(100, 100, 100));

                if (splitScreen)
                {
                    smgr.ActiveCamera = camera[0];
                    driver.ViewPort   = new Recti(0, 0, ResX / 2, ResY / 2);                   // top left
                    smgr.DrawAll();

                    smgr.ActiveCamera = camera[1];
                    driver.ViewPort   = new Recti(ResX / 2, 0, ResX, ResY / 2);                   // top right
                    smgr.DrawAll();

                    smgr.ActiveCamera = camera[2];
                    driver.ViewPort   = new Recti(0, ResY / 2, ResX / 2, ResY);                   // bottom left
                    smgr.DrawAll();

                    driver.ViewPort = new Recti(ResX / 2, ResY / 2, ResX, ResY);                     // bottom right
                }

                smgr.ActiveCamera = camera[3];
                smgr.DrawAll();

                driver.EndScene();

                int fps = driver.FPS;
                if (lastFPS != fps)
                {
                    device.SetWindowCaption(String.Format(
                                                "Split Screen example - Irrlicht Engine [{0}] fps: {1}",
                                                driver.Name, fps));

                    lastFPS = fps;
                }
            }

            device.Drop();
        }
コード例 #41
0
        private RayMeshGeometry3DHitTestResult CreateRayMeshGeometry3DHitTestResult(DXRayHitTestResult dxRayHitTestResult)
        {
            if (dxRayHitTestResult == null)
            {
                return(null);
            }


            Visual3D        visualHit;
            GeometryModel3D modelHit;
            MeshGeometry3D  meshHit;
            int             vertexIndex1, vertexIndex2, vertexIndex3;

            var wpfGeometryModel3DNode = dxRayHitTestResult.HitSceneNode as WpfGeometryModel3DNode;

            if (wpfGeometryModel3DNode != null)
            {
                modelHit = wpfGeometryModel3DNode.GeometryModel3D as GeometryModel3D;
                meshHit  = wpfGeometryModel3DNode.DXMesh.MeshGeometry;

                int indiceIndex = dxRayHitTestResult.TriangleIndex * 3;

                vertexIndex1 = meshHit.TriangleIndices[indiceIndex];
                vertexIndex2 = meshHit.TriangleIndices[indiceIndex + 1];
                vertexIndex3 = meshHit.TriangleIndices[indiceIndex + 2];
            }
            else
            {
                modelHit = null;
                meshHit  = null;

                vertexIndex1 = vertexIndex2 = vertexIndex3 = 0;
            }

            SceneNode currentNode = dxRayHitTestResult.HitSceneNode;

            while (currentNode != null && !(currentNode is WpfModelVisual3DNode))
            {
                currentNode = currentNode.ParentNode;
            }

            var wpfModelVisual3DNode = currentNode as WpfModelVisual3DNode;

            if (wpfModelVisual3DNode != null)
            {
                visualHit = wpfModelVisual3DNode.ModelVisual3D;
            }
            else
            {
                visualHit = null;
            }

            var rayMeshGeometry3DHitTestResult = CreateRayMeshGeometry3DHitTestResult(
                visualHit,
                modelHit,
                meshHit,
                dxRayHitTestResult.HitPosition.ToWpfPoint3D(),
                (double)dxRayHitTestResult.DistanceToRayOrigin,
                vertexIndex1,
                vertexIndex2,
                vertexIndex3,
                new Point(0, 0));     // barycentricCoordinate is not supported - user will need to calculate that by himself from triangle data if needed

            return(rayMeshGeometry3DHitTestResult);
        }
コード例 #42
0
 private void TreeControl_AfterSelect(object sender, TreeViewEventArgs e)
 {
     mCurrentSelectedNode = (SceneNode)e.Node.Tag;
     SelectedNodeSetControl();
 }
コード例 #43
0
        private void GetNodesRecursive(Rigging.Bone bone, List <Rigging.Bone> skeleton, SceneNode parent, List <Mesh> meshes, List <Material> materials)
        {
            SceneNode node = new SceneNode(NodeType.Joint, skeleton.IndexOf(bone), parent);

            FlatNodes.Add(node);

            int downNodeCount = 0;

            for (int mat_index = 0; mat_index < materials.Count; mat_index++)
            {
                foreach (Mesh mesh in meshes)
                {
                    if (mesh.MaterialIndex != mat_index)
                    {
                        continue;
                    }
                    if (mesh.BoneCount != 1 || mesh.Bones[0].Name != bone.Name)
                    {
                        continue;
                    }

                    SceneNode downNode1 = new SceneNode(NodeType.OpenChild, 0, Root);
                    SceneNode matNode   = new SceneNode(NodeType.Material, meshes.IndexOf(mesh), Root);
                    SceneNode downNode2 = new SceneNode(NodeType.OpenChild, 0, Root);
                    SceneNode shapeNode = new SceneNode(NodeType.Shape, meshes.IndexOf(mesh), Root);

                    FlatNodes.Add(downNode1);
                    FlatNodes.Add(matNode);
                    FlatNodes.Add(downNode2);
                    FlatNodes.Add(shapeNode);

                    downNodeCount += 2;
                }
            }

            if (bone.Children.Count > 0)
            {
                SceneNode downNode = new SceneNode(NodeType.OpenChild, 0, parent);
                FlatNodes.Add(downNode);

                foreach (Rigging.Bone child in bone.Children)
                {
                    GetNodesRecursive(child, skeleton, node, meshes, materials);
                }

                SceneNode upNode = new SceneNode(NodeType.CloseChild, 0, parent);
                FlatNodes.Add(upNode);
            }

            for (int i = 0; i < downNodeCount; i++)
            {
                FlatNodes.Add(new SceneNode(NodeType.CloseChild, 0, Root));
            }
        }
コード例 #44
0
 /// <summary>
 /// Adds the pending item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 /// <exception cref="NotImplementedException"></exception>
 public override bool AddPendingItem(SceneNode item)
 {
     return(false);
 }
コード例 #45
0
ファイル: FigureSample.cs プロジェクト: terrynoya/DigitalRune
        // Add a grid with thick major grid lines and thin stroked minor grid lines.
        private void CreateGrid()
        {
            var majorGridLines = new PathFigure3F();

            for (int i = 0; i <= 10; i++)
            {
                majorGridLines.Segments.Add(new LineSegment3F
                {
                    Point1 = new Vector3F(-5, 0, -5 + i),
                    Point2 = new Vector3F(5, 0, -5 + i),
                });
                majorGridLines.Segments.Add(new LineSegment3F
                {
                    Point1 = new Vector3F(-5 + i, 0, -5),
                    Point2 = new Vector3F(-5 + i, 0, 5),
                });
            }

            var minorGridLines = new PathFigure3F();

            for (int i = 0; i < 10; i++)
            {
                minorGridLines.Segments.Add(new LineSegment3F
                {
                    Point1 = new Vector3F(-5, 0, -4.5f + i),
                    Point2 = new Vector3F(5, 0, -4.5f + i),
                });
                minorGridLines.Segments.Add(new LineSegment3F
                {
                    Point1 = new Vector3F(-4.5f + i, 0, -5),
                    Point2 = new Vector3F(-4.5f + i, 0, 5),
                });
            }

            var majorLinesNode = new FigureNode(majorGridLines)
            {
                Name            = "Major grid lines",
                PoseLocal       = Pose.Identity,
                StrokeThickness = 2,
                StrokeColor     = new Vector3F(0.1f),
                StrokeAlpha     = 1f,
            };
            var minorLinesNode = new FigureNode(minorGridLines)
            {
                Name              = "Minor grid lines",
                PoseLocal         = Pose.Identity,
                StrokeThickness   = 1,
                StrokeColor       = new Vector3F(0.1f),
                StrokeAlpha       = 1f,
                DashInWorldSpace  = true,
                StrokeDashPattern = new Vector4F(10, 4, 0, 0) / 200,
            };
            var gridNode = new SceneNode
            {
                Name      = "Grid",
                Children  = new SceneNodeCollection(),
                PoseLocal = new Pose(new Vector3F(0, -0.5f, 0)),
            };

            gridNode.Children.Add(majorLinesNode);
            gridNode.Children.Add(minorLinesNode);
            _scene.Children.Add(gridNode);
        }
コード例 #46
0
 public ParticleNode(SceneNode n, uint time)
 {
     Node         = n;
     TimeOfSteady = time;
     LastAbsoluteTransformation = Matrix.Identity;
 }
コード例 #47
0
        protected override void OnChildRemoving(SceneNode child)
        {
            base.OnChildRemoving(child);
            TimelineSceneNode timeline = child as TimelineSceneNode;

            if (this.ViewModel.AnimationProxyManager != null && AnimationProxyManager.IsAnimationProxy(timeline))
            {
                this.ViewModel.AnimationProxyManager.UpdateOnDeletion(child as KeyFrameAnimationSceneNode);
            }
            VisualStateSceneNode controllingState = this.ControllingState;

            if (controllingState == null)
            {
                return;
            }
            TimelineSceneNode.PropertyNodePair propertyNodePair = timeline != null ? timeline.TargetElementAndProperty : new TimelineSceneNode.PropertyNodePair((SceneNode)null, (PropertyReference)null);
            VisualStateGroupSceneNode          stateGroup       = controllingState.StateGroup;

            if (propertyNodePair.SceneNode == null || propertyNodePair.PropertyReference == null || (!timeline.ShouldSerialize || stateGroup == null))
            {
                return;
            }
            List <KeyValuePair <VisualStateSceneNode, bool> > list = new List <KeyValuePair <VisualStateSceneNode, bool> >(stateGroup.States.Count);

            list.Add(new KeyValuePair <VisualStateSceneNode, bool>(controllingState, true));
            foreach (VisualStateTransitionSceneNode transitionSceneNode in (IEnumerable <VisualStateTransitionSceneNode>)stateGroup.Transitions)
            {
                if (transitionSceneNode.Storyboard != null && (!string.IsNullOrEmpty(transitionSceneNode.FromStateName) || !string.IsNullOrEmpty(transitionSceneNode.ToStateName)))
                {
                    VisualStateSceneNode fromState = transitionSceneNode.FromState;
                    VisualStateSceneNode toState   = transitionSceneNode.ToState;
                    if (fromState == controllingState || toState == controllingState)
                    {
                        TimelineSceneNode timelineSceneNode = (TimelineSceneNode)transitionSceneNode.Storyboard.GetAnimation(propertyNodePair.SceneNode, propertyNodePair.PropertyReference);
                        if (timelineSceneNode != null)
                        {
                            VisualStateSceneNode key = fromState == controllingState ? toState : fromState;
                            bool?nullable            = new bool?();
                            if (key == null)
                            {
                                nullable = new bool?(false);
                            }
                            if (!nullable.HasValue)
                            {
                                foreach (KeyValuePair <VisualStateSceneNode, bool> keyValuePair in list)
                                {
                                    if (keyValuePair.Key == key)
                                    {
                                        nullable = new bool?(keyValuePair.Value);
                                    }
                                }
                            }
                            if (!nullable.HasValue)
                            {
                                nullable = new bool?(key.Storyboard != null && key.Storyboard.GetAnimation(propertyNodePair.SceneNode, propertyNodePair.PropertyReference) != null);
                                list.Add(new KeyValuePair <VisualStateSceneNode, bool>(key, nullable.Value));
                            }
                            if (!nullable.Value)
                            {
                                transitionSceneNode.Storyboard.Children.Remove(timelineSceneNode);
                            }
                        }
                    }
                }
            }
        }
コード例 #48
0
        static void Main()
        {
            // setup Irrlicht

            device = IrrlichtDevice.CreateDevice(DriverType.OpenGL, new Dimension2Di(1024, 768), 32, false, true);
            if (device == null)
            {
                return;
            }

            device.SetWindowCaption("Stencil Shadows - Irrlicht Engine");
            device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent);

            VideoDriver  driver = device.VideoDriver;
            SceneManager scene  = device.SceneManager;

            GUIFont statsFont = device.GUIEnvironment.GetFont("../../media/fontlucida.png");

            cameraNode          = scene.AddCameraSceneNodeFPS();
            cameraNode.FarValue = 20000;

            device.CursorControl.Visible = false;

            // setup shadows

            shadows = new Shadows(new Color(0xa0000000), 4000);

            // load quake level

            device.FileSystem.AddFileArchive("../../media/map-20kdm2.pk3");

            Mesh          m = scene.GetMesh("20kdm2.bsp").GetMesh(0);
            MeshSceneNode n = scene.AddOctreeSceneNode(m, null, -1, 1024);

            n.Position     = new Vector3Df(-1300, -144, -1249);
            quakeLevelNode = n;

            // add faerie

            faerieNode = scene.AddAnimatedMeshSceneNode(
                scene.GetMesh("../../media/faerie.md2"),
                null, -1,
                new Vector3Df(100, -40, 80),
                new Vector3Df(0, 30, 0),
                new Vector3Df(1.6f));

            faerieNode.SetMD2Animation(AnimationTypeMD2.Wave);
            faerieNode.AnimationSpeed = 20;
            faerieNode.GetMaterial(0).SetTexture(0, driver.GetTexture("../../media/faerie2.bmp"));
            faerieNode.GetMaterial(0).Lighting         = false;
            faerieNode.GetMaterial(0).NormalizeNormals = true;

            shadows.AddObject(faerieNode);

            // add light

            lightMovementHelperNode = scene.AddEmptySceneNode();

            n = scene.AddSphereSceneNode(2, 6, lightMovementHelperNode, -1, new Vector3Df(15, -10, 15));
            n.SetMaterialFlag(MaterialFlag.Lighting, false);

            lightNode = n;
            shadows.AddLight(lightNode);

            // add flashlight

            m = scene.GetMesh("../../media/flashlight.obj");
            n = scene.AddMeshSceneNode(m, lightNode, -1, new Vector3Df(0), new Vector3Df(0), new Vector3Df(5));
            n.SetMaterialFlag(MaterialFlag.Lighting, false);

            flashlightNode         = n;
            flashlightNode.Visible = false;

            // render

            uint shdFrameTime = 0;
            uint shdFrames    = 0;
            uint shdFps       = 0;

            while (device.Run())
            {
                if (useShadowsRebuilding &&
                    shadows.BuildShadowVolume())
                {
                    shdFrames++;
                }

                uint t = device.Timer.Time;
                if (t - shdFrameTime > 1000)
                {
                    shdFrameTime = t;
                    shdFps       = shdFrames;
                    shdFrames    = 0;
                }

                if (useLightBinding)
                {
                    lightMovementHelperNode.Position = cameraNode.AbsolutePosition.GetInterpolated(lightMovementHelperNode.Position, 0.1);
                    lightMovementHelperNode.Rotation = cameraNode.AbsoluteTransformation.Rotation;
                }

                driver.BeginScene(ClearBufferFlag.All, new Color(0xff112244));

                scene.DrawAll();

                if (useShadowsRendering)
                {
                    shadows.DrawShadowVolume(driver);
                }

                // display stats

                driver.Draw2DRectangle(new Recti(10, 10, 150, 220), new Color(0x7f000000));

                Vector2Di v = new Vector2Di(20, 20);
                statsFont.Draw("Rendering", v, Color.SolidYellow);
                v.Y += 16;
                statsFont.Draw(driver.FPS + " fps", v, Color.SolidWhite);
                v.Y += 16;
                statsFont.Draw("[S]hadows " + (useShadowsRendering ? "ON" : "OFF"), v, Color.SolidGreen);
                v.Y += 16;
                statsFont.Draw("[L]ight binding " + (useLightBinding ? "ON" : "OFF"), v, Color.SolidGreen);
                v.Y += 16;
                statsFont.Draw("[F]lashlight " + (useFlashlight ? "ON" : "OFF"), v, Color.SolidGreen);
                v.Y += 32;
                statsFont.Draw("Shadows", v, Color.SolidYellow);
                v.Y += 16;
                statsFont.Draw(shdFps + " fps", v, Color.SolidWhite);
                v.Y += 16;
                statsFont.Draw(shadows.VerticesBuilt + " vertices", v, Color.SolidWhite);
                v.Y += 16;
                statsFont.Draw("[R]ebuilding " + (useShadowsRebuilding ? "ON" : "OFF"), v, Color.SolidGreen);
                v.Y += 16;
                statsFont.Draw("[Q]uake level " + (useShadowsQuakeLevel ? "ON" : "OFF"), v, Color.SolidGreen);

                driver.EndScene();
            }

            shadows.Drop();
            device.Drop();
        }
コード例 #49
0
 public AnimationSceneNode GetAnimation(SceneNode targetElement, IPropertyId targetProperty)
 {
     return(this.GetAnimation(targetElement, new PropertyReference(this.ProjectContext.ResolveProperty(targetProperty) as ReferenceStep)));
 }
コード例 #50
0
        public INF1(Scene scene, JNT1 skeleton)
        {
            FlatNodes = new List <SceneNode>();
            Root      = new SceneNode(NodeType.Joint, 0, null);
            FlatNodes.Add(Root);

            int downNodeCount = 0;

            // First add objects that should be the direct children of the root bone.
            // This includes any objects that are weighted to multiple bones, as well as objects weighted to only the root bone itself.
            for (int mat_index = 0; mat_index < scene.MaterialCount; mat_index++)
            {
                Console.Write(".");
                for (int i = 0; i < scene.MeshCount; i++)
                {
                    if (scene.Meshes[i].MaterialIndex != mat_index)
                    {
                        continue;
                    }
                    if (scene.Meshes[i].BoneCount == 1 && scene.Meshes[i].Bones[0].Name != skeleton.FlatSkeleton[0].Name)
                    {
                        continue;
                    }

                    SceneNode downNode1 = new SceneNode(NodeType.OpenChild, 0, Root);
                    SceneNode matNode   = new SceneNode(NodeType.Material, i, Root);
                    SceneNode downNode2 = new SceneNode(NodeType.OpenChild, 0, Root);
                    SceneNode shapeNode = new SceneNode(NodeType.Shape, i, Root);

                    FlatNodes.Add(downNode1);
                    FlatNodes.Add(matNode);
                    FlatNodes.Add(downNode2);
                    FlatNodes.Add(shapeNode);

                    downNodeCount += 2;
                }
            }

            // Next add objects as children of specific bones, if those objects are weighted to only a single bone.
            if (skeleton.FlatSkeleton.Count > 1)
            {
                SceneNode rootChildDown = new SceneNode(NodeType.OpenChild, 0, Root);
                FlatNodes.Add(rootChildDown);

                foreach (Rigging.Bone bone in skeleton.SkeletonRoot.Children)
                {
                    GetNodesRecursive(bone, skeleton.FlatSkeleton, Root, scene.Meshes, scene.Materials);
                }

                SceneNode rootChildUp = new SceneNode(NodeType.CloseChild, 0, Root);
                FlatNodes.Add(rootChildUp);
            }

            for (int i = 0; i < downNodeCount; i++)
            {
                FlatNodes.Add(new SceneNode(NodeType.CloseChild, 0, Root));
            }

            FlatNodes.Add(new SceneNode(NodeType.Terminator, 0, Root));
            Console.WriteLine("✓");
        }
コード例 #51
0
 public INF1()
 {
     FlatNodes = new List <SceneNode>();
     Root      = null;
 }
コード例 #52
0
ファイル: OceanTileView.cs プロジェクト: wof2/Wings-Of-Fury-2
        /// <summary>
        ///
        /// </summary>
        /// <param name="parentNode"></param>
        /// <param name="tileCMVIndex"></param>
        /// <param name="compositeModelTilesNumber"></param>
        public override void initOnScene(SceneNode parentNode, int tileCMVIndex, int compositeModelTilesNumber)
        {
            base.initOnScene(parentNode, tileCMVIndex, compositeModelTilesNumber);

            /*base.initOnScene(parentNode, tileCMVIndex, compositeModelTilesNumber);
             * String nameSuffix = tileID.ToString();
             *
             * float positionOnIsland = -getRelativePosition(parentNode, LevelTile);*/

            /*if (levelTile is BarrelTile)
             * {
             *  installationNode =
             *      parentNode.CreateChildSceneNode("Barrels" + nameSuffix, new Vector3(0, 0.1f, positionOnIsland - 5.0f));
             */

            float test = getRelativePosition(parentNode, LevelTile);

            if (LevelTile is OceanTile)
            {
                int variant = LevelTile.Variant;
                if (variant >= 0)
                {
                    //installationNode = parentNode.CreateChildSceneNode("OceanNode" + tileID, new Vector3(-getRelativePosition(parentNode, LevelTile), 0, 0));
                    installationNode = parentNode.CreateChildSceneNode("OceanNode" + tileID, new Vector3(getRelativePosition(parentNode, LevelTile) + 5.0f, 0, 0));
                }

                switch (variant)
                {
                case 0:
                    break;

                case 1:
                    initRocks(new Vector3(0, 0, 0));
                    break;

                case 2:
                    initRocks(new Vector3(0, 0, Mogre.Math.RangeRandom(-100, 100)));
                    break;

                case 3:
                    initBigRocks(new Vector3(0, 0, 0));
                    break;

                case 4:
                    initBigRocks(new Vector3(0, 0, Mogre.Math.RangeRandom(-100, 100)));
                    break;

                case 5:
                    initBarrels(new Vector3(0, 0, Mogre.Math.RangeRandom(-3, 3)), 2);
                    break;

                case 6:
                    initSmallIsland(new Vector3(0, -3, Mogre.Math.RangeRandom(-20, 20)), "Island1.mesh");
                    break;

                case 7:
                    initSmallIsland(new Vector3(0, -3, Mogre.Math.RangeRandom(-20, 20)), "Island3.mesh");
                    break;

                case 8:
                    initSmallIsland(new Vector3(0, -3, Mogre.Math.RangeRandom(-20, 20)), "Island4.mesh");
                    break;
                }
            }
        }
コード例 #53
0
        private void GetNodesRecursive(Rigging.Bone bone, List <Rigging.Bone> skeleton, SceneNode parent)
        {
            SceneNode node = new SceneNode(NodeType.Joint, skeleton.IndexOf(bone), parent);

            FlatNodes.Add(node);

            foreach (Rigging.Bone child in bone.Children)
            {
                SceneNode downNode = new SceneNode(NodeType.OpenChild, 0, parent);
                FlatNodes.Add(downNode);

                GetNodesRecursive(child, skeleton, node);

                SceneNode upNode = new SceneNode(NodeType.CloseChild, 0, parent);
                FlatNodes.Add(upNode);
            }
        }
コード例 #54
0
 public SceneNodeModelPropertyCollection(SceneNode sceneNode)
 {
     this.sceneNode  = sceneNode;
     this.properties = this.sceneNode.GetProperties();
 }
コード例 #55
0
        public void FillScene(Scene scene, List <Rigging.Bone> flatSkeleton, bool useSkeletonRoot)
        {
            Node root = scene.RootNode;

            if (useSkeletonRoot)
            {
                root = new Node("skeleton_root");
            }

            SceneNode curRoot  = Root;
            SceneNode lastNode = Root;

            Node curAssRoot  = new Node(flatSkeleton[0].Name, root);
            Node lastAssNode = curAssRoot;

            root.Children.Add(curAssRoot);

            for (int i = 1; i < FlatNodes.Count; i++)
            {
                SceneNode curNode = FlatNodes[i];

                if (curNode.Type == NodeType.OpenChild)
                {
                    curRoot    = lastNode;
                    curAssRoot = lastAssNode;
                }
                else if (curNode.Type == NodeType.CloseChild)
                {
                    curRoot    = curRoot.Parent;
                    curAssRoot = curAssRoot.Parent;
                }
                else if (curNode.Type == NodeType.Joint)
                {
                    Node assCurNode = new Node(flatSkeleton[curNode.Index].Name, curAssRoot);
                    assCurNode.Transform = flatSkeleton[curNode.Index].TransformationMatrix.ToMatrix4x4();
                    curAssRoot.Children.Add(assCurNode);

                    lastNode    = curNode;
                    lastAssNode = assCurNode;
                }
                else if (curNode.Type == NodeType.Terminator)
                {
                    break;
                }
                else
                {
                    Node assCurNode = new Node($"delete", curAssRoot);
                    curAssRoot.Children.Add(assCurNode);

                    lastNode    = curNode;
                    lastAssNode = assCurNode;
                }
                Console.Write(".");
            }

            DeleteNodesRecursive(root);

            if (useSkeletonRoot)
            {
                scene.RootNode.Children.Add(root);
            }
            Console.Write("✓");
        }
コード例 #56
0
 protected override void AssignDefaultValuesToSceneNode(SceneNode core)
 {
     base.AssignDefaultValuesToSceneNode(core);
     (core as CustomMeshNode).HeightScale = (float)HeightScale;
 }
コード例 #57
0
        protected void EnsureObjectsCreated()
        {
            ClearCreatedObjects();
            Texture prototypeTexture = null;

            if (useTextures)
            {
                prototypeMaterial = MaterialManager.Instance.Load("barrel.barrel");
                if (uniqueTextures)
                {
                    prototypeTexture = TextureManager.Instance.Load("blank.dds");
                }
            }
            else
            {
                prototypeMaterial = MaterialManager.Instance.Load("unit_box.unit_box");
            }
            prototypeMaterial.Compile();
            if (objectCount == 0)
            {
                return;
            }
            int materialCount = (animatedObjects ? 0 :
                                 (numObjectsSharingMaterial == 0 ? objectCount :
                                  (numObjectsSharingMaterial >= objectCount ? 1 :
                                   (objectCount + numObjectsSharingMaterial - 1) / numObjectsSharingMaterial)));

            materialCountLabel.Text = "Material Count: " + materialCount;
            if (whichObjects == WhichObjectsEnum.woPlane || whichObjects == WhichObjectsEnum.woRandom)
            {
                Mesh plane = meshes[(int)WhichObjectsEnum.woPlane];
                if (plane != null)
                {
                    plane.Unload();
                }
                // Create the plane
                float planeSide  = 1000f;
                int   planeUnits = Int32.Parse(planeUnitsTextBox.Text);
                plane = MeshManager.Instance.CreatePlane("testerPlane", new Plane(Vector3.UnitZ, Vector3.Zero), planeSide, planeSide, planeUnits, planeUnits, true,
                                                         1, planeSide / planeUnits, planeSide / planeUnits, Vector3.UnitY);
                meshes[(int)WhichObjectsEnum.woPlane] = plane;
            }
            // Create the new materials
            for (int i = 0; i < materialCount; i++)
            {
                Material mat = prototypeMaterial.Clone("mat" + i);
                Pass     p   = mat.GetTechnique(0).GetPass(0);
                if (!animatedObjects && uniqueTextures)
                {
                    Texture t       = prototypeTexture;
                    Texture texture = TextureManager.Instance.CreateManual("texture" + i, t.TextureType, t.Width, t.Height, t.NumMipMaps, t.Format, t.Usage);
                    textureList.Add(texture);
                    p.CreateTextureUnitState(texture.Name);
                }
                // Make the materials lovely shades of blue
                p.Ambient  = new ColorEx(1f, .2f, .2f, (1f / materialCount) * i);
                p.Diffuse  = new ColorEx(p.Ambient);
                p.Specular = new ColorEx(1f, 0f, 0f, 0f);
                materialList.Add(mat);
            }

            // Create the entities and scene nodes
            for (int i = 0; i < objectCount; i++)
            {
                Mesh     mesh = selectMesh();
                Material mat  = null;
                if (materialCount > 0)
                {
                    mat = materialList[i % materialCount];
                }
                Entity entity = scene.CreateEntity("entity" + i, mesh);
                if (animatedObjects)
                {
                    string[] visibleSubs = visibleSubMeshes[(int)whichObjects - (int)WhichObjectsEnum.woZombie];
                    for (int j = 0; j < entity.SubEntityCount; ++j)
                    {
                        SubEntity sub     = entity.GetSubEntity(j);
                        bool      visible = false;
                        foreach (string s in visibleSubs)
                        {
                            if (s == sub.SubMesh.Name)
                            {
                                visible = true;
                                break;
                            }
                        }
                        sub.IsVisible = visible;
                        if (visible)
                        {
                            totalVertexCount += sub.SubMesh.VertexData.vertexCount;
                        }
                    }
                }
                else
                {
                    if (mesh.SharedVertexData != null)
                    {
                        totalVertexCount += mesh.SharedVertexData.vertexCount;
                    }
                    else
                    {
                        for (int j = 0; j < mesh.SubMeshCount; j++)
                        {
                            SubMesh subMesh = mesh.GetSubMesh(j);
                            totalVertexCount += subMesh.VertexData.vertexCount;
                        }
                    }
                }
                if (animatedObjects && animateCheckBox.Checked)
                {
                    AnimationState currentAnimation = entity.GetAnimationState(GetAnimationName());
                    currentAnimation.IsEnabled = true;
                    if (!animationInitialized)
                    {
                        currentAnimationLength = entity.GetAnimationState(GetAnimationName()).Length;
                        animationInitialized   = true;
                    }
                }
                if (mat != null)
                {
                    entity.MaterialName = mat.Name;
                }
                entityList.Add(entity);
                SceneNode node = scene.RootSceneNode.CreateChildSceneNode();
                sceneNodeList.Add(node);
                node.AttachObject(entity);
                node.Position = new Vector3(randomCoord(), randomCoord(), randomCoord());
                if (randomSizes)
                {
                    node.ScaleFactor = Vector3.UnitScale * randomScale();
                }
                else if (randomScales)
                {
                    node.ScaleFactor = new Vector3(randomScale(), randomScale(), randomScale());
                }
                else
                {
                    node.ScaleFactor = Vector3.UnitScale * 1f;
                }
                if (randomOrientations)
                {
                    Vector3 axis = new Vector3((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble());
                    node.Orientation = Vector3.UnitY.GetRotationTo(axis.ToNormalized());
                }
                else
                {
                    node.Orientation = Quaternion.Identity;
                }
            }
        }
コード例 #58
0
ファイル: frmMain.cs プロジェクト: liberostelios/DPOW-Studio
        private SceneNode buildElement(DPOW.Reader.Element elem, string name)
        {
            if (mgr.HasSceneNode(name + "_node"))
            {
                return(mgr.GetSceneNode(name + "_node"));
            }

            SceneNode node = mgr.CreateSceneNode(name + "_node");

            node.SetPosition(elem.Position.X * 200, -elem.Position.Y * 200, -elem.Position.Z * 10);

            for (int i = 0; i < elem.Images.Length; i++)
            {
                string imgname = name + "_text" + i.ToString();

                SceneNode    textnode = node.CreateChildSceneNode(name + "_text" + i.ToString() + "_node", new Vector3(elem.Images[i].Position.X * 200, -elem.Images[i].Position.Y * 200, -elem.Images[i].Position.Z * 10));
                ManualObject manual   = mgr.CreateManualObject(name + "_text" + i.ToString());
                string       matname;
                matname = dpow.Textures[elem.Images[i].TextureId];
                // Build new material, if it's selected
                if (imgname == SelectedItem)
                {
                    matname = "Selected";
                }

                /*else
                 * {
                 *  MaterialPtr newmat = ((MaterialPtr)MaterialManager.Singleton.GetByName(matname, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)).Clone(imgname + "_mat");
                 *  matname = imgname + "_mat";
                 * }*/
                manual.Begin(matname, RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);

                for (int j = 0; j < elem.Images[i].Points.Length; j++)
                {
                    manual.Position(elem.Images[i].Points[j].X * 200, -elem.Images[i].Points[j].Y * 200, -elem.Images[i].Points[j].Z * 10);
                    manual.TextureCoord(elem.Images[i].Points[j].U, elem.Images[i].Points[j].V);
                    if (elem.Images[i].isGradient)
                    {
                        manual.Colour((float)elem.Images[i].Points[j].Color.R / 255, (float)elem.Images[i].Points[j].Color.G / 255, (float)elem.Images[i].Points[j].Color.B / 255, (float)elem.Images[i].Points[j].Color.A / 255);
                    }
                }

                manual.End();

                textnode.AttachObject(manual);
            }

            for (int i = 0; i < elem.Texts.Length; i++)
            {
                SceneNode strnode = node.CreateChildSceneNode(name + "_str" + i.ToString() + "_node", new Vector3(elem.Texts[i].Position.X * 200, -elem.Texts[i].Position.Y * 200, -elem.Texts[i].Position.Z * 10));

                ManualObject manual = mgr.CreateManualObject(name + "_str" + i.ToString());
                manual.Begin("String", RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);

                float left   = 0;
                float right  = elem.Texts[i].Size.X * 200;
                float bottom = -elem.Texts[i].Size.Y * 200.0f;
                float top    = 0;
                manual.Position(left, bottom, 0);
                manual.Position(right, bottom, 0);
                manual.Position(left, top, 0);
                manual.Position(right, top, 0);

                manual.End();

                strnode.AttachObject(manual);
            }

            for (int i = 0; i < elem.Icons.Length; i++)
            {
                SceneNode flagnode = node.CreateChildSceneNode(name + "_flag" + i.ToString() + "_node", new Vector3(elem.Icons[i].Position.X * 200, -elem.Icons[i].Position.Y * 200, -elem.Icons[i].Position.Z * 10));

                ManualObject manual = mgr.CreateManualObject(name + "_flag" + i.ToString());
                manual.Begin("Flag", RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);

                float left   = 0;
                float right  = elem.Icons[i].Size.X * 200;
                float bottom = -elem.Icons[i].Size.Y * 200.0f;
                float top    = 0;
                if (elem.Icons[i].WTF == 0)
                {
                    left   = -elem.Icons[i].Size.X / 2 * 200;
                    right  = elem.Icons[i].Size.X / 2 * 200;
                    bottom = -elem.Icons[i].Size.Y / 2 * 200.0f;
                    top    = elem.Icons[i].Size.Y / 2 * 200.0f;
                }
                manual.Position(left, bottom, 0);
                manual.Position(right, bottom, 0);
                manual.Position(left, top, 0);
                manual.Position(right, top, 0);

                manual.End();

                flagnode.AttachObject(manual);
            }

            return(node);
        }
コード例 #59
0
 public EnemyPlaneViewBase(Plane plane, IFrameWork frameWork, SceneNode parentNode, String name)
     : base(plane, frameWork, parentNode, name)
 {
 }
コード例 #60
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="force"></param>
        protected void RenderTextures(bool force)
        {
            Texture       renderTexture  = null;
            RenderTexture renderTarget   = null;
            Camera        renderCamera   = null;
            Viewport      renderViewport = null;
            //Set up RTT texture
            int textureSize = ImpostorPage.ImpostorResolution;

            if (renderTexture == null)
            {
                renderTexture = (Texture)TextureManager.Singleton.CreateManual(GetUniqueID("ImpostorTexture"), "Impostors",
                                                                               TextureType.TwoD, textureSize * ImpostorYawAngles, textureSize * ImpostorPitchAngles, 0,
                                                                               MogreLibMedia.PixelFormat.A8B8G8R8, TextureUsage.RenderTarget, mLoader);
            }

            renderTexture.MipmapCount = 0x7FFFFFFF;

            //Set up render target
            renderTarget = renderTexture.GetBuffer().GetRenderTarget();
            renderTarget.IsAutoUpdated = false;

            //Set up camera
            renderCamera                = mSceneMgr.CreateCamera(GetUniqueID("ImpostorCam"));
            renderCamera.LodBias        = 1000.0f;
            renderViewport              = renderTarget.AddViewport(renderCamera);
            renderViewport.ShowOverlays = false;
#warning why is set == protected?
            // renderViewport.ClearEveryFrame = true;
            renderViewport.ShowShadows     = false;
            renderViewport.BackgroundColor = ImpostorPage.ImpostorBackgroundColor;

            //Set up scene node
            SceneNode node = mSceneMgr.GetSceneNode("ImpostorPage.RenderNode");

            SceneNode oldSceneNode = mEntity.ParentSceneNode;
            if (oldSceneNode != null)
            {
                oldSceneNode.DetachObject(mEntity);
            }

            node.AttachObject(mEntity);
            node.Position = -mEntityCenter;

            //Set up camera FOV
            float objectDist = mEntityRadius * 100;
            float nearDist   = objectDist - (mEntityRadius + 1);
            float farDist    = objectDist + (mEntityRadius + 1);

            renderCamera.AspectRatio = 1.0f;
            renderCamera.FieldOfView = (float)MogreLibMath.Utility.ATan(mEntityDiameter / objectDist);
            renderCamera.Near        = nearDist;
            renderCamera.Far         = farDist;

            //Disable mipmapping (without this, masked textures look bad)
            MaterialManager mm           = MaterialManager.Instance;
            FilterOptions   oldMinFilter = mm.GetDefaultTextureFiltering(FilterType.Min);
            FilterOptions   oldMagFilter = mm.GetDefaultTextureFiltering(FilterType.Mag);
            FilterOptions   oldMipFilter = mm.GetDefaultTextureFiltering(FilterType.Mip);
            mm.SetDefaultTextureFiltering(FilterOptions.Point, FilterOptions.Linear, FilterOptions.None);

            //Disable fog
            FogMode oldFogMode    = mSceneMgr.FogMode;
            ColorEx oldFogColor   = mSceneMgr.FogColor;
            float   oldFogDensity = mSceneMgr.FogDensity;
            float   oldFogStart   = mSceneMgr.FogStart;
            float   oldFogEnd     = mSceneMgr.FogEnd;
            mSceneMgr.FogMode = FogMode.None;

            // Get current status of the queue mode
            SpecialCaseRenderQueueMode oldSpecialCaseRenderQueueMode = mSceneMgr.SpecialCaseRenderQueueList.RenderQueueMode;

            //Only render the entity
            mSceneMgr.SpecialCaseRenderQueueList.RenderQueueMode = SpecialCaseRenderQueueMode.Include;
            mSceneMgr.SpecialCaseRenderQueueList.AddRenderQueue(RenderQueueGroupID.Six + 1);

            RenderQueueGroupID oldRenderGroup = mEntity.RenderQueueGroup;
            mEntity.RenderQueueGroup = RenderQueueGroupID.Six + 1;
            bool oldVisible = mEntity.IsVisible;
            mEntity.IsVisible = true;
#warning implement float oldMaxDistance = entity->getRenderingDistance();
#warning implement entity->setRenderingDistance(0);

            bool needsRegen = true;
            //Calculate the filename used to uniquely identity this render
            string strKey = mEntityKey;
            char[] key    = new char[32];
            int    i      = 0;
            foreach (char c in mEntityKey)
            {
                key[i] ^= c;
                i       = (i + 1) % key.Length;
            }
            for (i = 0; i < key.Length; i++)
            {
                key[i] = (char)((key[i] % 26) + 'A');
            }

            ResourceGroupManager.Instance.AddResourceLocation(".", "Folder", "BinFolder");
            string keyStr = string.Empty;
            foreach (char c in key)
            {
                keyStr += c.ToString();
            }
            string fileName = "Impostor." + keyStr + "." + textureSize + ".png";
            //Attempt to load the pre-render file if allowed
            needsRegen = force;
            if (!needsRegen)
            {
                try
                {
                    mTexture = (Texture)TextureManager.Singleton.Load(fileName, "BinFolder", TextureType.TwoD, 0x7FFFFFFF);
                }
                catch
                {
                    needsRegen = true;
                }
            }

            if (needsRegen)
            {
                //If this has not been pre-rendered, do so now
                float xDivFactor = 1.0f / ImpostorYawAngles;
                float yDivFactor = 1.0f / ImpostorPitchAngles;
                for (int o = 0; o < ImpostorPitchAngles; o++)                                //4 pitch angle renders
                {
                    Radian pitch = (Radian) new Degree((Real)((90.0f * o) * yDivFactor));    //0, 22.5, 45, 67.5
                    for (i = 0; i < ImpostorYawAngles; i++)                                  //8 yaw angle renders
                    {
                        Radian yaw = (Radian) new Degree((Real)((360.0f * i) * xDivFactor)); //0, 45, 90, 135, 180, 225, 270, 315

                        //Position camera
                        renderCamera.Position    = new Vector3(0, 0, 0);
                        renderCamera.Orientation = Quaternion.Identity;
                        renderCamera.Pitch((float)-pitch);
                        renderCamera.Yaw((float)yaw);
                        renderCamera.MoveRelative(new Vector3(0, 0, objectDist));

                        //Render the impostor
                        renderViewport.SetDimensions((float)(i * xDivFactor), (float)(o * yDivFactor), xDivFactor, yDivFactor);
                        renderTarget.Update();
                    }
                }

                //Save RTT to file
                renderTarget.WriteContentsToFile(fileName);

                //Load the render into the appropriate texture view
                mTexture = (Texture)TextureManager.Singleton.Load(fileName, "BinFolder", TextureType.TwoD, 0x7FFFFFFF);
            }

            mEntity.IsVisible        = oldVisible;
            mEntity.RenderQueueGroup = oldRenderGroup;
#warning entity->setRenderingDistance(oldMaxDistance);
            mSceneMgr.SpecialCaseRenderQueueList.RemoveRenderQueue(RenderQueueGroupID.Six + 1);
            // Restore original state
            mSceneMgr.SpecialCaseRenderQueueList.RenderQueueMode = oldSpecialCaseRenderQueueMode;

            //Re-enable mipmapping
            mm.SetDefaultTextureFiltering(oldMinFilter, oldMagFilter, oldMipFilter);

            //Re-enable fog
            mSceneMgr.SetFog(oldFogMode, oldFogColor, oldFogDensity, oldFogStart, oldFogEnd);

            //Delete camera
            renderTarget.RemoveViewport(0);
            renderCamera.SceneManager.DestroyCamera(renderCamera);

            //Delete scene node
            node.DetachAllObjects();
            if (oldSceneNode != null)
            {
                oldSceneNode.AttachObject(mEntity);
            }


            //Delete RTT texture
            Debug.Assert(renderTexture != null);
            string texName2 = renderTexture.Name;

            renderTexture = null;
            if (TextureManager.Singleton != null)
            {
                TextureManager.Singleton.Remove(texName2);
            }
        }