Example #1
0
        public static CGfxEffectDesc CreateDesc(CGfxMaterial mtl, Mesh.CGfxMdfQueue mdf, GfxEnvShaderCode shadingenv)
        {
            CGfxEffectDesc result = new CGfxEffectDesc();

            result.MtlShaderPatch      = mtl;
            result.MdfQueueShaderPatch = mdf.CloneMdfQueue(CEngine.Instance.RenderContext, null);
            result.EnvShaderPatch      = shadingenv;
            //result.EnvShaderPatch = shadingenv.CloneShadingEnv();
            result.UpdateHash64(true);
            return(result);
        }
        public bool Init(CRenderContext rc, RName name, UInt32 atom)
        {
            if (false == SDK_GfxMeshPrimitives_Init(CoreObject, rc.CoreObject, name != null ? name.Name : "", atom))
            {
                return(false);
            }
            mName         = name;
            mGeometryMesh = new CGeometryMesh(SDK_GfxMeshPrimitives_GetGeomtryMesh(CoreObject));
            mMdfQueue     = new CGfxMdfQueue(rc, SDK_GfxMeshPrimitives_GetMdfQueue(CoreObject));

            ResourceState.StreamState = EStreamingState.SS_Valid;
            return(true);
        }
 public CGfxMeshPrimitives(NativePointer self)
 {
     mCoreObject = self;
     if (self.Pointer != IntPtr.Zero)
     {
         mResourceState = new CResourceState(SDK_VIUnknown_GetResourceState(self.Pointer));
         mGeometryMesh  = new CGeometryMesh(SDK_GfxMeshPrimitives_GetGeomtryMesh(CoreObject));
         if (mGeometryMesh.CoreObject.Pointer == IntPtr.Zero)
         {
             return;
         }
         mMdfQueue = new CGfxMdfQueue(CEngine.Instance.RenderContext, SDK_GfxMeshPrimitives_GetMdfQueue(CoreObject));
     }
 }
        public bool LoadMesh(CRenderContext rc, RName name, bool firstLoad)
        {
            using (var xnd = IO.XndHolder.SyncLoadXND(name.Address))
            {
                if (xnd == null)
                {
                    return(false);
                }

                if (false == SDK_GfxMeshPrimitives_LoadXnd(CoreObject, rc.CoreObject, name.Name, xnd.Node.CoreObject, firstLoad))
                {
                    return(false);
                }

                mName         = name;
                mGeometryMesh = new CGeometryMesh(SDK_GfxMeshPrimitives_GetGeomtryMesh(CoreObject));
                mMdfQueue     = new CGfxMdfQueue(rc, SDK_GfxMeshPrimitives_GetMdfQueue(CoreObject));

                var modQueueNode = xnd.Node.FindNode("ModStacks");
                if (modQueueNode != null)
                {
                    var mdfs = modQueueNode.GetNodes();
                    foreach (var i in mdfs)
                    {
                        if (i.GetClassId() == CGfxSkinModifier.CoreClassId)//GfxSkinModifier
                        {
                            //var rtti = CEngine.Instance.NativeRttiManager.FindRttiById(i.GetClassId());
                            //CGfxModifier.NativePointer corePtr = new CGfxModifier.NativePointer();
                            //corePtr.Pointer = rtti.CreateInstance("CGfxMeshPrimitives.cs", 117);
                            var skinModifier = new CGfxSkinModifier();
                            skinModifier.LoadXnd(i);
                            mMdfQueue.AddModifier(skinModifier);
                        }
                    }
                }

                if (firstLoad)
                {
                    ResourceState.StreamState = EStreamingState.SS_Valid;
                }
                else
                {
                    ResourceState.StreamState = EStreamingState.SS_Invalid;
                }
                return(true);
            }
        }
Example #5
0
 public CGfxMdfQueue CloneMdfQueue(CRenderContext rc, CGfxMdfQueue oldMdfQueue)
 {
     if (oldMdfQueue == null)
     {
         var mdfQueue = new CGfxMdfQueue();
         foreach (var i in Modifiers)
         {
             var modifier = i.CloneModifier(rc);
             mdfQueue.AddModifier(modifier);
         }
         return(mdfQueue);
     }
     else
     {
         return(oldMdfQueue);
     }
 }
        public bool InitFromGeomtryMesh(CRenderContext rc, CGeometryMesh mesh, UInt32 atom, ref BoundingBox aabb)
        {
            unsafe
            {
                fixed(BoundingBox *pAABB = &aabb)
                {
                    if (false == SDK_GfxMeshPrimitives_InitFromGeomtryMesh(CoreObject, rc.CoreObject, mesh.CoreObject, atom, pAABB))
                    {
                        return(false);
                    }
                }
            }
            mGeometryMesh = new CGeometryMesh(SDK_GfxMeshPrimitives_GetGeomtryMesh(CoreObject));
            mMdfQueue     = new CGfxMdfQueue(rc, SDK_GfxMeshPrimitives_GetMdfQueue(CoreObject));

            ResourceState.StreamState = EStreamingState.SS_Valid;
            return(true);
        }
 internal void UnsafeReInit(NativePointer self)
 {
     Core_Release();
     mCoreObject = self;
     mResourceState.UnsafeReInit(SDK_VIUnknown_GetResourceState(self.Pointer));
     if (mGeometryMesh == null)
     {
         mGeometryMesh = new CGeometryMesh(SDK_GfxMeshPrimitives_GetGeomtryMesh(CoreObject));
     }
     else
     {
         mGeometryMesh.UnsafeReInit(SDK_GfxMeshPrimitives_GetGeomtryMesh(CoreObject));
     }
     if (mMdfQueue == null)
     {
         mMdfQueue = new CGfxMdfQueue(CEngine.Instance.RenderContext, SDK_GfxMeshPrimitives_GetMdfQueue(CoreObject));
     }
     else
     {
         mMdfQueue.UnsafeReInit(CEngine.Instance.RenderContext, SDK_GfxMeshPrimitives_GetMdfQueue(CoreObject));
     }
 }