2nd camera rect: getting rid of scaling - solution? 2003-12-06 - By NoiseCrime
Back -- -- Original Message -- -- From: "Vegard Hofs�y" <me@(protected)>
> I have two identical models in a world, at different positions. They > each have a camera. One model is a wireframe, the other if filled. I > want to overlay (using camera[2].rect) one onto the other.
You mean like this? ;)
http://www.noisecrime.com/working/UFO_wireframe_knockout.dir
Mind you it ain't very straight forward, and took a little messing a round to get working properly. This technique should work well as long as you have a plain colour background. It would be possible with an image but requires a lot of effort.
However it's a very cool effect and you can actually do so much more than just a strip of wireframe with this technique. For example use different shapes for the plane, rotate instead of just translating etc, changing scale, etc.
I'll try and describe the effect in brief, but note the link above is to an open source director file, so you should download it, and check out the code.
Basically you want to obscure the area of the robot where you want to show the wireframe, however its not practical to do with multiple camera's, instead look at the _nodepth flags for a models visibility.
So first off create a plane, aligned to face the camera, and most importantly infront of the robot model position. i.e. closer to the camera. This plane then will overwrite the robot image and therefore the plane needs to be the same colour as the background. In this case its just black.
So what you'd see is the robot, with a black strip through the middle of it.
Now in order for the effect to work we need to control the draw order of the models. We do this by the order they are added to the scenegraph in sw3d. This means we need to create a newgroup which is parented to the world. This allows us to place models into this group in the order we want them drawn.
So the first thing to be drawn and fill the zbuffer is the obscure plane. That means we just create the model and leave it in the world group.
Then we need to create the wireframe model of the robot, so simply duplicate the original from its resources (I see little point using clone its crap anyway). The wireframe Robot must be placed into the newgroup so its the first model in the group. It must also have its visibility set to #both_nodepth and obviously use the wireframe shader.
Finally we move the original robot to be the last model in the newgroup, by changing its parent to be this group
This will create the effect you're after. First the obscure plane is drawn, then the wireframe model is drawn and because its no_depth it will be drawn in full, nothing hidden, even though its behind the obscure plane. Finally we draw the original robot, it will only be drawn outside the obscure plane area because the zbuffer has been filled in.
Alas this isn't quite right. Although the first time I did this I it worked, I made some changes and now the boundary of the wireframe model shows around the boundary of the original robot. Not sure what I did to cause this, but couldn't get rid of it. Maybe with a little more testing you could.
Anyway the solution is simple, we use two more obscure planes this time placed either side and abutting to the original obscure plane. Well call these blackout models, because their purpose is to remove the wireframe model from outside the obscure area. Obviously to do this, the blackout planes must be set to front_nodepth (so they are always drawn) and place directly after the wireframe robot model in the newgroup and before the original robot.
So the final draw order is
1. Obscure plane - fill in zbuffer and colourbuffer. Placed close to the camera, so any other model with zbuffer testing enabled cannot draw into this area.
(the following are in the new group) 2. Wireframe Robot Model 3. Blackout Model Left 4. Blackout Model Right 5. Original Robot Model
Anyway its kinda hard to explain in just words, so check out the source it should be self-explanatory. Also it was coded quickly and sloppily, so its all done with globals in movie script, and I'm sure could be optimised and perhaps written better.
But hey it works so who cares ;)
NoiseCrime 2003 www.noisecrime.com Purveyor of cool Shockwave games, toys and new media content.
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Dir3d-l mailing list Dir3d-l@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
|
|