Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Help me Please... How to rotate this object and give colour inside

  1. #1
    Junior Member rizkisteve's Avatar
    Join Date
    Apr 2013
    Location
    malang
    Posts
    4
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Help me Please... How to rotate this object and give colour inside

    package id.ac.ub.ptiik.computergraphics;

    import static org.lwjgl.opengl.GL11.*;
    import static org.lwjgl.util.glu.GLU.*;

    public class CG04_3DTransformation extends CGApplication {
    protected boolean wireframe = true;

    @Override
    public void init() {
    // TODO Auto-generated method stub
    // Setting up default viewport
    glViewport(0, 0, width, height);

    // Set perspective projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60.0f, width / height, 1.0f, 100.0f);

    glEnable(GL_TEXTURE_2D);

    }

    @Override
    public void update(int delta) {
    // TODO Auto-generated method stub
    //glRotatef(30, 10, 10, 10);

    }

    @Override
    public void render() {
    // TODO Auto-generated method stub
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    if(wireframe){
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    }else{
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    }

    glBegin(GL_LINES);
    //depan kanan
    glColor3f(0.0f, 0.0f, 0.0f);
    glVertex3f(-1, 1, -10);
    glVertex3f(-1, -3, -10);

    //belakang kanan
    glColor3f(0.0f, 0.0f, 0.0f);
    glVertex3f(0, 2, -14);
    glVertex3f(0, -2, -14);

    //belakang kiri
    glColor3f(0.0f, 0.0f, 0.0f);
    glVertex3f(-4, 2, -14);
    glVertex3f(-4, -2, -14);

    //depan kiri
    glColor3f(0.0f, 0.0f, 0.0f);
    glVertex3f(-4, 1, -10);
    glVertex3f(-4, -3, -10);

    //bawah
    glColor3f(0.0f, 0.0f, 0.0f);
    glVertex3f(-1, -3, -10);
    glVertex3f(-4, -3, -10);

    //kanan
    glColor3f(0.0f, 0.0f, 0.0f);
    glVertex3f(-1, -3, -10);
    glVertex3f(0, -2, -14);

    //belakang
    glColor3f(0.0f, 0.0f, 0.0f);
    glVertex3f(-4, -2, -14);
    glVertex3f(0, -2, -14);

    //kiri
    glColor3f(0.0f, 0.0f, 0.0f);
    glVertex3f(-4, -2, -14);
    glVertex3f(-4, -3, -10);
    glEnd();

    glBegin(GL_TRIANGLES);
    //depan
    glColor3f(0.0f, 0.0f, 1.0f);
    glVertex3f(-4, 1, -10);
    glVertex3f(-1, 1, -10);
    glVertex3f(-3, 5, -12);

    //kanan
    glColor3f(0.0f, 1.0f, 1.0f);
    glVertex3f(-3, 5, -12);
    glVertex3f(-1, 1, -10);
    glVertex3f(0, 2, -14);

    //belakang
    glColor3f(1.0f, 0.0f, 1.0f);
    glVertex3f(-3, 5, -12);
    glVertex3f(-4, 2, -14);
    glVertex3f(0, 2, -14);

    //kiri
    glColor3f(1.0f, 0.0f, 0.0f);
    glVertex3f(-3, 5, -12);
    glVertex3f(-4, 2, -14);
    glVertex3f(-4, 1, -10);
    glEnd();



    }

    @Override
    public void deinit() {
    // TODO Auto-generated method stub

    }

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    CG04_3DTransformation app = new CG04_3DTransformation();
    app.start(800, 600, false, true, "DemoApp04 - 3D Transformation");

    }

    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help me Please... How to rotate this object and give colour inside

    Please post your code correctly. If you've lost the link to the instructions, here it is (near the top).

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Help me Please... How to rotate this object and give colour inside

    Also: It seems to me that your problem is not actually java related but more of a problem with understanding OpenGL. Maybe you will have more success asking questions like these on an OpenGL-related forum.

Similar Threads

  1. Searching for object variables inside a 1-D array?
    By Scorks in forum Collections and Generics
    Replies: 2
    Last Post: September 6th, 2013, 11:36 PM
  2. Delete data from inside the object
    By ankityadav in forum What's Wrong With My Code?
    Replies: 13
    Last Post: September 5th, 2013, 09:11 AM
  3. Replies: 2
    Last Post: July 19th, 2013, 07:27 PM
  4. Only Constructing an Object Once (Details Inside)
    By avalanche72 in forum Object Oriented Programming
    Replies: 0
    Last Post: April 6th, 2012, 04:23 AM
  5. [SOLVED] Accessing methods of an object inside in ArrayList
    By jmack in forum Java Theory & Questions
    Replies: 3
    Last Post: January 22nd, 2011, 12:28 PM

Tags for this Thread