How to make a sphere clickable

Hi guys,
I've been programming in Java for a while, and am very new to Java3D. I have the code below which displays a simple sphere in a box. I have some things I'd like to do but am unsure of how to go about them.
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.behaviors.mouse.MouseWheelZoom;
import java.awt.event.*;
import java.awt.event.WindowAdapter;
import java.awt.*;
public class prototype1 {
public prototype1() {
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
Sphere sphere = new Sphere(0.5f);
TransformGroup maing = new TransformGroup();
maing.addChild(sphere);
   group.addChild(maing);
   Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);
   BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
   Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
   DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
   light1.setInfluencingBounds(bounds);
   group.addChild(light1);
   universe.getViewingPlatform().setNominalViewingTransform();
   universe.addBranchGraph(group);
public static void main(String[] args) { new prototype1(); }
}The first thing I cannot do is figure out how to resize the window that the sphere appears in.
The second thing I cannot do is to make the sphere clickable, so that when you click on it a simple System.out.println occurs. I have looked around and found a group.setPickable(true); sort of statement, can this be applied here? Or is a better method to have a button over the sphere and make it invisible? Or is there some way to detect the co-ordinates of the panel that have been clicked? If anyone has any ideas or can point me towards some good tutorials that would be fanatastic,
Thanks
Beccy

Hi!
Right have figured out the first problem by myself!
This is my code so far:
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.vecmath.*;
import com.sun.j3d.utils.behaviors.mouse.MouseWheelZoom;
import java.awt.event.*;
import java.awt.*;
public class prototype1 {
public prototype1() {
     JFrame.setDefaultLookAndFeelDecorated(true);
     JFrame frame = new JFrame("Prototype Visualisation");
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     Panel canvasPanel = new Panel();
     canvasPanel.setLayout(new BoxLayout(canvasPanel, BoxLayout.Y_AXIS));
     GraphicsConfiguration config = SimpleUniverse
            .getPreferredConfiguration();
     Canvas3D canvas = new Canvas3D(config);
     canvas.setSize(700,450);
     canvasPanel.add(canvas);
     frame.add(canvasPanel);
     frame.pack();
     frame.setVisible(true);
   SimpleUniverse universe = new SimpleUniverse(canvas);
   BranchGroup group = new BranchGroup();
   Sphere sphere = new Sphere(0.1f);
   sphere.setPickable(true);
   TransformGroup maing = new TransformGroup();
   maing.addChild(sphere);
   group.addChild(maing);
   Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);
   BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
   Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
   DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
   light1.setInfluencingBounds(bounds);
   group.addChild(light1);
   //group.setPickable(true);
   universe.getViewingPlatform().setNominalViewingTransform();
   //TransformGroup cameraTransform = universe.getViewingPlatform().getViewPlatformTransform();
   //cameraTransform.setTransform(getCameraTransform(5.0));
   // add the group of objects to the Universe
   universe.addBranchGraph(group);
public static void main(String[] args) { new prototype1(); }
}

