I think it is a simple question, but it really confuse me...
In the case which I try to show three object together, like Fibers, Volume and Mesh, just as you can see in this demo web.
Demo Web: http://goo.gl/NP2eUo
But there is a problem, the Fibers object can not automatic alignment with Volume and Mesh. Those files are come from the same source (one subject's DICOM file) so it should can be match together in default.
If only show the Fibers object, it can be put in the center of the view. But if show three object together, then Fibers object will be Shift!!!
Is there any possible way can let three object automatic alignment together?
And here is my source code: http://goo.gl/Ttzc84
What if you try to call reset boundingBox on showtime?
...
// .. add the mesh
r.add(mesh);
r.onShowtime = function() {
r.resetBoundingBox();
}
r.render();
...
How did you generate the surface and the trk file? Freesurfer and DTK?
I suspect the trk file does not provide any IJKToRAS transformation.
Related
There are many examples of doing this in axml, but I would like to have a complete binding using code behind. To be honest, I would like to have NO axml, but seems like creating all the controls programmatically is a nightmare.
I first tried the suggestions at:
MvxListView create binding for template layout from code
I have my list binding from code-behind, and I get six rows (so source binding is working); but the cells itself does not bind.
Then at the following url:
Odd issue with MvvmCross, MvxListViewItem on Android
Stuart has the following comment: Have looked through. In this case, I don't think you want to use DelayBind. DelayBind is used to delay the binding action until next time the DataContext is set. In Android's MvxAdapter/MvxListItemView case, the DataContext is passed in the ctor - so DataContext isn't set again until the cell is reused. (This is different to iOS MvxTableDataSource).
So in essence, the only example I see shows DelayBind, which shouldn't work.
Can someone please show me some examples... thanks in advance.
Added reply to Comments:
Cheesebaron, first of all, a huge thank you and respect for all your contributions;
Now, why not use axml? Well, as programmers, we all have our own preferences and way of doing stuff - I guess I am old school where we didn't have any gui designer (not really true).
Real reasons:
Common Style: I have a setup where Core has all the style details, including what all the colors would be. My idea is, each platform would get the style details from core and update accordingly. It's easy for me to create controls with the correct style this way.
Copy-Paste across platform (which then I can even have as linked files if I wanted). For example, I have a login screen with web-like verification, where a red error text appears under a control; overall on that screen I have around 10 items that needs binding. I have already got iOS version working - so starting on Droid, I copied the whole binding section from ios, and it worked perfectly. So, the whole binding, I can make it same across all platform... Any possible error in my way will stop at building, which I think is a major advantage over axml binding. Even the control creation is extremely similar, where I have helpers with same method name.
Ofcourse I understand all the additional layout that has to be handled; to be honest, it's not that bad if one really think it through; I have created a StackPanel for Droid which is based on WP - that internally handles all the layouts for child views; so for LinearLayout, all I do is setup some custom parameters, and let my panel deal with it. Relative is a different story; so far, I have only one screen that's relative, and I can even make it Linear to reduce my additional layout code.
So, from my humble point of view, for my style, code-behind creation allows me to completely copy all my bindings (I do have some custom binding factories to allow that), copy all my control create lines; then only adding those controls to the view is the only part that is different (then again, droid and WP are almost identical). So there is no way I can miss something on one platform and all are forced to be the same. It also allows me to change all the styles for every platform just by changing the core. Finally, any binding error is detected during compile - and I love that.
My original question wasn't about NOT using axml... it was on how to use MvxListView where all the binding is done in code-behind; as I have explained, I got the list binding, but not the item/cell binding working.
Thanks again in advance.
Here is part of my LoginScreen from droid; I think it's acceptable amount of code for being without axml file.
//======================================================================================================
// create and add all controls
//======================================================================================================
var usernameEntry = ControlHelper.GetUITextFieldCustom(this, "Username.", maxLength: 20);
var usernameError = AddErrorLabel<UserAuthorization, string>(vm => ViewModel.Authorization.Username);
var passwordEntry = ControlHelper.GetUITextFieldCustom(this, "Password.", maxLength: 40, secureTextEntry: true);
var passwordError = AddErrorLabel<UserAuthorization, string>(vm => ViewModel.Authorization.Password);
var loginButton = ControlHelper.GetUIButtonMain(this);
var rememberMe = new UISwitch(this);
var joinLink = ControlHelper.GetUIButtonHyperLink(this, textAlignment: UITextAlignment.Center);
var copyRightText = ControlHelper.GetUILabel(this, textAlignment: UITextAlignment.Center);
var copyRightSite = ControlHelper.GetUIButtonHyperLink(this, textAlignment: UITextAlignment.Center);
var layout = new StackPanel(this, Orientation.Vertical)
{
Spacing = 15,
SubViews = new View[]
{
ControlHelper.GetUIImageView(this, Resource.Drawable.logo),
usernameEntry,
usernameError,
passwordEntry,
passwordError,
loginButton,
rememberMe,
joinLink,
ControlHelper.GetSpacer(this, ViewGroup.LayoutParams.MatchParent, weight: 2),
copyRightText,
copyRightSite
}
};
I just came across a similar situation myself using Mvx4.
The first link you mentioned had it almost correct AND when you combine it from Staurts comment in the second link and just remove the surrounding DelayBind call, everything should work out ok -
public class CustomListItemView
: MvxListItemView
{
public MvxListItemView(Context context,
IMvxLayoutInflater layoutInflater,
object dataContext,
int templateId)
: base(context, layoutInflater, dataContext, templateId)
{
var control = this.FindViewById<TextView>(Resource.Id.list_complex_title);
var set = this.CreateBindingSet<CustomListViewItem, YourThing>();
set.Bind(control).To(vm => vm.Title);
set.Apply();
}
}
p.s. I have asked for an Edit to the original link to help others.
Right, I am trying to make a game and I would like a bit of code that whenever I place makes something applies to all objects. For example I have: A background, Lamp, Player and Text. I would like it so I don't have to make the Lamp, Background and Text a symbol but have one bit of code that refers to them whenever I type it, so I don't have to list them all individually.
If you are looking to affect a specific, known set of display objects, you could add them into an array when they get created, and then use that array as your collection of objects to do whatever you need to.
Code here is procedural, not OOP, but should give you the gist. If you paste this into an FLA file and create the three objects (instances names) you'll have a decent sample of what this approach may be able to help you work with.
This can become more advanced, creates asa its own AS3 class, and be made smarted to handle whatever visual display changes that might be needed. But you only need ot make it as complicated as suits your needs.
var myDisplayObjs_arr:Array = [];
function addObj(obj:DisplayObject):void{
myDisplayObjs_arr.push(obj);
}
function affectObjs(config:Object):void{
// config object that includes things like alpha, colorTransform, whatever
for (var i:int = 0; i<myDisplayObjs_arr.length; i++){
var dispObj:DisplayObject = myDisplayObjs_arr[i];
if (config.alpha) {
dispObj.alpha = config.alpha;
}
if (config.scaleX) {
dispObj.scaleX = config.scaleX;
}
}
}
addObj(lamp);
addObj(background);
addObj(header_txt);
// Call affectObjs(), passing it an object of some basic changes
affectObjs({alpha:.5, scaleX:2});
I want to try a simple task where if i move a object inside the world and then press a button it should go back to its original position , but its not working , below is the code i am using - the file is here - http://www.fastswf.com/yAnIvBs (when i remove the event listener)
with event listener - http://www.fastswf.com/rpYsIt8
////////========================
stop();
var startXPos:Number = level1WorldObj.box1.x;
var startYPos:Number = level1WorldObj.box1.y;
function areaS(e:Event) {
level1WorldObj.box1.y= startYPos;
level1WorldObj.box1.x= startXPos;
level1WorldObj.box1.removeEventListener(Event.ENTER_FRAME, areaS);
}
but1.addEventListener(MouseEvent.CLICK,nClick3);
function nClick3(event:MouseEvent):void{
level1WorldObj.box1.addEventListener(Event.ENTER_FRAME, areaS);
level1WorldObj.box1.y= startYPos;
level1WorldObj.box1.x= startXPos;
}
/////////////////======================
Now i want to be able to do it many time so i kept the variables that detect the initial x, y as global ...
Here you can see how it behaves in debugdraw mode , strangely only the clip moves not the actual body - http://www.fastswf.com/-Ijkta4
Can some one please guide me here ...
Thanks in advance ...
Jin
The graphics that you see (box1) aren't related to the physical object behind the scenes - you're currently only moving the graphics not the object itself.
You need to use either SetPosition() or SetTransform() on the b2Body of the object
Edit 07/7
As you're using the Box2D World Construction Kit, I took a look at the source code (available here: https://github.com/jesses/wck). The main class seems to be BodyShape (https://raw.githubusercontent.com/jesses/wck/master/wck/BodyShape.as).
Looking through it, you should be able to access the b2Body directly. If it's null (which is probably the source of the TypeError that you're getting, then you haven't called createBody(), which is what actually takes all of your properties as creates the physical object behind the scenes.
Once you have a b2Body, if you want to position it based on the graphics, there's a function syncTransform() to do just that.
You should turn on debugDraw on your World class to make it easier to see what's going on in the background. NOTE: this needs to be done before calling create()
I was able to find solution to this problem , i found the starting point by using this -
trace(level1WorldObj.box1.b2body.GetPosition().x);
trace(level1WorldObj.box1.b2body.GetPosition().y);
then once i had the position manually i took down the coordinates and used the below code ....
level1WorldObj.box1.b2body.SetTransform(new V2(-2, 2),0 );
Thanks #divillysausages for all the help ...
Regards
I'm getting my feet wet with AS3, Flixel and component/entity systems (yes, all at the same time), and my entities (which subclass FlxSprite) aren't being added correctly (i.e., not at all). I've just spent a good two hours nailing down the offending line. If I remove it, the rest of the game chugs along happily.
What's wrong with this code?
public function addComponent(c:Component):void
{
var type:String = Object(c).constructor.toString();
FlxG.log("type=" + type);
this._components[type] = c; // The evil line
FlxG.log("now type=" + _components[type]);
c.setData(this);
}
components is an Object field being used as a map/dictionary. type gets set to [class PlayerComponent]. Based on googling, this is valid and should work as intended.
Based on the output from the console, it's just bailing after that line--not crashing entirely. What's going on? More details gladly offered upon request.
I'm not certain about Component - not my forte - but I do know that FlxGroup and its children (which include FlxState) have a method called add() which adds children to them.
So if you have an FlxSprite, the correct way (in flixel) to add it to the chain of things to update/draw is to use that; you can add it directly to your state or to a group that is a child of the state.
Function docs: http://flixel.org/docs/org/flixel/FlxGroup.html#add()
I need to create a .DAE file from one DisplayObject3D and do not know how to do it. Only I find information about how importing a DAE. Never of how exporting it.
Thanks.
I cannot change simply "mesh" for "container".
I do not understand this line very well:
mesh = scene.addChild(new PaperPlane(new FlatShadeMaterial(light,0xFFFF00,0xFF6600),3));
If I do this:
mesh = container.addChild(new PaperPlane(new FlatShadeMaterial(light,0xFFFF00,0xFF6600),3));
Then it creates a dae with the paperplane but only the paperplane and not other objects that exist in "container".
How can I create the dae with the objects of my DisplayObject3D "container"?
Thanks
You can write a .DAE file using ExportCollada's export() static method:
trace(ExportCollada.export(yourDisplayObject3D));
I've put together a very basic example here:
Run the test and double click the stage to save the plane as a .dae file to disk.
Update
Nesting objects also work as you can see here:
You mentioned this line:
mesh = scene.addChild(new PaperPlane(new FlatShadeMaterial(light,0xFFFF00,0xFF6600),3));
That is just a lazy way to doing multiple things in one line:
create a new PaperPlane object
add it to the scene
assign the PaperPlane object to the mesh variable
It probably makes more sense like this:
var mesh:DisplayObject3D = new PaperPlane(new FlatShadeMaterial(light,0xFFFF00,0xFF6600),3);
scene.addChild(mesh);
Your modified snippet:
mesh = container.addChild(new PaperPlane(new FlatShadeMaterial(light,0xFFFF00,0xFF6600),3));
says that mesh is equal to the DisplayObject3D returned by adding the paper plane to container, which is the paper plane, so if you're exporting mesh, you only export the plane.
If you export container, you should get the dae with all the child elements that container has.
Might be easier to change this line:
data.writeUTFBytes(ExportCollada.export(mesh));
to this:
data.writeUTFBytes(ExportCollada.export(container));//assuming container is visible here