Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (VoroneTZ, Quad), 479 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 31 of 32 1 2 29 30 31 32
Re: C# wrapper - RELEASE [Re: Timothy] #402651
06/08/12 14:28
06/08/12 14:28
Joined: Apr 2007
Posts: 141
Germany
Timothy Offline
Member
Timothy  Offline
Member

Joined: Apr 2007
Posts: 141
Germany
How can I use vec_for_screen in the wrapper? There are no examples and I can't figure it out by myself.

Re: C# wrapper - RELEASE [Re: Timothy] #402655
06/08/12 15:06
06/08/12 15:06
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
i have not used it but should be
the same as manual except called like this

yourvector.vec_for_screen(yourview)


A8.3x Commercial, AcknexWrapper and VS 2010 Express
○pararealist now.
Re: C# wrapper - RELEASE [Re: pararealist] #402656
06/08/12 15:21
06/08/12 15:21
Joined: Apr 2007
Posts: 141
Germany
Timothy Offline
Member
Timothy  Offline
Member

Joined: Apr 2007
Posts: 141
Germany
Thank you, it works. I got the whole syntax wrong crazy

Re: C# wrapper - RELEASE [Re: Timothy] #402948
06/12/12 17:01
06/12/12 17:01
Joined: Apr 2007
Posts: 141
Germany
Timothy Offline
Member
Timothy  Offline
Member

Joined: Apr 2007
Posts: 141
Germany
Hi, when I use an OpenFileDialog to load a model with

"ENTITY.ent_create(LoadModel.FileName, new Vector(100, 100, 0), *anyfunction*);"

I often get an AccessViolationException error (...wurde nicht behandelt. Es wurde versucht,
im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf,
dass anderer Speicher beschädigt ist).

The Debugger points to (EngFun.cs):
Code:
/// <summary>
        /// engine_frame - see Gamestudio manual
        ///  - for more detailed and up to date documentation, visit http://manual.3dgamestudio.net/ </summary>
        public static int engine_frame()
        {
            return NativeEngFun.engine_frame();
        }


This mainly happens if I load an *.MDL-file with 3+ MB. Then the engine needs a little time to load the model
(short freeze of the embedded engine window) and I get the error (depends on the complexity/texture space of the model).
I suspect that maybe the Scheduler and this freeze cause this error but it could be my fault, too. Do you have an idea?

Re: C# wrapper - RELEASE [Re: Timothy] #402950
06/12/12 17:28
06/12/12 17:28
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
Where are you calling openfiledialog from?
could be a threading issue maybe.
LoadModel.FileName is this a string? or a class that returns a string? Maybe check that string is not empty before passing to ent_create().


A8.3x Commercial, AcknexWrapper and VS 2010 Express
&#9675;pararealist now.
Re: C# wrapper - RELEASE [Re: pararealist] #402951
06/12/12 18:10
06/12/12 18:10
Joined: Apr 2007
Posts: 141
Germany
Timothy Offline
Member
Timothy  Offline
Member

Joined: Apr 2007
Posts: 141
Germany
Thanks for your answer. I use this code:
Code:
private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog LoadModel = new OpenFileDialog();
            LoadModel.Title = "Import Model";
            LoadModel.InitialDirectory = @"C:\";
            LoadModel.Filter = "MDL (*.mdl)|*.mdl|Alle Dateien (*.*)|*.*";
            LoadModel.FilterIndex = 1;
            LoadModel.RestoreDirectory = true;
            if(LoadModel.ShowDialog() == DialogResult.OK)
            {
                ENTITY.ent_create(LoadModel.FileName, new Vector(100, 100, 0), obj);
                _items.Add(LoadModel.FileName);
                listBox1.DataSource = null;
                listBox1.DataSource = _items;
            }
        }



It is called by a button in my Form. I think that OpenFileDialog returns a string but I don't know how to control the string.
The code does work sometimes, but bigger models cause it to crash and this is not because I am out of memory.



Last edited by Timothy; 06/12/12 19:03.
Re: C# wrapper - RELEASE [Re: Timothy] #402984
06/13/12 05:46
06/13/12 05:46
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
Yes i had the same problem too.
To give you an idea what i did.

Code:
private void button_LoadLevel_Click(object sender, EventArgs e)
        {
            //you can still put opendialog here
            //i use a global "levelloaded" string in a static
            //class called Global accessed through properties.
            ...
            Global.strLoadedLevel = opendialog.filename;

            Scheduler.AddEventVoidThreadSafe(LoadLevel);
        }
     
private IEnumerable<ScheduleMethod> LoadLevel()
        {
            //i use a Global.strLoadedLevel as string
            if(Global.strLoadedLevel != string.empty}
             {
                EngFun.level_load(Global.strLoadedLevel);

		//reinit camera
                InitCamera();
             }
            yield break;
        }



Calling some engine functions from a Form event will cause thread problems.
Hope this makes sense.


A8.3x Commercial, AcknexWrapper and VS 2010 Express
&#9675;pararealist now.
Re: C# wrapper - RELEASE [Re: pararealist] #402998
06/13/12 10:51
06/13/12 10:51
Joined: Apr 2007
Posts: 141
Germany
Timothy Offline
Member
Timothy  Offline
Member

Joined: Apr 2007
Posts: 141
Germany
I defined the Global class like this:
Code:
public static class Global
        {
            public static string entity_import;
        }


I used the string like you said and it seems to work now.
Thank you very much!

Re: C# wrapper - RELEASE [Re: Timothy] #403023
06/13/12 16:47
06/13/12 16:47
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
Good.

probably better to use properties in global
Code:
public static class Global
        {
            private static string entity_import;

            public static string Import
            {
               get {return entity_import;}
            }
        }



Last edited by pararealist; 06/13/12 16:48.

A8.3x Commercial, AcknexWrapper and VS 2010 Express
&#9675;pararealist now.
Re: C# wrapper - RELEASE [Re: pararealist] #404993
07/20/12 17:36
07/20/12 17:36
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
could you please do something like this:
Code:
public Vector xyz
{
	get
	{
		return Vector.createFromPointer(xPointer);
	}
	set
	{
		Vector.createFromPointer(xPointer).vec_set(value);
	}
}


this would enable us to write better and easier code, because assigning a vector would look like this:
Code:
skyStars.xyz = camera.xyz;


and not like this:
Code:
skyStars.xyz.vec_set(camera.xyz);



EDIT:
And please do not wrap all functions!
I know it was hard work, but wrapping clamp instead of rewriting it is really bad. This solution is much safer and faster:
Code:
public static double clamp(double x, double a, double b)
{
	if (x < a) return a;
	if (x > b) return b;
	return x;
}



also you should use ref/out instead of DoubleSet and those strange variable-setting delegates

another thing to mention is that using read-only properties for stuff like getting entity or bmap properties:
Code:
public int Width
{
	get
	{
		return bmap_width();
	}
}



Last edited by MasterQ32; 07/20/12 18:38. Reason: Additional things

Visit my site: www.masterq32.de
Page 31 of 32 1 2 29 30 31 32

Moderated by  TWO 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1