Author Topic: decals  (Read 11736 times)

0 Members and 1 Guest are viewing this topic.

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
ok I have been toiling on this thing for quite a while now, and I have reached a new level
this ismy old simple decal code, it's fast and seems very very stable however has several major drawbacks
but now here is my
my new horindusly complex and inefishent decal code, that takes about a second to cut out a single decal from the hull, it is almost garunteed to crash within a few seconds of you'r playing with it, and it doesn't have any code for calculateing uv coordanants, and it generaly doesn't work corectly
this is the source files, be carefull, for they be things of evil :shaking:
I need some math people to help me by geting some sort of polygon-polygon intersection code, and some good culling code that would be able to tell wich faces are going to be defanantly used by the decal

now can I please get more atention than my last topic on the subject got :doubt:
I'm gona be prety mad if I come back here in nine hours and nobody's posted :rolleyes:
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Fry_Day

  • 28
Bobbaou, you could probably steal the sheild-ANI drawing code, except that you map stuff onto the model mesh instead of the shield mesh, and don't draw an ANI.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
the sheild code doesn't realy make decals it's more like slaping the UV coord closest to right to the polys of the mesh, wich is fine for energy effects, but if you'r going for a scorch mark you need things to be more acurate
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Zarax

  • 210
Bobbau, if you need help or testing, just contact the beta testers on the tester list, you can find me at [email protected]
The Best is Yet to Come

 

Offline Zarax

  • 210
Assert: instance->frame_num >= 0 && instance->frame_num < instance->parent->total_frames
File: D:\Games\projects\freespace2_public\fs2_open\code\Anim\AnimPlay.cpp
Line: 578

Call stack:
------------------------------------------------------------------
    anim_render_all()    cmd_brief_do_frame()    game_do_state()    gameseq_process_events()    WinMainSub()    WinMain()    WinMainCRTStartup()    kernel32.dll 77e5eb69()
------------------------------------------------------------------

I'm not using modded tables and this appears every time...
The Best is Yet to Come

 

Offline Zarax

  • 210
Bobbau, what does your code do exactly?
I can't find anything really new, except table intolerance...
The Best is Yet to Come

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
well this isn't any ware near the testing stage, it doesn't do what it's suposed to do right almost ever, most of the time it'll just crash,
it is an extreemly early version of decal code, use a fighter beam to hit something and i't leave a little mark on the ship, or that's the idea anyway, more than likely it'll ether leave a bit of jumbled geometry or just out right crash
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
I've made an update to the exe and the sorce files, I seem to have made it a tiny bit more stable, to the point that I should be able to start fixing the actual unworking code (so it makes the right data for the decals), I havn't actualy crashed with this build, but that doesn't mean it would be a herculean effort to do so

I reiterate my request for some math to find if a line (defined by two points) will intersect a poly (defined by three or four coplaner points), maybe I should ask the general forum were CP would be likely to see it.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline DTP

  • ImPortant Coder
  • 28
    • http://www.c4-group.dk
Quote
Originally posted by Bobboau
I've made an update to the exe and the sorce files, I seem to have made it a tiny bit more stable, to the point that I should be able to start fixing the actual unworking code (so it makes the right data for the decals), I havn't actualy crashed with this build, but that doesn't mean it would be a herculean effort to do so

I reiterate my request for some math to find if a line (defined by two points) will intersect a poly (defined by three or four coplaner points), maybe I should ask the general forum were CP would be likely to see it.


you mean something in the order of this.
by thought of how i would design it to check.

fake math (TEXT)

on a 4 coplanar point polygon

x1,x2,x3,x4 & y1,y2,y3,y4 and z1,z2,z3,z4

and our two point line in 3 diemensonal world

px1,px2 & py1, py2 & pz1, pz2

create a boundrie box of the 4 coplanar point polygon.

determine if our two point line will ever touch this box, i will spare you the hows and dont of how this is done, i presume you have basic knowledge of mathimathical equations.

but simply test our two point line´s funtion of fx()=ax+by+c against the coordinates of the bounderie boxes edges.

