public void CreateNetWorkObject(NetWorkClientObject no) { Debug.Assert(no.CreateRemoteObjectOrder != null); Debug.Assert(no.HandleRemoteObjectOrder != null); NetOutgoingMessage om = this.CreateMessage(NetMessageType.CreateNetworkObjectOnServer); om.Write(no.Identifier); SendMessage(no.CreateRemoteObjectOrder(om), NetDeliveryMethod.ReliableOrdered); NetWorkObjects[no.Identifier] = no; }
/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { ///must be called before all base.LoadContent(GraphicInfo, factory, contentManager); client = new NetworkCliente(World); NetWorkClientObject no = new NetWorkClientObject("tmesh", (mes) => { mes.WriteTrianglemesh("Model//cenario", Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); return mes; }, (mes, id) => { SimpleModel model; TriangleMeshObject triangleMesh = mes.ReadTrianglemesh(GraphicFactory, out model); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, model, triangleMesh); obj.SetId(id); return obj; } ); client.CreateNetWorkObject(no); ///Add some directional lights to completely iluminate the world #region Lights DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.4f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(false, GraphicInfo.Viewport)); { SimpleConcreteKeyboardInputPlayable key = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Space); key.KeyStateChange += new KeyStateChange(key_KeyStateChange); this.BindInput(key); } { SimpleConcreteKeyboardInputPlayable key = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Enter); key.KeyStateChange +=new KeyStateChange(key_KeyStateChange2); this.BindInput(key); } }
void key_KeyStateChange(InputPlayableKeyBoard ipk) { NetWorkClientObject no = new NetWorkClientObject("simpleball", (mes) => { mes.WriteSphere(new Vector3(50, 50, 10), 1, 1, 10, MaterialDescription.DefaultBepuMaterial()); return mes; }, (mes,id) => { SimpleModel simpleModel = new SimpleModel(this.GraphicFactory, "Model//ball"); SphereObject sphere = mes.ReadSphere(); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, sphere); obj.SetId(id); return obj; } ); client.CreateNetWorkObject(no); }
public void CreateNetWorkObject(NetWorkClientObject no) { Debug.Assert(no.CreateRemoteObjectOrder != null); Debug.Assert(no.HandleRemoteObjectOrder != null); NetOutgoingMessage om = this.CreateMessage(NetMessageType.CreateNetworkObjectOnServer); om.Write(no.Identifier); SendMessage(no.CreateRemoteObjectOrder(om),NetDeliveryMethod.ReliableOrdered); NetWorkObjects[no.Identifier] = no; }