Similar Messages

  • How to make shape objects clickable/selectable in transformgroups in java 3

    I am building a visualizer program that has Java 3D components inside Swing components. I have a branchgroup inside a canvas3d inside a simpleuniverse, which is added to a JTabbedPane. Inside the branchgroup I have multiple transformgroups each with one shape in them (box, cone, sphere, cylinder). Each transformgroup has the ability to rotate, zoom, and tranlate objects because I have incorperated a MouseZoom, MouseRotate, and MouseTranslate object as from the Java 3D library functions (these are applied to each transformgroup every time one is created and added to the branchgroup). My problem is that I am trying to make these shapes clickable/sectable/dragable/dropable on the screen - currently when I try to translate ONE object all the shapes move on the screen and I cannot get just one shape to move (all shapes move when I only want one to). How do I make only one shape move when it is clicked?
    I know the question is kind of out there and specific so if anyone knows how to generically give transformgroups/shapes drag and drop properties that would also help a great deal. Does anyone know how to to this? Thanks a ton.

    shape uses the contains and intersects methods, is that what you need? Without code it is hard to guess what is required.

  • How to make form fields "Clickable"

    Hey Guys,
    I created a Fillable PDF Form with Form fields using ADOBE Acrobat 9.0 Pro-Ex + LiveCycle Designer for Windows XP.
    My question is when you create a form, is there a way to make form fields "clickable" instead of just auto-tab? Because if you mess up when filling out the form, you don't want to have to tab through the whole document just to get back to that spot. How can i fix that?
    My other question is, when printing the form, the form field "text boxes" always show up. Is there a way to hide the boxes and just print the form without them. (The information that was filled in will still show, just the outline of the boxes won't?)
    Thanks a bunch,
    Joseph

    Unfortunately I don't know enough about Designer to tell you what you did to make the boxes unclickable, but for me I've never had an issue doing that.
    However, I can tell you what you need to do to get rid of the boxes around each of your text fields.
    1. In design mode, select the field(s) you wish to get rid of the borders on. (If all you have are text fields, you can press Ctrl+A to select all fields. If not, you can hold down the Ctrl button while left-clicking each field to change all text fields at once.)
    2. Open the Object window (Shift+F7 toggles this on and off). Find the option for Appearance.
    3. Click the drop down menu next to Appearance and choose none.
    4. The borders will now be gone from the text fields.

  • How to make a div clickable and still be w3c compliant

    Can someone help me to make a div clickable so it is still w3c compliant?This is my current div and it seems to work, but when I check for compliance I get "unexpected end tag (a not expected). ???
    <div id="pic-wrapper">
    <a href="../index.htm"><div id="pic"></div></a></div>
    Appreciate any help. Thank you.

    This is something I've never needed to do mysefl, but it ought to work ok.  And do not remove your standard a tag with its link currenlty inside the div so Search Engines will be able to spider the link and users without javascript will be able to reach it as well.  I've added the code in orange:
    <div id="pic-wrapper" onclick="location.href='http://www.yourwebsite.com/index.htm';" style="cursor: pointer;">
    <a href="../index.htm"><div id="pic"></div></a></div>
    I just guessed your link was to the homepage, so that is what I replicated in orange, but of course you would be sure to change the link to the correct absolute address.
    Let us know how this works for you.
    E. Michael Brandt
    www.divahtml.com
    www.divahtml.com/products/scripts_dreamweaver_extensions.php
    Standards-compliant scripts and Dreamweaver Extensions
    www.valleywebdesigns.com/vwd_Vdw.asp
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

  • How to make an image clickable region?

    Hi
    Please see the image below, in particular I have a seperate layer READ MORE, I want to save this image as a PNG file and in my HTML page make the READ MORE region like a clickable button. I know I can slice this into a seperate image and wrap in a <DIV tag to do this, but any other ideas please ?

    Google for "HTML image map" for way too many tutorials. Image maps are typically taught before DIVs.

  • How to make path object clickable in flex 4.0

    hi , i apprechiate if any one can help me out  with my problem here as i am new to flex
    I am developing a flex web application and in one my components i need to draw paths around some shapes , i did this easily but my problem is that i need to make changes in response to user  mouse click or mouse hover events over that path.
    the problem is that the path object do not have any events accept the activate event. any one can help me out on this one .

    thanks for your reply but my problem is not to recreate the path based on an event
    what i need is to listen to the click event on the path itself after it is created and diplayed to the user so that when the path is clicked i can change application state.

  • How to make clickable links in headers

    I am using POPFile to filter my mail. It is terrific. I have used it for years. It will produce a link in the header to any message. In most email programs, the link will appear clickable. But in Mac Mail, it does not. I have to highlight it, and then drag it onto my Firefox icon in the doc. That works, but I would like to find a way to make the links clickable. In Thunderbird there is a plugin called mheny, but I cannot find such a plugin for Mac Mail. Any ideas?

    Anyone...anyone? Ferris Buehler?

  • How to make portlet header not clickable?

    Hi,
    I published a page as a portlet and placed it on another page. I enabled the region where the portlet resides in to show the portlet header. Now I found out that if I click the portlet header, the orignial page of the portlet is shown. I don't want to show it to my users, but do want to keep the portlet header and make it non-clickable. Is there a way to do that? Any help will be appreciated.
    I'm using version 10g.
    Thanks,
    Yaxu

    Hi,
    You have to disable the "Show Details Link on Portlet Header" box for the region where you display the page as portlet.
    It's at the end of the "Edit Region" Main page where you can set which links you want to display.
    Alex

  • How to make HDivide Box Bars clickable?

    Does anyone know how to make the bars of a HDivide box click
    able so I can collapse or open the children. Basically when clicked
    I want to collapse the bars and change the bar image and then if
    it's closed have it open... Similar to Editing tools in windows
    applications. Any examples or help would be appreciated

    Be sure that you have assigned the button covering the stage
    the instance name "clic"
    Also, to cover all bases, you will be better off to approach
    the code using strict AS3...
    var url:String = "
    http://hartkopfconstruction.com";
    var request:URLRequest = new URLRequest(url);
    function clicked(e:MouseEvent):void{
    navigateToURL(request);
    clic.addEventListener(MouseEvent.CLICK, clicked);
    Sorry, but I don't personally know any good Flash books. I've
    done most of my learning by doing (trying) and searching for
    solutions when I need them. If you search the forum you may find
    some recommendations. I've seen this question a few times.

  • Can't figure out how to make "sub-tabs" / Too many "top-tabs" / Other ?

    First of all, the website that I am webmaster for is: www.cindydennis.org .
    I am having some problems:
    1) There are TOO MANY tabs at the top. I can't figure out how to make sub-headings on one page...
    For example, I'd like on the "About CDM" page, tabs that can be clicked on to go to other information tabs, but that don't end up appearing on the top (e.g.: having "Remarks" and "What We Believe" tabs go there, but not appear at the top).
    Another example, if you look at the home screen, I'd like to have the link to the "Privacy Policy" and Terms of Service" pages on the bottom, but not have them appear as tabs in the top, too.
    How do I do this, please? I've searched, and can't figure out/___sbsstatic___/migration-images/migration-img-not-avail.png
    2) How do I add "Copyright 2011" automatically? I saw in the Rapidweaver trial version, it automatically adds it when you publish... is there a way to tell this program to do this? Or do I need to type that in on each page? (I don't want to purchase RW... I'm not ready for that yet.)
    Thank you in advance
    Cindee

    Cindee ~ One way to do the copyright notice is to use a Text Clipping — Select (highlight) the copyright text you want to use and drag it to the Desktop. If necessary, change the name of the Clipping icon so that it's more easily identifiable on the Desktop. Then, when you need it in iWeb, simply drag the Clipping icon from the Desktop to iWeb's main canvas.
    By the way, rather than posting your URL here like this:
    www.cindydennis.org
    ...include the prefix to make it conveniently clickable:
    http://www.cindydennis.org

  • How to make Shape3D object translucent

    Hi,
    How to make Shape3D object (like Box, Cylinder) translucent? I tried the below option but the box is not becoming translucent at all.
    final PhongMaterial redMaterial = new PhongMaterial();
              redMaterial.setSpecularColor(Color.rgb(10, 255, 15, opacity));
              redMaterial.setDiffuseColor(Color.rgb(10, 255, 15, opacity));
    final Box box = new Box(width,height,depth);
    box.setMaterial(redMaterial);
    When opacity is 1, the color of the box will be Green, when it is 0 the color becomes black.
    Is there any way the box can be made translucent?

    There is at least one unresolved issue concerning PhongMaterial's transparency: RT-28874.
    I'm neither able to get it working properly. My red Sphere also fades to black while varying the opacity value from 1.0 to 0.0.
    August

  • On a mac with snow leopard, how do you paste a clickable url?

    When I cut and paste a url, it is not clickable. I have been unable to figure out how to make it clickable, which  I believe is called a hyperlink. Thank you for any info.

    Do you mean like this? First, copy the URL. Next, open up TextEdit. Here, you can paste the URL. Next, highlight the URL, right click it and select "Make Link". After that, press the arrow key or click in a blank spot on TextEdit. Select the link, and type in the new name of the link. You have now successfully created a hyperlink.

  • How to make a rollover image, but not for a button

    Hello,
    I should probably not care so much about this, but I'm
    wondering how to make an image have a rollover state without making
    it a clickable button. See the link below, and when it all loads,
    move your mouse over the "go home" button at the bottom. I'd like
    for that rollover to happen but without the little "link hand"
    showing up, you know? I know how to do this in html but I'm new to
    flash so I'd love it if somebody here could help me out. Thanks!
    Here's the link:
    http://www.designedbytim.com/flash/

    holycrap its tim wrote:
    > Hello,
    > I should probably not care so much about this, but I'm
    wondering how to make
    > an image have a rollover state without making it a
    clickable button. See the
    > link below, and when it all loads, move your mouse over
    the "go home" button at
    > the bottom. I'd like for that rollover to happen but
    without the little "link
    > hand" showing up, you know? I know how to do this in
    html but I'm new to flash
    > so I'd love it if somebody here could help me out.
    Thanks!
    >
    > Here's the link:
    http://www.designedbytim.com/flash/
    >
    onClipEvent (load) {
    useHandCursor = false;
    i hope this works.
    Michael Katindig
    www.somnotikroom.tk
    \\ illustrator and multimedia designer //

  • I was able copy the hardrive of my old macbook from "My Passport" onto the desktop on an older iMac. but i dont know how to make my hardrive and user name be the main one since someone had used it in the past and had their info on the comp. please help!

    I recently broke my 2008 macbook. i was able to use an external hardrive to back up my data onto My Passport. I was going to buy a new computer but a friend told me sher had an older version of the iMac. (not sure how old but it doesnt have a camera if that helps) i was able to hook it up and turn it on but i ran into a few problems. 1) the "authentic" user or whatever it says is someone who previously used the computer. i added me as a user but im not sure how to make me the main user. 2) after hooking up My Passport, i was able to drag my files and copy them to the desktop.(i think i did it correctly) now, i dont know how to make my hard drive and applications and iformation the "main " info. The current apps on the iMac are super old versions of iTunes and iPhoto and such. 3) while trying to open the apps from my macbook on the iMac, it said it didnt have the right software to open these apps.
    I am so computer illiterate so someone please help!!! Also, i do not have internet in my new apartment yet so if there is a way to make this happen without using the internet that would be preferred. sorry for the horrible spelling and poorly written paragraph.
    THANK YOU!!

    You are not going to be able to run your old system from the backup on this old computer as the hardware is incompatible.
    You need to get a new computer or a refurbished one.

  • How to make column headers in table in PDF report appear bold while datas in table appear regular from c# windows forms with sql server2008 using iTextSharp

    Hi my name is vishal
    For past 10 days i have been breaking my head on how to make column headers in table appear bold while datas in table appear regular from c# windows forms with sql server2008 using iTextSharp.
    Given below is my code in c# on how i export datas from different tables in sql server to PDF report using iTextSharp:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    using System.Diagnostics;
    using System.IO;
    namespace DRRS_CSharp
    public partial class frmPDF : Form
    public frmPDF()
    InitializeComponent();
    private void button1_Click(object sender, EventArgs e)
    Document doc = new Document(PageSize.A4.Rotate());
    var writer = PdfWriter.GetInstance(doc, new FileStream("AssignedDialyzer.pdf", FileMode.Create));
    doc.SetMargins(50, 50, 50, 50);
    doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width, iTextSharp.text.PageSize.LETTER.Height));
    doc.Open();
    PdfPTable table = new PdfPTable(6);
    table.TotalWidth =530f;
    table.LockedWidth = true;
    PdfPCell cell = new PdfPCell(new Phrase("Institute/Hospital:AIIMS,NEW DELHI", FontFactory.GetFont("Arial", 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK)));
    cell.Colspan = 6;
    cell.HorizontalAlignment = 0;
    table.AddCell(cell);
    Paragraph para=new Paragraph("DCS Clinical Record-Assigned Dialyzer",FontFactory.GetFont("Arial",16,iTextSharp.text.Font.BOLD,BaseColor.BLACK));
    para.Alignment = Element.ALIGN_CENTER;
    iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance("logo5.png");
    png.ScaleToFit(105f, 105f);
    png.Alignment = Element.ALIGN_RIGHT;
    SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
    SqlCommand cmd = new SqlCommand("Select d.dialyserID,r.errorCode,r.dialysis_date,pn.patient_first_name,pn.patient_last_name,d.manufacturer,d.dialyzer_size,r.start_date,r.end_date,d.packed_volume,r.bundle_vol,r.disinfectant,t.Technician_first_name,t.Technician_last_name from dialyser d,patient_name pn,reprocessor r,Techniciandetail t where pn.patient_id=d.patient_id and r.dialyzer_id=d.dialyserID and t.technician_id=r.technician_id and d.deleted_status=0 and d.closed_status=0 and pn.status=1 and r.errorCode<106 and r.reprocessor_id in (Select max(reprocessor_id) from reprocessor where dialyzer_id=d.dialyserID) order by pn.patient_first_name,pn.patient_last_name", conn);
    conn.Open();
    SqlDataReader dr;
    dr = cmd.ExecuteReader();
    table.AddCell("Reprocessing Date");
    table.AddCell("Patient Name");
    table.AddCell("Dialyzer(Manufacturer,Size)");
    table.AddCell("No.of Reuse");
    table.AddCell("Verification");
    table.AddCell("DialyzerID");
    while (dr.Read())
    table.AddCell(dr[2].ToString());
    table.AddCell(dr[3].ToString() +"_"+ dr[4].ToString());
    table.AddCell(dr[5].ToString() + "-" + dr[6].ToString());
    table.AddCell("@count".ToString());
    table.AddCell(dr[12].ToString() + "-" + dr[13].ToString());
    table.AddCell(dr[0].ToString());
    dr.Close();
    table.SpacingBefore = 15f;
    doc.Add(para);
    doc.Add(png);
    doc.Add(table);
    doc.Close();
    System.Diagnostics.Process.Start("AssignedDialyzer.pdf");
    if (MessageBox.Show("Do you want to save changes to AssignedDialyzer.pdf before closing?", "DRRS", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) == DialogResult.Yes)
    var writer2 = PdfWriter.GetInstance(doc, new FileStream("AssignedDialyzer.pdf", FileMode.Create));
    else if (MessageBox.Show("Do you want to save changes to AssignedDialyzer.pdf before closing?", "DRRS", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) == DialogResult.No)
    this.Close();
    The above code executes well with no problem at all!
    As you can see the file to which i create and save and open my pdf report is
    AssignedDialyzer.pdf.
    The column headers of table in pdf report from c# windows forms using iTextSharp are
    "Reprocessing Date","Patient Name","Dialyzer(Manufacturer,Size)","No.of Reuse","Verification" and
    "DialyzerID".
    However the problem i am facing is after execution and opening of document is my
    column headers in table in pdf report from
    c# and datas in it all appear in bold.
    I have browsed through net regarding to solve this problem but with no success.
    What i want is my pdf report from c# should be similar to following format which i was able to accomplish in vb6,adodb with MS access using iTextSharp.:
    Given below is report which i have achieved from vb6,adodb with MS access using iTextSharp
    I know that there has to be another way to solve my problem.I have browsed many articles in net regarding exporting sql datas to above format but with no success!
    Is there is any another way to solve to my problem on exporting sql datas from c# windows forms using iTextSharp to above format given in the picture/image above?!
    If so Then Can anyone tell me what modifications must i do in my c# code given above so that my pdf report from c# windows forms using iTextSharp will look similar to image/picture(pdf report) which i was able to accomplish from
    vb6,adodb with ms access using iTextSharp?
    I have approached Sound Forge.Net for help but with no success.
    I hope anyone/someone truly understands what i am trying to ask!
    I know i have to do lot of modifications in my c# code to achieve this level of perfection but i dont know how to do it.
    Can anyone help me please! Any help/guidance in solving this problem would be greatly appreciated.
    I hope i get a reply in terms of solving this problem.
    vishal

    Hi,
    About iTextSharp component issue , I think this case is off-topic in here.
    I suggest you consulting to compenent provider.
    http://sourceforge.net/projects/itextsharp/
    Regards,
    Marvin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • How do i transfer songs from an old ipod to a new one?

    I had a nano and i now have a classic.  My computer with my old itunes account gpt stolen, so i dont have all the songs i didnt buy from itunes anywhere but my ipod.  how do i transfer all my songs to my computer so i can put them on my new ipod?

  • PDF search for term with space yields term with hyphen

    Hi, I've encountered what seems to be an unpleasant problem in PDF searches, and am wondering whether it's known or has a solution. In words, the problem is that when I perform a PDF search for a term with a space I get results for the term with a hy

  • Missing data in ref cursor

    I've got a procedure in PL/SQL that returns data to a .NET program using a ref cursor. If I run the procedure, all the data shows correctly. However, when I run it from .NET, it drops two records entirely (they are blank) and another one has "SYSTEM.

  • Saved LKM Options not reflecting in new Interface

    I have modified my LKM option to truncate my target table. When I create a new interface, the LKM is automatically selected, but the options selected are not what I had saved. How can I "really" change my option so that every time I create a new inte

  • User interface annoyances in N97

    I just basically wanted to nag about few really annoying features in hope that Nokia might actually read this post. Please feel free to reaply and add to this list. Unlocking announcements Due to security, my phone locks itself every 60 minutes when