if it does not ever intersect meaning your result will be NULL
then skip the next and dont check for more.(this will increase performance because the next cheking is system time exspensive.

if so then enter precise cheking function of exactly where it touches our polygon.

where it should check the edges of the polygon, that are converted to functions like fx()=ax+by+c and are set to be tested against each other.

should you at any time get a NULL result because it can easely enter the boundery box, but still miss the polygon, then skip further checking to save performance.

finally you will get the exact coordinate of where your two point line will intersect with the polygon.

if you are not sure on how to do these mathimatical equations, then grab a math book becuase this is not easely explained.

it has been a long long time since i did this kind of math, when i was attending business college. and man am i rusty.

but if you like, i could try and write/test some code for it.
VBB member; reg aug 1999; total posts 600.
War is a lion, on whos back you fall, never to get up.
Think big. Invade Space.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
OH NO!  IT'S CALCULUS III! :shaking: :shaking: :shaking:

Even though I like math, I found that to be one of the most horrid courses I've ever taken.  If CP enjoys it, well then... :shaking:

I found something on the Internet that might help.  You need to define the plane as a point with a normal vector, and the line as simply a point with a vector.
http://mathforum.org/library/drmath/view/55094.html

The final equation is tricky, but not really hard:
Code: [Select]

            (A-P)*[b]N[/b]
    X = P + ------- [b]V[/b]
              [b]V[/b]*[b]N[/b]

where A is the point on the plane, P is the point on the line, N is the normal vector to the plane, V is the line vector, and X is the point of intersection.  The asterisk stands for the dot product.  If the line does not intersect, the V*N dot product will be zero (and you'll get a divide-by-zero error).
« Last Edit: November 24, 2002, 11:11:04 pm by 561 »

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Quote
Originally posted by Goober5000
(and you'll get a divide-by-zero error).
Which would be a very bad thing.
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline mikhael

  • Back to skool
  • 211
  • Fnord!
    • http://www.google.com/search?q=404error.com
Quote
Originally posted by Sesquipedalian
Which would be a very bad thing.


Nah. div-by-zero is pretty smartly handled by most modern systems, Sesq. Its just a matter of checking your results for (usually) 'nan'.
[I am not really here. This post is entirely a figment of your imagination.]

 

Offline DTP

  • ImPortant Coder
  • 28
    • http://www.c4-group.dk
Quote
Originally posted by mikhael


Nah. div-by-zero is pretty smartly handled by most modern systems, Sesq. Its just a matter of checking your results for (usually) 'nan'.


oh we did´nt know that:rolleyes:

:D
VBB member; reg aug 1999; total posts 600.
War is a lion, on whos back you fall, never to get up.
Think big. Invade Space.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Or you could evaluate the dot-product before you evaluate the rest of the formula.  If the dot product is 0, you have your solution right there.  If it's not, you can still run the formula but you've saved yourself a bit of work by computing the denominator ahead of time.

Not handling the divide-by-zero error would leave a NASTY bug that would show up only once in a blue moon and be impossible to track down. :shaking: Best catch it ahead of time.

Incidentally, I was reading up on the amount of bugs in programs nowadays, and it seems that the programmer's ethic has changed quite a bit since computers first came out.  People used to scrutinize their code for bugs before compiling, since compilation was a huge production (what with the punch cards and everything).  The result was well-written, extremely stable code.  Nowadays people tend to just throw something together and ram it through the compiler until it works, leaving a lot of bugs all over the place that have to be tracked down later.
« Last Edit: November 24, 2002, 11:19:13 pm by 561 »

 

Offline Sesquipedalian

  • Atankharz'ythi
  • 211
Quote
Originally posted by DTP


oh we did´nt know that:rolleyes:

:D
I didn't.  :)
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

The Scroll of Atankharzim | FS2 syntax highlighting

 

Offline mikhael

  • Back to skool
  • 211
  • Fnord!
    • http://www.google.com/search?q=404error.com
Quote
Originally posted by Goober5000
Or you could evaluate the dot-product before you evaluate the rest of the formula.  If the dot product is 0, you have your solution right there.  If it's not, you can still run the formula but you've saved yourself a bit of work by computing the denominator ahead of time.

This is, of course, much better than checking for NaNs. ;)

When I do OpenGL stuff, I'm pretty rabid about checking denominators that might just turn out to be zero (and usually never will). Of course, i'm anal about fiddly little things most of the time anyway. Its just too easy to make big dumb mistakes, and too hard to find all the little bitty ones.

Quote

Incidentally, I was reading up on the amount of bugs in programs nowadays, and it seems that the programmer's ethic has changed quite a bit since computers first came out.  People used to scrutinize their code for bugs before compiling, since compilation was a huge production (what with the punch cards and everything).  The result was well-written, extremely stable code.  Nowadays people tend to just throw something together and ram it through the compiler until it works, leaving a lot of bugs all over the place that have to be tracked down later.

That's where most of us start these days, because of the speed of modern processors and compilers. After you do it for a while though, you start to get tired of looking at a billion syntax errors, followed by a billion linker errors, and you start checking your code  a little more carefully.
« Last Edit: November 25, 2002, 02:14:15 am by 440 »
[I am not really here. This post is entirely a figment of your imagination.]

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
ok what I realy need it something that will tell if a point is with in the decal cube, remember that the decal cube has it's on relitive position and orientation, currently I have to subtract it's position fromt a vert then unrotate that vert then see it it's withing the box, the unrotate function is what seems to be bringing the code to a screeching hault,
so if I give the "is_point_in_cube" function a position (of the cube), size (of the cube in terms of x,y,z, or just  a radius), and an orientation matrix (for the cube), as well as a point to test, it will return a 1 for yes (the point is in the box) and a 0 for no (the point is not in the box), and do it quickly and acurately

the system I have set up does diferent things based on how many of a (three point) polly's points are in the cube and how many of the cube's line segments intersect the polly

and I have been running under the assumtion that (with a cube with equily sized four point faces) the cube intersection closest to a poly intersection will be the next point on a poly,
I'm not sure if this was a correct assumption
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
:wtf: Spelling and grammar are A-1 Supar...

Wouldn't this be easier to do with a sphere?  Just check the distance between the point and the sphere's center.  If the distance <= the sphere's radius, the point is inside the sphere.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
the cube is not along the same oientation as the model, otherwise yes it would be quite simple
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Just realized that, which is why I edited it out. :o :p

How about the sphere, though?