I want to put a barell model (and a lot of other models of course) into my game. It looks like an ellipsoid, with the two ends cutted down, so none of the premade entities are acceptable to this model. So I try to make a StaticTriangleGroup from the model, and use the generatePositionList method to make a ConvexHull from the vertex list. Then I add this ConvexHull to the space with 'noDisplayObject' tag, so it will not get into the entityRenderer. Then I made a DisplayModel, and set the entity property to the ConvexHull, so the real barell model with the DisplayModel will be visible, and the physic modelling will be done width the ConvexHull.
This idea is working, but there is a problem, when the barell starting to move on the screen. There is a lag in its moving, sometimes it is freezing for a few moments, and then continue to move. The interesting thing is, that the other models in my scene, made of the Box premade entity, are working snoothly at the same time, there aren't any lag in their moving. How can I take rid of the lag? Please help...
Here is my code of setting up the barell (the model named 'Hordo' in the code):
Code: Select all
StaticTriangleGroup HordoTriangleGroup = new StaticTriangleGroup(.5f, 1, 0, 0, .4f, 0);
HordoTriangleGroup.initializeData(Hordo);
List<Vector3> Hordovertexlist = new List<Vector3>();
HordoTriangleGroup.generatePositionList(Hordovertexlist, false);
ConvexHull HordoHull = new ConvexHull(new Vector3(0,5,0),Hordovertexlist,20f);
HordoHull.tag = "noDisplayObject";
space.add(HordoHull);
DisplayModel HordoDisplayModel = new DisplayModel(Hordo);
HordoDisplayModel.entity = HordoHull;
entityRenderer.displayModels.Add(HordoDisplayModel);
Thanks for any help...