Tuesday, November 10, 2009

Installing OpenSceneGraph 2.8.0

I have gotten help with installing OpenSceneGraph on Windows XP. It was simple after all, at least using the pre-compiled binaries. I just wanted to get started making apps using OSG. With some helpful advice from the OSG community, here’s my detailed instructions for installing OSG on Windows XP from the pre-compiled binaries for use with Visual Studio 2005. The instructions are similar for other versions of Windows and Visual Studio, but I have no experience with them with regard to OSG. This tutorial assumes some experience (but not much) with C++, Visual Studio, command line usage, and Windows XP.

  1. First, you have to actually get the binaries. They can be found here.
  2. Download the packages labeled (i) "openscenegraph-all-2.8.0-win32-x86-vc80sp1-Debug.tar.gz" and (ii) "openscenegraph-all-2.8.0-win32-x86-vc80sp1-Release.tar.gz". They are the files associated with the Debug and Release builds, respectively.
  3. Also download the Sample Datasets labeled OpenSceneGraph-Data-2.8.0.zip (found here).
  4. Uncompress all three archives (try 7-zip for the .tar.gz files). Put all the directories from the Debug release in a directory you want to be the install directory. I’m going to assume C:\Program Files\OpenSceneGraph-2.8.0 from now on as the root for your installation.
  5. Inside the root, you should now see that it contains the folders: bin, doc, include, lib, and share
  6. So you can use both the debug and release builds of each library, go to the Release version’s folder (uncompressed) and copy all the contents into your installation directory. If and when it asks to overwrite a file, click no to all.
  7. It doesn’t really matter where you put the Sample files, so I made a folder in my installation directory called “samples” and copied them there (specifically “C:\Program Files\OpenSceneGraph-2.8.0\samples\OpenSceneGraph-Data-2.8.0″). These files are useful for running examples and giving access to basic fonts and textures.
  8. Now the files are “installed”, but Windows doesn’t know how to use them. To do that, we have to modify the environmental variables.
    1. Right-click on My Computer and select Properties.
    2. Select the Advanced tab.
    3. Click the Environmental Variables button.
    4. Under “System Variables” select the New button.
    5. Give the variable name “OSG_ROOT”.
    6. Give the variable value “C:\Program Files\OpenSceneGraph-2.8.0″ or whereever your install directory is.
    7. Now do the same for several other references, which refer to the OSG_ROOT variable:
      • Name: OSG_BIN_PATH | Value: %OSG_ROOT%\bin
      • Name: OSG_INCLUDE_PATH | Value: %OSG_ROOT%\include
      • Name: OSG_LIB_PATH | Value: %OSG_ROOT%\lib
      • Name: OSG_SAMPLES_PATH | Value: %OSG_ROOT%\share\OpenSceneGraph\bin
      • Name: OSG_FILE_PATH | Value: %OSG_ROOT%\samples\OpenSceneGraph-Data-2.8.0 (note: your directory structure may be different, see above)
    8. Then, select the already existing Path variable, and click Edit.
    9. To the end of the line, after the final semi-colon, add “%OSG_BIN_PATH%;%OSG_SAMPLES_PATH%;”
    10. Apply your changes and close the windows
    11. Your environmental variables should be successfully changed.
    12. To make sure they are working, open a command line window by going to Start, then Run, type “cmd”, and push OK.
    13. Type in “echo %OSG_ROOT%” and hit enter. It should display your install directory.
  9. At this point, you can also test to make sure Windows understands where OSG is. Open a command line window and type “osgversion”. It should return the version of OSG, namely “OpenSceneGraph Library 2.8.0″.
  10. Furthermore, you can test that the sample datasets have been installed by typing “osgviewer cow.osg” into the command line window. This should open the cow model in OSG’s viewer program. Push the escape key to exit.
  11. Now, we need to set up Visual Studio.
    1. Open Visual Studio 2005. If it was already open, close it and reopen it (so that it will get the latest changes you just made above).
    2. Select File > New > Project… and choose Empty Project under Visual C++ > General.
    3. Put it in a directory you’ll remember, and name is something like “OSGDefaultProject”.
    4. So that you will have all the necessary available options, create a new C++ file that will serve as your main file. (I named mine “Main.cpp”.)
    5. Select Project > [ProjectName] Properties…
    6. Select the Debug option from the Configuration dropdown.
    7. Select Configuration Properties > C/C++ > General
    8. Select the box to the right of Additional Include Directories and paste “$(OSG_INCLUDE_PATH)” there.
    9. Select Configuration Properties > C/C++ > Preprocessor
    10. Select the box to the right of Preprocessor Definitions and paste “WIN32;_WIN32;_DEBUG”
    11. Select Configuration Properties > Linker > General
    12. Select the box to the right of Additional Library Directories and paste “$(OSG_LIB_PATH)”
    13. Select Configuration Properties > Linker > Input
    14. Select the box to the right of Additional Dependencies and paste whatever libraries you will use. For now, paste these: osgd.lib osgGAd.lib osgDBd.lib osgViewerd.lib osgTextd.lib osgUtild.lib OpenThreadsd.lib
    15. Now the Debug mode is set up. Select the Release configuration and follow the same steps, except that the library names should NOT have a ‘d’ at the end (As.osg.lib osgGA.lib osgDB.lib osgViewer.lib osgText.lib osgUtil.lib OpenThreads.lib), and in the Preprocessor Definitions change “_DEBUG” to “NDEBUG”.
    16. Visual Studio should now be set up.
  12. Finally, you need to test it.
    • Into your C++ file, you need to copy some valid OSG code.
    • Many test their installation with osgViewer.cpp which can be found in OSG’s source.
    • If you don’t have the source or want a quicker method, go to this tutorial and download "BasicGeometry.cpp" placed at the bottom of that page.
    • There are links at the bottom to the full source for the tutorial. Copy the text into your file.
    • Compile and run. You should see two colored pyramids that you can rotate with your mouse.
  13. Now that it’s installed and you have a working project, you can use this project as a basis for all your OSG projects.

