Ejemplo n.º 1
0
        public async System.Threading.Tasks.Task <bool> Init(Graphics.CGfxMaterialInstance material, float halfWidth = 0.1F)
        {
            var rc = CEngine.Instance.RenderContext;

            Material = material;
            GeomMesh = new Graphics.Mesh.CGfxMeshPrimitives();
            GeomMesh.Init(rc, null, 1);
            CDrawPrimitiveDesc dpDesc = new CDrawPrimitiveDesc();

            dpDesc.SetDefault();
            dpDesc.StartIndex = 0xFFFFFFFF;
            GeomMesh.PushAtomLOD(0, ref dpDesc);

            var Mesh = new Graphics.Mesh.CGfxMesh();

            Mesh.Init(rc, null, GeomMesh);
            var img = new Graphics.Mesh.CGfxImage2D();

            Mesh.Tag = img;

            UpdateGeomMesh(rc, halfWidth);

            GraphActor = GamePlay.Actor.GActor.NewMeshActorDirect(Mesh);
            var meshComp = GraphActor.GetComponent <GamePlay.Component.GMeshComponent>();
            await meshComp.SetMaterialInstanceAsync(rc, 0, material, null);

            //await meshComp.SetMaterial(rc, 0, material, CEngine.Instance.PrebuildPassData.Image2DShadingEnvs, false, true);
            return(true);
        }
Ejemplo n.º 2
0
        public async System.Threading.Tasks.Task SetMaterial()
        {
            await AwaitLoadDebugActor();

            await mDebugActor.GetComponent <GamePlay.Component.GMeshComponent>().SetMaterialInstance(
                CEngine.Instance.RenderContext, 0,
                RName.GetRName("editor/icon/icon_3D/material/physical_model.instmtl"), null);
        }
Ejemplo n.º 3
0
        public void UpdateActor(GamePlay.Actor.GActor actor)
        {
            var pointComp = actor.GetComponent <PointActorComponent>();

            if (pointComp != null)
            {
                UpdatePointComponent(pointComp);
            }
            else
            {
                var boxComp = actor.GetComponent <BoxActorComponent>();
                if (boxComp != null)
                {
                    UpdateBoxComponent(boxComp);
                }
            }
        }
Ejemplo n.º 4
0
            public static TouchInputEventArgs CreateTouchInputEventArgsFromeScreenXY(
                GamePlay.Actor.GActor showActor,
                float showWidth,
                float showHeight,
                float hitLength,
                enTouchState State,
                int x,
                int y,
                int FingerIdx,
                float DeltaX,
                float DeltaY)
            {
                if (showActor.Scene == null)
                {
                    return(null);
                }
                if (CEngine.Instance.GameInstance == null)
                {
                    return(null);
                }
                var hitResult = new GamePlay.SceneGraph.VHitResult(Bricks.PhysicsCore.PhyHitFlag.eDEFAULT);

                if (showActor.Scene.PickActor(out hitResult, CEngine.Instance.GameInstance.GameCamera, x, y, hitLength) != showActor)
                {
                    return(null);
                }
                var triMeshComp = showActor.GetComponent <Bricks.PhysicsCore.CollisionComponent.GPhysicsMeshCollision>();

                if (triMeshComp == null)
                {
                    return(null);
                }
                var triMesh = triMeshComp.HostShape.TriGeom;

                if (triMesh == null)
                {
                    return(null);
                }
                if (hitResult.FaceId == -1)
                {
                    return(null);
                }

                if (triMeshComp.HostShape == null)
                {
                    return(null);
                }

                int faceid = triMeshComp.HostShape.GetTrianglesRemap(hitResult.FaceId);

                if (faceid == -1)
                {
                    return(null);
                }

                triMesh.GetUV(faceid, hitResult.U, hitResult.V, out ResultUV);
                var pos = triMesh.GetPos(faceid, hitResult.U, hitResult.V);

                pos = Vector3.TransformCoordinate(pos, showActor.Placement.DrawTransform);
                //以后要改成pool模式
                var result = new TouchInputEventArgs();

                result.TouchEvent.State     = State;
                result.TouchEvent.PosX      = ResultUV.X * showWidth;
                result.TouchEvent.PosY      = ResultUV.Y * showHeight;
                result.TouchEvent.FingerIdx = FingerIdx;
                result.TouchEvent.DeltaX    = DeltaX;
                result.TouchEvent.DeltaY    = DeltaY;
                return(result);
            }