|
Hi,
I am writing a game and planning to use DTED files for terrain generation.There is an example(http://www.geocities.com/oldjajubear/dtedview.zip) for viewing in 2D. I just need the help of this forum in using DTED+OpenGL to modify this code
to disaply DTED in 3D.
|
|
|
|
|
dgpdgp wrote: I am writing a game and planning to use DTED files for terrain generation.There is an example(http://www.geocities.com/oldjajubear/dtedview.zip) for viewing in 2D. I just need the help of this forum in using DTED+OpenGL to modify this code
to disaply DTED in 3D.
OpenSceneGraph directly supports the building and drawing of terrain using DTED:
http://www.openscenegraph.com/index.php[^] or
http://www.delta3d.org/[^] (based on OSG)
you can also use many algorithms at Vterrain.org (including the site's owner's code):
http://www.vterrain.org/LOD/[^]
http://www.vterrain.org/Request/index.html[^] (virtual terrain project's code) Ben is a good guy too.
http://www.vterrain.org/index.html[^] (the root page for information in many terrain related visualization issues).
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hi Expert(s),
I need to draw 100 line with e.Graphics.DrawLine() command. Problem is that, that when i minimize my window all 100 line are vanish. I learn some topic on device context but not got idea how to do.Wht i wanna to do is that
i am drawing line from many differenct event says with 10-20 mouse down events of picture box.So here how do i write code in my OnPaoint() .Pls Pls giv me solution.
Help wud b really appreciated.
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
You need to store any information you need to redraw all the lines when you receive the
WM_PAINT notification.
For a DC to do the drawing to, you can use the BeginPaint/EndPaint APIs or get a DC for the
window and handle the validating of the update region of the window yourself.
What language are you coding in?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I am currently working on a drawing application using openGL and C#..........having a nightmare trying to grasp concept of selection/picking...
My application will be drawing 2D(later 3D) objects...the user will be able to select any edge of a polygon and move it around/modify it..
I have seen few tutorials but they were not really useful..i am still confused about how the retreived information in selection mode(Hits records) will help in performing above mentioned editing functions
kindly help
please suggest links/tutorials (better if in C#)
thanks
|
|
|
|
|
Have you tried http://nehe.gamedev.net. It's in C++ but the concept is the same for selection. Here[^] is the tutorial for selection/picking. It mentions something about gluPickMatrix() so i don't know if that's the same in C#.
Hope that helps.
--------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
The gamedev tutorial is definatly a good place o start.
The basic concept is as follows.
You have an object (say a box) give the box a bounding box or sphere. Pass the center vertex position of the box through the projection pipeline (i.e. project it onto the screen, there are opengl matrices that can do this). This will give you the coords of the object in 2d screen space. You also have to find the screen space size of your bounding area (same kind of method) once you have these you can test the mouse coords against the screen space bounding area.
That isn't the best explination ever but it's somthing to start on. I'll see if I can dig out the code to project into screen coords
|
|
|
|
|
I'm seeking a video encoder software for a camera control system.
The video encoder should provide an SDK and it should be able to support video streaming's buffer size less than 1s or near real time.
Could you please recommend some alternatives (open source/commercial)?
|
|
|
|
|
Would you be able to recommend a virtual camera utility (freeware/shareware)?
The utility needs to be able to read in an video file (such as video.avi) and outputs the video stream as a virtual camera device.
|
|
|
|
|
Until now i used the blend function glBlendFunc(GL_SRC_ALPHA,GL_ONE) to use transparency. But the problem with that is that although it blends black with the background to make it transparent it also blends all colours. That is, it adds the colour with the background colour so black becomes transparent but red blended with green(?) will give white.
The point is that i don't want to blend all colours but simply make a vertex/poly transparent if i set the colour to glColor4f(red, green, blue, alpha) so that the image will have the colour (red,green,blue) but also transparent, instead of blending red, green and blue if you know what i mean.
Here are the params i set on init (if it helps):
glShadeModel(GL_SMOOTH);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glDepthFunc(GL_LEQUAL);
glEnable(GL_COLOR_MATERIAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
Can anyone help me please?
----------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
VizCoder wrote: to use transparency.
the question is actually more complex than you think. OpenGL doesn't know how to do transparency. "Alpha blending" applies a mathematical function to the source and destination values of color from raster buffer to new data, to achieve a "similar" appearance. You can do better than this and get close to true transparency, but you must get smart on ordering of your scene and combination of blends. You've already realized that color add goes high to white which may not be the look you want. There are other blending functions, combining them with ordered triangles, you can get the look you want through design more than automation. True OpenGL transparency takes a bit of thought and work.
http://www.opengl.org/resources/faq/technical/transparency.htm[^]
http://www.derivativeinc.com/Tools/Touch000/Manual/Tips/011_AlphaBlending/AlphaBlending.asp[^]
http://www.sjbaker.org/steve/omniv/alpha_sorting.html[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I know about sorting the vertices and all that. That's not my problem. Why can't OpenGL simply blend the colour with the alpha value so that an alpha of 1.0 will mean (r,g,b) stays as (r,g,b) but alpha of 0.5 will blend 1/2 the red of the source with 1/2 the red of the dest (& same for green & blue). I keep reading that glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) does that trick but it doesn't work for me. Black came out as black even when alpha was at 0.
Or am i just doing something wrong?
--------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
The problem is that blending really doesn't know all that goes into the accumulation of color in the raster image. This is where some of the other layers come in. You can utilize a overlay or underlay to improve blending by providing a forced layer of "this is different than that". have you tried the blend program from the Red book on opengl? http://cs-sdl.sourceforge.net/index.php/Red_Book_Chapter_07[^] http://www.opengl.org/resources/code/samples/redbook/[^]
The issue is complicated because of performance consideration. True blending would mean that all objects are blended independently on their own layer such that the blend of background and foreground and even midground can all be weighted appropriately. But it doesn't work that way since all we have is a raster "destination" plane and a source object. Once the blend operation is finished the net result is a new destination plane (the raster plane) and all you can do is change the calculation and whether or not you write to the z-buffer which prevents something else from blending.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I really don't know anything about OpenGL. I just want to create transparent areas (among other things) so could you please just tell me how to make an area transparent. It must be possible since many games do it (like car windows).
See this picture: http://img187.imageshack.us/my.php?image=alphale2.png[^]
which shows what i am getting when i use the blend functions. The edges of the wave (which is from Windows Media Player) should fade to transparent. The edges are (0,0,0,0) and the inside is (r,g,b,1).
If you can't help me then i guess the second image (GL_SRC_ALPHA, GL_ONE) look good enough.
thanks
--------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
VizCoder wrote: which shows what i am getting when i use the blend functions.
I am not positive what the issue is, have you set your driver renderings to quality? are you blending these via vertex coloring or via alpha textures? I understand you don't want to learn all the hardware dependant modes of alpha blending, and only want to do transparency, but the problem is how to do transparency correctly.
When you see see light through a transparent window you see a mixture of different High Dynamic events. You may not realize it, and you may not care, but when you have to model this on a computer, you really need to care. Yes people do transparency, I do it regularly via Z-sorting. Worse, I do it with plane canopies. Why is that worse? because half the canopy is behind the cockpit. The cockpit exists between two transparent volumes. So now I must sort such that without loosing bits in a blending environment, one half of the canopy is merged with the background earth image, then the cockpit is drawn, and then the other half of hte canopy is merged with the after-rending result of the previous operations.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
El Corazon wrote: are you blending these via vertex coloring or via alpha textures?
I am blending via vertex colouring. And you're right, i don't really care about all of the High Dynamic events. I do a Computer Science degree at uni but graphics is not one of my courses. I am just doing this as a hobby because i like graphics. So i really shouldn't waste my time learning about OpenGL lighting effects (i might read up on it on the holidays). I guess i will just use GL_SRC_ALPHA, GL_ONE for now, as long as i don't blend many colours at once and end up with a white screen!
thanks for your help anyway
--------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
I've been using CastorTiu's amazing IconLib in my application.
http://www.codeproject.com/cs/library/IconLib.asp
He has a function in the library that adds an image to an icon. It can add images of many different bit types and they all work fine except for 8bit images. When 8 bit images go through this code which reproduces a full palette the for loop iterates 256 times and this causes the program to go unresponsive for too long... It does eventually finish but only after nearly freezing the program for a few seconds. I was wondering if anyone knew of an alternative for creating a full palette that isn't so intensive on the system.
Here is the function that causes the delays with 8bit images but not 4bit [16 iterations] or 32 bit [skips loop altogether]
public static RGBQUAD[] RGBQUADFromColorArray(Bitmap bmp)<br />
{<br />
int bits = Tools.BitsFromPixelFormat(bmp.PixelFormat);<br />
RGBQUAD[] rgbArray = new RGBQUAD[bits <= 8 ? (1 << bits) : 0];<br />
for(int i=0; i < bmp.Palette.Entries.Length; i++)<br />
{<br />
rgbArray[i].rgbRed = bmp.Palette.Entries[i].R;<br />
rgbArray[i].rgbGreen= bmp.Palette.Entries[i].G;<br />
rgbArray[i].rgbBlue = bmp.Palette.Entries[i].B;<br />
}<br />
return rgbArray;<br />
}
|
|
|
|
|
Hmm that loop should take under a millisecond if bmp.Palette.Entries.Length is 256.
Are you positive that's where time is being consumed (on the thread executing the loop)?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Positive... I stepped through the entire thing and the slowdowns happen during the iterations of the loop.
Happens in my program and just to make sure it wasn't something I did, I loaded up the IconLib project itself and passed it an 8bit image and had the same problem.
|
|
|
|
|
This sounds kinda strange...
Copying 1 byte from one location to another 768 times shouldn't take long (unless you have a
REALLY slow machine. I'm pretty sure the original PC at 4.77 MHz could do it in under a
millisecond
If you break execution when it stalls is it really in the loop or is it maybe in the
Tools.BitsFromPixelFormat(bmp.PixelFormat) call.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Machine can more than handle this that's why I posted the question because it's so strange... Yes it does stall during the loop not during the bitsfrompixel
Bits from pixel is just a simply switch anyway
public static int BitsFromPixelFormat(PixelFormat pixelFormat)<br />
{<br />
switch (pixelFormat)<br />
{<br />
case PixelFormat.Format1bppIndexed:<br />
return 1;<br />
case PixelFormat.Format4bppIndexed:<br />
return 4;<br />
case PixelFormat.Format8bppIndexed:<br />
return 8;<br />
... etc.
|
|
|
|
|
Here's a picture of my actual breakpoints...
http://wwwp.mirror.waffleimages.com/files/13/13e214fd705683442d70081bb7c901230aac708a.png
With the wya they are setup in the picture it takes a while to manually step through 256times but it reaches the end eventually and all is fine... But only because it took some time to do manually.
If I remove the breakpoints on i < bmp.Palette.Entries.Length; and i++; the stall happens directly between int i=0; and return rgbArray;
There isn't any further question in my mind that something is going wrong during that palette copying inside that loop. But the real question is why? This machine is a beast and the rest of the code is fine just for somereason 256 iterations of
rgbArray[i].rgbRed = bmp.Palette.Entries[i].R;<br />
rgbArray[i].rgbGreen= bmp.Palette.Entries[i].G;<br />
rgbArray[i].rgbBlue = bmp.Palette.Entries[i].B;
stalls the program for 30 seconds or so.
|
|
|
|
|
I'm wondering if it's reallocating/recreating a new palette every time the Palette property is
accessed.
Maybe the optimized loop I posted below will help
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hmmm...
Is this managed C++? If so, does optimizing the loop help any?
public static RGBQUAD[] RGBQUADFromColorArray(Bitmap bmp)
{
int bits = Tools.BitsFromPixelFormat(bmp.PixelFormat);
if (bits <= 8)
{
RGBQUAD[] rgbArray = new RGBQUAD[1 << bits];
ColorPalette ^palette = bmp.Palette;
array<Color>^palcolors = palette->Entries;
for(int i=0; i < palcolors->Length; i++)
{
rgbArray[i].rgbRed = palcolors[i].R;
rgbArray[i].rgbGreen= palcolors[i].G;
rgbArray[i].rgbBlue = palcolors[i].B;
}
return rgbArray;
}
return 0;
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|