"the Beginings"

Bady

03-04-2012 22:38:52

Maybe I am idiot for this, but i tryed to build in the Mogre in a Consol aplication (I don't want to use the tutorial framework)
I used this tutorial:
http://www.ogre3d.org/tikiwiki/Mogre+Basic+Tutorial+0

And I copy the first tutorial code to test it.

And i get this message:
An unhandled exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll

Additional information: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.


Visual studio 2010 premium version 4.0

The tutorial frameworks are working perfectly, I know, i forget, skip something, but i can't find the problem.
Please help me.

Aralox

04-04-2012 00:09:42

Hey Bady, I had this same problem too.
Did you use the Dlls from the tutorial project? They are actually kinda outdated - Most specifically MOIS, which is the reason you get the exception. You could just replace the MOIS dll with the latest one, but its better if you download all the latest Mogre dlls too.
The tutorial framework project gets around the old Mois dll by using an appconfig file.

By the way, I wanted to do the same thing you did - start up Mogre by myself without relying on a tutorial framework; and I highly recommend that you go through the tutorials on the wiki (using the tutorial framework, like they say), because what the tutorials teach you is how to build your own framework!
So just hang in there and do the tutorials, and you will be taught step by step how to properly initialize Mogre without the stress of trying to figure it out on your own.

Bady

04-04-2012 21:50:23

I tried to use the dll-s at the MogreDSK folders, and i have the latest Mogre/Ogre
OgreSDK_vc10_v1-7-4
And I was made all of Basic tutorials width the tutorial framework.

Just i want to make without the tutorial framework too.

ok, my problem started width this: First I was go trough the tutorials. And now I want to made a windows aplication to make my own "setings window"
But always get that error, if my program get a "Mogre command".
And I tried make a consol aplication (like the tutorials), and i get the same error again.
Please tell me, how to set up my project, to accept the mogre commands.

Aralox

05-04-2012 09:53:14

Ok its good that you have the latest Mogre Dlls, but just double-check that you have the latest Mois dlls too.
Do you have all your dlls in the bin/Debug folder of your project? For some reason, it only works if the dlls are in the same directory as the exe.

This is an example using Miyagi (a gui system), but try downloading it and compiling it, and see if you have any problems. It should work right out of the box.

zarfius

05-04-2012 12:00:41

Your error is cause by having a .NET 2.0 project trying to use .NET 4 DLL's or visa versa. There are a few ways around this. Firstly, as already suggested you should use the latest DLL's (they should be .NET 4) and you should make sure your project build settings are also set to .NET 4.

The alternative is to setup an app.config file that allows you to run .NET 2 DLL's in a .NET 4 project like so:
http://stackoverflow.com/questions/2455 ... mixed-mode

<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>


Or finally, a third option is to simply change your project settings to be a .NET 2 project.

Once you've got all that sorted out you might still run into problems if the DLL's are not in the right directory. The easiest option is to simply copy then into your bin/Debug or bin/Release folder but it has the downside that Visual Studio can delete them during a clean build. A better option is to add them as links to your solution and set them to 'Copy if newer' in properties.

Someone should really do a tutorial on this stuff so we can just link to the wiki ;)

Bady

08-04-2012 23:51:09

FInally work. Thanks to zafirus I realized that I forgot to inclue the app.config file. :?

Thank you

Beauty

14-04-2012 12:46:37

Hi Bady, welcome to Mogre!

Sorry for my late answer. I was focused to other topics in the last time.

Maybe I am idiot
Don't worry. Me and others had also problems in the first time.

I used this tutorial:
http://www.ogre3d.org/tikiwiki/Mogre+Basic+Tutorial+0

