Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
This AI stuff is SCARY!!!
#1
So, I need to calculate surface normals which are stored compressed and need to some math I don't get yet so i gave Googles AI  my code for all types and everything for loading and drawing the model and asked it to write me some code to do the task...3 seconds and poof! I got this...its VB but that's close enough for me to convert easily! Scary thing is, its coded very much like i would do it....


Code: (Select All)

vb
' ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
' // Function to decode an MD3 compressed normal integer into a 3D vector
' // Input: compressedNormal_Integer - The integer from GDK_GL_MD3_Vertex.Normal
' // Output: GDK_GL_MD3_Vector_3 representing the decoded normal vector
' // (Note: This is a common decoding method, but may vary slightly based on specific MD3 implementations)
' // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
FUNCTION DecodeMD3Normal (compressedNormal_Integer AS INTEGER) AS GDK_GL_MD3_Vector_3
  DIM NormalVector AS GDK_GL_MD3_Vector_3

  ' // The integer is typically broken into two 8-bit values (one for longitude, one for latitude)
  ' // Shift bits to get the individual angle values
  DIM lat AS INTEGER ' // Latitude angle index
  DIM lon AS INTEGER ' // Longitude angle index

  lat = (compressedNormal_Integer >> 8) AND &HFF ' // Extract the upper 8 bits (latitude)
  lon = compressedNormal_Integer AND &HFF        ' // Extract the lower 8 bits (longitude)

  ' // Convert angle indices to radians. MD3 uses 255 steps for 360 degrees (or 2*PI radians)
  DIM lat_rad AS SINGLE
  DIM lon_rad AS SINGLE

  lat_rad = lat * (2 * 3.14159265 / 255)
  lon_rad = lon * (2 * 3.14159265 / 255)

  ' // Calculate X, Y, Z components from spherical coordinates
  ' // Standard conversion:
  ' // X = cos(latitude) * sin(longitude)
  ' // Y = sin(latitude)
  ' // Z = cos(latitude) * cos(longitude)
  ' // However, Q3/MD3 often uses a different convention (e.g., Y and Z might be swapped or negated)
  ' // based on their coordinate system. You might need to adjust this.
  ' // For Quake 3: Z is usually up, but the models are often exported with Y up.
  ' // This conversion assumes Y is 'up' and adjusts for potential Q3 peculiarities.

  DIM CosLat AS SINGLE = COS(lat_rad)
  DIM SinLat AS SINGLE = SIN(lat_rad)
  DIM CosLon AS SINGLE = COS(lon_rad)
  DIM SinLon AS SINGLE = SIN(lon_rad)

  NormalVector.X = CosLat * SinLon
  NormalVector.Y = SinLat
  NormalVector.Z = CosLat * CosLon

  ' // You might need to swap Y and Z, or negate one, depending on your desired coordinate system.
  ' // For example, if you want Z to be "up":
  ' // DIM TmpY AS SINGLE = NormalVector.Y
  ' // NormalVector.Y = NormalVector.Z
  ' // NormalVector.Z = TmpY
  ' // Or possibly: NormalVector.Y = -NormalVector.Y

  FUNCTION = NormalVector
END FUNCTION

' ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
' // Function to normalize a 3D vector (make its length 1)
' // Input: vec - The vector to normalize
' // Output: The normalized vector
' // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
FUNCTION NormalizeVector (vec AS GDK_GL_MD3_Vector_3) AS GDK_GL_MD3_Vector_3
  DIM ResultVec AS GDK_GL_MD3_Vector_3
  DIM Length AS SINGLE = SQR((vec.X * vec.X) + (vec.Y * vec.Y) + (vec.Z * vec.Z))

  IF Length > 0 THEN
    ResultVec.X = vec.X / Length
    ResultVec.Y = vec.Y / Length
    ResultVec.Z = vec.Z / Length
  ELSE
    ' // Handle zero-length vector (e.g., return (0,0,0) or throw an error)
    ResultVec.X = 0
    ResultVec.Y = 0
    ResultVec.Z = 0
  END IF

  FUNCTION = ResultVec
END FUNCTION

' ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
' // Function to perform a vector subtraction (V2 - V1)
' // Input: V1, V2 - The two vectors
' // Output: The resulting vector (V2 - V1)
' // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
FUNCTION VectorSubtract (V1 AS GDK_GL_MD3_Vector_3, V2 AS GDK_GL_MD3_Vector_3) AS GDK_GL_MD3_Vector_3
  DIM ResultVec AS GDK_GL_MD3_Vector_3
  ResultVec.X = V2.X - V1.X
  ResultVec.Y = V2.Y - V1.Y
  ResultVec.Z = V2.Z - V1.Z
  FUNCTION = ResultVec
