public new void Draw() { if (player == Player.Computer) { Sprite.BasicEffect.View = boardTranslation * Camara.View; } Sprite.BasicEffect.TextureEnabled = true; Sprite.BasicEffect.Texture = EngineContent.GetTextureByName("boardCell"); Sprite.BasicEffect.LightingEnabled = false; foreach (EffectPass pass in Sprite.BasicEffect.CurrentTechnique.Passes) { pass.Apply(); //PORT //Sprite.Graphics.GraphicsDevice.SamplerStates[0].MinFilter = TextureFilter.Anisotropic; //Sprite.Graphics.GraphicsDevice.SamplerStates[0].MagFilter = TextureFilter.Anisotropic; //Sprite.Graphics.GraphicsDevice.SamplerStates[0].MipFilter = TextureFilter.Linear; //Sprite.Graphics.GraphicsDevice.SamplerStates[0].MaxAnisotropy = 16; //Sprite.BasicEffect.CommitChanges(); Sprite.Graphics.GraphicsDevice.DrawUserPrimitives <VertexPositionTexture>( PrimitiveType.TriangleList, pointList, 0, // vertex buffer offset to add to each element of the index buffer 300 // number of vertices in pointList ); } Sprite.BasicEffect.LightingEnabled = true; Sprite.BasicEffect.View = Camara.View; }
public Fire(float px, float py, float pz, Player player) { base.scale = 1; alpha = 0; alpha += (float)(randomizer.NextDouble() * 0.1); direction = Game.Alternator(); if (direction == 1) { transHorz = -0.09f; } else { transHorz = 0.09f; } x = px + 0.5f; y = pz + 0.5f + (float)(randomizer.NextDouble() * 0.1) * direction; angleRot = 55 * (float)randomizer.NextDouble(); this.textureID = EngineContent.GetTextureByName("fire"); if (player == Player.Computer) { x += Game.BoardSeparation; } position = new Vector3(x, 0, y);; translate = new Vector3(transHorz, transVert, 0); }
public new void Draw() { Sprite.BasicEffect.TextureEnabled = true; Sprite.BasicEffect.Texture = EngineContent.GetTextureByName("boardCell"); Sprite.BasicEffect.LightingEnabled = false; Sprite.BasicEffect.Begin(); //Sprite.Graphics.GraphicsDevice.RenderState.FillMode = FillMode.WireFrame; //Sprite.Graphics.GraphicsDevice.RenderState.CullMode = CullMode.None; foreach (EffectPass pass in Sprite.BasicEffect.CurrentTechnique.Passes) { pass.Begin(); Sprite.Graphics.GraphicsDevice.VertexDeclaration = new VertexDeclaration(Sprite.Graphics.GraphicsDevice, VertexPositionTexture.VertexElements); Sprite.Graphics.GraphicsDevice.DrawUserPrimitives <VertexPositionTexture>( PrimitiveType.TriangleList, pointList, 0, // vertex buffer offset to add to each element of the index buffer 300 // number of vertices in pointList ); pass.End(); } Sprite.Graphics.GraphicsDevice.RenderState.FillMode = FillMode.Solid; Sprite.BasicEffect.End(); }
public new void Create() { if (player == Player.Computer) { translate = Matrix.CreateTranslation(Game.BoardSeparation, 0, 0); } else { translate = Matrix.Identity; } textureID = EngineContent.GetTextureByName(textureName); pointList = new VertexPositionTexture[6]; pointList[0] = new VertexPositionTexture( new Vector3(0, Game.BoardAltitude, 0), new Vector2(0, 0)); pointList[1] = new VertexPositionTexture( new Vector3(1, Game.BoardAltitude, 0), new Vector2(1, 0)); pointList[2] = new VertexPositionTexture( new Vector3(0, Game.BoardAltitude, 1), new Vector2(0, 1)); pointList[3] = new VertexPositionTexture( new Vector3(0, Game.BoardAltitude, 1), new Vector2(0, 1)); pointList[4] = new VertexPositionTexture( new Vector3(1, Game.BoardAltitude, 0), new Vector2(1, 0)); pointList[5] = new VertexPositionTexture( new Vector3(1, Game.BoardAltitude, 1), new Vector2(1, 1)); }
public Cloud() { angle = ((float)randomizer.NextDouble() * 30 + 10) * direction; position = new Vector3(10, 15, -35); base.textureID = EngineContent.GetTextureByName("cloud"); scaleModel = new Vector3(15, 8, 1); }
public new void Create() { texture = EngineContent.GetTextureByName("boardCell"); pointList = new VertexPositionTexture[900]; // 150 celdas * 6 puntos cada una int index = 0; for (int x = 0; x < 10; x++) { for (int y = 0; y < 15; y++) { pointList[index] = new VertexPositionTexture( new Vector3(x, Game.BoardAltitude, y), new Vector2(0, 0)); pointList[index + 1] = new VertexPositionTexture( new Vector3(x + 1, Game.BoardAltitude, y), new Vector2(1, 0)); pointList[index + 2] = new VertexPositionTexture( new Vector3(x, Game.BoardAltitude, y + 1), new Vector2(0, 1)); pointList[index + 3] = new VertexPositionTexture( new Vector3(x, Game.BoardAltitude, y + 1), new Vector2(0, 1)); pointList[index + 4] = new VertexPositionTexture( new Vector3(x + 1, Game.BoardAltitude, y), new Vector2(1, 0)); pointList[index + 5] = new VertexPositionTexture( new Vector3(x + 1, Game.BoardAltitude, y + 1), new Vector2(1, 1)); index += 6; } } }
public void Create() { textHover = EngineContent.GetTextureByName(textHoverS); texPressed = EngineContent.GetTextureByName(texPressedS); texNormal = EngineContent.GetTextureByName(texNormalS); texCurrent = texNormal; }
public virtual void Draw() { foreach (ModelMesh mesh in modelMeshes.Meshes) { // This is where the mesh orientation is set, as well as our camera and projection. foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = mesh.ParentBone.Transform * Matrix.CreateFromYawPitchRoll(0, -MathHelper.PiOver2, 0); effect.View = Camara.View; effect.Projection = Camara.Projection; if (EngineContent.GetTextureByName(mesh.Name) != null) { effect.TextureEnabled = true; effect.Texture = EngineContent.GetTextureByName(mesh.Name); } else { effect.TextureEnabled = false; } } // Draw the mesh, using the effects set above. mesh.Draw(); } }
public void Dispose() { Game.World?.UnloadContent(); Renderer.Dispose(); WorldContent?.Dispose(); EngineContent.Dispose(); }
public new void Create() { texturePlayer = EngineContent.GetTextureByName("logoPlayer"); textureCPU = EngineContent.GetTextureByName("logoCPU"); textureID = texturePlayer; base.file = "sphere"; base.Create(); }
public Panel(Rectangle rectangle, string texture, Aligment aligment) { base.zOrder = 1; base.areaRectangle = rectangle; if (aligment == Aligment.Center) { areaRectangle.X = Globals.ScreenWidthOver2 - areaRectangle.Width / 2; } this.texture = EngineContent.GetTextureByName(texture); }
public new void Create() { VertexPositionTexture[] waterVertices = CreateWaterVertices(); int[] waterIndices = CreateWaterIndices(); CreateBuffers(waterVertices, waterIndices); waterBumps = EngineContent.GetTextureByName("waterbumps"); effect = EngineContent.GetEffectByName("oceanwater"); skyboxTexture = EngineContent.GetTextureCubeByName("skybox02"); }
public Ship() { this.IsTarget = true; //randomizo la direccion de rotacion angleDirX = Game.Alternator(); angleDirZ = Game.Alternator(); textureBurn = EngineContent.GetTextureByName("barcoquemao"); currentTexture = textureID; }
public ShipSmoke(Vector3 pCoord) { alpha -= (float)randomizer.NextDouble() * 0.1f; this.position = pCoord; base.scale = (float)randomizer.NextDouble(); base.textureID = EngineContent.GetTextureByName("shipSmoke"); if (scale > 0.5f) { angleRot += 90; } }
public FlagButton(Rectangle rectangle, MouseClick onClick, Vector3 flagPos, string text, string textureFlag) { base.areaRectangle = rectangle; base.mouseClick = onClick; this.text = text; Texture2D textureID = EngineContent.GetTextureByName(textureFlag); flag = new Flag(flagPos, new Vector3(1.1f, 1.7f, 2), textureID, rectangle); textSize = Sprite.SpriteFont.MeasureString(text); textPosition = new Vector2(areaRectangle.X + (areaRectangle.Width - textSize.X) / 2, areaRectangle.Y + areaRectangle.Height); base.fontColor = Color.WhiteSmoke; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); Sprite.SpriteBatch = spriteBatch; Sprite.Graphics = graphics; Sprite.BasicEffect = new BasicEffect(graphics.GraphicsDevice); Sprite.BasicEffect.EnableDefaultLighting(); //effect load //EngineContent.SetEffectList("effects\\"); //EngineContent.LoadEffects(); //texture load EngineContent.SetTextureList("textures\\"); EngineContent.LoadTextures(); //texture cube load //TODO PORT EngineContent.SetTextureCubeList("cubeMaps\\"); //TODO PORT EngineContent.LoadTextureCube(); //model load EngineContent.SetModelList("models\\"); EngineContent.LoadModels(); //cursor load Cursor cursor = new Cursor(); cursor.AddCursor(ECursor.Aim, "aim"); cursor.AddCursor(ECursor.Arrow, "custom"); cursor.CurrentCursor = ECursor.Arrow; manager.Cursor = cursor; //font load SpriteFont spriteFont = Content.Load <SpriteFont>("fonts\\spriteFont12"); Sprite.SpriteFont = spriteFont; Sprite.Create(); SamplerState sState = new SamplerState(); sState.Filter = TextureFilter.Anisotropic; Sprite.Graphics.GraphicsDevice.SamplerStates[0] = sState; manager.CreateScreens(); manager.Camara.InitCamara(); manager.LoadModels(); // TODO: use this.Content to load your game content here }
public ExplosionWave(int x, int y, Player player, int type) { base.file = "sphere"; this.x = x; this.y = y; this.player = player; if (type == 0) { base.textureID = EngineContent.GetTextureByName("imagenMar");; } else { base.textureID = EngineContent.GetTextureByName("explosion"); } }
protected void Create() { modelMeshes = EngineContent.GetModelByName(file); float mayor = -1; int index = 0; //calculates the mesh index with the bigger bounding sphere radius foreach (var item in modelMeshes.Meshes) { if (item.BoundingSphere.Radius > mayor) { meshIndexforSelection = index; mayor = item.BoundingSphere.Radius; } index++; } }
public new void Create() { base.Create(); SkySphereEffect = EngineContent.GetEffectByName("skySphere"); //SkySphereEffect.Parameters["ViewMatrix"].SetValue(Camara.View); //SkySphereEffect.Parameters["ProjectionMatrix"].SetValue(Camara.Projection); //SkySphereEffect.Parameters["SkyboxTexture"].SetValue(CreateSkyBox()); //// Set the Skysphere Effect to each part of the Skysphere model //foreach (ModelMesh mesh in modelMeshes.Meshes) //{ // foreach (ModelMeshPart part in mesh.MeshParts) // { // part.Effect = SkySphereEffect; // } //} }
public MisileFire(Vector3 pCoord) { coord = pCoord; base.textureID = EngineContent.GetTextureByName("fireMisile"); base.scale = 0.7f; }
private TextureCube CreateSkyBox() { return(EngineContent.GetTextureCubeByName("skybox02")); }
public MainScreen(Manager manager) { base.manager = manager; if (Layout.ScreenFormat == ScreenFormat.Format4X3) { flag = new Flag(new Vector3(1, 1, 0.01f), new Vector3(1.2f, 2, 1), EngineContent.GetTextureByName(Game.GameStrings.GetString("Title")), new Rectangle(430, 85, 520, 140)); flag.Create(); Edit edit = new Edit(new Rectangle(690, 660, 120, 40), "edtName", Game.GameStrings.GetString("DefaultName")); Panel panel = new Panel(new Rectangle(0, 0, 1024, 768), "portada", Aligment.Left); Button button = new Button(new Rectangle(830, 660, 100, 40), Game.GameStrings.GetString("Enter"), new MouseClick(base.EnterSetupScreen)); Label textInsertar = new Label(Game.GameStrings.GetString("InsertName"), new Vector2(730, 622), Sprite.SpriteFont); FlagButton languageSpanish = new FlagButton(new Rectangle(80, 642, 100, 50), SelectSpanish, new Vector3(-5.55f, -5.1f, -15), Game.GameStrings.GetString("Spanish"), "espanna"); FlagButton languageEnglish = new FlagButton(new Rectangle(200, 642, 100, 50), SelectEnglish, new Vector3(-3.6f, -5.1f, -15), Game.GameStrings.GetString("English"), "uk"); Label textLanguage = new Label(Game.GameStrings.GetString("SelectLanguage"), new Rectangle(82, 622, 218, 20), Sprite.SpriteFont, Aligment.Center); base.AddControl(panel); base.AddControl(textInsertar); base.AddControl(button); base.AddControl(edit); base.AddControl(languageSpanish); base.AddControl(languageEnglish); base.AddControl(textLanguage); } else { flag = new Flag(new Vector3(1, 1, 0.01f), new Vector3(1.2f, 2, 1), EngineContent.GetTextureByName(Game.GameStrings.GetString("Title")), Layout.CalculateTotalLayout(new Rectangle(538, 79, 520, 140))); flag.Create(); Edit edit = new Edit(Layout.CalculateTotalLayout(new Rectangle(940, 612, 120, 40)), "edtName", Game.GameStrings.GetString("DefaultName")); Panel panel = new Panel(Layout.CalculateTotalLayout(new Rectangle(0, 0, 1280, 720)), "portada", Aligment.Left); Button button = new Button(Layout.CalculateTotalLayout(new Rectangle(1080, 612, 100, 40)), Game.GameStrings.GetString("Enter"), new MouseClick(base.EnterSetupScreen)); Label textInsertar = new Label(Game.GameStrings.GetString("InsertName"), Layout.CalculateLayoutXY(980, 574), Sprite.SpriteFont); FlagButton languageSpanish = new FlagButton(Layout.CalculateTotalLayout(new Rectangle(80, 596, 100, 50)), SelectSpanish, new Vector3(-5.55f, -5.1f, -15), Game.GameStrings.GetString("Spanish"), "espanna"); FlagButton languageEnglish = new FlagButton(Layout.CalculateTotalLayout(new Rectangle(200, 596, 100, 50)), SelectEnglish, new Vector3(-3.6f, -5.1f, -15), Game.GameStrings.GetString("English"), "uk"); Label textLanguage = new Label(Game.GameStrings.GetString("SelectLanguage"), Layout.CalculateTotalLayout(new Rectangle(82, 574, 218, 20)), Sprite.SpriteFont, Aligment.Center); base.AddControl(panel); base.AddControl(textInsertar); base.AddControl(button); base.AddControl(edit); base.AddControl(languageSpanish); base.AddControl(languageEnglish); base.AddControl(textLanguage); } }
public new void Create() { this.textureID = EngineContent.GetTextureByName("misil"); base.Create(); }
public new void Create() { textureID = EngineContent.GetTextureByName("sun"); sunGlow = EngineContent.GetTextureByName("sunGlow"); }
public void AddText(string text, int time, SpriteFont font, Color textColor, int half) { screens[(int)selectedScreen].AddControl(new Message(text, time, font, textColor, half, EngineContent.GetTextureByName("message"))); }
public MisileSmoke(Vector3 pCoord) { position = pCoord; base.scale = 0.5f; base.textureID = EngineContent.GetTextureByName("smoke"); }
public void AddCursor(ECursor cname, string cursorName) { cursors.Add(cname, EngineContent.GetTextureByName(cursorName)); }
public EngineContent ToSceneNode() { string name = Path.GetFileNameWithoutExtension(this.name); VertexDescriptor vd = EngineResources.CreateVertexDescriptor <ModelVertex>(); List <Tuple <string, Mesh> > meshes = new List <Tuple <string, Mesh> >(groups.Count); List <SceneNode> nodes = new List <SceneNode>(groups.Count); MeshMaterial[] sceneMaterials = new MeshMaterial[materials.Count]; Dictionary <string, MeshMaterial> materialLookup = new Dictionary <string, MeshMaterial>(); for (int i = 0; i < materials.Values.Count; i++) { var sourceMat = materials.Values[i]; sceneMaterials[i] = new MeshMaterial { Name = name + "_" + sourceMat.Name, Surface = sourceMat.ToSurfaceInfo(), NormalMap = sourceMat.NormalMap, DiffuseMap = sourceMat.Textures != null && sourceMat.Textures.Length > 0 ? sourceMat.Textures[0] : null }; materialLookup.Add(sceneMaterials[i].Name, sceneMaterials[i]); } List <MeshLayer> layers = new List <MeshLayer>(); //register for each positionIndex in the source container the List of the destination vertices that contain that position Dictionary <int, List <VertexInfo> > lookup = new Dictionary <int, List <VertexInfo> >(); VertexInfo vi; ModelVertex v; List <ModelVertex> vertexes = new List <ModelVertex>(); uint[] indexes; #region Groups foreach (var g in groups) { List <MeshMaterial> meshMaterials = new List <MeshMaterial>(); Mesh mesh = new Mesh(vd: vd); mesh.Name = g.Name; indexes = new uint[g.FaceCount * 3]; int k = 0; #region Layers layers.Clear(); foreach (var layer in g.Layers) { int startVertex = int.MaxValue; int vertexCount = 0; MeshLayer meshLayer = new MeshLayer(); meshLayer.startIndex = k; meshLayer.primitiveCount = layer.Faces.Count; var mat = materialLookup[name + "_" + layer.MaterialName]; meshLayer.materialIndex = meshMaterials.IndexOf(mat); if (meshLayer.materialIndex < 0) { meshLayer.materialIndex = meshMaterials.Count; meshMaterials.Add(mat); } #region Faces foreach (var face in layer.Faces) { //for each vertex of the face create a new mesh vertex if the vertex if not yet in the mesh add it to the VertexBuffer //and create a new face in the IndexBuffer for (int i = 0; i < 3; i++) { //vi describe a new vertex vi = new VertexInfo() { PositionIndex = face.Vertexes[i].Position, NormalIndex = -1, TcIndex = -1 }; //if the vertex position is not in the VertexBuffer add it if (!lookup.ContainsKey(vi.PositionIndex)) { v = new ModelVertex(position: positions[vi.PositionIndex]); if ((vertexFormat & VertexFormat.Normal) == VertexFormat.Normal && face.Vertexes[i].Normal >= 0) { vi.NormalIndex = face.Vertexes[i].Normal; v.Normal = normals[vi.NormalIndex]; } if ((vertexFormat & VertexFormat.TexCoord) == VertexFormat.TexCoord && face.Vertexes[i].TexCoord >= 0) { vi.TcIndex = face.Vertexes[i].TexCoord; v.TexCoord = texCoords[vi.TcIndex]; } vi.VertexIndex = vertexes.Count; lookup.Add(vi.PositionIndex, new List <VertexInfo>() { vi }); vertexes.Add(v); vertexCount++; indexes[k] = (uint)vi.VertexIndex; } else { //else get the list of vertices that contains that position and // if new vertex is not in the list create the new destination vertex and add it to the VertexBuffer var vlist = lookup[vi.PositionIndex]; if ((vertexFormat & VertexFormat.Normal) == VertexFormat.Normal) { vi.NormalIndex = face.Vertexes[i].Normal; } if ((vertexFormat & VertexFormat.TexCoord) == VertexFormat.TexCoord) { vi.TcIndex = face.Vertexes[i].TexCoord; } int index = vlist.FindIndex(x => x.Equals(vi)); if (index < 0) { v = new ModelVertex(positions[vi.PositionIndex]); if (vi.NormalIndex >= 0) { v.Normal = normals[vi.NormalIndex]; } if (vi.TcIndex >= 0) { v.TexCoord = texCoords[vi.TcIndex]; } vi.VertexIndex = vertexes.Count; indexes[k] = (uint)vi.VertexIndex; vertexCount++; vertexes.Add(v); vlist.Add(vi); } else { //else the vertex is already in the VertexBuffer so create add the vertex index //to the indexbuffer vi = vlist[index]; indexes[k] = (uint)vi.VertexIndex; } } k++; startVertex = Math.Min(startVertex, vi.VertexIndex); } } #endregion Faces meshLayer.startVertex = startVertex; meshLayer.vertexCount = vertexCount; layers.Add(meshLayer); } #endregion Layers mesh.SetLayers(layers.ToArray()); var data = vertexes.ToArray(); mesh.CreateVertexBuffer(data); if (mesh.VertexCount < ushort.MaxValue) { mesh.CreateIndexBuffer(indexes.Select(x => (ushort)x).ToArray()); } else { mesh.CreateIndexBuffer(indexes); } mesh.DefragmentLayers(); mesh.BlendLayers(); if ((vertexFormat & VertexFormat.Normal) != VertexFormat.Normal) { mesh.ComputeNormals(); } if ((vertexFormat & VertexFormat.TexCoord) != VertexFormat.TexCoord) { mesh.ComputeTextureCoords(CoordMappingType.Spherical); } mesh.ComputeTangents(); nodes.Add(new SceneNode <MeshInstance>(g.Name, new MeshInstance(meshMaterials.ToArray(), mesh))); vertexes.Clear(); //test lookup.Clear(); } #endregion QuadTreeSceneNode node = new QuadTreeSceneNode(name, 10); node.Context = new TechniqueRenderContext(node); foreach (var item in nodes) { node.Add(item); } node.UpdateLayout(); var package = new EngineContent(name); package.Providers.AddRange(sceneMaterials); package.Providers.Add(node); return(package); }