Esempio n. 1
0
        private void DrawModel(NursiaModel model)
        {
            if (!_beginCalled)
            {
                throw new Exception("Begin wasnt called");
            }

            model.UpdateNodesAbsoluteTransforms();
            using (var transformScope = new TransformScope(_context, model.Transform))
            {
                foreach (var mesh in model.Meshes)
                {
                    DrawMeshNode(mesh);
                }
            }
        }
Esempio n. 2
0
        private void DrawMeshNode(MeshNode meshNode)
        {
            foreach (var part in meshNode.Parts)
            {
                var boundingSphere = part.BoundingSphere.Transform(meshNode.AbsoluteTransform * _context.World);
                if (_context.Frustrum.Contains(boundingSphere) == ContainmentType.Disjoint)
                {
                    continue;
                }

                // If part has bones, then parent node transform had been already
                // applied to bones transform
                // Thus to avoid applying parent transform twice, we use
                // ordinary Transform(not AbsoluteTransform) for parts with bones
                using (var scope = new TransformScope(_context,
                                                      part.Bones.Count > 0 ? Matrix.Identity : meshNode.AbsoluteTransform))
                {
                    DrawMeshPart(part);
                }
            }
        }