Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Using POINT OBJECT to keep PLAINs facing towards camera?

Author
Message
gbark
19
Years of Service
User Offline
Joined: 14th Oct 2005
Location: US - Virginia
Posted: 15th Oct 2005 00:56
Hello, this is my first post on this forum, so I'll just give a little intro.

I've been lurking here for a while and reading up on DarkBASIC. I have some experience with computer programming (mostly with JavaScript and Liberty BASIC, I've dabbled a bit with C++, but I couldn't figure out how to use the editor I was using, so I didn't get very far with that. ) so I'm already used to variables, loops, etc, and I've worked with 3D also (POV-RAY and CAD programs mostly), so I'm also familiar with 3D coordinates, axis rotations, etc. This is my first foray into putting the two together however, so it's pretty exciting for me.

Anyways, downloaded the trial a couple of days ago, almost finished with my very first game. It's a simple game where you're running around a matrix, collecting blue crystals, and trying to get more than the CPU before time runs out. I've got all of the main routines done, the menu system, the game engine, the AI, etc, so I decided to start adding the bells and whistles. Right now I'm trying to add a small sparkle effect whenever you get a crystal, but I can't get the sparkle to align to the camera's position.

I did a forum search, seems other people also had this problem, but none of the suggestions offered seemed to worked for me.

Here's my code:


I'm pretty much stumped. Anybody have any solutions?
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 15th Oct 2005 04:43 Edited at: 15th Oct 2005 04:44
Well you didnt post a question but to do what youre asking shouldnt be too hard...



Alternitavely, you could use LOCK OBJECT ON to lock the object to the screen, the pro being easier calculations for the computer, the con being the object wont change in size as you get closer and farther from the plain.

Note that you'll have to first use either the xrotate command or zrotate command to rotate the plain 90 degrees before you can point it to the camera, like so:



Goodluck, hope it helps.
- RUCCUS


gbark
19
Years of Service
User Offline
Joined: 14th Oct 2005
Location: US - Virginia
Posted: 15th Oct 2005 04:57
Hi RUCCUS,

I don't know what happened, I had made my post, submitted it, waited for it to be approved, and once the thread appeared, my post was blank!

Anyway...

Yeah, basically I want a textured PLAIN to always face towards the camera. I'm using the camera x, y, and z coords with POINT object just like you suggested, but it just doesn't seem to work.

Here's my code, you'll see it doesn't work as expected:



What do you think? I'm pretty stumped as to why it's not working.

Btw, I'm using DarkBASIC classic trial, and I did some forum searches, and it seems other people have this same problem, but none of the solutions offered seem to work, so I'm asking here.

Any ideas?
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 15th Oct 2005 10:42
When using make object plain add an extra ,1 at the end to make a proper plain.

make object plain 1, 15, 15, 1

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 15th Oct 2005 21:08
Quote: "make object plain 1, 15, 15, 1"


The extra 1 parameter only applies to DB Pro. It will error if you use it in the trial version of DB Classic.

TDK_Man

Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 15th Oct 2005 22:26
Ah didn't see the classic. Well if Classic has the same bug DBP had before 5.9 then you can use this:

` Update object orientation
point object 1, camera position x(), camera position y(), camera position z()
yrotate object 1, wrapvalue(object angle y(1)+180)

as the plains are build backwards.

Grossman
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Russia
Posted: 16th Oct 2005 18:52
Maybe, set object rotation zyx <obj> will helps a bit ?
gbark
19
Years of Service
User Offline
Joined: 14th Oct 2005
Location: US - Virginia
Posted: 16th Oct 2005 19:31
Thanks, using ZYX rotation, and setting the X and Y rotations after the point command, I was able to get it working.



Thanks for all the help everybody.

Login to post a reply

Server time is: 2024-11-27 14:43:29
Your offset time is: 2024-11-27 14:43:29