Converting voxels to MD2/MD3 and actor pitch?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
DoukDouk
Posts: 39
Joined: Sat Jan 31, 2015 1:53 pm

Converting voxels to MD2/MD3 and actor pitch?

Post by DoukDouk »

I'm trying to make voxel projectiles that change pitch according to their momentum and I'm noticing that they can't rotate along the Y axis like models can, understandably enough.

There are a ton of resources out there for converting polygonal models to voxels, but I cannot find anything that can convert a voxel to a polygonal model.

From my understanding of the GZDoom renderer, it generates voxel models as MD3 on the fly, if I'm correct.

Would it be possible to convert these voxels to MD3s off the bat so I would be able to import them as such and make use of the +PITCHFROMMOMENTUM flag? Or do I have the process wrong and there's something inhibiting the voxels from being readily converted to more accessible model types?
Last edited by DoukDouk on Fri Mar 24, 2017 7:05 am, edited 1 time in total.
User avatar
Ozymandias81
Posts: 2068
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars
Contact:

Re: Converting voxels to MD2/MD3?

Post by Ozymandias81 »

You can import a voxel as an .obj file with MagicaVoxel, then open it with Blender, MilkShape or Misfit3d (the one I use) and save it as .md3 (avoid .md2, too old format).
User avatar
DoukDouk
Posts: 39
Joined: Sat Jan 31, 2015 1:53 pm

Re: Converting voxels to MD2/MD3?

Post by DoukDouk »

Works perfectly. Thank you!

Now I'm stuck with a new problem though.

I wanted to make an arrow projectile that would change its pitch according to gravity, and it would stick into a wall and stay in that pitch. At first I used PITCHFROMMOMENTUM for the modeldefs, but upon hitting the ground or wall or any surface, the actor's pitch never actually changed, just the model's, so the model would go back to 0 pitch again.

I've been racking my brain trying to figure out a proper calculation for changing the actor's pitch through its momentum, much like the PITCHFROMMOMENTUM flag, but for actors. It might be easier in ZScript, since I'm still using DECORATE. Until I can come up with anything, any advice would be greatly appreciated. If I can find a solution, I'll try to post it here.
User avatar
kodi
 
 
Posts: 1361
Joined: Mon May 06, 2013 8:02 am

Re: Converting voxels to MD2/MD3 and actor pitch?

Post by kodi »

You can put USEACTORPITCH in modeldef and have the actor call A_FaceMovementDirection in the first spawn frame with Nodelay.

For reference, the pitch calculation you're after is atan2(vel.z,sqrt((vel.x*vel.x) + (vel.y*vel.y))), but the previously mentioned function should handle that for you :)
User avatar
DoukDouk
Posts: 39
Joined: Sat Jan 31, 2015 1:53 pm

Re: Converting voxels to MD2/MD3 and actor pitch?

Post by DoukDouk »

I tried using A_FaceMovementDirection, but it turned out that it was facing the correct angle, but the pitch was totally off. Crappy!

But then I realized if I inverted the pitch, and if I put A_SetPitch(pitch*-1) in the same state, then it works perfectly!

Thank you all very much! It works excellently now.

Here's the code for archival reasons, just in case anyone wants to do the same thing:

MODELDEF

Code: Select all

Model SteelArrowFlight      // Name of actor in DECORATE
{
   Path "Models" // Path to model in PK3
   SKIN 0 "arrow.png" // Model index, model file
   MODEL 0 "arrow.md3" // Model index, texture (can be in any format supported by GZDoom)
   Scale 1.0 1.0 -1.0
   USEACTORPITCH
   FrameIndex ARRO A 0 0 // The sprite lump, sprite frame, model index, frame number
}
}
DECORATE

Code: Select all

ACTOR SteelArrowFlight
{ 
   Radius 3 
   Height 2 
   Speed 20
   Scale .5
   Damage (random(15,30))
   Gravity 0.15
   PROJECTILE 
   -NOGRAVITY
   +WINDTHRUST
   +NOEXTREMEDEATH
   +BLOODSPLATTER
   States 
   { 
   Spawn: 
		ARRO A 0 NoDelay
		{
			A_FaceMovementDirection;
			A_SetPitch(pitch*-1);
		}
		ARRO A 1 A_AlertMonsters(64)
		Loop
   Crash:
   Death: 
		ARRW A 0 A_NoGravity
		ARRO A 500
		Stop 
   Xdeath:
		ARRW A 0 A_PlaySound("arrow/hit")
		Stop
   } 
} 
Locked

Return to “Editing (Archive)”