camera (.cam) files - how to generate/change

Talk about Severance Blade of Darkness modifications and maps here. No tips or tech support questions please, use the forum above. Note that the game is rated 18 so some content may be unsuitable for younger readers.

Moderators: Ade, prospero

User avatar
cieply
Dragon
Posts: 327
Joined: Wed Jun 26, 2013 3:43 pm

camera (.cam) files - how to generate/change

Postby cieply » Mon Sep 29, 2014 5:23 pm

hey,
how to generate or change camera files?

by default it starts from Knight and can go left to Barbarian->Amazon->Dwarf or other way around to the right

what I try to do is to change the path that camera goes in Casa map - more specifically to go Knight->Barbarian->Dwarf->Amazon
a way from barbarian to dwarf would be through building behind barbarian so it needs to create one new path for camera

any ideas how to do it?
l'aria fresca,
vino puro, ...

User avatar
prospero
Ancient Dragon
Posts: 1725
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Re: camera (.cam) files - how to generate/change

Postby prospero » Tue Sep 30, 2014 3:04 am

I've done .cam files. Not easy. It's rather like doing animations for characters but you animate the camera in Max. But you need a wireframe model of the actual map as reference. You can do this by running the map and entering Bladex.ExportWorld() in the console. This will save a WhateverMap.mbw file. Then you import this into max (must b v2.5 with BOD plugins installed). You create a camera in max and use the animation tools to create nodes along a path. Sorry..... bit hazy on the details as the only time I did it was on an arena map to play online. Long time since I did that. :( But it is possible. A max tutorial book will tell you more.

You can do the same using code. Not quite as versatile as you can't invert the camera. A you have to write down the camera position and target position for each node. For some strange reason if you detach the camera and use the onscreen de-bugging readouts you get a true reading. If you attempt to print them with a keystorke - like

cx,cy,cz = cam.Position
tx,ty,tz = cam.TPos
print cx,cy,cz
print tx,ty,tz


It prints where the camera was at the point of detachment, not where it actually is. So doing cutscenes can be a long-winded process. :?

User avatar
cieply
Dragon
Posts: 327
Joined: Wed Jun 26, 2013 3:43 pm

Re: camera (.cam) files - how to generate/change

Postby cieply » Tue Sep 30, 2014 12:09 pm

ad.1. about doing it in max-2.5
I understand what you say but it doesn't mean I can do it...
seems to be loooooooot of learning before lot of work

well, long time ago I tried to make quake maps in quark, which IMO is easy and it was beyond my capabilities, so I decide it's not an option

ad.2. about using code - this looks way easier to me
> you have to write down the camera position and target position for each node

like this?:
print cx,cy,cz
print tx,ty,tz


so how the cam file is organised? it's binary file, that's for sure, is it just cx,cy,cz,tx,ty,tz ?
and what type are these values? float?
would it be 24B (6*4B) record? or it is something more there - because I just looked at one of them and it looks like they are more 32B aligned which would mean there are two additional floats in single record

ed: and as I just noticed, is there any orientation at all?
l'aria fresca,
vino puro, ...

User avatar
cieply
Dragon
Posts: 327
Joined: Wed Jun 26, 2013 3:43 pm

.cam file investigation

Postby cieply » Tue Sep 30, 2014 4:35 pm

I did little .cam file investigation in hex viewer taking one of $BoD/Maps/Casa/ .cam files under examination
that's the first 8 bytes:
2C 01 00 00 00 00 40 40

because file is 9640 B long and 0x0000012C = 300 it looks like first 4 bytes are integer containing number of records (9640/300=32.133)
and 0x 00004040 is unknown at this moment but because in files of different length it is the same - probably can be ignored, just kept as it is

unfortunately 300*32=9600 which means 32 bytes left somewhere or for some reason this value means number_of_records-1
so this can be called sorted

the idea I have is to record camera position every 0.2 or so second while walking with dwarf from Barbarian to Dwarf positions and record positions to file which should become .cam file
but I still don't know how they are organised so I can't start to record them
l'aria fresca,
vino puro, ...

User avatar
prospero
Ancient Dragon
Posts: 1725
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Re: camera (.cam) files - how to generate/change

Postby prospero » Thu Oct 02, 2014 4:20 am

This is a typical cut scene function that uses the Abrecam.py module....

Code: Select all

def IntroCam(): AbreCam.ResetNode() AbreCam.AddNode ((-223624,-2843,748000),(-216522,-8253,743509), 0) AbreCam.AddNode ((-223624,-2843,745000),(-214050,-2488,744970), 11) AbreCam.AddNode ((-214334,-1865,755425),(-206511,-353,761468), 9) AbreCam.AddNode ((-208000,-250,772189),(-198390,344,774855),9) AbreCam.AddNode ((-193389,-1916,781776),(-190268,748,772656),7) AbreCam.AddNode ((-183000,-990,768211),(-187800,1415,759778),6) AbreCam.LastTime=0 AbreCam.AbreCam()
The pairs of coordinates are the camera position and camera target position. The last argumnet is the time it takes to go from one view to the next.
So when the function is called the camera will go from the Player to the first view instantly - and then though all the other views and back to the Player view at the end.

User avatar
cieply
Dragon
Posts: 327
Joined: Wed Jun 26, 2013 3:43 pm

Re: camera (.cam) files - how to generate/change

Postby cieply » Fri Oct 03, 2014 10:10 am

so, if I understand it correctly AbreCam.AbreCam() will run immediately camera along just defined nodes?


how it corresponds with .cam files so I could use it in Casa map? Or I have to reprogram whole Maps/Casa/selec.py?
l'aria fresca,
vino puro, ...

User avatar
prospero
Ancient Dragon
Posts: 1725
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Re: camera (.cam) files - how to generate/change

Postby prospero » Fri Oct 03, 2014 7:27 pm

Are you sure it's worth all the work? :) It's not just a matter of defining new camera paths but implementing then into the code.

User avatar
cieply
Dragon
Posts: 327
Joined: Wed Jun 26, 2013 3:43 pm

Re: camera (.cam) files - how to generate/change

Postby cieply » Sat Oct 04, 2014 12:02 pm

It's not just a matter of defining new camera paths (...)
I think I can get cam.Position and cam.TPos easily just by walking along the path and "recording" it every fraction of a second
(...)but implementing then into the code.
I thought it's already done in Maps/Casa/selec.py


I still don't know how to translate (-223624,-2843,748000),(-216522,-8253,743509), 0.1 into those 32B record in .cam file
l'aria fresca,
vino puro, ...

User avatar
prospero
Ancient Dragon
Posts: 1725
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Re: camera (.cam) files - how to generate/change

Postby prospero » Sun Oct 05, 2014 2:20 am

How are you going to record it?

You are on your own with hex editing. :oops: :roll: :|

User avatar
cieply
Dragon
Posts: 327
Joined: Wed Jun 26, 2013 3:43 pm

Re: camera (.cam) files - how to generate/change

Postby cieply » Sun Oct 05, 2014 10:13 am

How are you going to record it?
for example like that: (note that formatting is free, text here but can be binary and can be done as required)

Code: Select all

## camera def camera_pos_print(): cam = Bladex.GetEntity("Camera") cx,cy,cz = cam.Position tx,ty,tz = cam.TPos print "cam.Position=",cx,cy,cz print "cam.TPos=",tx,ty,tz #def camera_cam_print(): def camera_pos_print_for_AbreCam(ti): cam = Bladex.GetEntity("Camera") cx,cy,cz = cam.Position tx,ty,tz = cam.TPos ##AbreCam.AddNode ((-183000,-990,768211),(-187800,1415,759778),6) print "AbreCam.AddNode ((%d, %d, %d), (%d, %d, %d), %f)" %(cx,cy,cz, tx,ty,tz, ti) #def camera_pos_print_for_AbreCam(): #import array #import struct def cam_create_file_header(camera_file_name): cam_file = open(camera_file_name, "wb") # records=int(0) # header2=int(1077936128) # 0x00004040 records=0 header2=1077936128 # 0x00004040 a = array.array("l") a.append(records) a.append(header2) #a.tofile(cam_file) format = "l" i=0 while i < len(a): data = struct.pack(format, a[i]) cam_file.write(data) i = i+1 # cam_file.close() #def cam_create_file_header(camera_file_name): # Writing integer to a file @ http://gamedev.net/topic/465655-write-int-to-file-in-python CAMERA_RECORD = 0 def camera_record_start(): global CAMERA_RECORD CAMERA_RECORD = 1 #print "CAMERA_RECORD=", CAMERA_RECORD #def camera_record_start(): def camera_record_stop(): global CAMERA_RECORD CAMERA_RECORD = 0 #print "CAMERA_RECORD=", CAMERA_RECORD #def camera_record_stop(): def camera_record(record_time_interval): global CAMERA_RECORD #print "CAMERA_RECORD=", CAMERA_RECORD if CAMERA_RECORD == 0: return ##camera_pos_print() camera_pos_print_for_AbreCam(record_time_interval) Bladex.AddScheduledFunc(Bladex.GetTime()+record_time_interval, camera_record, (record_time_interval,)) #def camera_record(time_interval):
it works, just checked it
to start you have to camera_record_start() and then camera_record() and when want to stop: camera_record_stop()
You are on your own with hex editing.
I can write it in binary form analogically to cam_create_file_header(camera_file_name) and then edit if necessary with dd even :twisted:
l'aria fresca,
vino puro, ...

User avatar
cieply
Dragon
Posts: 327
Joined: Wed Jun 26, 2013 3:43 pm

Postby cieply » Sun Oct 05, 2014 11:35 am

btw. .cam file would be better because with AbreCam method camera stops at every node, is not smooth and this is another concern

and don't worry about hex editing, I'm good with it - it's even more funny
l'aria fresca,
vino puro, ...

User avatar
cieply
Dragon
Posts: 327
Joined: Wed Jun 26, 2013 3:43 pm

keyboard bindings don't work

Postby cieply » Wed Oct 22, 2014 8:00 pm

# I managed to do everything right (at least binary file writing works, the actual calculations of camera vectors are probably wrong althogh it's not the contetnt of my question) and enclose it in module - my module now records camera based on "Camera" Position and TPos and writes everything in binary .cam file

I also made keyboard bindings to do so but they don't work - and that's the question, what's wrong with them

Code: Select all

# Casa cam record config script # execfile("i1cam_record.cfg") import i1cam import Bladex def cam_start(): print "cam_start()" i1cam.camera_record_start("test.cam") def cam_record(): print "cam_record()" i1cam.camera_record("test.cam", 1/30.0) def cam_stop(): print "cam_stop()" i1cam.camera_record_stop("test.cam") # for some reason, following bindings don't work L( Bladex.AddInputAction("cam_start", 0) Bladex.AddBoundFunc("cam_start", cam_start) Bladex.AssocKey("cam_start", "Keyboard", "Z", 1) Bladex.AddInputAction("cam_record", 0) Bladex.AddBoundFunc("cam_record", cam_record) Bladex.AssocKey("cam_record", "Keyboard", "X", 1) Bladex.AddInputAction("cam_stop", 0) Bladex.AddBoundFunc("cam_stop", cam_stop) Bladex.AssocKey("cam_stop", "Keyboard", "C", 1) # Maps/Casa: # start gladiator in Casa map and put dwarf in following place, then start to record and move dwarf the route you want to record char.Position=(-2661.19916686, -207.042995066, -2728.79453727) char.Orientation=(0.540267944336, 0.540267944336, -0.45619136095, 0.45619136095) Bladex.DeleteEntity("NoName11") # remove obstacle stone in Gladiator mod
l'aria fresca,
vino puro, ...


Return to “Severance BoD: Modding Community”

Who is online

Users browsing this forum: No registered users and 1 guest