tags:

views:

218

answers:

2

HI all,

I'm developing a software to control light show ( through DMX protocol ), i use C# and wpf to develop my main software (.net 4.0)

To help people preview their show, i would like to make a live 3D visualizer...

First, i thought that i could use wpf 3D to make the visualizer, but i need to work with light ..

My main application should send property ( beam angle, orientation (X,Y), position(X,Y), Brush ( color,shape,effect)) to the 3D visualizer

But i would like to be able to move light (position in the scene) by mouse during execution and had value in return...

So ..

Does XNA is the easiest way to doing that ?

Can you help me for that :

  • Generating light (orientation , bitmap like filter in front of light )

  • Dynamically moving object with mouse and get position in return

  • Dynamically add or remove fixture

All of your advice, sample, example are very welcome ... I don't espect to have a perfect result at the first time but i need to understand the main concepts for doing that

Thank You !!

+1  A: 

XNA does not contain any functionality for managing a "scene" - you will have to implement that yourself. For example: you might make a Light class containing the information about your light (position, orientation, etc), and then have a List<Light> of them, which you update and render yourself.

I will now assume that you have a 3D model of a "Light" (as in: the metal box containing the lightbulb) and also a 3D model of a stage. And that you can figure out how to render them - there are plenty of tutorials online for simple model rendering in XNA. Here is a starting point.

So your 3rd requirement ("Dynamically add or remove fixture") should be fairly simple once you can render things. Just add and remove Lights from your List of them based on user input. See the Input namespace.

And your 2nd requirement ("Dynamically moving object with mouse and get position in return") should also be simple. If you want your user to move lights by clicking and dragging, just keep track of the mouse position between frames and apply that as an adjustment to the clicked Light's position (or rotation).

To figure out which Light the user clicks in the first place, a good starting point is the Picking Sample.

I am assuming here that the user will click the Light (metal box) itself to move/rotate it. If you would rather have the user click and drag the endpoint of the light (the spot it projects) - that is more difficult. One idea that comes to mind: Intersect a ray from your Light with the stage to find the centre of the projected spot. At that point draw a dummy "handle" object (like a sphere) that the user can click and drag around. When the user finishes dragging, figure out the new orientation for the Light to make that the new centre.

Finally your 1st requirement ("Generating light (orientation , bitmap like filter in front of light )") is the tricky one. My understanding of this is that you want a way to draw the endpoint of the beam of light on your stage model? If so, what you are looking for is called Projective Texture Mapping. Presumably you will have a circular texture for basic lights, and perhaps other textures for gobos.

The quick-and-dirty way to do this would be to draw your stage model, once for each light, with additive blending (so that each light added with the other lights and the black had no effect), with a colour set to whatever you want the light colour to be, and with a black and white texture (a white circle on black background) drawn with TextureAddressMode.Clamp, with a shader that draws the texture with projective texture mapping which is set up with the light as the projection point.

Andrew Russell
A: 

Thanks for your answers,

I will try to be a little more precise,

For interaction with the user, only "the metal box containing the lightbulb" can be move in the 3D view, the beam ( position, angle , ... should be dynamicly update by the parent software (render 25 fps for example)

I don't know exactly how that work ( should the scene has to be render for every frame, or the moving of light is handling ) : i guess it's my concept of render which is not very defined, for me rendering is the opposite of real time visualization ... and for this project, i need real time visu.

Second point, the Projective Texture Mapping, you got it, i need to see on a wall the shape and the color ( i guess additive blending will be the easy way to doing that) but to make it more efficient, i need to simulate fog (don't care about fog, just to see light ray) have you any clue to doing that.

Here is an example ( i don't expect to be as realistic !!! lol) : http://common.zero88.com/public/images/Lightconverse.jpg

Bgnt44
In XNA you render (draw) your scene every frame. The easiest way to do a light ray would be to simply have a model of a light ray - imagine two rectangles that form an X and extend from your (metal box) light out in some direction with an appropriate texture. Just each draw each light ray model in the same position/orientation as each of your lights. Probably the best way to render them is after everything else, with Z-writes turned off, Z-testing turned on, and with additive blending.
Andrew Russell
I was thinking of that..., Can i extrude a bitmap to a 3D shape (from wall to lightspot .. with reducing size
Bgnt44
Yes, you can. And this may open up other light/shadow-casting techniques (as an alternative to projective texture mapping). Basically you want to convert your bitmap to a series of lines at the outline (I'll leave you to google a method or implementation). Then each of those lines simply becomes the base of a triangle - and all the triangles share a common endpoint - your lightsource.
Andrew Russell
does wpf can convert bitmap to vecto or geometry ?
Bgnt44
ok, i have thinking a bit much and i may found a way :i mass convert my bitmap gobos to vector (svg ??!)then i get lines infos from these and extrude one side to projector and the other side to room limit.. i'm right ?does WPF 3D can handle that ?
Bgnt44
i guess (svg - > geomtry 2d -> geometry 3d ) and what about performance ( doing that for 100 projectors 20 times / seconds for example) (svg will be simple star,cross,bubbles ...)i think of wpf because it could be more integrated in my main application ( and i'm thinking of "in" and "out" communication)
Bgnt44
I'd suggest forming these into full questions and asking them here on Stack Overflow - you'll give more people a chance to answer. And it's easier than trying to fit it into comments here.
Andrew Russell
ok thanks i do it
Bgnt44