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.

DarkBASIC Professional Discussion / Change the center of a 3D object REALLY EASILY. (dumb trick, but works)

Author
Message
Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 23rd Dec 2017 16:42
It is easy and saves a lot of coding.

Check it out.

To do the trick you just need to follow these steps:

1. Make a small object, as small as possible, and number it with the number you would use for the REAL object.
2. Make the object whose rotation center you want to change and number it whatever. Remember that the other one is the one who needs to be correctly named to be called when you need it.
3. Position the first object (the small one) in 3D space in such a way it becomes in the position where you want the new center be located inside the second object.
4. Perform CSG union first, second.
4. Delete second object.

Now, the first object is exactly equal to the second you deleted, but if you try to rotate it around, it will be turned around the new center, not the geometric one.

Just an example:

WickedX
9
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 23rd Dec 2017 17:16 Edited at: 23rd Dec 2017 17:18
That's kind of cool. But wouldn't this be simpler?

Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 7th Feb 2018 16:16
Indeed it is simpler, but I've never heard anything about being able to offset limb 0. Thought only was possible to offset limbs from 1 on.

Very cool and taught me something I did not know. Thanks.
Derek Darkly
6
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 7th Feb 2018 19:30

CSG is fun to mess with! I'm not certain if all of its potential has been tapped yet, but it's interesting to find new uses.
(I wonder if anyone has had success with a simple pre-fracturing of objects using CSG commands.)

Here is a simple arched doorway, although there may be pinholes showing in the final object:



Send your parents to noisy sprite demo hell... enter the D-Zone
Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 10th Feb 2018 03:10 Edited at: 10th Feb 2018 08:59
Well, DeI am trying to create a system to produce objects for my game - nothing much detailed, just some minimalistic but functional stuff - but I am having some problems doing so.

One of the issues I was facing (before seeing your snippet and realizing that I am an idiot) was to move the objects properly before CSG'ing them. I was using POSITION OBJECT, when it is easier - and far more comprehensible - to use MOVE OBJECT. At least now I know that doing it dthis way is easier and this part is something I don't need to worry about anymore.

About CONVERT FVF, I took a peek at some threads and learned enough to find out that, for now, I'll probably won't need that.

One of the TRUE problems with building stuff with CSG is that it is bound to the same limitation as VERTEXDATA - 65535 vertices. This limitation makes it impossible, for example, to build huge objects. I tried to use CSG to make a maze's walls, but it was quite hard since my maze was too big and exceeded easily 65535 vertex count. OK, I know that I'll need to split things up to make it work properly, it is not an issue right now, but indeed it's a limitation to take into account.

Other really terrible part is that CSG simply doesn't work with spheres, and works strangely with cones and cylinders, and doesn't work with plains at all (at least as long as I know). These limitations make it hard to build certain forms with CSG, forcing to use VERTEXDATA to make the desired forms - something that I HATE to do and I'm not very good at.

I think for now I know enough to start building stuff with CSG and using them at my games - for the same reason: save filesize and honor my tradition of using little to no external media on my games.

But I have a question, and it is nothing related to CSG, but I'll need to know that because it is something I plan to use for a simple AI for a kind of racing game:

If I assign one camera to be the "eyes" of a computer player, can I use PICK OBJECT to tell to my CPU player, for example, where it is running on (which floor tile object), or if there is someone ahead or behind it or how far it is from the walls? And if I can do it, how can I ensure that the additional cameras I'll use for the eyes of the CPU players be the lightest possible to prevent FPS from dropping due these additional screens being analysed every time?


[size=+2]Forever and one[/size]
Derek Darkly
6
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 10th Feb 2018 09:03

I'm not well versed in anything other than which McNugget sauces McDonald's has available. (I'm a Hot Mustard guy myself)

Quote: "
the flags signal what components are present in the structure for each vertex. The order of them is fixed, so there is sort of a 'full' structure that is selected from by the flags"


Maybe someone out there knows...
https://www.gamedev.net/forums/topic/486995-flexible-vertex-format/
Send your parents to noisy sprite demo hell... enter the D-Zone
Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 10th Feb 2018 09:39
I asked a question and while you were writing the answer, I figure out that YES, it is POSSIBLE to use a camera to serve as an eye and grab data for the AI to use.

This is the code with my idea working:



With these data - plus PICK DISTANCE to check how far the object is from the "eye" - I will be able to teach my CPU how to avoid them and when to shoot at someone, for example, or when to perform a turn or strafe left or right.

I don't know if this idea is really good, but it worked exactly as I was planning.

Just one question: PICK DISTANCE will tell me how far is the center of the object or it's nearest edge? I need to know that to help my system to keep a safe distance from anything.
[size=+2]Forever and one[/size]
Zep
15
Years of Service
User Offline
Joined: 31st Aug 2002
Location: From PA, USA. Currently reside in Hanoi, Vietnam
Posted: 10th Feb 2018 11:54
Quote: "With these data - plus PICK DISTANCE to check how far the object is from the "eye" - I will be able to teach my CPU how to avoid them and when to shoot at someone, for example, or when to perform a turn or strafe left or right."



You need to add a little randomization to that eye, so the enemies are not always DEAD ON to the player or able to AVOID the player.
Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 10th Feb 2018 12:47 Edited at: 10th Feb 2018 12:59
For shooting targets, indeed I'll put a modifier to determine if the enemy shall shoot or not - and the player stil'l can strafe left or right to avoid it.
I am beginning with it. In face, I am working all night long triying to teach the CPU how to evade obstacles, but I am failing miserably. I restarted the whole thing twice and no results yet - but I am working hard on it.

By the way, I have a problem - hope I can explain it properly>
I have 2 cameras - one for the game view itself and another to represent the "eye" of the CPU "pilot".

Well, the question is:

I need both cameras work with the same view settings - screen width and height. The view camera follows the object - for me to see what it is doing - and the second is the "eye", but I simply cannot find a way to hide it properly.

How can I use the "eye" camera without showing on screen what it is "seeing"?

EDIT:
Guess I solved this issue using the SET CAMERA TO IMAGE function. One less problem.
[size=+2]Forever and one[/size]
Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 10th Feb 2018 14:25
Somebody can help me with this?
The object 10 is the "player" and it tries to avoid the object 2, that is the "enemy" the AI try to identify. For some reason it is working bizarrely.

[size=+2]Forever and one[/size]

Login to post a reply

Server time is: 2018-05-22 14:49:10
Your offset time is: 2018-05-22 14:49:10