And that’s it. Hopefully the tutorial wasn’t too simplistic. This is the quickest way I know how to install it on Windows. If you want to install from source, try some of the links below.

Thursday, October 29, 2009

How Can Run an .exe file in java

Example:-
import java.io.*;
class test{
public static void main(String args[]){
try{
String str="C:/Program Files/Adobe/Reader 9.0/Reader/AcroRd32.exe";
Runtime.getRuntime().exec(str);
}
catch(Exception e){
}
}
}





Wednesday, October 28, 2009

How to Hide Console in C++

Example:-
#include 
#include
int main()
{
HWND hWnd
= GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );

return 0;
}

Tuesday, October 27, 2009

How to convert 'System::String' to 'char*'?

In VC++ 8:

Example:-


using namespace System::Runtime::InteropServices; // for class Marshal

void PrintMessage(System::String^ str)
{
const char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(str);
printf(str2);
Marshal::FreeHGlobal((System::IntPtr)(void*)str2);
}

PrintMessage("Method 2");

You receive a System.Threading.ThreadStateException exception when you try to create an instance of a Windows form

Problem:- An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll

in microsoft visual c++

Solution:-

Just write '[STAThread]' above the main() function to resolve the problem. This code make your program single-threaded apartment (STA) instead of MTA.


Example:-

[STAThread]
int main(){

Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew UserForm());
return 0;
}

Tuesday, March 17, 2009

Computer Tricks

Convert FAT to NTFS

To convert a FAT partition to NTFS, perform the following steps.

Click Start, click Programs, and then click Command Prompt. In Windows XP, click Start, click Run, type cmd and then click OK.

At the command prompt, type CONVERT [driveletter]: /FS:NTFS. Convert.exe will attempt to convert the partition to NTFS.

NOTE:=
Although the chance of corruption or data loss during the conversion from FAT to NTFS is minimal, it is best to perform a full backup of the data on the drive that it is to be converted prior to executing the convert command.


Change text on XP Start button

Step 1 - Modify Explorer.exe File

In order to make the changes, the file explorer.exe located at C:\Windows needs to be edited. Since explorer.exe is a binary file it requires a special editor. For purposes of this article I have used Resource Hacker. Resource HackerTM is a freeware utility to view, modify, rename, add, delete and extract resources in 32bit Windows executables and resource files (*.res). It incorporates an internal resource script compiler and decompiler and works on Microsoft Windows 95/98/ME, Windows NT, Windows 2000 and Windows XP operating systems.

get this from h**p://delphi.icm.edu.pl/ftp/tools/ResHack.zip

The first step is to make a backup copy of the file explorer.exe located at C:\Windows\explorer. Place it in a folder somewhere on your hard drive where it will be safe. Start Resource Hacker and open explorer.exe located at C:\Windows\explorer.exe.

The category we are going to be using is "String Table". Expand it by clicking the plus sign then navigate down to and expand string 37 followed by highlighting 1033. If you are using the Classic Layout rather than the XP Layout, use number 38. The right hand pane will display the stringtable. We’re going to modify item 578, currently showing the word “start” just as it displays on the current Start button.

There is no magic here. Just double click on the word “start” so that it’s highlighted, making sure the quotation marks are not part of the highlight. They need to remain in place, surrounding the new text that you’ll type. Go ahead and type your new entry. In my case I used Click Me!

