antoniond / nitro-engine Goto Github PK
View Code? Open in Web Editor NEW3D engine for the Nintendo DS
3D engine for the Nintendo DS
Hi,
got into NE quiete a bit. After spending some time on the engine itself i started 3D modelling.
Theres some optimisation to be done for sure, but i quick tested my 3D Modell and Texture. It works as long as the texture is only 128x128 big. As soon i try to use an 256x256 Texture it looks pretty ugly and like UV coordinates not respected anymore?
Following package contains:
-Screenshots of the issue
-Compiled NDS files of that example
-Texture Files i used in 128
-and the 3D modell itself
Tested on Desmume, MelonDS and real Hardware (Nintendo DSI and DS Lite) :)
128x128 Texture
I'd like to draw text using rich text's quad drawing mode within a specific box region on a screen (ideally, wrapping the text if it goes over). With the monospace NE_Text.h
API I could do NE_TextPrintBox
/NE_TextPrintBoxFree
to do this, or implement my own thing using NE_TextPrintFree
since characters were of a constant known width.
Since rich text is VWF and box drawing isn't a thing in NE_RichText
, this isn't quite possible. It'd be great to expose a method to get the length of a string, as DSF exposes DSF_StringRenderDryRun
for this purpose, but the handle needed to call DSF methods is abstracted away by Nitro-Engine :).
Similarly, an option to limit the number of characters to draw is no longer present (though of course this isn't a big deal as you can just trim the string before passing it). Still, it'd be nice to have this option.
Attempting to call these methods will result in compiler linkage errors as they are not implemented in NERichText.c
Hello again!
I changed your example to show a problem with the physics engine.
If you have a floor made from more than 2 blocks, if you slide on this floor and when try to go in the other floor block, the blue cube is stuck.
(you can launch the .nds file, it's more explicit)
collisionProblem.zip
Hi,
are there any examples for how to use pallets?
Like when using RGB256 for textures?
Couldnt find any in the example folders :)
Hello,
For me the big problem of Nitro Engine is the 2D.
Because if the 2D system we are limited to 30fps in dual screen mode if we just want to use 3D at the top and 2D at the bottom.
Real 2D would allow 60 fps with both screen mode.
You are adding the support of compressed textures, maybe it's time to support real 2D right? :)
Thanks!
Hello,
I have multiple (most) Textures using the same colors,
it would be nice if there was an option in img2ds to select a Palette.
All source code for examples in Nitro Engine is compressing the elf to binary before using ndstool on it:
Is this intended? Was there a performance benefit to doing so?
This correlates to an issue in TWiLight where none of the Nitro Engine examples were detected in TWiLight as homebrew and was instead detected as a retail title: DS-Homebrew/TWiLightMenu#1753. I removed the $(TARGET).arm9
flag from here and directly used the .elf
against ndstool and this was detected fine, but I'm not sure if that would break functionality in Nitro Engine somewhere.
First of all, thanks so much for making this library; it's been a huge boon to the project I'm working on so far. Fair warning that I'm not sure this is actually a bug with NE -- I may just be holding something wrong, but I was hoping to get help either way.
I'm attempting to use the 3D engine to display 2D textures using nitro-engine. I have a 256x256 texture that is transparent below pixel 192.
I converted this texture to a DS texture, first using a tool I wrote and then using your tool to confirm it wasn't something I was doing while preparing the texture. I am displaying the texture with the following code:
void displayBgAsTex(GraphicInfo &bgInfo, Globals &globals)
{
GraphicImage bgTex = loadPixels(bgInfo.name);
Palette bgPal = loadPalette(bgInfo.name);
if (globals.bgTex[0])
{
NE_Palette *oldPalette = globals.bgTex[0]->mat->palette;
NE_Material *oldMaterial = globals.bgTex[0]->mat;
NE_SpriteDelete(globals.bgTex[0]);
NE_MaterialDelete(oldMaterial);
NE_PaletteDelete(oldPalette);
globals.bgTex[0] = NULL;
}
NE_Material *material = NE_MaterialCreate();
NE_Palette *palette = NE_PaletteCreate();
NE_PaletteLoad(palette, (u16 *)bgPal.palette, bgPal.numColors, bgInfo.format);
NE_MaterialTexLoad(material, bgInfo.format, bgInfo.width, bgInfo.height, NE_TEXGEN_OFF, (void *)bgTex.pixels);
NE_MaterialSetPalette(material, palette);
globals.bgTex[0] = NE_SpriteCreate();
NE_SpriteSetPos(globals.bgTex[0], 0, 0);
NE_SpriteSetSize(globals.bgTex[0], bgInfo.width, bgInfo.height);
NE_SpriteSetPriority(globals.bgTex[0], 256);
NE_SpriteSetMaterial(globals.bgTex[0], material);
}
which is called by a script which does the appropriate thing for rendering the texture
void Draw3DScene()
{
NE_2DViewInit();
NE_SpriteDrawAll();
}
...
NE_Process(Draw3DScene);
In my main function, I do all the appropriate setup:
irqEnable(IRQ_HBLANK);
irqSet(IRQ_VBLANK, NE_VBLFunc);
irqSet(IRQ_HBLANK, NE_HBLFunc);
NE_Init3D();
NE_SwapScreens();
Globals globals = loadStaticFiles();
so i think I'm doing everything correctly.
The bgInfo class reads in the width and height from a file I prepared; both of those values are set to 256.
However, in-game, it looks like this:
And the 3D rendering screen in no$ seems to indicate that the lower texcoords are being set to 252 rather than 256:
So... weird!
Hoping you can help figure out what's going on. I can provide the ROM if needed!
Thanks!
What language is this scripting in?
Is there ample documentation?
Hi, I've been using your library to learn to program in c for my old dsi, I'm using version 0.9.1 and there seems to be a problem with the NE_CameraSet() function, the X unit vector up generates rendering problems with values greater and lower than zero, however, this input doesn't seems to do anything if the other two inputs, Y up and Z up, are not zero (either positive and negative values), I'm testing a the function to get an idea of a way to implement a fully free camera rotation using quaternions (though I don't know if there's another way to do this).
Also, I have a question, maybe there's already a function or a way to do this but I haven't found nor understand it yet, it is how can I specify a non power of 2 sector/area from a power of 2 material to be the texture for a quad, because I have the textures and sprite sheets extracted from Age of Empires 3 Mobile (j2me) and all of them are non power of 2 textures (i.e. the background tiles are 48x23, many sprites are 12x48 and so on), I can merge most of them in a power of 2 sprite sheet to use nitro-engine material function. I've seen Fewinty's minecraft ds project for reference but I want to use your library because it makes it alot of it way easier.
Should be "properties" instead of "propierties" :). Typo is also present in doc comments.
https://github.com/AntonioND/nitro-engine/blob/master/include/NETexture.h#L322
http://paulbourke.net/dataformats/obj/colour.html
It will be needed to add an option to enable or disable color commands as opposed to normals because only the last color or normal command is used, and they override the previous one. Both can't be used at the same time.
Hello,
I am using the NE_OutliningEnable function to draw outlines for my models in dual screen 3D mode - however, I am also drawing sprites on top of these models, which are affected by the outlines.
Is it possible to turn off outlining for sprites?
I have tried this code, but sadly that didn't work out.
NE_OutliningEnable(true);
NE_CameraUse(TSCamera);
NE_PolyFormat(31, 0, NE_LIGHT_0, NE_CULL_NONE, 0);
NE_ModelDraw(GetModel(MODEL_MainChara));
NE_OutliningEnable(false);
NE_2DViewInit();
NE_SpriteDrawAll();
Thank you!
Hi, I'm curious about the volumetric shadow example, didn't expected that in nitro-engine, it reminded me to a character shadow effect present in star wars Clone Wars - Jedi Alliance, I don't know if you already know this, but there's a short writing by the programmer about how he implemented animated characters' dynamic shadows:
http://tfpsly.free.fr/english/3d/Shadows_on_ds.html
Would it be possible to implement something similar to nitro-engie?, I don't know if it is something hard to do, I'm learing C/C++ in my free time and your engine already is incredible.
Right now the only ways supported by Nitro Engine to send display lists to the GPU are to use the CPU itself to copy the display list, or to use the DMA in GFX FIFO mode. This DMA mode is buggy and it can't be used at the same time as the HBL DMA mode, so this task involves creating a new way to send the display lists using DMA.
The new way should setup an interrupt to trigger when the GFX FIFO is half empty, or empty, and it should use DMA to send more commands to the FIFO.
Hi,
im trying to understand the differences when setting the positions of an camera in comparison to setting the position of an model.
Doing:
NE_ModelSetCoord(PlayerModel,-0.07424927f,1.3f,16.1f);
...
NE_CameraSet(Camera,
-0.07424927f,1.3f,16.1f, // Position
0,0,0, // Look at
0, 1, 0);
Works and positions of the PlayerModel and the Camera are the same.
Tho, doing following doesnt work:
NE_ModelSetCoord(PlayerModel,-0.07424927f,1.3f,16.1f);
...
NE_CameraSet(Camera,
PlayerModel->x,PlayerModel->y,PlayerModel->z, // Position
0,0,0, // Look at
0, 1, 0);
I know positions of an Model are declared as an int and are effectifely f32, shouldnt those values be compatible with the cameras NE_CameraSet function? Sorry for the questions!
Hi,
im having issues with these three functions:
NE_GetPolygonCount
NE_GetVertexCount
NE_GetCPUPercent
First two always return 0, while the GetCPUPercent one is returning numbrs between 400-600.
I attached an example project and the resulting compiled .nds
Compiled.zip
free_camera.zip
Here is what my shell gives me:
melonDS 0.9.4
https://melonds.kuribo64.net/
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
(process:75401): Gtk-WARNING **: 22:34:02.501: Locale not supported by C library.
Using the fallback 'C' locale.
Gtk-Message: 22:34:02.532: Failed to load module "canberra-gtk-module"
Gtk-Message: 22:34:02.533: Failed to load module "canberra-gtk-module"
Qt: Session management error: Could not open network socket
libpng warning: iCCP: known incorrect sRGB profile
Audio output frequency: 48000 Hz
Resetting JIT block cache...
done resetting jit mem
done resetting jit mem
MAC: 00:09:BF:11:22:33
FW: WIFI CRC16 = GOOD
FW: AP1 CRC16 = GOOD
FW: AP2 CRC16 = GOOD
FW: AP3 CRC16 = GOOD
FW: USER0 CRC16 = GOOD
FW: USER1 CRC16 = BAD
Game code: ####
ROM entry not found
!! bad ROM size 703488 (expected 1048576) rounded to 1048576
Cart ID: 400000C2
remapping SWRAM
Secure area decryption failed
remapping DTCM 0 1000 ffffffff ffffffff
PU: region 0 = 04000033 : enabled, 04000000-08000000
PU: region 0 = 04000033 : enabled, 04000000-08000000
PU: region 1 = 0200002B : enabled, 02000000-02400000
PU: region 1 = 0200002B : enabled, 02000000-02400000
PU: region 2 = 00000000 : disabled, 00000000-00000002
PU: region 2 = 00000000 : disabled, 00000000-00000002
PU: region 3 = 08000035 : enabled, 08000000-10000000
PU: region 3 = 08000035 : enabled, 08000000-10000000
PU: region 4 = 0300001B : enabled, 03000000-03004000
PU: region 4 = 0300001B : enabled, 03000000-03004000
PU: region 5 = 00000000 : disabled, 00000000-00000002
PU: region 5 = 00000000 : disabled, 00000000-00000002
PU: region 6 = FFFF001D : enabled, FFFF0000-FFFF8000
PU: region 6 = FFFF001D : enabled, FFFF0000-FFFF8000
PU: region 7 = 027FF017 : enabled, 027FF000-02800000
PU: region 7 = 027FF017 : enabled, 027FF000-02800000
remapping DTCM 3000000 3004000 0 fffff000
Game is now booting
Mic init failed: Could not connect PulseAudio stream
remapping DTCM ffffffff ffffffff 3000000 2ffc000
PU: region 0 = 04000033 : enabled, 04000000-08000000
PU: region 1 = FFFF001F : enabled, FFFF0000-00000000
PU: region 2 = 00000017 : enabled, 00000000-00001000
PU: region 5 = 02FF001B : enabled, 02FF0000-02FF4000
PU: region 4 = 0100001D : enabled, 01000000-01008000
unknown ARM9 IO read32 04004008 02017794
PU: region 3 = 08000035 : enabled, 08000000-10000000
PU: region 6 = 0200002F : enabled, 02000000-03000000
PU: region 7 = 0200002B : enabled, 02000000-02400000
remapping DTCM 2ff0000 2ff4000 ffffffff ffffffff
PU region 0: 04000000-08000000, user=07 priv=07
33333363/33333363
PU region 1: FFFF0000-00000000, user=55 priv=55
33333363/33333363
PU region 2: 00000000-00001000, user=07 priv=07
33333363/33333363
PU region 3: 08000000-10000000, user=07 priv=07
33333363/33333363
PU region 4: 01000000-01008000, user=07 priv=07
33333363/33333363
PU region 5: 02FF0000-02FF4000, user=07 priv=07
33333363/33333363
PU region 6: 02000000-03000000, user=07 priv=07
33333363/33333363
PU region 7: 02000000-02400000, user=77 priv=77
33333363/33333363
unknown ARM9 IO read8 04004000 02000864
RTC INTERRUPT ON: 41
NDSCART: !! BAD TRANSFER DIRECTION FOR CMD B7, DIR=0, ROMCNT=E97F3FFF
The error given at the end seems the most relevant. One person reported a similar issue on the MelonDS repo:
I will try with desmume and see if I get the same issue or not.
Thanks for your superb work on this lib!!
It'd be nice if nitro-engine provided a way of drawing polygons outside -6 < x < 6 | -6 < z < 6, which isn't currently possible without dipping into libnds and manually calling one of the glTranslate
methods (as this is the approximate max range supported by the 4.12 fixed point number)
My use case is drawing a super-simple shadow below a character, so would rather not have to bother making and loading a super simple model when I can just draw it directly.
Perhaps an alternate/better solution for my use case (as I note you say to avoid drawing polys where possible) would be some methods for the 3d engine to draw simple planes/shapes?
note: I could have missed something in the docs!! very sorry for wasting your time if so (am quite new to this)!
Hi,
im sorry! In Dual mode, bank C and D cant be used. What are they used for?
If i understand correctly, i cant use them to store textures for the bottom screens ui?
This is the website with its documentation: https://bztsrc.gitlab.io/model3d/
This is the original issue in the DSMA repository: AntonioND/dsma-library#1
In dual 3D mode, models drawn by the function that runs on the main screen are rendered on the sub screen and vice-versa; this doesn't seem to happen with sprites/GUI elements, only models
For example, the landscape model here is supposed to be rendered on the main screen (currently set to the top screen), but instead renders on the other one
Hi, I'm having an issue with (What I presume to be) the md2_to_nea exporter.
I've got a rigged 3D model created in Maya and exported to .md2 using MilkShape 3D. Inside both Ms3d and it's accompanying md2 model viewer I can see it exported perfectly fine, animated, etc. But when I convert it into a nea bin and load it into the game, there seems to be a couple of things that can happen;
The examples I've encountered have all occurred by scrapping and starting my animation from scratch in MilkShape, a different result being achieved each time. I've tried modifying the nea exporter to print values such as frame->scale and frame->translate, and in my findings, on the broken model scale/translate was set to 0.000 at some point through the animation, where on the working model they were all unique values. I'm not sure if this is relevant to the problem, but figured I'd mention it anyway.
Do you have a specific workflow/programs to use to ensure compatibility with the exporter, or is there other special care that needs to be taken with it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.