This is a very old wiki page and mostly outdated and not much necessary now. (For this reason why it's not linked from the Mogre tutorials page)

To make the startup more easy for beginners, somebody created an improved SDK installer for Mogre.
Unfortunately it wasn't updated for a while.

I suggest to start with the Basic tutorial 1.
The Tutorial Framework was re-written from the scratch 1 year ago by the great user AmirAbiri (now inactive). The framework is very good. For advanced usage, include it's source code instad of linking the dll file.
It's just download the code and add it to your procect. Then you see how it works and can modify it if needed.
The link you find on the tutorial framework wiki page in the section "source".

And i get this message:
An unhandled exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll

Additional information: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.


Your Mogre binary was compiled against .NET 2.0. So you can use it for projects, which use .NET upto version 3.5.
It's not usable with applications, which uses .NET 4.0. (The reason is the .NET related architecture.)
Solution: Either change your project settings to .NET 3.5 OR use Mogre binaries, which were compiled against .NET 4.0.

Bady

20-04-2012 23:23:35

A new Question:
Where can find a tutorial, how to include the mogre in window form. I mean the program run only in a window. I found one program in the mogre "Mogreform" but that does not work.


Edit:

Meantime i found a sourcecode:
http://www.ogre3d.org/tikiwiki/Mogre+Tutorial+-+Embedding+Mogre+in+Windows.Forms+-+Source
but i get this error:

------ Build started: Project: Tutorial06, Configuration: Debug x86 ------
C:\Users\Bady\Documents\Visual Studio 2010\Mogre destiy\Tutorial06\Tutorial06\Form1.Designer.cs(14,33): error CS0115: 'Tutorial06.Form1.Dispose(bool)': no suitable method found to override

Compile complete -- 1 errors, 0 warnings
Build started 2012.04.21. 1:42:55.
ResolveAssemblyReferences:
A TargetFramework profile exclusion list will be generated.
CoreResGen:
All outputs are up-to-date.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:x86 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\Microsoft.CSharp.dll" /reference:"C:\Users\Bady\Documents\Visual Studio 2010\Mogre destiy\Tutorial06\Tutorial06\bin\Debug\Mogre.dll" /reference:"C:\Users\Bady\Documents\Visual Studio 2010\Mogre destiy\Tutorial06\Tutorial06\bin\Debug\Mogre.TutorialFramework.dll" /reference:"C:\Users\Bady\Documents\Visual Studio 2010\Mogre destiy\Tutorial06\Tutorial06\bin\Debug\MOIS.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\mscorlib.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Data.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Deployment.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Drawing.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Windows.Forms.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Xml.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\x86\Debug\Tutorial06.exe /resource:obj\x86\Debug\Tutorial06.OgreForm.resources /resource:obj\x86\Debug\Tutorial06.Properties.Resources.resources /target:winexe Form1.cs Form1.Designer.cs Program.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs "C:\Users\Bady\AppData\Local\Temp\.NETFramework,Version=v4.0,Profile=Client.AssemblyAttributes.cs"

Build FAILED.

Time Elapsed 00:00:00.16
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Sorry, I am beginner in windows Forms.

Aralox

21-04-2012 04:50:27

Hi Bady,
Here is an excerpt using this technique, from my game:

//Create a window using winforms, to embed mogre in
_gameWindow = null;
string windowHandle = null;

_windowThread = new Thread(() =>
{
//GameWindow is a windows form class I made (just a plain window)
_gameWindow = new GameWindow();
Application.Run(_gameWindow);
});

_windowThread.Start();

while (_gameWindow == null || _gameWindow.Created == false) //spin wait
Thread.Sleep(10);

_gameWindow.Invoke((MethodInvoker)
delegate{ windowHandle = _gameWindow.Handle.ToString(); });

var settings = new NameValuePairList();
settings["externalWindowHandle"] = windowHandle;


_root.Initialise(false, WINDOW_TITLE);
_window = _root.CreateRenderWindow(WINDOW_TITLE, 0, 0, true, settings); //size of window taken from settings


Have a look at that and see if you understand it, and ask more questions for more info :)

I think using a windows form window instead of one created by Mogre is much better, as you get so much more abstracted control over the host window.
What I mean by that is: Mono has an implementation of System.Windows.Forms. So eventually when Mogre can be used with Mono, your game will still be fully cross-platform
if you use winforms. And we use winforms in the first place because it lets you control much more aspects of the window than you can using Mogre's RenderWindow - Usually if you want that kind of control, you have to work with the win32 apis directly

zarfius

21-04-2012 05:48:49

You might want to take a look at the open source version of my editor for an example of how to render in WinForms. It renders in multiple viewports, etc. If you want to make an editor of your own this could be a good starting point.
http://www.craftworkgames.com/blog/glue ... -for-ogre/

Beauty

24-04-2012 19:26:30

Aralox and Zarifus - thank you very much for your support in the Mogre forum!!
I'm happy to see that we have an active community. :D

Bady

26-04-2012 01:35:39

Thank you the helping, but problem is, I Can't uderstand perectly. Yes, I know the basics in Mogre and C# too, but:
zarfius, your Editor is awesome, but too complex to understand that width my beginner C# winform knowledge.

