Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - XL2

Pages: 1 ... 19 20 [21] 22 23
301
Great! Thanks!

I know the topic is now in "Wish list", but I could need some help.
Bad news ; while the binary mesh loading works in Yabause, in SSF it's a real mess (but works with lower compatibility) while on real hardware it doesn't work at all (it crashes before even loading anything).
It's probably a mistake related to memory allocation or initalization, but I have no idea what's wrong at the moment.
I've attached the files, if anyone with better knowledge of memory allocation could look it up, I would really appreciate!
Thanks!

Code: [Select]
//Start address is 0x00200000

void * LoadBinaryMAP(void * startAddress)
{

 char * stream;
 void * currentAddress;
 int length;
 mesh_tot = 0;
 stream = jo_fs_read_file("MAPT.ZTM", &length);

register unsigned int idx = 0;
register unsigned short i=0;
register unsigned int ii=0;
register unsigned int iii=0;
register unsigned int nbpoint=0;
register unsigned int nbpolygon=0;

currentAddress = startAddress;

mesh_tot = jo_swap_endian_ushort(*((unsigned short *)(stream)));
idx+=2;

for (i=0; i<mesh_tot; i++)
{
    jo3dMesh[i] = currentAddress;
    nbpoint = jo_swap_endian_uint(*((unsigned int *)(stream+idx)));
    idx+=4;
    nbpolygon = jo_swap_endian_uint(*((unsigned int *)(stream + idx)));
    idx+=4;

    jo3dMesh[i]->data.pntbl = (POINT*)(jo3dMesh[i] + sizeof(unsigned int));
    for (JO_ZERO(ii); ii<nbpoint; ii++)
    {
        for (JO_ZERO(iii); iii<3; iii++)
        {
            jo3dMesh[i]->data.pntbl[ii][iii] =  jo_swap_endian_int(*((int *)(stream + idx)));
            idx+=4;
        }
    }
    jo3dMesh[i]->data.pltbl = (POLYGON*) (jo3dMesh[i]->data.pntbl + sizeof(POINT)*nbpoint);
    for (JO_ZERO(ii); ii<nbpolygon; ii++)
    {
        for (JO_ZERO(iii); iii<3; iii++)
        {
            jo3dMesh[i]->data.pltbl[ii].norm[iii] = jo_swap_endian_int(*((int *)(stream + idx)));
            idx+=4;
        }
        for (JO_ZERO(iii); iii<4; iii++)
        {
            jo3dMesh[i]->data.pltbl[ii].Vertices[iii]=jo_swap_endian_ushort(*((unsigned short*)(stream + idx)));
            idx+=2;
        }
    }
    jo3dMesh[i]->data.attbl = (ATTR*) (jo3dMesh[i]->data.pltbl + sizeof(POLYGON)*nbpolygon);

    for (JO_ZERO(ii); ii<nbpolygon; ii++)
    {
        jo3dMesh[i]->data.attbl[ii].texno = jo_swap_endian_ushort(*((unsigned short*)(stream + idx)));
        idx+=2;
        jo3dMesh[i]->data.attbl[ii].sort = SORT_MAX;
        jo3dMesh[i]->data.attbl[ii].flag = Dual_Plane;
        jo3dMesh[i]->data.attbl[ii].colno = No_Palet;
        jo3dMesh[i]->data.attbl[ii].gstb = No_Gouraud;
        jo3dMesh[i]->data.attbl[ii].dir = MESHoff, sprNoflip, UseLight;
    }

    jo3dMesh[i]->data.nbPoint = nbpoint;
    jo3dMesh[i]->data.nbPolygon = nbpolygon;

    currentAddress = (void*) (jo3dMesh[i] + sizeof(jo3dMesh[i]));
}
jo_free(stream);
jo_printf(0, 6, "current adress :            %d     ", currentAddress);
return currentAddress;
}

302
I managed to build my custom binary file format and read it on the Saturn, so I can display a mesh loaded from a binary file on the CD.

