XTK - rendering volume in multiple renderers without .onShowtime()? - xtk

I'm wondering if someone can explain to me why I can't render the same volume in a 4 panel setup (3D, X, Y, Z) just like in XTK Tutorial 13, without the .onShowtime function. I tried altering the code to do this, rather than call the .onShowtimes function:
volume = new X.volume();
volume.file = 'http://x.babymri.org/?vol.nrrd';
sliceX.add(volume);
sliceX.render();
sliceY.add(volume);
sliceY.render();
sliceZ.add(volume);
sliceZ.render();
but when I do this, I get the load bars in the 3 display panels, but after loading, only the sliceX panel will display an image, the others remain black. Do I always have to have a main renderer and make the other renderers listen to it, as the tutorial suggests?
Thanks,
Dave

It is because the first call to 'render' is going to trigger the downloading of the data.
Once it has been downloaded 1 time and rendered the first time, we add/render it in the other renderers.
When we call 'render' on the next renderers, it will not try to download the data again since it has already been downloaded once.
If we call renderer as you are doing it right now, it tries to download the volume 3 times and it can mess up the internals of the object.
So long answer short, it is to avoid some race conditions but I agree we should improve that if possible.
Thanks

I have solved it temporaly replacing onShowTime with the JavaScript function setTimeout.You render the first renderer and after that you rend the others inside that function
volume = new X.volume();
volume.file = 'http://x.babymri.org/?vol.nrrd';
slice3D.add(volume);
slice3D.render();
setTimeout(function(){
sliceX.add(volume);
sliceX.render();
sliceY.add(volume);
sliceY.render();
sliceZ.add(volume);
sliceZ.render();
},600);
it worked for me.

Related

Migrating to vtk6: Is it not necessary to Update() (anymore)?

Migrating some code from VTK 5.10 to 6.1, I have several code pieces like this:
vtkSmartPointer<vtkImageData> img = vtkSmartPointer<vtkImageData>::New();
// ... initialize img somehow, e.g. copy from other image:
img->DeepCopy(otherImg);
img->SetInformation(otherImg->getInformation());
// the problematical statement:
img->Update();
At the call to Update(), the compiler now complains that there isn't such a function (anymore).
The migration site from VTK doesn't really tell me too much about that - I believe this falls into the section Removal of Data Objects’ Dependency on the Pipeline , but as it's no Algorithm which is filling my image, I can't call update on an algorithm.
Similar goes for custom-filled vtkPolyData objects.
My question now is: Is the call to Update not necessary (anymore?), can I just remove it? Or by what would I need to replace it?
I have to say I'm relatively new to vtk, so if there's something fundamentally simple that I'm missing I'd be glad if you could point it out to me!
I think you've been meaning to call Modified() on your image rather than Update().
Apparently they already answered your question on VTK:
http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Removal_of_Update

How do you control a player character in Bullet Physics?