END FUNCTION

' ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
' // Function to perform a vector cross product (U x V)
' // Input: U, V - The two vectors
' // Output: The resulting perpendicular vector
' // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
FUNCTION VectorCrossProduct (U AS GDK_GL_MD3_Vector_3, V AS GDK_GL_MD3_Vector_3) AS GDK_GL_MD3_Vector_3
  DIM ResultVec AS GDK_GL_MD3_Vector_3
  ResultVec.X = (U.Y * V.Z) - (U.Z * V.Y)
  ResultVec.Y = (U.Z * V.X) - (U.X * V.Z)
  ResultVec.Z = (U.X * V.Y) - (U.Y * V.X)
  FUNCTION = ResultVec
END FUNCTION

' ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
' // Function to calculate the face normal of a triangle
' // Input: P1, P2, P3 - The three vertices of the triangle (in their float coordinates)
' // Output: The normalized face normal vector
' // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
FUNCTION CalculateFaceNormal (P1 AS GDK_GL_MD3_Vector_3, P2 AS GDK_GL_MD3_Vector_3, P3 AS GDK_GL_MD3_Vector_3) AS GDK_GL_MD3_Vector_3
  DIM Edge1 AS GDK_GL_MD3_Vector_3
  DIM Edge2 AS GDK_GL_MD3_Vector_3
  DIM NormalVector AS GDK_GL_MD3_Vector_3

  ' // Calculate two edges of the triangle
  Edge1 = VectorSubtract(P1, P2) ' // P2 - P1
  Edge2 = VectorSubtract(P1, P3) ' // P3 - P1

  ' // Calculate the cross product to get the normal
  NormalVector = VectorCrossProduct(Edge1, Edge2)

  ' // Normalize the normal vector (make its length 1)
  NormalVector = NormalizeVector(NormalVector)

  FUNCTION = NormalVector
END FUNCTION
Use code with caution.

Integrating into your Loading Logic
Integrate this into your loading loop. You'll need to allocate memory for the triangle data and load it as well. Assume that you've finished allocating Model.Vert_Data and Model.Tri_Data and loaded the corresponding arrays.
vb
' ( ... previous code ... )

  Model.Vert_Data = _MEMNEW((LEN(GDK_GL_MD3_Vertex)) * (Total_Verts& * TmpMD3.Num_Frames))
  ' // You'll need to actually read the vertex data into a temporary array first, like MD3_Vertices
  DIM MD3_Vertices((Total_Verts& * TmpMD3.Num_Frames) - 1) AS GDK_GL_MD3_Vertex
  ' // ... code to read all vertices from file into MD3_Vertices ...
  ' // This involves calculating offsets based on TmpMD3.Offset_Surfaces, MD3_Surface(j&).Offset_Vertices
  ' // and looping through frames and surfaces.
  ' // For simplicity in this example, let's assume MD3_Vertices() is populated with all vertices.
  _MEMPUT Model.Vert_Data, Model.Vert_Data.OFFSET, MD3_Vertices()

  Model.Tri_Data = _MEMNEW(LEN(GDK_GL_MD3_Triangle) * Total_Tris&)
  DIM MD3_Triangles(Total_Tris& - 1) AS GDK_GL_MD3_Triangle
  ' // ... code to read all triangles from file into MD3_Triangles ...
  ' // This involves calculating offsets based on TmpMD3.Offset_Surfaces, MD3_Surface(j&).Offset_Triangles
  ' // and looping through surfaces.
  ' // For simplicity in this example, let's assume MD3_Triangles() is populated with all triangles.
  _MEMPUT Model.Tri_Data, Model.Tri_Data.OFFSET, MD3_Triangles()

  ' // Allocate memory to store the calculated triangle normals (if needed separately)
  ' // Or you might integrate this into a more general data structure for rendering.
  DIM CalculatedFaceNormals(Total_Tris& - 1) AS GDK_GL_MD3_Vector_3
  DIM ProcessedVertices(Total_Verts& * TmpMD3.Num_Frames - 1) AS GDK_GL_MD3_Vector_3 ' // To store decoded vertices

  ' // First pass: Decode compressed vertex positions and normals
  FOR i& = 0 TO (Total_Verts& * TmpMD3.Num_Frames) - 1
    ' // MD3 vertices are typically scaled and offset.
    ' // You'll need to reverse this process to get the actual float positions.
    ' // Assuming a common scale factor (e.g., 1/64) and potentially an offset.
    ' // For simplicity here, assume these are directly convertible or already converted.
    ProcessedVertices(i&).X = MD3_Vertices(i&).X / 64.0 ' // Example scaling
    ProcessedVertices(i&).Y = MD3_Vertices(i&).Y / 64.0
    ProcessedVertices(i&).Z = MD3_Vertices(i&).Z / 64.0
    ' // You'd also decode the normal here if needed for direct vertex normal usage
    ' // ProcessedVerticesNormals(i&) = DecodeMD3Normal(MD3_Vertices(i&).Normal)
  NEXT

  ' // Second pass: Calculate face normals for each triangle
  FOR i& = 0 TO Total_Tris& - 1
    DIM Tri AS GDK_GL_MD3_Triangle = MD3_Triangles(i&)
    DIM P1_Index AS LONG = Tri.X
    DIM P2_Index AS LONG = Tri.Y
    DIM P3_Index AS LONG = Tri.Z

    DIM P1_Pos AS GDK_GL_MD3_Vector_3 = ProcessedVertices(P1_Index)
    DIM P2_Pos AS GDK_GL_MD3_Vector_3 = ProcessedVertices(P2_Index)
    DIM P3_Pos AS GDK_GL_MD3_Vector_3 = ProcessedVertices(P3_Index)

    CalculatedFaceNormals(i&) = CalculateFaceNormal(P1_Pos, P2_Pos, P3_Pos)
  NEXT

  ' // ( ... continue with any further processing, e.g., storing CalculatedFaceNormals ... )

  CLOSE #FFile&

