• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

3D d3d model transform

M

Misty

Guest
Hi I recall seeing a script that allowed you to transform a model before adding it to the rendering pipeline, this way you dont have to use expensive transforms every time you want to randomize decorative objects. I thought I clicked download but I can't find it on my pc. Does anyone know what script/extension I'm talking about? I can't find it.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
I don't know what script you are talking about but you can pass points through a transformation matrix to get new point coordinates. This is a thing I did for a P3DC port at some point
Code:
struct p3dc_add_triangles_data {
    double x1, y1, z1;
    double x2, y2, z2;
    double x3, y3, z3;
};
///
struct p3dc_matrix {
    double xx, yx, zx, px;
    double xy, yy, zy, py;
    double xz, yz, zz, pz;
    double size;
};
export double p3dc_add_triangles_raw(p3dc_add_triangles_data* triangles_address, double num_triangles, p3dc_matrix* matrix_address) {
    int countvertex = 0;
    unsigned int tlid = temp_vector.size();
    int n = (int)num_triangles;
    //
    p3dc_matrix* m = matrix_address;
    double mxx = m->xx, myx = m->yx, mzx = m->zx, mpx = m->px;
    double mxy = m->xy, myy = m->yy, mzy = m->zy, mpy = m->py;
    double mxz = m->xz, myz = m->yz, mzz = m->zz, mpz = m->pz;
    //
    buffer buf(triangles_address);
    for (int i = 0; i < n; i++) {
        p3dc_add_triangles_data* tri = buf.ptr<p3dc_add_triangles_data>();
        double tx1 = tri->x1, ty1 = tri->y1, tz1 = tri->z1;
        double tx2 = tri->x2, ty2 = tri->y2, tz2 = tri->z2;
        double tx3 = tri->x3, ty3 = tri->y3, tz3 = tri->z3;
        mat(
// start interesting part
            tx1*mxx + ty1*myx + tz1*mzx + mpx,
            tx1*mxy + ty1*myy + tz1*mzy + mpy,
            tx1*mxz + ty1*myz + tz1*mzz + mpz,
// end interesting part
            tx2*mxx + ty2*myx + tz2*mzx + mpx,
            tx2*mxy + ty2*myy + tz2*mzy + mpy,
            tx2*mxz + ty2*myz + tz2*mzz + mpz,
            tx3*mxx + ty3*myx + tz3*mzx + mpx,
            tx3*mxy + ty3*myy + tz3*mzy + mpy,
            tx3*mxz + ty3*myz + tz3*mzz + mpz
        );
        buf.skip(sizeof(p3dc_add_triangles_data));
    }
    return (double)tlid;
}
 
M

Misty

Guest
Oh yeah its strange. I looked into the GMS2 compatibility scripts. Apparently when you try to load a d3d_model it somehow accesses all the points of the model and turns it into a buffer. I don't know how it does it, or if GM1.4 can access all the points of a model without having to directly code your own model importer from file.
 
Top