Aralox, I tried to understad your sourcecode, but I failed. Example I can't find out what the " _windowThread" need to do.
(another problem is, I can't imagine, Where is this source code in the program.)

I Know, I am idiot for this.

Aralox

26-04-2012 02:28:29

Thats ok, youre not an idiot at all - I wasnt sure how much info you wanted, so I just gave you a kinda general (and admittedly complex) example.
'_windowThread' is just the separate Thread I create to run the windows Form object in (_gameWindow). Its not necessary to keep hold of the thread, but I do because I abort it when my game is over (when the Mogre thread finishes).

The reason I create another thread in the first place is because winforms takes over the thread when you call Application.Run(). It also fires frame events like the mogre root does, but I didnt want to rewrite my whole program to depend on the winform, so I decided to put all the windows forms stuff in another thread (It also was pretty fun :P)

Here is what happens in the code below:
1. (Not Shown) Declare a class that derives from Form (easy, right click on project, add windows form)

2. Create a new thread, then pass to that thread a (parameterless, void-return) method (ive used a lambda method in this case but you can use a normal method) that you want to run on the thread. What i've passed it is some commands that create my windows form, and then start executing it using Application.Run(). Note: on this thread, execution basically stops at that line, i.e. statements that come after Application.Run() wont get executed until the winform that it is running terminates.

3. After calling _windowThread.Start(), you have a thread running a pretty windows form. Now what you want to do is use the 'handle' of the window as the render target mogre uses. What Ive done in the next little bit is a little loop that spin-waits (i.e. checks condition, then if true, waits for a bit, repeat) until the windows form is created. I do this because I was getting errors where it was trying to get the handle of the window before it was created (code was too fast or something).

4. So now that you know the windows form is created, we want to retrieve the handle from it. The key statement is this: "windowHandle = _gameWindow.Handle.ToString();". However you cannot just call that normally, as you will get an exception scolding you about screwing with another thread's business. To get around this, we invoke that command on the winform we created, which will run that invocation on its thread. This is really important. We can do this because winforms provides the Invoke and BeginInvoke functions (as well as a few others - its a useful interface that windows forms implements) which makes it really easy for us to call commands on its thread. Im not sure if you know already how it works, so Ill just give you a quick rundown (its worth looking up). Invoke() takes a System.Windows.Forms.MethodInvoker delegate, which it then well...invokes :D. You can see in the code how ive done it inline. You will use this alot in your program.

5. But anyway, now that we have the windowHandle (and we know we have it, because we used Invoke instead of BeginInvoke - look them up), we want to give it to Mogre. In the ogre documentation, look at Ogre::Root, and somewhere there they have a big list of all the parameters you can pass to Root.CreateRenderWindow() as settings. One of the settings is "externalWindowHandle", which is exactly what we want. After creating a NameValuePairList with the handle in it, we go ahead and create our RenderWindow object. You can see that ive passed 0s as the 'width' and 'height' of CreateRenderWindow - this is because mogre will now take all its dimensions from the window you have given it.

And there you have it, a nice window with all your fancy controls in it, rendering Mogre in the background! :D

Additional Notes: You can also use a Panel's handle to render in - which is how you create fancy movable viewports. but Important: for MOIS input, you can only use the window's handle.

Hope that helps - If you want me to create a simple example project, id be happy to

//Create a window using winforms, to embed mogre in
_gameWindow = null;
string windowHandle = null;

//_windowThread is actually declared as a class variable, but ive put 'Thread' here jsut so youre clear (its in System.Threading or something)
Thread _windowThread = new Thread(() =>
{
//GameWindow is a windows form class I made (just a plain window)
_gameWindow = new GameWindow();
Application.Run(_gameWindow);
});

_windowThread.Start();

while (_gameWindow == null || _gameWindow.Created == false) //spin wait
Thread.Sleep(10);

_gameWindow.Invoke((MethodInvoker)
delegate{ windowHandle = _gameWindow.Handle.ToString(); });

var settings = new NameValuePairList();
settings["externalWindowHandle"] = windowHandle;


_root.Initialise(false, WINDOW_TITLE);
_window = _root.CreateRenderWindow(WINDOW_TITLE, 0, 0, true, settings); //size of window taken from settings

zarfius

26-04-2012 04:32:06

Here is what happens in the code below:
Wow, that's an impressive and detailed description of how to get Mogre running in WinForms on another thread. I've throught about doing this a few times but never got around to trying. This might be worthy of dumping on the wiki :)

Bady

01-06-2012 04:14:19

