示例#1
0
 public async Task SendDraw(DrawDetails drawDetails)
 {
     if (UserIsDrawing && Lobby.State == LobbyState.Drawing)
     {
         await _hubConnection.SendAsync("SendDraw", drawDetails);
     }
 }
示例#2
0
        //  Draw helper that actually issues geometry, or defers for later.
        internal bool Draw(DrawDetails dd, bool asDeferred, uint mask)
        {
            //  keep a copy of world, because I override it in the DrawDetails
            bool added = false;

            //  each chunk is drawn separately, as it represents a different
            //  shader set-up (world transform, texture, etc).
            foreach (Chunk ch in chunks_)
            {
//        if ((ch.Bitmask & mask) == 0)
//          continue;
                if (asDeferred)
                {
                    //  If I'm called back to draw deferred pieces, don't draw if this
                    //  piece is not deferred.
                    if (!ch.Deferred)
                    {
                        continue;
                    }
                }
                else if (ch.Deferred)
                {
                    added = true;
                    continue;
                }
                DrawChunk(dd, ch);
            }
            return(added);
        }
示例#3
0
        public async Task SendDraw(DrawDetails drawDetails)
        {
            var lobby  = _lobbiesManager.GetLobbyByPlayerConnectionId(Context.ConnectionId);
            var player = lobby.GetPlayerByConnectionId(Context.ConnectionId);

            if (lobby.GetDrawingPlayer() == player && lobby.State == LobbyState.Drawing)
            {
                await Clients.OthersInGroup(lobby.Id).SendAsync("GetDraw", drawDetails);
            }
        }
示例#4
0
        //  do the device and effect magic to render a given chunk of geometry
        private void DrawChunk(DrawDetails dd, Chunk ch)
        {
            //  configure the device and actually draw
            dd.dev.Indices           = ch.Mesh.IndexBuffer;
            dd.dev.VertexDeclaration = ch.Part.VertexDeclaration;
            dd.dev.Vertices[0].SetSource(ch.Mesh.VertexBuffer, ch.Part.StreamOffset, ch.Part.VertexStride);
            //  note: calculating the world matrix overrides the previous value, hence the use
            //  of the saved copy of the world transform
            Matrix.Multiply(ref matrices_[ch.Mesh.ParentBone.Index], ref world_, out dd.world);
            ch.Fx.Setup(dd);
            ch.Fx.FX.Begin(); //  be lazy and save state
            EffectTechnique et = ch.Fx.FX.CurrentTechnique;

            //  most my effects are single-pass, but at least transparency is multi-pass
            for (int i = 0, n = et.Passes.Count; i != n; ++i)
            {
                EffectPass ep = et.Passes[i];
                ep.Begin();
                dd.dev.DrawIndexedPrimitives(PrimitiveType.TriangleList, ch.Part.BaseVertex,
                                             0, ch.Part.NumVertices, ch.Part.StartIndex, ch.Part.PrimitiveCount);
                ep.End();
            }
            ch.Fx.FX.End();
        }
示例#5
0
 //  callback for transparent drawing
 public void SceneDrawTransparent(DrawDetails dd, int technique)
 {
     Draw(dd, true, (1U << technique));
 }
示例#6
0
 //  Only call Draw() once per object instance per frame. Else
 //  transparently sorted pieces won't draw correctly, as there is
 //  only one set of state per ModelDraw. Use multiple ModelDraw
 //  instances for multiple object instances.
 //  Immediately draw the parts that do not require transparency.
 //  put parts that need transparency on a deferred list, to be
 //  drawn later (z sorted) using DrawDeferred().
 public bool SceneDraw(DrawDetails dd, int pass)
 {
     //  chain to an internal helper
     return(Draw(dd, false, (1U << pass)));
 }
示例#7
0
        public void ScenePrepare(DrawDetails dd)
        {
            if (PoseSource != null)
            {
                PoseSource.Get(out world_);
            }
            //  if animating, then pose it
            if (instance_ != null)
            {
                Matrix     temp;
                Keyframe[] kfs = instance_.CurrentPose;
                unchecked
                {
                    int i = 0, n = matrices_.Length;
                    foreach (Keyframe kf in kfs)
                    {
                        if (i == n)
                        {
                            break;
                        }
                        if (kf != null)
                        {
                            kf.ToMatrix(out temp);
                            //  set up the model in parent-relative pose
                            model_.Bones[i].Transform = temp;
                        }
                        ++i;
                    }
                }
            }
            else
            {
            }
            //  get the object-relative matrices (object->world is separate)
            model_.CopyAbsoluteBoneTransformsTo(matrices_);
#if DRAW_SKELETON
            //  draw the skeleton, but only in debug mode
            foreach (ModelBone mb in model_.Bones)
            {
                if (mb.Parent != null)
                {
                    Matrix  m = matrices_[mb.Index];
                    Vector3 c = m.Translation;
                    DebugLines.Global.AddLine(
                        c,
                        matrices_[mb.Parent.Index].Translation,
                        Color.White);
                    DebugLines.Global.AddLine(
                        c,
                        c + m.Right * 0.5f,
                        Color.Red);
                    DebugLines.Global.AddLine(
                        c,
                        c + m.Up * 0.5f,
                        Color.Green);
                    DebugLines.Global.AddLine(
                        c,
                        c + m.Backward * 0.5f,
                        Color.Blue);
                }
            }
#endif
            //  If I have a 3x4 matrix pose, then generate that for skinning
            if (pose_ != null)
            {
                GeneratePose();
            }
        }
示例#8
0
 //  callback for transparent drawing
 public void SceneDrawTransparent(DrawDetails dd)
 {
     Draw(dd, true);
 }
示例#9
0
 protected virtual void OnDraw(DrawDetails drawDetails)
 {
     DrawReceived?.Invoke(this, drawDetails);
 }