Adding GameObjects to Recast - How do I transform? menu

User Tag List

Results 1 to 2 of 2
  1. #1
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding GameObjects to Recast - How do I transform?

    All-

    So I've been slowly collecting various game objects (think: mailboxes) to add to my R+D meshes, but of course I've come into a problem on the last step.

    I'm trying to use the matrix I saved with each game object to transform the vertices of the given model to the correct coordinates, but I don't know how to do this unfortunately.

    I'm basically adapting the transformVertices function that comes with wowmapper to accept the GO's matrix, but it's still not working correctly (the final vertices are definitely not the correct coords, by any means). Anyone have any ideas on what I'm doing wrong?

    Code:
    static void transformVerticesGO( float matrix[4][4], float scale, Vertices_t *vertices ) {
        static const float map_offset = 17066.0f + (2/3.0f);
        static const glm::vec3 map_pos( map_offset, 0, map_offset );
        static const glm::vec3 pos( matrix[3][0], matrix[3][1], matrix[3][2] );
      
        
        // create rotation matrix
        glm::mat4 rot_mtx = glm::mat4(matrix[0][0], matrix[0][1], matrix[0][2], matrix[0][3],   \
                                      matrix[1][0], matrix[1][1], matrix[1][2], matrix[1][3],   \
                                      matrix[2][0], matrix[2][1], matrix[2][2], matrix[2][3],   \
                                      matrix[3][0], matrix[3][1], matrix[3][2], matrix[3][3]);
        
        // transform vertices
        for ( Vertices_t::iterator vertex = vertices->begin(); vertex != vertices->end(); ++vertex ){
            glm::vec4 v4( *vertex, 0 );
            v4 = scale * rot_mtx * v4;
            *vertex = glm::vec3( v4 );
            *vertex += pos - map_pos;
        }
    }
    Thanks in advance!
    ~ Tanaris
    Last edited by Tanaris4; 03-07-2012 at 09:07 AM.
    https://tanaris4.com

    Adding GameObjects to Recast - How do I transform?
  2. #2
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it, MaiN is amazingly awesome... (Note: the PPCoords just helps me convert between wow coords and R+D coords)

    Code:
    static void Transform( float m[4][4], Vertices_t *vertices ){
        
        // transform vertices
        for ( Vertices_t::iterator vertex = vertices->begin(); vertex != vertices->end(); ++vertex ){
            
            float x = vertex->x * m[0][0] + vertex->y * m[1][0] + vertex->z * m[2][0] + m[3][0];
            float y = vertex->x * m[0][1] + vertex->y * m[1][1] + vertex->z * m[2][1] + m[3][1];
            float z = vertex->x * m[0][2] + vertex->y * m[1][2] + vertex->z * m[2][2] + m[3][2];
            
            PPCoords *pos = [[PPCoords alloc] initWithPGX:x Y:y Z:z];
            
            vertex->x = [pos x];
            vertex->y = [pos y];
            vertex->z = [pos z];
        }
    }
    https://tanaris4.com

Similar Threads

  1. Replies: 9
    Last Post: 12-17-2010, 06:13 PM
  2. How do i make an gameobject .go activated for always?
    By Creepfold in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 12-26-2007, 08:52 PM
  3. adding land? How would i?
    By unen in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 11-28-2007, 08:34 AM
  4. How do i make a Gameobject say Somthing
    By Illidan1 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 10-12-2007, 07:07 PM
  5. Antrix adding commands but how
    By 30480 in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 09-02-2007, 01:04 PM
All times are GMT -5. The time now is 06:47 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