- Main Page
- Packages
- Classes
- Files

- File List
- File Members

# D:/guillaume/guillara/3D/DXGfx/Backup/DXGfxLib/FrameworkMeshObject.cs

Go to the documentation of this file.

    00001 //BSD License
    00002 //DXGfx® - http://www.eteractions.com
    00003 //Copyright (c) 2005
    00004 //by Guillaume Randon
    00005 //Permission is hereby granted, free of charge, to any person obtaining a copy of this software
    00006 //and associated documentation files (the "Software"), to deal in the Software without restriction,
    00007 //including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00008 //and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
    00009 //subject to the following conditions:
    00010 //The above copyright notice and this permission notice shall be included in all copies or substantial
    00011 //portions of the Software.
    00012 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    00013 //INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
    00014 //AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
    00015 //DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00016 //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    00017 using System;
    00018 using System.Collections.Generic;
    00019 using System.Text;
    00020 using Microsoft.DirectX;
    00021 using Microsoft.DirectX.Direct3D;
    00022 using Microsoft.Samples.DirectX.UtilityToolkit;
    00023
    00024 namespace DXGfxLib
    00025 {
    00026     public class FrameworkMeshObject : MeshObjectWithLOD
    00027     {
    00032         protected FrameworkMesh frameworkMesh = null;
    00033
    00038         public void Attach(FrameworkMesh meshToAttach)
    00039         {
    00040             frameworkMesh = meshToAttach;
    00041             base.Attach(meshToAttach.LocalMesh);
    00042         }
    00043
    00052         public virtual void AttachWithLOD(Device d3ddevice, FrameworkMesh meshToAttach)
    00053         {
    00054             int[] generatedAdjacency = new int[3*meshToAttach.LocalMesh.NumberFaces];
    00055             meshToAttach.LocalMesh.GenerateAdjacency(0.01f, generatedAdjacency);
    00056
    00057             ExtendedMaterial[] generatedMaterials = new ExtendedMaterial[meshToAttach.NumberMaterials];
    00058             for (int i = 0; i < meshToAttach.NumberMaterials; i++)
    00059             {
    00060                 generatedMaterials[i] = new ExtendedMaterial();
    00061                 Material mat = meshToAttach.GetMaterial(i);
    00062
    00063                 generatedMaterials[i].Material3D = mat;
    00064             }
    00065             base.AttachWithLOD(d3ddevice, meshToAttach.LocalMesh, generatedAdjacency, generatedMaterials, null);
    00066         }
    00067
    00073         public override void Draw(Device device)
    00074         {
    00075             device.SetTransform(TransformType.World, worldMat);
    00076             frameworkMesh.Render(device);
    00077         }
    00078     }
    00079 }