Tokamak Integration doesn't work

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Tokamak Integration doesn't work

Post by VeneX »

When I try to compile the tokamak integration there are a lot of errors.
Niko: do you have so many errors too? I think not, what's wrong?

--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
e:\irrlicht\examples\tokamak in irrlicht\main.cpp(4) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(112) : error C2065: 'sizeInfo' : undeclared identifier
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(112) : error C2228: left of '.rigidBodiesCount' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(114) : error C2228: left of '.animatedBodiesCount' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(116) : error C2228: left of '.rigidBodiesCount' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(116) : error C2228: left of '.animatedBodiesCount' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(116) : error C2228: left of '.geometriesCount' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(118) : error C2228: left of '.overlappedPairsCount' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(120) : error C2228: left of '.rigidParticleCount' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(120) : error C2228: left of '.constraintsCount' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(120) : error C2228: left of '.terrainNodesStartCount' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(122) : error C2065: 'gravity' : undeclared identifier
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(122) : error C2228: left of '.Set' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(126) : error C2065: 'i' : undeclared identifier
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(132) : error C2065: 'boxSize1' : undeclared identifier
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(132) : error C2228: left of '.Set' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(132) : error C2109: subscript requires array or pointer type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(132) : error C2109: subscript requires array or pointer type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(132) : error C2109: subscript requires array or pointer type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(132) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(132) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(132) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(134) : error C2065: 'pos' : undeclared identifier
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(134) : error C2228: left of '.Set' must have class/struct/union type
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(136) : error C2601: 'KillPhysics' : local function definitions are illegal
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(152) : fatal error C1075: end of file found before the left brace '{' at 'E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(144)' was matched
Error executing cl.exe.

main.exe - 22 error(s), 4 warning(s)
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

well it's getting better but there are still problems here.

--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
e:\irrlicht\examples\tokamak in irrlicht\main.cpp(4) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(268) : warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(268) : warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(268) : warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(447) : warning C4305: 'argument' : truncation from 'const double' to 'const float'
Linking...
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library

main.exe - 0 error(s), 6 warning(s)

And, as you can read on my site, I am shocked. This is ugly. The blocks are falling half in the floor!
Image
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Post by DarkWood_Neo »

E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(459) : error C2017: illegal escape sequence
use '\\' istaed of '\'
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(268) : warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(268) : warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(268) : warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
E:\Irrlicht\examples\tokamak in irrlicht\main.cpp(447) : warning C4305: 'argument' : truncation from 'const double' to 'const float'
try to write "(double)" before the variable
but I don't think that this fix the half-through-the-floor-bug
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

line 268:
pos.Set((rand()%10) / 20.0f * CUBEX, 4.0f + i * (CUBEY + 1), rand()%10)/ 20.0f * CUBEZ);

line 447:
TempVect *= 180 / PI;

Where do I have to set (double)?
And why are the boxes falling half through the floor?
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Post by DarkWood_Neo »

I am sorry. I meant float not double.

pos.Set((rand()%10) / 20.0f * (float)CUBEX, 4.0f + i * ((float)CUBEY + 1), rand()%10)/ 20.0f * (float)CUBEZ);

and

TempVect *= 180 / (float)PI;


but I'am not sure if it works, but it should.
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

Wow, thank you. There are no errors AND warnings!

The result is really disappointing me, the boxes won't fall very good. They will overlap each other and are with the angles in the floor as you can see on my site.
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Post by DarkWood_Neo »

maybe you can send the code to me. I'm intressted in it because I've got an similar problem when I coded my own collision detection (Irrlich version 0.1 :D )

mail: jonas AT laklein.de
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

to: DarkWood_Neo I have sended you an email, notice I am using irrlicht 0.4
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

For note: the problem occurs because Tokamak and Irrlicht do not use the same rotation structure. The conversion given in the Tokamak tutorial is not correct. I'm not exaclty sure how to convert from Tokamak to Irrlicht, or vice versa, however there is an easier way, as mentioned previously in the forums. Just get the transformation matrix from Tokamak and copy it into the Irrlicht object's AbsoluteTransformationMatrix.
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

can you please give me that link?
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Boogle wrote:The conversion given in the Tokamak tutorial is not correct.
That's right, but someone already sent me a correction for this. I had no time to correct the tutorial yet.
Gonosz
Posts: 24
Joined: Wed Oct 29, 2003 4:21 pm
Location: Hungary (one joke and you're dead)

Post by Gonosz »

Yap that was me :)

Link: http://irrlicht.sourceforge.net/phpBB2/ ... .php?t=349

I'll clean up the code and post it here,

Gonosz[/quote]
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

thanks dude, I was affraid it was the tokamak engine which causes the problem :?
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
Gonosz
Posts: 24
Joined: Wed Oct 29, 2003 4:21 pm
Location: Hungary (one joke and you're dead)

Post by Gonosz »

Ookay I found the files at last :)
Sorry for the long post :)

GPhyCubeNode.h:

Code: Select all

class CGPhyCubeNode : public irr::scene::ISceneNode
{
public:  
	void Update();
	void InitPhysics(neSimulator* gSim, int index, int materialindex);
	CGPhyCubeNode(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id);
	virtual ~CGPhyCubeNode();
	virtual void OnPreRender();
	virtual void render();
	virtual const irr::core::aabbox3d<f32>& getBoundingBox() const;
	virtual s32 getMaterialCount();
	virtual irr::video::SMaterial& getMaterial(s32 i);
private:
	irr::core::aabbox3d<irr::f32> Box;  
	irr::video::S3DVertex Vertices[8];  
	irr::video::SMaterial Material;
	neRigidBody *gCube;
};
.cpp:

Code: Select all

// GPhyCubeNode.cpp: implementation of the CGPhyCubeNode class.
//
//////////////////////////////////////////////////////////////////////

#include "GPhyCubeNode.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CGPhyCubeNode::CGPhyCubeNode(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id) : irr::scene::ISceneNode(parent, mgr, id)
{
	gCube = NULL;
	Material.Wireframe = false;
	Material.Lighting = false;
	Vertices[0] = irr::video::S3DVertex(
		-CUBEX/2,-CUBEY / 2,-CUBEZ/2, 1,1,0,
		irr::video::SColor(255,255,0,0), 0, 1);
	Vertices[1] = irr::video::S3DVertex(
		CUBEX/2,-CUBEY / 2,-CUBEZ/2, 1,0,0,
		irr::video::SColor(255,0,0,255), 1, 1);
	Vertices[2] = irr::video::S3DVertex(
		CUBEX/2,-CUBEY / 2, CUBEZ/2, 0,1,1,
		irr::video::SColor(255,0,0,255), 1, 0);
	Vertices[3] = irr::video::S3DVertex(
		-CUBEX/2,-CUBEY / 2, CUBEZ/2, 0,0,1,
		irr::video::SColor(255,0,0,255), 0, 0);
	Vertices[4] = irr::video::S3DVertex(
		-CUBEX/2, CUBEY / 2,-CUBEZ/2, 0,0,1,
		irr::video::SColor(255,0,0,255), 0, 0);
	Vertices[5] = irr::video::S3DVertex(
		CUBEX/2, CUBEY / 2,-CUBEZ/2, 0,0,1,
		irr::video::SColor(255,0,255,0), 0, 0);
	Vertices[6] = irr::video::S3DVertex(
		CUBEX/2, CUBEY / 2, CUBEZ/2, 0,0,1,
		irr::video::SColor(255,0,0,255), 0, 0);
	Vertices[7] = irr::video::S3DVertex(
		-CUBEX/2, CUBEY / 2, CUBEZ/2, 0,0,1,
		irr::video::SColor(255,0,0,255), 0, 0);
	Box.reset(Vertices[0].Pos);  
	for (s32 i=1; i<8; ++i)
		Box.addInternalPoint(Vertices[i].Pos);
}

CGPhyCubeNode::~CGPhyCubeNode()
{

}

void CGPhyCubeNode::OnPreRender()
{  
	if (IsVisible)
		SceneManager->registerNodeForRendering(this);
	ISceneNode::OnPreRender();
}

void CGPhyCubeNode::render() 
{  
	irr::u16 indices[] = 
	{0,1,2,  0,2,3,  1,6,2,  
	1,5,6,  0,5,1,  0,4,5,  
	0,3,7,  0,7,4,  2,7,3,  
	2,6,7,  4,6,5,  4,7,6 };  
	irr::video::IVideoDriver* driver = SceneManager->getVideoDriver();
	driver->setMaterial(Material);  
	driver->setTransform(irr::video::TS_WORLD, AbsoluteTransformation);
	driver->drawIndexedTriangleList(&Vertices[0], 8, &indices[0], 12); 
}

const irr::core::aabbox3d<f32>& CGPhyCubeNode::getBoundingBox() const
{  
	return Box;
}

s32 CGPhyCubeNode::getMaterialCount() 
{  
	return 1; 
} 

irr::video::SMaterial& CGPhyCubeNode::getMaterial(s32 i) 
{   
	return Material;
}

void CGPhyCubeNode::InitPhysics(neSimulator *gSim, int index, int materialindex)
{
	gCube = gSim->CreateRigidBody();
	neGeometry *geom = gCube->AddGeometry();  
	neV3 boxSize1;
	boxSize1.Set(CUBEX, CUBEY, CUBEZ);  
	geom->SetBoxSize(boxSize1[0], boxSize1[1], boxSize1[2]);
	gCube->UpdateBoundingInfo();  
	gCube->SetInertiaTensor( 
		neBoxInertiaTensor(boxSize1[0], boxSize1[1], boxSize1[2], CUBEMASS));
	gCube->SetMass(CUBEMASS);
	neV3 pos;
	pos.Set((rand()%10) / 10.0f * CUBEX,4.0f + index*(CUBEY+1), (rand()%10)/ 10.0f * CUBEZ);  
	gCube->SetPos(pos);
}

void CGPhyCubeNode::Update()
{
	neQ q = gCube->GetRotationQ();
	neM4 neMatrix = q.BuildMatrix();
	neMatrix.SetTranslation(gCube->GetPos());
	for (int x=0; x < 4; x++)
	{
		for (int y=0; y < 4; y++)
		{
			AbsoluteTransformation(y,x) = neMatrix.M[x][y];
		}
	}
}
Gonosz
Posts: 24
Joined: Wed Oct 29, 2003 4:21 pm
Location: Hungary (one joke and you're dead)

Post by Gonosz »

Oh I forgot. Just simply call the Update() function after the gSim->Advance() in your main loop.

If anyone needs more information (help or code), drop me a line.


Gonosz
Post Reply