My concern now is that I'm using the jo_fs_read_file, which returns a char stream, which takes memory while I'm loading everything to the right place.
It's not a huge problem while loading small images and sound files, but for a map taking 1 MB, it just won't be doable (unless I'm mistaken and got it all wrong).

Is there a way, in Jo Engine, to just use a pointer to read the file and return each time only what you need (like 8, 16, 24 or 32 bits from a start pointer)?
If not, can it be added in the next version?
Thanks!

303
About you / Re: Hello!
« on: August 02, 2017, 03:21:26 pm »
I played Panzer Dragoon 2 to death when I was a kid, so I'm a bit biaised.
But having a new kind of game is always great, I'm sure you will come out with something interesting!

304
Thanks a lot, this is greatly appreciated!

305
Seems like a solution is coming : http://www.jo-engine.org/forum/index.php?topic=800.0

306
Awesome! Can you share more details with us? This is a really annoying issue that we all have (except those lucky modchip owners)

307
About you / Re: Hello!
« on: August 01, 2017, 02:22:13 pm »
Wow, it already looks amazing! I'm happy that more people are joining the small (but growing) Saturn homebrew community! Don't give up and don't hesitate to ask if you have questions!

308
Share your code / Re: Collision BB generator (WIP) + FPS demo
« on: July 30, 2017, 04:16:11 pm »
I'm also using larger values to prevent loss of precision, but the issue must be different than that since -1 doesn't result im the opposite of 1.
Even if you only move on one axis, one direction goes faster than the other.
The negative int shift issue seems to fit the actual seen problem.

I guess I should use the SGL functions for now until a solution is found.
I updated the demo in the second post, the only difference is the use of gouraud shading, weapon switching and look up/down (Euler only for now)

309
Share your code / Re: Collision BB generator (WIP) + FPS demo
« on: July 30, 2017, 01:52:09 pm »
I took a quick look at the latest version of my code, and I don't use shifts for movements (since I just integrated your code).


The Jo_cos_mult/sin functions use JO_DIV_BY_32768 (or >>15) and they accept signed integers returned by the cosinus/sinus lookup table.
Code: [Select]
static  __jo_force_inline int	jo_sin_mult(const int value, const int angle) { return JO_DIV_BY_32768(value * jo_sin(angle)); }


Maybe adding a check would help?
Like, instead of simply returning the value >> 15 :

Code: [Select]
int val = value * jo_sin(angle)
if  (val<0)
    return -JO_DIV_BY_32768(JO_ABS(val)); 
else
    return JO_DIV_BY_32768(val);

Or is it supposed to be dealed with by the compiler?

EDIT : Did a small test by modifying the math.h file directly, it didn't really help.
Here is a video of the issue, but without the modification to the math.h file : https://youtu.be/i2N4E0j8FZI

310
Share your code / Re: Collision BB generator (WIP) + FPS demo
« on: July 30, 2017, 02:55:03 am »
Yes, I played quite a lot with both in Sonic Z-Treme, overall I had much better results with logical shifts (You just wouldn't believe it unless you saw it).
But after reading the link you sent me, you are right, for signed int the shift right is different for positive and negative values.
Funny thing is that I wrote a workaround in Sonic Z-Treme by  adding 512 (Instead of using floats, I used integers where 1=1024 to keep precision at low cost, but shifted right when sending these for drawing and collisions, so >>10), but I thought I just wrote a cheap workaround.
I guess that might be correct as it will get rounded down after being shifted (-1+1)>>1=0, or (-1024+512)>>10=0.
I guess that also explains why SGL demos are almost always using Unsigned integers and are always doing shifts.

One small question : just how much does shifting saves/costs in Cpu cycles? And SGL demos doing shifts for just about everything, doesn't that waste some CPU ressources?


311
Share your code / Re: Collision BB generator (WIP) + FPS demo
« on: July 28, 2017, 10:55:40 pm »
Your contribution is highly appreciated!
I will improve the FPS demo (and tool) to work with the mesh loading you wrote.
People will be able to turn it easily into other genres (3d person games, RPG, etc.).
Hopefully this will bring more people on board! ;)

About the FPS demo : There is a bug with the controls, and I have the same problem with Sonic Z-Treme : it seems to always go faster one direction. Now, it might be something I don't understand about the >>#  and <<# functions and negatives/positives, but it's quite anoying when you are trying to move in diagonal.
Anyone got an idea about that? Johannes suggested a weird overflow issue, but I really can't find it.
Any suggestions for modifications to avoid that?

312
Share your code / Re: Collision BB generator (WIP) + FPS demo
« on: July 28, 2017, 05:30:05 pm »
Like usual, thank you and amazing work Danny! I integrated your smooth FPS control in the FPS demo.
I didn't make a video of it, but you can see I updated the video in the previous post to show what it looks like with a VDP2 plane (with transparency), and I think it shows how much potential the Saturn has for beautiful effects!
I'll try over the weekend to update the collision tool to output .h files compatible with the format you made and integrate that in the FPS demo as a starting point for others.

313
Share your code / Re: Collision BB generator (WIP)
« on: July 26, 2017, 12:43:57 am »
Ok, as promised, a small demo (source code attached here) with a simple 3D collision engine.

I haven't spent much time on this, so it's buggy and far from perfect, and isn't modular enough.

I wanted to use the smooth control made by Danny, but I just used a 2-axis system for straffing and really didn't do much control-wise.

So, don't go burn this for your Saturn expecting a Quake-killer or Lobotoby software quality!
That being said, it should still be better than the SGL FPS demo (which had terrible collision detection).

Ingame : D-Pad for turning and going forward/backward, L/R for straffing and B for jumping.

The collision generator tool worked well for the Sonic level I tested, but it didn't work well with the small level I made for this demo (the slopes had problems, getting merged with other BB). I will have to improve the tool and share it again here once I do.

EDIT : Moved the file to the first post. I also added the map changing functions which now reads the binary file format (press L or R + start to switch maps)

Video here :
https://www.youtube.com/watch?v=a2TQrK2ZPJU

314
General Jo Engine Help / Re: Megadrive to Saturn
« on: July 23, 2017, 11:36:05 pm »
I wish I could be more helpful. Sadly the forum and the Saturn homebrew scene is pretty small, so it's hard to get answers.

For everything relate to Assembly, I'm afraid I can't help you as I'm a noob even for C. But I think you should really try to port the game to the Saturn and make full use of the hardware.

I understand it would be quite hard to convert code from Assembly to C, but you can reuse all the assets you have and porting the game logic shouldn't be that hard (but maybe it would take more time than you currently have)

What kind of game is it? Do you have youtube videos of it?

315
Share your code / 3D Map tool + FPS demo
« on: July 21, 2017, 08:57:49 pm »
Hi all,

I wrote a little tool to convert a level's polygons into bounding boxes (axis-aligned).
It merges the bounding boxes (BB) with their neighbour to reduce the amount of boxes.
It also calculates the slopes on one axis (x or z), but it doesn't generate the heigth masks yet (on my to do list).
It will be complicated to explain as I didn't add an example (on my to do list), so read carefuly and don't hesitate if you have questions.

Ok, now for the explanations (I'll try to explain, but I hope you guys will understand)

The idea is like this : you use a function similar to the Jo_intersect, but add the z axis... or just do 2 jo_intersect and replace the x with the z value for the second function.
Do 2 or 3 collision checks (x/z and y, or x and z and y - I suggest you go for 3)

If the collision mask value is -1, then just use it as is : you have a collision and just stop the movement on that direction.

If the mask is 0 or higher, then you just do a lookup in an array of values. The arrays I use are only 2 dimensions (because of memory constraints), but you could do 3 dimensions arrays as well for hills and other shapes.

Example : You know you have a slope if the rotation value on the x-axis isn't 0. So you look for a mask.
As an example, for a 45 degrees slope on the x-axis, your slopeRXangle will be 45 (or -45 depending on the direction).
So you look for the heigth mask returned by the function, and you look it up with your current Z position (not x since the axis of rotation is on the x axis - look for z as you go up or down on the slope), which will return a heigth value.

So let's say your relative Z position to the current BB is 100, and the BB has a length of 200.
Look at the array at position 100 (your z position minus the BB minimum z position), which will return a heigth value.

Just look for that value added to the minimum Y value of the bounding box to see if you have a collision (like, the minimum Y of the BB being -200, Y length being 200, and the heigth mask returns 100, so you look to see if you currently have a collision for an object with Y values ranging from -100 to 0)
.
Do another intersect check with your current Y value, if there is a hit, return it, else there is no collision.

This way, you can have smooth slopes with very little CPU usage. An it works for all 3 axis collision checks.
I need to improve my code to better merge the BB together and improve memory usage and CPU usage.
If you have a slope with side walls (looking "out" of the slope), you will hit an invisible wall as it won't merge them and it will cover your slope.
Just remove these walls for now and only keep the "ground" part (you might have to manualy ajust the heigth as well in the resulting file)
I didn't do much testing, so there might still be bugs I haven't found.

I'll also share my collision code at a later date, but right now I'm pretty much rewriting many parts of it so it's far from complete.

Hope this helps someone creating a 3D game!

EDIT : I added another version of the collision tool (still not good enough, it's buggy with slopes)
EDIT 2 : Added a function to write using Danny's code, but it's not 100% complete (WIP). Also got rid of the need to link to SGL.h, if it's causing issues make sure you tell me as I didn't test properly. I also quickly coded a .Obj exporter to Danny's code, but I didn't test it. Some stuff is wrong for sure and it might not work with all .Obj formatting, I will have to spend more time on this.
EDIT 3 : Added reading .OBJ files and binary file output. The FPS demo now uses the binary file format to load maps. I will add more features to the binary format.
EDIT 4 : Many bug fixed such as unaligned read/write, issues with multiple meshes. The .OBJ to binary seems to work fine now, tell me if you have issues. I also added basic view frustum culling to the FPS demo, put a HUD using Jo Engine functions (causes issues with other VDP2 functions, just uncomment other lines to revert to the RBG0 plane), removed the gouraud shading depth (made the game way too slow on real Saturn).

EDIT (2017-08-16) : Upgraded to Jo Engine 9.0 (make sure you upgrade also). I also fixed the memory allocation, so you should be able to load much bigger files now (try map 3 to see).

EDIT (2017-08-25) : You can now write textures directly in the binary file. The map program will read TGA textures (uncompressed only) and write them. Also added auto-subdivision of the map for culling, you just need to specify how many "cuts" you want (there is a bug that will sometimes "lose" polygons, so just try different values for "cuts" (x, y, z axis) if one setting doesn't work well). I also changed the FPS demo's collision code to reduce CPU usage.

Pages: 1 ... 19 20 [21] 22 23
SMF spam blocked by CleanTalk