so.....
I read some book about the windowsform and started to understand your code. ( the first problem was: I don't know about the threads. :oops: :D )
But I still have one problem:
What type the "_gameWindow" is?

And an another Question:
Can you tell me, how can I put it in a picturebox or a panel (or something like that)?

And Thank you for helping. Thank to you I learn a lot of useful thing.

Aralox

01-06-2012 05:28:40

Hey Bady,
Its good to know you're still interested :)

_gameWindow's type is just a class that i created, derived from Form. If you go add -> item -> new windows form (in visual studio), thats what you get.
It hasnt got anything special in it, i basically left it at the default form you get after creating it.

To render in a panel (i'm not sure about pictureboxes), you just have to pass in the panel's handle when creating the ogre render window, instead of the form's (ie. _gameWindow) handle. Its pretty cool rendering in panels :P. The only downside is MOIS only works properly if you give it the handle of the form, not the panel.

Good luck, and keep at it :)

Bady

01-06-2012 17:47:21

ok,

I write the code and on this line:
_window = _root.CreateRenderWindow("work", 0, 0, true, settings); //size of window taken from settings
I get this Exeption:

OGRE EXCEPTION(3:RenderingAPIException): Cannot create device! in D3D9Device::createD3D9Device at ..\..\..\ogre\RenderSystems\Direct3D9\src\OgreD3D9Device.cpp (line 707)

Maybe i forgot something?

Aralox

02-06-2012 01:44:07

try using OpenGL instead of DirectX, i switched over a while ago when i found out that directX does not like multiple windows

Bady

02-06-2012 04:19:04


Hope that helps - If you want me to create a simple example project, id be happy to



i don't want to ask, but (because when I solved an error I get an another) I would like to ask you to write me the simplest example code, please. (Just how the mogre stand up in a winform, not any more)
:oops:

Aralox

02-06-2012 08:24:11

No worries, here you go: https://www.box.com/s/b7ec8668ac9e9c3a3e71

You should get something that looks like this:

Bady

03-06-2012 03:08:13

Thank you :)
this is a huge help for me

Bady

08-06-2012 04:21:37

I'm sorry to disturb you again width my idiot questions, but I have an another teeny tiny problem:
When I whant to close the program (with the aplication.exit command), it does not close completely...
The window is closed, but a part of the program still run in the background (in your example, the consol)

How can I close the whole apication?

Aralox

08-06-2012 04:42:09

lol they are not idiot questions, dont worry. And what I do in my program to deal with that is: when the winforms window is closed, I will trigger a flag that tells my mogre thread to also quit, and also do it conversely, i.e. when my mogre thread quits, i will tell my window thread to quit too.

Since you are activating flags (just boolean variables usually) in different threads, you have to make sure that your operations are thread safe. I can show you the code I use in my program, but I dont want to ruin it for you haha - you mentioned that you were reading up on threads and stuff, so it'll be an interesting experience figuring out how to do it (its not hard).

Good luck :)

Bady

30-06-2012 03:21:00

Hy.

At least have enough time to work on my project.

I succesfully stop the mogre rendering (with the return flag)
But when exit the window With the "Application.Exit()" command, I get this Message:

An unhandled exception of type 'System.AccessViolationException' occurred in Mogre.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Can you give me some hint, where is the problem?

But the main question is :

how to load 3d object in the program? I mean not pre definied object:
I choose any 3d object with an opendialog. And of course, the object's number is not pre-defined too.

...Am if you not get tired of my novice questions.

Aralox

30-06-2012 08:15:24

Hey Bady

Whenever i get that error in my program, its because i forgot to unload a mogre manager that i used, eg. overlay manager. Make sure that you unload all the managers that you use before closing your program. If that is not the problem, then youll have to do some trial and error (or some good searching) to find out why that happens. Sorry but I havent done much coding in the last month as I had to focus on university, so I cant recall how I fixed that error in other cases.

As for your second question, that is a big thing to achieve, and it all depends on how much control you want / how much you want to re-invent the wheel (i.e. do everything by yourself). Do some more searching about writing code to load 3d models in Ogre, but off the top of my head, you have to deal with parsing different 3d format files, or you can use available libraries, etc.
Read up on the vertex manipulation classes (eg vertex buffer) of ogre, it will point you in the right direction.

Good luck!

zarfius

01-07-2012 00:19:35

Also, make sure you check your Ogre.log file for more hints. It's almost always helpful.

Bady

01-07-2012 18:04:03

edited

i forgot to unload a mogre manager

in the tutorials (in the "The Ogre startup sequence " too) when the RenderOneFrame gets false the whole program is stop running.
I don't know I need to unload all managgers. And I don't know how to do it either :?

