public BasketballScene()
        {
            reset = false;

            Song bgm = Cloud.content.Load <Song>("Thats a Wrap");

            MediaPlayer.Play(bgm);
            MediaPlayer.IsRepeating = true;

            sw.Start();

            renderables        = new RenderableCollection();
            Physics.collisions = new CollisionHandler(renderables);

            toAdd    = new List <Renderable>();
            toRemove = new List <Renderable>();

            Ball = new ball(new Vector2(120, 150), this);
            renderables.Add(Ball);

            TextureStatic.Load("hoopA", @"Art");
            TextureStatic.Load("hoopB", @"Art");
            TextureStatic.Load("courtBG", @"Art");
            TextureStatic.Load("net", @"Art");
            TextureStatic.Load("net2", @"Art");
            //courtbg = new Background("court", @"Art\Backgrounds", new Vector2(-360, 110), new Vector2(-10, 0), 0.11f, true, this);
            //renderables.Add(courtbg);

            //tentacle tn = new tentacle(new Vector2(0, 0), this);
            //renderables.Add(tn);
        }
示例#2
0
 public RenderCommand(Renderer renderer, IMaterial material, RenderableCollection sceneNodeCollection)
     : base(CommandType.Render)
 {
     Contract.Requires<NullReferenceException>(renderer != null);
     Contract.Requires<NullReferenceException>(material != null);
     CommandAttributes |= CommandAttributes.MonoRendering;
     Renderer = renderer;
     Items = sceneNodeCollection;
     Material = material;
     Technique = Material.EffectDescription.Technique;
     Pass = Technique.GetPassByIndex(Material.EffectDescription.Pass);
     InputLayout = new InputLayout(Game.Context.Device, Pass.Description.Signature, Items.Description.InputElements);
 }
示例#3
0
        public override void Init()
        {
            TexturedPolygon quad = TexturedPolygon.CreateTexturedQuad("ScreenQuad", Vector3.Zero, 1920, 1080);
            ImageLoadInformation info = new ImageLoadInformation()
            {
                BindFlags = BindFlags.None,
                CpuAccessFlags = CpuAccessFlags.Read,
                FilterFlags = FilterFlags.None,
                Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm,
                MipFilterFlags = FilterFlags.None,
                OptionFlags = ResourceOptionFlags.None,
                Usage = ResourceUsage.Staging,
                MipLevels = 1
            };
            Texture2D tex = Texture2D.FromFile(Game.Context.Device, "medusa.jpg",  info);

            ShaderResourceView srv = new ShaderResourceView(Game.Context.Device,  Make3D(tex));
            quad.DiffuseMapResource = srv;
            rNode = new RenderableNode(quad);
            iMat = new ImageMaterial();
            FixedNode fNode = new FixedNode();
            fNode.Init();
            quad.PositionV3 = Layout.OrthographicTransform(Vector2.Zero, 100, new Size(1920,1080));

            RenderableCollection rCol = new RenderableCollection(iMat.RenderableCollectionDescription);
            MaterialNode mMat = new MaterialNode(iMat);
            rCol.Add(rNode);

            fNode.AppendChild(mMat);
            mMat.AppendChild(rNode);

            rCommand = new RenderCommand(mMat, rCol);
            rCommand.Init();
            DeviceContext.Immediate.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            Scene.Tree.RootNode.AppendChild(fNode);
            Scene.BuildRenderScene();
        }
        public TriviaScene()
        {
            Song bgm = Cloud.content.Load <Song>("MilitaireElectronic");

            MediaPlayer.Play(bgm);
            MediaPlayer.IsRepeating = true;

            Camera2D.cam.Zoom = .5f;
            animator          = new BoneAnimator(null, StaticStanceplayer.GetBoneSet(), StaticStanceplayer.Get(playerStance.Idle), 0, 0);
            animator.Depth    = .6f;
            //animator.SetAnimation(StaticStanceplayer.GetAnimation(playerAnimation.Idle));
            animator.Update();


            animator2       = new BoneAnimator(null, StaticStanceplayer2.GetBoneSet(), StaticStanceplayer2.Get(player2Stance.Idle), 0, 0);
            animator2.Depth = .6f;
            //animator2.SetAnimation(StaticStanceplayer2.GetAnimation(player2Animation.Idle));
            animator2.Update();


            answers.Clear();
            tr = new StreamReader("../../trivia.txt");

            renderables        = new RenderableCollection();
            Physics.collisions = new CollisionHandler(renderables);

            toAdd    = new List <Renderable>();
            toRemove = new List <Renderable>();

            TextureStatic.Load("questionBG", @"Art");
            TextureStatic.Load("playerAnswerBG", @"Art");
            TextureStatic.Load("unknown", @"Art");
            TextureStatic.Load("pod", @"Art");


            //Ball = new ball(new Vector2(120, 150), this);
            //renderables.Add(Ball);
        }
示例#5
0
        private Node BuildSubTree(RenderableCollection primitives, int start, int end)
        {
            if (start - end == 0)
                return null;
            AABB bound = primitives.GetRange(start, end - start).Select(prim => prim.WorldBound(sceneVertices)).Aggregate((b1, b2) => b1.Union(b2));
            var node = new Node() { Bound = bound, SplitAxis = (Axis)bound.MaximumExtent() };
            bvhNodesCount++;
            if ((end - start) <= PrimitivesInNode)
            {
                node.StartOffset = start;
                node.nPrims = end - start;
                //node.Primitives = primitives.GetRange(start, (end - start));
                return node;
            }


            //float pmid;
            int axis = bound.MaximumExtent();
            Comparison<Triangle> tc = (t1, t2) => CompareTriangles(t1, t2, (Axis)bound.MaximumExtent());

            primitives.PartialSort(tc, start, end);

            //FindBestSplit(primitives, start, end, out pmid, out axis);



            //var pmid = .5f * (bound.Min[axis] + bound.Max[axis]);
            //FindBestSplit(primitives.GetRange(start, end-start), start, end, out pmid, out axis);
            //var cmp = new MidComparer() { dim = axis, pMid = pmid, vertices = sceneVertices};
            node.SplitAxis = (Axis)axis;

            var mid =
                //start+Algorithms.Partition(primitives.GetRange(start, end - start), cmp.Compare);
                (start + end) / 2;
            node.Left = this.BuildSubTree(primitives, start, mid);
            node.Right = this.BuildSubTree(primitives, mid, end);
            return node;
        }
