コード例 #1
0
        private void CreateLODNodesFNV(NiFile file, BSMultiBoundNode node, QuadDesc quad, List<ShapeDesc> shapes)
        {
            foreach (ShapeDesc shapeDesc in shapes)
            {
                BSSegmentedTriShape segmentedTriShape = new BSSegmentedTriShape((NiGeometry)shapeDesc.shape);
                node.AddChild(file.AddBlock((NiObject)segmentedTriShape));
                node.SetCullMode(1U);
                string str = "obj";
                // use material name from list file, Snow/Ash
                if (!this.ignoreMaterial && shapeDesc.material != "")
                    str = str + shapeDesc.material;
                // only level 4 should have HD
                if (shapeDesc.isHighDetail && (this.quadLevel == 4 || useHDFlag))
                {
                    str = str + "HD";
                }
                //segmentedTriShape.SetNameIndex(file.AddString(str));
                segmentedTriShape.SetFlags((ushort)14);
                segmentedTriShape.SetFlags2((ushort)8);
                //segmentedTriShape.SetBSProperty(1, -1);
                segmentedTriShape.SetTranslation(new Vector3((float)quad.x * 4096f, (float)quad.y * 4096f, 0.0f));
                segmentedTriShape.SetRotation(new Matrix33(true));
                segmentedTriShape.SetScale((float)this.quadLevel);

                BSShaderTextureSet shaderTextureSet = new BSShaderTextureSet();
                BSShaderPPLightingProperty lightingShaderProperty = new BSShaderPPLightingProperty();
                segmentedTriShape.SetProperties(file.AddBlock((NiObject)lightingShaderProperty));
                lightingShaderProperty.SetTextureSet(file.AddBlock((NiObject)shaderTextureSet));
                shaderTextureSet.SetNumTextures(6);
                shaderTextureSet.SetTexture(0, shapeDesc.textures[0]);
                shaderTextureSet.SetTexture(1, shapeDesc.textures[1]);
                segmentedTriShape.SetData(file.AddBlock((NiObject)shapeDesc.data));
                for (int index = 0; index < 16; ++index)
                    segmentedTriShape.AddSegment(new BSSegment(0U, (ushort)0));
                for (int index = 0; index < shapeDesc.segments.Count; ++index)
                {
                    BSSegment segmentAtIndex = segmentedTriShape.GetSegmentAtIndex(shapeDesc.segments[index].id);
                    segmentAtIndex.startTriangle = shapeDesc.segments[index].startTriangle;
                    segmentAtIndex.numTriangles = shapeDesc.segments[index].numTriangles;
                    segmentedTriShape.SetSegment(shapeDesc.segments[index].id, segmentAtIndex);
                }
                for (int index = 15; index >= 0 && (int)segmentedTriShape.GetSegmentAtIndex(index).numTriangles == 0; --index)
                {
                    segmentedTriShape.RemoveSegment(index);
                }
                this.GenerateMultibound(file, node, quad, shapeDesc.boundingBox);
            }
        }
コード例 #2
0
 private void CreateLODNodes(NiFile file, NiNode rootNode, QuadDesc quad, List<ShapeDesc> shapes)
 {
     foreach (ShapeDesc shapeDesc in shapes)
     {
         BSMultiBoundNode node = new BSMultiBoundNode();
         rootNode.AddChild(file.AddBlock((NiObject)node));
         BSSegmentedTriShape segmentedTriShape = new BSSegmentedTriShape((NiGeometry)shapeDesc.shape);
         node.AddChild(file.AddBlock((NiObject)segmentedTriShape));
         node.SetCullMode(1U);
         string str = "obj";
         // use material name from list file, Snow/Ash
         if (!this.ignoreMaterial && shapeDesc.material != "")
         {
             str = str + shapeDesc.material;
         }
         // only level 4 should have HD
         if (shapeDesc.isHighDetail && (this.quadLevel == 4 || this.useHDFlag))
         {
             str = str + "HD";
         }
         segmentedTriShape.SetNameIndex(file.AddString(str));
         segmentedTriShape.SetFlags((ushort)14);
         segmentedTriShape.SetFlags2((ushort)8320);
         segmentedTriShape.SetData(file.AddBlock((NiObject)shapeDesc.data));
         segmentedTriShape.SetBSProperty(1, -1);
         segmentedTriShape.SetScale((float)this.quadLevel);
         segmentedTriShape.SetRotation(new Matrix33(true));
         segmentedTriShape.SetTranslation(new Vector3((float)quad.x * 4096f, (float)quad.y * 4096f, 0.0f));
         for (int index = 0; index < 16; ++index)
         {
             segmentedTriShape.AddSegment(new BSSegment(0U, (ushort)0));
         }
         for (int index = 0; index < shapeDesc.segments.Count; ++index)
         {
             BSSegment segmentAtIndex = segmentedTriShape.GetSegmentAtIndex(shapeDesc.segments[index].id);
             segmentAtIndex.startTriangle = shapeDesc.segments[index].startTriangle;
             segmentAtIndex.numTriangles = shapeDesc.segments[index].numTriangles;
             segmentedTriShape.SetSegment(shapeDesc.segments[index].id, segmentAtIndex);
         }
         for (int index = 15; index >= 0 && (int)segmentedTriShape.GetSegmentAtIndex(index).numTriangles == 0; --index)
         {
             segmentedTriShape.RemoveSegment(index);
         }
         BSShaderTextureSet shaderTextureSet = new BSShaderTextureSet();
         BSLightingShaderProperty lightingShaderProperty = new BSLightingShaderProperty();
         segmentedTriShape.SetBSProperty(0, file.AddBlock((NiObject)lightingShaderProperty));
         lightingShaderProperty.SetTextureSet(file.AddBlock((NiObject)shaderTextureSet));
         lightingShaderProperty.SetLightingEffect1(0.0f);
         lightingShaderProperty.SetLightingEffect2(0.0f);
         lightingShaderProperty.SetGlossiness(1f);
         lightingShaderProperty.SetTextureClampMode(shapeDesc.TextureClampMode);
         uint num1 = 2151677952U;
         /*if (this.quadLevel == 4)
         {
             num1 = 2151678720U; // Recieve/Cast Shadows - no worky :(
         }*/
         uint num3 = 1U; // ZBuffer_Write
         if (shapeDesc.isHighDetail && (this.quadLevel == 4 || this.useHDFlag))
         {
             num3 |= 2147483648U; //HD_LOD_Objects
         }
         else
         {
             num3 |= 4U; //LOD_Objects
         }
         if (shapeDesc.data.HasVertexColors())
             num3 |= 32U;
         // set double-sided flag
         if (shapeDesc.isDoubleSided)
             num3 |= 16;
         lightingShaderProperty.SetShaderFlags1(num1);
         lightingShaderProperty.SetShaderFlags2(num3);
         shaderTextureSet.SetNumTextures(9);
         shaderTextureSet.SetTexture(0, shapeDesc.textures[0]);
         shaderTextureSet.SetTexture(1, shapeDesc.textures[1]);
         this.GenerateMultibound(file, node, quad, shapeDesc.boundingBox);
     }
 }