You don't understand me....my bad english.
When I load an obejct :


Entity ent = mSceneMgr.CreateEntity("something", "something.mesh");
SceneNode node = mSceneMgr.RootSceneNode.CreateChildSceneNode("HeadNode");
node.AttachObject(ent);



need to make an entity With a variable (ent),
and a scenennode too.
How to load continuously object in a running program? (i mean, click, a button, and load an another object) in the tutorials no mentioned, how to do it, and i have no idea...

And I would like to askthree question(and I will stop asking beginner questions fo a while :D):
how to give the route of the 3d object for the entity command? I tried to give a full path, but he Mogre don't like the "\" .
I know the Mogre have a folder for objects, but i want to load objet from an another place.

second:
Possible to get a pixel data (ARGB) from the screen or get the whole rendered screen? (into a bitmap)
And how?

and the last:

how to glue object to an another object:
Example : a "man" walking, and if step an object, the object is "stick" on the "man".
No tutorial for this one too
:?

And good luck to university, Aralox :)

Aralox

02-07-2012 09:36:16

Heres a look at what my game does on exit:
private static void Quit()
{
_miyagiSystem.Dispose();
InputCollector.Unload();
MaterialManager.Singleton.UnloadAll(); //must unload all managers you use, or else access violation exception
OverlayManager.Singleton.DestroyAll();
TextureManager.Singleton.UnloadAll();
FontManager.Singleton.UnloadAll();
ResourceGroupManager.Singleton.UnloadResourceGroup(ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
_windowThread.Abort();
_root.Dispose(); //Prevents the access violation exception when using opengl
}


And ohh ok I see what you mean now. It shouldnt be too hard, look up the Path class in the MSDN documentation, and try passing in the full path to Mogre instead of partial ones (with the leading '/'). If you want an 'open' dialog, im quite sure there should be an easy way to get one using Winforms, so start with googling that.

I know there is definitely a way of saving/accessing the render texture (essential for post processing and stuff), but I actually have not dealt with it, so you'll have to look around for that too. Im sure it is something many others have wanted to do as well.

In order to 'glue' something to another, its as easy as making it the child of the other. eg. to glue a mesh to another object, attach the mesh to a scene node, then make that scene node the child of the scene node you want to glue it to.

Thanks for the well wishes, and keep at it :)

Bady

08-07-2012 16:09:50

Today I wanted to start to go trough the Intermediate Tutorials.
so far I did not want to start it because I wanted to properly understand the basics... (thanks to you now understand it :) )
But now i realized the Ogredotnet not the same the Mogre (how smart I am)
This means no usable Intermediate Tutorials for Mogre?
Now must start again from the beginning in Ogredotnet ? :(
Or how to connect the Mogre to Ogredotnet? ( in the tutorials not including the Mogre library, just Ogredotnet)
And where can find that ogredotnet dll-s.
Now a don't understand anithing :?


Oh:

Attention: The tutorials of OgreDotNet could run with Mogre. Maybe you have to edit some code, but this should be much more easy than porting Ogre C++ code
That was nice....
The half program is a big error for me.... It was a big problem in a tutorial.... :cry:

My problem is, I can learn only tutorials (or in scool with a teacher) If I see how it work the basics, then I can understand it perfectly...
In the "libraries" I can't do anithing with the bare commands, because I can't understand what, how, when do it...

Forget it, i Failed :?

Aralox

09-07-2012 02:34:06

This is a barrier you will have to conquer Bady. Tutorials are only good for helping you get started, and to teach you how to learn, not just what to learn.
Reading and learning from the documentation is very important, and the only way to get better at it is to do it. A really good way of getting the motivation to learn is to decide to make a game.
Come up with a simple game idea, it doesn't have to be original (my first was a circular pong game called spaceball - i learned a massive amount from that; and my second was a clone of starwars battlefront - I had so so much fun doing that, and learned an incredible amount more too).
As you deal with all the problems involved, you will do alot of searching and documentation-reading, and gain experience.

Don't give up, the satisfaction of seeing people (and you) enjoy your game is well worth it

Bady

13-07-2012 06:20:42

Undestand something in the documentation is really hard, and sometimes not understandable perfectly :( (especially when you programming in c#, and the documentation is in c++ ) But, I will try my best, if I collect enough fortitude.
But Now I will broke my Promise and I ask some noob question:

It is possible somehow, to color a non textured object (I mean loaded mesh object)? I know I can put texture on it, but I want to use several colors.
And How can I set to show only the wires of the object?

and I want to move the camera where it see, but I don't know which command to do this, can you give me some hint?

Thank you.

Aralox

13-07-2012 08:04:26

A quick google search will give you the answers to most of your questions - see here for coloring the mesh: http://www.ogre3d.org/forums/viewtopic.php?f=5&t=52641
The wires render and camera look are also very commonly sought out techniques, there are definitely forum posts about them

Bady

18-10-2012 04:21:37

An another beginner quetion, what is started to drive me Crazy:

I would like to save (and later load) objects and the camera x angle, y angle and z angle)
I tryed with the orientation thing, but the result is: nothing. When I "load" the four number (I dont understand why the Orientation "W" need)
the object not rotated to the saved positure. (the camera look wrong direction, and the object don't do anything)
to get the orientation datas I use this commands:

ds.Adatok.Rows[6] = cn.Orientation.w.ToString();
ds.Adatok.Rows[7] = cn.Orientation.w.ToString();
ds.Adatok.Rows[8] = cn.Orientation.w.ToString();
ds.Adatok.Rows[9] = cn.Orientation.w.ToString();

and tried to restore with this:

cn.Orientation = new Mogre.Quaternion((float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][6]), new Mogre.Vector3((float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][7]), (float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][8]), (float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][9])));

