Ok, it looks like I'm just asking for help and it looks that I haven't tried anything. I found samples. And I think little bit know how it works. Here you can see my code.
Variables:
private float _Gravity = -9.8f;
private World _World;
private Vector3 _CamSize = new Vector3(1, 1, 1);
private SceneNode _CamNode;
private SceneNode _CamViewNode;
private Body _CamBody;
private CollisionPrimitives.Ellipsoid _CamColl;
and rest of important code:
void camera_force_callback(Body body)
{
float mass;
Vector3 inertia;
body.getMassMatrix(out mass, out inertia);
Vector3 force = new Vector3(0, this._Gravity, 0);
force *= mass;
body.addForce(force);
body.setOmega(new Vector3(0, this._CameraRotationX, 0));
}
public override void CreateScene()
{
// Newton initialization
this._World = new World();
Vector3 cam_size = new Vector3(10, 10, 10);
float cam_mass = 40;
MogreNewt.Debugger.Instance.init(sceneMgr);
// sky box.
sceneMgr.SetSkyBox(true, "Examples/CloudyNoonSkyBox");
// shadows on!
sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE;
// floor object!
Entity city;
SceneNode citynode;
city = sceneMgr.CreateEntity("City", "mesto.mesh");
citynode = sceneMgr.RootSceneNode.CreateChildSceneNode("CityNode");
citynode.AttachObject(city);
city.CastShadows = false;
// using the new "SceneParser" TreeCollision primitive. this will automatically parse an entire tree of
// SceneNodes (parsing all children), and add collision for all meshes in the tree.
// Collision of city model
MogreNewt.CollisionPrimitives.TreeCollisionSceneParser stat_col = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser(this._World);
stat_col.parseScene(citynode, true);
MogreNewt.Body bod = new MogreNewt.Body(this._World, stat_col);
stat_col.Dispose();
bod.attachToNode(citynode);
bod.setPositionOrientation(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.IDENTITY);
//Collision of camera
this._CamNode = sceneMgr.RootSceneNode.CreateChildSceneNode("CamNode");
this._CamNode.SetScale(this._CamSize);
this._CamColl = new CollisionPrimitives.Ellipsoid(this._World, this._CamSize);
this._CamBody = new Body(this._World, this._CamColl);
this._CamColl.Dispose();
this._CamBody.attachToNode(this._CamNode);
Vector3 cam_inertia = MomentOfInertia.CalcEllipsoidSolid(cam_mass, cam_size);
this._CamBody.setMassMatrix(cam_mass, cam_inertia);
this._CamBody.ForceCallback += new ForceCallbackHandler(camera_force_callback);
// create an upvector. This forces the body to rotate just in the X and Z axes.
BasicJoints.UpVector uv2 = new BasicJoints.UpVector(this._World, this._CamBody, Vector3.UNIT_Y);
this._CamViewNode = this._CamNode.CreateChildSceneNode("CamViewNode", new Vector3(0, 0, 0));
this._CamViewNode.AttachObject(camera);
// position camera
camera.SetPosition(-3, -3, -50);
camera.LookAt(0, 0, 0);
//make a light
Light light;
light = sceneMgr.CreateLight("Light1");
light.Type = Light.LightTypes.LT_POINT;
light.SetPosition(0.0f, 100.0f, 100.0f);
}
I know I am not a programmer, but I thought it could work