how to use Klasker's cal3d scenenode?

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.
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

how to use Klasker's cal3d scenenode?

Post by terrorchrist »

I have some problems in understanding how the cal3dscenenode of klasker is used...
is there any tutorial?

or can u explain it to me briefly?
plz help ^^
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

Post by terrorchrist »

hi!
I think that I*ve already figured out how this is done:

Code: Select all

ICal3DModel *model = getCal3DModelFromFile(this->rootManager->GetIrrManager()->GetDriver(),configfile);
		ICal3DSceneNode *node = irr::scene::createCal3DSceneNode(this->rootManager->GetIrrManager()->GetSceneManager(),model,0);
The problem is, that the linker says the following:
Error 1 error LNK2001: unresolved external symbol "class irr::scene::ICal3DSceneNode * __cdecl irr::scene::createCal3DSceneNode(class irr::scene::ISceneManager *,class irr::scene::ICal3DModel *,class irr::scene::ISceneNode *)" (?createCal3DSceneNode@scene@irr@@YAPAVICal3DSceneNode@12@PAVISceneManager@12@PAVICal3DModel@12@PAVISceneNode@12@@Z) PlayerRemote.obj
This is really weird as I am coding in visual studio 2k5 and intelli sense can find the function irr::scene::createCal3DSceneNode()

can anyone tell me what I did wrong?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You did not include the object code for the scene node into your project. IntelliSense just as the compiler use only the headers while the linker requires the compiled object.
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

Post by terrorchrist »

no it wasnt that... seems that the function in the cpp was named differently than that in the header....
however it now worked. I had to make dynamics arrays (new Int[]) out of the (Int bla[dd]) syntax, to get this to work but now I have another linker problem:
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall CalRenderer::getFaces(unsigned short *)" (__imp_?getFaces@CalRenderer@@QAEHPAG@Z) referenced in function "public: virtual void __thiscall irr::scene::CCal3DSceneNode::render(void)" (?render@CCal3DSceneNode@scene@irr@@UAEXXZ) CCal3DSceneNode.obj
in this part of code:

Code: Select all

//------------------------------------------------------//
      s32 faceCount = renderer->getFaceCount();               // Get the number of faces
      u16 **faceBuffer = new u16*[faceCount];                         // Buffer for the face v1,v2,v3 indices
	  for(int i = 0; i<faceCount; i++)
	  {
		faceBuffer[i] = new u16[3];
	  };
	  renderer->getFaces( &faceBuffer[0][0] );                // Copy the face indices to the buffer
      
I simply do not get this, because I have already included the lib into my project with the #pragma comment(lib, "cal3d.lib") command... so what could be missing?
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

To solve that problem, you need to define CAL_16BIT_INDICES. To do that you can either open "global.h" and edit it from there or let it be overall defined by setting it in the project settings.
The reason you are getting an undefined reference is that the signatures don't match when the compiled cal3d has 32-bit indices.

I'm working on a new version of the scene node that should be a little easier to implement, with support for gcc/mingw32 and microsoft's compiler.
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

Post by terrorchrist »

thanks for that hint klasker!

now I can compile it but as I start the program, it crashes when the "render()" method of the cal3dscenenode is called.

this is because I am developing in visual studio sk5 and had to change your array syntax...
for example I changed:

Code: Select all

f32 vertexBuffer[vertexCount][3];
to

Code: Select all

f32 **vertexBuffer = new f32*[vertexCount];             // Buffer for the vertex coordinates
	  for(int i = 0; i<vertexCount; i++)
	  {
		vertexBuffer[i] = new f32[3];
	  };
      renderer->getVertices( &vertexBuffer[0][0] );           // Copy the vertices to the buffer

I now can compile this code, but I seem did it wrong because as I let the informations of the buffers be printed on screen I only get values that cannot be true like only 0.00000 and -0.00000s....

I print them like this:

Code: Select all

  for(int i = 0; i<vertexCount; i++)
	  {
		  for(int j = 0; j<3; j++)
		  {
			printf("\n texCoordBuffer[%d][%j] = %f",i,j,vertexBuffer[i][j]);
		  }
	  }
do you have an idea what could be wrong with my code?
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

Post by terrorchrist »

now I fixed the problem with the dynamic arrays provisional as I entered a fixed array size of [10000][3]...

but there are still two problems:

the first is that the fps count drops from about 250 to 30 when ONLY THIS F**ING model is rendered additionally

the second is that - though it is renderes (which I am already very happy about)- it is not rendered correctly!

see:http://stud04.technikum-wien.at/~tw04n178/cal3d_bug.jpg

has anyone any ideas?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Are you sure that you have less than 10000 or 65535 vertices? It seems to be you're lacking some vertices or correct indices. Either the additional vertices are not set (or some values from after your array are used), or the 16bit indices are overflowing (in addition to using values behind your allocated array).
BTW: Why don't you use 'new f32[3*vertexcount]'?
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

Post by terrorchrist »

using f32 *vertexBuffer = new f32[3*vertexCount];
does not work as this array is used as an two dimensional one.

= later on there is this part of code:

Code: Select all

 for (s32 vert=0; vert<vertexCount; vert++)              // Convert all vertices to irrlicht format
      { // Irrlicht and Cal3D uses different coordinates. Irrlicht's Y points up, where Cal3D's Z points up
        irrVertexBuffer[vert].Pos.X = vertexBuffer[vert][0];  // Set the X coordinate
        irrVertexBuffer[vert].Pos.Y = vertexBuffer[vert][2];  // Set the Y coordinate (Cal3D's Z coord)
        irrVertexBuffer[vert].Pos.Z = vertexBuffer[vert][1];  // Set the Z coordinate (Cal3D's Y coord)
        
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

Post by terrorchrist »

ok due to hybrid's hint I modified the whole render() method of Klasker's CCal3DSceneNode to use only one dimensional arrays.

Now I can compile my application and the Cal3d model gets rendered, but the same buggy rendering as before happens....

I am perfectly sure that the models are not to blame for this as I am using the cally and the paladin model of cal3d itself...

so I would appreciate if you could just test my code and give me some feedback...

here is the code of my "new" render() method

Code: Select all

//============================================================//
// render()
// Renders the Cal3D model
void CCal3DSceneNode::render()
{
  //std::cout << "Begin rendering\n";
  //----------------------------------------------------------//
  if ( m_calModel == 0 ) return;                              // Make sure there is a model to render

  //----------------------------------------------------------//
  video::IVideoDriver* driver = SceneManager->getVideoDriver(); // Get the video driver
  CalRenderer* renderer = m_calModel->getRenderer();          // Get the CalRenderer
  
  
  //----------------------------------------------------------//
  // All we're doing here is form a bridge between the CalRenderer and the IVideoDriver
  // The CalRenderer gives us data (doesn't draw anything) and IVideoDriver needs that data
  // Only problem is that we need to convert it to Irrlicht Compatible data
  // To explain what's going on, this simple diagram should help:
  //  CalRenderer >--GET--> Data >--CONVERT--> Irrlicht Format >--SEND--> IVideoDriver >--DRAW--> ..

  //----------------------------------------------------------//
  m_calModel->getSkeleton()->calculateBoundingBoxes();        // Calculate the bounding box of the skeleton

  //----------------------------------------------------------//
  if ( renderer == 0  ) return;                               // Bail out if no renderer was received
  if ( !renderer->beginRendering() ) return;                  // Bail out if renderer encountered an error
  
  //----------------------------------------------------------// Move to our position (and rotate/scale)
  driver->setTransform( video::ETS_WORLD, AbsoluteTransformation );


  //----------------------------------------------------------//
  s32 numMeshes = renderer->getMeshCount();                   // Get the number of meshes we need to draw
  for ( s32 meshId = 0; meshId < numMeshes; meshId++ )        // Loop for every mesh
  {
    //--------------------------------------------------------//
    s32 numSubMeshes = renderer->getSubmeshCount(meshId);     // Get the number of submeshes
    for ( s32 subId = 0; subId < numSubMeshes; subId++ )      // Loop for every submesh
    {
      if ( !renderer->selectMeshSubmesh(meshId, subId) )      // Select the current mesh and submesh
      {
        continue;                                             // Skip this submesh if it failed
      }
      
      //------------------------------------------------------//
      if ( !m_OverrideMaterial )                              // Should we use Cal3D's material?
      {
        u8 meshColor [4];                                     // Color stored in RGBA format
                                                              // Irrlicht wants it in ARGB format
        renderer->getAmbientColor( meshColor );               // Get the ambient color
        m_Material.AmbientColor.setRed( meshColor[0] );       // Set the red component
        m_Material.AmbientColor.setGreen( meshColor[1] );     // Set the green component
        m_Material.AmbientColor.setBlue( meshColor[2] );      // Set the blue component
        m_Material.AmbientColor.setAlpha( meshColor[3] );     // Set the alpha component
        
        renderer->getDiffuseColor( meshColor );               // Get the diffuse color
        m_Material.DiffuseColor.setRed( meshColor[0] );       // Set the red component
        m_Material.DiffuseColor.setGreen( meshColor[1] );     // Set the green component
        m_Material.DiffuseColor.setBlue( meshColor[2] );      // Set the blue component
        m_Material.DiffuseColor.setAlpha( meshColor[3] );     // Set the alpha component
        
        renderer->getSpecularColor( meshColor );              // Get the specular color
        m_Material.SpecularColor.setRed( meshColor[0] );      // Set the red component
        m_Material.SpecularColor.setGreen( meshColor[1] );    // Set the green component
        m_Material.SpecularColor.setBlue( meshColor[2] );     // Set the blue component
        m_Material.SpecularColor.setAlpha( meshColor[3] );    // Set the alpha component
        
        m_Material.Shininess = renderer->getShininess();      // Set the shininess factor
        
        if ( renderer->getMapCount() >= 1 )
        {                                                     // Get the irrlicht texture from user data
          m_Material.Texture1 = (video::ITexture*)renderer->getMapUserData(0);
        }
      }
      
      //------------------------------------------------------//
      s32 vertexCount = renderer->getVertexCount();           // Get the number of vertices

	  
      if (vertexCount == 0) continue;                         // Avoid trying to allocate a [0][3] array

//###############################################################################################
//################### CHANGED FROM vertexBuffer[vertexCount][3]
//###############################################################################################

      f32 *vertexBuffer = new f32[3*vertexCount];		// Buffer for the vertex coordinates
	  renderer->getVertices(&vertexBuffer[0]);           // Copy the vertices to the buffer

	  
      
      //------------------------------------------------------//
//###############################################################################################
//################### CHANGED FROM normalBuffer[vertexCount][3]
//###############################################################################################

	  f32 *normalBuffer = new f32[3*vertexCount];			// Buffer for the vertex normals
      renderer->getNormals( &normalBuffer[0] );            // Copy the normals to the buffer

	  
      
      //------------------------------------------------------//
//###############################################################################################
//################### CHANGED FROM textCoordBuffer[vertexCount][2]
//###############################################################################################

        f32 *texCoordBuffer = new f32[2*vertexCount];				// Buffer for the vertex texture coordinates
      renderer->getTextureCoordinates( 0, &texCoordBuffer[0] );// Copy the texture coordinates to the buffer
      
	  

      //------------------------------------------------------//
      s32 faceCount = renderer->getFaceCount();               // Get the number of faces

//###############################################################################################
//################### CHANGED FROM faceBuffer[vertexCount][3]
//###############################################################################################

	  s32 *faceBuffer = new s32[3*faceCount];				// Buffer for the face v1,v2,v3 indices
	  renderer->getFaces( &faceBuffer[0] );                // Copy the face indices to the buffer
	  
	
      //------------------------------------------------------//
	  video::S3DVertex *irrVertexBuffer = new video::S3DVertex[vertexCount];         // Buffer for the irrlicht vertices

//###############################################################################################
//################### MODIFIED TO BE ABLE TO USE ONE DIMENSIONAL ARRAYS! -->
//################### instead of "vertexBuffer[vert][0]" - "vertexBuffer[3 * vert + 0]"
//################### instead of "vertexBuffer[vert][1]" - "vertexBuffer[3 * vert + 1]" and so on
//###############################################################################################

      for (s32 vert=0; vert<vertexCount; vert++)              // Convert all vertices to irrlicht format
      { // Irrlicht and Cal3D uses different coordinates. Irrlicht's Y points up, where Cal3D's Z points up
        irrVertexBuffer[vert].Pos.X = vertexBuffer[3 * vert];  // Set the X coordinate
        irrVertexBuffer[vert].Pos.Y = vertexBuffer[3 * vert + 2];  // Set the Y coordinate (Cal3D's Z coord)
        irrVertexBuffer[vert].Pos.Z = vertexBuffer[3 * vert + 1];  // Set the Z coordinate (Cal3D's Y coord)
        
        irrVertexBuffer[vert].Color.set(255,255,255,255);     // Vertex colors aren't supported by Cal3D
        
        irrVertexBuffer[vert].Normal.X = normalBuffer[3 * vert];// Set the X coordinate
        irrVertexBuffer[vert].Normal.Y = normalBuffer[3 * vert + 2];// Set the Y coordinate (Cal3D's Z coord)
        irrVertexBuffer[vert].Normal.Z = normalBuffer[3 * vert + 1];// Set the Z coordinate (Cal3D's Y coord)
        
        irrVertexBuffer[vert].TCoords.X = texCoordBuffer[2 * vert];// Set the X texture coordinate (U)
        irrVertexBuffer[vert].TCoords.Y = texCoordBuffer[2 * vert + 1];// Set the Y texture coordinate (V)
      }
      
      //------------------------------------------------------// Invert triangle direction
      for (s32 face=0; face<faceCount; face++)                // Irrlicht wants indices in the opposite order
      {
        s32 faceA = faceBuffer[3 * face];                      // Swap first and last vertex index
        faceBuffer[3 * face] = faceBuffer[3 * face + 2];            // Set the first to the last
        faceBuffer[3 * face + 2] = faceA;                          // And the last to the first
      }
      
      //------------------------------------------------------// Finally! Time to draw everthing
      driver->setMaterial( m_Material );                      // Set the material we are using
      
      driver->drawIndexedTriangleList(                        // Draw the triangle list
            &irrVertexBuffer[0],                              // Array of vertices
            vertexCount,                                      // Number of vertices
            (u16*)&faceBuffer[0],                                // Array of indices
            faceCount);                                       // Number of triangles
			

//###############################################################################################
//############# ADDED : deleting allocated memory after usage
//###############################################################################################
	  delete vertexBuffer;
	  delete normalBuffer;
	  delete texCoordBuffer;
	  delete faceBuffer;
      
    } // for subId
    
  } // for meshId
  
  //----------------------------------------------------------//
  renderer->endRendering();                                   // Tell the renderer we are finished now
  
}

just copy paste it into your "Klasker Cal3DSceneNode" and tell me what happens....
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

Post by terrorchrist »

I now overcame the problem of the buggy render method by replacing it with the render method of the other CCal3DSceneNode I previously tried to use...
Now the first rendering bug with the totally mixed up mesh faces does not exist any more.
BUT unfortunately ALL meshnormals are the wrong way around - as you can see in this pícture:

http://stud04.technikum-wien.at/~tw04n1 ... ormals.jpg

so pleays anyone simply tell me what part of the following code I have to alter to get the mesh normals right...

Code: Select all

if( !m_calModel ) {
				printf("Null cal model in PostRender\n");
				return;
			}

	
			
				irr::video::IVideoDriver* driver=SceneManager->getVideoDriver();
				
				
				driver->setTransform(irr::video::ETS_WORLD, AbsoluteTransformation);
				
				
				irr::video::S3DVertex tmp;
				irr::scene::SMeshBuffer mb;

				unsigned char meshColor[4]; // r g b a


				// get the renderer of the model
				CalRenderer *pCalRenderer;
				pCalRenderer = m_calModel->getRenderer();
				pCalRenderer->setNormalization(true);

				if(this->DebugDataVisible)
				{
					irr::video::SMaterial mat;
					mat.Wireframe=false;
					mat.Lighting=false;
					driver->setMaterial(mat);
					driver->draw3DBox(Box);

					CalSkeleton* pCalSkeleton = m_calModel->getSkeleton();
					pCalSkeleton->calculateBoundingBoxes();
					std::vector<CalBone*> &vectorCoreBone = pCalSkeleton->getVectorBone();
					irr::core::aabbox3df b;
					CalVector p[8];
					vector3df v[8];
					

					for(size_t boneId=0;boneId<vectorCoreBone.size();++boneId)
					{
						CalBone* bone=vectorCoreBone[boneId];
						CalBoundingBox & calBoundingBox = bone->getBoundingBox();
						calBoundingBox.computePoints(p);
						
						for(int i=0;i<8;++i) v[i].set(p[i].x,p[i].y,p[i].z);
						
						driver->setMaterial(mat);
						// draw the box
						driver->draw3DLine(v[0],v[1],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[0],v[2],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[1],v[3],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[2],v[3],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[4],v[5],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[4],v[6],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[5],v[7],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[6],v[7],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[0],v[4],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[1],v[5],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[2],v[6],irr::video::SColor(255,0,0,255));
						driver->draw3DLine(v[3],v[7],irr::video::SColor(255,0,0,255));

					}
						

				}


				// begin the rendering loop
				if(pCalRenderer->beginRendering())
				{

					// get the number of meshes
					int meshCount;
					meshCount = pCalRenderer->getMeshCount();

					// render all meshes of the model
					int meshId;
					for(meshId = 0; meshId < meshCount; meshId++)
					{
						// get the number of submeshes
						int submeshCount;
						submeshCount = pCalRenderer->getSubmeshCount(meshId);

						// render all submeshes of the mesh
						int submeshId;
						for(submeshId = 0; submeshId < submeshCount; submeshId++)
						{
							// select mesh and submesh for further data access
							if(pCalRenderer->selectMeshSubmesh(meshId, submeshId))
							{

								// set the material ambient color
								pCalRenderer->getAmbientColor(&meshColor[0]);
								m_Material.AmbientColor.set(meshColor[3],meshColor[0],meshColor[1],meshColor[2]);

								// set the material diffuse color
								pCalRenderer->getDiffuseColor(&meshColor[0]);
								m_Material.DiffuseColor.set(meshColor[3],meshColor[0],meshColor[1],meshColor[2]);

								// set the material specular color
								pCalRenderer->getSpecularColor(&meshColor[0]);
								m_Material.SpecularColor.set(meshColor[3],meshColor[0],meshColor[1],meshColor[2]);

								// set the material shininess factor
								m_Material.Shininess = pCalRenderer->getShininess();

								
								int vertexCount = pCalRenderer->getVertexCount();
								
								// get the transformed vertices of the submesh
								//static float meshVertices[30000][3];
								f32 *meshVertices = new f32[vertexCount * 3];
								pCalRenderer->getVertices(&meshVertices[0]);
																

								// get the transformed normals of the submesh
								//static float meshNormals[30000][3];
								f32 *meshNormals = new f32[vertexCount * 3];
								int normalsCount=pCalRenderer->getNormals(&meshNormals[0]);

								// get the texture coordinates of the submesh
								//static float meshTextureCoordinates[30000][2];
								f32 *meshTextureCoordinates = new f32[vertexCount *2];
								int textureCoordinateCount;
								textureCoordinateCount = pCalRenderer->getTextureCoordinates(0, &meshTextureCoordinates[0]);

								// get the faces of the submesh
								//static CalIndex meshFaces[50000][3];
								int faceCount = pCalRenderer->getFaceCount();
								s32 *meshFaces = new s32[faceCount*3];
								pCalRenderer->getFaces(&meshFaces[0]);
								
								if((pCalRenderer->getMapCount() > 0) && (textureCoordinateCount > 0))
								{
									irr::video::ITexture* t=static_cast<irr::video::ITexture*>(pCalRenderer->getMapUserData(0));
									m_Material.Texture1=t;
								}
								
								mb.Vertices.clear();
								for(int i=0;i<vertexCount;i++)
								{
									tmp.Pos.set(meshVertices[i*3+0],meshVertices[i*3+2],meshVertices[i*3+1]);
									tmp.Normal.set(meshNormals[i*3+0],meshNormals[i*3+2],meshNormals[i*3+1]);
									tmp.TCoords.set(meshTextureCoordinates[i*2+0],meshTextureCoordinates[i*2+1]);
									tmp.Color=irr::video::SColor(255,255,255,255);
									mb.Vertices.push_back(tmp);


								}

								mb.Indices.clear();
								for(int i=0; i<faceCount; ++i){
									mb.Indices.push_back(meshFaces[i*3+0]);
									mb.Indices.push_back(meshFaces[i*3+1]);
									mb.Indices.push_back(meshFaces[i*3+2]);
								}

								// draw 
								driver->setMaterial(m_Material);

								driver->drawIndexedTriangleList(mb.Vertices.const_pointer(),
									mb.Vertices.size(),mb.Indices.const_pointer(),faceCount);
								
								//CLog::GetSingleton().write(LOG_APP,"#Verts %d #Norm %d #Tex %d #Faces %d #Map %d",
								//	vertexCount,normalsCount,textureCoordinateCount,faceCount, pCalRenderer->getMapCount());
								delete meshVertices;
								delete meshNormals;
								delete meshTextureCoordinates;
								delete meshFaces;


							}
						}
					}

					// end the rendering
					pCalRenderer->endRendering();
					
				}
thanks a lot guys!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Try to change the index order to 0,2,1 on the last lines of the code.
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

Post by terrorchrist »

gg you are a joker!

^^ which ones
terrorchrist
Posts: 83
Joined: Wed Apr 26, 2006 10:07 pm
Location: Vienna

Post by terrorchrist »

ok
now I changed

Code: Select all

  mb.Indices.clear(); 
                        for(int i=0; i<faceCount; ++i){ 
                           mb.Indices.push_back(meshFaces[i*3+0]); 
                           mb.Indices.push_back(meshFaces[i*3+1]); 
                           mb.Indices.push_back(meshFaces[i*3+2]); 
                        }
to

Code: Select all

  mb.Indices.clear(); 
                        for(int i=0; i<faceCount; ++i){ 
                           mb.Indices.push_back(meshFaces[i*3+0]); 
                           mb.Indices.push_back(meshFaces[i*3+2]); 
                           mb.Indices.push_back(meshFaces[i*3+1]); 
                        }
that did the trick.
unfortunately the frame count still drops from 200 to 20 when I load the cal3d mesh....
If cal3d is really SOOOOOOO slow, then what game on earth could use it? A game with maps that have 200 triangles and where there is only one player?
i mean this "performance" is ridiculous...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

As you can see from the code (if you really understand it) there's a lot of memory allocation which does all too much for your purpose. Even worse the code uses lots of push_back operations which allocate memory each time. I think klasker optimized his code to avoid it, or was it for the tree nodes? It's pretty simple though: use set_used(vertexcount) first and then access the array elements directly with arrayname[index]. This should give a major performance boost.
Post Reply