What did I do wrong?

Aralox

18-10-2012 04:46:00

you made a typo in this part:

ds.Adatok.Rows[6] = cn.Orientation.w.ToString();
ds.Adatok.Rows[7] = cn.Orientation.w.ToString();
ds.Adatok.Rows[8] = cn.Orientation.w.ToString();
ds.Adatok.Rows[9] = cn.Orientation.w.ToString();


you want to get the x,y, and z of the orientation too, rather than just w for all

Bady

19-10-2012 02:33:03

Hups, I write here wrong...

The code is bigger, just I want to write here the simple commands, and I forgot to write the "w" to "x","y" and "z"

the data in the "adatok" datatable
w: 0,7070789
x:-0,006061956
y:-0,008726203
z:0
the obect still standing the loaded orientation. (the scale, and the position is changed perfectly)
here the part of the loading code(the positioning part):



cn = this.mgr.RootSceneNode.GetChild((ushort)objnum);
sn = this.mgr.GetSceneNode(objnum.ToString());
ent = this.mgr.GetEntity(objnum.ToString());



MessageBox.Show(ds.Adatok.Rows[objcounter][3].ToString()+" : "+ds.Adatok.Rows[objcounter][4].ToString()+" : "+ds.Adatok.Rows[objcounter][5].ToString());
cn.Position = new Mogre.Vector3((float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][3]), (float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][4]), (float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][5]));

cn.Orientation = new Mogre.Quaternion((float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][6]),new Mogre.Vector3((float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][7]), (float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][8]), (float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][9])));

cn.Scale(new Mogre.Vector3((float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][10]), (float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][11]), (float)Convert.ToDecimal(ds.Adatok.Rows[objcounter][12])));


edit:

And here the rotate code (meanvile I changed it a bit, now the full actual orientation changed in the datatable when I push the button.):


private void minxrotate_Click(object sender, EventArgs e)
{

cn.Yaw(new Degree(-(float)rotatenumber.Value));

objtree.BeginUpdate();

ds.Adatok.Rows[aktobj][6] = cn.Orientation.w.ToString();
ds.Adatok.Rows[aktobj][7] = cn.Orientation.x.ToString();
ds.Adatok.Rows[aktobj][8] = cn.Orientation.y.ToString();
ds.Adatok.Rows[aktobj][9] = cn.Orientation.z.ToString();


objtree.EndUpdate();
ds.Adatok.AcceptChanges();
}

But I think the problem is in the full loading algorithm, and it is not a Mogre question.
And If you will say, this commands are good, I will happy, because I found the problem :)

Aralox

19-10-2012 08:11:18

Ah ok yeah i figured you wouldnt make typos like that :P - I haven't done any programming for some months now, and cant really spot anything wrong right now, but i would strongly recommend making a separate test project where you isolate your problem with very basic code. I suspect the error might be due to the complexity of your storage system, which could have caused you to index the array wrongly somewhere or make small errors like that.
In a test project, use simple variables like x,y,z,w and strip things down to the absolute basics - this will definitely help you find out exactly what the problem is.

It could potentially be a problem with Mogre, but 9/10 times its always a programmer problem.
Good luck