END SUB
Use code with caution.



Its a brave new world folks!

Unseen
Reply
#2
I'm just waiting for the day AI becomes sentient, so I can sell my Amazon stock. I figure shortly after that day comes, sex robots will begin bitching at men, and the Amazon return policy will overwhelm the company's profit margin.

Pete Big Grin
Reply
#3
Sentient or not, its amazing!

I've spent a few hours asking questions, providing base code, etc...

From this interaction..it now knows how I want to code, how it should use _MEM where arrays are required inside types and has given me a fresh perspective on what is actually possible as time is no longer a constraint...

Basically, if you want to learn to code, dont use it....but if you already know how then it's a TOOL that expands your abilities a million fold!! I'll likely be unseen again for a few months but when I return, I'll be packing two six shooters!

Happy coding folks!

Unseen
Reply
#4
My QB64 trained agent on NotebookLM can provide perfect code in a one shot prompt sometimes. It's trained on 300 (the maximum) documents from the help pages.
The noticing will continue
Reply
#5
The irony is the first jobs to be replaced by AI will likely be many coders. Goodby World! 

An update is coming. Resistance if futile!

Oh, and most teachers could be replaced by trained squirrels... the rest by untrained ones. Big Grin (This joke excludes Terry Richie, sorry squirrels.)

