I was wondering which kind of expressiveness fits a language used to generate particle effects.. Supposing to want an engine as flexible as possible what kind of 'features' should it have? (in addition to trivial ones like color, position, velocity, acceleration)
我想知道哪种表达适合用于产生粒子效果的语言。假设想要一个尽可能灵活的引擎,它应该具有什么样的“特征”? (除了颜色,位置,速度,加速度等微不足道的)
3 个解决方案
#1
SO everybody's urging you not to reinvent the wheel and that's a great idea, I have a soft spot for Python (which would allow your scripting users to also install and use plenty of other useful math libs &c), but LUA's no doubt even easier to integrate (and other scripting languages such as Ruby would also no doubt be just fine). Not writing your own ad-hoc scripting language is excellent advice.
所以每个人都在敦促你不要重新发明*,这是一个好主意,我对Python有一个情有独钟(这将允许你的脚本用户也安装和使用大量其他有用的数学库和c),但LUA毫无疑问更容易集成(和其他脚本语言,如Ruby也无疑会很好)。不编写自己的特殊脚本语言是很好的建议。
But reading your question suggests to me that your issue is more about -- what attributes of the objects of my engine (and what objects -- particles, sure, but, what else besides) should I expose to whatever scripting language I ember (or, say via MS COM or .NET, to whatever scripting or non-scripting language my users prefer)?
但是阅读你的问题告诉我你的问题更多的是 - 我的引擎的对象的属性(以及什么对象 - 粒子,当然,除此之外还有什么)我应该暴露给我的任何脚本语言(或者,通过MS COM或.NET,用我喜欢的脚本或非脚本语言)?
Specific properties of each particle such as those you list are no doubt worthwhile. Do you have anything else in your engine besides point-like particles, such as, say, surfaces and other non-pointlike entities, off which particles might bounce? What about "forces" of attraction or repulsion? Might your particles have angular momentum / spin?
每个粒子的特定属性(例如您列出的那些)无疑是值得的。除了点状粒子之外,你的引擎中是否还有其他东西,例如表面和其他非点状实体,粒子可能反弹?吸引力或排斥力的“力量”怎么样?你的粒子可能有角动量/旋转吗?
A great idea would be to make your particles' properties "expando", to use a popular term (other object models express the same idea differently) -- depending on the app using your engine, other programmers may decide to add to particles whatever properties they need... maybe mass, say -- maybe electric charge -- maybe cost in eurocents, for all you know or care;-). This makes life easier for your users compared to just offering a "particle ID" (which you should anyway of course;-) for them to use in hash tables or the like to keep track of the specific attributes they care about! Allowing them to add "methods" and "triggers" (methods that you call automatically if and when certain conditions hold, e.g. two particles get closer than a certain distance) would be awesome, but maybe a bit harder.
一个好主意是让你的粒子的属性“expando”,使用一个流行的术语(其他对象模型以不同的方式表达相同的想法) - 取决于使用你的引擎的应用程序,其他程序员可能决定添加到粒子任何属性他们需要...也许质量,比如说 - 可能是电费 - 也许是欧元的成本,对于所有你知道或关心的事情;-)。与仅仅提供“粒子ID”(当然你应该使用它;-)让他们在哈希表等中使用以跟踪他们关心的特定属性相比,这使得用户的生活更轻松!允许他们添加“方法”和“触发器”(当某些条件成立时你自动调用的方法,例如两个粒子比一定距离更近)会很棒,但可能会有点难度。
Don't forget, BTW, to allow a good method to "snapshot" the current state of the particle system (INCLUDING user-added expando properties) to a named stream or file and restore from such a snapshot -- that's absolutely crucial in many uses.
不要忘了,顺便说一下,允许一个好的方法将粒子系统的当前状态(包含用户添加的expando属性)“快照”到命名的流或文件并从这样的快照恢复 - 这在许多人中绝对是至关重要的使用。
Going beyond specific particles (and possibly other objects such as surfaces if you have them) you should probably have a "global environment" with its own properties (including expando ones) and ideally methods and triggers too. E.g., a force field acting on all particles depending on their position (and maybe their charge, mass, etc...!-)...
超越特定粒子(以及可能的其他对象,如表面,如果你有它们),你应该有一个“全局环境”,它有自己的属性(包括expando),理想情况下也是方法和触发器。例如,根据它们的位置(可能是它们的电荷,质量等等)作用在所有粒子上的力场......! - ......
Hope some of these ideas strike you as interesting -- hard for me to tell, with little idea of your intended field of application!-)
希望其中一些想法让你觉得有趣 - 我很难说清楚,对你的预期应用领域一无所知! - )
#2
Don't try and design a new language just for your application, instead embed another, well-established language in there. Take a look at the mess it has caused for other applications trying to implement their own scripting language (mIRC is a good example). It will mean users will have to learn another language just to script your application. Also, if you design your own language it will probably end up not as useful as other languages. Don't try to reinvent the wheel.
不要只为您的应用程序尝试设计一种新语言,而是在其中嵌入另一种完善的语言。看看它为试图实现自己的脚本语言的其他应用程序造成的混乱(mIRC就是一个很好的例子)。这意味着用户必须学习另一种语言才能编写应用程序脚本。此外,如果您设计自己的语言,它可能最终没有其他语言有用。不要试图重新发明*。
You might want to look at Lua as it is light-weight, popular, well-established, and is designed to be used by games (users of it include EA, Blizzard, Garry's Mod, etc.), and has a very minimal core library (it is designed to be a modular language).
你可能想看看Lua,因为它重量轻,流行,完善,并且设计用于游戏(其用户包括EA,暴雪,Garry的Mod等),并且具有非常小的核心库(它被设计为模块化语言)。
#3
Just embed Lua. It's a great language design, excellent performance, widely used by game developers, and small enough that you can master it in a few days.
刚刚嵌入Lua。这是一个很棒的语言设计,出色的性能,被游戏开发者广泛使用,并且足够小,你可以在几天内掌握它。
Then you can get on with your game design.
然后你可以继续你的游戏设计。
#1
SO everybody's urging you not to reinvent the wheel and that's a great idea, I have a soft spot for Python (which would allow your scripting users to also install and use plenty of other useful math libs &c), but LUA's no doubt even easier to integrate (and other scripting languages such as Ruby would also no doubt be just fine). Not writing your own ad-hoc scripting language is excellent advice.
所以每个人都在敦促你不要重新发明*,这是一个好主意,我对Python有一个情有独钟(这将允许你的脚本用户也安装和使用大量其他有用的数学库和c),但LUA毫无疑问更容易集成(和其他脚本语言,如Ruby也无疑会很好)。不编写自己的特殊脚本语言是很好的建议。
But reading your question suggests to me that your issue is more about -- what attributes of the objects of my engine (and what objects -- particles, sure, but, what else besides) should I expose to whatever scripting language I ember (or, say via MS COM or .NET, to whatever scripting or non-scripting language my users prefer)?
但是阅读你的问题告诉我你的问题更多的是 - 我的引擎的对象的属性(以及什么对象 - 粒子,当然,除此之外还有什么)我应该暴露给我的任何脚本语言(或者,通过MS COM或.NET,用我喜欢的脚本或非脚本语言)?
Specific properties of each particle such as those you list are no doubt worthwhile. Do you have anything else in your engine besides point-like particles, such as, say, surfaces and other non-pointlike entities, off which particles might bounce? What about "forces" of attraction or repulsion? Might your particles have angular momentum / spin?
每个粒子的特定属性(例如您列出的那些)无疑是值得的。除了点状粒子之外,你的引擎中是否还有其他东西,例如表面和其他非点状实体,粒子可能反弹?吸引力或排斥力的“力量”怎么样?你的粒子可能有角动量/旋转吗?
A great idea would be to make your particles' properties "expando", to use a popular term (other object models express the same idea differently) -- depending on the app using your engine, other programmers may decide to add to particles whatever properties they need... maybe mass, say -- maybe electric charge -- maybe cost in eurocents, for all you know or care;-). This makes life easier for your users compared to just offering a "particle ID" (which you should anyway of course;-) for them to use in hash tables or the like to keep track of the specific attributes they care about! Allowing them to add "methods" and "triggers" (methods that you call automatically if and when certain conditions hold, e.g. two particles get closer than a certain distance) would be awesome, but maybe a bit harder.
一个好主意是让你的粒子的属性“expando”,使用一个流行的术语(其他对象模型以不同的方式表达相同的想法) - 取决于使用你的引擎的应用程序,其他程序员可能决定添加到粒子任何属性他们需要...也许质量,比如说 - 可能是电费 - 也许是欧元的成本,对于所有你知道或关心的事情;-)。与仅仅提供“粒子ID”(当然你应该使用它;-)让他们在哈希表等中使用以跟踪他们关心的特定属性相比,这使得用户的生活更轻松!允许他们添加“方法”和“触发器”(当某些条件成立时你自动调用的方法,例如两个粒子比一定距离更近)会很棒,但可能会有点难度。
Don't forget, BTW, to allow a good method to "snapshot" the current state of the particle system (INCLUDING user-added expando properties) to a named stream or file and restore from such a snapshot -- that's absolutely crucial in many uses.
不要忘了,顺便说一下,允许一个好的方法将粒子系统的当前状态(包含用户添加的expando属性)“快照”到命名的流或文件并从这样的快照恢复 - 这在许多人中绝对是至关重要的使用。
Going beyond specific particles (and possibly other objects such as surfaces if you have them) you should probably have a "global environment" with its own properties (including expando ones) and ideally methods and triggers too. E.g., a force field acting on all particles depending on their position (and maybe their charge, mass, etc...!-)...
超越特定粒子(以及可能的其他对象,如表面,如果你有它们),你应该有一个“全局环境”,它有自己的属性(包括expando),理想情况下也是方法和触发器。例如,根据它们的位置(可能是它们的电荷,质量等等)作用在所有粒子上的力场......! - ......
Hope some of these ideas strike you as interesting -- hard for me to tell, with little idea of your intended field of application!-)
希望其中一些想法让你觉得有趣 - 我很难说清楚,对你的预期应用领域一无所知! - )
#2
Don't try and design a new language just for your application, instead embed another, well-established language in there. Take a look at the mess it has caused for other applications trying to implement their own scripting language (mIRC is a good example). It will mean users will have to learn another language just to script your application. Also, if you design your own language it will probably end up not as useful as other languages. Don't try to reinvent the wheel.
不要只为您的应用程序尝试设计一种新语言,而是在其中嵌入另一种完善的语言。看看它为试图实现自己的脚本语言的其他应用程序造成的混乱(mIRC就是一个很好的例子)。这意味着用户必须学习另一种语言才能编写应用程序脚本。此外,如果您设计自己的语言,它可能最终没有其他语言有用。不要试图重新发明*。
You might want to look at Lua as it is light-weight, popular, well-established, and is designed to be used by games (users of it include EA, Blizzard, Garry's Mod, etc.), and has a very minimal core library (it is designed to be a modular language).
你可能想看看Lua,因为它重量轻,流行,完善,并且设计用于游戏(其用户包括EA,暴雪,Garry的Mod等),并且具有非常小的核心库(它被设计为模块化语言)。
#3
Just embed Lua. It's a great language design, excellent performance, widely used by game developers, and small enough that you can master it in a few days.
刚刚嵌入Lua。这是一个很棒的语言设计,出色的性能,被游戏开发者广泛使用,并且足够小,你可以在几天内掌握它。
Then you can get on with your game design.
然后你可以继续你的游戏设计。