Page 3 of 3

Posted: Sat Jan 20, 2007 3:33 pm
by drac_gd
sio2,
I have the directx 9.0 sdk ( MSDN March 2003 ).. could not find the source to mview:( Could I possibly get you to send it to me?
brett (DOT) r (DOT) jones (AT) gmail ( DOT) com

Posted: Sat Jan 20, 2007 4:03 pm
by Espanol
Luke, thank you for your kind. It is actually interested me. Would you please send your patch and .b3d for test?

Is there any option I should do for working with your patch?

Posted: Mon Jan 22, 2007 9:11 pm
by Spintz
Making progress on the loaders( X mesh and DDS textures ), here's a screenshot in IrrSpintz of the dwarf mesh from the DX Dec 2006 SDK( without normal mapping )

Image

DDS Loader can load R8G8B8, B8G8R8, A8R8G8B8, A8B8G8R8 and DXT1 formats so far, is all I needed, I'll add more to it as I come across the need to. It also loads 8-bit volume/3d textures, but as I mentioned, those texture types aren't supported in Irrlicht.

Posted: Tue Jan 23, 2007 2:22 am
by drac_gd
SWEEEEEEEEEEEEEET.. UMM when do you think IrrSpintz will be updated with the new code?

Bug for this topic

Posted: Sat Mar 03, 2007 10:52 pm
by Ки&am
Hello! I am using Irrlicht SVN (last).
Without .x model (tyny.x and it's optimized to 2K poly's version) FPS~=160. With model, FPS ~=40.
I'm fix some leaks in modifySkin() and animateSkeleton(), but FPS stil be very slow (~50). Two matrix transform in modifySkin() executed many (~7000) times at one call. It' dificult to reduce/

P/S/
I think that another fast order of weights are exists.

Posted: Mon Mar 05, 2007 11:10 pm
by Ки&am
Some optimizations increase FPS to (max, in Debug) 70 (+30).
CXAnimationPlayer.cpp:

Code: Select all

void CXAnimationPlayer::modifySkin()
{
	// set animated vertices to zero
#ifdef _XREADER_DEBUG
	for (s32 k=0; k<(s32)Joints.size(); ++k)
	{
		for (s32 w=0; w<(s32)Joints[k].Weights.size(); ++w)
		{
			SWeightData& wd = Joints[k].Weights[w];

			if (wd.buffer >= AnimatedMesh->getMeshBufferCount() ||
				wd.vertex >= AnimatedMesh->getMeshBuffer(wd.buffer)->getVertexCount())
				os::Printer::log("CXAnimationPlayer: Invalid Weights");
			
			video::S3DVertex* nv = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(wd.buffer)->getVertices();
			nv[wd.vertex].Pos.set(0,0,0);
/*This two code lines in xreader-debug only! */
		}
	}
#endif


#ifdef _XREADER_DEBUG
	bool somethingIsWrong = false;

	// check if all vertices are set to zero
	for (u32 mb=0; mb<AnimatedMesh->getMeshBufferCount(); ++mb)
	{
		video::S3DVertex* v = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices();
		s32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount();
		for (s32 vt=0; vt<c; ++vt)
			if (v[vt].Pos != core::vector3df(0,0,0))
			{
				char tmp[255];
				sprintf(tmp, "CXAnimationPlayer: Vertex not null. Buf:%d Vtx:%d", mb, vt);
				// this can happen if something is wrong with the vertex weights,
				// not all vertices have a weight attached.
				os::Printer::log(tmp);
				somethingIsWrong = true;
			}
	}

	if (somethingIsWrong)
	{
		// write out mesh informations
		char tmp[255];
		sprintf(tmp, "CXAnimationPlayer: Meshbuffers:%d", AnimatedMesh->getMeshBufferCount());
		os::Printer::log(tmp);

		for (u32 mb=0; mb<AnimatedMesh->getMeshBufferCount(); ++mb)
		{
			sprintf(tmp, "CXAnimationPlayer: Meshbuffer #%d: %d vertices", mb, AnimatedMesh->getMeshBuffer(mb)->getVertexCount());	
			os::Printer::log(tmp);
		}
	}
#endif
	
core::vector3df orig;
core::matrix4   mat;
			s32 w;
	for (s32 mb=0; mb<AnimatedMesh->getMeshBufferCount(); ++mb)
	{
		video::S3DVertex* av = (video::S3DVertex*)AnimatedMesh->getMeshBuffer(mb)->getVertices();
		video::S3DVertex* ov = (video::S3DVertex*)OriginalMesh.getMeshBuffer(mb)->getVertices();
		const s32 c = AnimatedMesh->getMeshBuffer(mb)->getVertexCount();
		for (s32 vt=0; vt<c; ++vt)
		{
			orig = ov[vt].Pos;
			const SVertexWeight& weight = Weights[mb].pointer()[vt];

			memset(mat.M,0,16*4);

			for (w=0; w<weight.weightCount; ++w)
			{
            //mat += combined*weight
				mat.set_summ_with_weight
				 (Joints[weight.joint[w]].CombinedAnimationMatrix,weight.weight[w]);
			}

			mat.transformVect(av[vt].Pos,orig);
			// yin nadie: let's modify the normals
			orig += ov[vt].Normal;
			mat.transformVect(av[vt].Normal,orig);
			av[vt].Normal -= av[ vt ].Pos;
			av[vt].Normal.normalize();
		}
	}
}
matrix4.h:

Code: Select all

			//! multiply by scalar
			matrix4 operator*(const f32 scalar) const;

			//! summ to another matrix
			matrix4 operator+(const matrix4& other) const;

			//! add this to another matrix
			inline void operator+=(const matrix4& other);

			//! add to another with weight
			inline void set_summ_with_weight(const matrix4& other, const f32 weight); 

Code: Select all

	//! multiply by scalar
	inline matrix4 matrix4::operator*(const f32 scalar) const
	{
		matrix4 tmtrx ( EM4CONST_NOTHING );

		const f32 *m1 = M;
		f32 *m3 = tmtrx.M;

		m3[0] = m1[0]*scalar; m3[1] = m1[1]*scalar;
		m3[2] = m1[2]*scalar; m3[3] = m1[3]*scalar;
		m3[4] = m1[4]*scalar; m3[5] = m1[5]*scalar;
		m3[6] = m1[6]*scalar; m3[7] = m1[7]*scalar;
		m3[8] = m1[8]*scalar; m3[9] = m1[9]*scalar;
		m3[10] = m1[10]*scalar; m3[11] = m1[11]*scalar;
		m3[12] = m1[12]*scalar; m3[13] = m1[13]*scalar;
		m3[14] = m1[14]*scalar; m3[15] = m1[15]*scalar;

		return tmtrx;
	}

	//! summ to another matrix
	inline matrix4 matrix4::operator+(const matrix4& other) const
	{
		matrix4 tmtrx ( EM4CONST_NOTHING );

		const f32 *m1 = M;
		const f32 *m2 = other.M;
		f32 *m3 = tmtrx.M;

		m3[0] = m1[0] + m2[0]; m3[1] = m1[1] + m2[1];
		m3[2] = m1[2] + m2[2]; m3[3] = m1[3] + m2[3];
		m3[4] = m2[4] + m1[4]; m3[5] = m1[5] + m2[5];
		m3[6] = m1[6] + m2[6]; m3[7] = m1[7] + m2[7];
		m3[8] = m2[8] + m1[8]; m3[9] = m2[9] + m1[9];
		m3[10] = m1[10] + m2[10]; m3[11] = m1[11] + m2[11];
		m3[12] = m2[12] + m1[12]; m3[13] = m2[13] + m1[13];
		m3[14] = m2[14] + m1[14]; m3[15] = m1[15] + m2[15];

		return tmtrx;
	}
	//! add this to another matrix
	inline void matrix4::operator+=(const matrix4& other)
	{
		const f32 *m2 = other.M;

		M[0] += m2[0]; M[1] += m2[1];
		M[2] += m2[2]; M[3] += m2[3];
		M[4] += m2[4]; M[5] += m2[5];
		M[6] += m2[6]; M[7] += m2[7];
		M[8] += m2[8]; M[9] += m2[9];
		M[10] += m2[10]; M[11] += m2[11];
		M[12] += m2[12]; M[13] += m2[13];
		M[14] += m2[14]; M[15] += m2[15];
	}
	//! add to another with weight
	inline void matrix4::set_summ_with_weight(const matrix4& other, const f32 weight) 
	{
		const f32 *m2 = other.M;

		M[0] += m2[0]*weight; M[1] += m2[1]*weight;
		M[2] += m2[2]*weight; M[3] += m2[3]*weight;
		M[4] += m2[4]*weight; M[5] += m2[5]*weight;
		M[6] += m2[6]*weight; M[7] += m2[7]*weight;
		M[8] += m2[8]*weight; M[9] += m2[9]*weight;
		M[10] += m2[10]*weight; M[11] += m2[11]*weight;
		M[12] += m2[12]*weight; M[13] += m2[13]*weight;
		M[14] += m2[14]*weight; M[15] += m2[15]*weight;
	}

Posted: Tue Mar 06, 2007 12:19 am
by hybrid
The .x enhancements looks interesting, I'll have to check it (or bitplane will). But what do you need the matrix ops for? They seem to be useful, but is there any need in the current example?

Posted: Tue Mar 06, 2007 3:40 pm
by &#1050;&#1080;&am
operator*(scalar) и operator+(matrix4) is typical matrix operations.


Threefold count of verices :shock:
it's error in CXAnimationPlayer::addFacesToBuffer

Code: Select all

 buf->Vertices.linear_reverse_search(v); 
always return -1

Posted: Tue Mar 06, 2007 3:52 pm
by hybrid
That'S for sure, I was just asking if you need it for the enhanced .x code. I'll add the matrix methods anyway, I was just curious why you made the two things together in this post.

Posted: Tue Mar 06, 2007 7:09 pm
by &#1050;&#1080;&am
To fix threefold count of verices remove
irrMath.h:

Code: Select all

	inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32)
	{
		return (a + tolerance > b) && (a - tolerance < b);
	}
by

Code: Select all

	inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32)
	{
		return (a + tolerance >= b) && (a - tolerance <= b);
	}
// (-tolerance;+tolerance) -> [-tolerance;+tolerance]

------
:) max 110 FPS in Debug!

Posted: Tue Mar 06, 2007 11:17 pm
by Spintz
Just made these changes it IRRspintz. There was no change in FPS after the changes....

Posted: Wed Mar 07, 2007 12:59 am
by hybrid
Anyway, it should be correct!? Although most implementations I've seen uses the strict comparisons...
Maybe the effect depends on the compiler and optimizations set. If you get some more rounding errors the comparisons might work.

Posted: Wed Mar 07, 2007 2:52 pm
by &#1050;&#1080;&am
It's correct. Tolerance can be 0, also rounding errors of tolerance does not influence result.

Spintz:
It depends on model (from average quantity of weights on one vertex). And uselessness of the first nulling cycle on all vertices in not a debugging mode is obvious.

P.S. I'm use VC++6.0 (SP5), DX9 SDK feb.
I test results of the optimization in a debugging mode, i.e. by the switched off machine optimization.