I tried against the code of the tutorial "Introduction to Models" and have 101 entities count using "ENTITY_MODEL | ENTITY_BODY":
#include "engine.h"
#include <cstdio>
#include <sstream>
int entities = 0;
void _stdcall myfunc( TEntity entity, BP extra )
{
entities++;
}
inline float rnd( float min=0.0, float max=1.0 ) {
return min + ((float)rand()/RAND_MAX)*(max-min);
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd )
{
Initialize() ;
RegisterAbstractPath("D:/LE/2.32");
SetAppTitle( "ConsoleCPP" ) ;
Graphics( 800, 600 ) ;
TWorld world = CreateWorld() ;
if (!world) {
MessageBoxA(0,"Error","Failed to create world.",0);
return Terminate();
}
TBuffer gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);
//Create a camera
TCamera cam=CreateCamera();
CameraClearColor(cam,Vec4(0,0,1,1));
PositionEntity(cam,Vec3(0,2,-10));
//Create a light
TLight light=CreateDirectionalLight();
RotateEntity(light,Vec3(45,45,0));
//Create a render buffer
TBuffer buffer=CreateBuffer(800,600,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);
TModel model=LoadModel("abstract::oildrum.gmf");
if (!model) {
MessageBoxA(0,"Error","Failed to load mesh.",0);
goto exitapp;
}
SetBodyMass(model, 1);
for ( int n=1; n<=100; n++ ) {
model=CopyEntity(model);
PositionEntity(model,Vec3(rnd(-5,5),rnd(5,15),rnd(-5,5)));
RotateEntity(model,Vec3(rnd(0,360),rnd(0,360),rnd(0,360)));
SetBodyMass(model, 1);
}
//Main loop
while(!KeyHit(KEY_ESCAPE))
{
//Update the world
UpdateWorld();
//Render the scene
SetBuffer(buffer);
RenderWorld();
//Render lighting
SetBuffer(BackBuffer());
RenderLights(buffer);
entities = 0;
ForEachEntityDo(reinterpret_cast<byte*>(myfunc), 0, ENTITY_MODEL | ENTITY_BODY);
//std::string s;
std::stringstream out;
out << entities;
//s = out.str();
DrawText(0, 30, out.str().c_str());
//Swap the front and back buffer
Flip();
}
exitapp:
return Terminate();
}