Author Topic: Model converter (.ZTP) -0.1 - WIP  (Read 1652 times)

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #45 on: July 26, 2018, 10:51:54 pm »
ikr

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #46 on: July 27, 2018, 01:21:14 am »
You can just say that your start and end keyframe are the same and just use a timer.
Like each frame ++, when it's over 30, you play the blinking animation, when it's over 38, you reset it to zero.

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #47 on: July 28, 2018, 04:45:45 pm »
I made a modification to the framerate code in the my_gamepad function so that it can go over 2.0, yet stay above 0:

Code: [Select]
    if (jo_is_pad1_key_pressed(PER_DGT_TL))
{SynchConst=(Sint8)1; framerate-=1;}

    else if (jo_is_pad1_key_pressed(PER_DGT_TR))
{SynchConst=(Sint8)2; framerate+=1;}
    else if
    (framerate<0)
    {framerate=0;}

The above negative integer prevention part of the code only seems to reset the framerate integer to 0 as soon as the left trigger is released. How would I remove the possibility of negative integers completely?

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #48 on: July 28, 2018, 06:41:31 pm »
Change the data type of framerate to unsigned instead of signed (Uint instead of Sint).
However, you should be working with the binary file instead of the header files, which use a different function to animate.
I'm pretty close to being entirely done with PCM sound (which is big yay), so maybe in the next few days I can get my own version of the animate function out.
[Yes, I really want my own version, since there could be computational implications different from what XL2 makes and I just want to see what those end up being]
« Last Edit: July 28, 2018, 06:44:30 pm by ponut64 »

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #49 on: July 29, 2018, 07:34:30 pm »
I've been trying to counter the distortion of displaying a texture on a triangular polygon, and it seems that there is another factor that comes in...
As an example, I made the Windows logo in Flash, and I skewed it on the X axis at 45 deg, because I was going to put it on an isosceles right triangle. However, when I ran the emulator, the texture seems to be distorted, with a curve to it...

May someone please tell me why this other distortion occurs?

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #50 on: July 29, 2018, 07:44:43 pm »
The Saturn uses distorted sprites only, so it will distort your image unless it's a perfect square. It doesn't use texture coordinates either, so the way to do it is to distort your triangle texture into a quad, which will then be rendered correctly. It's really just sprites and you distort them by playing with the 4 corners.

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #51 on: July 29, 2018, 07:58:49 pm »
So, it looks MUCH better, with your statement in mind!  8)

But why does the texture on the triangle still have this curved distortion?

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #52 on: July 29, 2018, 08:19:14 pm »
Because it interpolates the texture across the 4 vertices.
I would say that in your case gouraud shading would look better.
Another thing you can do is have a quad with transparent pixels, but it will be slower to render.

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #53 on: August 02, 2018, 03:02:51 am »
So variable interpolation was simpler than I expected. It's pretty coarse, but it works.

The struct is now like this:
Code: [Select]
typedef struct
{
bool uniform;
Uint8 arate[256];
    Uint16 currentFrm;
    Uint8 currentKeyFrm;
    Uint8 startFrm;
    Uint8 endFrm;
} animationControl;

Note arate, a 256 array of 8-bit values. The array size corresponds with the key frame data sizes.

For each frame of your animation area, if it is of non-uniform interpolation speed, you must define the arate for each key frame.

Code: [Select]
void	anim_defs(void)
{
forward.uniform = false;
forward.arate[0] = 1;
forward.arate[1] = 4;
forward.arate[2] = 1;
forward.arate[3] = 1;
forward.arate[4] = 4;
forward.arate[5] = 1;
forward.arate[6] = 1;
forward.currentKeyFrm = 0;
forward.startFrm = 1;
forward.endFrm=7;

left.uniform = false;
left.arate[8] = 2;
left.arate[9] = 1;
left.arate[10] = 1;
left.arate[11] = 2;
left.currentKeyFrm = 8;
left.startFrm = 8;
left.endFrm = 11;

right.uniform = false;
right.arate[10] = 2;
right.arate[11] = 1;
right.arate[12] = 1;
right.arate[13] = 2;
right.currentKeyFrm = 10;
right.startFrm = 10;
right.endFrm = 13;

idle.uniform = false;
idle.arate[0] = 0;
idle.currentKeyFrm = 8;
idle.startFrm = 7;
idle.endFrm = 7;
}

And here's a slightly changed animation code.

