Forum Replies Created
-
AuthorPosts
-
Yes, colors mixes. To get clean custom color your source image should be white.
Ok, try it in real project to know is it good enough.
I think the new system works really well for the end user, since they never have to even know about the EntityBox class
This time it’s FALSE:
- you add public method GetComponentBox:EntityBox() to Entity
- all your virtual OnStuff methods are inside of EntityBox – maybe you didn’t done with that part yet, I’m interested in how you will override them?
Also there is an Image.Color property.
Would it add overhead compared with getting it from a String Map?
AFAIK name of type is a minimal reflection part that directly return precompiled string.
What is inside of Typeof I don’t know.
It can run on every frame on several hundreds of objects, so I think it’s important to pick the fastest way.
Using GetComponent () inside of loops is a bad idea. You can store (cache) needed components in a private filds of objects which should use them.
I dislike idea with external box container.
Try to use
#Import “assets/graphics/@/graphics/”
It should copy all files from graphics folder to the same product folder.
After @ symbol you can specify any dest folder name.
Congrats!
- GameObj name sounds not good for me, GameObject is better
- GameObj have a few public global stringmaps – not good, user can clear them in any program place
- For adding and getting components you are using Name property, I do like that in monkey-x, but mx2 allow us to do it more clean way – using reflection:
Monkey1234567891011121314151617181920212223242526272829303132333435363738Method AddComponent<T>:T() Where T Extends ComponentLocal comp:=ComponentBridge_Go.NewComponent<T>()Local name:=Typeof( comp ).NameLocal items:=_components[name]Local unique:=comp.isUniqueIf uniqueAssert( items=Null Or items.Length=1,"Allowed only one instance of '"+name+"' component to be attached!" )EndifIf items=Nullitems=New Stack<Component>_components.Add( name,items )Endifitems.Add( comp )ComponentBridge_Go.SetGameObject( comp,Self )ScriptExecutorBridge_Go.GrabComponent( comp )Return compEndMethod GetComponent<T>:T() Where T Extends ComponentLocal c:T=Null ' hack to get type of TLocal name:=Typeof( c ).NameLocal items:=_components[name]If items=Null Or items.Empty Return NullReturn Cast<T>( items[0] )EndPrivateField _components:=New StringMap<Stack<Component>>XXX_Bridge_YYY classes is a little magic to get acces to protected field, it allow me set protected fields and provide read-only public properties to end user (I’ll write a post about that).
My rule is – hide under the hood as more logic as possible, stay public for really needed things.
Also in my framework I deny directly creation of components – constructor is protected. Because I need to set it protected field _gameObject in creation time. In your code user can set null to someComponent.gameObj field and get memory access violation.
Inside of your components you can store ‘raw’ monkey2 entities / parts. And manage them under the hood.
As for me – GameObject is a core object which don’t extends any base class. It contains components and allow us some manipulating by setting layer and enabled properties, as well as providing OnStuff callbacks. In my framework I add OnStuff callbacks to MonkeyBehaviour class to left gameObject as simple as possible.
Then you create any components like
Monkey1Class Camara Extends ComponentMesh, Sprite, etc (not LoadMesh, LoadSprite)
And then add it into game object. To simplify process you can write helper functions like
Monkey123456Function CreateCamera:GameObject( name:String )Local go:=New GameObject( name )go.AddComponent<Camera>()Return goEndIn my framework I extends Behaviour class for scriptable, that contains ‘enabled’ property.
(need to add repository to rely on code)
I also like component-based system and even started to do similar ‘framework’ for 2d, almost unity3d-clone by concept / structure / naming.
But I left / freeze this project.
The most difficult thing for me was coordinate processing – each GameObject can have it’s own scale and rotation and children hierarchy. And we should to calculate local and global values, matrix matrix matrix.
I can help to concrete problems. Looks like if you complete your wrapper – you can easily add new features. And you can start with minimal functional and extend it as needed.
Thanks for information!
There is what I do: http://monkeycoder.co.nz/forums/topic/image-with-texture-mask/
Maybe there is built-in support for this and I missed it.
In my case, I want to bring MaskTexture property into Image class.
To apply texture as a mask I was going to use shader processing, and for that purpose I need to switch default ‘sprite’ shader with ‘sprite-masked’.
Maybe you’ll add this as a core part or mojo.
I’ll post my approach with masks in code libs soon.
Why Image.Shader property is read-only? I want to change shader on the fly. Is it possible?
Canvas class just grab shader when render image,
Monkey1AddDrawOp( image.Shader,image.Material,image.BlendMode,4,1 )so I think we can change it and that should break nothing.
You can pass texture to shader by two ways:
- _image.Material.SetTexture( “myTex”,_tex )
- in shader name will be m_myTex
- _image.SetTexture( 0,_tex )
- in shader name will be m_ImageTexture0
Note: _image.Material.SetTexture( 0,_tex ) don’t raise an exception but is incorrect.
(0 -> toString -> “0”)
Yay, I got it myself!
Monkey1234567891011121314151617#Import "assets/@/"' place your shaders into 'assets/shaders/' folder with extension .glsl.........Local tex:=Texture.Load( "asset::pal.png",TextureFlags.None )Local shader:=Shader.Open( "myShader" )_image=New Image( 400,400,,shader )' pass some params into shader' inside of shader them looks like m_center, m_scale, etc_image.Material.SetVec2f( "center", New Vec2f(.5,0) )_image.Material.SetFloat( "scale", 2.5 )_image.Material.SetFloat( "iterF", 70 )' textures inside of shader looks like' uniform sampler2D m_ImageTexture0;' where last 0 is index (m_ImageTexture0, m_ImageTexture1, etc)_image.SetTexture( 0,tex ).....canvas.DrawImage( _image,xx,yy ) ' render with our shaderNo GLWindow required, just mojo.Window.
I missed Material.SetInt() method to pass iterations counter, so need to cast types inside of shader.
-
AuthorPosts