You’ll notice that after the new text string has been entered the Compile Script button that was grayed out is now active. I won’t get into what’s involved in compiling a script, but suffice it to say it’s going to make this exercise worthwhile. Click Compile Script and then save the altered file using the Save As command on the File Menu. Do not use the Save command – Make sure to use the Save As command and choose a name for the file. Save the newly named file to C:\Windows.

Step 2 – Modify the Registry

!!!make a backup of your registry before making changes!!!

Now that the modified explorer.exe has been created it’s necessary to modify the registry so the file will be recognized when the user logs on to the system. If you don’t know how to access the registry I’m not sure this article is for you, but just in case it’s a temporary memory lapse, go to Start (soon to be something else) Run and type regedit in the Open field. Navigate to:

HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion\ Winlogon

In the right pane, double click the "Shell" entry to open the Edit String dialog box. In Value data: line, enter the name that was used to save the modified explorer.exe file. Click OK.

Close Registry Editor and either log off the system and log back in, or reboot the entire system if that’s your preference. If all went as planned you should see your new Start button with the revised text.[/b]


Hide Drives and Partitions


Do you have data on a partition or hard drive that you don't want tampered with or easily accessible to other users? Well, you can hide any drive/partition in Windows XP, NT, and 2000. That means that they won't show up in Explorer or My Computer.

If you want access to that drive from your user account you should create a desktop shortcut before proceeding. Once hidden, you can still access by typing the drive letter and a colon in Start/Run—for example, "D:" will bring up a folder of the contents on your D drive.

The easiest way with Win XP is to use the TweakUI power toy from Mcft. Go to Start/Run and type in "tweakui" (without the quotes).

Go to My Computer/Drives and uncheck the drive/partition(s) you want hidden. Click "Apply" or "OK" when finished.

If you have XP but not Tweak UI you can download it here...
http://www.Mcft.com/windowsxp/downloads/powertoys/xppowertoys.mspx

For Win NT, 2000, and XP you can use the following Registry edit:

*Be sure to back up the Registry before proceeding
http://www.worldstart.com/tips/tips.php/401

Open the Registry Editor by going to Start/Run and typing in "regedit" (without the quotes). Find your way to...

HKEY_CURRENT_USER\Software\Mcft\Windows\CurrentVersion\Policies


Click on "Explorer".

Double-click the "NoDrives" key in the right column. If you don't find a "NoDrives" registry key, just right-click in the right pane and choose "New/DWORD Value" then name the key "NoDrives".

You'll see a value like "0000 00 00 00 00". This is where the fun starts. The four sets of double zeros (after the "0000") are where you'll enter the values for the drive/partitions. Now, stay with me on this—it's not as complicated as it sounds:

The first column is for drives A-H, the second for I-P, the third for Q-X, and the fourth for Y-Z.

The values for each drive are as follows:

1 - A I Q Y
2 - B J R Z
4 - C K S
8 - D L T
16 - E M U
32 - F N V
64 - G O W
80 - H P X

So, let's say you want to hide drive D. In the first column you would put "08". For drive K you would put "04" in the second column.

But what if you want to hide more than one drive in a column? Simply add the values together: D+E = 8+16 = 24. So in the first column you would put "24".

Still baffled? If you have XP then go get TweakUI and save yourself the math.

Whichever method you use, you can rest easy knowing that the files on that drive or partition are less accessible to other users.


How To Increase Download Speeds By 100-200 Kbsec


First of all download this wonderful program:

http://www.speedguide.net/files/TCPOptimizer.exe

Then when u start trhe program goto settings goto cable modem or dsl whatevcer u have.

Go to MaxMTU and set it to 1500 this is optimal anything above this will not work as well.

Thats bout it!! Enjoy the speed!!


How To Speed Up A Slow Computer

first off in the bottom right hand corner of your computer if you see alot of icons start up there when you first start your computer then this is for you if you dont know already how to get rid of em.

Press your Start Button (bottom left) and go to "run"
now type in: msconfig
now you will get a box that pops up and will tell you bunch of stuff dont mess with anything else other than what I tell you otherwise you could do something really bad (possible) go to your "startup" tab on the top right of the screen where it usually is and click it.

Now you will have a closed in box with bunch of filenames n addresses and more boxes with checks in them. Now if your like me you dont want anything startin up when you start you computer up or while your even doing anything cause it slows you down. Now unless your like me right now 1 have 1 thing starting up when my computer starts up and thats my settin for my overclocked vid card. But other than that uncheck every box and then hit apply and ok. Then window you were jus in will now close and ask you if you want to restart or wait till later to restart.

Either way when you shut it off and then turn it back on the settins will kick in.

Sunday, March 8, 2009

Vishal in Bithoor


I am in Bithoor and enjoying with friends. The monument behind me is the temple of lord Shiva.
That was constructed in 18th century with the cost of Rs. 250 only at that time.