Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8294343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:10:44+00:00 2026-06-08T14:10:44+00:00

i am trying to make small 3D scene where are 4 pyramids that can

  • 0

i am trying to make small 3D scene where are 4 pyramids that can user rotate and zoom in/out.

i wrote following code. it works good, but when i delay pyramids to far (-100 units), they are not drawed. i dont know why. is there some restriction for glTranslatef()?

    public class PrespectiveView extends GLSurfaceView implements GLSurfaceView.Renderer
    {
        MainActivity thiz;
        Triag t = new Triag();
        public PrespectiveView(MainActivity a)
        {
            super(a);
            thiz = a;
            setRenderer(this);
        }

        float _width = 320, _height = 462;

        public void onSurfaceCreated(GL10 gl, EGLConfig arg1)
        {
            gl.glMatrixMode(GL10.GL_PROJECTION);
            float size = .01f * (float) Math.tan(Math.toRadians(45.0) / 2); 
            float ratio = _width / _height;
            gl.glFrustumf(-size, size, -size/ratio, size/ratio, 0.1f, 100.0f);
            gl.glMatrixMode(GL10.GL_MODELVIEW);
            gl.glEnable(GL10.GL_DEPTH_TEST);
            gl.glClearColor(0.5f, 0.8f, 0.8f, 1f);
            gl.glEnable(GL10.GL_CULL_FACE);
            gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
            gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
        }

        public void onSurfaceChanged(GL10 gl, int arg1, int arg2)
        {
            _width = arg1;
            _height = arg2;
            gl.glViewport(0, 0, arg1, arg2);
        }

        float[][] transArr = {{-1f,1f, 0f},{1f,1f, -1f},{-1f,-1f, -2f},{1f,-1f, -3f}};
        public void onDrawFrame(GL10 gl)
        {
            gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
            gl.glLoadIdentity();
            gl.glTranslatef(0f, 0f, -50f+CameraDist);
            gl.glRotatef(CameraAX, 1f, 0f, 0f);
            gl.glRotatef(CameraAY, 0f, 1f, 0f);
            for(int i = 0; i < 4; i++)
            {
                gl.glPushMatrix();
                gl.glTranslatef(transArr[i][0], transArr[i][1], 0);
                t.draw(gl);
                gl.glPopMatrix();
            }
            thiz.write(""+CameraDist);
        }
        boolean UpDown;
        float CameraAX = 0, CameraAY = 0, CameraDist = 0, tempX, tempY;
        @Override public boolean onTouchEvent(MotionEvent e)
        {
            if(e.getAction() == MotionEvent.ACTION_DOWN)
            {
                tempX = e.getX();
                tempY = e.getY();
                UpDown = e.getY() > _width/2;
                return true;
            }

            if(UpDown)
            {
                CameraAY -= (tempX-e.getX())/5;
                CameraAX -= (tempY-e.getY())/5;
            }
            else
            {
                CameraDist -= (tempY-e.getY())/2;
            }
            tempX = e.getX();
            tempY = e.getY();

            return true;   
        }
    }

//Triag draw
public void draw(GL10 gl)
{
   gl.glColor4f(1, 1, 1, 1);
   gl.glVertexPointer(3, GL10.GL_FLOAT, 0, f);
   gl.glColorPointer(4, GL10.GL_FLOAT, 0, c);
   gl.glDrawElements(GL10.GL_TRIANGLES, 12, GL10.GL_UNSIGNED_SHORT, s);
}

Thanks for help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:10:48+00:00Added an answer on June 8, 2026 at 2:10 pm

    You’re translating your pyramid past the far clipping plane of your viewing frustum (the gl.glFrustumf(-size, size, -size/ratio, size/ratio, 0.1f, 100.0f); line defines this).

    Increase the far clipping plane (currently 100.0f) if you want it to be visible further, but take note that if you ever do any sort of depth testing, your depth values will get less accurate the further away you go. If you notice any z-fighting, increase the near clipping plane as much as you can without clipping objects in the world (currently 0.1f).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make some small additions to some old java code that
I'm trying to make a small script that takes 2 user inputs (a timezone
I am trying to make a small form that lets the user pick one
I'm trying to make a small Python script that is executed by clicking an
I'm trying to make a small program that could intercept the open process of
'm trying to make a small modification to django lfs project, that will allow
Im trying to make a small app in c++ that saves midifiles with this
I'm trying to make a small VBScript that compacts a MS Access 2007 database
i'm trying to make a small project that uses multiple forms (dialogs) for different
I'm trying to make a small Flash game that has a GUI, which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.