示例#6
0
 public void AddRenderCommand(IMaterial material, RenderableCollection rNodeCollection)
 {
     Type renderCommandType = rNodeCollection.Description.PreferredRenderCommandType;
     RenderCommand rCommand = (RenderCommand)Activator.CreateInstance(renderCommandType, new object[] {material, rNodeCollection});
     rCommand.Init();
     commandList.AddLast(rCommand);
 }
 public CollisionHandler(RenderableCollection collection)
 {
     renderables = collection;
 }
        public GameScene()
        {
            sky   = Color.FromNonPremultiplied(78, 142, 203, 255);
            grass = Color.FromNonPremultiplied(45, 179, 75, 255);

            isDead = false;
            string dir = "BonePix";

            TextureStatic.Load("tentacle_tip_1", dir);
            TextureStatic.Load("tentacle_2", dir);
            TextureStatic.Load("tentacle_3", dir);
            TextureStatic.Load("tentacle_4", dir);
            TextureStatic.Load("tentacle_5", dir);
            TextureStatic.Load("tentacle_base", dir);

            animator       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Idle), 0, 0);
            animator.Depth = .6f;

            animator2       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Walk1), 0, 0);
            animator2.Depth = .7f;

            animator3       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Walk4), 0, 0);
            animator3.Depth = .7f;

            animator4       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Walk4), 0, 0);
            animator4.Depth = .6f;

            animator5       = new BoneAnimator(null, StaticStancetentacle.GetBoneSet(), StaticStancetentacle.Get(tentacleStance.Walk4), 0, 0);
            animator5.Depth = .7f;

            roadHeight         = 200;
            counter            = 0;
            worldSpeed         = -10;
            particleTimer      = 0;
            edgeLine           = -250;
            renderables        = new RenderableCollection();
            Physics.collisions = new CollisionHandler(renderables);

            toAdd    = new List <Renderable>();
            toRemove = new List <Renderable>();

            player = new Player(new Vector2(120, 150), this);
            renderables.Add(player);

            mainbg = new Background("road_railing", @"Art\Backgrounds", new Vector2(-360, 60), new Vector2(-10, 0), 0.15f, true, this);
            renderables.Add(mainbg);
            farbg = new Background("far_bg", @"Art\Backgrounds", new Vector2(-360, -370), new Vector2(-10, 0), 0.1f, true, this);
            renderables.Add(farbg);
            midbg = new Background("middle_bg", @"Art\Backgrounds", new Vector2(-360, -340), new Vector2(-10, 0), 0.12f, true, this);
            renderables.Add(midbg);
            forebg = new Background("foreground_railing", @"Art\Backgrounds", new Vector2(-360, 290), new Vector2(-10, 0), 0.999f, true, this);
            renderables.Add(forebg);
            roadbg = new Background("road", @"Art\Backgrounds", new Vector2(-360, 110), new Vector2(-10, 0), 0.11f, true, this);
            renderables.Add(roadbg);

            /*voidbg = new Background("void", @"Art", new Vector2(-360, -202), Vector2.Zero, 0.2f, false, this);
             * renderables.Add(voidbg);*/
            TextureStatic.Load("void", "Art");

            //tentacle tn = new tentacle(new Vector2(0, 0), this);
            //renderables.Add(tn);

            vanSpeed   = 0;
            voidLine   = -360;
            oscillator = 0;

            animator.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Idle));
            animator.Update();
            animator2.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk));
            animator2.Update();
            animator3.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk2));
            animator3.Update();
            animator4.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk3));
            animator4.Update();
            animator5.SetAnimation(StaticStancetentacle.GetAnimation(tentacleAnimation.Walk4));
            animator5.Update();
        }
示例#9
0
 public RenderCommand(IMaterial material, RenderableCollection sceneNodeCollection)
     : this(Game.CurrentRenderer, material, sceneNodeCollection)
 {
 }
示例#10
0
 public void Activate()
 {
     text = new TextLiteral(FrameStats, new Vector3(10, 10, 0));
     FunctionalMaterial textWriter = new FunctionalMaterial();
     MaterialNode mNode = new MaterialNode("Logger", textWriter);
     RenderableNode rNode = new RenderableNode(text);
     mNode.AppendChild(rNode);
     RenderableCollection rCollection = new RenderableCollection(textWriter.RenderableCollectionDescription)
                                            {rNode};
     //RenderCommand rCommand = new RenderCommand(mNode, rCollection);
     Game.CurrentRenderer.Scene.Tree.RootNode.AppendChild(mNode);
 }
 void UpdateSprites(IEnumerable<ISpriteObject> spriteControls)
 {
     TextItems = new RenderableCollection(TextMaterial.ItemsDescription);
     tNode.RemoveAll();
     tNode.AppendChild(rNode);
     foreach (ISpriteObject spriteControl in spriteControls)
     {
         RenderableNode textNode = new RenderableNode(spriteControl.RenderableObject);
         tNode.AppendChild(textNode);
         TextItems.Add(textNode);
         textNode.Update();
     }
 }