Downloadpercent Δημοσ. 29 Ιουλίου 2012 Δημοσ. 29 Ιουλίου 2012 (επεξεργασμένο) Αν έχεις 3,4 τέρατα δεν υπάρχει θέμα, όταν όμως έχεις 200? πως γίνεται η διαχείρηση τους, δηλαδή - σε πoιο κάνουμε Attack από τα 200 - πoιο πρέπει να πεθάνει από τα 200 - πoιο από τα 200 είναι ο στόχος μας... με λίστες γίνεται η διαχείριση? ένα πρόχειρο παράδειγμα: > List<Model> Pigs = new List(); //............. // This one delete objects where you are above-in // This way is bad because every time check all in list but anyway... for (int i=1; i < Pigs.Count; i++) { if(Math.Abs(Pigs[i].X - Pigs[i+1].X) < 2 && Math.Abs(Pigs[i].Y - Pigs[i+1].Y) < 2 && Math.Abs(Pigs[i].Z - Pigs[i+1].Z) < 2 ) { // i+1 is target, so we remove target not self Pigs.RemoveAt(i+1) } } //.......... protected ovveride Draw(GameTime gameTime) { //..... // This one draw objects from list D3D.DrawThemFromList(Models, Positions, CPosition, AspectRatio); } class Draw3D { public Draw3D() { } public void DrawThemFromList(List<Models> LM, List<Vector3> LP, Vector3 Camera, float AspectRatio) { for (int i=0; i<LM.Count; i++) { //...... foreach(ModelMesh M in LM[i].Meshes) { //....... } } } }//Class Επεξ/σία 29 Ιουλίου 2012 από Downloadpercent 1
georgemarios Δημοσ. 29 Ιουλίου 2012 Δημοσ. 29 Ιουλίου 2012 Δε είμαι σίγουρος πως καταλαβαινω την ερώτηση. Αν ειμαι παίχτης (άνθρωπος), επιλέγω όποιο θέλω, σωστά; Πλακώνομαι μαζί του και αν το νικήσω πεθαίνει. Αν η ερώτηση είναι πως επιλέγει ένα τέρας (ή καλύτερα ενα ΑΙ entity) τον στόχο του, αυτό ειναι δικό σου θέμα. Η πιο απλή/προφανής λύση είναι να lock-αρει τον πιο κοντινό του στόχο (μετράς την απόσταση του απο ολους τους πιθανους στόχους και παίρνεις τη μικρότερη). Αν το θες λιγο πιο "έξυπνο", μπορεις να τον κάνεις να τσεκαρει πιο παιχτης είναι πιο επικύνδυνος (κάτι σαν το aggro value του wow) ή να τον κανεις να έχει προτιμηση σε συγκεκριμενες ρατσες/κλάσεις (πχ να εχει στοχο να καθαρισει πρωτα τους spellcasters). Βασικα, κάνεις ότι θεωρεις εσυ διασκεδαστικοτερο για το παιχνιδι σου.
javavall Δημοσ. 29 Ιουλίου 2012 Δημοσ. 29 Ιουλίου 2012 (επεξεργασμένο) Το σκεπτικό είναι το ίδιο με την περιγραφή που έδωσε ο @georgemarios στο προηγούμενο θέμα σου. Κάντο όπως σε βολεύει για αρχή και βλέπεις. Οι λίστες για πολλά τέρατα νομίζω πως δεν θα είναι αποδοτικές. Ίσως hash tables. Επεξ/σία 29 Ιουλίου 2012 από javavall
Downloadpercent Δημοσ. 29 Ιουλίου 2012 Μέλος Δημοσ. 29 Ιουλίου 2012 Βασικά, είναι ο παίχτης και μπροστά του έχει 5 τέρατα σε διαφορετικά σημεία αλλά κοντά το ένα με το άλλο ένας τρόπος είναι να κλικαρει με το ποντίκι και να το εντοπίσει, λοιπόν αυτό που θέλω είναι να το "lock"arw και ότι ενέργεια κάνω να γίνεται σε αυτό, και όταν είναι να πεθάνει , να πεθάνει αυτό και όχι το δίπλα ξέρω γω (φαντάσου να πλακώνεσαι με τον Β και να πέφτει ο Γ) ο παραπάνω ψευδοκώδικας, κάνει Draw τα μοντέλα από μια λίστα, το σκεπτικό μου είναι όταν ένα πεθαίνει να το βγάλουμε από τη λίστα άρα δεν θα γίνεται Draw ...
georgemarios Δημοσ. 29 Ιουλίου 2012 Δημοσ. 29 Ιουλίου 2012 Η βασική ίδεα είναι πως τα τερατα ειναι σε κάποιο έιδος λιστας, ας πουμε ενα List. Κάπου έχεις μια μεταβλητη που κρατά ενα reference στο επιλεγμενο τερας. Μερικά παραδείγματα > List<Monsters> monsterList = ..... Monster selectedMonster = null; // null means no monster selected ... // select the second monster selectedMonster = monsterList[1]; ... // deselect monster selectedMonster = null; ... // kill selected monster selectedMonster.Kill(); // check 5th monster is selected if (monsterList[4] == selectedMonster) // is selected
παπι Δημοσ. 30 Ιουλίου 2012 Δημοσ. 30 Ιουλίου 2012 Βασικά, είναι ο παίχτης και μπροστά του έχει 5 τέρατα σε διαφορετικά σημεία αλλά κοντά το ένα με το άλλο ένας τρόπος είναι να κλικαρει με το ποντίκι και να το εντοπίσει, λοιπόν αυτό που θέλω είναι να το "lock"arw και ότι ενέργεια κάνω να γίνεται σε αυτό, και όταν είναι να πεθάνει , να πεθάνει αυτό και όχι το δίπλα ξέρω γω (φαντάσου να πλακώνεσαι με τον Β και να πέφτει ο Γ) ο παραπάνω ψευδοκώδικας, κάνει Draw τα μοντέλα από μια λίστα, το σκεπτικό μου είναι όταν ένα πεθαίνει να το βγάλουμε από τη λίστα άρα δεν θα γίνεται Draw ... Το πας λαθος. Η κλαση model ειναι για μεταφορα resources απο σκληρο σε vram. Θα φτιαξεις μια κλαση ή μια ομαδα κλασεων που θα διαχειρηζεται την κατασταση του καθε object μεσα στο game (object != model!!) Πχ αυτο το project http://create.msdn.com/en-US/education/catalog/sample/skinned_model Θα στο κανω να εχει 5 τυπους που 1 θα παιζει το ρολο του χαρακτηρα και οι αλλοι τα τερατα ξερω γω. Ο δε χαρακτηρας οταν κοιταει καποιον τοτε ο δε κοιταζομενος (τι εγραψα παλι) θα γινεται μικρος, αυτο θα ειναι το σουπερ σκιλ Για αρχη θες μια κλαση που θα εχει τα καποιες πληροφοριες για το object πχ εγω θελω ενα ονομα για το object ενα ονομα για το ποιον κοιταω (εχω target), το που ειμαι, μια συναρτηση για ναπαω καπου μια συναρτηση για να κοιταξω καποιων > public class ModelTransformation { public string MyName { get; set; } public string ImLooking { get; set; } public Matrix Scaling { get; set; } public Matrix Rotation { get; set; } public Matrix Translate { get; set; } public Matrix SRT { get { return Scaling * Rotation * Translate; } } public Vector3 MyPosition { get { return Vector3.Transform(Vector3.Zero, SRT); } } public void LookAt(Vector3 pos) { if (MyPosition == pos) return; Vector3 myPos = Vector3.Transform(Vector3.Zero, SRT); Vector3 right = Vector3.Cross(Vector3.Up, myPos - pos); right = Vector3.Normalize(right); Vector3 back = Vector3.Cross(right, Vector3.Up); back = Vector3.Normalize(back); Vector3 up = Vector3.Cross(back, right); Rotation = new Matrix( right.X, right.Y, right.Z, 0, up.X, up.Y, up.Z, 0, back.X, back.Y, back.Z, 0, 0, 0, 0, 1); } public void GoTo(Vector3 pos) { Translate = Matrix.CreateTranslation(pos); } } Αυτη η κλαση μου ειναι το core του object ας πουμε. Τωρα για να φτιαξω 5 τυπους θα παω στο παραπανω project στην function LoadContent και θα βαλω τα παρακαω στο κατω μερος > protected override void LoadContent() { // Load the model. currentModel = Content.Load<Model>("dude"); // Look up our custom skinning information. SkinningData skinningData = currentModel.Tag as SkinningData; if (skinningData == null) throw new InvalidOperationException ("This model does not contain a SkinningData tag."); // Create an animation player, and start decoding an animation clip. animationPlayer = new AnimationPlayer(skinningData); AnimationClip clip = skinningData.AnimationClips["Take 001"]; animationPlayer.StartClip(clip); models.Add(new ModelTransformation { MyName = "me", Scaling = Matrix.CreateScale(0.7f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models.Add(new ModelTransformation { MyName = "other1", Scaling = Matrix.CreateScale(0.5f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models.Add(new ModelTransformation { MyName = "other2", Scaling = Matrix.CreateScale(0.5f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models.Add(new ModelTransformation { MyName = "other3", Scaling = Matrix.CreateScale(0.5f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models.Add(new ModelTransformation { MyName = "other4", Scaling = Matrix.CreateScale(0.5f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models[1].GoTo(new Vector3(50.0f, 0.0f, -30.0f)); models[2].GoTo(new Vector3(50.0f, 0.0f, 30.0f)); models[3].GoTo(new Vector3(-50.0f, 0.0f, -30.0f)); models[4].GoTo(new Vector3(-50.0f, 0.0f, 30.0f)); } Τωρα το πρεπει να τα ζωγραφισω παω στο Draw και κανω αυην την αλλαγη > protected override void Draw(GameTime gameTime) { GraphicsDevice device = graphics.GraphicsDevice; device.Clear(Color.CornflowerBlue); Matrix[] bones = animationPlayer.GetSkinTransforms(); // Compute camera matrices. view = /*Matrix.CreateTranslation(0, -40, 0) */ Matrix.CreateRotationY(MathHelper.ToRadians(cameraRotation)) * Matrix.CreateRotationX(MathHelper.ToRadians(cameraArc)) * Matrix.CreateLookAt(new Vector3(0, 0, -cameraDistance), new Vector3(0, 0, 0), Vector3.Up); projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, device.Viewport.AspectRatio, 1, 10000); /* // Render the skinned mesh. foreach (ModelMesh mesh in currentModel.Meshes) { foreach (SkinnedEffect effect in mesh.Effects) { effect.SetBoneTransforms(bones); effect.View = view; effect.Projection = projection; effect.EnableDefaultLighting(); effect.SpecularColor = new Vector3(0.25f); effect.SpecularPower = 16; } mesh.Draw(); } */ foreach (ModelTransformation model in models) { foreach (ModelMesh mesh in currentModel.Meshes) { foreach (SkinnedEffect effect in mesh.Effects) { effect.SetBoneTransforms(bones); effect.View = model.SRT * view; effect.Projection = projection; effect.EnableDefaultLighting(); effect.SpecularColor = new Vector3(0.25f); effect.SpecularPower = 16; // kanto me sirma gia na ksexorizei if (model.MyName == "me") this.GraphicsDevice.RasterizerState = wireframeRasterizer; else this.GraphicsDevice.RasterizerState = solidRasterizer; } mesh.Draw(); } } base.Draw(gameTime); } Εβαλα μια παραπανω for με σκοπο να ζωγραφισω το ιδιο πραγμα σε διαφορετικο σημειο και κατασταση (μπορεις να βαλεις και το animation στην κλαση του ModelTransformation ωστε το καθε object να εχει συγκεκριμενο animation αλλα εμενα δεν με νοιαζει αυτο) αυτο γινεται με τον πολλαπλασιασμου του view με το SRT (scaling rotation translation) του καθε object. Ως εδω εχει 5 τυπους να περπατανε προς το πουθενα. Τωρα θες ενα collision detect εγω θα βαλω μονο για mouse pick με Ray > void UpdatePlayerMove() { if (mouseStateCur.LeftButton == ButtonState.Pressed && mouseStatePrev.LeftButton == ButtonState.Released) { Vector3 near, far, nearPoint, farPoint,direction; near = new Vector3(mouseStateCur.X, mouseStateCur.Y, 0.0f); far = near; far.Z = 1.0f; nearPoint = GraphicsDevice.Viewport.Unproject(near, projection, view, Matrix.Identity); farPoint = GraphicsDevice.Viewport.Unproject(far, projection, view, Matrix.Identity); direction = farPoint - nearPoint; direction.Normalize(); Ray ray = new Ray(nearPoint, direction); Dictionary<string, float> closerObject = new Dictionary<string, float>(); foreach (var item in models) { foreach (var mesh in currentModel.Meshes) { float? f; if ((f = ray.Intersects(mesh.BoundingSphere.Transform(item.SRT))) != null) closerObject[item.MyName] = f.Value; } } var me = models.Where(w => w.MyName == "me").First(); if (closerObject.Count != 0) { var clickedObject = models.Where(w => w.MyName == closerObject.First().Key).First(); me.LookAt(clickedObject.MyPosition); me.ImLooking = clickedObject.MyName; } else { //den vlepw kanenan me.LookAt(new Vector3(0.0f, 0.0f, -1.0f)); me.ImLooking = string.Empty; } } } Εδω μπορεις να κανεις και κανα googling αλλα η βασικη ιδια ειναι οτι πεταμε μια ακτινα απο την οθονη προς τα μεσα και οτι πετυχουμε το βαζουμε σε ενα map με κλειδι την αποσταση και value το ονομα του object που πετυχαμε. Εφοσον περασει η ακτινα απο ολα τα object τοτε παιρνουμε αυτο που πετυχαμε πρωτο (ψεμα, αυτο που ειναι πιο κοντα στην οθονη δηλαδη αυτο με το μικροτερο Key το οποιο ειναι και πρωτο για αυτονοητους λογους) Τελος φτιαχνω και μια function SuperGameLogic η οποια θα εφαρμοζει την ΚΑΤΑΡΑ μας !!! > void SuperGameLogic() { var me = models.Where(w => w.MyName == "me").First(); if (string.IsNullOrEmpty(me.ImLooking)) me.ImLooking = ""; foreach (var item in models) { if (item.MyName == me.ImLooking) item.Scaling = Matrix.CreateScale(0.4f); else item.Scaling = Matrix.CreateScale(0.7f); } } Εδω πολυ απλα εφαρμοζουμε scaling 40% σε αυτο που κοιταω (εχω target) και 70% σε αυτα που δεν κοιταω. Θα μπορουσες να φτιαξεις μια κλαση που να διαχειριζεται αυτες τις σχεσεις, μπορει αντι για scaling να εχεις αλλη μεταβλητη πχ HP MP κλπ κλπ κλπ κλπ κλπ. Εδω το αποτελεσμα http://www.youtube.com/watch?v=NrpWPwupWWg Εδω ολες οι αλλαγες στο αρχειο SkinnedModel.cs > #region File Description //----------------------------------------------------------------------------- // SkinningSample.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using SkinnedModel; using System.Collections.Generic; using System.Linq; #endregion namespace SkinningSample { public class ModelTransformation { public string MyName { get; set; } public string ImLooking { get; set; } public Matrix Scaling { get; set; } public Matrix Rotation { get; set; } public Matrix Translate { get; set; } public Matrix SRT { get { return Scaling * Rotation * Translate; } } public Vector3 MyPosition { get { return Vector3.Transform(Vector3.Zero, SRT); } } public void LookAt(Vector3 pos) { if (MyPosition == pos) return; Vector3 myPos = Vector3.Transform(Vector3.Zero, SRT); Vector3 right = Vector3.Cross(Vector3.Up, myPos - pos); right = Vector3.Normalize(right); Vector3 back = Vector3.Cross(right, Vector3.Up); back = Vector3.Normalize(back); Vector3 up = Vector3.Cross(back, right); Rotation = new Matrix( right.X, right.Y, right.Z, 0, up.X, up.Y, up.Z, 0, back.X, back.Y, back.Z, 0, 0, 0, 0, 1); } public void GoTo(Vector3 pos) { Translate = Matrix.CreateTranslation(pos); } } /// <summary> /// Sample game showing how to display skinned character animation. /// </summary> public class SkinningSampleGame : Microsoft.Xna.Framework.Game { #region Fields GraphicsDeviceManager graphics; KeyboardState currentKeyboardState = new KeyboardState(); GamePadState currentGamePadState = new GamePadState(); MouseState mouseStateCur, mouseStatePrev; RasterizerState solidRasterizer = new RasterizerState { FillMode = Microsoft.Xna.Framework.Graphics.FillMode.Solid }; RasterizerState wireframeRasterizer = new RasterizerState { FillMode = Microsoft.Xna.Framework.Graphics.FillMode.WireFrame }; Model currentModel; AnimationPlayer animationPlayer; List<ModelTransformation> models = new List<ModelTransformation>(); Matrix projection, view; float cameraArc = 0; float cameraRotation = 0; float cameraDistance = 100; #endregion #region Initialization protected override void Initialize() { this.IsMouseVisible = true; base.Initialize(); } public SkinningSampleGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; #if WINDOWS_PHONE // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); graphics.IsFullScreen = true; #endif } /// <summary> /// Load your graphics content. /// </summary> protected override void LoadContent() { // Load the model. currentModel = Content.Load<Model>("dude"); // Look up our custom skinning information. SkinningData skinningData = currentModel.Tag as SkinningData; if (skinningData == null) throw new InvalidOperationException ("This model does not contain a SkinningData tag."); // Create an animation player, and start decoding an animation clip. animationPlayer = new AnimationPlayer(skinningData); AnimationClip clip = skinningData.AnimationClips["Take 001"]; animationPlayer.StartClip(clip); models.Add(new ModelTransformation { MyName = "me", Scaling = Matrix.CreateScale(0.7f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models.Add(new ModelTransformation { MyName = "other1", Scaling = Matrix.CreateScale(0.5f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models.Add(new ModelTransformation { MyName = "other2", Scaling = Matrix.CreateScale(0.5f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models.Add(new ModelTransformation { MyName = "other3", Scaling = Matrix.CreateScale(0.5f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models.Add(new ModelTransformation { MyName = "other4", Scaling = Matrix.CreateScale(0.5f), Rotation = Matrix.Identity, Translate = Matrix.Identity }); models[1].GoTo(new Vector3(50.0f, 0.0f, -30.0f)); models[2].GoTo(new Vector3(50.0f, 0.0f, 30.0f)); models[3].GoTo(new Vector3(-50.0f, 0.0f, -30.0f)); models[4].GoTo(new Vector3(-50.0f, 0.0f, 30.0f)); } #endregion #region Update and Draw /// <summary> /// Allows the game to run logic. /// </summary> protected override void Update(GameTime gameTime) { HandleInput(); UpdateCamera(gameTime); UpdatePlayerMove(); SuperGameLogic(); animationPlayer.Update(gameTime.ElapsedGameTime, true, Matrix.Identity); base.Update(gameTime); } void SuperGameLogic() { var me = models.Where(w => w.MyName == "me").First(); if (string.IsNullOrEmpty(me.ImLooking)) me.ImLooking = ""; foreach (var item in models) { if (item.MyName == me.ImLooking) item.Scaling = Matrix.CreateScale(0.4f); else item.Scaling = Matrix.CreateScale(0.7f); } } /// <summary> /// This is called when the game should draw itself. /// </summary> protected override void Draw(GameTime gameTime) { GraphicsDevice device = graphics.GraphicsDevice; device.Clear(Color.CornflowerBlue); Matrix[] bones = animationPlayer.GetSkinTransforms(); // Compute camera matrices. view = /*Matrix.CreateTranslation(0, -40, 0) */ Matrix.CreateRotationY(MathHelper.ToRadians(cameraRotation)) * Matrix.CreateRotationX(MathHelper.ToRadians(cameraArc)) * Matrix.CreateLookAt(new Vector3(0, 0, -cameraDistance), new Vector3(0, 0, 0), Vector3.Up); projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, device.Viewport.AspectRatio, 1, 10000); /* // Render the skinned mesh. foreach (ModelMesh mesh in currentModel.Meshes) { foreach (SkinnedEffect effect in mesh.Effects) { effect.SetBoneTransforms(bones); effect.View = view; effect.Projection = projection; effect.EnableDefaultLighting(); effect.SpecularColor = new Vector3(0.25f); effect.SpecularPower = 16; } mesh.Draw(); } */ foreach (ModelTransformation model in models) { foreach (ModelMesh mesh in currentModel.Meshes) { foreach (SkinnedEffect effect in mesh.Effects) { effect.SetBoneTransforms(bones); effect.View = model.SRT * view; effect.Projection = projection; effect.EnableDefaultLighting(); effect.SpecularColor = new Vector3(0.25f); effect.SpecularPower = 16; // kanto me sirma gia na ksexorizei if (model.MyName == "me") this.GraphicsDevice.RasterizerState = wireframeRasterizer; else this.GraphicsDevice.RasterizerState = solidRasterizer; } mesh.Draw(); } } base.Draw(gameTime); } #endregion #region Handle Input /// <summary> /// Handles input for quitting the game. /// </summary> private void HandleInput() { currentKeyboardState = Keyboard.GetState(); currentGamePadState = GamePad.GetState(PlayerIndex.One); mouseStateCur = Mouse.GetState(); if (mouseStatePrev == null) mouseStatePrev = mouseStateCur; // Check for exit. if (currentKeyboardState.IsKeyDown(Keys.Escape) || currentGamePadState.Buttons.Back == ButtonState.Pressed) { Exit(); } } void UpdatePlayerMove() { if (mouseStateCur.LeftButton == ButtonState.Pressed && mouseStatePrev.LeftButton == ButtonState.Released) { Vector3 near, far, nearPoint, farPoint,direction; near = new Vector3(mouseStateCur.X, mouseStateCur.Y, 0.0f); far = near; far.Z = 1.0f; nearPoint = GraphicsDevice.Viewport.Unproject(near, projection, view, Matrix.Identity); farPoint = GraphicsDevice.Viewport.Unproject(far, projection, view, Matrix.Identity); direction = farPoint - nearPoint; direction.Normalize(); Ray ray = new Ray(nearPoint, direction); Dictionary<string, float> closerObject = new Dictionary<string, float>(); foreach (var item in models) { foreach (var mesh in currentModel.Meshes) { float? f; if ((f = ray.Intersects(mesh.BoundingSphere.Transform(item.SRT))) != null) closerObject[item.MyName] = f.Value; } } var me = models.Where(w => w.MyName == "me").First(); if (closerObject.Count != 0) { var clickedObject = models.Where(w => w.MyName == closerObject.First().Key).First(); me.LookAt(clickedObject.MyPosition); me.ImLooking = clickedObject.MyName; } else { //den vlepw kanenan me.LookAt(new Vector3(0.0f, 0.0f, -1.0f)); me.ImLooking = string.Empty; } } } /// <summary> /// Handles camera input. /// </summary> private void UpdateCamera(GameTime gameTime) { float time = (float)gameTime.ElapsedGameTime.TotalMilliseconds; // Check for input to rotate the camera up and down around the model. if (currentKeyboardState.IsKeyDown(Keys.Up) || currentKeyboardState.IsKeyDown(Keys.W)) { cameraArc += time * 0.1f; } if (currentKeyboardState.IsKeyDown(Keys.Down) || currentKeyboardState.IsKeyDown(Keys.S)) { cameraArc -= time * 0.1f; } cameraArc += currentGamePadState.ThumbSticks.Right.Y * time * 0.25f; // Limit the arc movement. if (cameraArc > 90.0f) cameraArc = 90.0f; else if (cameraArc < -90.0f) cameraArc = -90.0f; // Check for input to rotate the camera around the model. if (currentKeyboardState.IsKeyDown(Keys.Right) || currentKeyboardState.IsKeyDown(Keys.D)) { cameraRotation += time * 0.1f; } if (currentKeyboardState.IsKeyDown(Keys.Left) || currentKeyboardState.IsKeyDown(Keys.A)) { cameraRotation -= time * 0.1f; } cameraRotation += currentGamePadState.ThumbSticks.Right.X * time * 0.25f; // Check for input to zoom camera in and out. if (currentKeyboardState.IsKeyDown(Keys.Z)) cameraDistance += time * 0.25f; if (currentKeyboardState.IsKeyDown(Keys.X)) cameraDistance -= time * 0.25f; cameraDistance += currentGamePadState.Triggers.Left * time * 0.5f; cameraDistance -= currentGamePadState.Triggers.Right * time * 0.5f; // Limit the camera distance. if (cameraDistance > 500.0f) cameraDistance = 500.0f; else if (cameraDistance < 10.0f) cameraDistance = 10.0f; if (currentGamePadState.Buttons.RightStick == ButtonState.Pressed || currentKeyboardState.IsKeyDown(Keys.R)) { cameraArc = 0; cameraRotation = 0; cameraDistance = 100; } } #endregion } #region Entry Point /// <summary> /// The main entry point for the application. /// </summary> static class Program { static void Main() { using (SkinningSampleGame game = new SkinningSampleGame()) { game.Run(); } } } #endregion }
Downloadpercent Δημοσ. 30 Ιουλίου 2012 Μέλος Δημοσ. 30 Ιουλίου 2012 Thanks, καλή φάση.. θα το κοιτάξω μετά...
Προτεινόμενες αναρτήσεις
Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε
Πρέπει να είστε μέλος για να αφήσετε σχόλιο
Δημιουργία λογαριασμού
Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!
Δημιουργία νέου λογαριασμούΣύνδεση
Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.
Συνδεθείτε τώρα