Code: [Select]
/**XL2 Animation Interpolation system with ANORM.h lookup table**/
#include "anorm.h"
void display_animated_model(animationControl * animCtrl, entity_t * currentModel, bool UseRealtimeGouraud)
{
if(currentModel->nbMeshes < 1){
return;
}
Uint8 ANIM_SIZE = 6;
Uint8 ANIM_QUAL = 3;

    XPDATA * currentPDATA = currentModel->pol[0];

    /**Sets the animation data**/
///Variable interpolation set
if(animCtrl->uniform == false){
    animCtrl->currentFrm += animCtrl->arate[animCtrl->currentKeyFrm];
} else {
animCtrl->currentFrm += 2;
}
///MATH: The below line increments the key-frame based on the current frame, which is incremented each frame by the arate.
///The arate in this case is 2. With an arate of 2, the current frame goes up twice for every frame of the game played...
///To compensate for this, we bitshift by 3 instead of 4 to increment the keyframe once every 30 iterations instead of once every 15 iterations.
///The ultimate control is the arate. XL2 set it up this way so it could be related to the game's frame-rate value, which at 30fps, is 2.
///It really does need to be this way or else the compression ratio does not work at all properly.
///This is, for all practical purposes, a fixed-function animation system with only 1 controllable variable of precise operation: the arate. (though creative souls could change the anim size variable)
   animCtrl->currentKeyFrm = (animCtrl->currentFrm>>3);  //should be >>currentModel->AnimInterpolation;
    if (animCtrl->currentKeyFrm >= animCtrl->endFrm)    {
        animCtrl->currentFrm -= (animCtrl->endFrm - animCtrl->startFrm)<<3; //<<currentModel->AnimInterpolation;
        animCtrl->currentKeyFrm = animCtrl->currentFrm>>3;  //>>currentModel->AnimInterpolation;
     } else if(animCtrl->currentKeyFrm < animCtrl->startFrm){
animCtrl->currentKeyFrm = animCtrl->startFrm;
animCtrl->currentFrm += (animCtrl->endFrm-animCtrl->startFrm)<<3;
}

    Uint8 nextKeyFrm = animCtrl->currentKeyFrm+1;
    if (nextKeyFrm >= animCtrl->endFrm){
        nextKeyFrm = animCtrl->startFrm;
} else if (nextKeyFrm <= animCtrl->startFrm){
        nextKeyFrm = animCtrl->startFrm;
}
    compVert * curKeyFrame = (compVert*)currentModel->animation[animCtrl->currentKeyFrm]->cVert;
    compVert * nextKeyFrame = (compVert*)currentModel->animation[nextKeyFrm]->cVert;

///Don't touch this!
Uint32 compHelp = (animCtrl->currentFrm)-(animCtrl->currentKeyFrm<<3);
    /*if (nextKeyFrm>animCtrl->currentKeyFrm) compHelp = animCtrl->currentFrm-(animCtrl->currentKeyFrm<<3);
    else compHelp = animCtrl->currentFrm-(animCtrl->currentKeyFrm<<3);*/

    /**Uncompress the vertices and apply linear interpolation**/
    register Uint32 i;
    Sint32 *dst=currentPDATA->pntbl[0];
    Sint16 *src=curKeyFrame[0];
    Sint16 *nxt=nextKeyFrame[0];
///Decompression
    for (i = 0; i < currentPDATA->nbPoint*sizeof(POINT); i+= sizeof(int)) {
*dst++=(*src+(((*nxt-*src)*compHelp)>>ANIM_QUAL))<<ANIM_SIZE;
*src++; *nxt++;
    }
    *dst=currentPDATA->pltbl[0].norm[0];
    Uint8 *src2=currentModel->animation[animCtrl->currentKeyFrm]->cNorm;
///Interpolation
    for (i = 0; i < currentPDATA->nbPolygon; i++)    {
    /**Not 100% sure which technique is faster**/
        // currentPDATA->pltbl[i].norm[X]=ANORMS[*src2][X];
        // currentPDATA->pltbl[i].norm[Y]=ANORMS[*src2][Y];
        // currentPDATA->pltbl[i].norm[Z]=ANORMS[*src2++][Z];
        *dst++=ANORMS[*src2][X];
        *dst++=ANORMS[*src2][Y];
        *dst++=ANORMS[*src2++][Z];
        *dst++; *dst++;
    }
jo_printf(0, 10, "(anim dat)");
jo_printf(0, 11, "(%i)", dst);
jo_printf(0, 12, "(%i)", src);
jo_printf(0, 13, "(%i)", dst);

jo_printf(0, 15, "(%i)", animCtrl->currentKeyFrm);
jo_printf(0, 16, "(%i)", animCtrl->currentFrm);
jo_printf(0, 17, "(%i)", animCtrl->startFrm);
jo_printf(0, 18, "(%i)", animCtrl->endFrm);
jo_printf(0, 19, "(%i)", compHelp);
    if (UseRealtimeGouraud) slPutPolygonX(currentPDATA, light);
    else slPutPolygon((PDATA*)currentPDATA);
}


http://www.mediafire.com/file/78rr5pc0zbvln52/proj_8118.zip/file
« Last Edit: August 02, 2018, 08:22:37 pm by ponut64 »

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #54 on: August 08, 2018, 07:04:04 pm »
So, this is the closest thread that is similar to the ZTP format, but how does the ZTM (Z-Treme Map?) format work? One difference between the two formats is that ZTP files compress the textures to 4bpp, and the ZTM format compresses the textures to at least 8bpp (or, evident by earlier versions, 15bpp).

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #55 on: August 08, 2018, 07:17:28 pm »
That version (old one) isn't supported by me anymore, it was 16 bpp.

20EnderDude20

  • Full Member
  • ***
  • Posts: 115
  • Karma: +6/-0
  • I'm also known as "The Blender Fiddler" on Youtube
    • View Profile
    • Youtube Channel
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #56 on: August 08, 2018, 07:25:37 pm »
May you release the ZTM converter anytime soon? I found a technique to fix the triangular faces.

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Model converter (.ZTP) -0.1 - WIP
« Reply #57 on: August 08, 2018, 07:26:30 pm »
No, I don't intend to release it

 

Sitemap 1 2 3 4 5 6 7 8 9 10 
SMF spam blocked by CleanTalk