ZioRed Posted June 23, 2010 Share Posted June 23, 2010 any Entity has two properties GlobalPosition and Position (same for rotation: Rotation and GlobalRotation, same syntax as positions). I forgot to expose the global one, just now updated the examples above. Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
macklebee Posted June 23, 2010 Share Posted June 23, 2010 really? you have to use two separate property lines to differ between global and local... and its like this for all of your entity OOP commands? seems like a global flag parameter would really cut down on the number of properties... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
ZioRed Posted June 23, 2010 Share Posted June 23, 2010 One can ever use Core.PositionEntity / RotateEntity if he doesn't like the OOP way. Personally I almost like properties much more than methods when possible Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
Josh Posted June 23, 2010 Author Share Posted June 23, 2010 Why doesn't the C# header do it like this?: entity.SetPosition( Vec3 position, int global ) Why is the .core prefix necessary?: Core.PositionEntity(IntPtr entity, float[] position, int global); Doesn't C# support objects from pointers? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
ZioRed Posted June 23, 2010 Share Posted June 23, 2010 Core is the static class which wraps all the C headers (as I said, there is not procedural programming in C#), any C functions is called statically through the Core class (it contains and exposes all the procedural C functions with same names). For the SetPosition method or property method generally the C# programmers like more the OOP way, that is avoid get/set functions and prefer properties more for code elegance/aesthetics than other, and of course I like this way much more than functions. For pointers question, IntPtr is the pointer type we use to pass to any C function, like Core.EntityPosition(yourValueIntPtr). I thing there is not the pointer concept exactly as C/C++, or at least I never checked/used it Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
Josh Posted June 23, 2010 Author Share Posted June 23, 2010 So when you assign this value, there is a set method that gets called internally?: myEntity.Position = new Vector3(1.5f, 2f, 4.5f); Is it customary to call the base class "core"? If not, wouldn't "engine" be more appropriate? I don't like this approach because it splits the command into two commands that aren't really even commands: myEntity.Position = new Vector3(1.5f, 2f, 4.5f); myEntity.GlobalPosition = new Vector3(1.5f, 2f, 4.5f); I understand you know more about C# than I do, but I would like additional feedback from other C# programmers. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Roland Posted June 23, 2010 Share Posted June 23, 2010 So when you assign this value, there is a set method that gets called internally?: myEntity.Position = new Vector3(1.5f, 2f, 4.5f); Is it customary to call the base class "core"? If not, wouldn't "engine" be more appropriate? I don't like this approach because it splits the command into two commands that aren't really even commands: myEntity.Position = new Vector3(1.5f, 2f, 4.5f); myEntity.GlobalPosition = new Vector3(1.5f, 2f, 4.5f); I understand you know more about C# than I do, but I would like additional feedback from other C# programmers. I'm no C# expert but this is how it works A property can be declared and then when used it has a get and a set method internally. An example public class myClass { private int myval = 0 ; public int MyValue { get { return myval ; } set { myval = value ; } } } the class can then be used like this myClass c = new myClass ; c.MyValue = 10 ; // the internal set will be called and assign 10 to myval int x = c.MyValue ; // the internal get will be called and it returns the myval You can omit to write the internal set method c.MyValue = 10 ; // Causes a compiler error as the MyValue now is ReadOnly (it has no set method) Of course you can the have more code inside the internal get and set to do more things as range checking or whatever you decide Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Josh Posted June 23, 2010 Author Share Posted June 23, 2010 That's what I figured. Is there any way to pass an extra variable along with the assignment, that the get/set method can process? We can do the same thing in C++ and even Lua: http://www.rasterbar.com/products/luabind/docs.html#properties I am not sure this is the best approach in v3.0. I believe it eliminates the ability to have an extra argument, and thus changes our command paradigm a bit. What do you guys think? This should be decided and made consistent for everything in 3.0. We're either looking at: entity.SetPosition( 1, 2, 3, True ); ...or this: entity.globalposition = Vec3( 1, 2, 3 ); Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Roland Posted June 23, 2010 Share Posted June 23, 2010 No. The property approach works just like an assignment. You can compare the set thing with the operator=( some value ) in C++ For more than one argument you have to go with a normal Method. Edit: In LEO I implemented some kind of set/get approach Everything that assigns something has a SetXXXX method and everything that queries a value has a GetXXXX method Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Josh Posted June 23, 2010 Author Share Posted June 23, 2010 We would not have an equivalent to this: entity.SetPosition(1,2,3) ...because we can only assign one value. We could do this: entity.position.x = 1; entity.position.y = 2; entity.position.z = 3; ...but this would involve a separate hierarchical matrix update for each line, so it would be very suboptimal. In LEO I implemented some kind of set/get approach Yes, and unless I am convinced otherwise, this is the approach I intend to use in 3.0. I am not so concerned about the current C# header that anything has to be rewritten. I am more interested in determining a consistent design for the future. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Roland Posted June 23, 2010 Share Posted June 23, 2010 We would not have an equivalent to this: entity.SetPosition(1,2,3) ...because we can only assign one value. We could do this: entity.position.x = 1; entity.position.y = 2; entity.position.z = 3; ...but this would involve a separate hierarchical matrix update for each line, so it would be very suboptimal. Yes thats true. Using properties you would have to go this way entity.Position = new Vec3( 1,2,3 ) ; // C# entity.SetPosition( Vec3( 1, 2, 3 ) ) ; // C++ Edit: In C++ you could have Position Vec3 as a public and then use a Vec3= operator Then you would have almost same as in C# entity.Position = Vec3( 1,2,3 ) ; // C++ Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
macklebee Posted June 23, 2010 Share Posted June 23, 2010 That's what I figured. Is there any way to pass an extra variable along with the assignment, that the get/set method can process? We can do the same thing in C++ and even Lua: http://www.rasterbar.com/products/luabind/docs.html#properties I am not sure this is the best approach in v3.0. I believe it eliminates the ability to have an extra argument, and thus changes our command paradigm a bit. What do you guys think? This should be decided and made consistent for everything in 3.0. We're either looking at: entity.SetPosition( 1, 2, 3, True ); ...or this: entity.globalposition = Vec3( 1, 2, 3 ); youre thinking of changing the command structures for everyone based on 5 people that use C#? just saw your last message- nevermind! Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Roland Posted June 23, 2010 Share Posted June 23, 2010 My personal preference is to go the LEO way, of course Set to set things Get to get things Create to create things Always the same. You never have to wonder ... Edit: Oh.. and one more thing while I'm at it GetXXXX should always be const method All arguments that is input-only should also be const Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Josh Posted June 23, 2010 Author Share Posted June 23, 2010 Agreed. The C# header is okay the way it is, but in version 3.0 I think the syntax should match C++. I will question a lot of basic design elements in the next few months. Keep in mind it is because I want to make sure we are designing 3.0 the right way. The command reference database I created is for version 2.x. A lot of it can be copied to a new database for 3.0, and we will make whatever changes are needed. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Roland Posted June 23, 2010 Share Posted June 23, 2010 Agreed. The C# header is okay the way it is, but in version 3.0 I think the syntax should match C++. I will question a lot of basic design elements in the next few months. Keep in mind it is because I want to make sure we are designing 3.0 the right way. The command reference database I created is for version 2.x. A lot of it can be copied to a new database for 3.0, and we will make whatever changes are needed. Cant wait to dive into it :P Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
macklebee Posted June 23, 2010 Share Posted June 23, 2010 My personal preference is to go the LEO way, of course Set to set things Get to get things Create to create things Always the same. You never have to wonder ... I agree that does make it easier. Switching back and forth between lua and bmax has made me appreciate Set/Get versus StateEntity/EntityState. I just hope Josh keeps the flag parameter for global/local... seems silly to have a second one... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Canardia Posted June 23, 2010 Share Posted June 23, 2010 Just brainstorming, all commands do the same thing, move a cube 1 unit forward. cube.Move(Vec3(0,0,1)); LE 0-2 way cube.Move(0,0,1); also LE 0-2 way, but not officially implemented (except in BlitzMax and Lua) cube.MoveForward(1); shorter to write, faster and more effective since x and y values don't need to be passed cube.MoveZ(1); very short, while still readable cube.position+=Vec3(0,0,1); interesting way also, since = and += operators can do seperate things like SetPosition and Move cube.position.z+=1; now i kinda start to like it, no need to create additional memory, just do it directly! and shortest to write too cube.globalposition.z+=1; same along the global Z direction Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Roland Posted June 23, 2010 Share Posted June 23, 2010 Just brainstorming, all commands do the same thing, move a cube 1 unit forward. cube.Move(Vec3(0,0,1)); LE 0-2 way cube.Move(0,0,1); also LE 0-2 way, but not officially implemented (except in BlitzMax and Lua) cube.MoveForward(1); shorter to write, faster and more effective since x and y values don't need to be passed cube.position+=Vec3(0,0,1); interesting way also, since = and += operators can do seperate things like SetPosition and Move cube.position.z+=1; now i kinda start to like it, no need to create additional memory, just do it directly! and shortest to write too The two last suggestion can seem handy, but they goes against all oop rules. I would not recommend those. Data protection (or hiding) is a very important part of good oop programming. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Canardia Posted June 23, 2010 Share Posted June 23, 2010 Data protection is a non-existing issue in this case, since you can do the same with Set()/Get() anyway. And it really depends what attributes you expose as public, but position is not a very secret and vulnerable information. There's no need to be absolutarian when you can use common sense, and use whatever method is best in each situation Speed, easyness and effectiveness is everything here, since it's one of the most used commands. More ideas: cube.MoveZ(1); cube.GetZ(); cube.GetPositionZ(); // same as GetZ cube.MoveZ(1,1); // global cube.GetZ(1); // global cube.TurnZ(1); cube.RotateZ(); // not same as TurnZ, so perhaps confusing cube.SetRotationZ(); // more to write, but less to think since Set/Get // stands for absolute things cube.GetRotationZ(); cube.GetRotation().z; // also possible, but slower since // x and y is also returned by GetRotation() Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
macklebee Posted June 23, 2010 Share Posted June 23, 2010 why is there a java icon on the documentation page? did i miss a meeting or something? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
macklebee Posted June 23, 2010 Share Posted June 23, 2010 Data protection is a non-existing issue, since you can do the same with Set()/Get() anyway. And it really depends what attributes you expose as public, but position is not a very secret and vulnerable information. There's no need to be absolutarian when you can use common sense Speed, easyness and effectiveness everything. then if easiness are one of your goals then none of those are very good... I am just thinking about new people that come to LE that are not programmers... cannot beat the simplicity of Set/Get Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
macklebee Posted June 23, 2010 Share Posted June 23, 2010 you can do cube:GetRotation().z cube:GetRotation(1).z in lua right now... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Roland Posted June 23, 2010 Share Posted June 23, 2010 Data protection is a non-existing issue in this case, since you can do the same with Set()/Get() anyway. And it really depends what attributes you expose as public, but position is not a very secret and vulnerable information. There's no need to be absolutarian when you can use common sense, and use whatever method is best in each situation Speed, easyness and effectiveness is everything here, since it's one of the most used commands. cube.MoveZ(1); cube.GetZ(); cube.MoveZ(1,1); // global cube.GetZ(1); // global cube.TurnZ(1); cube.GetRotationZ(); My approach is that either you go with oop-rules or you don't. You cant have if kind of half-oop and go the struct public way in some places and not in other places. Get,Set is simple to understand. Its fast as it will be inline code when optimized by the compiler Its a question about be consistent in you coding. If you are making members public, well whats the idea of using classes at all. Then you could use struct's instead. About adding extra methods like suggested. That may be OK even though I think thats not needed. If anyone want those I would be easy to make an own version with those methods that inherits the original. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Roland Posted June 23, 2010 Share Posted June 23, 2010 you can do cube:GetRotation().z cube:GetRotation(1).z in lua right now... Same goes for LEO. cube.GetRotation().X = 10 ; Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
macklebee Posted June 23, 2010 Share Posted June 23, 2010 Same goes for LEO. cube.GetRotation().X = 10 ; you can set a value to a Get? i would have thought that it would have been cube.rotation.x = 10 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.