Page 2 of 7

Re: create 3d and include

Posted: Wed Feb 16, 2011 11:45 pm
by zeromus
http://forum.gbadev.org/viewtopic.php?t=14947

as far as i know it is in every download of ndsmodelexporter

ask google for jre

Re: create 3d and include

Posted: Thu Feb 17, 2011 4:22 pm
by lazyprogramer
thanks! I got it now!

Re: create 3d and include

Posted: Sat Feb 19, 2011 1:16 pm
by lazyprogramer
Is it possible to add more textures to one mesh?
I create my models with 'Blender', but when I add a texture to the model with Blender and
save this file as a .3ds file and try convert it with the ndsmodelexporter.jar it just freeze!
How can I add a texture to the model that it display it correct like in the env_mapping ex-
ample in the devkitpro\examples\nds folder?

Re: create 3d and include

Posted: Sun Feb 20, 2011 1:52 am
by zeromus
maybe the exporter is flaky. you may be out of luck. you may have to give up. nobody guarantees that any of that java model conversion junk works.

Re: create 3d and include

Posted: Sun Feb 20, 2011 4:44 pm
by lazyprogramer
Do you work with 3d stuff?
How can I see a model I created with a good texture (I don't know how to create a texture and which fits to the model!!) in my game?
Is this so hard, I saw many nice 3d games for the DS!

Re: create 3d and include

Posted: Mon Feb 21, 2011 2:48 am
by Izhido
You seem to think we have some kind of standard tool to place 3D figures in a .nds application. We don't. Everything you see in 3D on the DS is either 1) Built with Nintendo-supplied tools (and therefore only seen in "official" games), or 2) Hand-crafted by experienced hobbyists / developers.

Read a little about 3D APIs. Read gbatek ( http://nocash.emubase.de/gbatek.htm ) . Study both well. Maybe, after doing this, you will finally figure what's needed to create 3D games for the DS.

By the way, if after doing this, you come out with a handy set of tools you yourself just created to do 3D with the toolchains, be a nice guy and share them with all of us. Deal?

Re: create 3d and include

Posted: Tue Feb 22, 2011 5:26 pm
by lazyprogramer
Deal?
Deal! If I invent something or found something I will tell you!

I wrote a simple script which shows a model (made out of 11 other models):

Code: Select all

#include <nds.h>


#include "m1_bin.h"
#include "m2_bin.h"
#include "m3_bin.h"
#include "m4_bin.h"
#include "m5_bin.h"
#include "m6_bin.h"
#include "m7_bin.h"
#include "m8_bin.h"
#include "m9_bin.h"
#include "m10_bin.h"
#include "m11_bin.h"

#include "cafe_bin.h"


static void get_pen_delta( int *dx, int *dy )
{
	static int prev_pen[2] = { 0x7FFFFFFF, 0x7FFFFFFF };
	touchPosition touchXY;
	
	u32 keys = keysHeld();

	if( keys & KEY_TOUCH )
	{
		
		touchRead(&touchXY);

		if( prev_pen[0] != 0x7FFFFFFF )
		{
			*dx = (prev_pen[0] - touchXY.rawx);
			*dy = (prev_pen[1] - touchXY.rawy);
		}

		prev_pen[0] = touchXY.rawx;
		prev_pen[1] = touchXY.rawy;
	}
	else
	{
		prev_pen[0] = prev_pen[1] = 0x7FFFFFFF;
		*dx = *dy = 0;
	}
}


int main()
{

	int rotateX = 0;
	int rotateY = 0;

	//set mode 0, enable BG0 and set it to 3D
	videoSetMode(MODE_0_3D);

	// intialize gl
	glInit();
	
	// enable antialiasing
	glEnable(GL_ANTIALIAS);
	
	// setup the rear plane
	glClearColor(0,0,0,31); // BG must be opaque for AA to work
	glClearPolyID(63); // BG must have a unique polygon ID for AA to work
	glClearDepth(0x7FFF);

	//this should work the same as the normal gl call
	glViewport(0,0,255,191);

	vramSetBankA(VRAM_A_TEXTURE);
	glEnable(GL_TEXTURE_2D);
	
	int cafe_texid;
	glGenTextures( 1, &cafe_texid );
	glBindTexture( 0, cafe_texid );
	glTexImage2D( 0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, GL_TEXTURE_WRAP_S|GL_TEXTURE_WRAP_T|TEXGEN_NORMAL, (u8*)cafe_bin );

	
	//any floating point gl call is being converted to fixed prior to being implemented
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(100, 256.0 / 192.0, 0.1, 40);
	
	while(1)
	{
		//TEXGEN_NORMAL helpfully pops our normals into this matrix and uses the result as texcoords
		glMatrixMode(GL_TEXTURE);
		glLoadIdentity();
		GLvector tex_scale = { 64<<16, -64<<16, 1<<16 };
		glScalev( &tex_scale );		//scale normals up from (-1,1) range into texcoords
		glRotateXi(rotateX);		//rotate texture-matrix to match the camera
		glRotateYi(rotateY);


		glMatrixMode(GL_POSITION);
		glLoadIdentity();
		glTranslatef32(0, 0, floattof32(-3));
		glRotateXi(rotateX);
		glRotateYi(rotateY);

		glMaterialf(GL_EMISSION, RGB15(31,31,31));

		glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK );

		scanKeys();
		u32 keys = keysHeld();


		if( keys & KEY_UP ) rotateX += 3<<3;
		if( keys & KEY_DOWN ) rotateX -= 3<<3;
		if( keys & KEY_LEFT ) rotateY += 3<<3;
		if( keys & KEY_RIGHT ) rotateY -= 3<<3;

		int pen_delta[2];
		get_pen_delta( &pen_delta[0], &pen_delta[1] );
		rotateY -= pen_delta[0];
		rotateX -= pen_delta[1];


	//	glBindTexture( 0, cafe_texid );
		glCallList((u32*)m1_bin);	
        glCallList((u32*)m2_bin);
		glCallList((u32*)m3_bin);
		glCallList((u32*)m4_bin);
		glCallList((u32*)m5_bin);
		glCallList((u32*)m6_bin);
		glCallList((u32*)m7_bin);
		glCallList((u32*)m8_bin);
		glCallList((u32*)m9_bin);
		glCallList((u32*)m10_bin);
		glCallList((u32*)m11_bin);
		glFlush(0);
	}

	return 0;
}//end main
But I have no textures yet what you can see on the pic is the color of the model.
But why isn't there any shadow?

Re: create 3d and include

Posted: Wed Feb 23, 2011 8:47 am
by zeromus
first, quit wasting your time on models. that is level 10 and you are at level 1. work through the nehe examples first.
next, if you insist on wasting your time, you have unwisely chosen an environment mapping demo which just makes things more complicated for you. choose another demo to start from.

Re: create 3d and include

Posted: Wed Feb 23, 2011 12:53 pm
by lazyprogramer
work through the nehe examples first.
hm okay I will do this.

How is it possible to animate the models? I mean when I load a mesh it is static and not formable. Do I have to code
the polygons and vertexes and change the positions of them to animate something, isn't there no better way?

Re: create 3d and include

Posted: Wed Feb 23, 2011 2:44 pm
by relminator
lazyprogramer wrote:
work through the nehe examples first.
hm okay I will do this.

How is it possible to animate the models? I mean when I load a mesh it is static and not formable. Do I have to code
the polygons and vertexes and change the positions of them to animate something, isn't there no better way?
That's about level 15.

Try:
  • 1. Keyframe animation (easy and fast but a memory hog)
    2. Skining(Bone-animation) with matrices (artifacts galore)
    3. Skining(Bone-animation) with quaternion slerping ( de facto standard )