Pete
Reply
#6
Everyone says AI will replace jobs, but as AI grows, it will eventually cannibalize itself. The internet is flooded with AI-generated images, text, code, etc. All of which are inferior to human things. As the internet becomes more inundated with AI content, the AI will be eventually trained on other AI content (if it hasn't already), making it even worse. Even ChatGPT's newest model (5) will confidently give the wrong answer to a simple algebra problem with only 1 variable. Same with Gemini's new 2.5 Pro thinking model. There are times when I use Gemini or ChatGPT in my job to help me write or simplify a complex query, but it often takes so much effort to get the right output. If AI had not been allowed to be used by the public at such a large scale, I could agree. But there is simply too much AI content. AI is pretty much guaranteed to be cannibalized at this point. Not only that, but most AI is trained primarily on Reddit. Not exactly known for their intellectual prowess. Just stubbornness and liberal mindsets. Redditors aren't taking over the world. They can barely move out of their parents' basements or take a shower.
The noticing will continue
Reply
#7
Hi Spriggy .. are you suggesting that AI will never reach AGI ( artificial general intelligence, not generative intelligence) or ASI?
Reply
#8
Yep The Singularity is SCARY! and the way it's coming together it is likely something BIG will happen too soon!

I was watching a video the other day and until someone made a comment about the repeated hand gestures by the presenter, I had no idea it was AI PHOTOSHOPPED! the lips were moving in sync with words spoken.

The narrating voices are getting pretty good but they read "read" as reed not red or there is a wrong pause. Kinda fun to watch for those hints Smile
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#9
I am suggesting that AI can never become a superpower (AGI or ASI or whatever other buzzword you want to use) because we've allowed it to be used by everyone with no limit. AI itself will not be anything special. AI as a tool can be used for propaganda, bots, etc... and those can be used to cause issues. AI content is too prevalent. I've seen articles online proving that AI has begun to Ouroboros itself already.

I don't claim to understand the workings of LLMs or image/video generators and I probably never will understand them. I doubt even the guys who invented them fully understand how they work. But I do know that they're only as good as the data provided to them. And so far, LLMs are getting worse. Sure, they can add a "reasoning" or "thinking" model to their LLM, but it doesn't fix the data they were trained on. And you know they're not personally curating the data that goes in. There simply isn't enough manpower or man hours to sift through all that. So, you get something that's "good enough" to get premium subscriptions. But then you put it through its paces and find out it wasn't worth the money because it can't handle simple tasks because it is missing data, trained on bad data, or biased. AI is a good tool. And that's all it is. That's all it ever will be. A tool. It will be used for propaganda. It will be used for government operations. It's a shiny toy for the general public to worship and admire while more pressing matters are at hand. It's the UFO spotted by the pilots so the media talks about that for weeks and keeps us distracted. It's bread and circus. It's a feather on a stick being dangled in front of a cat's face by the rats. Take away the feather and the cats might focus on the rats. And the rats can't have that.

It's done a great job at fooling and controlling the "boomer" generation. I see it daily. A boomer is tricked by an AI generated image or video. Is this the fault of the AI? Was this made by the AI on its own? No, it was made by someone who probably has the last name Patel and wanted to get quick money online by only typing in a sentence or two into ChatGPT and then posting the result. It works. All the time. And even when the boomer is informed that the thing they are viewing is fake, instead of being upset that they were tricked, they marvel at the technology and seek out more content made this way, incentivizing more scam content to be created.

AI should be shut down. Not because it will become some intelligent entity that will cause Skynet, but because we as humans have chosen to worship, misuse, and be distracted by it.
The noticing will continue
Reply
#10
A closer look at your perspective
You raise some interesting points regarding the potential pitfalls and limitations of Artificial Intelligence (AI). Let's delve deeper into some of the key concerns you've highlighted:

The "AI Ouroboros" and data degradation
You're right to be concerned about the quality of data used to train AI models. As AI-generated content becomes more prevalent, there's a risk of what you describe as the "AI Ouroboros", where AI models are increasingly trained on data that was itself generated by other AIs. This can lead to a degradation in the quality, accuracy, and diversity of the data, potentially creating biased or even nonsensical outputs over time.

AI as a tool for propaganda and misinformation
Your point about AI's potential use in propaganda, bots, and the spread of misinformation is a serious one. AI can be used to generate realistic-looking fake images and videos, manipulate public opinion, and create echo chambers online. This poses a significant challenge to critical thinking and media literacy, particularly among those who may be less familiar with AI's capabilities, as you mentioned.

The question of AGI/ASI and the hype surrounding AI
Many share the skepticism about AGI (Artificial General Intelligence) and ASI (Artificial Superintelligence). While some researchers believe these are imminent or even achievable within a lifetime, others argue that the architectural understanding and data necessary to achieve them is currently lacking. The hype surrounding AI, often fueled by sensational media coverage, can contribute to unrealistic expectations and distract from the actual capabilities and limitations of current AI technology.

AI as a tool: advantages and ethical concerns
AI is accurately described as a powerful tool that can be used for automation, prediction, personalization, and data analysis. However, as with any powerful tool, its benefits are accompanied by ethical considerations and potential for misuse. Conversations around responsible AI development, ethical guidelines, and ensuring human oversight are increasingly important, according to the AI Alignment Forum.

The importance of critical thinking
The observations about the need for critical thinking and media literacy in the age of AI are crucial. Learning to discern authentic content from AI-generated content and being skeptical of information encountered online are vital skills for navigating the increasingly complex digital landscape.

In conclusion
The assessment of AI highlights critical concerns that need to be addressed as this technology continues to evolve. While AI offers immense potential for progress and innovation, it's essential to approach its development and implementation with a focus on ethical considerations, responsible use, and fostering critical thinking among individuals.

LOL! ELIZA
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)