示例#1
0
        private void RenderNode(MNL.NiAVObject node, float distance)
        {
            var niGeom = node as MNL.NiTriBasedGeometry;

            if (niGeom != null && niGeom.Mesh != null)
            {
                GL.PushMatrix();
                GL.MultMatrix(ref niGeom.Transform);
                niGeom.Mesh.BeginRender();
                niGeom.Mesh.Render();
                GL.PopMatrix();
            }

            if (node is NiLODNode)
            {
                var lod = node as NiLODNode;

                if (lod.LODLevels != null)
                {
                    for (int i = 0; i < lod.LODLevels.Length; i++)
                    {
                        if (distance >= lod.LODLevels[i].NearExtent && distance < lod.LODLevels[i].FarExtent)
                        {
                            RenderNode(lod.Children[i].Object, distance);
                        }
                    }
                }

                if (lod.LODLevelData != null)
                {
                    if (lod.LODLevelData.Object is NiRangeLODData)
                    {
                        var rangeLod = lod.LODLevelData.Object as NiRangeLODData;
                        for (int i = 0; i < rangeLod.LODLevels.Length; i++)
                        {
                            if (distance >= rangeLod.LODLevels[i].NearExtent && distance < rangeLod.LODLevels[i].FarExtent)
                            {
                                RenderNode(lod.Children[i].Object, distance);
                            }
                        }
                    }

                    //NiRangeLodData
                    //NiScreenLodData
                }
            }
            else
            {
                var niNode = node as MNL.NiNode;
                if (niNode != null)
                {
                    foreach (var child in niNode.Children)
                    {
                        RenderNode(child.Object, distance);
                    }
                }
            }
        }
示例#2
0
        private void RenderGroupNode(MNL.NiAVObject node, IEnumerable <Matrix4> transforms)
        {
            float distance = 1; // haxx for lod :>

            var niGeom = node as MNL.NiTriBasedGeometry;

            if (niGeom != null && niGeom.Mesh != null)
            {
                niGeom.Mesh.BeginRender();
                foreach (var objTransform in transforms)
                {
                    GL.PushMatrix();
                    Matrix4 nodeTransform = niGeom.Transform * objTransform;
                    GL.MultMatrix(ref nodeTransform);
                    niGeom.Mesh.Render();
                    GL.PopMatrix();
                }
                niGeom.Mesh.EndRender();
            }

            var niNode = node as MNL.NiNode;

            if (niNode != null)
            {
                var lod = node as MNL.NiLODNode;
                if (lod != null)
                {
                    if (lod.LODLevels != null)
                    {
                        for (int i = 0; i < lod.LODLevels.Length; i++)
                        {
                            if (distance >= lod.LODLevels[i].NearExtent && distance < lod.LODLevels[i].FarExtent)
                            {
                                RenderGroupNode(lod.Children[i].Object, transforms);
                            }
                        }
                    }

                    if (lod.LODLevelData != null)
                    {
                        if (lod.LODLevelData.Object is NiRangeLODData)
                        {
                            var rangeLod = lod.LODLevelData.Object as NiRangeLODData;
                            for (int i = 0; i < rangeLod.LODLevels.Length; i++)
                            {
                                if (distance >= rangeLod.LODLevels[i].NearExtent && distance < rangeLod.LODLevels[i].FarExtent)
                                {
                                    RenderGroupNode(lod.Children[i].Object, transforms);
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (var child in niNode.Children)
                    {
                        RenderGroupNode(child.Object, transforms);
                    }
                }
            }
        }