PDA

View Full Version : removing objects and timing+objects movement



07-19-2001, 10:02 AM
This may sound stupid...
1.Question
How Can I delete obejcts after use so that it will deleted from screen???

2.Question
How can I put time on how long something will stay on screen??? Like I want to show that red cube around here 5 seconds???

3.Question
How Can I move Objects around Screen???

DFrey
07-19-2001, 10:29 AM
Those are so basic, that it would hint to me that you simply aren't familiar with programming in general. You might want to try something easier first to better learn the principles involved. Like make a simple program that prints your name on the screen for 5 seconds then takes it away. If you can do that, then you could do this.

[This message has been edited by DFrey (edited 07-19-2001).]

07-19-2001, 11:09 AM
You know what beginner means?
I know the all c++ **** that they teach us on books... cout << "I am beginner"
And on turials they just show how to make objects and texture and rotate them...
Please I really need help

Deiussum
07-19-2001, 11:34 AM
Just knowing the stuff in books isn't always good enough. You have to understand it as well, and have to be able to use what you know to achieve what you want. As DFrey said, think about how you would print out "I am a beginner" for 5 seconds and then remove it from the screen. The way you would do it in OpenGL is almost exactly the same. Just as the console doesn't keep track of letters you send it, OpenGL doesn't keep track of objects you draw...

Newbie2001
07-19-2001, 01:55 PM
Hey, why won't you guys help stupid? I need help with the same problem.

DFrey
07-19-2001, 02:10 PM
Give a man a fish, he eats for a day. Teach a man to fish, he eats for a lifetime.

Newbie2001
07-19-2001, 02:15 PM
Thanks for nothin' DFrey. I don't eat fish.

DFrey
07-19-2001, 02:27 PM
Uh, nice one Newbie2001. Or should I say cousin http://www.opengl.org/discussion_boards/ubb/tongue.gif?

Newbie2001
07-19-2001, 02:42 PM
I know nothing of OpenGL people. I'm just bored 15 yr. old kid lookin' for somethin' to do http://www.opengl.org/discussion_boards/ubb/frown.gif. So, I ban myself from this forum until I am a true newbie.

T2k
07-20-2001, 12:36 AM
ok i will help http://www.opengl.org/discussion_boards/ubb/rolleyes.gif

if you want to see one object for eyample 5 seconds draw it on screen and dont clear it for 5seconds, and dont draw anything else ...


Real answer: every call is only done 1time, never repeated by the api( that mean, if you draw, and then clear the api does not do this again until you say it !!!)

T2k
07-20-2001, 12:39 AM
and guys, isnt it so that directx keeps tracking objects .... !?! i think it is ...

Bob
07-20-2001, 05:48 AM
D3D is as stupid as OpenGL. It doesn't know anything about what is to be drawn, nor what has been drawn, nor does it know what an object is (actually what IS an object? The whole car, or each part of the car?). D3DX, on the other hand, MIGHT know about something like an object. D3DX is a helper library for D3D, similar to GLU I suppose. It includes vector/matrix functions, file loaders and stuff like that.

A suggestion for you other guys. Go to NeHe's site (http://nehe.gamedev.net) . He got some nice tutorials on OpenGL programming. He starts from scratch, and all you have to have is some basic programming knowlegde.

Deiussum
07-20-2001, 05:53 AM
Direct3D RM kept track of objects in "frames" (not animation frames, but something that I thought of as planes), but the new combined Direct3D stuff in Dx8, and Direct3D IM in older releases didn't.

Anyway, so far as the questions, you should basically be clearing and redrawing the scene each frame. If you want to "delete" an object from the scene, just don't draw it!! Duh! :P http://www.opengl.org/discussion_boards/ubb/smile.gif

07-21-2001, 10:11 AM
Are you guys so 1337 that you cannot help newbies???
Like I would be teacher and I would not let pupils to my classroom!!!
Grow up people...
And what is Delay(x) command on windows?
And what is the command to delete objects?

DFrey
07-21-2001, 10:25 AM
You're still not getting it. If you do not want something to appear on the screen, then you just do not draw it. There is no general delay command (except for sleep but I doubt you want to put the thread to sleep). Instead you have to keep track of time and decide when and when not to draw things. I would suggest you visit http://nehe.gamedev.net and work through the tutorials.


[This message has been edited by DFrey (edited 07-21-2001).]

Newbie2001
07-21-2001, 01:23 PM
Hey stupid?, I'm not a real newbie. I was just bored at that time of day. I know nothing of OpenGL, and as of now don't care to as I am only 15. I have other things to worry about then how to programm at the moment. Sorry if you people except for DFrey thought I was really a newbie. :P

TheMad1
07-21-2001, 01:49 PM
hey maybe you could help me out then, cuz i am a real newbie instead of not helping this kid out http://www.opengl.org/discussion_boards/ubb/smile.gif?

Starnut coder
07-23-2001, 04:25 AM
Ok these questions are really the basics of Graphics programming using an API. I suggest doing 2d-DirectDraw or just GDI programming before going to 3d. But if you want to know the answers anyway here they are:
It is very simple. When you Display objects
or better vertices, they are calculated and displayed every couple of milliseconds.
So you dont actually delete an object, you stop telling the computer to draw it.
First make a Timer(if you dont know what this is tell me).
Inside the timer use the
glCallList() function
or the standard Primitive functions to display your objects. Put these inside an if clause for example if(planet1).
now to delete these objects just set
planet1 = FALSE;
Ill give you a short example.
(dont copy the code its just an extrakt,
and its only to show the idea)
BOOL planet1 = TRUE;

void Timer()
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
if(planet1)
{
glCallList(myobject);
}
}

2.)
I will show the example using Timer ticks
not Time.
Make a variable time = 0;

void Timer()
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
if(planet1)
{
time+=1;
if(time > 100) //example time
{
time = 0;
planet1 = FALSE;
}
glCallList(myobject);
}
}

3.)
This you really have to know unless this is your first time graphics programming.
From left to right example
Just make an object with coords
x, y, z and then ad this in the
Timer Function:
x++;

-Starnut

Deiussum
07-23-2001, 05:34 AM
Another way to think about it would be something like so... You have a list of C++ objects, each with a member variable that has some timeout variable. Each frame you walk through the list and draw all the objects. If an object times out, or you use some other way to "delete" the object from the scene, you simply remove it from the list so it doesn't get drawn anymore.

07-23-2001, 09:59 AM
When I got no help I tried my own...
*did not see 2 messages above this*
I realized that all the tutorials loop the one part of the code forever...
so I made little If function...
now it works...
but getting good timer is mission impossible...

DFrey
07-23-2001, 10:29 AM
When I got no help I tried my own...
*did not see 2 messages above this*
I realized that all the tutorials loop the one part of the code forever...


Exactly. And you figured it out on your own, so you'll better understand it now than if you had just been blindly using something that was given to you. As for creating a timing mechanism, there are several options.
You can use the C time function which will give you 1 second precision, or in Windows, you can use timeGetTime which has millisecond precision. That's usually good enough, but if you want to get microsecond precision, you can do so in Windows with QueryPerformanceCounter and QueryPerformanceFrequency, or in asemmbly on the x86 processors (Pentium and up) by using the rdtsc op-code.