I am not sure how you are supposed to control a player character in Bullet. The methods that I read were to use the provided btKinematicCharacterController. I also saw methods that use btDynamicCharacterController from the demos. However, in the manual it is stated that kinematic controller has several outstanding issues. Is this still the preferred path? If so, are there any tutorials or documentations for this? All I found are snippets of code from the demo, and the usage of controllers with Ogre, which I do not use.
If this is not the path that should be tread, then someone point me to the correct solution. I am new to bullet and would like a straightforward, easy solution. What I currently have is hacked together bits of a btKinematicCharacterController.
This is the code I used to set up the controller:
playerShape = new btCapsuleShape(0.25, 1);
ghostObject= new btPairCachingGhostObject();
ghostObject->setWorldTransform(btTransform(btQuaternion(0,0,0,1),btVector3(0,20,0)));
physics.getWorld()->getPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
ghostObject->setCollisionShape(playerShape);
ghostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
controller = new btKinematicCharacterController(ghostObject,playerShape,0.5);
physics.getWorld()->addCollisionObject(ghostObject,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
physics.getWorld()->addAction(controller);
This is the code I use to access the controller's position:
trans = controller->getGhostObject()->getWorldTransform();
camPosition.z = trans.getOrigin().z();
camPosition.y = trans.getOrigin().y()+0.5;
camPosition.x = trans.getOrigin().x();
The way I control it is through setWalkDirection() and jump() (if canJump() is true).
The issue right now is that the character spazzes out a little, then drops through the static floor. Clearly this is not intended. Is this due to the lack of a rigid body? How does one integrate that?
Actually, now it just falls as it should, but then slowly sinks through the floor.
I have moved this line to be right after the dynamic world is created
physics.getWorld()->getPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
It is now this:
broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
I am also using a .bullet file imported from blender, if that is relevant.
The issue was with the bullet file, which has since been fixed(the collision boxes weren't working). However, I still experience jitteryness, unable to step up occasionally, instant step down from to high a height, and other issues.
My answer to this question here tells you what worked well for me and apparently also for the person who asked.
Avoid ground collision with Bullet
The character controller implementations in bullet are very "basic" unfortunately.
To get good character controller, you'll need to invest this much.

Project1.exe Has Stopped Working. I cant seem to find what the heel is wrong with my SDL Code

All right, i apologize right away because the code is actually kind of big. The thing is, i am working with SDL, learning actually. I had managed to create animations, but i decided i wanted to go a little deeper. This is how the Code works
App - Uses: This has the main loop, the Init function, the Render Function and the whole softwares is originated from here.
Animation - Uses: This will contain and declare all of the functions in the Class Animation. It only works when a bool variable called Running is true.
Surface - Uses: This will Load files onto surfaces, Make certain color transparents and Draw images or part of images onto the MainSurface.
Events - Uses: This has all of the Virtual Functions to Events
Object - Uses: This is the big part. It was working perfectly. Before i would have a Surface Called Yoshi on the Main Class, and i would interact with the animation using that Surface. I thought that the method of having the "Character" on the main Class was a little bit confusing and it would cause me problems when having Multiple images on the screen. So therefore i decided to create a class called Object, which would have its own SDL_Surface, its own location on screen, Its own variable decided which frame it is. What i did was that i created an object to This class on the APP Class... Something like
Object MainCharacter;
So then i would be able to manipulate that Character alone, and if i ever needed to have another Object on screen i would just use
Object *SecondCharacter;
etc... So then the OBJECT Class would call the Animation. APP Class would render all of the images, by a function somewhat like this
MySurface::OnDraw(Surf_Display, MainCharacter.Img_Surface, MainCharacter.RetrievePosX(), MainCharacter.RetrievePosY(), MainCharacter.RetrieveFrameByID(0), MainCharacter.RetrieveFrameByID(1), 64, 64);
Well... But the thing is: The code stops working. This is far from a finished code, but i would like to fix this issue right away, so i can finish only after it already has a base.
Here are all of the files: Some of them dont have too many lines. I also wrote some comments to help anyone who may be able to help me.
HEADERS:
Animation.h - http://pastebin.com/v4REcmBd
Object.h - http://pastebin.com/KdeamZTG
Events.h - http://pastebin.com/dpQ7zwpG
CApp.h - http://pastebin.com/5zZYwDjv
Surface.h - http://pastebin.com/S66ChQ3f
SOURCES:
Surface.cpp - http://pastebin.com/KRgAkHpw
Object.cpp - http://pastebin.com/RtDRwVj4
Events.cpp - http://pastebin.com/dpXn8Rh3
OnRender.cpp - http://pastebin.com/AqgMTacb
OnLoop.cpp - http://pastebin.com/UAeAt7y6
OnInit.cpp - http://pastebin.com/1iiZVeyK
OnEvent.cpp - http://pastebin.com/AjRXnKC1
OnCleanUp.cpp - http://pastebin.com/cv0M11nV
CApp.cpp - http://pastebin.com/L0jhfWY8
Animation.cpp - http://pastebin.com/0BZhh6TG
All right those are it. Some of them are really short. Well, if anyone can help me finding where is my mistake i would be glad. And with that aside, i would really like to get an opinion on the structure of the software, do you think what i am doing is practical? What Design do YOU use when creating SDL Software or Games???
Having been told in the comments it happens on line 12 of Source.cpp which says
Res = SDL_DisplayFormat(Temp);
and googled SDL_DisplayFormat for you, I find this manual page
Near the bottom it says:
Newbie hint
You have to call SDL_Init before using the SDL_DisplayFormat function.
If you don't, your program will crash with an access violation.

after effects looping for web

im making a video for a website in after effects
Its a simple under construction page. The video made in after effects effectively has two parts
transitions in the text,
some minor flicker animation.
I want to keep the flicker animation going for the rest of the time (infinite loop on my page), instead of looping the whole video. How do i Do that?
You can use a video api like this one:
http://videojs.com/docs/api/
A simple event would be the solution.
var myFunc = function(){
var myPlayer = this;
if(myPlayer.currentTime == x) {
myPlayer.currentTime(y);
};
myPlayer.addEvent("eventName", myFunc);
Your best bet is some kind of script (like the one posted by Gijoey above...) You can technically export videos to be "looping" but trusting that keyframing to translate across codecs/browsers is risky. I would convert the vid to something like an FLV / F4V as well. You could wrap it in a SWF if you want to deal with flash, but that's probably unnecessary for this purpose :P

OPENGL ARB_occlusion_query Occlusion Culling

for (int i = 0; i < Number_Of_queries; i++)
{
glBeginQueryARB(GL_SAMPLES_PASSED_ARB, queries[i]);
Box[i]
glEndQueryARB(GL_SAMPLES_PASSED_ARB);
}
I'm curious about the method suggested in GPU GEMS 1 for occlusion culling where a certain number of querys are performed. Using the method described you can't test individual boxes against each other so are you supposed to do the following?
Test Box A -> Render Box A
Test Box B -> Render Box B
Test Box C -> Render Box C
and so on...
I'm not sure if I understand you correctly, but isn't this one of the drawbacks of the naive implementation of first rendering all boxes (and not writing to depth buffer) and then using the query results to check every object? But your suggestion to use the query result of a single box immediately is an even more naive approach as this stalls the pipeline. If you read this chapter (assuming you refer to chapter 29) further, they present a simple technique to overcome the disadvantages of both naive approaches (that is, just render everything normally and use the query results of the previous frame).
I think (it would have been good to link the GPU gems article...) you are confused about somewhat asynchronous queries as described in extensions like this:
http://developer.download.nvidia.com/opengl/specs/GL_NV_conditional_render.txt
If I recall correctly there were other extensions to check for the availability of a result without blocking also.
As Christian Rau points out doing just "query, wait for result, do stuff based on result" might stall and might not be any gain because of that, depending on how much work is in "do stuff". In fact, doing the query, waiting for it to round trip just to save a single draw call is most likely not going to help at all.