예제 #1
0
        /// <summary>
        /// Creates a model with information loaded from a model file
        /// </summary>
        /// <param name="transforms">Transforms applied to each model meshes</param>
        /// <param name="mesh">A collection of model meshes</param>
        public Model(Matrix[] transforms, ModelMeshCollection mesh)
        {
            this.transforms = transforms;
            this.mesh       = mesh;

            offsetTransform = Matrix.Identity;
            offsetToOrigin  = false;

            vertices = new List <Vector3>();
            indices  = new List <int>();

            shader             = new SimpleEffectShader();
            technique          = "";
            afterEffectShaders = new List <IShader>();

            animationTransforms = new Dictionary <string, Matrix>();

            resourceName = "";
#if !WINDOWS_PHONE
            shaderName = TypeDescriptor.GetClassName(shader);
#endif
            modelLoaderName = "";

            useInternalMaterials  = false;
            useLighting           = true;
            shadowAttribute       = ShadowAttribute.None;
            showBoundingBox       = false;
            boundingBoxCalculated = false;

            CalculateTriangleCount();
            CalculateMinimumBoundingSphere();
        }
예제 #2
0
        /// <summary>
        /// Creates a model with VertexBuffer and IndexBuffer.
        /// </summary>
        /// <param name="customMesh">A mesh defined with VertexBuffer and IndexBuffer</param>
        public PrimitiveModel(CustomMesh customMesh)
        {
            offsetTransform = Matrix.Identity;
            offsetToOrigin  = false;

            vertices = new List <Vector3>();
            indices  = new List <int>();

            this.customMesh    = customMesh;
            shader             = new SimpleEffectShader();
            afterEffectShaders = new List <IShader>();

            customShapeParameters = "";
#if !WINDOWS_PHONE
            shaderName = TypeDescriptor.GetClassName(shader);
#endif

            useLighting     = true;
            shadowAttribute = ShadowAttribute.None;
            showBoundingBox = false;
            useVertexColor  = false;
            technique       = "";

            if (customMesh != null)
            {
                CalculateMinimumBoundingBox();
                triangleCount = customMesh.NumberOfPrimitives;
            }
        }
예제 #3
0
 public virtual void Load(XmlElement xmlNode)
 {
     if (xmlNode.HasAttribute("UseLighting"))
     {
         useLighting = bool.Parse(xmlNode.GetAttribute("UseLighting"));
     }
     if (xmlNode.HasAttribute("ShadowAttribute"))
     {
         shadowAttribute = (ShadowAttribute)Enum.Parse(typeof(ShadowAttribute),
                                                       xmlNode.GetAttribute("CastShadow"));
     }
     if (xmlNode.HasAttribute("ShowBoundingBox"))
     {
         showBoundingBox = bool.Parse(xmlNode.GetAttribute("ShowBoundingBox"));
     }
     if (xmlNode.HasAttribute("OffsetToOrigin"))
     {
         offsetToOrigin = bool.Parse(xmlNode.GetAttribute("OffsetToOrigin"));
     }
 }
예제 #4
0
    private void InitializeCallableWrapperStorage()
    {
        var ccw = _ccw;

        Debug.Assert(ccw is not null);
        Debug.Assert(ccw.Count == 0);
        Debug.Assert(!_thisHandle.IsAllocated);

        // Associate all shadows with their interfaces.
        var interfaces = GetUninheritedShadowedInterfaces(GetType());

        if (interfaces.Count == 0)
        {
            return;
        }

        var thisHandle = _thisHandle = GCHandle.Alloc(this, GCHandleType.WeakTrackResurrection);

        foreach (var item in interfaces)
        {
            Debug.Assert(VtblAttribute.Has(item.Type));

            GCHandle shadowHandle;
            if (ShadowAttribute.Get(item.Type) is { Type: { } shadowType })
예제 #5
0
 public virtual void Load(XmlElement xmlNode)
 {
     if (xmlNode.HasAttribute("UseLighting"))
         useLighting = bool.Parse(xmlNode.GetAttribute("UseLighting"));
     if (xmlNode.HasAttribute("ShadowAttribute"))
         shadowAttribute = (ShadowAttribute)Enum.Parse(typeof(ShadowAttribute),
             xmlNode.GetAttribute("CastShadow"));
     if (xmlNode.HasAttribute("ShowBoundingBox"))
         showBoundingBox = bool.Parse(xmlNode.GetAttribute("ShowBoundingBox"));
     if (xmlNode.HasAttribute("UseInternalMaterials"))
         useInternalMaterials = bool.Parse(xmlNode.GetAttribute("UseInternalMaterials"));
     if (xmlNode.HasAttribute("OffsetToOrigin"))
         offsetToOrigin = bool.Parse(xmlNode.GetAttribute("OffsetToOrigin"));
 }
예제 #6
0
        /// <summary>
        /// Creates a model with information loaded from a model file
        /// </summary>
        /// <param name="transforms">Transforms applied to each model meshes</param>
        /// <param name="mesh">A collection of model meshes</param>
        public Model(Matrix[] transforms, ModelMeshCollection mesh)
        {
            this.transforms = transforms;
            this.mesh = mesh;

            offsetTransform = Matrix.Identity;
            offsetToOrigin = false;

            vertices = new List<Vector3>();
            indices = new List<int>();

            shader = new SimpleEffectShader();
            technique = "";
            afterEffectShaders = new List<IShader>();

            animationTransforms = new Dictionary<string, Matrix>();

            resourceName = "";
#if !WINDOWS_PHONE
            shaderName = TypeDescriptor.GetClassName(shader);
#endif
            modelLoaderName = "";

            useInternalMaterials = false;
            useLighting = true;
            shadowAttribute = ShadowAttribute.None;
            showBoundingBox = false;
            boundingBoxCalculated = false;

            CalculateTriangleCount();
            CalculateMinimumBoundingSphere();
        }
예제 #7
0
        /// <summary>
        /// Creates a model with VertexBuffer and IndexBuffer.
        /// </summary>
        /// <param name="customMesh">A mesh defined with VertexBuffer and IndexBuffer</param>
        public PrimitiveModel(CustomMesh customMesh)
        {
            offsetTransform = Matrix.Identity;
            offsetToOrigin = false;

            vertices = new List<Vector3>();
            indices = new List<int>();

            this.customMesh = customMesh;
            shader = new SimpleEffectShader();
            afterEffectShaders = new List<IShader>();

            customShapeParameters = "";
#if !WINDOWS_PHONE
            shaderName = TypeDescriptor.GetClassName(shader);
#endif

            useLighting = true;
            shadowAttribute = ShadowAttribute.None;
            showBoundingBox = false;
            useVertexColor = false;
            technique = "";

            if (customMesh != null)
            {
                CalculateMinimumBoundingBox();
                triangleCount = customMesh.NumberOfPrimitives;
            }
        }