evil M2s ... menu

User Tag List

Thread: evil M2s ...

Results 1 to 3 of 3
  1. #1
    hobbienoobie's Avatar Member
    Reputation
    1
    Join Date
    Jun 2009
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    evil M2s ...

    I have been using the program posted previously by DarrenSmith0125: http://www.mmowned.com/forums/bots-programs/251315-source-pathing-3d-viewer.html. I altered the original code to act as a server for inter-process calls for pathing-- works fine for me except M2s are screwed up. I have an in game collision sensor for "near" pathing to deal with some of that, but you can imagine the kinds of headaches that can create with M2 heavy rooms/regions... So, for all intents and purposes it works-- except for the M2s which it mis-assigns (the original code includes a comment about how it's not working). I've spent quite some time looking at it and trying out various implementations of quaternions in the code, but I always get either a mis-alignment or a total mess. The M2s are converted here (mostly removed because they are buggy and not worth people mistaking them for anything correct):

    (FIXES IN NEXT RESPONSE TO THREAD)

    Code:
            
            private static void AddTrianglesGroupDoodads2(TriangleCollection s, ModelInstance mi, Vec3D world_dir, Vec3D world_off, float rot)
            {
                ... removed-- can be found in  http://www.mmowned.com/forums/bots-programs/251315-source-pathing-3d-viewer.html.
                ...  corrected code found below.
                
                }
            }
    The above routine is called from the loop at the end of this WMO routine:
    Code:
         private static void AddTriangles(TriangleCollection s, WMOInstance wi)
            {
                ... removed-- can be found in  http://www.mmowned.com/forums/bots-programs/251315-source-pathing-3d-viewer.html.
                ...  corrected code found below.
            }
    Last edited by hobbienoobie; 03-03-2010 at 01:42 AM.

    evil M2s ...
  2. #2
    hobbienoobie's Avatar Member
    Reputation
    1
    Join Date
    Jun 2009
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I figured it out. For the two routines I mentioned above as problematic, I had to do a a fair amount of testing to get the M2s right, but the rewritten routines that work are below.

    Pic on top is Dalaran (I randomized the colors of the vertice M2s/wmos etc. to more readily check orientations of things). Below is a "solid" view (4 colors are rather limiting... and I don't have time to write a sophisticated shader). M2s are all in the right place and orientation.

    Program now:

    1. Accepts inter-process calls from bots (1-> 10 bots), containing zone request, From/To coords.
    2. Batches the requests, does an A* path search.
    3. Returns path to appropriate bot via inter-process.


    [IMG][/IMG]

    I did the following to the rewritten routines:
    1. Rewrite the quaternions,
    2. Added in a missing WMO transform to the M2s.
    3. Added a ToAxisAngle routine for the quaternion transformations.

    Code:
            private static void AddTriangles(TriangleCollection s, WMOInstance wi)
            {
                float dx = wi.pos.X;
                float dy = wi.pos.Y;
                float dz = wi.pos.Z;
    
                float dir_x = wi.dir.Z;
                float dir_y = wi.dir.Y - 90;
                float dir_z = -wi.dir.X;
    
                var newrot = new Vector3();
                newrot.X = wi.dir.Z;
                newrot.Y = -wi.dir.X;
                newrot.Z = wi.dir.Y;
    
                WMO wmo = wi.wmo;
    
                foreach (var g in wmo.groups)
                {
                    int[] vertices = new int[g.nVertices];
    
                    for (int i = 0; i < g.nVertices; i++)
                    {
                        int off = i*3;
    
                        float x = g.vertices[off];
                        float y = g.vertices[off + 2];
                        float z = g.vertices[off + 1];
    
                        rotate(z, y, dir_x, out z, out y);
                        rotate(x, y, dir_z, out x, out y);
                        rotate(x, z, dir_y, out x, out z);
    
                        float xx = x + dx;
                        float yy = y + dy;
                        float zz = -z + dz;
    
                        float finalx = ChunkReader.ZEROPOINT - zz;
                        float finaly = ChunkReader.ZEROPOINT - xx;
                        float finalz = yy;
    
                        vertices[i] = s.AddVertex(finalx, finaly, finalz);
    
                    }
                    
                    for (int i = 0; i < g.nTriangles; i++)
                    {
                        int off = i*3;
                        int i0 = vertices[g.triangles[off]];
                        int i1 = vertices[g.triangles[off + 1]];
                        int i2 = vertices[g.triangles[off + 2]];
    
                        int t = s.AddTriangle(i0, i1, i2, ChunkedTriangleCollection.TriangleFlagObject);
                    }
                }
    
                int doodadset = wi.doodadset;
                if (doodadset < wmo.nDoodadSets)
                {
                    uint firstDoodad = wmo.doodads[doodadset].firstInstance;
                    uint nDoodads = wmo.doodads[doodadset].nInstances;
    
                    for (uint i = 0; i < nDoodads; i++)
                    {
                        uint d = firstDoodad + i;
                        ModelInstance mi = wmo.doodadInstances[d];
                        if (mi != null)
                            AddTrianglesGroupDoodads2(s, mi, wi, newrot); // Does not work :(
                    }
                }
            }
    
            // modd
            private static void AddTrianglesGroupDoodads2(TriangleCollection s, ModelInstance mi, WMOInstance wi, Vector3 newrot)
            {
                Model m = mi.model;
                if (m == null)
                    return;
               
                if (m.boundingTriangles == null)
                    return;
    
                // We got bounding stuff, that is better
                int nBoundingVertices = m.boundingVertices.Length / 3;
                int[] vertices = new int[nBoundingVertices];
    
                Microsoft.Xna.Framework.Quaternion quat = new Microsoft.Xna.Framework.Quaternion { X = mi.dir.Y, Y = mi.dir.Z, Z = mi.dir.X, W = mi.W };
                Vector3 vTemp = new Vector3();
                float fAngle;
    
                ToAxisAngle(quat, out vTemp, out fAngle);
    
                vTemp.Y = -vTemp.Y;
                Microsoft.Xna.Framework.Quaternion newquat = Microsoft.Xna.Framework.Quaternion.CreateFromAxisAngle(vTemp, fAngle);
                Vector3 vPos = new Vector3(mi.pos.X, mi.pos.Z, mi.pos.Y);
    
                scaleMatrix = Matrix.CreateScale(mi.sc);
                worldMatrix = scaleMatrix * Matrix.CreateFromQuaternion(newquat) * Matrix.CreateTranslation(vPos);
    
                var WmoWorld = new Matrix();
                var matWorld = new Matrix();
                var matTemp = new Matrix();
                var matRot = new Matrix();
    
                float ax = ChunkReader.ZEROPOINT - wi.pos.Z;
                float ay = ChunkReader.ZEROPOINT - wi.pos.X;
                float az = wi.pos.Y;
    
                matWorld = Matrix.CreateTranslation(ChunkReader.ZEROPOINT - wi.pos.Z, ChunkReader.ZEROPOINT - wi.pos.X, wi.pos.Y);
                matRot = Matrix.Identity;
                matTemp = Matrix.CreateRotationX((float)deg2rad(newrot.X));
                matRot = Matrix.Multiply(matRot, matTemp);
                matTemp = Matrix.CreateRotationY((float)deg2rad(newrot.Y));
                matRot = Matrix.Multiply(matRot, matTemp);
                matTemp = Matrix.CreateRotationZ((float)deg2rad(newrot.Z + 180));
                matRot = Matrix.Multiply(matRot, matTemp);
    
                WmoWorld = Matrix.Multiply(matRot, matWorld);
    
                var MatFinal = Matrix.Multiply(worldMatrix, WmoWorld);
                int count = 0;
                for (uint i = 0; i < nBoundingVertices; i++)
                {
                    count++;
                    uint off = i * 3;
                    float x = m.boundingVertices[off];
                    float z = m.boundingVertices[off + 2];
                    float y = m.boundingVertices[off + 1];
    
                    Vector3 rotatedVector = Vector3.Transform(new Vector3(-x, y, -z), MatFinal);
    
                    vertices[i] = s.AddVertex(rotatedVector.X, rotatedVector.Y, rotatedVector.Z);
                }
                int nBoundingTriangles = m.boundingTriangles.Length / 3;
                for (uint i = 0; i < nBoundingTriangles; i++)
                {
                    uint off = i * 3;
                    int v0 = vertices[m.boundingTriangles[off]];
                    int v1 = vertices[m.boundingTriangles[off + 1]];
                    int v2 = vertices[m.boundingTriangles[off + 2]];
                    s.AddTriangle(v0, v1, v2, ChunkedTriangleCollection.TriangleFlagModel );
                }
            }
    
            /// <summary>
            /// Convert this instance to an axis-angle representation.
            /// </summary>
            /// <returns>A Vector4 that is the axis-angle representation of this quaternion.</returns>
            public static void ToAxisAngle(Microsoft.Xna.Framework.Quaternion q, out Vector3 axis, out float angle)
            {
                if (q.W > 1.0f)
                    q.Normalize();
    
                Vector4 result = new Vector4();
    
                result.W = 2.0f * (float)Math.Acos(q.W); // angle
                float den = (float)Math.Sqrt(1.0 - q.W * q.W);
                if (den > 0.0001f)
                {
                    axis.X = q.X / den;
                    axis.Y = q.Y / den;
                    axis.Z = q.Z / den;
                }
                else
                {
                    // This occurs when the angle is zero. 
                    // Not a problem: just set an arbitrary normalized axis.
                    axis.X = 1;
                    axis.Y = 0;
                    axis.Z = 0;
                }
    
                angle = result.W;
            }

  3. #3
    misz's Avatar Member
    Reputation
    1
    Join Date
    Nov 2007
    Posts
    17
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Realy cool, Keep up the good work.

Similar Threads

  1. Evil Addon Website
    By Bobrick22 in forum World of Warcraft General
    Replies: 0
    Last Post: 05-07-2007, 05:17 PM
  2. Associate Professor Evil Kills All Beggars
    By Alkhara Majere in forum Screenshot & Video Showoff
    Replies: 0
    Last Post: 05-03-2007, 09:25 PM
  3. Black Stalion - Evil PVP warhorse
    By Blarkman11 in forum WoW ME Questions and Requests
    Replies: 3
    Last Post: 01-22-2007, 09:19 AM
  4. Very evil model editing..
    By dumbledrew in forum World of Warcraft Model Editing
    Replies: 7
    Last Post: 11-05-2006, 12:09 PM
  5. Need To Do Something Really Evil To A Player
    By Niko33 in forum World of Warcraft General
    Replies: 13
    Last Post: 10-15-2006, 03:35 PM
All times are GMT -5. The time now is 03:28 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search